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

718 lines
28KB

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