예제 #1
0
 public static function &buildTree($source, $mode = XMLDocument::BUILD_MODE_FROM_FILE, $ns = NULL)
 {
     if ($mode == XMLDocument::BUILD_MODE_FROM_FILE) {
         if (($content = Filesystem::getFileContent($source)) === NULL) {
             return NULL;
         }
     } else {
         if ($source == "" || $source == NULL) {
             return new xmlTree();
         }
         $content = $ns == NULL ? "<ROOT>" . $source . "</ROOT>" : "<ROOT xmlns:{$ns}=\".\">" . $source . "</ROOT>";
     }
     /*$content = ereg_replace( "&amp;", "&", $content );
     		$content = ereg_replace( "&", "&amp;", $content );*/
     //echo $content;
     $content = preg_replace("/&amp;/", "&", $content);
     $content = preg_replace("/&/", "&amp;", $content);
     $content = iconv("windows-1251", "UTF-8", $content);
     $reader = new XMLReader();
     if ($reader->XML($content)) {
         $_docTree = NULL;
         $_docTree = new xmlTree();
         self::_appendChilds($_docTree->getCurrent(), $reader, 0);
         $reader = NULL;
         return $_docTree;
     } else {
         self::raiseException(ERR_XML_INVALID_XML, $content);
         return NULL;
     }
 }
예제 #2
0
 public function getTree($attr = NULL)
 {
     if (isset($this->_params)) {
         $tree = new xmlTree();
         $text = new xmlNode("#text");
         $this->_params[0]["title"] = iconv("windows-1251", "UTF-8", $this->_params[0]["title"]);
         $text->text($this->_params[0]["title"]);
         $title = new xmlNode("title");
         $title->addChild($text);
         $tree->addChild($title);
         return $tree;
     }
 }
 public function getTree($attr = NULL)
 {
     if (isset($this->_params)) {
         $tree = new xmlTree();
         $text = new xmlNode("#text");
         $text->text($this->_params[0]["dsc"]);
         $div = new xmlNode("div");
         $div->addChild($text);
         $div->setAttribute("class", "error-dsc");
         $tree->addChild($div);
         //echo $tree; die;
         return XMLDocument::buildTree("<div class=\"error-dsc\">{$this->_params[0]["dsc"]}</div>", XMLDocument::BUILD_MODE_FROM_TEXT);
         //return $tree;
     } else {
         return new xmlTree();
     }
 }
예제 #4
0
 public function getTree($attr = NULL)
 {
     if ($this->_isValid) {
         $jsPath = __ROOT_PATH . DS . "template" . DS . "default" . DS . "js" . DS;
         $scripts = Filesystem::getFilesFromDir($jsPath, "js");
         if ($attr !== NULL) {
             if (($scripts = $this->_assignAttr($attr)) !== NULL) {
                 $p = $this->_assignAttr($attr);
                 if (isset($scripts["src"])) {
                     $scripts = explode(",", ereg_replace(" ", "", $scripts["src"]));
                 }
                 if (isset($p["combat"]) && $p["combat"]) {
                     $jsPath = Config::SITE_DIR . "/" . "js" . "/";
                 }
                 for ($i = 0; $i < count($scripts); $i++) {
                     $scripts[$i] = Filesystem::absoluteUrl($jsPath . $scripts[$i]);
                 }
             }
         }
         $tree = new xmlTree();
         for ($i = 0; $i < count($scripts); $i++) {
             $url = Filesystem::absoluteUrl($scripts[$i]);
             if (!$url) {
                 return NULL;
             }
             /* else */
             $script = new xmlNode("script");
             $script->setAttribute("src", $url);
             $script->setAttribute("type", "text/javascript");
             $tree->addChild($script);
         }
         if ($main !== NULL) {
             $script = new xmlNode("script");
             $script->setAttribute("src", $main);
             $script->setAttribute("type", "text/javascript");
             $tree->addChild($script);
         }
         return $tree;
     }
 }