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

239 lines
6.7KB

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