国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > PhpCMS > 正文

【phpcms-v9】phpcms-v9中將選中的批量文章推送到推薦位、推送

2024-09-10 07:15:57
字體:
來源:轉載
供稿:網友

【phpcms-v9】phpcms-v9中將選中的批量文章推送到推薦位、推送到專題及推送到其他欄目的功能.

1.推送按鈕:

2.推送彈出框:

3.push()函數:

  1. function push() {   
  2.     var str = 0;   
  3.     var id = tag = '';   
  4.     $("input[name='ids[]']").each(function() {   
  5.         if($(this).attr('checked')=='checked') {   
  6.             str = 1;   
  7.             id += tag+$(this).val();   
  8.             tag = '|';   
  9.         }   
  10.     });   
  11.     if(str==0) {   
  12.         alert('<?php echo L('you_do_not_check');?>');   
  13.         return false;   
  14.     }   
  15.     window.top.art.dialog({id:'push'}).close();   
  16.     window.top.art.dialog({title:'<?php echo L('push');?>:',id:'push',iframe:'?m=content&c=push&action=position_list&catid=<?php echo $catid?>&modelid=<?php echo $modelid?>&id='+id,width:'800',height:'500'}, function(){var d = window.top.art.dialog({id:'push'}).data.iframe;// 使用內置接口獲取iframe對象   
  17.     var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'push'}).close()});   

