2010-12-15
lartet
I was installing newpagetemplate, I'll backtrace all to explain, from the plugin class to the top class.
plugins/newpagetemplate/action.php:
function pagefromtemplate(&$event, $param) {
...
$event->result=$tpl; // $tpl contains contents of a page
$event->preventDefault();
}
inc/events.php(171)
function process_event(&$event,$advise='') {
...
$obj->$method($event, $param);
}
inc/events.php(56)
function advise_before($enablePreventDefault=true) {
...
$EVENT_HANDLER->process_event($this,'BEFORE');
return (!$enablePreventDefault || $this->_default);
}
inc/events.php(56)
function trigger($action=null, $enablePrevent=true) {
...
if ($this->advise_before($enablePrevent) && is_callable($action)) {
...
return $this->result;
}
inc/events.php(196)
function trigger_event($name, &$data, $action=null, $canPreventDefault=true) {
...
return $evt->trigger($action, $canPreventDefault);
}
inc/common.php(828)
function pageTemplate($id) {
...
$data = compact('tpl', 'id');
trigger_event('COMMON_PAGE_FROMTEMPLATE', $data, 'parsePageTemplate', true);
return $data['tpl'];
}
The problem should be here, the call of trigger_event() has no lvalue and data is not modified in the functions called after.
On my dokuwiki, I've made these changes in pageTemplate($id)
$data = compact('tpl', 'id');
$data['tpl'] = trigger_event('COMMON_PAGE_FROMTEMPLATE', $data, 'parsePageTemplate', true);
return $data['tpl'];
and it makes the plugin work.
I wonder if the change deserves to be in this function or if a sub-function should modify &$data and don't actually do this.
Thanks,
Florent.