/** * findSectionNode : helper function to resolve the section name into a node * @param $sec * @return unknown_type */ private function &findSectionNode($sec, &$parent) { $ns = ''; //PD09SEP09: check for a namespace in the section name, format namespace:section $parts = explode(':', $sec, 2); if (count($parts) > 1) { $ns = $parts[0]; $sec = $parts[1]; } // locate the section node using nanoContent if ($ns) { // One_Script_Factory::saveSearchPath(); // One_Script_Factory::setSearchPath( $this->searchPath ); $node = One_Script_Content_Factory::getNode($ns, $sec); // One_Script_Factory::restoreSearchPath( ); // print_r($node); // $node->dump(); return $node; } // locate the section node in the traditinal style (inside the parent) $node = $parent->findSection($sec, $parent); //PD11OCT09: if not found, try prefixing with default namespace if (One_Script_Config::$defaultNamespace) { if ($node == null) { // One_Script_Factory::saveSearchPath(); // One_Script_Factory::setSearchPath( $this->searchPath ); $node = One_Script_Content_Factory::getNode(One_Script_Config::$defaultNamespace, $sec); // One_Script_Factory::restoreSearchPath( ); } } return $node; }
function listUsedNodes() { if (isset($_SESSION['nsShowNodes'])) { ob_start(); echo '<div id="nsShowNodes">'; One_Script_Content_Factory::listUsedNodes(); echo '<div>'; $nodeInfo = ob_get_clean(); } else { $nodeInfo = ''; } return $nodeInfo; }
/** * Parse the template or if $section is set and the section exists, parse the specified section * @param string $section */ public function parse($section = NULL) { $oldSearchpath = One_Script_Factory::getSearchPath(); One_Script_Factory::clearSearchpath(); One_Script_Factory::setSearchPath($this->getSearchPath()); if ($this->useFile()) { $this->nScript->load($this->getFile()); $this->nScript->select($section); if (!$this->nScript->isError()) { $output = $this->nScript->execute($this->getData()); } } else { $this->nScript->select($section); $output = $this->nScript->executeString($this->getContent(), $this->getData()); } One_Script_Factory::clearSearchpath(); One_Script_Factory::setSearchPath($oldSearchpath); One_Script_Content_Factory::$nsContentCache = array(); if ($this->nScript->isError()) { throw new One_Exception($this->nScript->error); } return trim($output); }
/** * Parse the template or if $section is set and the section exists, parse the specified section * * @param string $section */ public function render($section = null) { $oldSearchpath = One_Script_Factory::getSearchPath(); One_Script_Factory::setSearchPath($this->getSearchPath()); if ($this->useFile()) { $this->script->load($this->getFile()); if ($section !== null) { $this->script->select($section); } if (!$this->script->isError()) { $output = $this->script->execute($this->getData()); } } else { $this->script->select($section); $output = $this->script->executeString($this->getContent(), $this->getData()); } One_Script_Factory::setSearchPath($oldSearchpath); One_Script_Content_Factory::clearContentCache(); // *** why is this here ? WTF ! if ($this->script->isError()) { throw new One_Exception_Script($this->script->error); } return trim($output); }
public static function clearContentCache() { self::$nsContentCache = array(); }