4.modules/content/push.php推送控制器文件:

  1. <?php   
  2. defined('IN_PHPCMS'or exit('No permission resources.');   
  3.    
  4. pc_base::load_app_class('admin','admin',0);   
  5. pc_base::load_sys_class('push_factory''', 0);   
  6. //權限判斷,根據欄目里面的權限設置檢查       
  7. if((isset($_GET['catid']) || isset($_POST['catid'])) && $_SESSION['roleid'] != 1) {   
  8.     $catid = isset($_GET['catid']) ? intval($_GET['catid']) : intval($_POST['catid']);   
  9.     $this->priv_db = pc_base::load_model('category_priv_model');   
  10.     $priv_datas = $this->priv_db->get_one(array('catid'=>$catid,'is_admin'=>1,'action'=>'push'));   
  11.     if(!$priv_datas['catid']) showmessage(L('permission_to_operate'),'blank');   
  12. }   
  13.    
  14. class push extends admin {   
  15.        
  16.     public function __construct() {   
  17.         parent::__construct();   
  18.         $this->siteid = $this->get_siteid();   
  19.         /*  
  20.          * $_GET['module']值分析:  
  21.          * 1.推送到推薦位:不傳遞moduls參數  
  22.          * 2.推送到專題:special  
  23.          * 3.推送到其它欄目:content  
  24.          */   
  25.         $module = (isset($_GET['module']) && !emptyempty($_GET['module'])) ? $_GET['module'] : 'admin';   
  26.         if (in_array($modulearray('admin''special','content'))) {   
  27.             /*根據$module值定位到對應的推送接口文件  
  28.              * 1.推送至推薦位:調用modules/admin/classes/push_api.class.php接口文件  
  29.              * 2.推薦至專題:調用modules/special/classes/push_api.class.php接口文件  
  30.              * 3.推薦至其它欄目:調用modules/content/classes/push_api.class.php接口文件   
  31.              */   
  32.             $this->push = push_factory::get_instance()->get_api($module);   
  33.         } else {   
  34.             showmessage(L('not_exists_push'), 'blank');   
  35.         }   
  36.     }   
  37.        
  38.     /**  
  39.      * 推送選擇界面  
  40.      */   
  41.     public function init() {   
  42.         if ($_POST['dosubmit']) {   
  43.             $c = pc_base::load_model('content_model');//實例化一個content_model對象   
  44.             $c->set_model($_POST['modelid']);//模型id   
  45.             $info = array();//被推送的文章內容數組   
  46.             $ids = explode('|'$_POST['id']);//要推送的文章id,如:39|38|37  
  47.    
  48.             if(is_array($ids)) {   
  49.                 foreach($ids as $id) {   
  50.                     $info[$id] = $c->get_content($_POST['catid'], $id);//根據欄目id及文章id獲取文章內容   
  51.                 }   
  52.             }   
  53.             //position_list:推薦到推薦位       _push_special:推薦到專題     category_list:推薦到其它欄目             
  54.             $_GET['add_action'] = $_GET['add_action'] ? $_GET['add_action'] : $_GET['action'];   
  55.             $this->push->$_GET['add_action']($info$_POST);//將文章推送到其它地方   
  56.             showmessage(L('success'), '''''push');   
  57.         } else {   
  58.             pc_base::load_app_func('global''template');   
  59.             /*  
  60.              * $this->push分析:推送接口文件  
  61.              * 1.推送至推薦位:調用modules/admin/classes/push_api.class.php接口文件  
  62.              * 2.推薦至專題:調用modules/special/classes/push_api.class.php接口文件  
  63.              * 3.推薦至其它欄目:調用modules/content/classes/push_api.class.php接口文件  
  64.              */   
  65.             if (method_exists($this->push, $_GET['action'])) {   
  66.                 $html = $this->push->{$_GET['action']}(array('modelid'=>$_GET['modelid'], 'catid'=>$_GET['catid']));   
  67.                 $tpl = isset($_GET['tpl']) ? 'push_to_category' : 'push_list';   
  68.                 include $this->admin_tpl($tpl);   
  69.             } else {  //開源代碼Vevb.com 
  70.                 showmessage('CLASS METHOD NO EXISTS!''blank');   
  71.             }   
  72.         }   
  73.     }   
  74.        
  75.     public function public_ajax_get() {   
  76.         if (method_exists($this->push, $_GET['action'])) {   
  77.             $html = $this->push->{$_GET['action']}($_GET['html']);   
  78.             echo $html;   
  79.         } else {   
  80.             echo 'CLASS METHOD NO EXISTS!';   
  81.         }   
  82.     }   
  83. }   
  84. ?> 

5.modules/content/classes/push_api.class.php文件分析:

  1. <?php   
  2. /**  
  3.  *  position_api.class.php 推薦至欄目接口類  
  4.  *  
  5.  * @copyright           (C) 2005-2010 PHPCMS  
  6.  * @license             http://www.phpcms.cn/license/  
  7.  * @lastmodify          2010-10-14  
  8.  */   
  9.    
  10. defined('IN_PHPCMS'or exit('No permission resources.');   
  11.    
  12. class push_api {   
  13.     private $db$pos_data//數據調用屬性   
  14.        
  15.     public function __construct() {   
  16.         $this->db = pc_base::load_model('content_model');  //加載數據模型   
  17.     }   
  18.        
  19.     /**  
  20.      * 接口處理方法,參數1:要推送的文章數組        參數2:舊的模型id及舊的欄目id  
  21.      * @param array $param 屬性 請求時,為模型、欄目數組。提交添加為二維信息數據 。例:array(1=>array('title'=>'多發發送方法', ....))  
  22.      * @param array $arr 參數 表單數據,只在請求添加時傳遞。 例:array('modelid'=>1, 'catid'=>12);   
  23.      */   
  24.     public function category_list($param = array(), $arr = array()) {   
  25.         //確認推送按鈕   
  26.         if ($arr['dosubmit']) {   
  27.             $id = $_POST['id'];//要批量推送的文章id,如:39|38|37   
  28.             if(emptyempty($id)) return true;   
  29.             $id_arr = explode('|',$id);//要批量推送的文章id數組   
  30.             if(count($id_arr)==0) return true;   
  31.             $old_catid = intval($_POST['catid']);//舊欄目id   
  32.             if(!$old_catidreturn true;   
  33.             $ids = $_POST['ids'];//推送欄目,如:6|68   
  34.             if(emptyempty($ids)) return true;   
  35.             $ids = explode('|'$ids);//推送欄目id數組   
  36.             $siteid = intval($_POST['siteid']);//站點id   
  37.             $siteids = getcache('category_content','commons');//所有欄目對應的站點id   
  38.             $oldsiteid = $siteids[$old_catid];//舊站點id   
  39.             $this->categorys = getcache('category_content_'.$oldsiteid,'commons');//舊站點下所有欄目信息   
  40.    
  41.             $modelid = $this->categorys[$old_catid]['modelid'];//舊欄目所屬的模型id   
  42.             $this->db->set_model($modelid);//根據模型id設置對應的模型表   
  43.             $tablename = $this->db->table_name;   
  44.             $this->hits_db = pc_base::load_model('hits_model');//點擊率統計表   
  45.             foreach($id_arr as $id) {//要批量推送的文章id數組   
  46.                 $this->db->table_name = $tablename;//模型表   
  47.                 $r = $this->db->get_one(array('id'=>$id));//根據當前文章id獲取該文章詳細信息   
  48.                 $linkurl = preg_match('/^http://///',$r['url']) ? $r['url'] : siteurl($siteid).$r['url'];   
  49.                 foreach($ids as $catid) {//推送欄目,如:6|68   
  50.                     $siteid = $siteids[$catid];//推送到哪個站點id下的欄目   
  51.                     $this->categorys = getcache('category_content_'.$siteid,'commons');//推送站點下所有的欄目信息   
  52.                     $modelid = $this->categorys[$catid]['modelid'];//推送欄目所屬模型id   
  53.                     $this->db->set_model($modelid);//根據模型id設置對應的模型表   
  54.                         $newid = $this->db->insert(   
  55.                         array('title'=>$r['title'],//標題   
  56.                             'style'=>$r['style'],   
  57.                             'thumb'=>$r['thumb'],//縮略圖   
  58.                             'keywords'=>$r['keywords'],//關鍵詞   
  59.                             'description'=>$r['description'],//描述   
  60.                             'status'=>$r['status'],//狀態   
  61.                             'catid'=>$catid,//欄目id   
  62.                             'url'=>$linkurl,//舊的鏈接地址   
  63.                             'sysadd'=>1,//系統添加   
  64.                             'username'=>$r['username'],//作者   
  65.                             'inputtime'=>$r['inputtime'],//發布時間   
  66.                             'updatetime'=>$r['updatetime'],//更新時間   
  67.                             'islink'=>1 //外部鏈接   
  68.                         ),true);//將文章內容發布到推送欄目,并返回新插入的文章id   
  69.                         $this->db->table_name = $this->db->table_name.'_data';//模型附表   
  70.                         $this->db->insert(array('id'=>$newid));//新插入的文章id存儲到附表中,注意:文章內容沒有被存儲到附表中   
  71.                         $hitsid = 'c-'.$modelid.'-'.$newid;   
  72.                         $this->hits_db->insert(array('hitsid'=>$hitsid,'catid'=>$catid,'updatetime'=>SYS_TIME));//點擊量統計表   
  73.                 }   
  74.             }   
  75.             return true;   
  76.         } else {   
  77.             $siteid = get_siteid();   
  78.             $this->categorys = getcache('category_content_'.$siteid,'commons');   
  79.             $tree = pc_base::load_sys_class('tree');   
  80.             $tree->icon = array('   │ ','   ├─ ','   └─ ');   
  81.             $tree->nbsp = '   ';   
  82.             $categorys = array();   
  83.             $this->catids_string = array();   
  84.             if($_SESSION['roleid'] != 1) {   
  85.                 $this->priv_db = pc_base::load_model('category_priv_model');   
  86.                 $priv_result = $this->priv_db->select(array('action'=>'add','roleid'=>$_SESSION['roleid'],'siteid'=>$siteid,'is_admin'=>1));   
  87.                 $priv_catids = array();   
  88.                 foreach($priv_result as $_v) {   
  89.                     $priv_catids[] = $_v['catid'];   
  90.                 }   
  91.                 if(emptyempty($priv_catids)) return '';   
  92.             }   
  93.    
  94.             foreach($this->categorys as $r) {   
  95.                 if($r['siteid']!=$siteid || $r['type']!=0) continue;   
  96.                 if($_SESSION['roleid'] != 1 && !in_array($r['catid'],$priv_catids)) {   
  97.                     $arrchildid = explode(',',$r['arrchildid']);   
  98.                     $array_intersect = array_intersect($priv_catids,$arrchildid);   
  99.                     if(emptyempty($array_intersect)) continue;   
  100.                 }   
  101.                 if($r['child']) {   
  102.                     $r['checkbox'] = '';   
  103.                     $r['style'] = 'color:#8A8A8A;';   
  104.                 } else {   
  105.                     $checked = '';   
  106.                     if($typeid && $r['usable_type']) {   
  107.                         $usable_type = explode(','$r['usable_type']);   
  108.                         if(in_array($typeid$usable_type)) {   
  109.                             $checked = 'checked';   
  110.                             $this->catids_string[] = $r['catid'];   
  111.                         }   
  112.                     }   
  113.                     $r['checkbox'] = "<input type='checkbox' name='ids[]' value='{$r[catid]}' {$checked}>";   
  114.                     $r['style'] = '';   
  115.                 }   
  116.                 $categorys[$r['catid']] = $r;   
  117.             }   
  118.             $str  = "<tr>   
  119.                         <td align='center'>/$checkbox</td>   
  120.                         <td style='/$style'>/$spacer/$catname</td>   
  121.                     </tr>";   
  122.             $tree->init($categorys);   
  123.             $categorys = $tree->get_tree(0, $str);   
  124.             return $categorys;   
  125.         }   
  126.  }   
  127. }   
  128.  ?> 

例如:文章被推送到專題的情況:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 天水市| 永川市| 定西市| 体育| 舞钢市| 封开县| 平泉县| 驻马店市| 兴和县| 略阳县| 永靖县| 茂名市| 梁山县| 山丹县| 孝昌县| 汝阳县| 砚山县| 孝义市| 苍南县| 银川市| 芜湖市| 监利县| 武安市| 郑州市| 长岭县| 永安市| 阿巴嘎旗| 南郑县| 顺昌县| 祁门县| 乐陵市| 义乌市| 定襄县| 灵武市| 上饶市| 左云县| 绥宁县| 全州县| 喜德县| 剑川县| 原阳县|