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

首頁 > CMS > PhpCMS > 正文

【phpcms-v9】phpcms-v9中將一個站點(diǎn)下的文章內(nèi)容完美的推送到

2024-09-10 07:15:57
字體:
供稿:網(wǎng)友

【phpcms-v9】phpcms-v9中將一個站點(diǎn)下的文章內(nèi)容完美的推送到另一個站點(diǎn)下.

注意事項:

1.要將當(dāng)前站點(diǎn)下的文章內(nèi)容推送到另一個站點(diǎn)下,即:content字段的值,默認(rèn)情況下此content的內(nèi)容沒有推送到另一個站點(diǎn)下的附表中.

2.將當(dāng)前站點(diǎn)下的文章內(nèi)容推送到另一個站點(diǎn)下的主表時,將islink字段的值設(shè)置為0,代表不是尾部鏈接.

3.content字段的值在附表中,所有要查詢附表,默認(rèn)情況下只查詢了主表.

完整代碼如下:

  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//數(shù)據(jù)調(diào)用屬性   
  14.        
  15.     public function __construct() {   
  16.         $this->db = pc_base::load_model('content_model');  //加載數(shù)據(jù)模型   
  17.     }   
  18.        
  19.     /**  
  20.      * 接口處理方法,參數(shù)1:要推送的文章數(shù)組        參數(shù)2:舊的模型id及舊的欄目id  
  21.      * @param array $param 屬性 請求時,為模型、欄目數(shù)組。提交添加為二維信息數(shù)據(jù) 。例:array(1=>array('title'=>'多發(fā)發(fā)送方法', ....))  
  22.      * @param array $arr 參數(shù) 表單數(shù)據(jù),只在請求添加時傳遞。 例:array('modelid'=>1, 'catid'=>12);   
  23.      */   
  24.     public function category_list($param = array(), $arr = array()) {   
  25.         //確認(rèn)推送按鈕   
  26.         if ($arr['dosubmit']) {   
  27.             $id = $_POST['id'];//要批量推送的文章id,如:39|38|37   
  28.             if(emptyempty($id)) return true;   
  29.             $id_arr = explode('|',$id);//要批量推送的文章id數(shù)組   
  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數(shù)組   
  36.             $siteid = intval($_POST['siteid']);//站點(diǎn)id   
  37.             $siteids = getcache('category_content','commons');//所有欄目對應(yīng)的站點(diǎn)id   
  38.             $oldsiteid = $siteids[$old_catid];//舊站點(diǎn)id   
  39.             $this->categorys = getcache('category_content_'.$oldsiteid,'commons');//舊站點(diǎn)下所有欄目信息   
  40.    
  41.             $modelid = $this->categorys[$old_catid]['modelid'];//舊欄目所屬的模型id   
  42.             $this->db->set_model($modelid);//根據(jù)模型id設(shè)置對應(yīng)的模型表   
  43.             $tablename = $this->db->table_name;   
  44.             $this->hits_db = pc_base::load_model('hits_model');//點(diǎn)擊率統(tǒng)計表   
  45.             foreach($id_arr as $id) {//要批量推送的文章id數(shù)組   
  46.                 $this->db->table_name = $tablename;//模型表   
  47.                 $r = $this->db->get_one(array('id'=>$id));//根據(jù)當(dāng)前文章id獲取該文章詳細(xì)信息   
  48.                    
  49.                 //weiyanhui添加   
  50.                 //附屬表      
  51.                 $this->db->table_name = $this->db->table_name.'_data';   
  52.                 $r2 = $this->db->get_one(array('id'=>$id));//內(nèi)容字段在附表中   
  53.                 if($r2) {   
  54.                     $r = array_merge($r,$r2);   
  55.                 } else {   
  56.                     $r = $r;   
  57.                 }   
  58.                 //weiyanhui添加結(jié)束   
  59.                    
  60.                    
  61.                 $linkurl = preg_match('/^http://///',$r['url']) ? $r['url'] : siteurl($siteid).$r['url'];   
  62.                 foreach($ids as $catid) {//推送欄目,如:6|68   
  63.                     $siteid = $siteids[$catid];//推送到哪個站點(diǎn)id下的欄目   
  64.                     $this->categorys = getcache('category_content_'.$siteid,'commons');//推送站點(diǎn)下所有的欄目信息   
  65.                     $modelid = $this->categorys[$catid]['modelid'];//推送欄目所屬模型id   
  66.                     $this->db->set_model($modelid);//根據(jù)模型id設(shè)置對應(yīng)的模型表   
  67.                         $newid = $this->db->insert(   
  68.                         array('title'=>$r['title'],//標(biāo)題   
  69.                             'style'=>$r['style'],   
  70.                             'thumb'=>$r['thumb'],//縮略圖   
  71.                             'keywords'=>$r['keywords'],//關(guān)鍵詞   
  72.                             'description'=>$r['description'],//描述   
  73.                             'status'=>$r['status'],//狀態(tài)   
  74.                             'catid'=>$catid,//欄目id   
  75.                             'url'=>$linkurl,//舊的鏈接地址   
  76.                             'sysadd'=>1,//系統(tǒng)添加   
  77.                             'username'=>$r['username'],//作者   
  78.                             'inputtime'=>$r['inputtime'],//發(fā)布時間   
  79.                             'updatetime'=>$r['updatetime'],//更新時間   
  80.                             //'islink'=>1 //默認(rèn)值為1:外部鏈接   
  81.                             'islink'=>0 //weiyanhui添加   
  82.                         ),true);//將文章內(nèi)容發(fā)布到推送欄目,并返回新插入的文章id   
  83.                         $this->db->table_name = $this->db->table_name.'_data';//模型附表   
  84.                         //將文章內(nèi)容推送到其它站點(diǎn)后,將islink字段值修改為0,然后再重新發(fā)布一下,即可生成文章靜態(tài)頁到當(dāng)前站點(diǎn)當(dāng)前欄目下   
  85.                         //思考:1-可以在附表入庫前將islink字段值設(shè)置為0  2-將內(nèi)容入庫附表   
  86.                         //$this->db->insert(array('id'=>$newid));//新插入的文章id存儲到附表中,注意:文章內(nèi)容沒有被存儲到附表中   
  87.                         $this->db->insert(array('id'=>$newid,'content'=>$r['content']));//weiyanhui添加   
  88.                         $hitsid = 'c-'.$modelid.'-'.$newid;   
  89.                         $this->hits_db->insert(array('hitsid'=>$hitsid,'catid'=>$catid,'updatetime'=>SYS_TIME));//點(diǎn)擊量統(tǒng)計表   
  90.                 }   
  91.             }   
  92.             return true;   
  93.         } else {   
  94.             $siteid = get_siteid();   
  95.             $this->categorys = getcache('category_content_'.$siteid,'commons');   
  96.             $tree = pc_base::load_sys_class('tree');   
  97.             $tree->icon = array('   │ ','   ├─ ','   └─ ');   
  98.             $tree->nbsp = '   ';   
  99.             $categorys = array();   
  100.             $this->catids_string = array();   
  101.             if($_SESSION['roleid'] != 1) {   
  102.                 $this->priv_db = pc_base::load_model('category_priv_model');   
  103.                 $priv_result = $this->priv_db->select(array('action'=>'add','roleid'=>$_SESSION['roleid'],'siteid'=>$siteid,'is_admin'=>1));   
  104.                 $priv_catids = array();   
  105.                 foreach($priv_result as $_v) {   
  106.                     $priv_catids[] = $_v['catid'];   
  107.                 }   
  108.                 if(emptyempty($priv_catids)) return '';   
  109.             }   
  110.    
  111.             foreach($this->categorys as $r) {   
  112.                 if($r['siteid']!=$siteid || $r['type']!=0) continue;   
  113.                 if($_SESSION['roleid'] != 1 && !in_array($r['catid'],$priv_catids)) {   
  114.                     $arrchildid = explode(',',$r['arrchildid']);   
  115.                     $array_intersect = array_intersect($priv_catids,$arrchildid);   
  116.                     if(emptyempty($array_intersect)) continue;   
  117.                 }   
  118.                 if($r['child']) {   
  119.                     $r['checkbox'] = '';   
  120.                     $r['style'] = 'color:#8A8A8A;';   
  121.                 } else {   
  122.                     $checked = '';   
  123.                     if($typeid && $r['usable_type']) {   
  124.                         $usable_type = explode(','$r['usable_type']);   
  125.                         if(in_array($typeid$usable_type)) {   
  126.                             $checked = 'checked';   
  127.                             $this->catids_string[] = $r['catid'];   
  128.                         }   
  129.                     }   
  130.                     $r['checkbox'] = "<input type='checkbox' name='ids[]' value='{$r[catid]}' {$checked}>";   
  131.                     $r['style'] = '';   
  132.                 }   
  133.                 $categorys[$r['catid']] = $r;   
  134.             }  //開源代碼Vevb.com 
  135.             $str  = "<tr>   
  136.                         <td align='center'>/$checkbox</td>   
  137.                         <td style='/$style'>/$spacer/$catname</td>   
  138.                     </tr>";   
  139.             $tree->init($categorys);   
  140.             $categorys = $tree->get_tree(0, $str);   
  141.             return $categorys;   
  142.         }   
  143.  }   
  144. }   
  145.  ?>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 澜沧| 都匀市| 建水县| 大冶市| 鸡东县| 务川| 新营市| 阿合奇县| 象山县| 建始县| 垫江县| 治多县| 中卫市| 宁明县| 三门峡市| 汉中市| 江永县| 塔城市| 夏邑县| 宁城县| 宁南县| 南京市| 凉城县| 宿松县| 合山市| 佛山市| 广汉市| 青海省| 黄浦区| 建瓯市| 桂阳县| 长岭县| 罗平县| 响水县| 潼南县| 洪雅县| 阳东县| 盐边县| 七台河市| 德清县| 泾川县|