当前位置: 首页>>代码示例>>PHP>>正文


PHP xml::xml_to_DOM_node方法代码示例

本文整理汇总了PHP中xml::xml_to_DOM_node方法的典型用法代码示例。如果您正苦于以下问题:PHP xml::xml_to_DOM_node方法的具体用法?PHP xml::xml_to_DOM_node怎么用?PHP xml::xml_to_DOM_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xml的用法示例。


在下文中一共展示了xml::xml_to_DOM_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

 public function before()
 {
     // Get all categories
     $this->xml_content_categories = $this->xml_content->appendChild($this->dom->createElement('categories'));
     xml::to_XML(Galleries::get_categories_for_xml(), $this->xml_content_categories, 'category');
     // Get all galleries
     $this->xml_content_galleries = $this->xml_content->appendChild($this->dom->createElement('galleries'));
     xml::to_XML(Galleries::get_for_xml(), $this->xml_content_galleries, 'gallery');
     // We need to put some HTML in from our transformator
     // The reason for all this mess is that we must inject this directly in to the DOM, or else the <> will get destroyed
     $XPath = new DOMXpath($this->dom);
     foreach ($XPath->query('/root/content/galleries/gallery/description') as $raw_content_node) {
         $html_content = call_user_func(Kohana::$config->load('content.content_transformator'), $raw_content_node->nodeValue);
         $html_node = $raw_content_node->parentNode->appendChild($this->dom->createElement('description_html'));
         xml::xml_to_DOM_node($html_content, $html_node);
     }
 }
开发者ID:rockymontana,项目名称:Pajas-Gallery,代码行数:17,代码来源:generic.php

示例2: action_index

 public function action_index()
 {
     $URI = $this->request->uri();
     // Empty string defaults to 'welcome'
     if ($URI == '' || $URI == '/') {
         $URI = 'welcome';
     }
     // Set the name of the template to use
     $this->xslt_stylesheet = 'generic';
     // Initiate the page model
     $content_page = new Content_Page(Content_Page::get_page_id_by_uri($URI));
     // Create the DOM node <page>
     $this->xml_content_page = $this->xml_content->appendChild($this->dom->createElement('page'));
     // And load the page data into it
     $page_data = $content_page->get_page_data();
     foreach ($page_data['tag_ids'] as $template_field_id => $tag_ids) {
         // Get contents
         $contents = array();
         foreach ($tag_ids as $tag_id) {
             foreach (Content_Content::get_contents_by_tag_id($tag_id) as $content) {
                 if (!isset($contents[$content['id'] . 'content'])) {
                     $contents[$content['id'] . 'content'] = array('@id' => $content['id'], 'raw' => $content['content'], 'tags' => array());
                     $counter = 0;
                     foreach ($content['tags'] as $tag_name => $tag_values) {
                         foreach ($tag_values as $tag_value) {
                             $counter++;
                             $contents[$content['id'] . 'content']['tags'][$counter . 'tag']['@name'] = $tag_name;
                             if ($tag_value) {
                                 $contents[$content['id'] . 'content']['tags'][$counter . 'tag']['$value'] = $tag_value;
                             }
                         }
                     }
                 }
             }
         }
         // Get images
         $images = array();
         $image_tags = array();
         foreach ($tag_ids as $tag_id) {
             $image_tags[Tags::get_name_by_id($tag_id)] = TRUE;
         }
         $larger_counter = 0;
         foreach (Content_Image::get_images(NULL, $image_tags) as $image_name => $image_tags) {
             $image = array('@name' => $image_name, 'tags' => array());
             $counter = 0;
             foreach ($image_tags as $tag_name => $tag_values) {
                 if (count($tag_values)) {
                     foreach ($tag_values as $tag_value) {
                         $image['tags'][$counter . 'tag'] = array('@name' => $tag_name, '$value' => $tag_value);
                         $counter++;
                     }
                 } else {
                     $image['tags'][$counter . 'tag'] = array('@name' => $tag_name);
                     $counter++;
                 }
             }
             $images[$larger_counter . 'image'] = $image;
             $larger_counter++;
         }
         // Put it all in the $page_data for transport to the XML
         $page_data[$template_field_id . 'template_field'] = array('@id' => $template_field_id, 'contents' => $contents, 'images' => $images);
     }
     unset($page_data['tag_ids']);
     xml::to_XML($page_data, $this->xml_content_page, NULL, array('id', 'template_field_id'));
     // We need to put some HTML in from our transformator
     // The reason for all this mess is that we must inject this directly in to the DOM, or else the <> will get destroyed
     $XPath = new DOMXpath($this->dom);
     foreach ($XPath->query('/root/content/page/template_field/contents/content/raw') as $raw_content_node) {
         $html_content = call_user_func(Kohana::$config->load('content.content_transformator'), $raw_content_node->nodeValue);
         $html_node = $raw_content_node->parentNode->appendChild($this->dom->createElement('html'));
         xml::xml_to_DOM_node($html_content, $html_node);
     }
 }
开发者ID:rockymontana,项目名称:kohana-module-pajas,代码行数:73,代码来源:generic.php


注:本文中的xml::xml_to_DOM_node方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。