function tree_ctype($list = false, $padding = array()) { if (!$list) { return ""; } $tree = ""; $count = count($list); // var_dump($list); foreach ($list as $k => $v) { $tree .= '<li data-id="' . $v['id'] . '" data-sort="' . $v['sort_id'] . '">'; $tree .= '<span> <input class="select-it" type="checkbox" value="' . $v['id'] . '" > </span>'; $tree .= implode('', $padding); if (!isset($list[$k + 1])) { if (is_array($v['more'])) { $tree .= ' '; } else { $tree .= ' <i class="fa fa-circle-o"></i>'; } } else { if ($k == 0 and $v['fid'] == 0) { } else { if (is_array($v['more'])) { $tree .= ' '; } else { $tree .= ' <i class="fa fa-circle-o"></i>'; } } } if (intval($v['more'])) { $tree .= '<i class="fa fa-chevron-circle-right"></i>'; } else { // $tree.= '<i class="fa fa-ellipsis-h "></i>'; } $tree .= '<span> ' . $v['title'] . ' </span>'; if (ENVIRONMENT == "development") { $tree .= '<span class="label label-info"> ' . $v['id'] . '</span>'; } $tree .= '<div class="btn-group pull-right">'; $tree .= '<a class="btn btn-small" href="' . site_urlc('coltypes/edit/' . $v['id']) . ' " title="' . lang('edit') . '"> <i class="fa fa-pencil"></i> </a>'; $tree .= '<a class="btn btn-danger btn-small btn-del" href="#" title="' . lang('del') . '" data-id="' . $v['id'] . '"> <i class="fa fa-times"></i> </a>'; $tree .= '</div>'; $tree .= '</li>'; if (is_array($v['more'])) { $p = $padding; if (isset($list[$k + 1])) { array_push($p, '| '); } else { array_push($p, ' '); } $tree .= tree_ctype($v['more'], $p); } } return $tree; }
<a href="<?php echo site_urlc('coltypes/create'); ?> " class='btn btn-primary' > <i class="fa fa-plus"></i> 添加分类 </a> </div> <p></p> <div class="boxed"> <div class="boxed-inner"> <h3> <i class="fa fa-list"></i> 分类管理 </h3> <input id='selectbox-all' type="checkbox" class="hide" > <ul class="boxed-list select-list sort-list"> <?php echo tree_ctype($list); ?> </ul> <div class="clearfix"></div> </div> </div> <div class="btn-group"> <a id='select-all' class='btn' href="#"> <i class="fa fa-check-square-o"></i> <?php echo lang('select_all'); ?> </a> <a id='unselect-all' class='btn hide' href="#"> <i class="fa fa-square-o"></i> <?php echo lang('unselect'); ?> </a>