當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BaseAction::tree_dir方法代碼示例

本文整理匯總了PHP中BaseAction::tree_dir方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseAction::tree_dir方法的具體用法?PHP BaseAction::tree_dir怎麽用?PHP BaseAction::tree_dir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BaseAction的用法示例。


在下文中一共展示了BaseAction::tree_dir方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 public function index()
 {
     if (!isset($_GET['aid'])) {
         $this->error('非法操作');
     }
     inject_check($_GET['aid']);
     inject_check($_GET['p']);
     $aid = intval($_GET['aid']);
     //讀取數據庫和緩存
     ob_start();
     //用於生成靜態HTML
     $is_build = C('IS_BUILD_HTML');
     //允許參數
     $allow_param = array('p', 'keyword');
     $static_file = './Html/' . cookie('think_template') . '/articles/' . $aid;
     $mid_str = '';
     if (count($_REQUEST) > 1) {
         foreach ($_REQUEST as $k => $v) {
             if ($k != 'aid' && in_array($k, $allow_param)) {
                 $mid_str .= '/' . $k . '/' . md5($v);
             }
         }
     }
     $static_file .= $mid_str . '.html';
     $path = './ArticleAction.class.php';
     $php_file = basename($path);
     parent::html_init($static_file, $php_file, $is_build);
     //以下是動態代碼
     $article = M('article');
     $config = F('basic', '', './Web/Conf/');
     $page_model = 'page/page_default.html';
     //相關判斷
     $alist = $article->where('aid=' . $aid)->find();
     if (!$alist) {
         alert('文章不存在或已刪除!', __APP__);
     }
     if ($alist['islink'] == 1) {
         Header('Location:' . $alist['linkurl']);
     }
     if ($alist['status'] == 0) {
         alert('文章未審核!', __APP__);
     }
     //閱讀權限
     if ($config['isread'] == 1) {
         $uvail = explode(',', $_SESSION['dami_uservail']);
         if (!in_array($alist['typeid'], $uvail)) {
             alert('對不起您沒有閱讀改文章的權限!', __APP__);
         }
     }
     $this->assign('title', $alist['title']);
     parent::tree_dir($alist['typeid'], 'tree_list');
     $type = M('type');
     $list = $type->where('typeid=' . intval($alist['typeid']))->find();
     if ($list) {
         $pid = get_first_father($list['typeid']);
         $cur_menu = get_field('type', 'typeid=' . $pid, 'drank');
         $this->assign('cur_menu', $cur_menu);
         $this->assign('type', $list);
     }
     $a = M('type')->where('typeid=' . $alist['typeid'])->getField('page_path');
     if ($a != '' && file_exists(TMPL_PATH . cookie('think_template') . '/' . $a)) {
         $page_model = $a;
     }
     //網站頭部
     R('Public/head');
     R('Public/py_link');
     //統計處理
     if ($alist['status'] == 1) {
         $map['hits'] = $alist['hits'] + 1;
         $article->where('aid=' . $aid)->save($map);
     }
     //注銷map
     unset($map);
     $alist['hits'] += 1;
     //關鍵字替換
     $alist['content'] = $this->key($alist['content']);
     //鼠標輪滾圖片
     if ($config['mouseimg'] == 1) {
         $alist['content'] = $this->mouseimg($alist['content']);
     }
     //文章內分頁處理
     if ($alist['pagenum'] == 0) {
         //手動分頁
         $alist['content'] = $this->diypage($alist['content']);
     } else {
         //自動分頁
         $alist['content'] = $this->autopage($alist['pagenum'], $alist['content']);
     }
     //文章內投票
     $this->vote($alist['voteid']);
     //心情投票
     $url = __ROOT__;
     //用於心情js的根路徑變量
     $this->assign('url', $url);
     //文章上下篇
     $map['status'] = 1;
     $map['typeid'] = $alist['typeid'];
     $map['aid'] = array('lt', $alist['aid']);
     $up = $article->where($map)->field('aid,title')->order('addtime desc')->limit(1)->find();
     //dump($article->getLastsql());
//.........這裏部分代碼省略.........
開發者ID:babyhuangshiming,項目名稱:webserver,代碼行數:101,代碼來源:ArticleAction.class.php

示例2: index

 public function index()
 {
     inject_check($_GET['typeid']);
     inject_check($_GET['p']);
     //讀取數據庫&判斷
     $typeid = (int) $_GET['typeid'];
     $list_model = 'list/list_default.html';
     $type = M('type');
     $list = $type->where('typeid=' . intval($_GET['typeid']))->find();
     if (!$list) {
         $this->error('欄目不存在!');
     } else {
         //當前選中菜單
         $pid = get_first_father($list['typeid']);
         $cur_menu = get_field('type', 'typeid=' . $pid, 'drank');
         $this->assign('cur_menu', $cur_menu);
         if ($list['list_path'] != '' && file_exists(TMPL_PATH . cookie('think_template') . '/' . $list['list_path'])) {
             $list_model = $list['list_path'];
         }
     }
     ob_start();
     //用於生成靜態HTML
     $is_build = C('IS_BUILD_HTML');
     //允許參數
     $allow_param = array('p', 'author_id');
     $static_file = './Html/' . cookie('think_template') . '/lists/' . $typeid;
     $mid_str = '';
     if (count($_REQUEST) > 1) {
         foreach ($_REQUEST as $k => $v) {
             if ($k != 'typeid' && in_array($k, $allow_param)) {
                 $mid_str .= '/' . $k . '/' . md5($v);
             }
         }
     }
     $static_file .= $mid_str . '.html';
     $path = './ListAction.class.php';
     $php_file = basename($path);
     parent::html_init($static_file, $php_file, $is_build);
     //以下是動態代碼
     //家族樹與子孫樹
     parent::tree_dir($typeid, 'tree_list');
     parent::children_dir($typeid, 'child_list');
     //欄目基本信息封裝
     $this->assign('title', $list['typename']);
     $this->assign('type', $list);
     //欄目導航
     $config = F('basic', '', './Web/Conf/');
     if ($config['listshowmode'] == 1) {
         $map['fid'] = $list['fid'];
     } else {
         $map['fid'] = intval($_GET['typeid']);
     }
     $map['islink'] = 0;
     $nav = $type->where($map)->field('typeid,typename')->select();
     $this->assign('dh', $nav);
     //第一次釋放內存
     $pernum = isset($list['pernum']) && intval($list['pernum']) > 0 ? intval($list['pernum']) : $config['artlistnum'];
     unset($list, $nav, $map);
     $list_server = M('admin')->where('is_client=1')->select();
     $this->assign('list_server', $list_server);
     $vip_sn = M('vip_mess')->order('id desc')->getField('vip_sn');
     $this->assign('vip_sn', $vip_sn);
     //網站頭部與友情鏈接
     R('Public/head');
     R('Public/py_link');
     //查詢數據庫和緩存
     $article = D('ArticleView');
     //封裝條件
     $map['status'] = 1;
     //導入分頁類
     import('ORG.Util.Page');
     //準備工作
     $arr = get_children($typeid);
     $map['article.typeid'] = array('in', $arr);
     //用戶閱讀權限
     if ($config['isread'] == 1) {
         $map['_string'] = 'article.typeid in(' . $_SESSION['dami_uservail'] . ')';
     }
     //分頁處理
     $count = $article->where($map)->count();
     $p = new Page($count, $pernum);
     $p->setConfig('prev', '上一頁');
     $p->setConfig('header', '篇文章');
     $p->setConfig('first', '首 頁');
     $p->setConfig('last', '末 頁');
     $p->setConfig('next', '下一頁');
     if (check_wap()) {
         $temp_str = "%first%%upPage%%downPage%%end%";
     } else {
         $temp_str = "%first%%upPage%%prePage%%linkPage%%nextPage%%downPage%%end%\n\t\t<select name='select' onChange='javascript:window.location.href=(this.options[this.selectedIndex].value);'>%allPage%</select>共<font color='#CD4F07'><b>%totalRow%</b></font>篇 " . $config['artlistnum'] . "篇/每頁";
     }
     $p->setConfig('theme', $temp_str);
     //數據查詢
     $alist = $article->where($map)->order('istop desc,addtime desc')->limit($p->firstRow . ',' . $p->listRows)->select();
     //echo $article->getLastSql();
     //封裝變量
     $this->assign('page', $p->show());
     $this->assign('list', $alist);
     //釋放內存
     unset($article, $type, $p, $tlist, $alist);
//.........這裏部分代碼省略.........
開發者ID:babyhuangshiming,項目名稱:webserver,代碼行數:101,代碼來源:ListAction.class.php


注:本文中的BaseAction::tree_dir方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。