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

659 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 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 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['templeturl'] = $GLOBALS['cfg_templeturl'];
  365. $row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face'];
  366. if (is_array($this->dtp2->CTags)) {
  367. foreach ($this->dtp2->CTags as $k => $ctag) {
  368. if ($ctag->GetName() == 'array') {
  369. //传递整个数组,在runphp模式中有特殊作用
  370. $this->dtp2->Assign($k, $row);
  371. } else {
  372. if (isset($row[$ctag->GetName()])) {
  373. $this->dtp2->Assign($k, $row[$ctag->GetName()]);
  374. } else {
  375. $this->dtp2->Assign($k, '');
  376. }
  377. }
  378. }
  379. }
  380. $artlist .= $this->dtp2->GetResult();
  381. }//if hasRow
  382. }//Loop Col
  383. if ($col > 1) {
  384. $i += $col - 1;
  385. $artlist .= "</div>\r\n";
  386. }
  387. }//Loop Line
  388. $this->dsql->FreeResult('al');
  389. return $artlist;
  390. }
  391. /**
  392. * 获取动态的分页列表
  393. *
  394. * @access public
  395. * @param int $list_len 列表宽度
  396. * @param string $listitem 列表样式
  397. * @return string
  398. */
  399. function GetPageListDM($list_len, $listitem = "info,index,end,pre,next,pageno")
  400. {
  401. $prepage = "";
  402. $nextpage = "";
  403. $prepagenum = $this->PageNo - 1;
  404. $nextpagenum = $this->PageNo + 1;
  405. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  406. $list_len = 3;
  407. }
  408. $totalpage = $this->TotalPage;
  409. if ($totalpage <= 1 && $this->TotalResult > 0) {
  410. return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>";
  411. }
  412. if ($this->TotalResult == 0) {
  413. return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
  414. }
  415. $maininfo = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n";
  416. $purl = $this->GetCurUrl();
  417. $purl .= "?/".urlencode($this->Tag);
  418. //获得上一页和下一页的链接
  419. if ($this->PageNo != 1) {
  420. $prepage .= "<li class='page-item'><a class='page-link' href='".$purl."/$prepagenum/'>上一页</a></li>\r\n";
  421. $indexpage = "<li class='page-item'><a class='page-link' href='".$purl."/1/'>首页</a></li>\r\n";
  422. } else {
  423. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  424. }
  425. if ($this->PageNo != $totalpage && $totalpage > 1) {
  426. $nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."/$nextpagenum/'>下一页</a></li>\r\n";
  427. $endpage = "<li class='page-item'><a class='page-link' href='".$purl."/$totalpage/'>末页</a></li>\r\n";
  428. } else {
  429. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  430. }
  431. //获得数字链接
  432. $listdd = "";
  433. $total_list = $list_len * 2 + 1;
  434. if ($this->PageNo >= $total_list) {
  435. $j = $this->PageNo - $list_len;
  436. $total_list = $this->PageNo + $list_len;
  437. if ($total_list > $totalpage) {
  438. $total_list = $totalpage;
  439. }
  440. } else {
  441. $j = 1;
  442. if ($total_list > $totalpage) {
  443. $total_list = $totalpage;
  444. }
  445. }
  446. for ($j; $j <= $total_list; $j++) {
  447. if ($j == $this->PageNo) {
  448. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>\r\n";
  449. } else {
  450. $listdd .= "<li class='page-item'><a class='page-link' href='".$purl."/$j/'>".$j."</a></li>\r\n";
  451. }
  452. }
  453. $plist = '';
  454. if (preg_match('/info/i', $listitem)) {
  455. $plist .= $maininfo.' ';
  456. }
  457. if (preg_match('/index/i', $listitem)) {
  458. $plist .= $indexpage.' ';
  459. }
  460. if (preg_match('/pre/i', $listitem)) {
  461. $plist .= $prepage.' ';
  462. }
  463. if (preg_match('/pageno/i', $listitem)) {
  464. $plist .= $listdd.' ';
  465. }
  466. if (preg_match('/next/i', $listitem)) {
  467. $plist .= $nextpage.' ';
  468. }
  469. if (preg_match('/end/i', $listitem)) {
  470. $plist .= $endpage.' ';
  471. }
  472. return $plist;
  473. }
  474. function GetPageListST($list_len, $listitem = "info,index,end,pre,next,pageno")
  475. {
  476. $prepage = "";
  477. $nextpage = "";
  478. $prepagenum = intval($this->PageNo) - 1;
  479. $nextpagenum = intval($this->PageNo) + 1;
  480. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  481. $list_len = 3;
  482. }
  483. $totalpage = $this->TotalPage;
  484. if ($totalpage <= 1 && $this->TotalResult > 0) {
  485. return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>";
  486. }
  487. if ($this->TotalResult == 0) {
  488. return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
  489. }
  490. $maininfo = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n";
  491. $purl = $this->tagsDir.'/'.$this->TagInfos['id'];
  492. //获得上一页和下一页的链接
  493. if ($this->PageNo != 1) {
  494. $prepage .= "<li class='page-item'><a href='".$purl."/$prepagenum/' class='page-link'>上一页</a></li>\r\n";
  495. $indexpage = "<li class='page-item'><a href='".$purl."/1/' class='page-link'>首页</a></li>\r\n";
  496. } else {
  497. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  498. }
  499. if ($this->PageNo != $totalpage && $totalpage > 1) {
  500. $nextpage .= "<li class='page-item'><a href='".$purl."/$nextpagenum/' class='page-link'>下一页</a></li>\r\n";
  501. $endpage = "<li class='page-item'><a href='".$purl."/$totalpage/' class='page-link'>末页</a></li>\r\n";
  502. } else {
  503. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  504. }
  505. //获得数字链接
  506. $listdd = "";
  507. $total_list = $list_len * 2 + 1;
  508. if ($this->PageNo >= $total_list) {
  509. $j = $this->PageNo - $list_len;
  510. $total_list = $this->PageNo + $list_len;
  511. if ($total_list > $totalpage) {
  512. $total_list = $totalpage;
  513. }
  514. } else {
  515. $j = 1;
  516. if ($total_list > $totalpage) {
  517. $total_list = $totalpage;
  518. }
  519. }
  520. for ($j; $j <= $total_list; $j++) {
  521. if ($j == $this->PageNo) {
  522. $listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>\r\n";
  523. } else {
  524. $listdd .= "<li class='page-item'><a href='".$purl."/$j/' class='page-link'>".$j."</a></li>\r\n";
  525. }
  526. }
  527. $plist = "";
  528. if (preg_match('/info/i', $listitem)) {
  529. $plist .= $maininfo.' ';
  530. }
  531. if (preg_match('/index/i', $listitem)) {
  532. $plist .= $indexpage.' ';
  533. }
  534. if (preg_match('/pre/i', $listitem)) {
  535. $plist .= $prepage.' ';
  536. }
  537. if (preg_match('/pageno/i', $listitem)) {
  538. $plist .= $listdd.' ';
  539. }
  540. if (preg_match('/next/i', $listitem)) {
  541. $plist .= $nextpage.' ';
  542. }
  543. if (preg_match('/end/i', $listitem)) {
  544. $plist .= $endpage.' ';
  545. }
  546. return $plist;
  547. }
  548. function GetTruePath()
  549. {
  550. $truepath = $GLOBALS["cfg_basedir"];
  551. return $truepath;
  552. }
  553. function SetTagsDir($dir = '')
  554. {
  555. global $cfg_tags_dir, $cfg_cmspath;
  556. if ($dir == "") $dir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir);
  557. $this->tagsDir = $dir;
  558. }
  559. //生成静态Tag
  560. function MakeHtml($startpage = 1, $makepagesize = 0)
  561. {
  562. global $cfg_dir_purview, $envs, $cfg_cmspath, $cfg_tags_dir, $cfg_cmsurl;
  563. $envs['makeTag'] = 1;
  564. $tagsdir = str_replace("{cmspath}", $cfg_cmspath, $cfg_tags_dir);
  565. if (isset($envs['makeTag']) && $envs['makeTag'] == 1) {
  566. $this->Fields['position'] = $cfg_cmsurl.$tagsdir."/";
  567. }
  568. if (empty($this->TotalResult) && $this->Tag != "") $this->CountRecord();
  569. //初步给固定值的标记赋值
  570. $this->ParseTempletsFirst();
  571. if ($this->Tag == "") {
  572. MkdirAll($this->GetTruePath().$this->tagsDir, $cfg_dir_purview);
  573. $this->dtp->SaveTo($this->GetTruePath().$this->tagsDir."/index.html");
  574. } else {
  575. $totalpage = ceil($this->TotalResult / $this->pagesize);
  576. if ($totalpage == 0) {
  577. $totalpage = 1;
  578. }
  579. if ($makepagesize > 0) {
  580. $endpage = $startpage + $makepagesize;
  581. } else {
  582. $endpage = ($totalpage + 1);
  583. }
  584. if ($endpage >= $totalpage + 1) {
  585. $endpage = $totalpage + 1;
  586. }
  587. if ($endpage == 1) {
  588. $endpage = 2;
  589. }
  590. $makeDir = $this->GetTruePath().$this->tagsDir.'/'.$this->TagInfos['id']."/";
  591. MkdirAll($makeDir, $cfg_dir_purview);
  592. for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
  593. $this->ParseDMFields($this->PageNo, 1);
  594. $fileDir = $makeDir."/".$this->PageNo;
  595. MkdirAll($fileDir, $cfg_dir_purview);
  596. $this->dtp->SaveTo($fileDir."/index.html");
  597. }
  598. if ($startpage == 1) {
  599. $list_1 = $makeDir."/1/index.html";
  600. copy($list_1, $makeDir."/index.html");
  601. }
  602. }
  603. }
  604. /**
  605. * 获得一个指定的栏目的链接
  606. *
  607. * @access private
  608. * @param int $typeid 栏目id
  609. * @param string $typedir 栏目目录
  610. * @param int $isdefault 是否为默认
  611. * @param string $defaultname 默认名称
  612. * @param int $ispart 栏目属性
  613. * @param string $namerule2 栏目规则
  614. * @param string $siteurl 站点地址
  615. * @return string
  616. */
  617. function GetListUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $siteurl = "")
  618. {
  619. return GetTypeUrl($typeid, MfTypedir($typedir), $isdefault, $defaultname, $ispart, $namerule2, $siteurl);
  620. }
  621. /**
  622. * 获得一个指定文档的链接
  623. *
  624. * @access private
  625. * @param int $aid 文档id
  626. * @param int $typeid 栏目id
  627. * @param int $timetag 时间戳
  628. * @param string $title 标题
  629. * @param int $ismake 是否生成静态
  630. * @param int $rank 浏览权限
  631. * @param string $namerule 命名规则
  632. * @param string $artdir 文档路径
  633. * @param int $money 需要金币
  634. * @param string $filename 文件名称
  635. * @return string
  636. */
  637. function GetArcUrl($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = "", $artdir = "", $money = 0, $filename = '')
  638. {
  639. return GetFileUrl($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $artdir, $money, $filename);
  640. }
  641. /**
  642. * 获得当前的页面文件链接
  643. *
  644. * @access private
  645. * @return string
  646. */
  647. function GetCurUrl()
  648. {
  649. if (!empty($_SERVER["REQUEST_URI"])) {
  650. $nowurl = $_SERVER["REQUEST_URI"];
  651. $nowurls = explode("?", $nowurl);
  652. $nowurl = $nowurls[0];
  653. } else {
  654. $nowurl = $_SERVER["PHP_SELF"];
  655. }
  656. return $nowurl;
  657. }
  658. }//End Class
  659. ?>