PageRenderTime 42ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://phpfor.googlecode.com/
PHP | 209 lines | 147 code | 39 blank | 23 comment | 8 complexity | 1c8ddec0d0ce55df2984e864e9326dd4 MD5 | raw file
  1. <?php
  2. class ctl_sitemaps extends adminPage{
  3. var $workground = 'site';
  4. function welcome(){
  5. $this->page('content/welcome.html');
  6. }
  7. function index($close=false){
  8. $this->path[] = array('text'=>"??????");
  9. $this->pagedata['time'] = time();
  10. $mdl = $this->system->loadModel('content/sitemap');
  11. $list = $mdl->update();
  12. $this->pagedata['cloasall'] = $close;
  13. foreach($list as $k=>$v){
  14. $list[$k]['editUrl'] = $this->_edit_act($v);
  15. }
  16. $this->pagedata['list'] = $list;
  17. $this->page('content/sitemap.html');
  18. }
  19. function toRemove($node_id){
  20. $this->begin('index.php?ctl=content/sitemaps&act=index');
  21. $mdl = $this->system->loadModel('content/sitemap');
  22. if($mdl->checkDel($node_id,$string)){
  23. $mdl->remove($node_id);
  24. $this->splash('success', 'index.php?ctl=content/sitemaps&act=index', __('??????!'));
  25. }else{
  26. $this->splash('failed', 'index.php?ctl=content/sitemaps&act=index', __($string?$string:'???????????'));
  27. }
  28. }
  29. function doAdd($p_node_id=0){
  30. //???????????js?? xujilong 2010/8/5
  31. $_POST['title'] = html2txt($_POST['title']);
  32. if (empty($_POST['title'])){
  33. $this->splash('failed','index.php?ctl=content/sitemaps',__('??????'));
  34. exit();
  35. }
  36. $this->begin('index.php?ctl=content/sitemaps&act=index');
  37. $sitemap = $this->system->loadModel('content/sitemap');
  38. if(substr($_POST['type'],0,7)=='plugin-'){
  39. $ident = substr($_POST['type'],7);
  40. $node = $sitemap->newNode(array('node_type'=>'action','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'action_'.$ident.':index'));
  41. $this->end($node,'???????');
  42. }
  43. switch($_POST['type']){
  44. case 'custompage':
  45. $node = $sitemap->newNode(array('node_type'=>'custompage','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'custompage:'.$p_node_id,'item_id'=>$_POST['item_id']));
  46. break;
  47. case 'articles':
  48. $node = $sitemap->newNode(array('node_type'=>'articles','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'artlist:index'));
  49. break;
  50. case 'pageurl':
  51. $node = $sitemap->newNode(array('node_type'=>'pageurl','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>''));
  52. break;
  53. case 'page':
  54. $page = $this->system->loadModel('content/page');
  55. $page_id = $sitemap->title2page($_POST['title']);
  56. $exists=$page->getExists($_POST['title']);
  57. if($exists == true){
  58. trigger_error('??????????',E_USER_ERROR);
  59. }
  60. $node = $sitemap->newNode(array('node_type'=>'page','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'page:'.$page_id));
  61. break;
  62. case 'goodsCat':
  63. $node =$sitemap->newNode(array('node_type'=>'goodsCat','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>''));
  64. //$this->end($sitemap->newNode(array('node_type'=>'goodsCat','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'gallery:')),__('????????'));
  65. break;
  66. default:
  67. if(substr($_POST['type'],0,7)=='action_'){
  68. $action = substr($_POST['type'],7);
  69. $this->end($sitemap->newNode(array('node_type'=>'action','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>$action)),__('????????'));
  70. }else{
  71. trigger_error('???????'.$_POST['type'],E_USER_ERROR);
  72. }
  73. break;
  74. }
  75. $this->end_only();
  76. $this->location($this->_edit_act($node,'add'));
  77. /*
  78. if($_POST['type']=='articles'){
  79. $node = $sitemap->newNode(array('node_type'=>'articles','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'artlist:index'));
  80. }elseif($_POST['type']=='action'){
  81. if($_POST['action']){
  82. if($_POST['action']=='gallery:index'){
  83. $this->end($sitemap->newNode(array('node_type'=>'goodsCat','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'gallery:index')),__('????????'));
  84. }else{
  85. $this->end($sitemap->newNode(array('node_type'=>'action','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>$_POST['action'])),__('????????'));
  86. }
  87. }else{
  88. trigger_error('???????'.$_POST['action'],E_USER_ERROR);
  89. }
  90. }else{
  91. $page_id = $sitemap->title2page($_POST['title']);
  92. $node = $sitemap->newNode(array('node_type'=>'page','p_node_id'=>$p_node_id,'title'=>$_POST['title'],'action'=>'page:'.$page_id));
  93. }
  94. $this->end_only();
  95. $this->location($this->_edit_act($node));
  96. */
  97. }
  98. function _edit_act($data,$type){
  99. switch($data['node_type']){
  100. case 'page':
  101. $str = 'ctl=content/pages&act=index&p[0]='.urlencode(substr($data['action'],strpos($data['action'],':')+1)).'&p[1]='.$data['node_id'];
  102. break;
  103. case 'articles':
  104. if($type=='add'){
  105. $str = 'ctl=content/sitemaps&act=index';
  106. }else{
  107. $str = 'ctl=content/articles&act=index&p[0]='.$data['node_id'];
  108. }
  109. break;
  110. case 'goodsCat':
  111. $str = 'ctl=content/content&act=indexOfgoodsCat&p[0]='.$data['node_id'];
  112. break;
  113. case 'pageurl':
  114. $str = 'ctl=content/content&act=urllinkIndex&p[0]='.$data['node_id'];
  115. break;
  116. case 'custompage':
  117. $str = 'ctl=content/content&act=custompage&p[0]='.$data['node_id'];
  118. break;
  119. default:
  120. return false;
  121. }
  122. return 'index.php?'.$str.'&_wg=site';
  123. }
  124. function modify($node_id){
  125. $mdl = $this->system->loadModel('content/sitemap');
  126. $node = $mdl->getNode($node_id);
  127. $this->pagedata['node'] = &$node;
  128. foreach($mdl->update() as $item){
  129. if(false === strpos($item['path'].$item['node_id'],$node['path'].$node['node_id'])){
  130. $this->pagedata['list'][] = $item;
  131. }
  132. }
  133. $this->page('content/node_info.html');
  134. }
  135. function addNew($p_node_id=0){
  136. $this->path[] = array('text'=>'????');
  137. $sitemap = $this->system->loadModel('content/sitemap');
  138. $this->pagedata['path'] = $sitemap->getPathById($p_node_id,false);
  139. $this->pagedata['actions'] = $sitemap->getActions();
  140. $this->pagedata['parent_id'] = $p_node_id;
  141. $this->page('content/newnode.html');
  142. }
  143. function update(){
  144. $sitemap = $this->system->loadModel('content/sitemap');
  145. $sitemap->updatePorder($_POST['p_order']);
  146. $this->splash('success','index.php?ctl=content/sitemaps',__('??????'));
  147. }
  148. function save($node_id){
  149. $sitemap = $this->system->loadModel('content/sitemap');
  150. $this->begin('index.php?ctl=content/sitemaps&act=index');
  151. $this->end($sitemap->save($node_id,$_POST),'?????');
  152. }
  153. function location($url){
  154. header('Location: '.$url.($_GET['_ajax']?'&_ajax='.$_GET['_ajax']:null));
  155. }
  156. function enableNode($node_id){
  157. $this->begin('index.php?ctl=content/sitemaps&act=index');
  158. $sitemap = $this->system->loadModel('content/sitemap');
  159. $rst = $sitemap->setVisibility($node_id,true);
  160. $this->end($rst,'???????');
  161. }
  162. function disableNode($node_id){
  163. $this->begin('index.php?ctl=content/sitemaps&act=index');
  164. $sitemap = $this->system->loadModel('content/sitemap');
  165. $rst = $sitemap->setVisibility($node_id,false);
  166. $this->end($rst,'???????');
  167. }
  168. }
  169. ?>