template.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. defined('IN_PHPCMS') or exit('No permission resources.');
  3. pc_base::load_app_class('admin','admin',0);
  4. pc_base::load_app_func('global', 'special');
  5. class template extends admin {
  6. private $db;
  7. public function __construct() {
  8. parent::__construct();
  9. $this->db = pc_base::load_model('special_model');
  10. }
  11. /**
  12. * 编辑专题首页模板
  13. */
  14. public function init() {
  15. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
  16. $specialid = isset($_GET['specialid']) && intval($_GET['specialid']) ? intval($_GET['specialid']) : showmessage(L('illegal_action'), HTTP_REFERER);;
  17. if (!$specialid) showmessage(L('illegal_action'), HTTP_REFERER);
  18. $info = $this->db->get_one(array('id'=>$specialid, 'disabled'=>'0', 'siteid'=>$this->get_siteid()));
  19. if (!$info['id']) showmessage(L('illegal_parameters'), HTTP_REFERER);
  20. $id = $specialid;
  21. if($info['css']) $css_param = unserialize($info['css']);
  22. if(!$info['ispage']) {
  23. $type_db = pc_base::load_model('type_model');
  24. $types = $type_db->select(array('module'=>'special', 'parentid'=>$id), '*', '', '`listorder` ASC, `typeid` ASC');
  25. }
  26. extract($info);
  27. $css = get_css($css_param);
  28. $template = $info['index_template'] ? $info['index_template'] : 'index';
  29. pc_base::load_app_func('global', 'template');
  30. ob_start();
  31. include template('special', $template);
  32. $html = ob_get_contents();
  33. ob_clean();
  34. $html = visualization($html, 'default', 'test', 'block.html');
  35. include $this->admin_tpl('template_edit');
  36. }
  37. /**
  38. * css编辑预览
  39. */
  40. public function preview() {
  41. define('HTML', true);
  42. if (!$_GET['specialid']) showmessage(L('illegal_action'), HTTP_REFERER);
  43. $info = $this->db->get_one(array('id'=>$_GET['specialid'], 'disabled'=>'0', 'siteid'=>$this->get_siteid()));
  44. if (!$info['id']) showmessage(L('illegal_parameters'), HTTP_REFERER);
  45. $css = get_css($_POST['info']);
  46. $template = $info['index_template'] ? $info['index_template'] : 'index';
  47. include template('special', $template);
  48. }
  49. /**
  50. * css添加
  51. */
  52. public function add() {
  53. if (!$_GET['specialid']) showmessage(L('illegal_action'), HTTP_REFERER);
  54. $info = $this->db->get_one(array('id'=>$_GET['specialid'], 'disabled'=>'0', 'siteid'=>$this->get_siteid()));
  55. if (!$info['id']) showmessage(L('illegal_parameters'), HTTP_REFERER);
  56. $data = serialize($_POST['info']);
  57. $this->db->update(array('css'=>$data), array('id'=>$info['id']));
  58. showmessage(L('operation_success'), HTTP_REFERER);
  59. }
  60. }
  61. ?>