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


PHP xml::query方法代码示例

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


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

示例1: parse

 static function parse($node, $allow = null, $deny = null)
 {
     $find = array();
     $replace = array();
     foreach (self::$find as $n => $rule) {
         list($code, $expression) = $rule;
         $allowed = !$allow || $allow && in_array($code, $allow);
         $denied = $deny && in_array($code, $deny);
         if ($allowed && !$denied) {
             $find[] = $expression;
             $replace[] = self::$replace[$n];
         }
     }
     $xml = new xml();
     foreach ($node->children() as $child) {
         $xml->append($xml->import($child));
     }
     foreach ($xml->query('//text()') as $text) {
         $parent = $text->parent();
         $bbcode = preg_replace($find, $replace, $text->value());
         $bbcode = xml::parse("<?xml version=\"1.0\" encoding=\"utf-8\" ?><bbcode>{$bbcode}</bbcode>");
         foreach ($bbcode->query('/bbcode/* | /bbcode/text()') as $child) {
             $parent->insert($xml->import($child), $text);
         }
         $parent->remove($text);
     }
     return $xml;
 }
开发者ID:nyan-cat,项目名称:easyweb,代码行数:28,代码来源:bbcode.php

示例2: getSiteInfo

 function getSiteInfo()
 {
     $xml = new xml();
     $xml->dd()->appendChild($xml->importNode($this->de()));
     $ns = $xml->query('/site/mysql | /site/users');
     foreach ($ns as $n) {
         $n->parentNode->removeChild($n);
     }
     return $xml;
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:10,代码来源:site.php

示例3: install

 function install()
 {
     $xml_data = new xml(PATH_MODULE . $this->getName() . '/data.xml');
     $xml_sec = $this->getSection()->getXML();
     $ar = array('form_edit', 'form_add', 'banner_list');
     foreach ($ar as $id) {
         if (($e = $xml_data->query('//*[@id="' . $id . '"]')->item(0)) && !$xml_sec->evaluate('count(./*[@id="' . $id . '"])', $this->getRootElement())) {
             $xml_sec->elementIncludeTo($e, $this->getRootElement());
         }
     }
     $xml_sec->save();
     return true;
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:13,代码来源:apBanners.php

示例4:

 function __construct(xml $xml, $tagName = null)
 {
     global $_struct;
     if (!$tagName) {
         $tagName = 'modules';
     }
     if ($modules = $xml->query($query = '/*/' . $tagName)->item(0)) {
     } else {
         $modules = $xml->de()->appendChild($xml->createElement($tagName));
     }
     parent::__construct($modules, 'module');
     $this->keyAttribute = 'id';
     $this->setStructure($_struct);
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:14,代码来源:modules.php

示例5: getSentData

 function getSentData($form)
 {
     global $_site;
     $xml = new xml($form);
     $mysql = new mysql();
     $res = $xml->query('.//field', $form);
     $arRes = array('xml' => null, 'mysql' => null);
     $arRes['xml'] = new xml(null, 'email', null);
     $arRes['xml']->de()->setAttribute('domain', $_site->getDomain());
     $arRes['xml']->de()->setAttribute('hash', md5($mysql->getNextId($mysql->getTableName($form->getAttribute('dbTable')))));
     foreach ($res as $field) {
         $f = array('name' => $field->getAttribute('name'), 'label' => $field->getAttribute('label'));
         $val = param($field->getAttribute('name'));
         switch ($field->getAttribute('type')) {
             case 'file':
                 if (!($attach = $arRes['xml']->query('./attach', $arRes['xml']->de())->item(0))) {
                     $attach = $arRes['xml']->de()->appendChild($arRes['xml']->createElement('attach'));
                 }
                 $files = $_FILES[$field->getAttribute('name')];
                 switch (is_array($files['error'])) {
                     case true:
                         foreach ($files['error'] as $i => $code) {
                             if ($code == 0) {
                                 $attach->appendChild($arRes['xml']->createElement('item', array('name' => $files['name'][$i], 'path' => $files['tmp_name'][$i], 'size' => $files['size'][$i])));
                             }
                         }
                         break;
                     case false:
                         if ($files['error'] == 0) {
                             $attach->appendChild($arRes['xml']->createElement('item', array('name' => $files['name'], 'path' => $files['tmp_name'], 'size' => $files['size'])));
                         }
                         break;
                 }
                 break;
             case 'password':
                 $f['value'] = md5($val);
                 break;
             case 'checkbox':
                 $f['value'] = isset($_REQUEST[$field->getAttribute('name')]) ? "1" : "0";
                 break;
             case 'textarea':
                 $f['value'] = nl2br(strip_tags($val));
                 break;
             default:
                 $f['value'] = strip_tags($val);
         }
         if ($field->hasAttribute('mail')) {
             $arRes['xml']->de()->appendChild($arRes['xml']->createElement('field', array('name' => $field->getAttribute('name'), 'label' => $f['label']), $field->getAttribute('type') == 'password' ? $val : $f['value']));
         }
         if ($field->hasAttribute('uri')) {
             $arRes['mysql'][$field->getAttribute('name')] = $f['value'];
         }
     }
     if (!$arRes['xml']->query('//@label')->item(0) instanceof DOMAttr) {
         unset($arRes['xml']);
     }
     if (!$form->getAttribute('dbSave')) {
         unset($arRes['mysql']);
     }
     return $arRes;
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:61,代码来源:feedback.php

示例6: getList

 function getList($param = false)
 {
     $xml = new xml(PATH_MODULE . $this->getName() . '/data.xml');
     if ($e = $xml->query('/data/rowlist')->item(0)) {
         $modules = $this->getModuleList();
         $modules_this_section = $this->getModules();
         $rl = new rowlist($e, $modules_this_section->getNum(), param('page'));
         if (!$param) {
             $modules_sec = array();
             foreach ($modules_this_section as $m) {
                 $modules_sec[$m->getId()] = array('idmodule' => $m->getId(), 'title' => $m->getTitle(), 'name' => $m->getName(), 'active' => $m->getRootElement()->hasAttribute('readonly'));
             }
             $modules_new = array();
             foreach ($modules_sec as $key => $m) {
                 if (isset($modules[$m['name']])) {
                     $modules_new[$key] = $modules_sec[$key];
                     $modules_new[$key]['name'] = $modules[$m["name"]]['name'];
                     $modules_new[$key]['version'] = $modules[$m["name"]]['version'];
                     $modules_new[$key]['description'] = $modules[$m["name"]]['description'];
                     $modules_new[$key]['data'] = $modules[$m["name"]]['data'];
                 } else {
                     //модуль в разделе есть а в папке с модулями его нет, непонятно !(
                     $modules_new[$key] = $m;
                 }
             }
             $modules = $modules_new;
         }
         if (count($modules)) {
             foreach ($modules as $i => $module) {
                 if ($i >= $rl->getStartIndex() && $i <= $rl->getFinishIndex()) {
                     $rl->addRow($i, $module);
                 }
             }
         }
         return $rl->getRootElement();
     }
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:37,代码来源:apModuleManager.php

示例7: getButtons

 function getButtons()
 {
     $xml = new xml($this->e);
     if ($e = $xml->query('buttons', $this->e)->item(0)) {
     } else {
         $e = $this->e->appendChild($xml->createElement('buttons'));
     }
     if ($e) {
         return new taglist($e, 'b');
     }
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:11,代码来源:rowlist.php

示例8: seclist

 static function seclist($e, $ff, $arExclude = null)
 {
     //список разделов для селекта
     $xml = new xml($e);
     $shift = str_repeat('- ', $xml->evaluate('count(ancestor-or-self::sec)', $e));
     $res = $xml->query('sec', $e);
     foreach ($res as $sec) {
         if (!($arExclude && in_array($sec->getAttribute('id'), $arExclude))) {
             $ff->addOption($sec->getAttribute('id'), $shift . $sec->getAttribute('title'));
             apSectionEdit::seclist($sec, $ff, $arExclude);
         }
     }
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:13,代码来源:apSectionEdit.php

示例9: install

 function install()
 {
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/classes/feedback.php')) {
         copy($_SERVER['DOCUMENT_ROOT'] . '/ap/modules/' . get_class($this) . '/client/feedback.php', $_SERVER['DOCUMENT_ROOT'] . '/classes/feedback.php');
     }
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback.xsl')) {
         copy($_SERVER['DOCUMENT_ROOT'] . '/ap/modules/' . get_class($this) . '/client/email_feedback.xsl', $_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback.xsl');
     }
     if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback_user.xsl')) {
         copy($_SERVER['DOCUMENT_ROOT'] . '/ap/modules/' . get_class($this) . '/client/email_feedback_user.xsl', $_SERVER['DOCUMENT_ROOT'] . '/xml/templates/email_feedback_user.xsl');
     }
     $xml_data = new xml(PATH_MODULE . get_class($this) . '/data.xml');
     $this->xml = $this->getSection()->getXML();
     $ar = array('feedback_addForm', 'feedback_editForm', 'feedback_list_fields');
     foreach ($ar as $id) {
         $e = $xml_data->query('//*[@id="' . $id . '"]')->item(0);
         if ($e && !$this->xml->evaluate('count(./*[@id="' . $id . '"])', $this->getRootElement())) {
             $this->xml->elementIncludeTo($e, $this->getRootElement());
         }
     }
     $this->xml->save();
     if ($sec = ap::getClientSection($this->getSection()->getId())) {
         $modules = $sec->getModules();
         if (!$modules->getById($this->getId())) {
             $modules->add('feedback', $this->getTitle(), $this->getId());
             $e = $xml_data->query('//*[@id="feedback_form"]')->item(0);
             $m = $modules->getXML();
             if ($e && !$this->xml->evaluate('count(./*[@id="feedback_form"])', $this->getRootElement())) {
                 $m->elementIncludeTo($e, $m->getElementById('feedback', 'name'));
             }
             $m->save();
         }
         return true;
     }
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:35,代码来源:apFeedback.php

示例10: query

 function query($query)
 {
     $xml = new xml($this->e);
     return $xml->query($query, $this->e);
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:5,代码来源:module.php

示例11: getChildren

 function getChildren()
 {
     $ar = array();
     $xml = new xml($this->getElement());
     $res = $xml->query('sec', $this->getElement());
     foreach ($res as $e) {
         $ar[] = new section($e, $this->xmlPath, $this->getTemplatePath());
     }
     return count($ar) ? $ar : null;
 }
开发者ID:PapaKot,项目名称:Horowitz,代码行数:10,代码来源:section.php


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