国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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