/** set wiki variable specified by first argument to result of function call specified in rest of the arguments */ function wiki_fn_call($args, $renderer_state) { $name = array_shift($args); $call_func = array_shift($args); $call_args = $args; $value = call_wiki_function($call_func, $call_args, $renderer_state); $renderer_state->wiki_variables->set($name, $value); return ''; }
/** @private callback for preg_replace_callback in process_includes() */ function process_includes_cb($matches) { debug('MW_Page.process_includes_cb(matches=' . join(', ', $matches) . ')'); $inc_command = $matches[1]; if ($inc_command[0] == '$') { # {{$var}} -> {{&echo|$var}} $inc_command = '&echo|' . $inc_command; } elseif ($inc_command[0] != '&') { # {{page}} -> {{&include|page}} $inc_command = '&include|' . $inc_command; } elseif (strpos($inc_command, '|') === false) { # backwards compatible {{&func arg}} -> {{&func|arg}} $inc_command = preg_replace('/\\s+/s', '|', $inc_command, 1); } $inc_command = substr($inc_command, 1); $wiki_func_args = explode('|', $inc_command); $wiki_func = array_shift($wiki_func_args); $wiki_func_args = preg_replace('/\\$(\\S+)/es', '$this->wiki_variables->get("$1")', $wiki_func_args); $wiki_func_ret = call_wiki_function($wiki_func, $wiki_func_args, $this); if ($wiki_func_ret !== null) { return $wiki_func_ret; } return $matches[1]; }