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

719 lines
28KB

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