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

701 lines
27KB

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