ThemeAction.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. *
  4. * Theme(风格选择)
  5. *
  6. */
  7. if(!defined("Ainaphp")) exit("Access Denied");
  8. class ThemeAction extends AdminbaseAction
  9. {
  10. protected $filepath,$publicpath;
  11. function _initialize()
  12. {
  13. parent::_initialize();
  14. $this->filepath = TMPL_PATH.'Home/'.$this->sysConfig['DEFAULT_THEME'].'/';
  15. $this->publicpath = TMPL_PATH.'Home/'.$this->sysConfig['DEFAULT_THEME'].'/Public/';
  16. $this->tplpath = TMPL_PATH.'Home/';
  17. }
  18. public function index()
  19. {
  20. $filed = glob($this->tplpath.'*');
  21. foreach ($filed as $key=>$v) {
  22. $arr[$key]['name'] = basename($v);
  23. if(is_file($this->tplpath.$arr[$key]['name'].'/preview.jpg')){
  24. $arr[$key]['preview']=$this->tplpath.$arr[$key]['name'].'/preview.jpg';
  25. }else{
  26. $arr[$key]['preview']=__ROOT__.'/Public/Images/nopic.jpg';
  27. }
  28. if($this->sysConfig['DEFAULT_THEME']==$arr[$key]['name']) $arr[$key]['use']=1;
  29. }
  30. $this->assign ( 'themes',$arr );
  31. $this->display ();
  32. }
  33. public function chose()
  34. {
  35. $theme = $_GET['theme'];
  36. if($theme){
  37. $Model = M('Config');
  38. $r = $Model->where("varname='DEFAULT_THEME'")->setField('value',$theme);
  39. savecache('Config');
  40. $this->success(L('do_ok'));
  41. }else{
  42. $this->error(L('do_empty'));
  43. }
  44. }
  45. public function upload()
  46. {
  47. $this->display ();
  48. }
  49. }
  50. ?>