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

content_list.php 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. /**
  3. * 内容列表
  4. * content_s_list.php、content_i_list.php、content_select_list.php
  5. * 均使用本文件作为实际处理代码,只是使用的模板不同,如有相关变动,只需改本文件及相关模板即可
  6. *
  7. * @version $Id: content_list.php 1 14:31 2010年7月12日Z tianya $
  8. * @package DedeCMS.Administrator
  9. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  10. * @copyright Copyright (c) 2020, DedeBIZ.COM
  11. * @license https://www.dedebiz.com/license/v6
  12. * @link https://www.dedebiz.com
  13. */
  14. require_once(dirname(__FILE__).'/config.php');
  15. require_once(DEDEINC.'/typelink.class.php');
  16. require_once(DEDEINC.'/datalistcp.class.php');
  17. require_once(DEDEADMIN.'/inc/inc_list_functions.php');
  18. $cid = isset($cid) ? intval($cid) : 0;
  19. $channelid = isset($channelid) ? intval($channelid) : 0;
  20. $mid = isset($mid) ? intval($mid) : 0;
  21. if(!isset($keyword)) $keyword = '';
  22. if(!isset($flag)) $flag = '';
  23. if(!isset($f)) $f = '';
  24. if(!isset($arcrank)) $arcrank = '';
  25. if(!isset($dopost)) $dopost = '';
  26. $arcrank = RemoveXSS($arcrank);
  27. //检查权限许可,总权限
  28. CheckPurview('a_List,a_AccList,a_MyList');
  29. //栏目浏览许可
  30. $userCatalogSql = '';
  31. if(TestPurview('a_List'))
  32. {
  33. ;
  34. }
  35. else if(TestPurview('a_AccList'))
  36. {
  37. if($cid==0 && $cfg_admin_channel == 'array')
  38. {
  39. $admin_catalog = join(',', $admin_catalogs);
  40. $userCatalogSql = " arc.typeid IN($admin_catalog) ";
  41. }
  42. else
  43. {
  44. CheckCatalog($cid, '你无权浏览非指定栏目的内容!');
  45. }
  46. if(TestPurview('a_MyList')) $mid = $cuserLogin->getUserID();
  47. }
  48. $adminid = $cuserLogin->getUserID();
  49. $maintable = '#@__archives';
  50. setcookie('ENV_GOBACK_URL', $dedeNowurl, time()+3600, '/');
  51. $tl = new TypeLink($cid);
  52. //----------------------------------------
  53. //在不指定排序条件和关键字的情况下直接统计微表
  54. //----------------------------------------
  55. if(empty($totalresult) && empty($keyword) && empty($orderby) && empty($flag))
  56. {
  57. $tinyQuerys = array();
  58. if(!empty($userCatalogSql))
  59. {
  60. $tinyQuerys[] = str_replace('arc.', '', $userCatalogSql);
  61. }
  62. if(!empty($channelid) && empty($cid))
  63. {
  64. $tinyQuerys[] = " channel = '$channelid' ";
  65. }
  66. else
  67. {
  68. $tinyQuerys[] = " channel>0 ";
  69. }
  70. if(!empty($arcrank))
  71. {
  72. $tinyQuerys[] = " arcrank='$arcrank' ";
  73. }
  74. else
  75. {
  76. $tinyQuerys[] = " arcrank > -2 ";
  77. }
  78. if(!empty($mid))
  79. {
  80. $tinyQuerys[] = " mid='$mid' ";
  81. }
  82. if(!empty($cid))
  83. {
  84. $tinyQuerys[] = " typeid in(".GetSonIds($cid).") ";
  85. }
  86. if(count($tinyQuerys)>0)
  87. {
  88. $tinyQuery = "WHERE ".join(' AND ',$tinyQuerys);
  89. }
  90. // 缓存处理
  91. $sql = "SELECT COUNT(*) AS dd FROM `#@__arctiny` $tinyQuery ";
  92. $arr = $dsql->GetOne($sql);
  93. $totalresult = $arr['dd'];
  94. }
  95. if($cid==0)
  96. {
  97. if($channelid==0)
  98. {
  99. $positionname = '所有栏目&gt;';
  100. }
  101. else
  102. {
  103. $row = $tl->dsql->GetOne("SELECT id,typename,maintable FROM `#@__channeltype` WHERE id='$channelid'");
  104. $positionname = $row['typename']." &gt; ";
  105. $maintable = $row['maintable'];
  106. $channelid = $row['id'];
  107. }
  108. }
  109. else
  110. {
  111. $positionname = str_replace($cfg_list_symbol," &gt; ",$tl->GetPositionName())." &gt; ";
  112. }
  113. //当选择的是单表模型栏目时,直接跳转到单表模型管理区
  114. if(empty($channelid)
  115. && isset($tl->TypeInfos['channeltype']))
  116. {
  117. $channelid = $tl->TypeInfos['channeltype'];
  118. }
  119. if($channelid < -1 )
  120. {
  121. header("location:content_sg_list.php?f=$f&cid=$cid&channelid=$channelid&keyword=$keyword");
  122. exit();
  123. }
  124. // 栏目大于800则需要缓存数据
  125. $optHash = md5($cid. serialize($admin_catalogs).$channelid);
  126. $optCache = DEDEDATA."/tplcache/inc_option_$optHash.inc";
  127. $typeCount = 0;
  128. if (file_exists($cache1)) require_once($cache1);
  129. else $cfg_Cs = array();
  130. $typeCount = count($cfg_Cs);
  131. if ( $typeCount > 800)
  132. {
  133. if (file_exists($optCache))
  134. {
  135. $optionarr = file_get_contents($optCache);
  136. } else {
  137. $optionarr = $tl->GetOptionArray($cid, $admin_catalogs, $channelid);
  138. file_put_contents($optCache, $optionarr);
  139. }
  140. } else {
  141. $optionarr = $tl->GetOptionArray($cid, $admin_catalogs, $channelid);
  142. }
  143. $whereSql = empty($channelid) ? " WHERE arc.channel > 0 AND arc.arcrank > -2 " : " WHERE arc.channel = '$channelid' AND arc.arcrank > -2 ";
  144. $flagsArr = '';
  145. $dsql->Execute('f', 'SELECT * FROM `#@__arcatt` ORDER BY sortid ASC');
  146. while($frow = $dsql->GetArray('f'))
  147. {
  148. $flagsArr .= ($frow['att']==$flag ? "<option value='{$frow['att']}' selected>{$frow['attname']}</option>\r\n" : "<option value='{$frow['att']}'>{$frow['attname']}</option>\r\n");
  149. }
  150. if(!empty($userCatalogSql))
  151. {
  152. $whereSql .= " AND ".$userCatalogSql;
  153. }
  154. if(!empty($mid))
  155. {
  156. $whereSql .= " AND arc.mid = '$mid' ";
  157. }
  158. if($keyword != '')
  159. {
  160. $whereSql .= " AND ( CONCAT(arc.title,arc.writer) LIKE '%$keyword%') ";
  161. }
  162. if($flag != '')
  163. {
  164. $whereSql .= " AND FIND_IN_SET('$flag', arc.flag) ";
  165. }
  166. if($cid != 0)
  167. {
  168. $whereSql .= ' AND arc.typeid IN ('.GetSonIds($cid).')';
  169. }
  170. if($arcrank != '')
  171. {
  172. $whereSql .= " AND arc.arcrank = '$arcrank' ";
  173. $CheckUserSend = "<button type='button' class='btn btn-secondary btn-sm' onClick=\"location='catalog_do.php?cid=".$cid."&dopost=listArchives&gurl=content_list.php';\">所有文档</button>";
  174. }
  175. else
  176. {
  177. $CheckUserSend = "<button type='button' class='btn btn-secondary btn-sm' onClick=\"location='catalog_do.php?cid=".$cid."&dopost=listArchives&arcrank=-1&gurl=content_list.php';\">稿件审核</button>";
  178. }
  179. $orderby = empty($orderby) ? 'id' : preg_replace("#[^a-z0-9]#", "", $orderby);
  180. $orderbyField = 'arc.'.$orderby;
  181. $query = "SELECT arc.id,arc.typeid,arc.senddate,arc.flag,arc.ismake,
  182. arc.channel,arc.arcrank,arc.click,arc.title,arc.color,arc.litpic,arc.pubdate,arc.mid
  183. FROM `$maintable` arc
  184. $whereSql
  185. ORDER BY $orderbyField DESC";
  186. if(empty($f) || !preg_match("#form#", $f)) $f = 'form1.arcid1';
  187. //初始化
  188. $dlist = new DataListCP();
  189. $dlist->pageSize = 30;
  190. //GET参数
  191. $dlist->SetParameter('dopost', 'listArchives');
  192. $dlist->SetParameter('keyword', $keyword);
  193. if(!empty($mid)) $dlist->SetParameter('mid', $mid);
  194. $dlist->SetParameter('cid', $cid);
  195. $dlist->SetParameter('flag', $flag);
  196. $dlist->SetParameter('orderby', $orderby);
  197. $dlist->SetParameter('arcrank', $arcrank);
  198. $dlist->SetParameter('channelid', $channelid);
  199. $dlist->SetParameter('f', $f);
  200. //模板
  201. if(empty($s_tmplets)) $s_tmplets = 'templets/content_list.htm';
  202. $dlist->SetTemplate(DEDEADMIN.'/'.$s_tmplets);
  203. //查询
  204. $dlist->SetSource($query);
  205. //显示
  206. $dlist->Display();
  207. // echo $dlist->queryTime;
  208. $dlist->Close();