国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

676 рядки
28KB

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