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

662 lines
27KB

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