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


PHP XmlParser::readDocumentByPath方法代码示例

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


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

示例1: parsePages

 private function parsePages()
 {
     $this->pagedir = $this->basedir . "/apps/" . $this->args['application'] . "/config/pages";
     $data = array();
     $files = scandir($this->pagedir);
     foreach ($files as $file) {
         if (strtolower(substr($file, strrpos($file, ".") + 1)) == "xml") {
             $xp = XmlParser::readDocumentByPath($this->pagedir . "/" . $file);
             $nodes = $xp->evaluate("//i:component[child::i:params]");
             if (!$nodes->length) {
                 continue;
             } else {
                 foreach ($nodes as $node) {
                     $key = $node->getAttribute("module") . "/" . $node->getAttribute("name");
                     $params = $xp->evaluate("./i:params/i:param", $node);
                     $param_arr = array();
                     foreach ($params as $k => $param) {
                         $param_arr[$param->getAttribute("name") ? $param->getAttribute("name") : "noname" . $k] = trim($param->nodeValue);
                     }
                     $data[$key]["combos"][$file] = $param_arr;
                 }
             }
         }
     }
     $this->pages = $data;
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:26,代码来源:afUpdateWidgetSelectorTask.class.php

示例2: generateWidgets

 private function generateWidgets(array $data, $model, $module)
 {
     // Replace basic tokens. for edit / show..
     if (isset($data["_attributes"])) {
         unset($data["_attributes"]);
     }
     $visible = trim(implode(",", array_keys($data)), ",");
     $tokens = array("TITLE" => "Edit / Create " . $model, "DATACLASS" => $model . "Peer", "UPDATE_URL" => $module . "/update", "LIST_URL" => $module . "/list", "DELETE_URL" => $module . "/delete", "ADD_URL" => $module . "/edit", "ADD_TITLE" => "Add new item", "VISIBLE" => $visible);
     $templates = array("list", "edit");
     foreach ($templates as $key => $template) {
         $path = $this->path . "/config/" . $template . ".xml";
         $this->getFilesystem()->replaceTokens($path, '##', '##', $tokens);
         // Add fields and columns..
         $xpath = XmlParser::readDocumentByPath($path);
         $document = $xpath->document;
         $document->formatOutput = true;
         $document->normalizeDocument();
         $ns = $document->lookupNamespaceUri("i");
         $fields = $xpath->evaluate("//i:fields")->item(0);
         foreach ($data as $column => $type) {
             $coltype = $this->getFieldType($column, $type);
             if (!$key) {
                 $elem = $document->createElementNS($ns, "column");
             } else {
                 $elem = $document->createElementNS($ns, "field");
                 $elem->setAttribute("type", $coltype->type);
                 if (property_exists($coltype, "default") && $coltype->type == "checkbox") {
                     $elem->setAttribute("checked", "true");
                 } else {
                     if (property_exists($coltype, "foreignTable")) {
                         $table = $this->schema["propel"][$coltype->foreignTable];
                         $peer = $table["_attributes"]["phpName"] . "Peer";
                         unset($table["_attributes"]);
                         $id_column = $coltype->foreignReference;
                         if (isset($table["name"])) {
                             $name_column = "name";
                         } else {
                             if (isset($table["title"])) {
                                 $name_column = "title";
                             } else {
                                 foreach ($table as $colname => $thecol) {
                                     $c = is_array($thecol) ? $thecol["type"] : $thecol;
                                     if (strstr($c, "varchar")) {
                                         $name_column = $colname;
                                         break;
                                     }
                                 }
                                 if (!$name_column) {
                                     $name_column = $id_column;
                                 }
                             }
                         }
                         $child = $document->createElementNS($ns, "value");
                         $child->setAttribute("type", "orm");
                         $vchild = $document->createElementNS($ns, "class", "afGenerator");
                         $child->appendChild($vchild);
                         $vchild = $document->createElementNS($ns, "method");
                         $vchild->setAttribute("name", "asCombo");
                         $child->appendChild($vchild);
                         $values = array(1 => array($peer, "peer"), array($name_column, "name"), array($id_column, "id"));
                         $i = 1;
                         while ($i < 4) {
                             $vchild = $document->createElementNS($ns, "param", $values[$i][0]);
                             $vchild->setAttribute("name", $values[$i][1]);
                             $child->lastChild->appendChild($vchild);
                             $i++;
                         }
                         $elem->appendChild($child);
                         $elem->setAttribute("selected", "{" . $column . "}");
                     }
                 }
                 if (!property_exists($coltype, "foreignTable")) {
                     $value = $document->createElementNS($ns, "value");
                     $value->setAttribute("type", "orm");
                     $source = $document->createElementNS($ns, "source");
                     $source->setAttribute("name", "get" . sfInflector::camelize($column));
                     $value->appendChild($source);
                     $elem->appendChild($value);
                 }
             }
             $elem->setAttribute("label", $column);
             $elem->setAttribute("name", $column);
             $fields->appendChild($elem);
         }
         $document->save($path);
     }
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:87,代码来源:afWidgetBuilderTask.class.php

示例3: executeStructinfo

 public function executeStructinfo()
 {
     //Console::profile('struct start');
     // Params of call
     $expression = $this->getRequestParameter("node", null);
     $type = $this->getRequestParameter("type", "edit");
     $lang = $this->getRequestParameter("lang", "en");
     $do = $this->getRequestParameter("do", "nodes");
     // Read Schema
     $root = sfConfig::get("sf_root_dir");
     $this->schema = XmlParser::readDocumentByPath($root . "/plugins/appFlowerPlugin/schema/appflower.xsd", true, array("prefix" => "xs", "uri" => "http://www.w3.org/2001/XMLSchema"));
     // Data types
     if ($do == "types") {
         $result = $this->schema->evaluate("//xs:simpleType");
         foreach ($result as $dtype) {
             $data = $this->schema->evaluate("./descendant::xs:restriction|./descendant::xs:union|./descendant::xs:documentation[@xml:lang='" . $lang . "']", $dtype);
             $type_name = $dtype->getAttribute("name");
             if (!$type_name) {
                 continue;
             }
             foreach ($data as $info) {
                 if ($info->nodeName == "xs:documentation") {
                     $this->data_types[$type_name]["docs"] = $info->nodeValue;
                     continue;
                 } else {
                     if ($info->nodeName == "xs:union") {
                         $this->data_types[$type_name]["union"] = str_replace("i:", "", $info->getAttribute("memberTypes"));
                         continue;
                     }
                 }
                 $base = $info->getAttribute("base");
                 foreach ($info->childNodes as $child) {
                     if (!$child instanceof DOMElement || $child->nodeName != "xs:enumeration" && $child->nodeName != "xs:maxInclusive" && $child->nodeName != "xs:minInclusive" && $child->nodeName != "xs:pattern") {
                         continue;
                     }
                     if ($child->nodeName == "xs:maxInclusive" || $child->nodeName == "xs:minInclusive") {
                         $this->data_types[$type_name]["type"] = "range";
                         $this->data_types[$type_name]["base"] = str_replace("xs:", "", $base);
                     } else {
                         if ($child->nodeName == "xs:enumeration") {
                             $this->data_types[$type_name]["type"] = "enum";
                         } else {
                             $this->data_types[$type_name]["type"] = "pattern";
                             continue;
                         }
                     }
                     $this->data_types[$type_name]["values"][] = $child->getAttribute("value");
                 }
             }
         }
         $result = json_encode($this->data_types);
         return $this->renderText($result);
     }
     // Imported namespaces
     $result = $this->schema->evaluate("//xs:import");
     foreach ($result as $ns) {
         $this->imported_namespaces[$ns->getAttribute("namespace")] = $ns->getAttribute("i:name");
     }
     // Attribute and element groups
     $groups = array("element", "attribute");
     foreach ($groups as $k => $prefix) {
         $result = $this->schema->evaluate($prefix == "element" ? "//xs:group" : "//xs:attributeGroup");
         foreach ($result as $group) {
             $attrs = $this->schema->evaluate("./descendant::xs:" . $prefix, $group);
             foreach ($attrs as $attr) {
                 if (!$k) {
                     $this->element_groups[$group->getAttribute("name")][] = $attr->getAttribute("ref");
                 } else {
                     $this->attribute_groups[$group->getAttribute("name")][] = $this->getAttribute($attr);
                 }
             }
         }
     }
     if ($expression === null) {
         $result = $this->getElement("i:view", $type, $lang);
     } else {
         $result = $this->getElement($expression, $type, $lang);
     }
     $result = json_encode($result);
     //Console::profile('struct end');
     return $this->renderText($result);
 }
开发者ID:cbsistem,项目名称:appflower_engine,代码行数:82,代码来源:actions.class.php


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