本文整理汇总了PHP中tree::init方法的典型用法代码示例。如果您正苦于以下问题:PHP tree::init方法的具体用法?PHP tree::init怎么用?PHP tree::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::init方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActionTree
public function getActionTree()
{
$sql = "SELECT id,parent_id,action_name from {$this->_table}";
$cates = $res = $this->getList($sql);
$this->load->helper('html_tree');
$tree = new tree($cates);
$tree->icon = array(' │ ', ' ├─ ', ' └─ ');
//树形图标
$tree->nbsp = ' ';
//三个空格
$options = '';
$tree->init($cates);
return $tree->get_tree(0, "<option value='\$id'>\$spacer\$action_name</option>\n");
}
示例2: add
public function add($id = '')
{
require APPPATH . 'libraries/tree.class.php';
if ($id) {
$query = $this->db->where(array('catid' => $id))->get('category')->row_array();
}
$this->data['item'] = $query;
$categorys = $this->categorys;
$tree = new tree();
$tree->icon = array(' │ ', ' ├─ ', ' └─ ');
$tree->nbsp = ' ';
$string = '<select name="parentid">';
$string .= "<option value='0'>≡ 作为一级栏目 ≡</option>";
$str = "<option value='\$catid' \$selected>\$spacer \$catname</option>;";
$str2 = "<optgroup label='\$spacer \$catname'></optgroup>";
$tree->init($categorys);
$string .= $tree->get_tree_category(0, $str, $str2, $query['parentid']);
$string .= '</select>';
$this->data['categorys'] = $string;
$this->repair(false);
$this->load->view('category/add', $this->data);
}
示例3: select_category
/**
* 栏目选择
* @param string $file 栏目缓存文件名
* @param intval/array $catid 别选中的ID,多选是可以是数组
* @param string $str 属性
* @param string $default_option 默认选项
* @param intval $modelid 按所属模型筛选
* @param intval $type 栏目类型
* @param intval $onlysub 只可选择子栏目
* @param intval $siteid 如果设置了siteid 那么则按照siteid取
*/
public static function select_category($file = '', $catid = 0, $str = '', $default_option = '', $modelid = 0, $type = -1, $onlysub = 0, $siteid = 0, $is_push = 0)
{
require_once "Tree.class.php";
$tree = new tree();
if (!$siteid) {
$siteid = get_siteid();
}
if ($modelid) {
$result = D('Category')->where('siteid = %d and modelid = %d', $siteid, $modelid)->select();
} else {
$result = D('Category')->where('siteid = %d', $siteid)->select();
}
$string = '<select ' . $str . '>';
if ($default_option) {
$string .= "<option value='0'>{$default_option}</option>";
}
if (is_array($result)) {
foreach ($result as $r) {
if ($siteid != $r['siteid'] || $type >= 0 && $r['type'] != $type) {
continue;
}
$r['selected'] = '';
if (is_array($catid)) {
$r['selected'] = in_array($r['id'], $catid) ? 'selected' : '';
} elseif (is_numeric($catid)) {
$r['selected'] = $catid == $r['id'] ? 'selected' : '';
}
$r['html_disabled'] = "0";
if (!empty($onlysub) && $r['child'] != 0) {
$r['html_disabled'] = "1";
}
$categorys[$r['id']] = $r;
if ($modelid && $r['modelid'] != $modelid) {
unset($categorys[$r['catid']]);
}
}
}
$str = "<option value='\$id' \$selected>\$spacer \$catname</option>;";
$str2 = "<optgroup label='\$spacer \$catname'></optgroup>";
$tree->init($categorys);
$string .= $tree->get_tree_category(0, $str, $str2);
$string .= '</select>';
return $string;
}
示例4: role_perm
public function role_perm($type = 'module', $id = '')
{
$this->data['type'] = $type;
if ($id) {
$role = $this->db->where(array('roleid' => $id))->get('admin_role')->row_array();
$this->data['role'] = $role;
$role_perm = $this->data['roles'] = $this->M_user->get_admin_role_perm($id);
if ($type == 'module') {
//print_r($role_perm);
$this->data['role_perm'] = $role_perm['module'];
}
if ($type == 'category') {
require APPPATH . 'libraries/tree.class.php';
$this->load->model('M_content');
$categorys = $this->M_content->get_category();
$tree = new tree();
$tree->icon = array(' │ ', ' ├─ ', ' └─ ');
$tree->nbsp = ' ';
$str = "<tr>\n \t\t\t\t<td><label><input type='checkbox' \$checked class='ace' name='perm[]' value='\$id' /><span class='lbl'></span></label></td>\n \t\t\t\t<td>\$id</td>\n \t\t\t\t<td class='left'>\$spacer\$catname</td>\n \t\t\t</tr>";
$str2 = "<tr>\n \t\t\t\t<td><label><input type='checkbox' class='ace' name='perm[]' value='\$id' /><span class='lbl'></span></label></td>\n \t\t\t\t<td>\$id</td>\n \t\t\t\t<td class='left'>\$spacer\$catname</td>\n \t\t\t</tr>";
$tree->init($categorys);
$string = $tree->get_tree_multi(0, $str, implode(',', $role_perm['category']));
$this->data['categorys'] = $string;
}
$this->load->view('user/role_perm', $this->data);
} else {
show_error('参数异常');
}
}
示例5: getTree
public static function getTree($data, $format = "<option value='\$catid' \$selected>\$spacer\$name</option>", $id = 0, $nbsp = " ", $icon = array(" ", " ", " "))
{
Ibos::import("ext.Tree", true);
$tree = new tree();
$tree->init($data);
$tree->icon = $icon;
$tree->nbsp = $nbsp;
$trees = $tree->get_tree(0, $format, $id);
return $trees;
}