Example #1
0
 static function manualLoad($file, &$obj, $params = [])
 {
     $apply = new self();
     $apply->setParent($obj);
     $apply->parseFile($file, $params, 'apply');
     foreach ($apply->childNodes as $i => $extender) {
         if ($extender instanceof COMMENT || $extender instanceof TEXT || $extender instanceof PHP) {
             unset($apply->childNodes[$i]);
             continue;
         }
         if (method_exists($extender, 'applyLoad')) {
             $extender->applyLoad($obj);
         } else {
             $selector = $extender->nodeName;
             foreach ($extender->attributes as $k => $v) {
                 $selector .= '[' . $k . '="' . $v . '"]';
             }
             $obj->children($selector, true)->write($extender);
         }
     }
 }
Example #2
0
 protected function readInclude($currentFilename, $currentLine, $path, $raw, $options = array())
 {
     if (!($path[0] == '/' || preg_match('/^\\w\\:\\.+$/', $path))) {
         $path = realpath(dirname($currentFilename) . '/' . $path);
         if ($path == '') {
             throw new Exception($currentFilename, $currentLine, self::ERR_INVALID_FILENAME, $path);
         }
     }
     if (file_exists($path) && !is_dir($path)) {
         if ($raw) {
             $tline = file_get_contents($path);
         } else {
             $preproc = new self();
             $preproc->_doSaveVariables = false;
             $preproc->setVars($this->_variables);
             $tline = $preproc->parseFile($path);
             $this->_variables = $preproc->_variables;
             $preproc = null;
         }
     } else {
         throw new Exception($currentFilename, $currentLine, self::ERR_INVALID_FILENAME, $path);
     }
     if (count($options)) {
         $tline = $this->applyIncludeOptions($tline, $options);
     }
     return $tline;
 }
Example #3
0
 public static function parseAll()
 {
     $class = new self();
     foreach (get_included_files() as $file) {
         $class->parseFile($file);
     }
 }
Example #4
0
 public static function fromFile($path)
 {
     $p = new self();
     return $p->parseFile($path);
 }