1*1c9ef013SAndreas Gohr<?php 2*1c9ef013SAndreas Gohr/** 3*1c9ef013SAndreas Gohr * DokuWiki Plugin struct (Action Component) 4*1c9ef013SAndreas Gohr * 5*1c9ef013SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6*1c9ef013SAndreas Gohr * @author Andreas Gohr, Michael Große <dokuwiki@cosmocode.de> 7*1c9ef013SAndreas Gohr */ 8*1c9ef013SAndreas Gohr 9*1c9ef013SAndreas Gohr// must be run within Dokuwiki 10*1c9ef013SAndreas Gohruse dokuwiki\plugin\struct\meta\Title; 11*1c9ef013SAndreas Gohr 12*1c9ef013SAndreas Gohrif(!defined('DOKU_INC')) die(); 13*1c9ef013SAndreas Gohr 14*1c9ef013SAndreas Gohr/** 15*1c9ef013SAndreas Gohr * Class action_plugin_struct_title 16*1c9ef013SAndreas Gohr * 17*1c9ef013SAndreas Gohr * Saves the page title when meta data is saved 18*1c9ef013SAndreas Gohr */ 19*1c9ef013SAndreas Gohrclass action_plugin_struct_title extends DokuWiki_Action_Plugin { 20*1c9ef013SAndreas Gohr 21*1c9ef013SAndreas Gohr /** 22*1c9ef013SAndreas Gohr * Registers a callback function for a given event 23*1c9ef013SAndreas Gohr * 24*1c9ef013SAndreas Gohr * @param Doku_Event_Handler $controller DokuWiki's event controller object 25*1c9ef013SAndreas Gohr * @return void 26*1c9ef013SAndreas Gohr */ 27*1c9ef013SAndreas Gohr public function register(Doku_Event_Handler $controller) { 28*1c9ef013SAndreas Gohr $controller->register_hook('PARSER_METADATA_RENDER', 'AFTER', $this, 'handle_meta'); 29*1c9ef013SAndreas Gohr } 30*1c9ef013SAndreas Gohr 31*1c9ef013SAndreas Gohr /** 32*1c9ef013SAndreas Gohr * Store the page's title 33*1c9ef013SAndreas Gohr * 34*1c9ef013SAndreas Gohr * @param Doku_Event $event 35*1c9ef013SAndreas Gohr * @param $param 36*1c9ef013SAndreas Gohr */ 37*1c9ef013SAndreas Gohr public function handle_meta(Doku_Event $event, $param) { 38*1c9ef013SAndreas Gohr $id = $event->data['current']['last_change']['id']; 39*1c9ef013SAndreas Gohr $title = new Title($id); 40*1c9ef013SAndreas Gohr 41*1c9ef013SAndreas Gohr if(!blank($event->data['current']['title'])) { 42*1c9ef013SAndreas Gohr $title->setTitle($event->data['current']['title']); 43*1c9ef013SAndreas Gohr } else { 44*1c9ef013SAndreas Gohr $title->setTitle(null); 45*1c9ef013SAndreas Gohr } 46*1c9ef013SAndreas Gohr } 47*1c9ef013SAndreas Gohr 48*1c9ef013SAndreas Gohr} 49