當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLElement::setDTD方法代碼示例

本文整理匯總了PHP中XMLElement::setDTD方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLElement::setDTD方法的具體用法?PHP XMLElement::setDTD怎麽用?PHP XMLElement::setDTD使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XMLElement的用法示例。


在下文中一共展示了XMLElement::setDTD方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: view

 function view()
 {
     // fetch all pages
     $pages = PageManager::fetch();
     // build container DIV
     $sitemap = new XMLElement('div', null, array('class' => 'sitemap'));
     // add headings
     $sitemap->appendChild(new XMLElement('h1', 'Sitemap <span>' . Symphony::Configuration()->get('sitename', 'general') . '</span>'));
     $sitemap->appendChild(new XMLElement('h2', 'Site Map, ' . date('d F Y', time())));
     // build container ULs
     $primary = new XMLElement('ul', null, array('id' => 'primaryNav'));
     $utilities = new XMLElement('ul', null, array('id' => 'utilityNav'));
     // get values from config: remove spaces, remove any trailing commas and split into an array
     $this->type_index = explode(',', trim(preg_replace('/ /', '', Symphony::Configuration()->get('index_type', 'sitemap')), ','));
     $this->type_primary = explode(',', trim(preg_replace('/ /', '', Symphony::Configuration()->get('primary_type', 'sitemap')), ','));
     $this->type_utility = explode(',', trim(preg_replace('/ /', '', Symphony::Configuration()->get('utilities_type', 'sitemap')), ','));
     $this->type_exclude = explode(',', trim(preg_replace('/ /', '', Symphony::Configuration()->get('exclude_type', 'sitemap')), ','));
     // supplement list of pages with additional meta data
     foreach ($pages as $page) {
         $page['url'] = '/' . implode('/', Administration::instance()->resolvePagePath($page['id']));
         $page['edit-url'] = Administration::instance()->getCurrentPageURL() . 'edit/' . $page['id'] . '/';
         if (count(array_intersect($page['type'], $this->type_exclude)) > 0) {
             continue;
         }
         $page['is_home'] = count(array_intersect($page['type'], $this->type_index)) ? true : false;
         $page['is_primary'] = count(array_intersect($page['type'], $this->type_primary)) > 0 ? true : false;
         $page['is_utility'] = count(array_intersect($page['type'], $this->type_utility)) > 0 ? true : false;
         $this->_pages[] = $page;
     }
     // append the Home page first
     foreach ($this->_pages as $page) {
         if ($page['is_home'] == true) {
             $this->appendPage($primary, $page, 1, true, false);
         }
     }
     // append top level pages
     $primary_pages = 0;
     foreach ($this->_pages as $page) {
         if ($page['is_primary'] == true) {
             $primary_pages++;
             $this->appendPage($primary, $page);
         }
     }
     // sitemap provides styles for up to 10 top level pages
     if ($primary_pages > 0 && $primary_pages < 11) {
         $primary->setAttribute('class', 'col' . $primary_pages);
     }
     // append utilities (global) pages
     foreach ($this->_pages as $page) {
         if ($page['is_utility'] == true) {
             $this->appendPage($utilities, $page, 1, false, false);
         }
     }
     if ($utilities->getNumberOfChildren() > 0) {
         $sitemap->appendChild($utilities);
     }
     $sitemap->appendChild($primary);
     // build a vanilla HTML document
     $html = new XMLElement('html');
     $html->setDTD('<!DOCTYPE html>');
     $head = new XMLElement('head');
     $head->appendChild(new XMLElement('meta', null, array('charset' => 'utf-8')));
     $head->appendChild(new XMLElement('title', 'Site Map — ' . Symphony::Configuration()->get('sitename', 'general')));
     $head->appendChild(new XMLElement('link', null, array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'print, screen', 'href' => URL . '/extensions/sitemap/assets/sitemap.map.css')));
     $head->appendChild(new XMLElement('link', null, array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'print, screen', 'href' => URL . '/extensions/sitemap/assets/slickmap/slickmap.css')));
     $html->appendChild($head);
     $body = new XMLElement('body');
     $body->appendChild($sitemap);
     $html->appendChild($body);
     header('content-type: text/html');
     echo $html->generate(true);
     die;
 }
開發者ID:symphonists,項目名稱:sitemap,代碼行數:73,代碼來源:content.map.php


注:本文中的XMLElement::setDTD方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。