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

860 lines
35KB

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