国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

300 行
8.0KB

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