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

663 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;
  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->TempletsFile = '';
  64. //设置一些全局参数的值
  65. foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
  66. //读取Tag信息
  67. if (!empty($this->Tag)) {
  68. $this->TagInfos = $this->dsql->GetOne("Select * From `#@__tagindex` where id = '{$this->Tag}' ");
  69. if (!is_array($this->TagInfos)) {
  70. $msg = "系统无此标签,可能已经移除";
  71. ShowMsg($msg, "-1");
  72. exit();
  73. }
  74. $this->Fields['title'] = empty($this->TagInfos['title']) ? $this->TagInfos['tag'] : $this->TagInfos['title'];
  75. $this->Fields['keywords'] = empty($this->TagInfos['keywords']) ? $this->Fields['keywords'] : $this->TagInfos['keywords'];
  76. $this->Fields['description'] = empty($this->TagInfos['description']) ? $this->Fields['description'] : $this->TagInfos['description'];
  77. }
  78. //初始化模板
  79. $tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style'].'/'.$this->Templet;
  80. if (!file_exists($tempfile) || !is_file($tempfile)) {
  81. echo "模板文件不存在,无法解析文档";
  82. exit();
  83. }
  84. $this->dtp->LoadTemplate($tempfile);
  85. $this->TempletsFile = preg_replace("#^".$GLOBALS['cfg_basedir']."#", '', $tempfile);
  86. $envs['url_type'] = 4;
  87. $envs['value'] = $keyword;
  88. }
  89. //php4构造函数
  90. function TagList($keyword, $templet)
  91. {
  92. $this->__construct($keyword, $templet);
  93. }
  94. //关闭相关资源
  95. function Close()
  96. {
  97. @$this->TypeLink->Close();
  98. @$this->dsql->Close();
  99. }
  100. /**
  101. * 统计列表里的记录
  102. *
  103. * @access private
  104. * @return void
  105. */
  106. function CountRecord()
  107. {
  108. //统计数据库记录
  109. $this->TotalResult = -1;
  110. if (isset($GLOBALS['TotalResult'])) {
  111. $this->TotalResult = $GLOBALS['TotalResult'];
  112. }
  113. if (isset($GLOBALS['PageNo'])) {
  114. $this->PageNo = intval($GLOBALS['PageNo']);
  115. } else {
  116. $this->PageNo = 1;
  117. }
  118. if ($this->TotalResult == -1) {
  119. $cquery = "SELECT COUNT(*) AS dd FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank >-1 ";
  120. $row = $this->dsql->GetOne($cquery);
  121. $this->TotalResult = $row['dd'];
  122. //更新Tag信息
  123. $ntime = time();
  124. //更新浏览量和记录数
  125. $upquery = "UPDATE `#@__tagindex` SET total='{$row['dd']}',count=count+1,weekcc=weekcc+1,monthcc=monthcc+1 WHERE tag LIKE '{$this->Tag}' ";
  126. $this->dsql->ExecuteNoneQuery($upquery);
  127. $oneday = 24 * 3600;
  128. //周统计
  129. if (ceil(($ntime - $this->TagInfos['weekup']) / $oneday) > 7) {
  130. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET weekcc=0,weekup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  131. }
  132. //月统计
  133. if (ceil(($ntime - $this->TagInfos['monthup']) / $oneday) > 30) {
  134. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET monthcc=0,monthup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  135. }
  136. }
  137. $ctag = $this->dtp->GetTag("page");
  138. if (!is_object($ctag)) {
  139. $ctag = $this->dtp->GetTag("list");
  140. }
  141. if (!is_object($ctag)) {
  142. $this->pagesize = 30;
  143. } else {
  144. if ($ctag->GetAtt("pagesize") != '') {
  145. $this->pagesize = $ctag->GetAtt("pagesize");
  146. } else {
  147. $this->pagesize = 30;
  148. }
  149. }
  150. $this->TotalPage = ceil($this->TotalResult / $this->pagesize);
  151. }
  152. /**
  153. * 显示列表
  154. *
  155. * @access public
  156. * @return void
  157. */
  158. function Display()
  159. {
  160. global $cfg_cmspath,$cfg_tags_dir;
  161. $tagsDir = str_replace("{cmspath}",$cfg_cmspath,$cfg_tags_dir);
  162. $makeDir = empty($this->Tag) ? $this->GetTruePath().$tagsDir."/index.html" : $this->GetTruePath().$tagsDir."/".$this->Tag."/index.html";
  163. if ($this->Tag != '') {
  164. $this->CountRecord();
  165. }
  166. $this->ParseTempletsFirst();
  167. if ($this->Tag != '') {
  168. if ($this->PageNo == 0) {
  169. $this->PageNo = 1;
  170. }
  171. $this->ParseDMFields($this->PageNo, 0);
  172. }
  173. $this->dtp->Display();
  174. // $this->Close();
  175. }
  176. /**
  177. * 解析模板,对固定的标记进行初始给值
  178. *
  179. * @access private
  180. * @return void
  181. */
  182. function ParseTempletsFirst()
  183. {
  184. MakeOneTag($this->dtp, $this);
  185. }
  186. /**
  187. * 解析模板,对内容里的变动进行赋值
  188. *
  189. * @access public
  190. * @param int $PageNo 页码
  191. * @param int $ismake 是否编译
  192. * @return string
  193. */
  194. function ParseDMFields($PageNo, $ismake = 1)
  195. {
  196. foreach ($this->dtp->CTags as $tagid => $ctag) {
  197. if ($ctag->GetName() == "list") {
  198. $limitstart = (intval($this->PageNo) - 1) * $this->pagesize;
  199. if ($limitstart < 0) {
  200. $limitstart = 0;
  201. }
  202. $row = $this->pagesize;
  203. if (trim($ctag->GetInnerText()) == "") {
  204. $InnerText = GetSysTemplets("list_fulllist.htm");
  205. } else {
  206. $InnerText = trim($ctag->GetInnerText());
  207. }
  208. $this->dtp->Assign(
  209. $tagid,
  210. $this->GetArcList(
  211. $limitstart,
  212. $row,
  213. $ctag->GetAtt("col"),
  214. $ctag->GetAtt("titlelen"),
  215. $ctag->GetAtt("infolen"),
  216. $ctag->GetAtt("imgwidth"),
  217. $ctag->GetAtt("imgheight"),
  218. $ctag->GetAtt("listtype"),
  219. $ctag->GetAtt("orderby"),
  220. $InnerText,
  221. $ctag->GetAtt("tablewidth"),
  222. $ismake,
  223. $ctag->GetAtt("orderway")
  224. )
  225. );
  226. } else if ($ctag->GetName() == "pagelist") {
  227. $list_len = trim($ctag->GetAtt("listsize"));
  228. $ctag->GetAtt("listitem") == "" ? $listitem = "info,index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem");
  229. if ($list_len == "") {
  230. $list_len = 3;
  231. }
  232. //var_dump($ismake);
  233. if ($ismake == 0) {
  234. $this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem));
  235. } else {
  236. $this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem));
  237. }
  238. }
  239. }
  240. }
  241. /**
  242. * 获得一个单列的文档列表
  243. *
  244. * @access public
  245. * @param int $limitstart 限制开始
  246. * @param int $row 行数
  247. * @param int $col 列数
  248. * @param int $titlelen 标题长度
  249. * @param int $infolen 描述长度
  250. * @param int $imgwidth 图片宽度
  251. * @param int $imgheight 图片高度
  252. * @param string $listtype 列表类型
  253. * @param string $orderby 排列顺序
  254. * @param string $innertext 底层模板
  255. * @param string $tablewidth 表格宽度
  256. * @param string $ismake 是否编译
  257. * @param string $orderWay 排序方式
  258. * @return string
  259. */
  260. function GetArcList(
  261. $limitstart = 0,
  262. $row = 10,
  263. $col = 1,
  264. $titlelen = 30,
  265. $infolen = 250,
  266. $imgwidth = 120,
  267. $imgheight = 90,
  268. $listtype = "all",
  269. $orderby = "default",
  270. $innertext = "",
  271. $tablewidth = "100",
  272. $ismake = 1,
  273. $orderWay = 'desc'
  274. ) {
  275. $getrow = ($row == '' ? 10 : $row);
  276. if ($limitstart == '') $limitstart = 0;
  277. if ($titlelen == '') $titlelen = 100;
  278. if ($infolen == '') $infolen = 250;
  279. if ($imgwidth == '') $imgwidth = 120;
  280. if ($imgheight == '') $imgheight = 120;
  281. if ($listtype == '') $listtype = 'all';
  282. $orderby = ($orderby == '' ? 'default' : strtolower($orderby));
  283. if ($orderWay == '') $orderWay = 'desc';
  284. $tablewidth = str_replace("%", "", $tablewidth);
  285. if ($tablewidth == '') $tablewidth = 100;
  286. if ($col == '') $col = 1;
  287. $colWidth = ceil(100 / $col);
  288. $tablewidth = $tablewidth."%";
  289. $colWidth = $colWidth."%";
  290. $innertext = trim($innertext);
  291. if ($innertext == '') $innertext = GetSysTemplets("list_fulllist.htm");
  292. $idlists = $ordersql = '';
  293. $this->dsql->SetQuery("SELECT aid FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank>-1 LIMIT $limitstart,$getrow");
  294. $this->dsql->Execute();
  295. while ($row = $this->dsql->GetArray()) {
  296. $idlists .= ($idlists == '' ? $row['aid'] : ','.$row['aid']);
  297. }
  298. if ($idlists == '') return '';
  299. //按不同情况设定SQL条件
  300. $orwhere = " se.id IN($idlists) ";
  301. //排序方式
  302. if ($orderby == "sortrank") {
  303. $ordersql = " ORDER BY se.sortrank $orderWay";
  304. } else {
  305. $ordersql = " ORDER BY se.id $orderWay";
  306. }
  307. $query = "SELECT se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  308. 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;
  572. $envs['makeTag'] = 1;
  573. if (empty($this->TotalResult) && $this->Tag != "") $this->CountRecord();
  574. //初步给固定值的标记赋值
  575. $this->ParseTempletsFirst();
  576. if ($this->Tag == "") {
  577. MkdirAll($this->GetTruePath().$this->tagsDir, $cfg_dir_purview);
  578. $this->dtp->SaveTo($this->GetTruePath().$this->tagsDir."/index.html");
  579. } else {
  580. $totalpage = ceil($this->TotalResult / $this->pagesize);
  581. if ($totalpage == 0) {
  582. $totalpage = 1;
  583. }
  584. if ($makepagesize > 0) {
  585. $endpage = $startpage + $makepagesize;
  586. } else {
  587. $endpage = ($totalpage + 1);
  588. }
  589. if ($endpage >= $totalpage + 1) {
  590. $endpage = $totalpage + 1;
  591. }
  592. if ($endpage == 1) {
  593. $endpage = 2;
  594. }
  595. $makeDir = $this->GetTruePath().$this->tagsDir.'/'.$this->TagInfos['id']."/";
  596. MkdirAll($makeDir, $cfg_dir_purview);
  597. for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
  598. $this->ParseDMFields($this->PageNo, 1);
  599. $fileDir = $makeDir."/".$this->PageNo;
  600. MkdirAll($fileDir, $cfg_dir_purview);
  601. $this->dtp->SaveTo($fileDir."/index.html");
  602. }
  603. if ($startpage == 1) {
  604. $list_1 = $makeDir."/1/index.html";
  605. copy($list_1, $makeDir."/index.html");
  606. }
  607. }
  608. }
  609. /**
  610. * 获得一个指定的频道的链接
  611. *
  612. * @access private
  613. * @param int $typeid 栏目ID
  614. * @param string $typedir 栏目目录
  615. * @param int $isdefault 是否为默认
  616. * @param string $defaultname 默认名称
  617. * @param int $ispart 栏目属性
  618. * @param string $namerule2 栏目规则
  619. * @param string $siteurl 站点地址
  620. * @return string
  621. */
  622. function GetListUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $siteurl = "")
  623. {
  624. return GetTypeUrl($typeid, MfTypedir($typedir), $isdefault, $defaultname, $ispart, $namerule2, $siteurl);
  625. }
  626. /**
  627. * 获得一个指定档案的链接
  628. *
  629. * @access private
  630. * @param int $aid 文档ID
  631. * @param int $typeid 栏目ID
  632. * @param int $timetag 时间戳
  633. * @param string $title 标题
  634. * @param int $ismake 是否生成静态
  635. * @param int $rank 浏览权限
  636. * @param string $namerule 命名规则
  637. * @param string $artdir 文档路径
  638. * @param int $money 需要金币
  639. * @param string $filename 文件名称
  640. * @return string
  641. */
  642. function GetArcUrl($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = "", $artdir = "", $money = 0, $filename = '')
  643. {
  644. return GetFileUrl($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $artdir, $money, $filename);
  645. }
  646. /**
  647. * 获得当前的页面文件的url
  648. *
  649. * @access private
  650. * @return string
  651. */
  652. function GetCurUrl()
  653. {
  654. if (!empty($_SERVER["REQUEST_URI"])) {
  655. $nowurl = $_SERVER["REQUEST_URI"];
  656. $nowurls = explode("?", $nowurl);
  657. $nowurl = $nowurls[0];
  658. } else {
  659. $nowurl = $_SERVER["PHP_SELF"];
  660. }
  661. return $nowurl;
  662. }
  663. }//End Class