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

244 lines
6.8KB

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