【phpcms-v9】专题模块前端控制器index.php文件分析

[php]  view plain  copy
 print ?
  1. <?php   
  2. defined('IN_PHPCMS'or exit('No permission resources.');  
  3.   
  4. pc_base::load_app_func('global''special');//加载global.func.php文件  
  5. class index {  
  6.       
  7.     private $db;  
  8.       
  9.     function __construct() {  
  10.         $this->db = pc_base::load_model('special_model');//table_name:special  
  11.     }  
  12.       
  13.     /** 
  14.      * 专题列表  
  15.      */  
  16.     public function special() {  
  17.         //站点id  
  18.         $siteid = $_GET['siteid'] ? intval($_GET['siteid']) : (get_siteid() ? get_siteid() : 1);  
  19.         //seo信息  
  20.         $SEO = seo($siteid);  
  21.         //加载专题列表页面  
  22.         include template('special''special_list');  
  23.     }  
  24.       
  25.     /** 
  26.      * 专题首页 
  27.      */  
  28.     public function init() {  
  29.         //专题id  
  30.         $specialid = $_GET['id'] ? $_GET['id'] : ($_GET['specialid'] ? $_GET['specialid'] : 0);  
  31.         if (!$specialid) showmessage(L('illegal_action'));  
  32.         //相当于:select * from gt_special where id='$specialid' and disabled=0  
  33.         $info = $this->db->get_one(array('id'=>$specialid'disabled'=>0));  
  34.         if(!$info) showmessage(L('special_not_exist'), 'back');  
  35.           
  36.         //将当前专题id所对应的字段作为变量导入到当前的符号表  
  37.         extract($info);  
  38.           
  39.         $css = get_css(unserialize($css));  
  40.         if(!$ispage) {//字段变量:如果不分页的话  
  41.             $type_db = pc_base::load_model('type_model');//类别表  
  42.             //查询当前专题下所有的类别  
  43.             $types = $type_db->select(array('module'=>'special''parentid'=>$specialid), '*''''`listorder` ASC, `typeid` ASC''''listorder');  
  44.         }  
  45.         if ($pics) {//字段变量:专题导入的图片报道信息,如:1|65|周克华被警方击毙  
  46.             $pic_data = get_pic_content($pics);  
  47.             unset($pics);  
  48.         }  
  49.         if ($voteid) {//字段变量:投票信息,如:vote|1|你最爱吃的饭?  
  50.             $vote_info = explode('|'$voteid);  
  51.             $voteid = $vote_info[1];//投票id  
  52.         }  
  53.         $siteid =  $_GET['siteid'] ? $_GET['siteid'] : get_siteid();//站点id  
  54.         $SEO = seo($siteid''$title$description);//seo信息  
  55.         //评论表commentid字段的组成  
  56.         $commentid = id_encode('special'$id$siteid);//组成生成id号:urlencode($modules.'-'.$contentid.'-'.$siteid);  
  57.         $template = $info['index_template'] ? $info['index_template'] : 'index';//模板  
  58.         define('STYLE',$info['style']);  
  59.         include template('special'$template);  
  60.     }  
  61.       
  62.     /** 
  63.      * 专题分类 
  64.      */  
  65.     public function type() {  
  66.         $typeid = intval($_GET['typeid']);//分类id  
  67.         $specialid = intval($_GET['specialid']);//专题id  
  68.         if (!$specialid || !$typeid) showmessage(L('illegal_action'));  
  69.         //相当于:select * from gt_special where id='$special' and disabled=0  获取当前专题信息  
  70.         $info = $this->db->get_one(array('id'=>$specialid'disabled'=>0));  
  71.         if(!$info) showmessage(L('special_not_exist'), 'back');  
  72.         $page = max(intval($_GET['page']), 1);  
  73.         //当前专题信息  
  74.         extract($info);  
  75.         $css = get_css(unserialize($css));  
  76.         if(!$typeid) showmessage(L('illegal_action'));  
  77.         $type_db = pc_base::load_model('type_model');//类别表  
  78.         //相当于:select * from gt_type where typeid='$typeid'  
  79.         $info = $type_db->get_one(array('typeid'=>$_GET['typeid']));  
  80.         $SEO = seo($siteid''$info['typename'], '');//类别名称  
  81.         $template = $list_template ? $list_template : 'list';//类别对应的模板  
  82.         include template('special'$template);  
  83.     }  
  84.       
  85.     /** 
  86.      * 专题展示 
  87.      */  
  88.     public function show() {  
  89.         $id = intval($_GET['id']);//专题文章id  
  90.         if(!$id) showmessage(L('content_not_exist'),'blank');  
  91.           
  92.         $page = max(intval($_GET['page']), 1);  
  93.         $c_db = pc_base::load_model('special_content_model');//专题文章主表  
  94.         $c_data_db = pc_base::load_model('special_c_data_model');//专题文章附表  
  95.         $rs = $c_db->get_one(array('id'=>$_GET['id']));//获取当前专题文章的主表内容  
  96.         if(!$rs) showmessage(L('content_checking'),'blank');  
  97.         //将当前专题文章主表中的字段转化为变量  
  98.         extract($rs);  
  99.           
  100.         //是否用附表数据  
  101.         if ($isdata) {  
  102.             $arr_content = $c_data_db->get_one(array('id'=>$_GET['id']));//附表数据  
  103.             if (is_array($arr_content)) extract($arr_content);//将当前专题文章附表中的字段转化为变量  
  104.         }  
  105.         $siteid = get_siteid();//站点id  
  106.         if ($paginationtype) {          //文章使用分页时:0-不分页  1-自动分页    2-手动分页  
  107.             if($paginationtype==1) {  
  108.                 if (strpos($content'[/page]')!==false) {  
  109.                     $content = preg_replace("|
    page
    (.*)
    /page
    |U"''$content);  
  110.                 }  
  111.                 if (strpos($content'[page]')!==false) {  
  112.                     $content = str_replace('[page]'''$content);  
  113.                 }  
  114.                 $contentpage = pc_base::load_app_class('contentpage''content'); //调用自动分页类  
  115.                 $content = $contentpage->get_data($content$maxcharperpage); //自动分页,自动添加上[page]  
  116.             }   
  117.         } else {//文章不使用分页的情况  
  118.             if (strpos($content'[/page]')!==false) {  
  119.                 $content = preg_replace("|
    page
    (.*)
    /page
    |U"''$content);  
  120.             }  
  121.             if (strpos($content'[page]')!==false) {  
  122.                 $content = str_replace('[page]'''$content);  
  123.             }  
  124.         }  
  125.         $template = $show_template ? $show_template : 'show'//调用模板  
  126.         $CONTENT_POS = strpos($content'[page]');  
  127.         if ($CONTENT_POS !== false) {  
  128.             $contents = array_filter(explode('[page]'$content));  
  129.             $pagenumber = count($contents);  
  130.             $END_POS = strpos($content'[/page]');  
  131.             if ($END_POS!==false && ($CONTENT_POS<7)) {  
  132.                 $pagenumber--;  
  133.             }  
  134.             for ($i=1; $i<=$pagenumber$i++) {  
  135.                 $pageurls[$i] = content_url($_GET['id'], $i$inputtime'php');  
  136.             }  
  137.             if ($END_POS !== false) {  
  138.                 if($CONTENT_POS>7) {  
  139.                     $content = '[page]'.$title.'[/page]'.$content;  
  140.                 }  
  141.                 if (preg_match_all("|
    page
    (.*)
    /page
    |U"$content$m, PREG_PATTERN_ORDER)) {  
  142.                     foreach ($m[1] as $k=>$v) {  
  143.                         $p = $k+1;  
  144.                         $titles[$p]['title'] = strip_tags($v);  
  145.                         $titles[$p]['url'] = $pageurls[$p][1];  
  146.                     }  
  147.                 }  
  148.             }  
  149.             //判断[page]出现的位置是否在第一位   
  150.             if($CONTENT_POS<7) {  
  151.                 $content = $contents[$page];  
  152.             } else {  
  153.                 if ($page==1 && !empty($titles)) {  
  154.                     $content = $title.'[/page]'.$contents[$page-1];  
  155.                 } else {  
  156.                     $content = $contents[$page-1];  
  157.                 }  
  158.             }  
  159.             if($titles) {  
  160.                 list($title$content) = explode('[/page]'$content);  
  161.                 $content = trim($content);  
  162.                 if(strpos($content,'</p>')===0) {  
  163.                     $content = '<p>'.$content;  
  164.                 }  
  165.                 if(stripos($content,'<p>')===0) {  
  166.                     $content = $content.'</p>';  
  167.                 }  
  168.             }  
  169.             pc_base::load_app_func('util''content');  
  170.             $title_pages = content_pages($pagenumber,$page$pageurls);//分页代码  
  171.         }  
  172.         //当前专题的标题和url  
  173.         $_special = $this->db->get_one(array('id'=>$specialid), '`title`, `url`');  
  174.         pc_base::load_sys_class('format''', 0);  
  175.         $inputtime = format::date($inputtime);//发布时间  
  176.         $SEO = seo($siteid''$title);  
  177.         $template = $show_template ? $show_template : 'show';  
  178.         $style = $style ? $style : 'default';  
  179.         include template('special'$template$style);  
  180.     }  
  181.       
  182.     public function comment_show() {  
  183.         $commentid = isset($_GET['commentid']) ? $_GET['commentid'] : 0;  
  184.         $url = isset($_GET['url']) ? $_GET['url'] : HTTP_REFERER;  
  185.         $id = isset($_GET['id']) ? intval($_GET['id']) : 0;  
  186.         $userid = param::get_cookie('_userid');  
  187.         include template('special''comment_show');  
  188.     }  
  189.       
  190.     public function comment() {  
  191.         if (!$_GET['id']) return '0';  
  192.         $siteid =  $_GET['siteid'] ? $_GET['siteid'] : get_siteid();  
  193.         $id = intval($_GET['id']);  
  194.         $commentid = id_encode('special'$id$siteid);  
  195.         $username = param::get_cookie('_username');  
  196.         $userid = param::get_cookie('_userid');  
  197.         if (!$userid) {  
  198.             showmessage(L('login_website'), APP_PATH.'index.php?m=member&c=index');  
  199.         }  
  200.         $date = date('m-d H:i', SYS_TIME);  
  201.         if ($_POST['dosubmit']) {  
  202.             $r = $this->db->get_one(array('id'=>$_POST['id']), '`title`, `url`');  
  203.             $comment = pc_base::load_app_class('comment''comment');  
  204.             if ($comment->add($commentid$siteidarray('userid'=>$userid'username'=>$username'content'=>$_POST['content']), ''$r['title'], $r['url'])) {  
  205.                 exit($username.'|'.SYS_TIME.'|'.$_POST['content']);  
  206.             } else {  
  207.                 exit(0);  
  208.             }  
  209.         } else {  
  210.             pc_base::load_sys_class('form');  
  211.             include template('special''comment');  
  212.         }  
  213.     }  
  214. }  
  215. ?>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值