Beispiel #1
0
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * 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);
 }
Beispiel #4
0
 /**
  * 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);
 }
Beispiel #5
0
 public static function clearContentCache()
 {
     self::$nsContentCache = array();
 }