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

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