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

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