Ejemplo n.º 1
0
                 "forwardUrl":"admin.php?mod=info_cate&do=index",
                 "confirmMsg":""
             }';
             die;
         }
     }
     include template('admin/info/info_cate_edit');
     break;
 case "lookup_cate":
     $wheresql = '';
     $cate_results_tmp = $cate_results = array();
     $sql = "SELECT info_cateid, title, info_catepid from " . DB::table('content_cate') . " WHERE isdelete=0 " . $wheresql . " ORDER BY info_cateid ASC";
     $cate_results_tmp = DB::fetch_all($sql);
     $cate_results_tree = dbarr2tree($cate_results_tmp);
     $relate = isset($_GET['relate']) ? $_GET['relate'] : 0;
     $tree2htmlul = tree2htmlul($cate_results_tree, $relate);
     /*
     foreach($cate_results_tmp AS $key => $value){
         if(empty($value['info_catepid'])){
             $cate_results[$value['info_cateid']] = $value;
         }else{
             if($cate_results[$value['info_catepid']]){
                 $cate_results[$value['info_catepid']]['sub_cate'][$value['info_cateid']] = $value;
             }else{
                 foreach($cate_results AS $key_sub => $value_sub){
                     if($value_sub['sub_cate']){
                         foreach($value_sub['sub_cate'] AS $key_sub_sub => $value_sub_sub){
                             if($key_sub_sub==$value['info_catepid']){
                                 $cate_results[$key_sub]['sub_cate'][$key_sub_sub]['sub_cate'][$value['info_cateid']] = $value;
                             }
                         }
Ejemplo n.º 2
0
function tree2htmlul($tree, $relate)
{
    if ($relate == 1) {
        $bringback_id = 'relate_info_cateid';
        $bringback_title = 'title2';
    } else {
        $bringback_id = 'info_cateid';
        $bringback_title = 'title';
    }
    $tree2htmlul .= '<ul>';
    foreach ($tree as $leaf) {
        $tree2htmlul .= "<li><a href='javascript:' onclick=\"\$.bringBack({" . $bringback_id . ":'" . $leaf['info_cateid'] . "', " . $bringback_title . ":'" . $leaf['title'] . "'})\">" . $leaf['title'] . "</a>";
        if (!empty($leaf['children'])) {
            $tree2htmlul .= tree2htmlul($leaf['children'], $relate);
        }
        $tree2htmlul .= '</li>';
    }
    $tree2htmlul .= '</ul>';
    return $tree2htmlul;
}