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

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