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

922 lines
36KB

  1. <?php if (!defined('DEDEINC')) exit("Request Error!");
  2. /**
  3. * 自由列表类
  4. *
  5. * @version $Id: arc.freelist.class.php 3 15:15 2010年7月7日Z tianya $
  6. * @package DedeBIZ.Libraries
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once DEDEINC . '/arc.partview.class.php';
  12. @set_time_limit(0);
  13. /**
  14. * 自由列表类
  15. *
  16. * @package FreeList
  17. * @subpackage DedeBIZ.Libraries
  18. * @link https://www.dedebiz.com
  19. */
  20. class FreeList
  21. {
  22. var $dsql;
  23. var $dtp;
  24. var $TypeID;
  25. var $TypeLink;
  26. var $PageNo;
  27. var $TotalPage;
  28. var $TotalResult;
  29. var $PageSize;
  30. var $ChannelUnit;
  31. var $Fields;
  32. var $PartView;
  33. var $FLInfos;
  34. var $ListObj;
  35. var $TempletsFile;
  36. var $maintable;
  37. //php5构造函数
  38. function __construct($fid)
  39. {
  40. global $dsql;
  41. $this->FreeID = $fid;
  42. $this->TypeLink = new TypeLink(0);
  43. $this->dsql = $dsql;
  44. $this->maintable = '#@__archives';
  45. $this->TempletsFile = '';
  46. $this->FLInfos = $this->dsql->GetOne("SELECT * FROM `#@__freelist` WHERE aid='$fid' ");
  47. $liststr = $this->FLInfos['listtag'];
  48. $this->FLInfos['maxpage'] = (empty($this->FLInfos['maxpage']) ? 100 : $this->FLInfos['maxpage']);
  49. //载入数据里保存的列表属性信息
  50. $ndtp = new DedeTagParse();
  51. $ndtp->SetNameSpace("dede", "{", "}");
  52. $ndtp->LoadString($liststr);
  53. $this->ListObj = $ndtp->GetTag('list');
  54. $this->PageSize = $this->ListObj->GetAtt('pagesize');
  55. if (empty($this->PageSize)) {
  56. $this->PageSize = 30;
  57. }
  58. $channelid = $this->ListObj->GetAtt('channel');
  59. /*
  60. if(empty($channelid))
  61. {
  62. showmsg('必须指定频道','-1');exit();
  63. }
  64. else
  65. {
  66. $channelid = intval($channelid);
  67. $channelinfo = $this->dsql->getone("select maintable from #@__channeltype where id='$channelid'");
  68. $this->maintable = $channelinfo['maintable'];
  69. }
  70. */
  71. $channelid = intval($channelid);
  72. $this->maintable = '#@__archives';
  73. //全局模板解析器
  74. $this->dtp = new DedeTagParse();
  75. $this->dtp->SetNameSpace("dede", "{", "}");
  76. $this->dtp->SetRefObj($this);
  77. //设置一些全局参数的值
  78. $this->Fields['aid'] = $this->FLInfos['aid'];
  79. $this->Fields['title'] = $this->FLInfos['title'];
  80. $this->Fields['position'] = "<li class=\"breadcrumb-item\">{$this->FLInfos['title']}</li>";
  81. $this->Fields['keywords'] = $this->FLInfos['keywords'];
  82. $this->Fields['description'] = $this->FLInfos['description'];
  83. $channelid = $this->ListObj->GetAtt('channel');
  84. if (!empty($channelid)) {
  85. $this->Fields['channeltype'] = $channelid;
  86. $this->ChannelUnit = new ChannelUnit($channelid);
  87. } else {
  88. $this->Fields['channeltype'] = 0;
  89. }
  90. foreach ($GLOBALS['PubFields'] as $k => $v) {
  91. $this->Fields[$k] = $v;
  92. }
  93. $this->PartView = new PartView();
  94. $this->CountRecord();
  95. }
  96. //php4构造函数
  97. function FreeList($fid)
  98. {
  99. $this->__construct($fid);
  100. }
  101. //关闭相关资源
  102. function Close()
  103. {
  104. }
  105. /**
  106. * 统计列表里的记录
  107. *
  108. * @access private
  109. * @return void
  110. */
  111. function CountRecord()
  112. {
  113. global $cfg_list_son, $cfg_needsontype;
  114. //统计数据库记录
  115. $this->TotalResult = -1;
  116. if (isset($GLOBALS['TotalResult'])) {
  117. $this->TotalResult = $GLOBALS['TotalResult'];
  118. }
  119. if (isset($GLOBALS['PageNo'])) {
  120. $this->PageNo = $GLOBALS['PageNo'];
  121. } else {
  122. $this->PageNo = 1;
  123. }
  124. //已经有总记录的值
  125. if ($this->TotalResult == -1) {
  126. $addSql = " arcrank > -1 AND channel>-1 ";
  127. $typeid = $this->ListObj->GetAtt('typeid');
  128. $subday = $this->ListObj->GetAtt('subday');
  129. $listtype = $this->ListObj->GetAtt('type');
  130. $att = $this->ListObj->GetAtt('att');
  131. $channelid = $this->ListObj->GetAtt('channel');
  132. if (empty($channelid)) {
  133. $channelid = 0;
  134. }
  135. //是否指定栏目条件
  136. if (!empty($typeid)) {
  137. if ($cfg_list_son == 'N') {
  138. $addSql .= " AND (typeid='$typeid') ";
  139. } else {
  140. $addSql .= " AND typeid in (" . GetSonIds($typeid, 0, TRUE) . ") ";
  141. }
  142. }
  143. //自定义属性条件
  144. if ($att != '') {
  145. $flags = explode(',', $att);
  146. for ($i = 0; isset($flags[$i]); $i++) $addSql .= " AND FIND_IN_SET('{$flags[$i]}',flag)>0 ";
  147. }
  148. //文档的频道模型
  149. if ($channelid > 0 && !preg_match("#spec#i", $listtype)) {
  150. $addSql .= " AND channel = '$channelid' ";
  151. }
  152. //推荐文档 带缩略图 专题文档
  153. if (preg_match("#commend#i", $listtype)) {
  154. $addSql .= " AND FIND_IN_SET('c',flag) > 0 ";
  155. }
  156. if (preg_match("#image#i", $listtype)) {
  157. $addSql .= " AND litpic <> '' ";
  158. }
  159. if (preg_match("#spec#i", $listtype) || $channelid == -1) {
  160. $addSql .= " AND channel = -1 ";
  161. }
  162. if (!empty($subday)) {
  163. $starttime = time() - $subday * 86400;
  164. $addSql .= " AND senddate > $starttime ";
  165. }
  166. $keyword = $this->ListObj->GetAtt('keyword');
  167. if (!empty($keyword)) {
  168. $addSql .= " AND CONCAT(title,keywords) REGEXP '$keyword' ";
  169. }
  170. $cquery = "SELECT COUNT(*) AS dd FROM `{$this->maintable}` WHERE $addSql";
  171. $row = $this->dsql->GetOne($cquery);
  172. if (is_array($row)) {
  173. $this->TotalResult = $row['dd'];
  174. } else {
  175. $this->TotalResult = 0;
  176. }
  177. }
  178. $this->TotalPage = ceil($this->TotalResult / $this->PageSize);
  179. if ($this->TotalPage > $this->FLInfos['maxpage']) {
  180. $this->TotalPage = $this->FLInfos['maxpage'];
  181. $this->TotalResult = $this->TotalPage * $this->PageSize;
  182. }
  183. }
  184. /**
  185. * 载入模板
  186. *
  187. * @access public
  188. * @return void
  189. */
  190. function LoadTemplet()
  191. {
  192. $tmpdir = $GLOBALS['cfg_basedir'] . $GLOBALS['cfg_templets_dir'];
  193. $tempfile = str_replace("{style}", $GLOBALS['cfg_df_style'], $this->FLInfos['templet']);
  194. $tempfile = $tmpdir . "/" . $tempfile;
  195. if (!file_exists($tempfile)) {
  196. $tempfile = $tmpdir . "/" . $GLOBALS['cfg_df_style'] . "/list_free.htm";
  197. }
  198. $this->dtp->LoadTemplate($tempfile);
  199. $this->TempletsFile = preg_replace("#^" . $GLOBALS['cfg_basedir'] . "#", '', $tempfile);
  200. }
  201. /**
  202. * 列表创建HTML
  203. *
  204. * @access public
  205. * @param string $startpage 开始页面
  206. * @param string $makepagesize 生成的页码数
  207. * @return string
  208. */
  209. function MakeHtml($startpage = 1, $makepagesize = 0)
  210. {
  211. $this->LoadTemplet();
  212. $murl = "";
  213. if (empty($startpage)) {
  214. $startpage = 1;
  215. }
  216. $this->ParseTempletsFirst();
  217. $totalpage = ceil($this->TotalResult / $this->PageSize);
  218. if ($totalpage == 0) {
  219. $totalpage = 1;
  220. }
  221. if ($makepagesize > 0) {
  222. $endpage = $startpage + $makepagesize;
  223. } else {
  224. $endpage = ($totalpage + 1);
  225. }
  226. if ($endpage > ($totalpage + 1)) {
  227. $endpage = $totalpage;
  228. }
  229. $firstFile = '';
  230. for ($this->PageNo = $startpage; $this->PageNo < $endpage; $this->PageNo++) {
  231. $this->ParseDMFields($this->PageNo, 1);
  232. //文件名
  233. $makeFile = $this->GetMakeFileRule();
  234. if (!preg_match("#^\/#", $makeFile)) {
  235. $makeFile = "/" . $makeFile;
  236. }
  237. $makeFile = str_replace('{page}', $this->PageNo, $makeFile);
  238. $murl = $makeFile;
  239. $makeFile = $GLOBALS['cfg_basedir'] . $makeFile;
  240. $makeFile = preg_replace("#\/{1,}#", "/", $makeFile);
  241. if ($this->PageNo == 1) {
  242. $firstFile = $makeFile;
  243. }
  244. //保存文件
  245. $this->dtp->SaveTo($makeFile);
  246. echo "<div class=\"alert alert-success\" role=\"alert\">成功创建:<a href='" . preg_replace("#\/{1,}#", "/", $murl) . "' target='_blank'>" . preg_replace("#\/{1,}#", "/", $murl) . "</a></div><br/>";
  247. }
  248. if ($this->FLInfos['nodefault'] == 0) {
  249. $murl = '/' . str_replace('{cmspath}', $GLOBALS['cfg_cmspath'], $this->FLInfos['listdir']);
  250. $murl .= '/' . $this->FLInfos['defaultpage'];
  251. $indexfile = $GLOBALS['cfg_basedir'] . $murl;
  252. $murl = preg_replace("#\/{1,}#", "/", $murl);
  253. echo "<div class=\"alert alert-success\" role=\"alert\">复制:$firstFile 为 " . $this->FLInfos['defaultpage'] . "</div><br/>";
  254. copy($firstFile, $indexfile);
  255. }
  256. $this->Close();
  257. return $murl;
  258. }
  259. /**
  260. * 显示列表
  261. *
  262. * @access public
  263. * @return void
  264. */
  265. function Display()
  266. {
  267. $this->LoadTemplet();
  268. $this->ParseTempletsFirst();
  269. $this->ParseDMFields($this->PageNo, 0);
  270. $this->dtp->Display();
  271. }
  272. /**
  273. * 显示单独模板页面
  274. *
  275. * @access public
  276. * @return void
  277. */
  278. function DisplayPartTemplets()
  279. {
  280. $nmfa = 0;
  281. $tmpdir = $GLOBALS['cfg_basedir'] . $GLOBALS['cfg_templets_dir'];
  282. if ($this->Fields['ispart'] == 1) {
  283. $tempfile = str_replace("{tid}", $this->FreeID, $this->Fields['tempindex']);
  284. $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile);
  285. $tempfile = $tmpdir . "/" . $tempfile;
  286. if (!file_exists($tempfile)) {
  287. $tempfile = $tmpdir . "/" . $GLOBALS['cfg_df_style'] . "/index_default.htm";
  288. }
  289. $this->PartView->SetTemplet($tempfile);
  290. } else if ($this->Fields['ispart'] == 2) {
  291. $tempfile = str_replace("{tid}", $this->FreeID, $this->Fields['tempone']);
  292. $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile);
  293. if (is_file($tmpdir . "/" . $tempfile)) {
  294. $this->PartView->SetTemplet($tmpdir . "/" . $tempfile);
  295. } else {
  296. $this->PartView->SetTemplet("这是没有使用模板的单独页!", "string");
  297. $nmfa = 1;
  298. }
  299. }
  300. CreateDir($this->Fields['typedir']);
  301. $makeUrl = $this->GetMakeFileRule($this->Fields['id'], "index", $this->Fields['typedir'], $this->Fields['defaultname'], $this->Fields['namerule2']);
  302. $makeFile = $this->GetTruePath() . $makeUrl;
  303. if ($nmfa == 0) {
  304. $this->PartView->Display();
  305. } else {
  306. if (!file_exists($makeFile)) {
  307. $this->PartView->Display();
  308. } else {
  309. include($makeFile);
  310. }
  311. }
  312. }
  313. /**
  314. * 解析模板,对固定的标记进行初始给值
  315. *
  316. * @access public
  317. * @return void
  318. */
  319. function ParseTempletsFirst()
  320. {
  321. MakeOneTag($this->dtp, $this);
  322. }
  323. /**
  324. * 解析模板,对内容里的变动进行赋值
  325. *
  326. * @access public
  327. * @param string $PageNo 页码
  328. * @param string $ismake 是否编译
  329. * @return string
  330. */
  331. function ParseDMFields($PageNo, $ismake = 1)
  332. {
  333. foreach ($this->dtp->CTags as $tagid => $ctag) {
  334. if ($ctag->GetName() == "freelist") {
  335. $limitstart = ($this->PageNo - 1) * $this->PageSize;
  336. if ($this->PageNo > $this->FLInfos['maxpage']) $this->dtp->Assign($tagid, '已经超过了最大允许列出的页面!');
  337. else $this->dtp->Assign($tagid, $this->GetList($limitstart, $ismake));
  338. } else if ($ctag->GetName() == "pagelist") {
  339. $list_len = trim($ctag->GetAtt("listsize"));
  340. $ctag->GetAtt("listitem") == "" ? $listitem = "info,index,pre,pageno,next,end,option" : $listitem = $ctag->GetAtt("listitem");
  341. if ($list_len == "") {
  342. $list_len = 3;
  343. }
  344. if ($ismake == 0) {
  345. $this->dtp->Assign($tagid, $this->GetPageListDM($list_len, $listitem));
  346. } else {
  347. $this->dtp->Assign($tagid, $this->GetPageListST($list_len, $listitem));
  348. }
  349. } else if ($ctag->GetName() == "pageno") {
  350. $this->dtp->Assign($tagid, $PageNo);
  351. }
  352. }
  353. }
  354. /**
  355. * 获得要创建的文件名称规则
  356. *
  357. * @access public
  358. * @return string
  359. */
  360. function GetMakeFileRule()
  361. {
  362. $okfile = '';
  363. $namerule = $this->FLInfos['namerule'];
  364. $listdir = $this->FLInfos['listdir'];
  365. $listdir = str_replace('{cmspath}', $GLOBALS['cfg_cmspath'], $listdir);
  366. $okfile = str_replace('{listid}', $this->FLInfos['aid'], $namerule);
  367. $okfile = str_replace('{listdir}', $listdir, $okfile);
  368. $okfile = str_replace("\\", "/", $okfile);
  369. $mdir = preg_replace("#/([^/]*)$#", "", $okfile);
  370. if (!preg_match("#\/#", $mdir) && preg_match("#\.#", $mdir)) {
  371. return $okfile;
  372. } else {
  373. CreateDir($mdir, '', '');
  374. return $okfile;
  375. }
  376. }
  377. /**
  378. * 获得一个单列的文档列表
  379. *
  380. * @access public
  381. * @param string $limitstart 开始限制
  382. * @param string $ismake 是否编译
  383. * @return string
  384. */
  385. function GetList($limitstart, $ismake = 1)
  386. {
  387. global $cfg_list_son, $cfg_needsontype;
  388. $col = $this->ListObj->GetAtt('col');
  389. if (empty($col)) {
  390. $col = 1;
  391. }
  392. $titlelen = $this->ListObj->GetAtt('titlelen');
  393. $infolen = $this->ListObj->GetAtt('infolen');
  394. $imgwidth = $this->ListObj->GetAtt('imgwidth');
  395. $imgheight = $this->ListObj->GetAtt('imgheight');
  396. $titlelen = AttDef($titlelen, 60);
  397. $infolen = AttDef($infolen, 250);
  398. $imgwidth = AttDef($imgwidth, 80);
  399. $imgheight = AttDef($imgheight, 80);
  400. $innertext = trim($this->ListObj->GetInnerText());
  401. if (empty($innertext)) $innertext = GetSysTemplets("list_fulllist.htm");
  402. $tablewidth = 100;
  403. if ($col == "") $col = 1;
  404. $colWidth = ceil(100 / $col);
  405. $tablewidth = $tablewidth . "%";
  406. $colWidth = $colWidth . "%";
  407. //按不同情况设定SQL条件
  408. $orwhere = " arc.arcrank > -1 AND channel>-1 ";
  409. $typeid = $this->ListObj->GetAtt('typeid');
  410. $subday = $this->ListObj->GetAtt('subday');
  411. $listtype = $this->ListObj->GetAtt('type');
  412. $att = $this->ListObj->GetAtt('att');
  413. $channelid = $this->ListObj->GetAtt('channel');
  414. if (empty($channelid)) $channelid = 0;
  415. //是否指定栏目条件
  416. if (!empty($typeid)) {
  417. if ($cfg_list_son == 'N') {
  418. $orwhere .= " AND (arc.typeid='$typeid') ";
  419. } else {
  420. $orwhere .= " AND arc.typeid IN (" . GetSonIds($typeid, 0, TRUE) . ") ";
  421. }
  422. }
  423. //自定义属性条件
  424. if ($att != '') {
  425. $flags = explode(',', $att);
  426. for ($i = 0; isset($flags[$i]); $i++) $orwhere .= " AND FIND_IN_SET('{$flags[$i]}',flag)>0 ";
  427. }
  428. //文档的频道模型
  429. if ($channelid > 0 && !preg_match("#spec#i", $listtype)) {
  430. $orwhere .= " AND arc.channel = '$channelid' ";
  431. }
  432. //推荐文档 带缩略图 专题文档
  433. if (preg_match("#commend#i", $listtype)) {
  434. $orwhere .= " AND FIND_IN_SET('c',flag) > 0 ";
  435. }
  436. if (preg_match("#image#i", $listtype)) {
  437. $orwhere .= " AND arc.litpic <> '' ";
  438. }
  439. if (preg_match("#spec#i", $listtype) || $channelid == -1) {
  440. $orwhere .= " AND arc.channel = -1 ";
  441. }
  442. if (!empty($subday)) {
  443. $starttime = time() - $subday * 86400;
  444. $orwhere .= " AND arc.senddate > $starttime ";
  445. }
  446. $keyword = $this->ListObj->GetAtt('keyword');
  447. if (!empty($keyword)) {
  448. $orwhere .= " AND CONCAT(arc.title,arc.keywords) REGEXP '$keyword' ";
  449. }
  450. $orderby = $this->ListObj->GetAtt('orderby');
  451. $orderWay = $this->ListObj->GetAtt('orderway');
  452. //排序方式
  453. $ordersql = "";
  454. if ($orderby == "senddate") {
  455. $ordersql = " ORDER BY arc.senddate $orderWay";
  456. } else if ($orderby == "pubdate") {
  457. $ordersql = " ORDER BY arc.pubdate $orderWay";
  458. } else if ($orderby == "id") {
  459. $ordersql = " ORDER BY arc.id $orderWay";
  460. } else if ($orderby == "hot" || $orderby == "click") {
  461. $ordersql = " ORDER BY arc.click $orderWay";
  462. } else if ($orderby == "lastpost") {
  463. $ordersql = " ORDER BY arc.lastpost $orderWay";
  464. } else if ($orderby == "scores") {
  465. $ordersql = " ORDER BY arc.scores $orderWay";
  466. } else if ($orderby == "rand") {
  467. $ordersql = " ORDER BY rand()";
  468. } else {
  469. $ordersql = " ORDER BY arc.sortrank $orderWay";
  470. }
  471. //获得附加表的相关信息
  472. $addField = "";
  473. $addJoin = "";
  474. if (is_object($this->ChannelUnit)) {
  475. $addtable = $this->ChannelUnit->ChannelInfos['addtable'];
  476. if ($addtable != "") {
  477. $addJoin = " LEFT JOIN $addtable ON arc.id = " . $addtable . ".aid ";
  478. $addField = "";
  479. $fields = explode(",", $this->ChannelUnit->ChannelInfos['listfields']);
  480. foreach ($fields as $k => $v) {
  481. $nfields[$v] = $k;
  482. }
  483. foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
  484. if (isset($nfields[$k])) {
  485. if (!empty($arr['rename'])) {
  486. $addField .= "," . $addtable . "." . $k . " as " . $arr['rename'];
  487. } else {
  488. $addField .= "," . $addtable . "." . $k;
  489. }
  490. }
  491. }
  492. }
  493. }
  494. $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,
  495. tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath
  496. $addField
  497. FROM {$this->maintable} arc
  498. LEFT JOIN #@__arctype tp ON arc.typeid=tp.id
  499. $addJoin
  500. WHERE $orwhere $ordersql LIMIT $limitstart," . $this->PageSize;
  501. $this->dsql->SetQuery($query);
  502. $this->dsql->Execute("al");
  503. $artlist = "";
  504. if ($col > 1) {
  505. $artlist = "<table width='$tablewidth' border='0' cellspacing='0' cellpadding='0'>\r\n";
  506. }
  507. $indtp = new DedeTagParse();
  508. $indtp->SetNameSpace("field", "[", "]");
  509. $indtp->LoadSource($innertext);
  510. $GLOBALS['autoindex'] = 0;
  511. for ($i = 0; $i < $this->PageSize; $i++) {
  512. if ($col > 1) {
  513. $artlist .= "<tr>\r\n";
  514. }
  515. for ($j = 0; $j < $col; $j++) {
  516. if ($col > 1) {
  517. $artlist .= "<td width='$colWidth'>\r\n";
  518. }
  519. if ($row = $this->dsql->GetArray("al")) {
  520. $GLOBALS['autoindex']++;
  521. //处理一些特殊字段
  522. $row['id'] = $row['id'];
  523. $row['arcurl'] = $this->GetArcUrl(
  524. $row['id'],
  525. $row['typeid'],
  526. $row['senddate'],
  527. $row['title'],
  528. $row['ismake'],
  529. $row['arcrank'],
  530. $row['namerule'],
  531. $row['typedir'],
  532. $row['money'],
  533. $row['filename'],
  534. $row['moresite'],
  535. $row['siteurl'],
  536. $row['sitepath']
  537. );
  538. $row['typeurl'] = GetTypeUrl(
  539. $row['typeid'],
  540. $row['typedir'],
  541. $row['isdefault'],
  542. $row['defaultname'],
  543. $row['ispart'],
  544. $row['namerule2'],
  545. $row['siteurl'],
  546. $row['sitepath']
  547. );
  548. if ($ismake == 0 && $GLOBALS['cfg_multi_site'] == 'Y') {
  549. if ($row["siteurl"] == "") {
  550. $row["siteurl"] = $GLOBALS['cfg_mainsite'];
  551. }
  552. }
  553. $row['description'] = cn_substr($row['description'], $infolen);
  554. if ($row['litpic'] == '-' || $row['litpic'] == '') {
  555. $row['litpic'] = $GLOBALS['cfg_cmspath'] . '/static/defaultpic.gif';
  556. }
  557. if (!preg_match("#^http:\/\/#i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') {
  558. $row['litpic'] = $GLOBALS['cfg_mainsite'] . $row['litpic'];
  559. }
  560. $row['picname'] = $row['litpic'];
  561. $row['info'] = $row['description'];
  562. $row['filename'] = $row['arcurl'];
  563. $row['stime'] = GetDateMK($row['pubdate']);
  564. $row['textlink'] = "<a href='" . $row['filename'] . "' title='" . str_replace("'", "", $row['title']) . "'>" . $row['title'] . "</a>";
  565. $row['typelink'] = "<a href='" . $row['typeurl'] . "'>[" . $row['typename'] . "]</a>";
  566. $row['imglink'] = "<a href='" . $row['filename'] . "'><img src='" . $row['picname'] . "' border='0' width='$imgwidth' height='$imgheight' alt='" . str_replace("'", "", $row['title']) . "'></a>";
  567. $row['image'] = "<img src='" . $row['picname'] . "' border='0' width='$imgwidth' height='$imgheight' alt='" . str_replace("'", "", $row['title']) . "'>";
  568. $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
  569. $row['memberurl'] = $GLOBALS['cfg_memberurl'];
  570. $row['templeturl'] = $GLOBALS['cfg_templeturl'];
  571. $row['title'] = cn_substr($row['title'], $titlelen);
  572. if ($row['color'] != "") {
  573. $row['title'] = "<font color='" . $row['color'] . "'>" . $row['title'] . "</font>";
  574. }
  575. if (preg_match("#c#", $row['flag'])) {
  576. $row['title'] = "<b>" . $row['title'] . "</b>";
  577. }
  578. //编译附加表里的数据
  579. if (is_object($this->ChannelUnit)) {
  580. foreach ($row as $k => $v) {
  581. if (preg_match("#[A-Z]#", $k)) {
  582. $row[strtolower($k)] = $v;
  583. }
  584. }
  585. foreach ($this->ChannelUnit->ChannelFields as $k => $arr) {
  586. if (isset($row[$k])) {
  587. $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]);
  588. }
  589. }
  590. }
  591. //解析单条记录
  592. if (is_array($indtp->CTags)) {
  593. foreach ($indtp->CTags as $k => $ctag) {
  594. $_f = $ctag->GetName();
  595. if ($_f == 'array') {
  596. //传递整个数组,在runphp模式中有特殊作用
  597. $indtp->Assign($k, $row);
  598. } else {
  599. if (isset($row[$_f])) {
  600. $indtp->Assign($k, $row[$_f]);
  601. } else {
  602. $indtp->Assign($k, "");
  603. }
  604. }
  605. }
  606. }
  607. $artlist .= $indtp->GetResult();
  608. } //if hasRow
  609. else {
  610. $artlist .= "";
  611. }
  612. if ($col > 1) {
  613. $artlist .= " </td>\r\n";
  614. }
  615. } //Loop Col
  616. if ($col > 1) {
  617. $i += $col - 1;
  618. }
  619. if ($col > 1) {
  620. $artlist .= " </tr>\r\n";
  621. }
  622. } //Loop Line
  623. if ($col > 1) {
  624. $artlist .= "</table>\r\n";
  625. }
  626. $this->dsql->FreeResult("al");
  627. return $artlist;
  628. }
  629. /**
  630. * 获取静态的分页列表
  631. *
  632. * @access public
  633. * @param string $list_len 列表尺寸
  634. * @param string $listitem 列表项目
  635. * @return string
  636. */
  637. function GetPageListST($list_len, $listitem = "info,index,end,pre,next,pageno")
  638. {
  639. $prepage = "";
  640. $nextpage = "";
  641. $prepagenum = $this->PageNo - 1;
  642. $nextpagenum = $this->PageNo + 1;
  643. if ($list_len == "" || preg_match("#[^0-9]#", $list_len)) {
  644. $list_len = 3;
  645. }
  646. $totalpage = ceil($this->TotalResult / $this->PageSize);
  647. if ($totalpage <= 1 && $this->TotalResult > 0) {
  648. return "<li class='page-item d-none d-sm-block disabled'><span class=\"page-link\">共1页/" . $this->TotalResult . "条记录</span></li>";
  649. }
  650. if ($this->TotalResult == 0) {
  651. return "<li class='page-item d-none d-sm-block disabled'><span class=\"page-link\">共0页/" . $this->TotalResult . "条记录</span></li>";
  652. }
  653. $maininfo = "<li class='page-item d-none d-sm-block disabled'><span class=\"page-link\">共{$totalpage}页/" . $this->TotalResult . "条记录</span></li>";
  654. $purl = $this->GetCurUrl();
  655. $tnamerule = $this->GetMakeFileRule();
  656. $tnamerule = preg_replace("#^(.*)\/#", '', $tnamerule);
  657. //获得上一页和主页的链接
  658. if ($this->PageNo != 1) {
  659. $prepage .= "<li class='page-item'><a class='page-link' href='" . str_replace("{page}", $prepagenum, $tnamerule) . "'>上一页</a></li>\r\n";
  660. $indexpage = "<li class='page-item'><a class='page-link' href='" . str_replace("{page}", 1, $tnamerule) . "'>首页</a></li>\r\n";
  661. } else {
  662. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  663. }
  664. //下一页,未页的链接
  665. if ($this->PageNo != $totalpage && $totalpage > 1) {
  666. $nextpage .= "<a href='" . str_replace("{page}", $nextpagenum, $tnamerule) . "'>下一页</a>\r\n";
  667. $endpage = "<a href='" . str_replace("{page}", $totalpage, $tnamerule) . "'>末页</a>\r\n";
  668. } else {
  669. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  670. }
  671. //option链接
  672. $optionlen = strlen($totalpage);
  673. $optionlen = $optionlen * 12 + 18;
  674. if ($optionlen < 36) $optionlen = 36;
  675. if ($optionlen > 100) $optionlen = 100;
  676. $optionlist = "<select name='sldd' style='width:$optionlen' onchange='location.href=this.options[this.selectedIndex].value;'>\r\n";
  677. for ($fl = 1; $fl <= $totalpage; $fl++) {
  678. if ($fl == $this->PageNo) {
  679. $optionlist .= "<option value='" . str_replace("{page}", $fl, $tnamerule) . "' selected>$fl</option>\r\n";
  680. } else {
  681. $optionlist .= "<option value='" . str_replace("{page}", $fl, $tnamerule) . "'>$fl</option>\r\n";
  682. }
  683. }
  684. $optionlist .= "</select>";
  685. //获得数字链接
  686. $listdd = "";
  687. $total_list = $list_len * 2 + 1;
  688. if ($this->PageNo >= $total_list) {
  689. $j = $this->PageNo - $list_len;
  690. $total_list = $this->PageNo + $list_len;
  691. if ($total_list > $totalpage) {
  692. $total_list = $totalpage;
  693. }
  694. } else {
  695. $j = 1;
  696. if ($total_list > $totalpage) {
  697. $total_list = $totalpage;
  698. }
  699. }
  700. for ($j; $j <= $total_list; $j++) {
  701. if ($j == $this->PageNo) {
  702. $listdd .= "<li class=\"page-item active\"><span class='page-link'>{$j}</span></li>\r\n";
  703. } else {
  704. $listdd .= "<li class='page-item'><a class='page-link' href='" . str_replace("{page}", $j, $tnamerule) . "'>" . $j . "</a></li>\r\n";
  705. }
  706. }
  707. $plist = "";
  708. if (preg_match('#info#i', $listitem)) {
  709. $plist .= $maininfo . ' ';
  710. }
  711. if (preg_match('#index#i', $listitem)) {
  712. $plist .= $indexpage . ' ';
  713. }
  714. if (preg_match('#pre#i', $listitem)) {
  715. $plist .= $prepage . ' ';
  716. }
  717. if (preg_match('#pageno#i', $listitem)) {
  718. $plist .= $listdd . ' ';
  719. }
  720. if (preg_match('#next#i', $listitem)) {
  721. $plist .= $nextpage . ' ';
  722. }
  723. if (preg_match('#end#i', $listitem)) {
  724. $plist .= $endpage . ' ';
  725. }
  726. if (preg_match('#option#i', $listitem)) {
  727. $plist .= $optionlist;
  728. }
  729. return $plist;
  730. }
  731. /**
  732. * 获取动态的分页列表
  733. *
  734. * @access public
  735. * @param string $list_len 列表尺寸
  736. * @param string $listitem 列表项目
  737. * @return string
  738. */
  739. function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno")
  740. {
  741. $prepage = "";
  742. $nextpage = "";
  743. $prepagenum = $this->PageNo - 1;
  744. $nextpagenum = $this->PageNo + 1;
  745. if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) {
  746. $list_len = 3;
  747. }
  748. $totalpage = ceil($this->TotalResult / $this->PageSize);
  749. if ($totalpage <= 1 && $this->TotalResult > 0) {
  750. return "<li class='page-item d-none d-sm-block disabled'><span class=\"page-link\">共1页/" . $this->TotalResult . "条记录</span></li>";
  751. }
  752. if ($this->TotalResult == 0) {
  753. return "<li class='page-item d-none d-sm-block disabled'><span class=\"page-link\">共0页/" . $this->TotalResult . "条记录</span></li>";
  754. }
  755. $maininfo = "<li class='page-item d-none d-sm-block disabled'><span class=\"page-link\">共{$totalpage}页/" . $this->TotalResult . "条记录</span></li>";
  756. $purl = $this->GetCurUrl();
  757. $geturl = "lid=" . $this->FreeID . "&TotalResult=" . $this->TotalResult . "&";
  758. $hidenform = "<input type='hidden' name='lid' value='" . $this->FreeID . "' />\r\n";
  759. $hidenform .= "<input type='hidden' name='TotalResult' value='" . $this->TotalResult . "' />\r\n";
  760. $purl .= "?" . $geturl;
  761. //获得上一页和下一页的链接
  762. if ($this->PageNo != 1) {
  763. $prepage .= "<li class='page-item'><a class='page-link' href='" . $purl . "PageNo=$prepagenum'>上一页</a>\r\n";
  764. $indexpage = "<li class='page-item'><a class='page-link' href='" . $purl . "PageNo=1'>首页</a>\r\n";
  765. } else {
  766. $indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>\r\n";
  767. }
  768. if ($this->PageNo != $totalpage && $totalpage > 1) {
  769. $nextpage .= "<li class='page-item'><a class='page-link' href='" . $purl . "PageNo=$nextpagenum'>下一页</a>\r\n";
  770. $endpage = "<li class='page-item'><a class='page-link' href='" . $purl . "PageNo=$totalpage'>末页</a>\r\n";
  771. } else {
  772. $endpage = "<li class='page-item'><span class='page-link'>末页</span></li>\r\n";
  773. }
  774. //获得数字链接
  775. $listdd = "";
  776. $total_list = $list_len * 2 + 1;
  777. if ($this->PageNo >= $total_list) {
  778. $j = $this->PageNo - $list_len;
  779. $total_list = $this->PageNo + $list_len;
  780. if ($total_list > $totalpage) $total_list = $totalpage;
  781. } else {
  782. $j = 1;
  783. if ($total_list > $totalpage) $total_list = $totalpage;
  784. }
  785. for ($j; $j <= $total_list; $j++) {
  786. if ($j == $this->PageNo) {
  787. $listdd .= "<li class=\"page-item active\"><span class='page-link'>$j</span></li>\r\n";
  788. } else {
  789. $listdd .= "<li class='page-item'><a class='page-link' href='" . $purl . "PageNo=$j'>" . $j . "</a></li>\r\n";
  790. }
  791. }
  792. $plist = "<form name='pagelist' action='" . $this->GetCurUrl() . "'>$hidenform";
  793. $plist .= $maininfo . $indexpage . $prepage . $listdd . $nextpage . $endpage;
  794. if ($totalpage > $total_list) {
  795. $plist .= "<input type='text' name='PageNo' value='" . $this->PageNo . "' style='width:30px' />\r\n";
  796. $plist .= "<input type='submit' name='plistgo' value='GO' />\r\n";
  797. }
  798. $plist .= "</form>\r\n";
  799. return $plist;
  800. }
  801. /**
  802. * 获得一个指定档案的链接
  803. *
  804. * @access public
  805. * @param int $aid 文档ID
  806. * @param int $typeid 栏目ID
  807. * @param int $timetag 时间戳
  808. * @param string $title 标题
  809. * @param int $ismake 是否生成
  810. * @param int $rank 阅读权限
  811. * @param string $namerule 名称规则
  812. * @param string $typedir 栏目dir
  813. * @param string $money 需要金币
  814. * @param string $filename 文件名称
  815. * @param string $moresite 多站点
  816. * @param string $siteurl 站点地址
  817. * @param string $sitepath 站点路径
  818. * @return string
  819. */
  820. function GetArcUrl(
  821. $aid,
  822. $typeid,
  823. $timetag,
  824. $title,
  825. $ismake = 0,
  826. $rank = 0,
  827. $namerule = '',
  828. $artdir = '',
  829. $money = 0,
  830. $filename = '',
  831. $moresite = '',
  832. $siteurl = '',
  833. $sitepath = ''
  834. ) {
  835. return GetFileUrl(
  836. $aid,
  837. $typeid,
  838. $timetag,
  839. $title,
  840. $ismake,
  841. $rank,
  842. $namerule,
  843. $artdir,
  844. $money,
  845. $filename,
  846. $moresite,
  847. $siteurl,
  848. $sitepath
  849. );
  850. }
  851. /**
  852. * 获得当前的页面文件的url
  853. *
  854. * @access public
  855. * @return void
  856. */
  857. function GetCurUrl()
  858. {
  859. if (!empty($_SERVER["REQUEST_URI"])) {
  860. $nowurl = $_SERVER["REQUEST_URI"];
  861. $nowurls = explode("?", $nowurl);
  862. $nowurl = $nowurls[0];
  863. } else {
  864. $nowurl = $_SERVER["PHP_SELF"];
  865. }
  866. return $nowurl;
  867. }
  868. }//End Class