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


PHP HTML_TreeMenu::createFromStructure方法代碼示例

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


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

示例1: createFromXML

 /**
  * Creates a treeMenu from XML. The structure of your XML should be
  * like so:
  *
  * <treemenu>
  *     <node text="First node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
  *     <node text="Second node" icon="folder.gif" expandedIcon="folder-expanded.gif">
  *         <node text="Sub node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
  *     </node>
  *     <node text="Third node" icon="folder.gif" expandedIcon="folder-expanded.gif">
  * </treemenu>
  *
  * Any of the options you can supply to the HTML_TreeNode constructor can be supplied as
  * attributes to the <node> tag. If there are no subnodes for a particular node, you can
  * use the XML shortcut <node ... /> instead of <node ... ></node>. The $xml argument can
  * be either the XML as a string, or an pre-created XML_Tree object. Also, this method
  * REQUIRES my own Tree class to work (http://phpguru.org/tree.html). If this has not
  * been include()ed or require()ed this method will die().
  *
  * @param  mixed  $xml  This can be either a string containing the XML, or an XML_Tree object
  *                      (the PEAR::XML_Tree package).
  * @return object       The HTML_TreeMenu object
  */
 function createFromXML($xml)
 {
     if (!class_exists('Tree')) {
         die('Could not find Tree class');
     }
     // Supplied $xml is a string
     if (is_string($xml)) {
         require_once 'XML/Tree.php';
         $xmlTree =& new XML_Tree();
         $xmlTree->getTreeFromString($xml);
         // Supplied $xml is an XML_Tree object
     } else {
         $xmlTree = $xml;
     }
     // Now process the XML_Tree object, setting the XML attributes
     // to be the tag data (with out the XML tag name or contents).
     $treeStructure = Tree::createFromXMLTree($xmlTree, true);
     $treeStructure->nodes->traverse(create_function('&$node', '$tagData = $node->getTag(); $node->setTag($tagData["attributes"]);'));
     return HTML_TreeMenu::createFromStructure(array('structure' => $treeStructure));
 }
開發者ID:minggLu,項目名稱:openemr,代碼行數:43,代碼來源:TreeMenu.php


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