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


PHP Tree::load方法代码示例

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


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

示例1: buildFromString

 /**
  * get html dom from string
  * @param $str
  * @param bool $lowercase
  * @param bool $forceTagsClosed
  * @param $target_charset
  * @param bool $stripRN
  * @param $defaultBRText
  * @param $defaultSpanText
  * @return bool|Tree
  */
 static function buildFromString($str, $lowercase = true, $forceTagsClosed = true, $target_charset = self::DEFAULT_TARGET_CHARSET, $stripRN = true, $defaultBRText = self::DEFAULT_BR_TEXT, $defaultSpanText = self::DEFAULT_SPAN_TEXT)
 {
     $dom = new Tree(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
     if (empty($str) or strlen($str) > self::MAX_FILE_SIZE) {
         $dom->clear();
         return false;
     }
     $dom->load($str, $lowercase, $stripRN);
     return $dom;
 }
开发者ID:jasonshaw,项目名称:framework-1,代码行数:21,代码来源:Tree.php

示例2: foreach

            echo '<ul>';
            foreach ($tree as $node) {
                $selected = !empty($node['state']['selected']) ? 'checked' : '';
                echo "<li><input type=\"checkbox\" {$selected}>" . $node['name'];
                if (!empty($node['children'])) {
                    $this->printSelectTree($node['children']);
                }
                echo '</li>';
            }
            echo '</ul>';
        }
    }
}
//demo
//所有数据
$data = [['id' => 1, 'pid' => 0, 'name' => 'a'], ['id' => 2, 'pid' => 0, 'name' => 'b'], ['id' => 3, 'pid' => 0, 'name' => 'c'], ['id' => 4, 'pid' => 2, 'name' => 'd'], ['id' => 5, 'pid' => 1, 'name' => 'e'], ['id' => 6, 'pid' => 5, 'name' => 'f'], ['id' => 7, 'pid' => 5, 'name' => 'g'], ['id' => 8, 'pid' => 5, 'name' => 'h'], ['id' => 9, 'pid' => 4, 'name' => 'i'], ['id' => 10, 'pid' => 9, 'name' => 'j'], ['id' => 11, 'pid' => 0, 'name' => 'k']];
//有权限查看的数据
$allowed_data = [['id' => 1, 'pid' => 0, 'name' => 'a'], ['id' => 2, 'pid' => 0, 'name' => 'b'], ['id' => 10, 'pid' => 9, 'name' => 'j']];
//选中的数据
$selected_keys = [1, 2, 9];
$tree = new Tree();
$tree->load($data, $allowed_data, $selected_keys);
echo "<style>li{list-style-type:none;}</style>";
echo "完整树:<br/>";
$tree->printTree($tree->buildTree());
echo "------------------------------------------------------<br/>";
echo "有权限的树:<br/>";
$tree->printAllowedTree($tree->buildTree());
echo "------------------------------------------------------<br/>";
echo "有选择功能的树:<br/>";
$tree->printSelectTree($tree->buildTree());
开发者ID:Suninus,项目名称:BeautifulPHP,代码行数:31,代码来源:Tree.php

示例3: loadChildren

 /**
  * Load node children
  *
  * @param   int  $recursionLevel
  * @return  Node
  */
 public function loadChildren($recursionLevel = 0)
 {
     $this->_tree->load($this, $recursionLevel);
     return $this;
 }
开发者ID:schpill,项目名称:standalone,代码行数:11,代码来源:Node.php


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