国内流行的内容管理系统(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.

235 lines
7.5KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 视图
  5. *
  6. * @version $id:partview.class.php 14:17 2010年7月7日 tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(DEDEINC.'/channelunit.class.php');
  13. require_once(DEDEINC.'/typelink/typelink.class.php');
  14. class PartView
  15. {
  16. var $dsql;
  17. var $dtp;
  18. var $TypeID;
  19. var $Fields;
  20. var $TypeLink;
  21. var $pvCopy;
  22. var $refObj;
  23. var $remoteDir;
  24. /**
  25. * php5构造函数
  26. *
  27. * @access public
  28. * @param int $typeid 栏目id
  29. * @param int $needtypelink 是否需要栏目连接
  30. * @return void
  31. */
  32. function __construct($typeid = 0, $needtypelink = TRUE)
  33. {
  34. global $_sys_globals;
  35. $this->TypeID = $typeid;
  36. $this->dsql = $GLOBALS['dsql'];
  37. $this->dtp = new DedeTagParse();
  38. $this->dtp->SetNameSpace("dede", "{", "}");
  39. $this->dtp->SetRefObj($this);
  40. $this->remoteDir = '';
  41. if ($needtypelink) {
  42. $this->TypeLink = new TypeLink($typeid);
  43. if (is_array($this->TypeLink->TypeInfos)) {
  44. foreach ($this->TypeLink->TypeInfos as $k => $v) {
  45. if (preg_match("/[^0-9]/", $k)) {
  46. $this->Fields[$k] = $v;
  47. }
  48. }
  49. }
  50. $_sys_globals['curfile'] = 'partview';
  51. @$_sys_globals['typename'] = $this->Fields['typename'];
  52. //设置环境变量
  53. @SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'partview');
  54. }
  55. SetSysEnv($this->TypeID, '', 0, '', 'partview');
  56. $this->Fields['typeid'] = $this->TypeID;
  57. //设置一些全局参数的值
  58. foreach ($GLOBALS['PubFields'] as $k => $v) {
  59. $this->Fields[$k] = $v;
  60. }
  61. }
  62. //php4构造函数
  63. function PartView($typeid = 0, $needtypelink = TRUE)
  64. {
  65. $this->__construct($typeid, $needtypelink);
  66. }
  67. /**
  68. * 重新指定引入的对象
  69. *
  70. * @access private
  71. * @param object $refObj 引用对象
  72. * @return void
  73. */
  74. function SetRefObj(&$refObj)
  75. {
  76. $this->dtp->SetRefObj($refObj);
  77. if (isset($refObj->TypeID)) {
  78. $this->__construct($refObj->TypeID);
  79. }
  80. }
  81. /**
  82. * 指定typelink对象给当前类实例
  83. *
  84. * @access public
  85. * @param object $typelink 栏目链接
  86. * @return string
  87. */
  88. function SetTypeLink(&$typelink)
  89. {
  90. $this->TypeLink = $typelink;
  91. if (is_array($this->TypeLink->TypeInfos)) {
  92. foreach ($this->TypeLink->TypeInfos as $k => $v) {
  93. if (preg_match("/[^0-9]/", $k)) {
  94. $this->Fields[$k] = $v;
  95. }
  96. }
  97. }
  98. }
  99. /**
  100. * 设置要解析的模板
  101. *
  102. * @access public
  103. * @param string $temp 模板
  104. * @param string $stype 设置类型
  105. * @return string
  106. */
  107. function SetTemplet($temp, $stype = "file")
  108. {
  109. if ($stype == "string") {
  110. $this->dtp->LoadSource($temp);
  111. } else {
  112. $this->dtp->LoadTemplet($temp);
  113. }
  114. if ($this->TypeID > 0) {
  115. $this->Fields['position'] = $this->TypeLink->GetPositionLink(TRUE);
  116. $this->Fields['title'] = $this->TypeLink->GetPositionLink(false);
  117. }
  118. $this->ParseTemplet();
  119. }
  120. /**
  121. * 显示文档
  122. *
  123. * @access public
  124. * @return void
  125. */
  126. function Display()
  127. {
  128. $this->dtp->Display();
  129. }
  130. /**
  131. * 获取文档
  132. *
  133. * @access public
  134. * @return string
  135. */
  136. function GetResult()
  137. {
  138. return $this->dtp->GetResult();
  139. }
  140. /**
  141. * 保存结果为文件
  142. *
  143. * @access public
  144. * @param string $filename 文件名
  145. * @param string $isremote 是否远程
  146. * @return string
  147. */
  148. function SaveToHtml($filename, $isremote = 0)
  149. {
  150. $this->dtp->SaveTo($filename);
  151. }
  152. /**
  153. * 解析模板里的标签
  154. *
  155. * @access private
  156. * @return void
  157. */
  158. function ParseTemplet()
  159. {
  160. $GLOBALS['envs']['typeid'] = $this->TypeID;
  161. if ($this->TypeID > 0) {
  162. $GLOBALS['envs']['topid'] = GetTopid($this->TypeID);
  163. } else {
  164. $GLOBALS['envs']['topid'] = 0;
  165. }
  166. if (isset($this->TypeLink->TypeInfos['reid'])) {
  167. $GLOBALS['envs']['reid'] = $this->TypeLink->TypeInfos['reid'];
  168. }
  169. if (isset($this->TypeLink->TypeInfos['channeltype'])) {
  170. $GLOBALS['envs']['channelid'] = $this->TypeLink->TypeInfos['channeltype'];
  171. }
  172. MakeOneTag($this->dtp, $this); //这个函数放在 channelunit.func.php 文件中
  173. }
  174. /**
  175. * 获得限定模型或栏目的一个指定文档列表
  176. * 这个标记由于使用了缓存,并且处理数据是支持分表模式的,因此速度更快,但不能进行整站的数据调用
  177. * @param string $templets
  178. * @param int $typeid
  179. * @param int $row
  180. * @param int $col
  181. * @param int $titlelen
  182. * @param int $infolen
  183. * @param int $imgwidth
  184. * @param int $imgheight
  185. * @param string $listtype
  186. * @param string $orderby
  187. * @param string $keyword
  188. * @param string $innertext
  189. * @param int $tablewidth
  190. * @param int $arcid
  191. * @param string $idlist
  192. * @param int $channelid
  193. * @param string $limit
  194. * @param int $att
  195. * @param string $order
  196. * @param int $subday
  197. * @param int $autopartid
  198. * @param int $ismember
  199. * @param string $maintable
  200. * @param object $ctag
  201. * @return array
  202. */
  203. function GetArcList($templets='',$typeid = 0,$row = 10,$col = 1,$titlelen = 30,$infolen = 160,$imgwidth = 120,$imgheight = 90,$listtype = "all",$orderby = "default",$keyword = "",$innertext = "",$tablewidth = "100",$arcid = 0,$idlist = "",$channelid = 0,$limit = "",$att = 0,$order = 'desc',$subday = 0,$autopartid = -1,$ismember = 0,$maintable = '',$ctag = '') {
  204. if (empty($autopartid)) {
  205. $autopartid = -1;
  206. }
  207. if (empty($typeid)) {
  208. $typeid = $this->TypeID;
  209. }
  210. if ($autopartid != -1) {
  211. $typeid = $this->GetAutoChannelID($autopartid, $typeid);
  212. if ($typeid == 0) {
  213. return "";
  214. }
  215. }
  216. if (!isset($GLOBALS['__SpGetArcList'])) {
  217. require_once(dirname(__FILE__)."/inc/inc_fun_SpGetArcList.php");
  218. }
  219. return SpGetArcList($this->dsql,$templets,$typeid,$row,$col,$titlelen,$infolen,$imgwidth,$imgheight,$listtype,$orderby,$keyword,$innertext,$tablewidth,$arcid,$idlist,$channelid,$limit,$att,$order,$subday,$ismember,$maintable,$ctag);
  220. }
  221. function GetAutoChannelID($sortid, $topid)
  222. {
  223. global $dsql;
  224. if (empty($sortid)) $sortid = 1;
  225. $getstart = $sortid - 1;
  226. $row = $dsql->GetOne("SELECT id,typename FROM `#@__arctype` WHERE reid='{$topid}' And ispart<2 And ishidden<>'1' ORDER BY sortrank asc limit $getstart,1");
  227. if (!is_array($row)) return 0;
  228. else return $row['id'];
  229. }
  230. //关闭所占用的资源
  231. function Close()
  232. {
  233. }
  234. }//End Class
  235. ?>