Exemplo n.º 1
0
 private static function loadNamespace($namespace)
 {
     //                              if (self::loadNamespaceFromDB( $namespace )) return;
     // try the autoload approach
     //              echo '<hr>'; print_r(One_Script_Factory::getSearchPath());die;
     $ns = new One_Script();
     $ns->load('ini:' . $namespace . '.n.html');
     if (!$ns->isError()) {
         self::$nsContentCache[$namespace] = array();
         // process nodes and place them in the cache
         $root = $ns->rootNode;
         foreach ($root->chain as $node) {
             if ($node instanceof One_Script_Node_Section) {
                 self::$nsContentCache[$namespace][$node->sectionName] = $node;
             }
         }
     } else {
         echo $ns->error;
     }
     if (One_Script_Config::$ncEnabled) {
         //                      echo 'loading';
         $store = self::getStore();
         if ($store) {
             $store->loadNamespace($namespace);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Render the output of the widget and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $dom)
 {
     $src = $this->getCfg('src');
     if (trim($src) == '') {
         throw new One_Exception("A field of type 'nscript' should have a 'src'-attribute defining the nanoScript file to parse.");
     }
     One_Script_Factory::saveSearchPath();
     One_Script_Factory::clearSearchPath();
     $useLang = $this->getCfg('language');
     if ('' == trim($useLang)) {
         $useLang = strtolower(One_Config::get('app.language'));
     }
     die('deprecated stuff found in ' . __FILE__ . ':' . __LINE);
     $cps = One_Config::getInstance()->getCustomPaths();
     foreach ($cps as $cp) {
         One_Script_Factory::addSearchPath($cp . '/views/' . One_Config::get('app.name') . '/' . $model->getScheme()->getName() . '/language/' . $useLang . '/');
     }
     foreach ($cps as $cp) {
         One_Script_Factory::addSearchPath($cp . '/views/' . One_Config::get('app.name') . '/' . $model->getScheme()->getName() . '/');
     }
     $ns = new One_Script();
     $ns->load($src);
     if (!$ns->isError()) {
         if ($this->getID()) {
             $ns->set('id', $this->getID());
         }
         if ($this->getName()) {
             $ns->set('name', $this->getName());
         }
         if ($this->getLabel()) {
             $ns->set('label', $this->getLabel());
         }
         if ($this->getValue($model)) {
             $ns->set('value', $this->getValue($model));
         }
         $ns->set('model', $model);
         $dom->add($ns->execute());
     } else {
         throw new One_Exception($ns->error);
     }
     $dom->add($this->value);
     One_Script_Factory::restoreSearchPath();
 }
Exemplo n.º 3
0
 public function parseModelScript(One_Model $model, $script)
 {
     $ns = new One_Script();
     $output = $ns->executeString($script, array('model' => $model));
     if ($ns->isError()) {
         $output = $ns->error;
     }
     return $output;
 }