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

657 lines
28KB

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