ArticleCateTrashAction.class.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维p2p借贷系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class ArticleCateTrashAction extends CommonAction{
  10. public function trash()
  11. {
  12. if(intval($_REQUEST['action_id'])!='')
  13. {
  14. $action_id= intval($_REQUEST['action_id']);
  15. }
  16. $this->assign('action_id',$action_id);
  17. $condition['is_delete'] = 1;
  18. $this->assign("default_map",$condition);
  19. $map = $this->_search ();
  20. //追加默认参数
  21. if($this->get("default_map"))
  22. $map = array_merge($map,$this->get("default_map"));
  23. if (method_exists ( $this, '_filter' )) {
  24. $this->_filter ( $map );
  25. }
  26. $name="ArticleCate";
  27. $model = D ($name);
  28. if (! empty ( $model )) {
  29. $this->_list ( $model, $map );
  30. }
  31. $this->display ();
  32. return;
  33. }
  34. public function restore() {
  35. //删除指定记录
  36. $ajax = intval($_REQUEST['ajax']);
  37. $id = $_REQUEST ['id'];
  38. if (isset ( $id )) {
  39. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  40. $rel_data = M("ArticleCate")->where($condition)->findAll();
  41. foreach($rel_data as $data)
  42. {
  43. $info[] = $data['title'];
  44. }
  45. if($info) $info = implode(",",$info);
  46. $list = M("ArticleCate")->where ( $condition )->setField ( 'is_delete', 0 );
  47. if ($list!==false) {
  48. save_log($info.l("RESTORE_SUCCESS"),1);
  49. clear_auto_cache("cache_shop_acate_tree");
  50. clear_auto_cache("deal_shop_acate_belone_ids");
  51. clear_auto_cache("get_help_cache");
  52. $this->success (l("RESTORE_SUCCESS"),$ajax);
  53. } else {
  54. save_log($info.l("RESTORE_FAILED"),0);
  55. $this->error (l("RESTORE_FAILED"),$ajax);
  56. }
  57. } else {
  58. $this->error (l("INVALID_OPERATION"),$ajax);
  59. }
  60. }
  61. public function foreverdelete() {
  62. //彻底删除指定记录
  63. $ajax = intval($_REQUEST['ajax']);
  64. $id = $_REQUEST ['id'];
  65. if (isset ( $id )) {
  66. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  67. if(M("Article")->where(array ('cate_id' => array ('in', explode ( ',', $id ) ) ))->count()>0)
  68. {
  69. $this->error (l("SUB_ARTICLE_EXIST"),$ajax);
  70. }
  71. $rel_data = M("ArticleCate")->where($condition)->findAll();
  72. foreach($rel_data as $data)
  73. {
  74. $info[] = $data['title'];
  75. }
  76. if($info) $info = implode(",",$info);
  77. $list = M("ArticleCate")->where ( $condition )->delete();
  78. if ($list!==false) {
  79. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  80. clear_auto_cache("cache_shop_acate_tree");
  81. clear_auto_cache("deal_shop_acate_belone_ids");
  82. clear_auto_cache("get_help_cache");
  83. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  84. } else {
  85. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  86. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  87. }
  88. } else {
  89. $this->error (l("INVALID_OPERATION"),$ajax);
  90. }
  91. }
  92. public function get_bs(){
  93. $article_cates_bs= load_auto_cache("article_cates_bs",array(),false);
  94. $article_cates_bs=array_keys($article_cates_bs);
  95. return $article_cates_bs;
  96. }
  97. /*
  98. *
  99. */
  100. public function create_httpd(){
  101. $htppd=APP_ROOT_PATH.".htaccess";
  102. $content=file_get_contents($htppd);
  103. if(strpos($content,'title')==false){
  104. $htppd_old=APP_ROOT_PATH."public/rewrite_rule/.htaccess";
  105. $content=file_get_contents($htppd_old);
  106. }
  107. $article_cates_bs=$this->get_bs();
  108. $article_cates_bs=implode('|',$article_cates_bs);
  109. $str=trim($article_cates_bs,'|');
  110. $content=str_replace("title",$str,$content);
  111. file_put_contents($htppd,$content);
  112. }
  113. /*
  114. *
  115. */
  116. public function check_bs($bs,$seo_title){
  117. if(!$bs){
  118. return true;
  119. }
  120. $bs = strim($bs);
  121. $article_cates_bs=$this->get_bs();
  122. if($seo_title){
  123. foreach($article_cates_bs as $k=>$v){
  124. if($v==$seo_title){
  125. unset($article_cates_bs[$k]);
  126. }
  127. }
  128. }
  129. $article_cates_bs=array_merge($article_cates_bs,array('account','ajax','article_cate','article',
  130. 'avatar','cart','collocation','comment','deal_vote','deal','deals_cate',
  131. 'deals','faq','help','home','index','investor','message','news','notify',
  132. 'online_book','payment','project','referra','settings','user_message','user',
  133. 'vote'));
  134. if(in_array($bs,$article_cates_bs)){
  135. return false;
  136. }else{
  137. return true;
  138. }
  139. }
  140. }
  141. ?>