/** * Forms get parsedincluded now, using an extra <formdata> skinvar */ function doForm($filename) { global $DIR_NUCLEUS; array_push($this->parser->actions, 'formdata', 'text', 'callback', 'errordiv', 'ticket'); $oldIncludeMode = PARSER::getProperty('IncludeMode'); $oldIncludePrefix = PARSER::getProperty('IncludePrefix'); PARSER::setProperty('IncludeMode', 'normal'); PARSER::setProperty('IncludePrefix', ''); $this->parse_parsedinclude($DIR_NUCLEUS . 'forms/' . $filename . '.template'); PARSER::setProperty('IncludeMode', $oldIncludeMode); PARSER::setProperty('IncludePrefix', $oldIncludePrefix); array_pop($this->parser->actions); // errordiv array_pop($this->parser->actions); // callback array_pop($this->parser->actions); // text array_pop($this->parser->actions); // formdata array_pop($this->parser->actions); // ticket }
/** * Sets a property for the parser */ function parse_set($property, $value) { PARSER::setProperty($property, $value); }
function event_InitSkinParse($data) { global $blogid, $CONF, $manager; $feedurl = array('rss1.xml', 'index.rdf', 'rss2.xml', 'atom.xml'); $reqPaths = explode('/', serverVar('PATH_INFO')); $reqPath = end($reqPaths); $feeds = in_array($reqPath, $feedurl, true); if (!$feeds) { return; } else { $p_info = trim(serverVar('PATH_INFO'), '/'); $path_arr = explode('/', $p_info); switch (end($path_arr)) { case 'rss1.xml': case 'index.rdf': $skinName = 'feeds/rss10'; break; case 'rss2.xml': $skinName = 'feeds/rss20'; break; case 'atom.xml': $skinName = 'feeds/atom'; break; } if (SKIN::exists($skinName)) { $skin =& SKIN::createFromName($skinName); $data['skin']->SKIN($skin->getID()); $skinData =& $data['skin']; $pageType = $data['type']; if (!$CONF['DisableSite']) { ob_start(); $skinID = $skinData->id; $contents = $this->getSkinContent($pageType, $skinID); $actions = SKIN::getAllowedActionsForType($pageType); $dataArray = array('skin' => &$skinData, 'type' => $pageType, 'contents' => &$contents); $manager->notify('PreSkinParse', $dataArray); PARSER::setProperty('IncludeMode', SKIN::getIncludeMode()); PARSER::setProperty('IncludePrefix', SKIN::getIncludePrefix()); $handler = new ACTIONS($pageType, $skinData); $parser = new PARSER($actions, $handler); $handler->setParser($parser); $handler->setSkin($skinData); $parser->parse($contents); $dataArray = array('skin' => &$skinData, 'type' => $pageType); $manager->notify('PostSkinParse', $dataArray); $feed = ob_get_contents(); ob_end_clean(); $eTag = '"' . md5($feed) . '"'; header('Etag: ' . $eTag); if ($eTag == serverVar('HTTP_IF_NONE_MATCH')) { header('HTTP/1.0 304 Not Modified'); header('Content-Length: 0'); } else { if (extension_loaded('mbstring')) { $feed = mb_convert_encoding($feed, 'UTF-8', _CHARSET); $charset = 'UTF-8'; } else { $charset = _CHARSET; } header('Content-Type: application/xml; charset=' . $charset); header('Generator: Nucleus CMS ' . $nucleus['version']); // dump feed echo $feed; } } else { echo '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . '>'; ?> <rss version="2.0"> <channel> <title><?php echo $this->hsc($CONF['SiteName'], ENT_QUOTES); ?> </title> <link><?php echo $this->hsc($CONF['IndexURL'], ENT_QUOTES); ?> </link> <description></description> <docs>http://backend.userland.com/rss</docs> </channel> </rss> <?php } } exit; } }
function parse($type) { global $manager, $CONF, $skinid; $manager->notify('InitSkinParse', array('skin' => &$this, 'type' => $type)); $skinid = $this->id; // set output type sendContentType($this->getContentType(), 'skin', _CHARSET); // set skin name as global var (so plugins can access it) global $currentSkinName; $currentSkinName = $this->getName(); $contents = $this->getContent($type); if (!$contents) { // use base skin if this skin does not have contents $defskin =& new SKIN($CONF['BaseSkin']); $contents = $defskin->getContent($type); if (!$contents) { echo _ERROR_SKIN; return; } } $actions = $this->getAllowedActionsForType($type); $manager->notify('PreSkinParse', array('skin' => &$this, 'type' => $type, 'contents' => &$contents)); $skinid = $this->id; // set IncludeMode properties of parser PARSER::setProperty('IncludeMode', $this->getIncludeMode()); PARSER::setProperty('IncludePrefix', $this->getIncludePrefix()); $handler =& new ACTIONS($type, $this); $parser =& new PARSER($actions, $handler); $handler->setParser($parser); $handler->setSkin($this); $parser->parse($contents); $manager->notify('PostSkinParse', array('skin' => &$this, 'type' => $type)); $skinid = $this->id; }
function parseFile($filename, $includeMode = 'normal', $includePrefix = '') { $handler = new ACTIONS('fileparser'); $parser = new PARSER(SKIN::getAllowedActionsForType('fileparser'), $handler); $handler->parser =& $parser; // set IncludeMode properties of parser PARSER::setProperty('IncludeMode', $includeMode); PARSER::setProperty('IncludePrefix', $includePrefix); if (!file_exists($filename)) { doError(_GFUNCTIONS_PARSEFILE_FILEMISSING); } $fsize = filesize($filename); if ($fsize <= 0) { return; } // read file $fd = fopen($filename, 'r'); $contents = fread($fd, $fsize); fclose($fd); // parse file contents $parser->parse($contents); }