国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

675 líneas
27KB

  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. var $tagsDir;
  39. /**
  40. * php5构造函数
  41. *
  42. * @access public
  43. * @param string $keyword 关键词
  44. * @param string $templet 模板
  45. * @return void
  46. */
  47. function __construct($keyword, $templet)
  48. {
  49. global $dsql,$envs;
  50. $this->Templet = $templet;
  51. $this->Tag = (int)$keyword;
  52. $this->dsql = $dsql;
  53. $this->dtp = new DedeTagParse();
  54. $this->dtp->SetRefObj($this);
  55. $this->dtp->SetNameSpace("dede", "{", "}");
  56. $this->dtp2 = new DedeTagParse();
  57. $this->dtp2->SetNameSpace("field", "[", "]");
  58. $this->TypeLink = new TypeLink(0);
  59. $this->Fields['tag'] = $keyword;
  60. if (empty($keyword)) {
  61. $this->Fields['title'] = "TAGS列表";
  62. } else {
  63. $this->Fields['title'] = $keyword;
  64. }
  65. $this->TempletsFile = '';
  66. //设置一些全局参数的值
  67. foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
  68. //读取Tag信息
  69. if (!empty($this->Tag)) {
  70. $this->TagInfos = $this->dsql->GetOne("Select * From `#@__tagindex` where id = '{$this->Tag}' ");
  71. if (!is_array($this->TagInfos)) {
  72. $msg = "系统无此标签,可能已经移除";
  73. ShowMsg($msg, "-1");
  74. exit();
  75. }
  76. $this->Fields['title'] = empty($this->TagInfos['title']) ? $this->Fields['title'] : $this->TagInfos['title'];
  77. $this->Fields['keywords'] = empty($this->TagInfos['keywords']) ? $this->Fields['keywords'] : $this->TagInfos['keywords'];
  78. $this->Fields['description'] = empty($this->TagInfos['description']) ? $this->Fields['description'] : $this->TagInfos['description'];
  79. }
  80. //初始化模板
  81. $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style'].'/'.$this->Templet;
  82. if (!file_exists($tempfile) || !is_file($tempfile)) {
  83. echo "模板文件不存在,无法解析文档";
  84. exit();
  85. }
  86. $this->dtp->LoadTemplate($tempfile);
  87. $this->TempletsFile = preg_replace("#^".$GLOBALS['cfg_basedir']."#", '', $tempfile);
  88. $envs['url_type'] = 4;
  89. $envs['value'] = $keyword;
  90. }
  91. //php4构造函数
  92. function TagList($keyword, $templet)
  93. {
  94. $this->__construct($keyword, $templet);
  95. }
  96. //关闭相关资源
  97. function Close()
  98. {
  99. @$this->TypeLink->Close();
  100. @$this->dsql->Close();
  101. }
  102. /**
  103. * 统计列表里的记录
  104. *
  105. * @access private
  106. * @return void
  107. */
  108. function CountRecord()
  109. {
  110. //统计数据库记录
  111. $this->TotalResult = -1;
  112. if (isset($GLOBALS['TotalResult'])) {
  113. $this->TotalResult = $GLOBALS['TotalResult'];
  114. }
  115. if (isset($GLOBALS['PageNo'])) {
  116. $this->PageNo = intval($GLOBALS['PageNo']);
  117. } else {
  118. $this->PageNo = 1;
  119. }
  120. if ($this->TotalResult == -1) {
  121. $cquery = "SELECT COUNT(*) AS dd FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank >-1 ";
  122. $row = $this->dsql->GetOne($cquery);
  123. $this->TotalResult = $row['dd'];
  124. //更新Tag信息
  125. $ntime = time();
  126. //更新浏览量和记录数
  127. $upquery = "UPDATE `#@__tagindex` SET total='{$row['dd']}',count=count+1,weekcc=weekcc+1,monthcc=monthcc+1 WHERE tag LIKE '{$this->Tag}' ";
  128. $this->dsql->ExecuteNoneQuery($upquery);
  129. $oneday = 24 * 3600;
  130. //周统计
  131. if (ceil(($ntime - $this->TagInfos['weekup']) / $oneday) > 7) {
  132. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET weekcc=0,weekup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  133. }
  134. //月统计
  135. if (ceil(($ntime - $this->TagInfos['monthup']) / $oneday) > 30) {
  136. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET monthcc=0,monthup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  137. }
  138. }
  139. $ctag = $this->dtp->GetTag("page");
  140. if (!is_object($ctag)) {
  141. $ctag = $this->dtp->GetTag("list");
  142. }
  143. if (!is_object($ctag)) {
  144. $this->PageSize = 25;
  145. } else {
  146. if ($ctag->GetAtt("pagesize") != '') {
  147. $this->PageSize = $ctag->GetAtt("pagesize");
  148. } else {
  149. $this->PageSize = 25;
  150. }
  151. }
  152. $this->TotalPage = ceil($this->TotalResult / $this->PageSize);
  153. }
  154. /**
  155. * 显示列表
  156. *
  157. * @access public
  158. * @return void
  159. */
  160. function Display()
  161. {
  162. global $cfg_cmspath,$cfg_tags_dir;
  163. $tagsDir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir);
  164. $makeDir = empty($this->Tag) ? $this->GetTruePath().$tagsDir."/index.html" : $this->GetTruePath().$tagsDir."/".$this->Tag."/index.html";
  165. if (file_exists($makeDir)) {
  166. header('HTTP/1.1 301 Moved Permanently');
  167. if (!empty($this->Tag)) {
  168. header('Location:..'.$tagsDir.'/'.GetPinyin($this->Tag)."/");
  169. } else {
  170. header('Location:..'.$tagsDir.'/');
  171. }
  172. exit;
  173. }
  174. if ($this->Tag != '') {
  175. $this->CountRecord();
  176. }
  177. $this->ParseTempletsFirst();
  178. if ($this->Tag != '') {
  179. $this->ParseDMFields($this->PageNo, 0);
  180. }
  181. $this->dtp->Display();
  182. // $this->Close();
  183. }
  184. /**
  185. * 解析模板,对固定的标记进行初始给值
  186. *
  187. * @access private
  188. * @return void
  189. */
  190. function ParseTempletsFirst()
  191. {
  192. MakeOneTag($this->dtp, $this);
  193. }
  194. /**
  195. * 解析模板,对内容里的变动进行赋值
  196. *
  197. * @access public
  198. * @param int $PageNo 页码
  199. * @param int $ismake 是否编译
  200. * @return string
  201. */
  202. function ParseDMFields($PageNo, $ismake = 1)
  203. {
  204. foreach ($this->dtp->CTags as $tagid => $ctag) {
  205. if ($ctag->GetName() == "list") {
  206. $limitstart = (intval($this->PageNo) - 1) * $this->PageSize;
  207. if ($limitstart < 0) {
  208. $limitstart = 0;
  209. }
  210. $row = $this->PageSize;
  211. if (trim($ctag->GetInnerText()) == "") {
  212. $InnerText = GetSysTemplets("list_fulllist.htm");
  213. } else {
  214. $InnerText = trim($ctag->GetInnerText());
  215. }
  216. $this->dtp->Assign(
  217. $tagid,
  218. $this->GetArcList(
  219. $limitstart,
  220. $row,
  221. $ctag->GetAtt("col"),
  222. $ctag->GetAtt("titlelen"),
  223. $ctag->GetAtt("infolen"),
  224. $ctag->GetAtt("imgwidth"),
  225. $ctag->GetAtt("imgheight"),
  226. $ctag->GetAtt("listtype"),
  227. $ctag->GetAtt("orderby"),
  228. $InnerText,
  229. $ctag->GetAtt("tablewidth"),
  230. $ismake,
  231. $ctag->GetAtt("orderway")
  232. )
  233. );
  234. } else if ($ctag->GetName() == "pagelist") {
  235. $list_len = trim($ctag->GetAtt("listsize"));
  236. $ctag->GetAtt("listitem") == "" ? $listitem = "info,index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem");
  237. if ($list_len == "") {
  238. $list_len = 3;
  239. }
  240. //var_dump($ismake);
  241. if ($ismake == 0) {
  242. $this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem));
  243. } else {
  244. $this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem));
  245. }
  246. }
  247. }
  248. }
  249. /**
  250. * 获得一个单列的文档列表
  251. *
  252. * @access public
  253. * @param int $limitstart 限制开始
  254. * @param int $row 行数
  255. * @param int $col 列数
  256. * @param int $titlelen 标题长度
  257. * @param int $infolen 描述长度
  258. * @param int $imgwidth 图片宽度
  259. * @param int $imgheight 图片高度
  260. * @param string $listtype 列表类型
  261. * @param string $orderby 排列顺序
  262. * @param string $innertext 底层模板
  263. * @param string $tablewidth 表格宽度
  264. * @param string $ismake 是否编译
  265. * @param string $orderWay 排序方式
  266. * @return string
  267. */
  268. function GetArcList(
  269. $limitstart = 0,
  270. $row = 10,
  271. $col = 1,
  272. $titlelen = 30,
  273. $infolen = 250,
  274. $imgwidth = 120,
  275. $imgheight = 90,
  276. $listtype = "all",
  277. $orderby = "default",
  278. $innertext = "",
  279. $tablewidth = "100",
  280. $ismake = 1,
  281. $orderWay = 'desc'
  282. ) {
  283. $getrow = ($row == '' ? 10 : $row);
  284. if ($limitstart == '') $limitstart = 0;
  285. if ($titlelen == '') $titlelen = 100;
  286. if ($infolen == '') $infolen = 250;
  287. if ($imgwidth == '') $imgwidth = 120;
  288. if ($imgheight == '') $imgheight = 120;
  289. if ($listtype == '') $listtype = 'all';
  290. $orderby = ($orderby == '' ? 'default' : strtolower($orderby));
  291. if ($orderWay == '') $orderWay = 'desc';
  292. $tablewidth = str_replace("%", "", $tablewidth);
  293. if ($tablewidth == '') $tablewidth = 100;
  294. if ($col == '') $col = 1;
  295. $colWidth = ceil(100 / $col);
  296. $tablewidth = $tablewidth."%";
  297. $colWidth = $colWidth."%";
  298. $innertext = trim($innertext);
  299. if ($innertext == '') $innertext = GetSysTemplets("list_fulllist.htm");
  300. $idlists = $ordersql = '';
  301. $this->dsql->SetQuery("SELECT aid FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank>-1 LIMIT $limitstart,$getrow");
  302. $this->dsql->Execute();
  303. while ($row = $this->dsql->GetArray()) {
  304. $idlists .= ($idlists == '' ? $row['aid'] : ','.$row['aid']);
  305. }
  306. if ($idlists == '') return '';
  307. //按不同情况设定SQL条件
  308. $orwhere = " se.id IN($idlists) ";
  309. //排序方式
  310. if ($orderby == "sortrank") {
  311. $ordersql = " ORDER BY se.sortrank $orderWay";
  312. } else {
  313. $ordersql = " ORDER BY se.id $orderWay";
  314. }
  315. $query = "SELECT se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  316. FROM `#@__archives` se LEFT JOIN `#@__arctype` tp ON se.typeid=tp.id WHERE $orwhere $ordersql ";
  317. $this->dsql->SetQuery($query);
  318. $this->dsql->Execute('al');
  319. $row = $this->PageSize / $col;
  320. $artlist = '';
  321. $this->dtp2->LoadSource($innertext);
  322. $GLOBALS['autoindex'] = 0;
  323. for ($i = 0; $i < $row; $i++) {
  324. if ($col > 1) {
  325. $artlist .= "<div>\r\n";
  326. }
  327. for ($j = 0; $j < $col; $j++) {
  328. if ($row = $this->dsql->GetArray("al")) {
  329. $GLOBALS['autoindex']++;
  330. $ids[$row['id']] = $row['id'];
  331. //处理一些特殊字段
  332. $row['infos'] = cn_substr($row['description'], $infolen);
  333. $row['id'] = $row['id'];
  334. $row['arcurl'] = GetFileUrl(
  335. $row['id'],
  336. $row['typeid'],
  337. $row['senddate'],
  338. $row['title'],
  339. $row['ismake'],
  340. $row['arcrank'],
  341. $row['namerule'],
  342. $row['typedir'],
  343. $row['money'],
  344. $row['filename'],
  345. $row['moresite'],
  346. $row['siteurl'],
  347. $row['sitepath']
  348. );
  349. $row['typeurl'] = GetTypeUrl(
  350. $row['typeid'],
  351. MfTypedir($row['typedir']),
  352. $row['isdefault'],
  353. $row['defaultname'],
  354. $row['ispart'],
  355. $row['namerule2'],
  356. $row['moresite'],
  357. $row['siteurl'],
  358. $row['sitepath']
  359. );
  360. if ($row['litpic'] == '-' || $row['litpic'] == '') {
  361. $row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/defaultpic.jpg';
  362. }
  363. if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
  364. $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
  365. }
  366. $row['picname'] = $row['litpic'];
  367. $row['stime'] = GetDateMK($row['pubdate']);
  368. $row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
  369. $row['image'] = "<img src='".$row['picname']."' border='0' width='$imgwidth' height='$imgheight' alt='".preg_replace("/['><]/", "", $row['title'])."'>";
  370. $row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
  371. $row['fulltitle'] = $row['title'];
  372. $row['title'] = cn_substr($row['title'], $titlelen);
  373. if ($row['color'] != '') {
  374. $row['title'] = "<span style='color:".$row['color']."'>".$row['title']."</span>";
  375. }
  376. if (preg_match('/c/', $row['flag'])) {
  377. $row['title'] = "".$row['title']."";
  378. }
  379. $row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
  380. $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  381. $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  382. $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  383. if (is_array($this->dtp2->CTags)) {
  384. foreach ($this->dtp2->CTags as $k => $ctag) {
  385. if ($ctag->GetName() == 'array') {
  386. //传递整个数组,在runphp模式中有特殊作用
  387. $this->dtp2->Assign($k, $row);
  388. } else {
  389. if (isset($row[$ctag->GetName()])) {
  390. $this->dtp2->Assign($k, $row[$ctag->GetName()]);
  391. } else {
  392. $this->dtp2->Assign($k, '');
  393. }
  394. }
  395. }
  396. }
  397. $artlist .= $this->dtp2->GetResult();
  398. } //if hasRow
  399. } //Loop Col
  400. if ($col > 1) {
  401. $i += $col - 1;
  402. $artlist .= " </div>\r\n";
  403. }
  404. } //Loop Line
  405. $this->dsql->FreeResult('al');
  406. return $artlist;
  407. }
  408. /**
  409. * 获取动态的分页列表
  410. *
  411. * @access public
  412. * @param int $list_len 列表宽度
  413. * @param string $listitem 列表样式
  414. * @return string
  415. */
  416. function GetPageListDM($list_len, $listitem = "info,index,end,pre,next,pageno")
  417. {
  418. $prepage = "";
  419. $nextpage = "";
  420. $prepagenum = $this->PageNo - 1;
  421. $nextpagenum = $this->PageNo + 1;
  422. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  423. $list_len = 3;
  424. }
  425. $totalpage = $this->TotalPage;
  426. if ($totalpage <= 1 && $this->TotalResult > 0) {
  427. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>1页".$this->TotalResult."篇</span></li>";
  428. }
  429. if ($this->TotalResult == 0) {
  430. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>0页".$this->TotalResult."篇</span></li>";
  431. }
  432. $maininfo = "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."篇</span></li>\r\n";
  433. $purl = $this->GetCurUrl();
  434. $purl .= "?/".urlencode($this->Tag);
  435. //获得上一页和下一页的链接
  436. if ($this->PageNo != 1) {
  437. $prepage .= "<li class='page-item'><a class='page-link' href='".$purl."/$prepagenum/'>上一页</a></li>\r\n";
  438. $indexpage = "<li class='page-item'><a class='page-link' href='".$purl."/1/'>首页</a></li>\r\n";
  439. } else {
  440. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  441. }
  442. if ($this->PageNo != $totalpage && $totalpage > 1) {
  443. $nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."/$nextpagenum/'>下一页</a></li>\r\n";
  444. $endpage = "<li class='page-item'><a class='page-link' href='".$purl."/$totalpage/'>末页</a></li>\r\n";
  445. } else {
  446. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  447. }
  448. //获得数字链接
  449. $listdd = "";
  450. $total_list = $list_len * 2 + 1;
  451. if ($this->PageNo >= $total_list) {
  452. $j = $this->PageNo - $list_len;
  453. $total_list = $this->PageNo + $list_len;
  454. if ($total_list > $totalpage) {
  455. $total_list = $totalpage;
  456. }
  457. } else {
  458. $j = 1;
  459. if ($total_list > $totalpage) {
  460. $total_list = $totalpage;
  461. }
  462. }
  463. for ($j; $j <= $total_list; $j++) {
  464. if ($j == $this->PageNo) {
  465. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>\r\n";
  466. } else {
  467. $listdd .= "<li class='page-item'><a class='page-link' href='".$purl."/$j/'>".$j."</a></li>\r\n";
  468. }
  469. }
  470. $plist = '';
  471. if (preg_match('/info/i', $listitem)) {
  472. $plist .= $maininfo.' ';
  473. }
  474. if (preg_match('/index/i', $listitem)) {
  475. $plist .= $indexpage.' ';
  476. }
  477. if (preg_match('/pre/i', $listitem)) {
  478. $plist .= $prepage.' ';
  479. }
  480. if (preg_match('/pageno/i', $listitem)) {
  481. $plist .= $listdd.' ';
  482. }
  483. if (preg_match('/next/i', $listitem)) {
  484. $plist .= $nextpage.' ';
  485. }
  486. if (preg_match('/end/i', $listitem)) {
  487. $plist .= $endpage.' ';
  488. }
  489. return $plist;
  490. }
  491. function GetPageListST($list_len, $listitem = "info,index,end,pre,next,pageno")
  492. {
  493. $prepage = "";
  494. $nextpage = "";
  495. $prepagenum = intval($this->PageNo) - 1;
  496. $nextpagenum = intval($this->PageNo) + 1;
  497. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  498. $list_len = 3;
  499. }
  500. $totalpage = $this->TotalPage;
  501. if ($totalpage <= 1 && $this->TotalResult > 0) {
  502. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>1页".$this->TotalResult."篇</span></li>";
  503. }
  504. if ($this->TotalResult == 0) {
  505. return "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>0页".$this->TotalResult."篇</span></li>";
  506. }
  507. $maininfo = "<li class='page-item d-none d-sm-block disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."篇</span></li>\r\n";
  508. //$purl = $this->GetCurUrl();
  509. $purl = "/a/tags/".GetPinyin($this->Tag);
  510. //var_dump($purl);
  511. //获得上一页和下一页的链接
  512. if ($this->PageNo != 1) {
  513. $prepage .= "<li class='page-item'><a class='page-link' href='".$purl."/$prepagenum/'>上一页</a></li>\r\n";
  514. $indexpage = "<li class='page-item'><a class='page-link' href='".$purl."/1/'>首页</a></li>\r\n";
  515. } else {
  516. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  517. }
  518. if ($this->PageNo != $totalpage && $totalpage > 1) {
  519. $nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."/$nextpagenum/'>下一页</a></li>\r\n";
  520. $endpage = "<li class='page-item'><a class='page-link' href='".$purl."/$totalpage/'>末页</a></li>\r\n";
  521. } else {
  522. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  523. }
  524. //获得数字链接
  525. $listdd = "";
  526. $total_list = $list_len * 2 + 1;
  527. if ($this->PageNo >= $total_list) {
  528. $j = $this->PageNo - $list_len;
  529. $total_list = $this->PageNo + $list_len;
  530. if ($total_list > $totalpage) {
  531. $total_list = $totalpage;
  532. }
  533. } else {
  534. $j = 1;
  535. if ($total_list > $totalpage) {
  536. $total_list = $totalpage;
  537. }
  538. }
  539. for ($j; $j <= $total_list; $j++) {
  540. if ($j == $this->PageNo) {
  541. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>\r\n";
  542. } else {
  543. $listdd .= "<li class='page-item'><a class='page-link' href='".$purl."/$j/'>".$j."</a></li>\r\n";
  544. }
  545. }
  546. $plist = '';
  547. if (preg_match('/info/i', $listitem)) {
  548. $plist .= $maininfo.' ';
  549. }
  550. if (preg_match('/index/i', $listitem)) {
  551. $plist .= $indexpage.' ';
  552. }
  553. if (preg_match('/pre/i', $listitem)) {
  554. $plist .= $prepage.' ';
  555. }
  556. if (preg_match('/pageno/i', $listitem)) {
  557. $plist .= $listdd.' ';
  558. }
  559. if (preg_match('/next/i', $listitem)) {
  560. $plist .= $nextpage.' ';
  561. }
  562. if (preg_match('/end/i', $listitem)) {
  563. $plist .= $endpage.' ';
  564. }
  565. return $plist;
  566. }
  567. function GetTruePath()
  568. {
  569. $truepath = $GLOBALS["cfg_basedir"];
  570. return $truepath;
  571. }
  572. function SetTagsDir($dir = '')
  573. {
  574. global $cfg_tags_dir,$cfg_cmspath;
  575. if ($dir == "") $dir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir);
  576. $this->tagsDir = $dir;
  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().$this->tagsDir, $cfg_dir_purview);
  588. $this->dtp->SaveTo($this->GetTruePath().$this->tagsDir."/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().$this->tagsDir.'/'.$this->TagInfos['id']."/";
  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