ICMS一键按天按作者获取文章列表,在使用ICMS系统时候,在实际工作应用中可能涉及到多人多账户操作一个系统,并且工作中要求做报表的情况。做报表量少的情况可以直接少量复制,量大的时候我们就需要考虑如何提效率了。一下代码存入php文件中,访问PHP文件即可获取前面所提到的需求列表:

<?phprequire(dirname(__FILE__).'/iCMS.php');
header(
"Content-type:text/html;charset=utf-8");
$p=(int)$_GET['p']?(int)$_GET['p']:1;
//分页数$user=$_GET['user']?$_GET[
'user']:0;
$user=iSecurity::escapeStr($user);
$map_where=array();
$sql='';
$orderby='iddesc';
$pageSize=30;
$sqls=iDB::all(
"SELECTidFROM`icms_article`");
$total=count($sqls);
functionpageBar($total,$pageSize=20,$showPage=5,$user=0){
//第一个参数为条数第二个参数为每页显示几个需要与之前遍历数据处相同$page=(int)$_GET['p']?(int)$_GET[
'p']:1;
$user=$_GET['user']?$_GET['user']:0;
//获取作者$user=iSecurity::escapeStr($user);
if($user!="0"){
$sqlu=iDB::all(
"SELECTidFROM`icms_article`where`editor`like'%{$user}%'");
$total=count($sqlu);
}
$total=$total;
$totalPage=ceil($total/$pageSize);
//获取总页数$pageOffset=($showPage-1)/2;//页码偏移量$pageBanner="";if($total){
$pageBanner="<span>总条数:".$total."</span>";
}
$pageSelf=$_SERVER[
'PHP_SELF'];
$pageSelf=$pageSelf."?user=".$user."&";
$start=1;
//开始页码$end=$
totalPage;
//结束页码if($page>
1){
$pageBanner.="
<ahref='".$pageSelf."p=1'>
首页
</a>
";
$pageBanner.="
<ahref='".$pageSelf."p=".($page-1)."'>
上一页
</a>
";
}
if($totalPage>$showPage){
//当总页数大于显示页数时if($page>$pageOffset
+1){
//当当前页大于页码偏移量+1时,也就是当页码为4时开始页码1替换为...$pageBanner.="...";}if($page>$pageOffset){
//当当前页大于页码偏移量时开始页码变为当前页-偏移页码$start=$page-$pageOffset;
$end=$totalPage>$page+$pageOffset?$page+$pageOffset:$totalPage;
//如果当前页数+偏移量大于总页数那么$end为总页数}else{$start=1;$end=$totalPage>$showPage
?$showPage:$totalPage;
}
if($page+$pageOffset>$totalPage){
$start=$start-($page+$pageOffset-$end);
}
}
for($i=$start;$i<=$end;$i++){
//循环出页码if($i==$page){$pageBanner.="<span>".$i.
"</span>";
}else{
$pageBanner.="<ahref='".$pageSelf."p=".$i."'>".$i.
"</a>";
}
}
if($totalPage>
$showPage&&$totalPage>$page+$pageOffset){
//当总页数大于页码显示页数时且总页数大于当前页+偏移量
$pageBanner.="...";
}
if($page<$totalPage){
$pageBanner.="<ahref='".$pageSelf."p=".($page+1).
"'>下一页</a>";
$pageBanner.="<ahref='".$pageSelf."p=".$totalPage."'>尾页</a>";
}
if($total=="0"){
$pageBanner="暂无数据!";
}
echo$pageBanner;
}
if(($sql==""
)and($user!="0")){
$sql="where`editor`like'%{$user}%'";
}else
if(($sql=="")and($user=="0")){
$sql=$sql;
}else{
$sql.="and`editor`like'%{$user}%'"
;
}
$pagenote=$p-1;
if($pagenote<0){
$pagenote=0;
}
$pagenote=$pagenote*$pageSize;
$limit='LIMIT'.$pagenote.','.$pageSize;
$rs=iDB::all(
"SELECT*FROM`icms_article`{$sql}ORDERBY{$orderby}{$limit}");
$users=iDB::all(
"SELECTuid,username,nickname,statusFROM`icms_user`wherestatus=1ORDERBYuidDESC");
$categoryArray=category::multi_get($rs,'cid');
$scategoryArray=c
ategory::multi_get($rs,'scid');
if($rs)foreach($rsas$key=>
$value){
$C=(array)$categoryArray[$value['cid']];
$iurl=iURL::get('article',array($value,$C));
$value['url']=$iurl->href;
}
?>
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8">
<metahttp-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width,initial-scale=1">
<title>文章归档</title>
<!--Bootstrap-->
<linkhref="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"rel="stylesheet">
<!--[ifltIE9]>
<scriptsrc="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js">
</script>
<scriptsrc="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js">
</script>
<![endif]-->
</head>
<body>
<divstyle="margin-top:20px;">
<div>
<div>
<div>
<div>
<ul>
<li>发布者:
<selectname="user"id="user">
<optionvalue="0"<?phpif($user=="0"){echo"selected=''";}?>>显示全部</option>
<?phpif($users);foreach($usersas$k=>$v){if($v['nickname']!="技术部"){//unset($v['nickname']);$select="";if(($v['nickname']==$user)and$user!="0"){$select="selected";}echo"
<optionvalue='".$v['nickname']."'".$select.">".$v['nickname']."</option>";}}?></select>
</li>
</ul>
</div>
<tableclass="tabletable-condensedtable-hovertable-borderedtable-striped">
<tr>
<thcolspan="5"style="padding:10px010px5px;font-size:18px;">文章归档</th>
</tr>
<tr>
<th>时间</th>
<th>标题</th>
<th>url</th>
<th>栏目</th>
<th>发布人</th>
</tr>
<?phpif($rs)foreach($rsas$key=>$value){$C=(array)$categoryArray[$value['cid']];$iurl=iURL::get('article',array($value,$C));$value['url']=$iurl->href;?>
<tr>
<td>
<?phpif($value['pubdate'])echoget_date($value['pubdate'],'Y-m-dH:i');?>
</td>
<td>
<ahref="<?phpecho$value['url'];
?>"target="_blank">
<?phpecho$value['title'];?>
</a>
</td>
<td>
<?phpecho$value['url'];?>
</td>
<td>
<?phpecho$C['name'];?>
</td>
<td>
<?phpecho$value['editor'];?>
</td>
</tr>
<?php}?>
<tr>
<thcolspan="5">
<?phppageBar($total,$pageSize);?>
</th>
</tr>
</table>
</div>
</div>
</div>
</div>
<styletype="text/css">
*{
padding:0px;
margin:0px;
}
li{
list-style:none;
}
.titall{
width:100%;
height:auto;
overflow:hidden;
margin:auto;
}
.titallth{
text-align:center;
}
.successthspan{
color:#f00;
}
.successtha,.successthspan{
display:inline-block;
font-size:16px;
line-height:1.5;
padding:3px5px;
}
.successthspan.totla{
color:#2c2a2a;
margin-right:10px;
}
</style>
<scriptsrc="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js">
</script>
<scriptsrc="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js">
</script>
<scripttype="text/javascript">
$("#user").change(function(){
varuser=$("#user").val();
varhost=window.location.host;
varhref='http://'+host+'/updata.php?p=1&user='+user+'';
window.location.href=href;
});
</script>
</body>
</html>