function html_cate_list($tree = array(), $i = 0, $state = 0) { global $c, $template; $i++; foreach ($tree as $k => $t) { //验证权限 if (!check_admin_level($t['cate_id'])) { continue; } $flag = ''; for ($j = 1; $j < $i; $j++) { $flag .= ''; } $is_set = 0; // 分类类型 $style = ''; $_GET['cate_id'] = isset($_GET['cate_id']) ? $_GET['cate_id'] : ''; if ($t['cate_id'] == $_GET['cate_id']) { $style = 'style="color:red;"'; } $ctype = '<font color=red>目录分类</font>'; if ($c->cate_last($t['cate_id']) == 0) { $ctype = '<font color=#888>终极分类</font>'; $is_set = 1; } if ($c->cate_last($t['cate_id']) == 0 && $t['cdata'] > 0) { $ctype = '<font color=green>文档分类</font>'; $is_set = 1; } // 前缀图标 if (count($t['son']) > 0) { $onclick = ' onclick="show_hidden(' . $t['cate_id'] . ',this)" style="cursor:pointer;" title="点击展开子分类"'; $flag .= '<img src="' . $template . '/css/img/folder.gif"' . $onclick . '> '; } else { $onclick = ''; if ($ctype == '<font color=#888>终极分类</font>') { $flag .= '<img src="' . $template . '/css/img/file.gif"> '; $is_set = 1; } else { $flag .= '<img src="' . $template . '/css/img/file.gif"> '; } } echo '<table class="tb tbcate" style="background:#fff;font-size:10px;"><tr>'; echo '<td class="col4"><div style="float:left"><a name="cate_' . $t['cate_id'] . '" id="cate_' . $t['cate_id'] . '"></a>' . $flag . '<b style="color:#666;"><a ' . $style . ' onclick="window.parent.location.href=\'info.php?state=' . $state . '&cate_id=' . $t['cate_id'] . '&is_set=' . $is_set . '\'" href="javascript:void(0);">' . $t['cname'] . '</a></b> ' . ' ' . '</div></td>'; //echo('<td class="col8">'); echo '</tr></table>' . chr(10); if (is_array($t['son']) && count($t['son']) > 0) { echo chr(10) . '<div id="tbody_' . $t['cate_id'] . '" style="display:block;">' . chr(10); html_cate_list($t['son'], $i); echo chr(10) . '</div>' . chr(10); } } }
.tb tr td, .tb4 tr td{padding:0 0;} div{padding: 2px 0 2px 18px; text-align:left; background: url("<?php echo $template; ?> /css/img/treeview-default-line.gif") no-repeat scroll 0 0;} .tb tr td, .tb4 tr td{} .col4 img,.col4 b{display:inline-block;} .col4 b a{text-indent:5px;display:inline-block;} table.tbcate{width:400px;} </style> <script> $(function(){ $('body').height(window.parent.document.getElementById('center_frame').style.height); var top=C.cookie.get('cate_tree_scroll'); if(top!=null){ $('body').scrollTop(top); } $('body').scroll(function(){ C.cookie.set('cate_tree_scroll',$(this).scrollTop(),24); }); }); </script> </head> <body> <?php html_cate_list($c->cate_tree(), 0, $_GET['state']); ?> </body> </html>
function html_cate_list($tree = array(), $i = 0) { global $c, $template; $i++; $tree_ids = explode(',', isset($_COOKIE['tree_ids']) ? $_COOKIE['tree_ids'] : ''); foreach ($tree as $k => $t) { //验证权限 if (!check_admin_level($t['cate_id'])) { continue; } $flag = ''; for ($j = 1; $j < $i; $j++) { $flag .= ' '; } // 分类类型 $ctype = '<font color=red>目录分类</font>'; if ($c->cate_last($t['cate_id']) == 0) { $ctype = '<font color=#888>终极分类</font>'; } if ($c->cate_last($t['cate_id']) == 0 && $t['cdata'] > 0) { $ctype = '<font color=green>文档分类</font>'; } // 前缀图标 if (count($t['son']) > 0) { $onclick = ' onclick="show_hidden(' . $t['cate_id'] . ',this)" style="cursor:pointer;" title="点击展开子分类"'; $flag .= '<img src="' . $template . '/css/img/folder.png"' . $onclick . ' width="16"> '; } else { $onclick = ''; if ($ctype == '<font color=#888>终极分类</font>') { $flag .= '<img src="' . $template . '/css/img/file.png" width="16"> '; } else { $flag .= '<img src="' . $template . '/css/img/www_link.png" width="16"> '; } } echo '<table class="tb tbcate"><tr>'; echo '<td class="col1"><input class="corder ipt" pid="' . $t['cate_id'] . '" type="text" style="width:40px;" value="' . $t['corder'] . '"></td>'; echo '<td class="col2">' . $t['cate_id'] . '</td>'; echo '<td class="col3">' . $c->externs[$t['extern_id']]['extern_title'] . '</td>'; echo '<td class="col4"><div style="float:left">' . $flag . '<b style="color:#666;"><a href="info.php?state=0&cate_id=' . $t['cate_id'] . '">' . $t['cname'] . '</a></b> ' . $ctype . ' ' . ($t['nav_show'] == 1 ? '导航显示' : '') . ' <font color=#ccc>' . ($t['go_url'] == '' ? $t['cname_py'] : ' ' . $t['go_url'] . ' ') . '</font> <font color=deeppink>' . (count($t['son']) > 0 ? count($t['son']) : '') . '</font></div></td>'; echo '<td class="col41" style="text-align:left">' . ($t['tpl_index'] == '' ? '' : '封面:' . $t['tpl_index'] . '<br>') . ($t['tpl_listvar'] == '' ? '' : '列表:' . $t['tpl_listvar'] . '<br>') . ($t['tpl_content'] == '' ? '' : '内容:' . $t['tpl_content']) . '</td>'; echo '<td class="col7">' . $t['cdata'] . '</td>'; echo '<td class="col8">'; if ($c->cate_last($t['cate_id']) == 1 && $c->categories[$t['cate_id']]['cdata'] > 0) { echo show_button(array('class' => 'but2 but2s', 'onclick' => 'javascript:void(0);', 'other' => 'style="background:#ccc;border-color:#ccc;color:#888;cursor:default;"', 'text' => '移动', 'level' => 'C0405')); } else { echo show_button(array('class' => 'but2 but2s', 'onclick' => "cate_move_show('{$t['cate_id']}','{$t['cname']}');", 'text' => '移动', 'level' => 'C0405')); } if ($t['cdata'] == 0) { echo show_button(array('class' => 'but2 but2s but2r', 'onclick' => "cate_del('{$t['cate_id']}');", 'text' => '删除', 'level' => 'C0402')); } else { echo show_button(array('class' => 'but2 but2s', 'onclick' => "javascript:void(0);", 'text' => '删除', 'level' => 'C0402', 'other' => 'style="background:#ccc;border-color:#ccc;color:#888;cursor:default;"')); } echo show_button(array('class' => 'but2 but2s', 'onclick' => "cate_show('{$t['cate_id']}','{$t['parent_id']}','{$t['extern_id']}');", 'text' => '修改', 'level' => 'C0401')); if ($t['cdata'] == 0 || $c->cate_last($t['cate_id']) == 1) { echo show_button(array('class' => 'but2 but2s but2o', 'onclick' => "cate_show(0,'{$t['cate_id']}','{$t['extern_id']}');", 'text' => '添加子类', 'level' => 'C0401')); } else { echo show_button(array('class' => 'but2 but2s', 'onclick' => "javascript:void(0);", 'text' => '添加子类', 'level' => 'C0401', 'other' => 'style="background:#ccc;border-color:#ccc;color:#888;cursor:default;"')); } echo '</td>'; echo '</tr></table>' . chr(10); $dis_show = 'none'; foreach ($tree_ids as $tree_id) { if ($tree_id == $t['cate_id']) { $dis_show = ''; } } if (is_array($t['son']) && count($t['son']) > 0) { echo chr(10) . '<div id="tbody_' . $t['cate_id'] . '" style="display:' . $dis_show . ';">' . chr(10); html_cate_list($t['son'], $i); echo chr(10) . '</div>' . chr(10); } } }
.col8{width:250px;} .tbcate{border-top:0px;} </style> <table class="tb tbcate" id='list'> <tr> <th class="col1">排序</th> <th class="col2">分类ID</th> <th class="col3">模型</th> <th class="col4">分类名称</th> <th class="col41">模板页</th> <th class="col7">文档</th> <th class="col8"></th> </tr> </table> <?php html_cate_list($c->cate_tree()); ?> </form> </div> </div><!-- 右侧主体内容结束 --> <?php require_once dirname(__FILE__) . "/inc_footer.php"; ?> </div><!-- 右侧区域结束 --> <!-- 隐藏表单半透明层 --> <!-- 添加编辑分类 --> <div style="display:none;" id="addcate">