/**
* Get the article list
* @ Param int $ count quantity
* @ Param null $ cate Category ID
* @ Param null $ auth user ID
* @ Param null $ date
* @ Param null $ tags tag
* @ Param null $ search keywords
* @ Param null $ order sorting
* @ Param null $ option
* @ Return array | mixed
*/
Function TcgetList ($ count = 10, $ cate = null, $ auth = null, $ date = null, $ tags = null, $ search = null, $ option = null, $ order = null ){
Global $ zbp;
If (! Is_array ($ option )){
$ Option = array ();
}
If (! Isset ($ option ['only _ ontop '])
$ Option ['only _ ontop '] = false;
If (! Isset ($ option ['only _ not_ontop '])
$ Option ['only _ not_ontop '] = false;
If (! Isset ($ option ['has _ subcate '])
$ Option ['has _ subcate'] = false;
If (! Isset ($ option ['is _ related'])
$ Option ['is _ related'] = false;
If ($ option ['is _ related']) {
$ At = $ zbp-> GetPostByID ($ option ['is _ related']);
$ Tags = $ at-> Tags;
If (! $ Tags)
Return array ();
$ Count = $ count + 1;
}
If ($ option ['only _ ontop '] = true ){
$ W [] = array ('=', 'log _ IsTop ', 0 );
} Elseif ($ option ['only _ not_ontop '] = true ){
$ W [] = array ('=', 'log _ IsTop ', 1 );
}
$ W = array ();
$ W [] = array ('=', 'log _ status', 0 );
$ Articles = array ();
If (! Is_null ($ cate )){
$ Category = new Category;
$ Category = $ zbp-> GetCategoryByID ($ cate );
If ($ category-> ID> 0 ){
If (! $ Option ['has _ subcate']) {
$ W [] = array ('=', 'log _ cateid', $ category-> ID );
} Else {
$ Arysubcate = array ();
$ Arysubcate [] = array ('log _ cateid', $ category-> ID );
Foreach ($ zbp-> categorys [$ category-> ID]-> SubCategorys as $ subcate ){
$ Arysubcate [] = array ('log _ cateid', $ subcate-> ID );
}
$ W [] = array ('array', $ arysubcate );
}
}
}
If (! Is_null ($ auth )){
$ Author = new Member;
$ Author = $ zbp-> GetMemberByID ($ auth );
If ($ author-> ID> 0 ){
$ W [] = array ('=', 'log _ authorid', $ author-> ID );
}
}
If (! Is_null ($ date )){
$ Datetime = strtotime ($ date );
If ($ datetime ){
$ Datetitle = str_replace (array ('% y %', '% m %'), array (date ('Y', $ datetime), date ('N ', $ datetime), $ zbp-> lang ['MSG '] ['Year _ month']);
$ W [] = array ('between', 'log _ posttime', $ datetime, strtotime ('+ 1 month', $ datetime ));
}
}
If (! Is_null ($ tags )){
$ Tag = new Tag;
If (is_array ($ tags )){
$ Ta = array ();
Foreach ($ tags as $ t ){
$ Ta [] = array ('log _ tag', '% {'. $ t-> ID. '} % ');
}
$ W [] = array ('Array _ like', $ ta );
Unset ($ ta );
} Else {
If (is_int ($ tags )){
$ Tag = $ zbp-> GetTagByID ($ tags );
} Else {
$ Tag = $ zbp-> GetTagByAliasOrName ($ tags );
}
If ($ tag-> ID> 0 ){
$ W [] = array ('like', 'log _ tag', '% {'. $ Tag-> ID. '} % ');
}
}
}
If (is_string ($ search )){
$ Search = trim ($ search );
If ($ search! = ''){
$ W [] = array ('search', 'log _ content', 'log _ intro', 'log _ title', $ search );
}
}
If (! Empty ($ order )){
If ($ order = 'new '){
$ Order = array ('log _ posttime' => 'desc ');
}
If ($ order = 'Hot '){
$ Order = array ('log _ viewnums' => 'desc ');
}
If ($ order = 'comm '){
$ Order = array ('log _ commnums' => 'desc ');
}
If ($ order = 'Rand '){
$ Order = array ('rand () '=> '');
}
}
$ Articles = $ zbp-> GetArticleList ('*', $ w, $ order, $ count, null, false );
If ($ option ['is _ related']) {
Foreach ($ articles as $ k => $ ){
If ($ a-> ID = $ option ['is _ related'])
Unset ($ articles [$ k]);
}
If (count ($ articles) = $ count ){
Array_pop ($ articles );
}
}
Return $ articles;
}
|