PageRenderTime 26ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/b2b/core/admin/controller/content/ctl.articles.php

http://phpfor.googlecode.com/
PHP | 272 lines | 224 code | 28 blank | 20 comment | 36 complexity | 6080232049f93b19d861077966128195 MD5 | raw file
  1. <?php
  2. include_once('objectPage.php');
  3. class ctl_articles extends objectPage{
  4. var $name='??';
  5. var $workground ='site';
  6. var $object = 'content/article';
  7. var $actionView = 'content/article/finder_action.html'; //?????html??,???null
  8. var $filterView = 'content/article/finder_filter.html'; //??????html,???null
  9. var $allowImport =false;
  10. var $allowExport = false;
  11. function index($node_id){
  12. $this->pagedata['node_id'] = $node_id;
  13. $oArticle = $this->system->loadModel('content/article');
  14. parent::index(array('params'=>array('node_id'=>$node_id)));
  15. }
  16. //????
  17. function addArticle(){
  18. if($_POST['ifpub']) $_POST['ifpub'] = 1;
  19. else $_POST['ifpub'] = 0;
  20. $_POST['goodslink'] = $_POST['goodslink']?1:0;
  21. $_POST['hotlink'] = $_POST['hotlink']?1:0;
  22. $this->begin('index.php?ctl=content/articles&act=addnew');
  23. //????????????js??,?js???? xujilong 2010/8/5
  24. $_POST['title'] = html2txt($_POST['title']);
  25. if (empty($_POST['title'])){
  26. trigger_error('??????',E_USER_ERROR);
  27. $this->end();
  28. exit();
  29. }
  30. if ($_POST['userlev_all']=='1'){
  31. if ($_POST['member_lv']==''){
  32. trigger_error('????????',E_USER_ERROR);
  33. exit();
  34. }
  35. }
  36. if ($_POST['userlev_all']=='2'){
  37. if ($_POST['memberid']==''){
  38. trigger_error('????????',E_USER_ERROR);
  39. exit();
  40. }
  41. }
  42. if ($_FILES){
  43. $nums=count($_FILES['art_accessories']['name']);
  44. for ($i=0;$i<$nums;$i++){
  45. $up_url=HOME_DIR."/download/".urlencode($_FILES['art_accessories']['name'][$i]);
  46. if (!copy($_FILES['art_accessories']['tmp_name'][$i],$up_url)){
  47. trigger_error('???????',E_USER_ERROR);
  48. $this->end();
  49. exit;
  50. }
  51. }
  52. }
  53. array_pop($_POST['linkwords']);
  54. array_pop($_POST['linkurl']);
  55. $oArticle = $this->system->loadModel('content/article');
  56. if(!$oArticle->addArticle($_POST)){
  57. $this->splash('failed','index.php?ctl=content/articles&act=index',$msg);
  58. }
  59. $this->splash('success','index.php?ctl=content/articles&act=index',__('??????'));
  60. }
  61. function detail($nConId){
  62. $oArticle = $this->system->loadModel('content/article');
  63. $sitemap = $this->system->loadModel('content/sitemap');
  64. $this->pagedata['article'] = $oArticle->instance($nConId,"*");
  65. // BEGIN ????&???? by yangbing 2010-07-06 1509
  66. $goodsinfo = unserialize($this->pagedata['article']['goodsinfo']);
  67. if (is_array($goodsinfo) && count($goodsinfo)>0){
  68. $this->pagedata['goodsinfo'] = $goodsinfo;
  69. }
  70. $hotlink = $oArticle->gethotlink($nConId);
  71. if ($hotlink){
  72. $this->pagedata['hotlink'] = $hotlink;
  73. }
  74. // END
  75. $this->pagedata['node_id'] = $this->pagedata['article']['node_id'];
  76. $this->pagedata['ouser_name']=$this->pagedata['article']['member_lv'];
  77. $file_name=str_replace('home/download/','',$this->pagedata['article']['art_accessories']);
  78. $file_array=explode(",",$file_name);
  79. $this->pagedata['file_name_item']=$file_name;
  80. $this->pagedata['file_name']=$file_array;
  81. $this->pagedata['article_cat'] = $oArticle->getArticleCat();
  82. $this->pagedata['get_edit_lev'] = $oArticle->get_edit_lev($this->pagedata['ouser_name']);
  83. $this->pagedata['article_id'] = $nConId;
  84. $this->pagedata['level_status'] = $this->pagedata['article']['level_status'];
  85. if($this->pagedata['article']['level_status']==2){
  86. $members = $oArticle->getArticleMembers($this->pagedata['article']['article_id']);
  87. foreach ($members as $member){
  88. $ids[] = $member['member_id'];
  89. }
  90. $this->pagedata['members'] = $ids;
  91. }
  92. $this->setView('content/article/article.html');
  93. $this->output();
  94. }
  95. /**
  96. * ????
  97. *
  98. **/
  99. function addNew(){
  100. $this->path[] = array('text'=>'????');
  101. $sitemap = $this->system->loadModel('content/sitemap');
  102. $oArticle = $this->system->loadModel('content/article');
  103. $this->pagedata['article_cat'] = $oArticle->getArticleCat();
  104. $this->pagedata['get_add_lev'] = $oArticle->get_add_lev();
  105. $this->page('content/article/article.html');
  106. }
  107. /**
  108. * ????
  109. *
  110. **/
  111. function edit($article_id,$node_id){
  112. $this->path[] = array('text'=>'????');
  113. $sitemap = $this->system->loadModel('content/sitemap');
  114. $this->pagedata['node_id'] = $node_id;
  115. $this->pagedata['path'] = $sitemap->getPathById($node_id,false);
  116. $oArticle = $this->system->loadModel('content/article');
  117. $this->pagedata['article'] = $oArticle->instance($article_id,"*");
  118. $this->page('content/article/article.html');
  119. }
  120. function delfile($name){
  121. }
  122. /**
  123. * ????
  124. *
  125. **/
  126. function save($article_id,$node_id){
  127. if($_POST['ifpub']) $_POST['ifpub'] = 1;
  128. else $_POST['ifpub'] = 0;
  129. if($_POST['iftop']) $_POST['iftop'] = 1;
  130. else $_POST['iftop'] = 0;
  131. $_POST['goodslink'] = $_POST['goodslink']?1:0;
  132. $_POST['hotlink'] = $_POST['hotlink']?1:0;
  133. $this->begin('index.php?ctl=content/articles&act=detail&p[0]='.$article_id);
  134. //????????????js??,?js???? ??? 2010/8/5
  135. $_POST['title'] = html2txt($_POST['title']);
  136. if (empty($_POST['title'])){
  137. trigger_error('??????',E_USER_ERROR);
  138. exit();
  139. }
  140. if ($_POST['userlev_all']=='1'){
  141. if ($_POST['member_lv']==''){
  142. trigger_error('????????',E_USER_ERROR);
  143. exit();
  144. }
  145. }
  146. if ($_POST['userlev_all']=='2'){
  147. if ($_POST['memberid']==''){
  148. trigger_error('????????',E_USER_ERROR);
  149. exit();
  150. }
  151. }
  152. if ($_FILES){
  153. $nums=count($_FILES['art_accessories']['name']);
  154. $size=$this->system->getConf('system.upload.limit');
  155. for ($i=0;$i<$nums;$i++){
  156. switch ($size){
  157. case '0':
  158. $nsize='500000';
  159. $msg='500k';
  160. break;
  161. case '1':
  162. $nsize='1000000';
  163. $msg='1M';
  164. break;
  165. case '2':
  166. $nsize='2000000';
  167. $msg='2M';
  168. break;
  169. case '3':
  170. $nsize='3000000';
  171. $msg='3M';
  172. break;
  173. case '4':
  174. $nsize='5000000';
  175. $msg='5M';
  176. break;
  177. case '5':
  178. $nsize='';
  179. break;
  180. }
  181. if ($nsize){
  182. if($_FILES['art_accessories']['size'][$i]>$nsize){
  183. $ii=$i+1;
  184. trigger_error('????'.$ii.'?????????'.$msg.'??????????',E_USER_ERROR);
  185. $this->end();
  186. exit();
  187. }
  188. }
  189. $up_url=HOME_DIR."/download/".urlencode($_FILES['art_accessories']['name'][$i]);
  190. if (!copy($_FILES['art_accessories']['tmp_name'][$i],$up_url)){
  191. trigger_error('???????',E_USER_ERROR);
  192. exit;
  193. }
  194. }
  195. }
  196. array_pop($_POST['linkwords']);
  197. array_pop($_POST['linkurl']);
  198. $oArticle = $this->system->loadModel('content/article');
  199. if(!$oArticle->saveArticle($_POST)){
  200. $this->end(false, __('???????'));
  201. //$this->splash('failed','index.php?ctl=content/articles&act=detail&p[0]='.$article_id,__('????'));
  202. }else{
  203. $this->end(true, __('???????'));
  204. }
  205. }
  206. //$this->splash('success','index.php?ctl=content/articles&act=detail&p[0]='.$article_id,__('??????'));
  207. function __convert($from_charset,$to_charset,$str){
  208. if (function_exists('iconv')) {
  209. $str = iconv($from_charset,$to_charset,$str);
  210. }else{
  211. $str = mb_convert_encoding($str,$to_charset,$from_charset);
  212. }
  213. return $str;
  214. }
  215. // ?????? by yangbing
  216. function getGoods($num,$goodsId){
  217. $article = &$this->system->loadModel('content/article');
  218. $keywords = $_POST['keywords'];
  219. $relateGoods=$article->getGoodsByKw($keywords,$num);
  220. $this->pagedata['goods'] = &$relateGoods;
  221. if ($goodsId){
  222. $goodsIdG=explode(",",$goodsId);
  223. if ($relateGoods)
  224. foreach($relateGoods as $key => $val){
  225. if (in_array($val['goods_id'],$goodsIdG)){
  226. $relateGoods[$key]['checked']="checked";
  227. }
  228. }
  229. }
  230. $this->pagedata['disPath'] = true; // ??????? by yangbing
  231. $this->page('content/article/getgoods.html');
  232. }
  233. function delete() {
  234. if($this->model->delete($_POST)){
  235. foreach ($_POST['article_id'] as $aid){
  236. $this->model->deleteArticleMembers($aid);
  237. }
  238. echo '?????????!';
  239. }else{
  240. echo '????????!';
  241. }
  242. }
  243. }
  244. ?>