php 文章调用类代码

2019-04-09 00:19:42王冬梅

*/
function getArticleListByCateId(){
$this->InitSql();
$Str_Loop = '';
$ReturnString = '';
$Template = $this->Template;
//文章列表
$SqlStr = 'SELECT * FROM `'.DB_TABLE_PRE . 'view_article`';
$SqlStr.= ' WHERE 1=1';
$SqlStr.=$this->SqlNotShow; //是否显示不显示的
$SqlStr.=$this->SqlCateId; //栏目
$SqlStr.=$this->SqlArea; //区域
$SqlStr.=$this->SqlFlag; //状态
$SqlStr.=$this->SqlPic; //图片
$SqlStr.=$this->SqlVideo; //视频
$SqlStr.=$this->SqlWhere; //额外的查询
$SqlStr.=$this->SqlOrder; //排序
$SqlStr.=$this->SqlLimit; //显示条数
$this->SqlStr=$SqlStr;
$this->OrderBy2 = '';
$this->OrderSort2 = '';
//标题1
@preg_match('/{title|([d].+?)}/i', $Template, $matches);
@$title_count = $matches[1];
//标题2
@preg_match('/{title2|([d].+?)}/i', $Template, $matches);
@$title2_count = $matches[1];
//调用文字
@preg_match('/{memo|([d].+?)}/i', $Template, $matches);
@$memo_count = $matches[1];
//时间显示格式
@preg_match('/{posttime|(.+?)}/i', $Template, $matches);
@$posttime_format=$matches[1];
//替换掉这些
$Template = preg_replace('/({title|[d].+?})/i', '{title}', $Template);
$Template = preg_replace('/({title2|[d]+.?})/i', '{title2}', $Template);
$Template = preg_replace('/({posttime|.+?})/i', '{posttime}', $Template);
$Template = preg_replace('/({memo|[d].+?})/i', '{memo}', $Template);
//loop
$loop = $this->Loop;
$MyDatabase=Database::Get();
$MyDatabase->SqlStr = $SqlStr;
if ($MyDatabase->Query ()) {
$DB_Record_Arr = $MyDatabase->ResultArr;
foreach ( $DB_Record_Arr as $DB_Record ) {
$id = $DB_Record['id'];
$this->IdList .= $id . ',';
$title = $DB_Record['title'];
$title_full = $title;
$title2 = $DB_Record['title2'];
$titlestrip = strip_tags($title);
$memo = $DB_Record['memo'];
$posttime = $DB_Record['posttime'];
$reurl = $DB_Record['reurl'];
$url = $DB_Record['html'];
$hits = $DB_Record['hits'];
$titlecolor = $DB_Record['titlecolor'];
$catetitle = $DB_Record['catetitle'];
$catedir = $DB_Record['catedir'];
$catedesc = $DB_Record['catedesc'];
$Str_Loop = $Template;
//处理各个字符串
//跳转链接,如果存在,则文章链接为跳转链接
if ($reurl<>''){
$html = $reurl;
}else {
$html = SITE_URL . SITE_FOLDER . ARTICLEURL . $url;
}
$pic1 = $DB_Record['pic1'];
$pic2 = $DB_Record['pic2'];
if ($pic2<>''){
$pic = $pic2;
}else{
$pic = $pic1;
}
//标题长度 //调用文字
if ($title_count) $title = subString($title, $title_count);
if ($title2_count) $title2 = subString($title2, $title2_count);
if ($memo_count) $memo = subString($memo, $memo_count);
//文章标题颜色,用Style级别好像更高
if ($titlecolor<>'') $title = '<font style="color:'.$titlecolor.'">'.$title.'</font>';
相关文章 大家在看