国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

297 lines
7.9KB

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