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

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