/b2b/core/admin/controller/content/ctl.articles.php
PHP | 272 lines | 224 code | 28 blank | 20 comment | 36 complexity | 6080232049f93b19d861077966128195 MD5 | raw file
- <?php
- include_once('objectPage.php');
- class ctl_articles extends objectPage{
- var $name='??';
- var $workground ='site';
- var $object = 'content/article';
- var $actionView = 'content/article/finder_action.html'; //?????html??,???null
- var $filterView = 'content/article/finder_filter.html'; //??????html,???null
- var $allowImport =false;
- var $allowExport = false;
-
- function index($node_id){
- $this->pagedata['node_id'] = $node_id;
-
- $oArticle = $this->system->loadModel('content/article');
- parent::index(array('params'=>array('node_id'=>$node_id)));
- }
- //????
- function addArticle(){
- if($_POST['ifpub']) $_POST['ifpub'] = 1;
- else $_POST['ifpub'] = 0;
-
- $_POST['goodslink'] = $_POST['goodslink']?1:0;
- $_POST['hotlink'] = $_POST['hotlink']?1:0;
-
- $this->begin('index.php?ctl=content/articles&act=addnew');
-
- //????????????js??,?js???? xujilong 2010/8/5
- $_POST['title'] = html2txt($_POST['title']);
-
- if (empty($_POST['title'])){
- trigger_error('??????',E_USER_ERROR);
- $this->end();
- exit();
- }
-
- if ($_POST['userlev_all']=='1'){
- if ($_POST['member_lv']==''){
- trigger_error('????????',E_USER_ERROR);
- exit();
- }
- }
- if ($_POST['userlev_all']=='2'){
- if ($_POST['memberid']==''){
- trigger_error('????????',E_USER_ERROR);
- exit();
- }
- }
- if ($_FILES){
- $nums=count($_FILES['art_accessories']['name']);
- for ($i=0;$i<$nums;$i++){
- $up_url=HOME_DIR."/download/".urlencode($_FILES['art_accessories']['name'][$i]);
- if (!copy($_FILES['art_accessories']['tmp_name'][$i],$up_url)){
- trigger_error('???????',E_USER_ERROR);
- $this->end();
- exit;
- }
- }
- }
-
- array_pop($_POST['linkwords']);
- array_pop($_POST['linkurl']);
-
- $oArticle = $this->system->loadModel('content/article');
- if(!$oArticle->addArticle($_POST)){
- $this->splash('failed','index.php?ctl=content/articles&act=index',$msg);
- }
- $this->splash('success','index.php?ctl=content/articles&act=index',__('??????'));
- }
- function detail($nConId){
- $oArticle = $this->system->loadModel('content/article');
- $sitemap = $this->system->loadModel('content/sitemap');
- $this->pagedata['article'] = $oArticle->instance($nConId,"*");
-
- // BEGIN ????&???? by yangbing 2010-07-06 1509
- $goodsinfo = unserialize($this->pagedata['article']['goodsinfo']);
- if (is_array($goodsinfo) && count($goodsinfo)>0){
- $this->pagedata['goodsinfo'] = $goodsinfo;
- }
- $hotlink = $oArticle->gethotlink($nConId);
- if ($hotlink){
- $this->pagedata['hotlink'] = $hotlink;
- }
- // END
-
- $this->pagedata['node_id'] = $this->pagedata['article']['node_id'];
- $this->pagedata['ouser_name']=$this->pagedata['article']['member_lv'];
- $file_name=str_replace('home/download/','',$this->pagedata['article']['art_accessories']);
- $file_array=explode(",",$file_name);
- $this->pagedata['file_name_item']=$file_name;
- $this->pagedata['file_name']=$file_array;
- $this->pagedata['article_cat'] = $oArticle->getArticleCat();
- $this->pagedata['get_edit_lev'] = $oArticle->get_edit_lev($this->pagedata['ouser_name']);
- $this->pagedata['article_id'] = $nConId;
- $this->pagedata['level_status'] = $this->pagedata['article']['level_status'];
- if($this->pagedata['article']['level_status']==2){
- $members = $oArticle->getArticleMembers($this->pagedata['article']['article_id']);
- foreach ($members as $member){
- $ids[] = $member['member_id'];
- }
- $this->pagedata['members'] = $ids;
- }
-
- $this->setView('content/article/article.html');
- $this->output();
- }
- /**
- * ????
- *
- **/
- function addNew(){
- $this->path[] = array('text'=>'????');
- $sitemap = $this->system->loadModel('content/sitemap');
- $oArticle = $this->system->loadModel('content/article');
- $this->pagedata['article_cat'] = $oArticle->getArticleCat();
- $this->pagedata['get_add_lev'] = $oArticle->get_add_lev();
- $this->page('content/article/article.html');
- }
- /**
- * ????
- *
- **/
- function edit($article_id,$node_id){
- $this->path[] = array('text'=>'????');
- $sitemap = $this->system->loadModel('content/sitemap');
- $this->pagedata['node_id'] = $node_id;
- $this->pagedata['path'] = $sitemap->getPathById($node_id,false);
- $oArticle = $this->system->loadModel('content/article');
- $this->pagedata['article'] = $oArticle->instance($article_id,"*");
- $this->page('content/article/article.html');
- }
- function delfile($name){
-
- }
- /**
- * ????
- *
- **/
- function save($article_id,$node_id){
-
-
- if($_POST['ifpub']) $_POST['ifpub'] = 1;
- else $_POST['ifpub'] = 0;
- if($_POST['iftop']) $_POST['iftop'] = 1;
- else $_POST['iftop'] = 0;
-
- $_POST['goodslink'] = $_POST['goodslink']?1:0;
- $_POST['hotlink'] = $_POST['hotlink']?1:0;
-
- $this->begin('index.php?ctl=content/articles&act=detail&p[0]='.$article_id);
-
- //????????????js??,?js???? ??? 2010/8/5
- $_POST['title'] = html2txt($_POST['title']);
-
- if (empty($_POST['title'])){
- trigger_error('??????',E_USER_ERROR);
- exit();
- }
- if ($_POST['userlev_all']=='1'){
- if ($_POST['member_lv']==''){
- trigger_error('????????',E_USER_ERROR);
- exit();
- }
- }
- if ($_POST['userlev_all']=='2'){
- if ($_POST['memberid']==''){
- trigger_error('????????',E_USER_ERROR);
- exit();
- }
- }
- if ($_FILES){
- $nums=count($_FILES['art_accessories']['name']);
- $size=$this->system->getConf('system.upload.limit');
- for ($i=0;$i<$nums;$i++){
- switch ($size){
- case '0':
- $nsize='500000';
- $msg='500k';
- break;
- case '1':
- $nsize='1000000';
- $msg='1M';
- break;
- case '2':
- $nsize='2000000';
- $msg='2M';
- break;
- case '3':
- $nsize='3000000';
- $msg='3M';
- break;
- case '4':
- $nsize='5000000';
- $msg='5M';
- break;
- case '5':
- $nsize='';
- break;
- }
- if ($nsize){
- if($_FILES['art_accessories']['size'][$i]>$nsize){
- $ii=$i+1;
- trigger_error('????'.$ii.'?????????'.$msg.'??????????',E_USER_ERROR);
- $this->end();
- exit();
- }
- }
- $up_url=HOME_DIR."/download/".urlencode($_FILES['art_accessories']['name'][$i]);
- if (!copy($_FILES['art_accessories']['tmp_name'][$i],$up_url)){
- trigger_error('???????',E_USER_ERROR);
- exit;
- }
- }
- }
-
- array_pop($_POST['linkwords']);
- array_pop($_POST['linkurl']);
-
- $oArticle = $this->system->loadModel('content/article');
- if(!$oArticle->saveArticle($_POST)){
- $this->end(false, __('???????'));
- //$this->splash('failed','index.php?ctl=content/articles&act=detail&p[0]='.$article_id,__('????'));
-
- }else{
- $this->end(true, __('???????'));
- }
- }
- //$this->splash('success','index.php?ctl=content/articles&act=detail&p[0]='.$article_id,__('??????'));
-
- function __convert($from_charset,$to_charset,$str){
- if (function_exists('iconv')) {
- $str = iconv($from_charset,$to_charset,$str);
- }else{
- $str = mb_convert_encoding($str,$to_charset,$from_charset);
- }
- return $str;
- }
-
- // ?????? by yangbing
- function getGoods($num,$goodsId){
- $article = &$this->system->loadModel('content/article');
- $keywords = $_POST['keywords'];
- $relateGoods=$article->getGoodsByKw($keywords,$num);
- $this->pagedata['goods'] = &$relateGoods;
- if ($goodsId){
- $goodsIdG=explode(",",$goodsId);
- if ($relateGoods)
- foreach($relateGoods as $key => $val){
- if (in_array($val['goods_id'],$goodsIdG)){
- $relateGoods[$key]['checked']="checked";
- }
- }
- }
- $this->pagedata['disPath'] = true; // ??????? by yangbing
- $this->page('content/article/getgoods.html');
- }
-
- function delete() {
- if($this->model->delete($_POST)){
- foreach ($_POST['article_id'] as $aid){
- $this->model->deleteArticleMembers($aid);
- }
- echo '?????????!';
- }else{
- echo '????????!';
- }
- }
- }
- ?>