国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
2.7KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 自定义模型视图
  5. *
  6. * @version $id:sgpage.class.php 15:48 2010年7月7日 tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license https://www.dedebiz.com/license
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(DEDEINC."/archive/partview.class.php");
  13. class sgpage
  14. {
  15. var $dsql;
  16. var $dtp;
  17. var $TypeID;
  18. var $Fields;
  19. var $TypeLink;
  20. var $partView;
  21. /**
  22. * php5构造函数
  23. *
  24. * @access public
  25. * @param int $aid 文档id
  26. * @return string
  27. */
  28. function __construct($aid)
  29. {
  30. global $cfg_basedir, $cfg_templets_dir, $cfg_df_style, $envs;
  31. $this->dsql = $GLOBALS['dsql'];
  32. $this->dtp = new DedeTagParse();
  33. $this->dtp->refObj = $this;
  34. $this->dtp->SetNameSpace("dede", "{", "}");
  35. $this->Fields = $this->dsql->GetOne("SELECT * FROM `#@__sgpage` WHERE aid='$aid' ");
  36. $envs['aid'] = $this->Fields['aid'];
  37. //设置一些全局参数的值
  38. foreach ($GLOBALS['PubFields'] as $k => $v) {
  39. $this->Fields[$k] = $v;
  40. }
  41. if ($this->Fields['ismake'] == 1) {
  42. $pv = new PartView();
  43. $pv->SetTemplet($this->Fields['body'], 'string');
  44. $this->Fields['body'] = $pv->GetResult();
  45. }
  46. $tplfile = $cfg_basedir.str_replace('{style}', $cfg_templets_dir.'/'.$cfg_df_style, $this->Fields['template']);
  47. $this->dtp->LoadTemplate($tplfile);
  48. $this->ParseTemplet();
  49. }
  50. //php4构造函数
  51. function sgpage($aid)
  52. {
  53. $this->__construct($aid);
  54. }
  55. /**
  56. * 显示文档
  57. *
  58. * @access public
  59. * @return void
  60. */
  61. function Display()
  62. {
  63. $this->dtp->Display();
  64. }
  65. /**
  66. * 获取文档
  67. *
  68. * @access public
  69. * @return void
  70. */
  71. function GetResult()
  72. {
  73. return $this->dtp->GetResult();
  74. }
  75. /**
  76. * 保存结果为文件
  77. *
  78. * @access public
  79. * @return void
  80. */
  81. function SaveToHtml()
  82. {
  83. $filename = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_cmspath'].'/'.$this->Fields['filename'];
  84. $filename = preg_replace("/\/{1,}/", '/', $filename);
  85. $this->dtp->SaveTo($filename);
  86. }
  87. /**
  88. * 解析模板里的标签
  89. *
  90. * @access public
  91. * @return string
  92. */
  93. function ParseTemplet()
  94. {
  95. $GLOBALS['envs']['likeid'] = $this->Fields['likeid'];
  96. MakeOneTag($this->dtp, $this);
  97. }
  98. //关闭所占用的资源
  99. function Close()
  100. {
  101. }
  102. }//End Class
  103. ?>