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

702 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) 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. @set_time_limit(0);
  15. /**
  16. * Tag列表类
  17. *
  18. * @package TagList
  19. * @subpackage DedeCMS.Libraries
  20. * @link http://www.dedecms.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. /**
  39. * php5构造函数
  40. *
  41. * @access public
  42. * @param string $keyword 关键词
  43. * @param string $templet 模板
  44. * @return void
  45. */
  46. function __construct($keyword, $templet)
  47. {
  48. global $dsql;
  49. $this->Templet = $templet;
  50. $this->Tag = $keyword;
  51. $this->dsql = $dsql;
  52. $this->dtp = new DedeTagParse();
  53. $this->dtp->SetRefObj($this);
  54. $this->dtp->SetNameSpace("dede", "{", "}");
  55. $this->dtp2 = new DedeTagParse();
  56. $this->dtp2->SetNameSpace("field", "[", "]");
  57. $this->TypeLink = new TypeLink(0);
  58. $this->Fields['tag'] = $keyword;
  59. if (empty($keyword)) {
  60. $this->Fields['title'] = "TAGS列表";
  61. } else {
  62. $this->Fields['title'] = $keyword;
  63. }
  64. $this->TempletsFile = '';
  65. //设置一些全局参数的值
  66. foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
  67. //读取Tag信息
  68. if ($this->Tag != '') {
  69. $this->TagInfos = $this->dsql->GetOne("Select * From `#@__tagindex` where tag like '{$this->Tag}' ");
  70. if (!is_array($this->TagInfos)) {
  71. $fullsearch = $GLOBALS['cfg_phpurl'] . "/search.php?keyword=" . $this->Tag . "&searchtype=titlekeyword";
  72. $msg = "系统无此标签,可能已经移除!<br /><br />你还可以尝试通过搜索程序去搜索这个关键字:<a href='$fullsearch'>前往搜索&gt;&gt;</a>";
  73. ShowMsg($msg, "-1");
  74. exit();
  75. }
  76. }
  77. //初始化模板
  78. $tempfile = $GLOBALS['cfg_basedir'] . $GLOBALS['cfg_templets_dir'] . "/" . $GLOBALS['cfg_df_style'] . '/' . $this->Templet;
  79. if (!file_exists($tempfile) || !is_file($tempfile)) {
  80. echo "模板文件不存在,无法解析文档!";
  81. exit();
  82. }
  83. $this->dtp->LoadTemplate($tempfile);
  84. $this->TempletsFile = preg_replace("#^" . $GLOBALS['cfg_basedir'] . "#", '', $tempfile);
  85. }
  86. //php4构造函数
  87. function TagList($keyword, $templet)
  88. {
  89. $this->__construct($keyword, $templet);
  90. }
  91. //关闭相关资源
  92. function Close()
  93. {
  94. @$this->dsql->Close();
  95. @$this->TypeLink->Close();
  96. }
  97. /**
  98. * 统计列表里的记录
  99. *
  100. * @access private
  101. * @return void
  102. */
  103. function CountRecord()
  104. {
  105. //统计数据库记录
  106. $this->TotalResult = -1;
  107. if (isset($GLOBALS['TotalResult'])) {
  108. $this->TotalResult = $GLOBALS['TotalResult'];
  109. }
  110. if (isset($GLOBALS['PageNo'])) {
  111. $this->PageNo = intval($GLOBALS['PageNo']);
  112. } else {
  113. $this->PageNo = 1;
  114. }
  115. if ($this->TotalResult == -1) {
  116. $cquery = "SELECT COUNT(*) AS dd FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank >-1 ";
  117. $row = $this->dsql->GetOne($cquery);
  118. $this->TotalResult = $row['dd'];
  119. //更新Tag信息
  120. $ntime = time();
  121. //更新浏览量和记录数
  122. $upquery = "UPDATE `#@__tagindex` SET total='{$row['dd']}',count=count+1,weekcc=weekcc+1,monthcc=monthcc+1 WHERE tag LIKE '{$this->Tag}' ";
  123. $this->dsql->ExecuteNoneQuery($upquery);
  124. $oneday = 24 * 3600;
  125. //周统计
  126. if (ceil(($ntime - $this->TagInfos['weekup']) / $oneday) > 7) {
  127. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET weekcc=0,weekup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  128. }
  129. //月统计
  130. if (ceil(($ntime - $this->TagInfos['monthup']) / $oneday) > 30) {
  131. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET monthcc=0,monthup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  132. }
  133. }
  134. $ctag = $this->dtp->GetTag("page");
  135. if (!is_object($ctag)) {
  136. $ctag = $this->dtp->GetTag("list");
  137. }
  138. if (!is_object($ctag)) {
  139. $this->PageSize = 25;
  140. } else {
  141. if ($ctag->GetAtt("pagesize") != '') {
  142. $this->PageSize = $ctag->GetAtt("pagesize");
  143. } else {
  144. $this->PageSize = 25;
  145. }
  146. }
  147. $this->TotalPage = ceil($this->TotalResult / $this->PageSize);
  148. }
  149. /**
  150. * 显示列表
  151. *
  152. * @access public
  153. * @return void
  154. */
  155. function Display()
  156. {
  157. $makeDir = empty($this->Tag) ? $this->GetTruePath() . "/a/tags/index.html" : $this->GetTruePath() . "/a/tags/" . GetPinyin($this->Tag) . "/index.html";
  158. if (file_exists($makeDir)) {
  159. header('HTTP/1.1 301 Moved Permanently');
  160. if (!empty($this->Tag)) {
  161. header('Location:a/tags/' . GetPinyin($this->Tag) . "/");
  162. } else {
  163. header('Location:a/tags/');
  164. }
  165. exit;
  166. }
  167. if ($this->Tag != '') {
  168. $this->CountRecord();
  169. }
  170. $this->ParseTempletsFirst();
  171. if ($this->Tag != '') {
  172. $this->ParseDMFields($this->PageNo, 0);
  173. }
  174. $this->Close();
  175. $this->dtp->Display();
  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/defaultpic.gif';
  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'] . "' border='0' width='$imgwidth' height='$imgheight' alt='" . 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'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
  368. }
  369. if (preg_match('/c/', $row['flag'])) {
  370. $row['title'] = "<b>" . $row['title'] . "</b>";
  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->GetCurUrl();
  502. $purl = "/a/tags/" . GetPinyin($this->Tag);
  503. // var_dump($purl);
  504. //获得上一页和下一页的链接
  505. if ($this->PageNo != 1) {
  506. $prepage .= "<li class='page-item'><a class='page-link' href='" . $purl . "/$prepagenum/'>上一页</a></li>\r\n";
  507. $indexpage = "<li class='page-item'><a class='page-link' href='" . $purl . "/1/'>首页</a></li>\r\n";
  508. } else {
  509. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  510. }
  511. if ($this->PageNo != $totalpage && $totalpage > 1) {
  512. $nextpage .= "<li class='page-item'><a class='page-link' href='" . $purl . "/$nextpagenum/'>下一页</a></li>\r\n";
  513. $endpage = "<li class='page-item'><a class='page-link' href='" . $purl . "/$totalpage/'>末页</a></li>\r\n";
  514. } else {
  515. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  516. }
  517. //获得数字链接
  518. $listdd = "";
  519. $total_list = $list_len * 2 + 1;
  520. if ($this->PageNo >= $total_list) {
  521. $j = $this->PageNo - $list_len;
  522. $total_list = $this->PageNo + $list_len;
  523. if ($total_list > $totalpage) {
  524. $total_list = $totalpage;
  525. }
  526. } else {
  527. $j = 1;
  528. if ($total_list > $totalpage) {
  529. $total_list = $totalpage;
  530. }
  531. }
  532. for ($j; $j <= $total_list; $j++) {
  533. if ($j == $this->PageNo) {
  534. $listdd .= "<li class=\"page-item active\"><span class='page-link'>$j</span></li>\r\n";
  535. } else {
  536. $listdd .= "<li class='page-item'><a class='page-link' href='" . $purl . "/$j/'>" . $j . "</a></li>\r\n";
  537. }
  538. }
  539. $plist = '';
  540. if (preg_match('/info/i', $listitem)) {
  541. $plist .= $maininfo . ' ';
  542. }
  543. if (preg_match('/index/i', $listitem)) {
  544. $plist .= $indexpage . ' ';
  545. }
  546. if (preg_match('/pre/i', $listitem)) {
  547. $plist .= $prepage . ' ';
  548. }
  549. if (preg_match('/pageno/i', $listitem)) {
  550. $plist .= $listdd . ' ';
  551. }
  552. if (preg_match('/next/i', $listitem)) {
  553. $plist .= $nextpage . ' ';
  554. }
  555. if (preg_match('/end/i', $listitem)) {
  556. $plist .= $endpage . ' ';
  557. }
  558. return $plist;
  559. }
  560. function GetTruePath()
  561. {
  562. $truepath = $GLOBALS["cfg_basedir"];
  563. return $truepath;
  564. }
  565. // 生成静态Tag
  566. function MakeHtml($startpage = 1, $makepagesize = 0)
  567. {
  568. global $cfg_dir_purview, $envs;
  569. $envs['makeTag'] = 1;
  570. if (empty($this->TotalResult) && $this->Tag != "") $this->CountRecord();
  571. //初步给固定值的标记赋值
  572. $this->ParseTempletsFirst();
  573. if ($this->Tag == "") {
  574. MkdirAll($this->GetTruePath() . "/a/tags/", $cfg_dir_purview);
  575. $this->dtp->SaveTo($this->GetTruePath() . "/a/tags/index.html");
  576. } else {
  577. $totalpage = ceil($this->TotalResult / $this->PageSize);
  578. if ($totalpage == 0) {
  579. $totalpage = 1;
  580. }
  581. if ($makepagesize > 0) {
  582. $endpage = $startpage + $makepagesize;
  583. } else {
  584. $endpage = ($totalpage + 1);
  585. }
  586. if ($endpage >= $totalpage + 1) {
  587. $endpage = $totalpage + 1;
  588. }
  589. if ($endpage == 1) {
  590. $endpage = 2;
  591. }
  592. $makeDir = $this->GetTruePath() . "/a/tags/" . GetPinyin($this->Tag) . "/";
  593. MkdirAll($makeDir, $cfg_dir_purview);
  594. for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
  595. $this->ParseDMFields($this->PageNo, 1);
  596. $fileDir = $makeDir . "/" . $this->PageNo;
  597. MkdirAll($fileDir, $cfg_dir_purview);
  598. $this->dtp->SaveTo($fileDir . "/index.html");
  599. }
  600. if ($startpage == 1) {
  601. $list_1 = $makeDir . "/1/index.html";
  602. copy($list_1, $makeDir . "/index.html");
  603. }
  604. }
  605. }
  606. /**
  607. * 获得一个指定的频道的链接
  608. *
  609. * @access private
  610. * @param int $typeid 栏目ID
  611. * @param string $typedir 栏目目录
  612. * @param int $isdefault 是否为默认
  613. * @param string $defaultname 默认名称
  614. * @param int $ispart 栏目属性
  615. * @param string $namerule2 栏目规则
  616. * @param string $siteurl 站点地址
  617. * @return string
  618. */
  619. function GetListUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $siteurl = "")
  620. {
  621. return GetTypeUrl($typeid, MfTypedir($typedir), $isdefault, $defaultname, $ispart, $namerule2, $siteurl);
  622. }
  623. /**
  624. * 获得一个指定档案的链接
  625. *
  626. * @access private
  627. * @param int $aid 文档ID
  628. * @param int $typeid 栏目ID
  629. * @param int $timetag 时间戳
  630. * @param string $title 标题
  631. * @param int $ismake 是否生成静态
  632. * @param int $rank 浏览权限
  633. * @param string $namerule 命名规则
  634. * @param string $artdir 文档路径
  635. * @param int $money 需要金币
  636. * @param string $filename 文件名称
  637. * @return string
  638. */
  639. function GetArcUrl($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = "", $artdir = "", $money = 0, $filename = '')
  640. {
  641. return GetFileUrl($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $artdir, $money, $filename);
  642. }
  643. /**
  644. * 获得当前的页面文件的url
  645. *
  646. * @access private
  647. * @return string
  648. */
  649. function GetCurUrl()
  650. {
  651. if (!empty($_SERVER["REQUEST_URI"])) {
  652. $nowurl = $_SERVER["REQUEST_URI"];
  653. $nowurls = explode("?", $nowurl);
  654. $nowurl = $nowurls[0];
  655. } else {
  656. $nowurl = $_SERVER["PHP_SELF"];
  657. }
  658. return $nowurl;
  659. }
  660. }//End Class