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

282 lines
7.8KB

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