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

/b2b/core/admin/controller/ctl.editor.php

http://phpfor.googlecode.com/
PHP | 176 lines | 154 code | 21 blank | 1 comment | 10 complexity | b14643426fa4409733a0db90c44a553f MD5 | raw file
  1. <?php
  2. class ctl_editor extends adminPage{
  3. function link(){
  4. $sitemap = $this->system->loadModel('content/sitemap');
  5. $this->pagedata['linked'] = $sitemap->getLinkNode();
  6. foreach($this->pagedata['linked']['page'] as $k=>$p){
  7. $pos = strpos($p['action'],':');
  8. $ident = substr($p['action'],$pos+1);
  9. $this->pagedata['linked']['page'][$k]['url'] = $this->system->realUrl('page',$ident,null,'html',$this->system->base_url());
  10. }
  11. if($_POST['goods']){
  12. $mod = &$this->system->loadModel('goods/products');
  13. $rows = $mod->getList('name',array('goods_id'=>$_POST['goods']));
  14. $this->pagedata['goodsInfo'] = $rows[0]['name'].'<input type="hidden" name="goods" value="'.$_POST['goods'].'" />';
  15. }
  16. if($_POST['article']){
  17. $mod = &$this->system->loadModel('content/article');
  18. $rows = $mod->getList('title',array('article_id'=>$_POST['article']));
  19. $this->pagedata['articleInfo'] = $rows[0]['title'].'<input type="hidden" name="article" value="'.$_POST['article'].'" />';
  20. }
  21. $this->setView('editor/dlg_lnk.html');
  22. $this->output();
  23. }
  24. function find($type,$keywords){
  25. if(!$keywords){
  26. echo '???????';
  27. return;
  28. }
  29. if($type=='goods'){
  30. $mod = &$this->system->loadModel('goods/products');
  31. foreach($mod->getList('goods_id,name',array('name'=>$keywords)) as $k=>$r){
  32. $list[] = array(
  33. 'url'=>$this->system->realUrl('product','index',array($r['goods_id']),'html',$this->system->base_url())
  34. ,'label'=>$r['name']);
  35. }
  36. $this->pagedata['list'] = $list;
  37. }elseif($type=='article'){
  38. $mod = &$this->system->loadModel('content/article');
  39. foreach($mod->getList('article_id,title',array('keywords'=>$keywords)) as $k=>$r){
  40. $list[] = array(
  41. 'url'=>$this->system->realUrl('article','index',array($r['article_id']),'html',$this->system->base_url()),
  42. 'label'=>$r['title']);
  43. }
  44. $this->pagedata['list'] = $list;
  45. }
  46. if(count($list)>0){
  47. $this->pagedata['type'] = $type;
  48. $this->setView('editor/dlg_result.html');
  49. $this->output();
  50. }else{
  51. echo '??????<b>"'.$keywords.'"</b>????';
  52. }
  53. }
  54. function table(){
  55. $this->setView('editor/dlg_table.html');
  56. $this->output();
  57. }
  58. function image($showpicset=1){
  59. $this->setView('editor/dlg_image.html');
  60. $tag = &$this->system->loadModel('system/tag');
  61. $this->pagedata['show_picset']=$showpicset;
  62. $this->pagedata['imgtags'] = $tag->tagList('image');
  63. $this->output();
  64. }
  65. function flash(){
  66. $this->setView('editor/dlg_flash.html');
  67. $tag = &$this->system->loadModel('system/tag');
  68. $this->pagedata['imgtags'] = $tag->tagList('image');
  69. $this->output();
  70. }
  71. function uploader(){
  72. $storager = &$this->system->loadModel('system/storager');
  73. set_error_handler(array(&$this,'_eH')); //?????????trigger_error?????????_eH
  74. header('Content-Type: text/html; charset=utf-8');
  75. if($s = $storager->save_upload($_FILES['file'],'','',$msg)){
  76. restore_error_handler();
  77. $pubFile = &$this->system->loadModel('system/pubfile');
  78. $pubFile->insert(array(
  79. 'file_name'=>$_FILES['file']['name'],
  80. 'file_ident'=>$s,
  81. 'cdate'=>time(),
  82. 'memo'=>$_POST['memo'],
  83. 'tags'=>space_split(stripslashes($_POST['tags'])),
  84. 'file_type'=>$_POST['file_type']
  85. ));
  86. $info = array('url'=>$storager->getUrl($s),'ident'=>$s);
  87. echo '<script>window.top.uploadCallback('.json_encode($info).')</script>';
  88. }else{
  89. restore_error_handler();
  90. echo '<script>window.top.uploadCallback("'.($msg?$msg:'failed').'")</script>';
  91. }
  92. }
  93. function _eH($errno, $errstr, $errfile, $errline){
  94. restore_error_handler();
  95. echo '<script>window.top.uploadCallback(false)</script>';
  96. }
  97. function removeImage($id) {
  98. if ($id) {
  99. $pubFile = & $this->system->loadModel('system/pubfile');
  100. $pubFile->remove($id);
  101. }
  102. return true;
  103. }
  104. function gallery($tag=0,$page=1,$file_type=0){
  105. $pubFile = &$this->system->loadModel('system/pubfile');
  106. $p = 22;
  107. $result=$pubFile->getList(null,array('tag'=>$tag,'file_type'=>$file_type),$p*($page-1),$p,$c);
  108. foreach($result as $k=>$v){
  109. if(preg_match('/\.swf/',$v['file_name'])){
  110. unset($result[$k]);
  111. }
  112. }
  113. // $c=count($result);
  114. $this->pagedata['images'] = $result;
  115. $this->setView('editor/gallery_img.html');
  116. $this->pagedata['pager'] = array(
  117. 'current'=>$page,
  118. 'total'=>ceil($c/$p),
  119. 'link'=>'javascript:showResLib(\''.$tag.'\',orz)',
  120. 'token'=>'orz'
  121. );
  122. $this->output();
  123. }
  124. function gallery_SWF($tag=0,$page=1,$file_type=0){
  125. $pubFile = &$this->system->loadModel('system/pubfile');
  126. $p = 18;
  127. $result = $pubFile->getList(null,array('tag'=>$tag,'file_type'=>$file_type),$p*($page-1),$p,$c);
  128. foreach($result as $k=>$v){
  129. if(!preg_match('/\.swf/',$v['file_name'])){
  130. unset($result[$k]);
  131. }
  132. }
  133. $c=count($result);
  134. $this->pagedata['swfs'] = $result;
  135. $this->setView('editor/gallery_swf.html');
  136. $this->pagedata['pager'] = array(
  137. 'current'=>$page,
  138. 'total'=>floor($c/$p)+1,
  139. 'link'=>'javascript:showResLib(\''.$tag.'\',orz)',
  140. 'token'=>'orz'
  141. );
  142. $this->output();
  143. }
  144. function editHTML(){
  145. if(file_exists(CORE_DIR.'/admin/view/editor/dlg_editHTML.html')){
  146. $this->setView('editor/dlg_editHTML.html');
  147. }else{
  148. $this->setView('editor/dlg_editHtml.html');
  149. }
  150. $this->pagedata['htmls']=$_POST['htmls'];
  151. $this->pagedata['seri']=$_POST['seri'];
  152. $this->output();
  153. }
  154. }
  155. ?>