コード例 #1
0
ファイル: function.php プロジェクト: mcxzyang/vipclub
/**
 * 合并处理父子关系数据
 * @param  [type]  $cate  [description]
 * @param  string  $html  [description]
 * @param  integer $pid   [description]
 * @param  integer $level [description]
 * @return [type]         [description]
 */
function unlimitedForLevel($cate, $html = '--', $pid = 0, $level = 0)
{
    $arr = array();
    foreach ($cate as $key => $v) {
        if ($v['pid'] == $pid) {
            $v['level'] = $level;
            $v['html'] = str_repeat($html, $level);
            $arr[] = $v;
            $arr = array_merge($arr, unlimitedForLevel($cate, $html, $v['id'], $level + 1));
        }
    }
    return $arr;
}
コード例 #2
0
 /**
  * 获取所有分类
  * @return [type] [description]
  */
 public function _befor_add()
 {
     $model = D($this->dbname);
     $info = $model->getAllCate();
     $this->allCate = unlimitedForLevel($info);
 }
コード例 #3
0
 /**
  * 获取已经排列了的数据表
  * @return [type] [description]
  */
 private function getOrderList()
 {
     $menu = D('Menu');
     $map['status'] = array('neq', 0);
     return unlimitedForLevel($menu->getAllMenu($map));
 }