)', $pdelim = ',') { $this->actions = $allowedActions; $this->handler =& $handler; $this->delim = $delim; $this->pdelim = $pdelim; $this->norestrictions = 0; // set this to 1 to disable checking for allowedActions } /** * Parses the given contents and outputs it */ function parse(&$contents) { $pieces = preg_split('/'.$this->delim.'/',$contents); $maxidx = sizeof($pieces); for ($idx = 0; $idx < $maxidx; $idx++) { echo $pieces[$idx]; $idx++; if ($idx < $maxidx) { $this->doAction($pieces[$idx]); } } } /** * handle an action */ function doAction($action) { global $manager; if (!$action) return; // split into action name + arguments if (strstr($action,'(')) { $paramStartPos = strpos($action, '('); $params = substr($action, $paramStartPos + 1, strlen($action) - $paramStartPos - 2); $action = substr($action, 0, $paramStartPos); $params = explode ($this->pdelim, $params); // trim parameters // for PHP versions lower than 4.0.6: // - add // before '$params = ...' // - remove // before 'foreach' $params = array_map('trim',$params); // foreach ($params as $key => $value) { $params[$key] = trim($value); } } else { // no parameters $params = array(); } $actionlc = strtolower($action); // skip execution of skinvars while inside an if condition which hides this part of the page if (!$this->handler->if_currentlevel && ($actionlc != 'else') && ($actionlc != 'elseif') && ($actionlc != 'endif') && ($actionlc != 'ifnot') && ($actionlc != 'elseifnot') && (substr($actionlc,0,2) != 'if')) return; if (in_array($actionlc, $this->actions) || $this->norestrictions ) { // when using PHP versions lower than 4.0.5, uncomment the line before // and comment the call_user_func_array call //$this->call_using_array($action, $this->handler, $params); call_user_func_array(array(&$this->handler,'parse_' . $actionlc), $params); } else { // redirect to plugin action if possible if (in_array('plugin', $this->actions) && $manager->pluginInstalled('NP_'.$action)) $this->doAction('plugin('.$action.$this->pdelim.implode($this->pdelim,$params).')'); else echo '<%' , $action , '(', implode($this->pdelim, $params), ')%>'; } } /** * Calls a method using an array of parameters (for use with PHP versions lower than 4.0.5) * ( = call_user_func_array() function ) */ function call_using_array($methodname, &$handler, $paramarray) { $methodname = 'parse_' . $methodname; if (!method_exists($handler, $methodname)) { return; } $command = 'call_user_func(array(&$handler,$methodname)'; for ($i = 0; $isetParserProperty($property, $value); } function getProperty($name) { global $manager; return $manager->getParserProperty($name); } } ?>