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

697 lines
26KB

  1. <?php if (!defined('DEDEINC')) exit('Request Error!');
  2. /**
  3. * Tag列表类
  4. *
  5. * @version $Id: arc.taglist.class.php 1 18:17 2010年7月7日Z tianya $
  6. * @package DedeCMS.Libraries
  7. * @copyright Copyright (c) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.com
  10. */
  11. require_once(DEDEINC . '/channelunit.class.php');
  12. require_once(DEDEINC . '/typelink.class.php');
  13. @set_time_limit(0);
  14. /**
  15. * Tag列表类
  16. *
  17. * @package TagList
  18. * @subpackage DedeCMS.Libraries
  19. * @link http://www.dedecms.com
  20. */
  21. class TagList
  22. {
  23. var $dsql;
  24. var $dtp;
  25. var $dtp2;
  26. var $TypeLink;
  27. var $PageNo;
  28. var $TotalPage;
  29. var $TotalResult;
  30. var $PageSize;
  31. var $ListType;
  32. var $Fields;
  33. var $Tag;
  34. var $Templet;
  35. var $TagInfos;
  36. var $TempletsFile;
  37. /**
  38. * php5构造函数
  39. *
  40. * @access public
  41. * @param string $keyword 关键词
  42. * @param string $templet 模板
  43. * @return void
  44. */
  45. function __construct($keyword, $templet)
  46. {
  47. global $dsql;
  48. $this->Templet = $templet;
  49. $this->Tag = $keyword;
  50. $this->dsql = $dsql;
  51. $this->dtp = new DedeTagParse();
  52. $this->dtp->SetRefObj($this);
  53. $this->dtp->SetNameSpace("dede", "{", "}");
  54. $this->dtp2 = new DedeTagParse();
  55. $this->dtp2->SetNameSpace("field", "[", "]");
  56. $this->TypeLink = new TypeLink(0);
  57. $this->Fields['tag'] = $keyword;
  58. if (empty($keyword)) {
  59. $this->Fields['title'] = "TAGS列表";
  60. } else {
  61. $this->Fields['title'] = $keyword;
  62. }
  63. $this->TempletsFile = '';
  64. //设置一些全局参数的值
  65. foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v;
  66. //读取Tag信息
  67. if ($this->Tag != '') {
  68. $this->TagInfos = $this->dsql->GetOne("Select * From `#@__tagindex` where tag like '{$this->Tag}' ");
  69. if (!is_array($this->TagInfos)) {
  70. $fullsearch = $GLOBALS['cfg_phpurl'] . "/search.php?keyword=" . $this->Tag . "&searchtype=titlekeyword";
  71. $msg = "系统无此标签,可能已经移除!<br /><br />你还可以尝试通过搜索程序去搜索这个关键字:<a href='$fullsearch'>前往搜索&gt;&gt;</a>";
  72. ShowMsg($msg, "-1");
  73. exit();
  74. }
  75. }
  76. //初始化模板
  77. $tempfile = $GLOBALS['cfg_basedir'] . $GLOBALS['cfg_templets_dir'] . "/" . $GLOBALS['cfg_df_style'] . '/' . $this->Templet;
  78. if (!file_exists($tempfile) || !is_file($tempfile)) {
  79. echo "模板文件不存在,无法解析文档!";
  80. exit();
  81. }
  82. $this->dtp->LoadTemplate($tempfile);
  83. $this->TempletsFile = preg_replace("#^" . $GLOBALS['cfg_basedir'] . "#", '', $tempfile);
  84. }
  85. //php4构造函数
  86. function TagList($keyword, $templet)
  87. {
  88. $this->__construct($keyword, $templet);
  89. }
  90. //关闭相关资源
  91. function Close()
  92. {
  93. @$this->dsql->Close();
  94. @$this->TypeLink->Close();
  95. }
  96. /**
  97. * 统计列表里的记录
  98. *
  99. * @access private
  100. * @return void
  101. */
  102. function CountRecord()
  103. {
  104. //统计数据库记录
  105. $this->TotalResult = -1;
  106. if (isset($GLOBALS['TotalResult'])) {
  107. $this->TotalResult = $GLOBALS['TotalResult'];
  108. }
  109. if (isset($GLOBALS['PageNo'])) {
  110. $this->PageNo = intval($GLOBALS['PageNo']);
  111. } else {
  112. $this->PageNo = 1;
  113. }
  114. if ($this->TotalResult == -1) {
  115. $cquery = "SELECT COUNT(*) AS dd FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank >-1 ";
  116. $row = $this->dsql->GetOne($cquery);
  117. $this->TotalResult = $row['dd'];
  118. //更新Tag信息
  119. $ntime = time();
  120. //更新浏览量和记录数
  121. $upquery = "UPDATE `#@__tagindex` SET total='{$row['dd']}',count=count+1,weekcc=weekcc+1,monthcc=monthcc+1 WHERE tag LIKE '{$this->Tag}' ";
  122. $this->dsql->ExecuteNoneQuery($upquery);
  123. $oneday = 24 * 3600;
  124. //周统计
  125. if (ceil(($ntime - $this->TagInfos['weekup']) / $oneday) > 7) {
  126. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET weekcc=0,weekup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  127. }
  128. //月统计
  129. if (ceil(($ntime - $this->TagInfos['monthup']) / $oneday) > 30) {
  130. $this->dsql->ExecuteNoneQuery("UPDATE `#@__tagindex` SET monthcc=0,monthup='{$ntime}' WHERE tag LIKE '{$this->Tag}' ");
  131. }
  132. }
  133. $ctag = $this->dtp->GetTag("page");
  134. if (!is_object($ctag)) {
  135. $ctag = $this->dtp->GetTag("list");
  136. }
  137. if (!is_object($ctag)) {
  138. $this->PageSize = 25;
  139. } else {
  140. if ($ctag->GetAtt("pagesize") != '') {
  141. $this->PageSize = $ctag->GetAtt("pagesize");
  142. } else {
  143. $this->PageSize = 25;
  144. }
  145. }
  146. $this->TotalPage = ceil($this->TotalResult / $this->PageSize);
  147. }
  148. /**
  149. * 显示列表
  150. *
  151. * @access public
  152. * @return void
  153. */
  154. function Display()
  155. {
  156. $makeDir = empty($this->Tag) ? $this->GetTruePath() . "/a/tags/index.html" : $this->GetTruePath() . "/a/tags/" . GetPinyin($this->Tag) . "/index.html";
  157. if (file_exists($makeDir)) {
  158. header('HTTP/1.1 301 Moved Permanently');
  159. header('Location:a/tags/' . GetPinyin($this->Tag) . "/");
  160. exit;
  161. }
  162. if ($this->Tag != '') {
  163. $this->CountRecord();
  164. }
  165. $this->ParseTempletsFirst();
  166. if ($this->Tag != '') {
  167. $this->ParseDMFields($this->PageNo, 0);
  168. }
  169. $this->Close();
  170. $this->dtp->Display();
  171. }
  172. /**
  173. * 解析模板,对固定的标记进行初始给值
  174. *
  175. * @access private
  176. * @return void
  177. */
  178. function ParseTempletsFirst()
  179. {
  180. MakeOneTag($this->dtp, $this);
  181. }
  182. /**
  183. * 解析模板,对内容里的变动进行赋值
  184. *
  185. * @access public
  186. * @param int $PageNo 页码
  187. * @param int $ismake 是否编译
  188. * @return string
  189. */
  190. function ParseDMFields($PageNo, $ismake = 1)
  191. {
  192. foreach ($this->dtp->CTags as $tagid => $ctag) {
  193. if ($ctag->GetName() == "list") {
  194. $limitstart = (intval($this->PageNo) - 1) * $this->PageSize;
  195. if ($limitstart < 0) {
  196. $limitstart = 0;
  197. }
  198. $row = $this->PageSize;
  199. if (trim($ctag->GetInnerText()) == "") {
  200. $InnerText = GetSysTemplets("list_fulllist.htm");
  201. } else {
  202. $InnerText = trim($ctag->GetInnerText());
  203. }
  204. $this->dtp->Assign(
  205. $tagid,
  206. $this->GetArcList(
  207. $limitstart,
  208. $row,
  209. $ctag->GetAtt("col"),
  210. $ctag->GetAtt("titlelen"),
  211. $ctag->GetAtt("infolen"),
  212. $ctag->GetAtt("imgwidth"),
  213. $ctag->GetAtt("imgheight"),
  214. $ctag->GetAtt("listtype"),
  215. $ctag->GetAtt("orderby"),
  216. $InnerText,
  217. $ctag->GetAtt("tablewidth"),
  218. $ismake,
  219. $ctag->GetAtt("orderway")
  220. )
  221. );
  222. } else if ($ctag->GetName() == "pagelist") {
  223. $list_len = trim($ctag->GetAtt("listsize"));
  224. $ctag->GetAtt("listitem") == "" ? $listitem = "info,index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem");
  225. if ($list_len == "") {
  226. $list_len = 3;
  227. }
  228. // var_dump($ismake);
  229. if ($ismake == 0) {
  230. $this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem));
  231. } else {
  232. $this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem));
  233. }
  234. }
  235. }
  236. }
  237. /**
  238. * 获得一个单列的文档列表
  239. *
  240. * @access public
  241. * @param int $limitstart 限制开始
  242. * @param int $row 行数
  243. * @param int $col 列数
  244. * @param int $titlelen 标题长度
  245. * @param int $infolen 描述长度
  246. * @param int $imgwidth 图片宽度
  247. * @param int $imgheight 图片高度
  248. * @param string $listtype 列表类型
  249. * @param string $orderby 排列顺序
  250. * @param string $innertext 底层模板
  251. * @param string $tablewidth 表格宽度
  252. * @param string $ismake 是否编译
  253. * @param string $orderWay 排序方式
  254. * @return string
  255. */
  256. function GetArcList(
  257. $limitstart = 0,
  258. $row = 10,
  259. $col = 1,
  260. $titlelen = 30,
  261. $infolen = 250,
  262. $imgwidth = 120,
  263. $imgheight = 90,
  264. $listtype = "all",
  265. $orderby = "default",
  266. $innertext = "",
  267. $tablewidth = "100",
  268. $ismake = 1,
  269. $orderWay = 'desc'
  270. ) {
  271. $getrow = ($row == '' ? 10 : $row);
  272. if ($limitstart == '') $limitstart = 0;
  273. if ($titlelen == '') $titlelen = 100;
  274. if ($infolen == '') $infolen = 250;
  275. if ($imgwidth == '') $imgwidth = 120;
  276. if ($imgheight == '') $imgheight = 120;
  277. if ($listtype == '') $listtype = 'all';
  278. $orderby = ($orderby == '' ? 'default' : strtolower($orderby));
  279. if ($orderWay == '') $orderWay = 'desc';
  280. $tablewidth = str_replace("%", "", $tablewidth);
  281. if ($tablewidth == '') $tablewidth = 100;
  282. if ($col == '') $col = 1;
  283. $colWidth = ceil(100 / $col);
  284. $tablewidth = $tablewidth . "%";
  285. $colWidth = $colWidth . "%";
  286. $innertext = trim($innertext);
  287. if ($innertext == '') $innertext = GetSysTemplets("list_fulllist.htm");
  288. $idlists = $ordersql = '';
  289. $this->dsql->SetQuery("SELECT aid FROM `#@__taglist` WHERE tid = '{$this->TagInfos['id']}' AND arcrank>-1 LIMIT $limitstart,$getrow");
  290. $this->dsql->Execute();
  291. while ($row = $this->dsql->GetArray()) {
  292. $idlists .= ($idlists == '' ? $row['aid'] : ',' . $row['aid']);
  293. }
  294. if ($idlists == '') return '';
  295. //按不同情况设定SQL条件
  296. $orwhere = " se.id IN($idlists) ";
  297. //排序方式
  298. if ($orderby == "sortrank") {
  299. $ordersql = " ORDER BY se.sortrank $orderWay";
  300. } else {
  301. $ordersql = " ORDER BY se.id $orderWay";
  302. }
  303. $query = "SELECT se.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  304. FROM `#@__archives` se LEFT JOIN `#@__arctype` tp ON se.typeid=tp.id 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>\r\n";
  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'] = $GLOBALS['cfg_cmspath'] . '/static/defaultpic.gif';
  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'] . "' border='0' width='$imgwidth' height='$imgheight' alt='" . 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'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
  363. }
  364. if (preg_match('/c/', $row['flag'])) {
  365. $row['title'] = "<b>" . $row['title'] . "</b>";
  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['templeturl'] = $GLOBALS['cfg_templeturl'];
  371. if (is_array($this->dtp2->CTags)) {
  372. foreach ($this->dtp2->CTags as $k => $ctag) {
  373. if ($ctag->GetName() == 'array') {
  374. //传递整个数组,在runphp模式中有特殊作用
  375. $this->dtp2->Assign($k, $row);
  376. } else {
  377. if (isset($row[$ctag->GetName()])) {
  378. $this->dtp2->Assign($k, $row[$ctag->GetName()]);
  379. } else {
  380. $this->dtp2->Assign($k, '');
  381. }
  382. }
  383. }
  384. }
  385. $artlist .= $this->dtp2->GetResult();
  386. } //if hasRow
  387. } //Loop Col
  388. if ($col > 1) {
  389. $i += $col - 1;
  390. $artlist .= " </div>\r\n";
  391. }
  392. } //Loop Line
  393. $this->dsql->FreeResult('al');
  394. return $artlist;
  395. }
  396. /**
  397. * 获取动态的分页列表
  398. *
  399. * @access public
  400. * @param int $list_len 列表宽度
  401. * @param string $listitem 列表样式
  402. * @return string
  403. */
  404. function GetPageListDM($list_len, $listitem = "info,index,end,pre,next,pageno")
  405. {
  406. $prepage = "";
  407. $nextpage = "";
  408. $prepagenum = $this->PageNo - 1;
  409. $nextpagenum = $this->PageNo + 1;
  410. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  411. $list_len = 3;
  412. }
  413. $totalpage = $this->TotalPage;
  414. if ($totalpage <= 1 && $this->TotalResult > 0) {
  415. return "<span class=\"pageinfo\">共1页/" . $this->TotalResult . "条</span>";
  416. }
  417. if ($this->TotalResult == 0) {
  418. return "<span class=\"pageinfo\">共0页/" . $this->TotalResult . "条</span>";
  419. }
  420. $maininfo = "<span class=\"pageinfo\">共{$totalpage}页/" . $this->TotalResult . "条</span>\r\n";
  421. $purl = $this->GetCurUrl();
  422. $purl .= "?/" . urlencode($this->Tag);
  423. //获得上一页和下一页的链接
  424. if ($this->PageNo != 1) {
  425. $prepage .= "<li><a href='" . $purl . "/$prepagenum/'>上一页</a></li>\r\n";
  426. $indexpage = "<li><a href='" . $purl . "/1/'>首页</a></li>\r\n";
  427. } else {
  428. $indexpage = "<li><a>首页</a></li>\r\n";
  429. }
  430. if ($this->PageNo != $totalpage && $totalpage > 1) {
  431. $nextpage .= "<li><a href='" . $purl . "/$nextpagenum/'>下一页</a></li>\r\n";
  432. $endpage = "<li><a href='" . $purl . "/$totalpage/'>末页</a></li>\r\n";
  433. } else {
  434. $endpage = "<li><a>末页</a></li>\r\n";
  435. }
  436. //获得数字链接
  437. $listdd = "";
  438. $total_list = $list_len * 2 + 1;
  439. if ($this->PageNo >= $total_list) {
  440. $j = $this->PageNo - $list_len;
  441. $total_list = $this->PageNo + $list_len;
  442. if ($total_list > $totalpage) {
  443. $total_list = $totalpage;
  444. }
  445. } else {
  446. $j = 1;
  447. if ($total_list > $totalpage) {
  448. $total_list = $totalpage;
  449. }
  450. }
  451. for ($j; $j <= $total_list; $j++) {
  452. if ($j == $this->PageNo) {
  453. $listdd .= "<li class=\"thisclass\"><a>$j</a></li>\r\n";
  454. } else {
  455. $listdd .= "<li><a href='" . $purl . "/$j/'>" . $j . "</a></li>\r\n";
  456. }
  457. }
  458. $plist = '';
  459. if (preg_match('/info/i', $listitem)) {
  460. $plist .= $maininfo . ' ';
  461. }
  462. if (preg_match('/index/i', $listitem)) {
  463. $plist .= $indexpage . ' ';
  464. }
  465. if (preg_match('/pre/i', $listitem)) {
  466. $plist .= $prepage . ' ';
  467. }
  468. if (preg_match('/pageno/i', $listitem)) {
  469. $plist .= $listdd . ' ';
  470. }
  471. if (preg_match('/next/i', $listitem)) {
  472. $plist .= $nextpage . ' ';
  473. }
  474. if (preg_match('/end/i', $listitem)) {
  475. $plist .= $endpage . ' ';
  476. }
  477. return $plist;
  478. }
  479. function GetPageListST($list_len, $listitem = "info,index,end,pre,next,pageno")
  480. {
  481. $prepage = "";
  482. $nextpage = "";
  483. $prepagenum = intval($this->PageNo) - 1;
  484. $nextpagenum = intval($this->PageNo) + 1;
  485. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  486. $list_len = 3;
  487. }
  488. $totalpage = $this->TotalPage;
  489. if ($totalpage <= 1 && $this->TotalResult > 0) {
  490. return "<span class=\"pageinfo\">共1页/" . $this->TotalResult . "条</span>";
  491. }
  492. if ($this->TotalResult == 0) {
  493. return "<span class=\"pageinfo\">共0页/" . $this->TotalResult . "条</span>";
  494. }
  495. $maininfo = "<span class=\"pageinfo\">共{$totalpage}页/" . $this->TotalResult . "条</span>\r\n";
  496. // $purl = $this->GetCurUrl();
  497. $purl = "/a/tags/" . GetPinyin($this->Tag);
  498. // var_dump($purl);
  499. //获得上一页和下一页的链接
  500. if ($this->PageNo != 1) {
  501. $prepage .= "<li><a href='" . $purl . "/$prepagenum/'>上一页</a></li>\r\n";
  502. $indexpage = "<li><a href='" . $purl . "/1/'>首页</a></li>\r\n";
  503. } else {
  504. $indexpage = "<li><a>首页</a></li>\r\n";
  505. }
  506. if ($this->PageNo != $totalpage && $totalpage > 1) {
  507. $nextpage .= "<li><a href='" . $purl . "/$nextpagenum/'>下一页</a></li>\r\n";
  508. $endpage = "<li><a href='" . $purl . "/$totalpage/'>末页</a></li>\r\n";
  509. } else {
  510. $endpage = "<li><a>末页</a></li>\r\n";
  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=\"thisclass\"><a>$j</a></li>\r\n";
  530. } else {
  531. $listdd .= "<li><a href='" . $purl . "/$j/'>" . $j . "</a></li>\r\n";
  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. // 生成静态Tag
  561. function MakeHtml($startpage = 1, $makepagesize = 0)
  562. {
  563. global $cfg_dir_purview, $envs;
  564. $envs['makeTag'] = 1;
  565. if (empty($this->TotalResult) && $this->Tag != "") $this->CountRecord();
  566. //初步给固定值的标记赋值
  567. $this->ParseTempletsFirst();
  568. if ($this->Tag == "") {
  569. MkdirAll($this->GetTruePath() . "/a/tags/", $cfg_dir_purview);
  570. $this->dtp->SaveTo($this->GetTruePath() . "/a/tags/index.html");
  571. } else {
  572. $totalpage = ceil($this->TotalResult / $this->PageSize);
  573. if ($totalpage == 0) {
  574. $totalpage = 1;
  575. }
  576. if ($makepagesize > 0) {
  577. $endpage = $startpage + $makepagesize;
  578. } else {
  579. $endpage = ($totalpage + 1);
  580. }
  581. if ($endpage >= $totalpage + 1) {
  582. $endpage = $totalpage + 1;
  583. }
  584. if ($endpage == 1) {
  585. $endpage = 2;
  586. }
  587. $makeDir = $this->GetTruePath() . "/a/tags/" . GetPinyin($this->Tag) . "/";
  588. MkdirAll($makeDir, $cfg_dir_purview);
  589. for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
  590. $this->ParseDMFields($this->PageNo, 1);
  591. $fileDir = $makeDir . "/" . $this->PageNo;
  592. MkdirAll($fileDir, $cfg_dir_purview);
  593. $this->dtp->SaveTo($fileDir . "/index.html");
  594. }
  595. if ($startpage == 1) {
  596. $list_1 = $makeDir . "/1/index.html";
  597. copy($list_1, $makeDir . "/index.html");
  598. }
  599. }
  600. }
  601. /**
  602. * 获得一个指定的频道的链接
  603. *
  604. * @access private
  605. * @param int $typeid 栏目ID
  606. * @param string $typedir 栏目目录
  607. * @param int $isdefault 是否为默认
  608. * @param string $defaultname 默认名称
  609. * @param int $ispart 栏目属性
  610. * @param string $namerule2 栏目规则
  611. * @param string $siteurl 站点地址
  612. * @return string
  613. */
  614. function GetListUrl($typeid, $typedir, $isdefault, $defaultname, $ispart, $namerule2, $siteurl = "")
  615. {
  616. return GetTypeUrl($typeid, MfTypedir($typedir), $isdefault, $defaultname, $ispart, $namerule2, $siteurl);
  617. }
  618. /**
  619. * 获得一个指定档案的链接
  620. *
  621. * @access private
  622. * @param int $aid 文档ID
  623. * @param int $typeid 栏目ID
  624. * @param int $timetag 时间戳
  625. * @param string $title 标题
  626. * @param int $ismake 是否生成静态
  627. * @param int $rank 浏览权限
  628. * @param string $namerule 命名规则
  629. * @param string $artdir 文档路径
  630. * @param int $money 需要金币
  631. * @param string $filename 文件名称
  632. * @return string
  633. */
  634. function GetArcUrl($aid, $typeid, $timetag, $title, $ismake = 0, $rank = 0, $namerule = "", $artdir = "", $money = 0, $filename = '')
  635. {
  636. return GetFileUrl($aid, $typeid, $timetag, $title, $ismake, $rank, $namerule, $artdir, $money, $filename);
  637. }
  638. /**
  639. * 获得当前的页面文件的url
  640. *
  641. * @access private
  642. * @return string
  643. */
  644. function GetCurUrl()
  645. {
  646. if (!empty($_SERVER["REQUEST_URI"])) {
  647. $nowurl = $_SERVER["REQUEST_URI"];
  648. $nowurls = explode("?", $nowurl);
  649. $nowurl = $nowurls[0];
  650. } else {
  651. $nowurl = $_SERVER["PHP_SELF"];
  652. }
  653. return $nowurl;
  654. }
  655. }//End Class