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

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