国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

280 рядки
7.6KB

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