Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private function get_XML()
- {
- if($this->xml instanceOf DOMDocument)
- return $this->xml;
- $this->xml = new DOMDocument;
- $this->xml->formatOutput = true;
- $this->xml->preserveWhiteSpace = true;
- $this->xml->validateOnParse = true;
- return $this->xml;
- }
- private function get_XMLConfig()
- {
- if(NULL === $this->xml_config)
- $this->xml_config = $this->get_XML()->createElement("config:group");
- return $this->xml_config;
- }
- private function get_XMLPage()
- {
- if(NULL === $this->xml_page)
- $this->xml_page = $this->get_XML()->createElement("section:group");
- return $this->xml_page;
- }
- private function load_XMLConfig(broadcast $loadstuff, type $type)
- {
- if(empty($loadstuff))
- $configurl = self::$data_config_file;
- else
- $configurl = $loadstuff.DIRECTORY_SEPARATOR.self::$data_config_file;
- if(FALSE !== ($r = $this->findConfig($configurl)))
- return $r;
- $configdoc = NULL;
- $ispage = is_file(self::$broadcaster.$loadstuff.DIRECTORY_SEPARATOR.self::$data_page_file);
- if(is_file($_pl = self::$broadcaster.$configurl))
- {
- $configdoc = new DOMDocument;
- $configdoc->formatOutput = true;
- $configdoc->preserveWhiteSpace = true;
- if($type == 'root' || TRUE === $ispage)
- {
- $configdoc->load($_pl);
- if(($re = $configdoc->documentElement->nodeName) != 'config')
- throw New ILLI_Exception('Unknown root-element "'.$re.' in config-file "'.$configurl.'"');
- $configdoc = $configdoc->documentElement;
- }
- else $configdoc = NULL;
- }
- if($type == 'root' && NULL === $configdoc)
- throw new ILLI_Exception('Missing root-config '.self::$broadcaster.$configurl);
- if(NULL === $configdoc)
- {
- $configdoc = new DOMDocument;
- $configdoc->formatOutput = true;
- $configdoc->preserveWhiteSpace = true;
- $configdoc = $configdoc->createElement('config');
- }
- $configdoc = $this->get_XML()->importNode($configdoc, true);
- $pin = array();
- foreach(explode(DIRECTORY_SEPARATOR, $configurl) as $p)
- if(($p = preg_replace('#[^0-9]#', NULL, $p)) != '')
- $pin[] = $p;
- $configdoc->setAttribute('pin', ((($pin = implode('_', $pin)) == '') ? 0 : $pin));
- $configdoc->setAttribute('config', $this->saveChar($configurl));
- $configdoc->setAttribute("type", $type);
- $configdoc->setAttribute("ispage", ((TRUE === $ispage) ? "true" : "false"));
- if($type == 'section')
- $configdoc->setAttribute("chapters", 0);
- $this->get_XMLConfig()->appendChild($configdoc);
- if($type == 'root')
- {
- $this->parse_XMLConfigRoot();
- }
- else
- {
- $this->parse_XMLConfigSub($pin);
- }
- $this->parse_XMLConfig($configurl);
- return $configdoc;
- }
- private function isTextNode(DOMNode $c)
- {
- return ($c->nodeName == '#text');
- }
- private function saveChar(string $s)
- {
- return utf8_encode($s);
- }
- private function unsaveChar(string $s)
- {
- return utf8_decode($s);
- }
- public static function is_Type($type)
- {
- switch($type):
- case 'root':
- case 'section':
- case 'chapter':
- return true;
- endswitch;
- return false;
- }
- public static function is_broadcast($loadstuff)
- {
- if(!is_string($loadstuff))
- return FALSE;
- return (bool) is_dir(self::$broadcaster.$loadstuff);
- }
- public static function is_broadcastConfigFile($config_xml)
- {
- if(!is_string($config_xml))
- return FALSE;
- return (bool) preg_match('#'.self::$data_config_file.'#i', $config_xml);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement