Beispiel #1
0
function list_tad_gallery_cate_tree($def_csn = "")
{
    global $xoopsDB, $xoopsTpl;
    $tadgallery = new tadgallery();
    $cate_count = $tadgallery->get_tad_gallery_cate_count();
    $path = get_tadgallery_cate_path($def_csn);
    $path_arr = array_keys($path);
    $sql = "select csn,of_csn,title from " . $xoopsDB->prefix("tad_gallery_cate") . " order by sort";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    while (list($csn, $of_csn, $title) = $xoopsDB->fetchRow($result)) {
        $font_style = $def_csn == $csn ? ", font:{'background-color':'yellow', 'color':'black'}" : '';
        $open = in_array($csn, $path_arr) ? 'true' : 'false';
        $display_counter = empty($cate_count[$csn]['file']) ? "" : " ({$cate_count[$csn]['file']})";
        $data[] = "{ id:{$csn}, pId:{$of_csn}, name:'{$title}{$display_counter}', url:'cooliris.php?csn={$csn}', open: {$open} ,target:'_self' {$font_style}}";
    }
    $json = implode(",\n", $data);
    if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/ztree.php")) {
        redirect_header("index.php", 3, _MA_NEED_TADTOOLS);
    }
    include_once XOOPS_ROOT_PATH . "/modules/tadtools/ztree.php";
    $ztree = new ztree("album_tree", $json, '', '', "of_csn", "csn");
    $ztree_code = $ztree->render();
    $xoopsTpl->assign('ztree_code', $ztree_code);
    return $data;
}
Beispiel #2
0
function get_tad_gallery_cate_option($of_csn = 0, $level = 0, $v = "", $chk_view = 1, $chk_up = 0, $this_csn = "", $no_self = "0")
{
    global $xoopsDB, $xoopsUser, $xoopsModule, $isAdmin;
    if ($xoopsUser) {
        $module_id = $xoopsModule->getVar('mid');
        $isAdmin = $xoopsUser->isAdmin($module_id);
    } else {
        $isAdmin = false;
    }
    $tadgallery = new tadgallery();
    $show_uid = isset($_SESSION['show_uid']) ? intval($_SESSION['show_uid']) : 0;
    if ($show_uid) {
        $tadgallery->set_show_uid($show_uid);
    }
    $cate_count = $tadgallery->get_tad_gallery_cate_count();
    //$left=$level*10;
    $level += 1;
    $syb = str_repeat("-", $level) . " ";
    $option = $of_csn ? "" : "<option value='0'>" . _MD_TADGAL_CATE_SELECT . "</option>";
    $sql = "select csn,title from " . $xoopsDB->prefix("tad_gallery_cate") . " where of_csn='{$of_csn}' order by sort";
    $result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
    $ok_cat = $ok_up_cat = "";
    if ($chk_view) {
        $ok_cat = $tadgallery->chk_cate_power();
    }
    if ($chk_up) {
        $ok_up_cat = $tadgallery->chk_cate_power("upload");
    }
    while (list($csn, $title) = $xoopsDB->fetchRow($result)) {
        if ($chk_view and is_array($ok_cat)) {
            if (!in_array($csn, $ok_cat)) {
                continue;
            }
        }
        if ($chk_up and is_array($ok_up_cat)) {
            if (!in_array($csn, $ok_up_cat)) {
                continue;
            }
        }
        if ($no_self == '1' and $this_csn == $csn) {
            continue;
        }
        $selected = $v == $csn ? "selected" : "";
        $count = empty($cate_count[$csn]['file']) ? 0 : $cate_count[$csn]['file'];
        $option .= "<option value='{$csn}' {$selected}>{$syb}{$title}({$count})</option>";
        $option .= get_tad_gallery_cate_option($csn, $level, $v, $chk_view, $chk_up, $this_csn, $no_self);
    }
    return $option;
}