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

668 lines
27KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * Tag列表类
  5. *
  6. * @version $Id: taglist.class.php 1 18: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. @set_time_limit(0);
  15. /**
  16. * Tag列表类
  17. *
  18. * @package TagList
  19. * @subpackage DedeBIZ.Libraries
  20. * @link https://www.dedebiz.com
  21. */
  22. class TagList
  23. {
  24. var $dsql;
  25. var $dtp;
  26. var $dtp2;
  27. var $TypeLink;
  28. var $PageNo;
  29. var $TotalPage;
  30. var $TotalResult;
  31. var $pagesize;
  32. var $ListType;
  33. var $Fields;
  34. var $Tag;
  35. var $Templet;
  36. var $TagInfos;
  37. var $TempletsFile;
  38. var $tagsDir;
  39. /**
  40. * php5构造函数
  41. *
  42. * @access public
  43. * @param string $keyword 关键词
  44. * @param string $templet 模板
  45. * @return void
  46. */
  47. function __construct($keyword, $templet)
  48. {
  49. global $dsql,$envs,$cfg_cmsurl;
  50. $this->Templet = $templet;
  51. $this->Tag = (int)$keyword;
  52. $this->dsql = $dsql;
  53. $this->dtp = new DedeTagParse();
  54. $this->dtp->SetRefObj($this);
  55. $this->dtp->SetNameSpace("dede", "{", "}");
  56. $this->dtp2 = new DedeTagParse();
  57. $this->dtp2->SetNameSpace("field", "[", "]");
  58. $this->TypeLink = new TypeLink(0);
  59. $this->Fields['tag'] = $keyword;
  60. if (empty($keyword)) {
  61. $this->Fields['title'] = "TAGS列表";
  62. }
  63. $this->Fields['position'] = $cfg_cmsurl."/apps/tags.php";
  64. $this->TempletsFile = '';
  65. //设置一些全局参数的值
  66. foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
  67. //读取Tag信息
  68. if (!empty($this->Tag)) {
  69. $this->TagInfos = $this->dsql->GetOne("Select * From `#@__tagindex` where id = '{$this->Tag}' ");
  70. if (!is_array($this->TagInfos)) {
  71. $msg = "系统无此标签,可能已经移除";
  72. ShowMsg($msg, "-1");
  73. exit();
  74. }
  75. $this->Fields['title'] = empty($this->TagInfos['title']) ? $this->TagInfos['tag'] : $this->TagInfos['title'];
  76. $this->Fields['keywords'] = empty($this->TagInfos['keywords']) ? $this->Fields['keywords'] : $this->TagInfos['keywords'];
  77. $this->Fields['description'] = empty($this->TagInfos['description']) ? $this->Fields['description'] : $this->TagInfos['description'];
  78. }
  79. //初始化模板
  80. $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style'].'/'.$this->Templet;
  81. if (!file_exists($tempfile) || !is_file($tempfile)) {
  82. echo "模板文件不存在,无法解析文档";
  83. exit();
  84. }
  85. $this->dtp->LoadTemplate($tempfile);
  86. $this->TempletsFile = preg_replace("#^".$GLOBALS['cfg_basedir']."#", '', $tempfile);
  87. $envs['url_type'] = 4;
  88. $envs['value'] = $keyword;
  89. }
  90. //php4构造函数
  91. function TagList($keyword, $templet)
  92. {
  93. $this->__construct($keyword, $templet);
  94. }
  95. //关闭相关资源
  96. function Close()
  97. {
  98. @$this->TypeLink->Close();
  99. @$this->dsql->Close();
  100. }
  101. /**
  102. * 统计列表里的记录
  103. *
  104. * @access private
  105. * @return void
  106. */
  107. function CountRecord()
  108. {
  109. //统计数据库记录
  110. $this->TotalResult = -1;
  111. if (isset($GLOBALS['TotalResult'])) {
  112. $this->TotalResult = $GLOBALS['TotalResult'];
  113. }
  114. if (isset($GLOBALS['PageNo'])) {
  115. $this->PageNo = intval($GLOBALS['PageNo']);
  116. } else {
  117. $this->PageNo = 1;
  118. }
  119. if ($this->TotalResult == -1) {
  120. $cquery = "SELECT COUNT(*) AS dd FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank >-1 ";
  121. $row = $this->dsql->GetOne($cquery);
  122. $this->TotalResult = $row['dd'];
  123. //更新Tag信息
  124. $ntime = time();
  125. //更新浏览量和记录数
  126. $upquery = "UPDATE `#@__tagindex` SET total='{$row['dd']}',count=count+1,weekcc=weekcc+1,monthcc=monthcc+1 WHERE tag LIKE '{$this->Tag}' ";
  127. $this->dsql->ExecuteNoneQuery($upquery);
  128. $oneday = 24 * 3600;
  129. //周统计
  130. if (ceil(($ntime - $this->TagInfos['weekup']) / $oneday) > 7) {
  131. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET weekcc=0,weekup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  132. }
  133. //月统计
  134. if (ceil(($ntime - $this->TagInfos['monthup']) / $oneday) > 30) {
  135. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET monthcc=0,monthup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  136. }
  137. }
  138. $ctag = $this->dtp->GetTag("page");
  139. if (!is_object($ctag)) {
  140. $ctag = $this->dtp->GetTag("list");
  141. }
  142. if (!is_object($ctag)) {
  143. $this->pagesize = 30;
  144. } else {
  145. if ($ctag->GetAtt("pagesize") != '') {
  146. $this->pagesize = $ctag->GetAtt("pagesize");
  147. } else {
  148. $this->pagesize = 30;
  149. }
  150. }
  151. $this->TotalPage = ceil($this->TotalResult / $this->pagesize);
  152. }
  153. /**
  154. * 显示列表
  155. *
  156. * @access public
  157. * @return void
  158. */
  159. function Display()
  160. {
  161. global $cfg_cmspath,$cfg_tags_dir;
  162. $tagsDir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir);
  163. $makeDir = empty($this->Tag) ? $this->GetTruePath().$tagsDir."/index.html" : $this->GetTruePath().$tagsDir."/".$this->Tag."/index.html";
  164. if ($this->Tag != '') {
  165. $this->CountRecord();
  166. }
  167. $this->ParseTempletsFirst();
  168. if ($this->Tag != '') {
  169. if ($this->PageNo == 0) {
  170. $this->PageNo = 1;
  171. }
  172. $this->ParseDMFields($this->PageNo, 0);
  173. }
  174. $this->dtp->Display();
  175. //$this->Close();
  176. }
  177. /**
  178. * 解析模板,对固定的标记进行初始给值
  179. *
  180. * @access private
  181. * @return void
  182. */
  183. function ParseTempletsFirst()
  184. {
  185. MakeOneTag($this->dtp, $this);
  186. }
  187. /**
  188. * 解析模板,对内容里的变动进行赋值
  189. *
  190. * @access public
  191. * @param int $PageNo 页码
  192. * @param int $ismake 是否编译
  193. * @return string
  194. */
  195. function ParseDMFields($PageNo, $ismake = 1)
  196. {
  197. foreach ($this->dtp->CTags as $tagid => $ctag) {
  198. if ($ctag->GetName() == "list") {
  199. $limitstart = (intval($this->PageNo) - 1) * $this->pagesize;
  200. if ($limitstart < 0) {
  201. $limitstart = 0;
  202. }
  203. $row = $this->pagesize;
  204. if (trim($ctag->GetInnerText()) == "") {
  205. $InnerText = GetSysTemplets("list_fulllist.htm");
  206. } else {
  207. $InnerText = trim($ctag->GetInnerText());
  208. }
  209. $this->dtp->Assign(
  210. $tagid,
  211. $this->GetArcList(
  212. $limitstart,
  213. $row,
  214. $ctag->GetAtt("col"),
  215. $ctag->GetAtt("titlelen"),
  216. $ctag->GetAtt("infolen"),
  217. $ctag->GetAtt("imgwidth"),
  218. $ctag->GetAtt("imgheight"),
  219. $ctag->GetAtt("listtype"),
  220. $ctag->GetAtt("orderby"),
  221. $InnerText,
  222. $ctag->GetAtt("tablewidth"),
  223. $ismake,
  224. $ctag->GetAtt("orderway")
  225. )
  226. );
  227. } else if ($ctag->GetName() == "pagelist") {
  228. $list_len = trim($ctag->GetAtt("listsize"));
  229. $ctag->GetAtt("listitem") == "" ? $listitem = "info,index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem");
  230. if ($list_len == "") {
  231. $list_len = 3;
  232. }
  233. //var_dump($ismake);
  234. if ($ismake == 0) {
  235. $this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem));
  236. } else {
  237. $this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem));
  238. }
  239. }
  240. }
  241. }
  242. /**
  243. * 获得一个单列的文档列表
  244. *
  245. * @access public
  246. * @param int $limitstart 限制开始
  247. * @param int $row 行数
  248. * @param int $col 列数
  249. * @param int $titlelen 标题长度
  250. * @param int $infolen 描述长度
  251. * @param int $imgwidth 图片宽度
  252. * @param int $imgheight 图片高度
  253. * @param string $listtype 列表类型
  254. * @param string $orderby 排列顺序
  255. * @param string $innertext 底层模板
  256. * @param string $tablewidth 表格宽度
  257. * @param string $ismake 是否编译
  258. * @param string $orderWay 排序方式
  259. * @return string
  260. */
  261. function GetArcList(
  262. $limitstart = 0,
  263. $row = 10,
  264. $col = 1,
  265. $titlelen = 30,
  266. $infolen = 250,
  267. $imgwidth = 120,
  268. $imgheight = 90,
  269. $listtype = "all",
  270. $orderby = "default",
  271. $innertext = "",
  272. $tablewidth = "100",
  273. $ismake = 1,
  274. $orderWay = 'desc'
  275. ) {
  276. $getrow = ($row == '' ? 10 : $row);
  277. if ($limitstart == '') $limitstart = 0;
  278. if ($titlelen == '') $titlelen = 100;
  279. if ($infolen == '') $infolen = 250;
  280. if ($imgwidth == '') $imgwidth = 120;
  281. if ($imgheight == '') $imgheight = 120;
  282. if ($listtype == '') $listtype = 'all';
  283. $orderby = ($orderby == '' ? 'default' : strtolower($orderby));
  284. if ($orderWay == '') $orderWay = 'desc';
  285. $tablewidth = str_replace("%", "", $tablewidth);
  286. if ($tablewidth == '') $tablewidth = 100;
  287. if ($col == '') $col = 1;
  288. $colWidth = ceil(100 / $col);
  289. $tablewidth = $tablewidth."%";
  290. $colWidth = $colWidth."%";
  291. $innertext = trim($innertext);
  292. if ($innertext == '') $innertext = GetSysTemplets("list_fulllist.htm");
  293. $idlists = $ordersql = '';
  294. $this->dsql->SetQuery("SELECT aid FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank>-1 LIMIT $limitstart,$getrow");
  295. $this->dsql->Execute();
  296. while ($row = $this->dsql->GetArray()) {
  297. $idlists .= ($idlists == '' ? $row['aid'] : ','.$row['aid']);
  298. }
  299. if ($idlists == '') return '';
  300. //按不同情况设定SQL条件
  301. $orwhere = " se.id IN($idlists) ";
  302. //排序方式
  303. if ($orderby == "sortrank") {
  304. $ordersql = " ORDER BY se.sortrank $orderWay";
  305. } else {
  306. $ordersql = " ORDER BY se.id $orderWay";
  307. }
  308. $query = "SELECT se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  309. FROM `#@__archives` se LEFT JOIN `#@__arctype` tp ON se.typeid=tp.id WHERE $orwhere $ordersql ";
  310. $this->dsql->SetQuery($query);
  311. $this->dsql->Execute('al');
  312. $row = $this->pagesize / $col;
  313. $artlist = '';
  314. $this->dtp2->LoadSource($innertext);
  315. $GLOBALS['autoindex'] = 0;
  316. for ($i = 0; $i < $row; $i++) {
  317. if ($col > 1) {
  318. $artlist .= "<div>\r\n";
  319. }
  320. for ($j = 0; $j < $col; $j++) {
  321. if ($row = $this->dsql->GetArray("al")) {
  322. $GLOBALS['autoindex']++;
  323. $ids[$row['id']] = $row['id'];
  324. //处理一些特殊字段
  325. $row['infos'] = cn_substr($row['description'], $infolen);
  326. $row['id'] = $row['id'];
  327. $row['arcurl'] = GetFileUrl(
  328. $row['id'],
  329. $row['typeid'],
  330. $row['senddate'],
  331. $row['title'],
  332. $row['ismake'],
  333. $row['arcrank'],
  334. $row['namerule'],
  335. $row['typedir'],
  336. $row['money'],
  337. $row['filename'],
  338. $row['moresite'],
  339. $row['siteurl'],
  340. $row['sitepath']
  341. );
  342. $row['typeurl'] = GetTypeUrl(
  343. $row['typeid'],
  344. MfTypedir($row['typedir']),
  345. $row['isdefault'],
  346. $row['defaultname'],
  347. $row['ispart'],
  348. $row['namerule2'],
  349. $row['moresite'],
  350. $row['siteurl'],
  351. $row['sitepath']
  352. );
  353. if ($row['litpic'] == '-' || $row['litpic'] == '') {
  354. $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/defaultpic.jpg';
  355. }
  356. if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
  357. $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
  358. }
  359. $row['picname'] = $row['litpic'];
  360. $row['stime'] = GetDateMK($row['pubdate']);
  361. $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
  362. $row['image'] = "<img src='".$row['picname']."' width='$imgwidth' height='$imgheight' title='".preg_replace("/['><]/", "", $row['title'])."'>";
  363. $row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
  364. $row['fulltitle'] = $row['title'];
  365. $row['title'] = cn_substr($row['title'], $titlelen);
  366. if ($row['color'] != '') {
  367. $row['title'] = "<span style='color:".$row['color']."'>".$row['title']."</span>";
  368. }
  369. if (preg_match('/c/', $row['flag'])) {
  370. $row['title'] = "".$row['title']."";
  371. }
  372. $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
  373. $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  374. $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  375. $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  376. if (is_array($this->dtp2->CTags)) {
  377. foreach ($this->dtp2->CTags as $k => $ctag) {
  378. if ($ctag->GetName() == 'array') {
  379. //传递整个数组,在runphp模式中有特殊作用
  380. $this->dtp2->Assign($k, $row);
  381. } else {
  382. if (isset($row[$ctag->GetName()])) {
  383. $this->dtp2->Assign($k, $row[$ctag->GetName()]);
  384. } else {
  385. $this->dtp2->Assign($k, '');
  386. }
  387. }
  388. }
  389. }
  390. $artlist .= $this->dtp2->GetResult();
  391. } //if hasRow
  392. } //Loop Col
  393. if ($col > 1) {
  394. $i += $col - 1;
  395. $artlist .= " </div>\r\n";
  396. }
  397. } //Loop Line
  398. $this->dsql->FreeResult('al');
  399. return $artlist;
  400. }
  401. /**
  402. * 获取动态的分页列表
  403. *
  404. * @access public
  405. * @param int $list_len 列表宽度
  406. * @param string $listitem 列表样式
  407. * @return string
  408. */
  409. function GetPageListDM($list_len, $listitem = "info,index,end,pre,next,pageno")
  410. {
  411. $prepage = "";
  412. $nextpage = "";
  413. $prepagenum = $this->PageNo - 1;
  414. $nextpagenum = $this->PageNo + 1;
  415. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  416. $list_len = 3;
  417. }
  418. $totalpage = $this->TotalPage;
  419. if ($totalpage <= 1 && $this->TotalResult > 0) {
  420. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>";
  421. }
  422. if ($this->TotalResult == 0) {
  423. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
  424. }
  425. $maininfo = "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n";
  426. $purl = $this->GetCurUrl();
  427. $purl .= "?/".urlencode($this->Tag);
  428. //获得上一页和下一页的链接
  429. if ($this->PageNo != 1) {
  430. $prepage .= "<li class='page-item'><a class='page-link' href='".$purl."/$prepagenum/'>上一页</a></li>\r\n";
  431. $indexpage = "<li class='page-item'><a class='page-link' href='".$purl."/1/'>首页</a></li>\r\n";
  432. } else {
  433. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  434. }
  435. if ($this->PageNo != $totalpage && $totalpage > 1) {
  436. $nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."/$nextpagenum/'>下一页</a></li>\r\n";
  437. $endpage = "<li class='page-item'><a class='page-link' href='".$purl."/$totalpage/'>末页</a></li>\r\n";
  438. } else {
  439. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  440. }
  441. //获得数字链接
  442. $listdd = "";
  443. $total_list = $list_len * 2 + 1;
  444. if ($this->PageNo >= $total_list) {
  445. $j = $this->PageNo - $list_len;
  446. $total_list = $this->PageNo + $list_len;
  447. if ($total_list > $totalpage) {
  448. $total_list = $totalpage;
  449. }
  450. } else {
  451. $j = 1;
  452. if ($total_list > $totalpage) {
  453. $total_list = $totalpage;
  454. }
  455. }
  456. for ($j; $j <= $total_list; $j++) {
  457. if ($j == $this->PageNo) {
  458. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>\r\n";
  459. } else {
  460. $listdd .= "<li class='page-item'><a class='page-link' href='".$purl."/$j/'>".$j."</a></li>\r\n";
  461. }
  462. }
  463. $plist = '';
  464. if (preg_match('/info/i', $listitem)) {
  465. $plist .= $maininfo.' ';
  466. }
  467. if (preg_match('/index/i', $listitem)) {
  468. $plist .= $indexpage.' ';
  469. }
  470. if (preg_match('/pre/i', $listitem)) {
  471. $plist .= $prepage.' ';
  472. }
  473. if (preg_match('/pageno/i', $listitem)) {
  474. $plist .= $listdd.' ';
  475. }
  476. if (preg_match('/next/i', $listitem)) {
  477. $plist .= $nextpage.' ';
  478. }
  479. if (preg_match('/end/i', $listitem)) {
  480. $plist .= $endpage.' ';
  481. }
  482. return $plist;
  483. }
  484. function GetPageListST($list_len, $listitem = "info,index,end,pre,next,pageno")
  485. {
  486. $prepage = "";
  487. $nextpage = "";
  488. $prepagenum = intval($this->PageNo) - 1;
  489. $nextpagenum = intval($this->PageNo) + 1;
  490. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  491. $list_len = 3;
  492. }
  493. $totalpage = $this->TotalPage;
  494. if ($totalpage <= 1 && $this->TotalResult > 0) {
  495. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>";
  496. }
  497. if ($this->TotalResult == 0) {
  498. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
  499. }
  500. $maininfo = "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n";
  501. $purl = $this->tagsDir.'/'.$this->TagInfos['id'];
  502. //获得上一页和下一页的链接
  503. if ($this->PageNo != 1) {
  504. $prepage .= "<li class='page-item'><a class='page-link' href='".$purl."/$prepagenum/'>上一页</a></li>\r\n";
  505. $indexpage = "<li class='page-item'><a class='page-link' href='".$purl."/1/'>首页</a></li>\r\n";
  506. } else {
  507. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  508. }
  509. if ($this->PageNo != $totalpage && $totalpage > 1) {
  510. $nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."/$nextpagenum/'>下一页</a></li>\r\n";
  511. $endpage = "<li class='page-item'><a class='page-link' href='".$purl."/$totalpage/'>末页</a></li>\r\n";
  512. } else {
  513. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  514. }
  515. //获得数字链接
  516. $listdd = "";
  517. $total_list = $list_len * 2 + 1;
  518. if ($this->PageNo >= $total_list) {
  519. $j = $this->PageNo - $list_len;
  520. $total_list = $this->PageNo + $list_len;
  521. if ($total_list > $totalpage) {
  522. $total_list = $totalpage;
  523. }
  524. } else {
  525. $j = 1;
  526. if ($total_list > $totalpage) {
  527. $total_list = $totalpage;
  528. }
  529. }
  530. for ($j; $j <= $total_list; $j++) {
  531. if ($j == $this->PageNo) {
  532. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>\r\n";
  533. } else {
  534. $listdd .= "<li class='page-item'><a class='page-link' href='".$purl."/$j/'>".$j."</a></li>\r\n";
  535. }
  536. }
  537. $plist = "";
  538. if (preg_match('/info/i', $listitem)) {
  539. $plist .= $maininfo.' ';
  540. }
  541. if (preg_match('/index/i', $listitem)) {
  542. $plist .= $indexpage.' ';
  543. }
  544. if (preg_match('/pre/i', $listitem)) {
  545. $plist .= $prepage.' ';
  546. }
  547. if (preg_match('/pageno/i', $listitem)) {
  548. $plist .= $listdd.' ';
  549. }
  550. if (preg_match('/next/i', $listitem)) {
  551. $plist .= $nextpage.' ';
  552. }
  553. if (preg_match('/end/i', $listitem)) {
  554. $plist .= $endpage.' ';
  555. }
  556. return $plist;
  557. }
  558. function GetTruePath()
  559. {
  560. $truepath = $GLOBALS["cfg_basedir"];
  561. return $truepath;
  562. }
  563. function SetTagsDir($dir = '')
  564. {
  565. global $cfg_tags_dir,$cfg_cmspath;
  566. if ($dir == "") $dir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir);
  567. $this->tagsDir = $dir;
  568. }
  569. //生成静态Tag
  570. function MakeHtml($startpage = 1, $makepagesize = 0)
  571. {
  572. global $cfg_dir_purview,$envs,$cfg_cmspath,$cfg_tags_dir,$cfg_cmsurl;
  573. $envs['makeTag'] = 1;
  574. $tagsdir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir);
  575. if (isset($envs['makeTag']) && $envs['makeTag'] == 1) {
  576. $this->Fields['position'] = $cfg_cmsurl.$tagsdir."/";
  577. }
  578. if (empty($this->TotalResult) && $this->Tag != "") $this->CountRecord();
  579. //初步给固定值的标记赋值
  580. $this->ParseTempletsFirst();
  581. if ($this->Tag == "") {
  582. MkdirAll($this->GetTruePath().$this->tagsDir, $cfg_dir_purview);
  583. $this->dtp->SaveTo($this->GetTruePath().$this->tagsDir."/index.html");
  584. } else {
  585. $totalpage = ceil($this->TotalResult / $this->pagesize);
  586. if ($totalpage == 0) {
  587. $totalpage = 1;
  588. }
  589. if ($makepagesize > 0) {
  590. $endpage = $startpage + $makepagesize;
  591. } else {
  592. $endpage = ($totalpage + 1);
  593. }
  594. if ($endpage >= $totalpage + 1) {
  595. $endpage = $totalpage + 1;
  596. }
  597. if ($endpage == 1) {
  598. $endpage = 2;
  599. }
  600. $makeDir = $this->GetTruePath().$this->tagsDir.'/'.$this->TagInfos['id']."/";
  601. MkdirAll($makeDir, $cfg_dir_purview);
  602. for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
  603. $this->ParseDMFields($this->PageNo, 1);
  604. $fileDir = $makeDir."/".$this->PageNo;
  605. MkdirAll($fileDir, $cfg_dir_purview);
  606. $this->dtp->SaveTo($fileDir."/index.html");
  607. }
  608. if ($startpage == 1) {
  609. $list_1 = $makeDir."/1/index.html";
  610. copy($list_1, $makeDir."/index.html");
  611. }
  612. }
  613. }
  614. /**
  615. * 获得一个指定的频道的链接
  616. *
  617. * @access private
  618. * @param int $typeid 栏目id
  619. * @param string $typedir 栏目目录
  620. * @param int $isdefault 是否为默认
  621. * @param string $defaultname 默认名称
  622. * @param int $ispart 栏目属性
  623. * @param string $namerule2 栏目规则
  624. * @param string $siteurl 站点地址
  625. * @return string
  626. */
  627. function GetListUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $siteurl = "")
  628. {
  629. return GetTypeUrl($typeid, MfTypedir($typedir), $isdefault, $defaultname, $ispart, $namerule2, $siteurl);
  630. }
  631. /**
  632. * 获得一个指定档案的链接
  633. *
  634. * @access private
  635. * @param int $aid 文档id
  636. * @param int $typeid 栏目id
  637. * @param int $timetag 时间戳
  638. * @param string $title 标题
  639. * @param int $ismake 是否生成静态
  640. * @param int $rank 浏览权限
  641. * @param string $namerule 命名规则
  642. * @param string $artdir 文档路径
  643. * @param int $money 需要金币
  644. * @param string $filename 文件名称
  645. * @return string
  646. */
  647. function GetArcUrl($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = "", $artdir = "", $money = 0, $filename = '')
  648. {
  649. return GetFileUrl($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $artdir, $money, $filename);
  650. }
  651. /**
  652. * 获得当前的页面文件的url
  653. *
  654. * @access private
  655. * @return string
  656. */
  657. function GetCurUrl()
  658. {
  659. if (!empty($_SERVER["REQUEST_URI"])) {
  660. $nowurl = $_SERVER["REQUEST_URI"];
  661. $nowurls = explode("?", $nowurl);
  662. $nowurl = $nowurls[0];
  663. } else {
  664. $nowurl = $_SERVER["PHP_SELF"];
  665. }
  666. return $nowurl;
  667. }
  668. }//End Class