private static function _createCaches()
 {
     $treeObj = new Tree();
     $cccModel = D('CouponCodeCategory');
     $cates = array();
     $res = $cccModel->getAll();
     foreach ($res as $rs) {
         $rs['parents'] = $cccModel->getParents($rs['id']);
         $cates[$rs['id']] = $rs;
         $treeObj->setNode($rs['id'], $rs['parent_id'], $rs['name'], $rs['sort_order']);
     }
     $category = $treeObj->getCateTree(0);
     if (!empty($category)) {
         unset($category[0]);
     }
     $result = array('tree' => $category, 'all' => $cates);
     F('coupon_code_cates', $result);
     return $result;
 }
 private static function _createCaches()
 {
     $treeObj = new Tree();
     $cccModel = M('tao_shop_category');
     $cates = $tree = array();
     $res = $cccModel->order('sort_order ASC')->select();
     foreach ($res as $rs) {
         $cates[$rs['id']] = $rs;
         $treeObj->setNode($rs['id'], $rs['parent_id'], $rs['name'], $rs['sort_order']);
     }
     $category = $treeObj->getCateTree(0);
     if (!empty($category)) {
         unset($category[0]);
     }
     foreach ($category as $c) {
         $c['cid'] = $cates[$c['id']]['cid'];
         $tree[] = $c;
     }
     $result = array('tree' => $tree, 'all' => $cates);
     F('tao_shop_cates', $result);
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Get application list by role
  * For getting menus for whole application
  * @param int $role_id
  * @return array
  */
 public function getAppListByRole($role_id)
 {
     $sql = $this->select()->from($this->t1, array("{$this->t1}.*", "group_concat({$this->t2}.name) as role"))->joinLeft($this->rsh, "{$this->t1}.id = {$this->rsh}.app_id", null)->joinLeft($this->t2, "{$this->t2}.id = {$this->rsh}.role_id", null);
     if ($role_id) {
         if (is_array($role_id)) {
             $sql->where("{$this->rsh}.role_id in (?)", $role_id);
         } else {
             $sql->where("{$this->rsh}.role_id = ?", $role_id);
         }
     }
     $sql->group("{$this->t1}.id")->order(array("{$this->t1}.is_app desc", "{$this->t1}.pid", "{$this->t1}.order", "{$this->t1}.id"));
     $rawAppList = $this->dbr()->fetchAll($sql);
     // build app tree
     require_once 'Hush/Tree.php';
     $tree = new Tree();
     foreach ($rawAppList as $app) {
         $tree->setNode($app['id'], $app['pid'], $app);
     }
     // get top list
     $topAppList = array();
     $topAppListIds = $tree->getChild(0);
     foreach ($topAppListIds as $id) {
         $topAppList[$id] = $tree->getValue($id);
     }
     // get all list
     $allAppList = $topAppList;
     foreach ($topAppListIds as $tid) {
         $groupList = array();
         // group list
         $groupListIds = $tree->getChild($tid);
         foreach ($groupListIds as $gid) {
             $groupAppList = array();
             // group app list
             $groupList[$gid] = $tree->getValue($gid);
             $appListIds = $tree->getChild($gid);
             foreach ($appListIds as $aid) {
                 $groupAppList[$aid] = $tree->getValue($aid);
             }
             $groupList[$gid]['list'] = $groupAppList;
         }
         $allAppList[$tid]['list'] = $groupList;
     }
     //		Hush_Util::dump($allAppList);
     return $allAppList;
 }
Ejemplo n.º 4
0
/**
 * 从缓存中获得模型分类
 */
function getmodelcachecategory($categoryarr, $space = '|----', $delbase = 0)
{
    include_once S_ROOT . './class/tree.class.php';
    $tree = new Tree('');
    $miniupid = 0;
    $delid = array();
    if ($delbase) {
        $delid[] = $delbase;
    }
    $listarr = array();
    if (!empty($categoryarr)) {
        foreach ($categoryarr as $value) {
            $tree->setNode($value['catid'], $value['upid'], $value);
        }
        //根目录
        $carr = $tree->getChilds($miniupid);
        foreach ($carr as $key => $catid) {
            $cat = $tree->getValue($catid);
            $cat['pre'] = $tree->getLayer($catid, $space);
            if (!empty($delid) && (in_array($cat['upid'], $delid) || $cat['catid'] == $delbase)) {
                $delid[] = $cat['catid'];
            } else {
                $listarr[$cat['catid']] = $cat;
            }
        }
    }
    return $listarr;
}
Ejemplo n.º 5
0
function getmodelcategory($name, $space = '|----')
{
    global $_SGLOBAL;
    include_once S_ROOT . './class/tree.class.php';
    $tree = new Tree($name);
    $query = $_SGLOBAL['db']->query('SELECT * FROM ' . tname('categories') . ' WHERE `type`=\'' . $name . '\' ORDER BY upid, displayorder');
    $miniupid = '';
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        if ($miniupid == '') {
            $miniupid = $value['upid'];
        }
        $tree->setNode($value['catid'], $value['upid'], $value);
    }
    //¸ùĿ¼
    $listarr = array();
    if ($_SGLOBAL['db']->num_rows($query) > 0) {
        $categoryarr = $tree->getChilds($miniupid);
        foreach ($categoryarr as $key => $catid) {
            $cat = $tree->getValue($catid);
            $cat['pre'] = $tree->getLayer($catid, $space);
            $listarr[$cat['catid']] = $cat;
        }
    }
    return $listarr;
}
Ejemplo n.º 6
0
function getbbsforum($isblog = 0, $space = '|----')
{
    global $_SGLOBAL;
    dbconnect(1);
    $forumarr = array();
    if ($isblog) {
        $wheresql = ' AND (type=\'group\' || allowshare=\'1\')';
    } else {
        $wheresql = '';
    }
    include_once S_ROOT . './class/tree.class.php';
    $tree = new Tree('blog');
    $minfup = '';
    $query = $_SGLOBAL['db_bbs']->query('SELECT * FROM ' . tname('forums', 1) . ' WHERE status>0' . $wheresql . ' ORDER BY fup, displayorder');
    while ($forum = $_SGLOBAL['db_bbs']->fetch_array($query)) {
        if ($minfup == '') {
            $minfup = $forum['fup'];
        }
        $tree->setNode($forum['fid'], $forum['fup'], $forum);
    }
    //根目录
    $listarr = array();
    $categoryarr = $tree->getChilds($minfup);
    foreach ($categoryarr as $key => $catid) {
        $cat = $tree->getValue($catid);
        $cat['pre'] = $tree->getLayer($catid, $space);
        $listarr[$cat['fid']] = $cat;
    }
    return $listarr;
}
Ejemplo n.º 7
0
 } else {
     $catidinsql = $aviable_field[$catType . '_field'] == 'all' ? '' : 'catid in (' . $aviable_field[$catType . '_field'] . ') AND';
     $sql = 'SELECT *  FROM ' . tname('categories') . ' WHERE ' . $catidinsql . ' type=\'' . $catType . '\' LIMIT 0,50';
     $_query = DB::query($sql);
     while ($res = DB::fetch($_query)) {
         $cats[$res['catid']] = $res;
     }
     include_once B_ROOT . './source/class/tree.class.php';
     $tree = new Tree($type);
     $miniupid = '';
     $space = '|----';
     foreach ($cats as $catid => $category) {
         if ($miniupid === '') {
             $miniupid = $category['upid'];
         }
         $tree->setNode($category['catid'], $category['upid'], $category);
     }
     if (count($cats) > 0) {
         $categoryarr = $tree->getChilds($miniupid);
         foreach ($categoryarr as $key => $catid) {
             $cat = $tree->getValue($catid);
             $cat['pre'] = $tree->getLayer($catid, $space);
             $cat['havechild'] = $tree->getChild($catid) ? 1 : 0;
             $listarr[$cat['catid']] = $cat;
         }
     }
     echo '<option value="0" selected="selected">' . lang('please_select') . "</option>\n";
     foreach ($listarr as $catinfo) {
         echo '<option value="' . $catinfo['catid'] . '">' . $catinfo['pre'] . $catinfo['name'] . '</option>';
     }
 }