From 4f3afaaa208045f647ba75c9b84b36ccb839115d Mon Sep 17 00:00:00 2001 From: tianya Date: Mon, 21 Apr 2025 22:44:46 +0800 Subject: [PATCH] fix --- src/system/archive/listview.class.php | 32 ++- src/system/archive/sglistview.class.php | 316 +++++++++--------------- 2 files changed, 152 insertions(+), 196 deletions(-) diff --git a/src/system/archive/listview.class.php b/src/system/archive/listview.class.php index 22f88137..67899f1d 100755 --- a/src/system/archive/listview.class.php +++ b/src/system/archive/listview.class.php @@ -145,6 +145,33 @@ class ListView { global $cfg_list_son, $cfg_need_typeid2, $cfg_cross_sectypeid; if (empty($cfg_need_typeid2)) $cfg_need_typeid2 = 'N'; + $filtersql = ''; + //获得附加表的相关信息,联动单筛选 + $addtable = $this->ChannelUnit->ChannelInfos['addtable']; + if ($addtable!="") { + $addJoin = " LEFT JOIN `$addtable` ON arc.id = ".$addtable.'.aid '; + $addField = ''; + $fields = explode(',',$this->ChannelUnit->ChannelInfos['listfields']); + foreach($fields as $k=>$v) + { + $nfields[$v] = $k; + } + if (is_array($this->ChannelUnit->ChannelFields) && !empty($this->ChannelUnit->ChannelFields)) { + foreach($this->ChannelUnit->ChannelFields as $k=>$arr) + { + if (isset($nfields[$k])) { + if (!empty($arr['rename'])) { + $addField .= ','.$addtable.'.'.$k.' as '.$arr['rename']; + } else { + $addField .= ','.$addtable.'.'.$k; + } + } + } + } + } else { + $addField = ''; + $addJoin = ''; + } //统计数据库记录 $this->TotalResult = -1; if (isset($GLOBALS['TotalResult'])) $this->TotalResult = $GLOBALS['TotalResult']; @@ -192,7 +219,8 @@ class ListView } } if ($this->TotalResult==-1) { - $cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc WHERE ".$this->addSql; + //添加联动单筛选 + $cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc $addJoin WHERE ".$this->addSql; $row = $this->dsql->GetOne($cquery); if (is_array($row)) { $this->TotalResult = $row['dd']; @@ -845,7 +873,7 @@ class ListView if (preg_match('/senddate|pubdate|senddate|hot|click|weight|lastpost|rand/', $orderby)) { $query = "SELECT arc.*,tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,mb.uname,mb.face,mb.userid $addField FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb ON arc.mid=mb.mid $addJoin WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row"; } - //普通情况先从arctiny表查出id,然后按id查询速度非常快 + //普通情况先从arctiny表查出id,然后按di查询速度非常快 else { $t1 = ExecTime(); $ids = array(); diff --git a/src/system/archive/sglistview.class.php b/src/system/archive/sglistview.class.php index 2eb1cdf9..c3d4468e 100755 --- a/src/system/archive/sglistview.class.php +++ b/src/system/archive/sglistview.class.php @@ -9,8 +9,7 @@ if (!defined('DEDEINC')) exit('dedebiz'); * @license GNU GPL v2 (https://www.dedebiz.com/license) * @link https://www.dedebiz.com */ -require_once(DEDEINC.'/archive/partview.class.php'); -helper('cache'); +require_once(DEDEINC."/archive/partview.class.php"); @set_time_limit(0); class SgListView { @@ -63,7 +62,6 @@ class SgListView $this->TypeLink = new TypeLink($typeid); $this->searchArr = $searchArr; $this->mod = $mod; - $this->TotalResult = is_numeric($this->TotalResult) ? $this->TotalResult : ""; if (!is_array($this->TypeLink->TypeInfos)) { $this->IsError = true; } @@ -79,6 +77,7 @@ class SgListView $this->ListFields = explode(',', $listfield); //设置一些全局参数的值 foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; + $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; //api相关逻辑处理 if ($this->mod == 1 && empty($this->Fields['apikey'])) { echo json_encode(array( @@ -105,7 +104,6 @@ class SgListView exit; } } - $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."static/rss/".$this->TypeID.".xml"; //设置环境变量 SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); $this->Fields['typeid'] = $this->TypeID; @@ -115,9 +113,9 @@ class SgListView if ($this->TypeLink->TypeInfos['cross'] == 1) { $selquery = "SELECT id,topid FROM `#@__arctype` WHERE typename LIKE '{$this->Fields['typename']}' AND id<>'{$this->TypeID}' AND topid<>'{$this->TypeID}' "; } else { - $this->Fields['crossid'] = preg_replace('/[^0-9,]/', '', trim($this->Fields['crossid'])); + $this->Fields['crossid'] = preg_replace("/[^0-9,]/", '', trim($this->Fields['crossid'])); if ($this->Fields['crossid'] != '') { - $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id in({$this->Fields['crossid']}) AND id<>{$this->TypeID} AND topid<>{$this->TypeID} "; + $selquery = "SELECT id,topid FROM `#@__arctype` WHERE id IN({$this->Fields['crossid']}) AND id<>{$this->TypeID} AND topid<>{$this->TypeID} "; } } if ($selquery != '') { @@ -143,59 +141,51 @@ class SgListView * 统计列表里的记录 * * @access public - * @param string * @return void */ function CountRecord() { - global $cfg_list_son, $cfg_need_typeid2, $cfg_cross_sectypeid; - if (empty($cfg_need_typeid2)) $cfg_need_typeid2 = 'N'; - + global $cfg_list_son; //统计数据库记录 $this->TotalResult = -1; if (isset($GLOBALS['TotalResult'])) $this->TotalResult = $GLOBALS['TotalResult']; if (isset($GLOBALS['PageNo'])) $this->PageNo = $GLOBALS['PageNo']; else $this->PageNo = 1; $this->addSql = " arc.arcrank > -1 "; - $typeid2like = " '%,{$this->TypeID},%' "; - if ($cfg_list_son == 'N') { - if ($cfg_need_typeid2 == 'N') { + //栏目id条件 + if (!empty($this->TypeID)) { + if ($cfg_list_son == 'N') { if ($this->CrossID == '') $this->addSql .= " AND (arc.typeid='".$this->TypeID."') "; - else $this->addSql .= " AND (arc.typeid in({$this->CrossID},{$this->TypeID})) "; + else $this->addSql .= " AND (arc.typeid IN({$this->CrossID},{$this->TypeID})) "; } else { - if ($this->CrossID == '') { - $this->addSql .= " AND ( (arc.typeid='".$this->TypeID."') OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2like) "; + if ($this->CrossID == '') $this->addSql .= " AND (arc.typeid IN (".GetSonIds($this->TypeID, $this->Fields['channeltype']).") ) "; + else $this->addSql .= " AND (arc.typeid IN (".GetSonIds($this->TypeID, $this->Fields['channeltype']).",{$this->CrossID}) ) "; + } + } + $naddQuery = ''; + //地区与信息类型条件 + if (count($this->searchArr) > 0) { + if (!empty($this->searchArr['nativeplace'])) { + if ($this->searchArr['nativeplace'] % 500 == 0) { + $naddQuery .= " AND arc.nativeplace >= '{$this->searchArr['nativeplace']}' AND arc.nativeplace < '".($this->searchArr['nativeplace'] + 500)."'"; } else { - if ($cfg_cross_sectypeid == 'Y') { - $typeid2Clike = " '%,{$this->CrossID},%' "; - $this->addSql .= " AND ( arc.typeid IN({$this->CrossID},{$this->TypeID}) OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2like OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2Clike)"; - } else { - $this->addSql .= " AND ( arc.typeid IN({$this->CrossID},{$this->TypeID}) OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2like)"; - } + $naddQuery .= "AND arc.nativeplace = '{$this->searchArr['nativeplace']}'"; } } - } else { - $sonids = GetSonIds($this->TypeID, $this->Fields['channeltype']); - if (!preg_match("/,/", $sonids)) { - $sonidsCon = " arc.typeid = '$sonids' "; - } else { - $sonidsCon = " arc.typeid IN($sonids) "; - } - if ($cfg_need_typeid2 == 'N') { - if ($this->CrossID == '') $this->addSql .= " AND ( $sonidsCon ) "; - else $this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) ) "; - } else { - if ($this->CrossID == '') { - $this->addSql .= " AND ( $sonidsCon OR CONCAT(',', arc.typeid2, ',') like $typeid2like ) "; + if (!empty($this->searchArr['infotype'])) { + if ($this->searchArr['infotype'] % 500 == 0) { + $naddQuery .= " AND arc.infotype >= '{$this->searchArr['infotype']}' AND arc.infotype < '".($this->searchArr['infotype'] + 500)."'"; } else { - if ($cfg_cross_sectypeid == 'Y') { - $typeid2Clike = " '%,{$this->CrossID},%' "; - $this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2like OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2Clike) "; - } else { - $this->addSql .= " AND ( arc.typeid IN ({$sonids},{$this->CrossID}) OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2like) "; - } + $naddQuery .= "AND arc.infotype = '{$this->searchArr['infotype']}'"; } } + if (!empty($this->searchArr['keyword'])) { + $naddQuery .= "AND arc.title like '%{$this->searchArr['keyword']}%' "; + } + } + if ($naddQuery != '') { + $this->sAddTable = true; + $this->addSql .= $naddQuery; } if ($this->TotalResult == -1) { if ($this->sAddTable) { @@ -228,12 +218,12 @@ class SgListView $ctag = $this->dtp->GetTag("list"); } if (!is_object($ctag)) { - $this->pagesize = 30; + $this->pagesize = 20; } else { - if ($ctag->GetAtt("pagesize") != "") { - $this->pagesize = $ctag->GetAtt("pagesize"); + if ($ctag->GetAtt('pagesize') != '') { + $this->pagesize = $ctag->GetAtt('pagesize'); } else { - $this->pagesize = 30; + $this->pagesize = 20; } } } else { @@ -247,7 +237,7 @@ class SgListView * * @access public * @param string $startpage 开始页面 - * @param string $makepagesize 创建文件数目 + * @param string $makepagesize 生成尺寸 * @return string */ function MakeHtml($startpage = 1, $makepagesize = 0) @@ -271,9 +261,7 @@ class SgListView if ($totalpage == 0) { $totalpage = 1; } - if ($this->TypeLink->TypeInfos['isdefault'] != -1) { - CreateDir(MfTypedir($this->Fields['typedir'])); - } + CreateDir(MfTypedir($this->Fields['typedir'])); $murl = ''; if ($makepagesize > 0) { $endpage = $startpage + $makepagesize; @@ -299,12 +287,15 @@ class SgListView $murl = $this->GetTrueUrl($murl); $this->dtp->SaveTo($makeFile); if (PHP_SAPI === 'cli') { - DedeCli::showProgress(ceil(($this->PageNo / ($endpage-1)) * 100), 100); + DedeCli::showProgress(ceil(($this->PageNo / $endpage) * 100), 100); } } if ($startpage == 1) { //如果列表启用封面文件,复制这个文件第一页 - if ($this->TypeLink->TypeInfos['isdefault'] == 1 && $this->TypeLink->TypeInfos['ispart'] == 0) { + if ( + $this->TypeLink->TypeInfos['isdefault'] == 1 + && $this->TypeLink->TypeInfos['ispart'] == 0 + ) { $onlyrule = $this->GetMakeFileRule($this->Fields['id'], "list", $this->Fields['typedir'], '', $this->Fields['namerule2']); $onlyrule = str_replace("{page}", "1", $onlyrule); $list_1 = $this->GetTruePath().$onlyrule; @@ -329,16 +320,6 @@ class SgListView return; } $this->CountRecord(); - if ((empty($this->PageNo) || $this->PageNo == 1) && $this->TypeLink->TypeInfos['ispart'] == 1) { - $tmpdir = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']; - $tempfile = str_replace("{tid}", $this->TypeID, $this->Fields['tempindex']); - $tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); - $tempfile = $tmpdir."/".$tempfile; - if (!file_exists($tempfile)) { - $tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default_sg.htm"; - } - $this->dtp->LoadTemplate($tempfile); - } $this->ParseTempletsFirst(); $this->ParseDMFields($this->PageNo, 0); $this->dtp->Display(); @@ -364,25 +345,19 @@ class SgListView * GetAPIList * * @param mixed $PageNo 页码 - * @param mixed $row 条数 - * @param mixed $titlelen 标题字符长度 - * @param mixed $infolen 描述字符长度 + * @param mixed $row 行数 + * @param mixed $titlelen 标题宽度 * @param mixed $orderby 排序 * @param mixed $orderWay 排序方式 * @return array */ - function GetAPIList($PageNo = 1,$row = 10,$titlelen = 30,$infolen = 250,$orderby = "default",$orderWay = 'desc') { + function GetAPIList($PageNo, $row = 10, $titlelen = 30, $orderby = "default", $orderWay = 'desc') + { $limitstart = ($PageNo - 1) * $row; - if ($row == '') $row = 10; - if ($limitstart == '') $limitstart = 0; if ($titlelen == '') $titlelen = 100; - if ($infolen == '') $infolen = 250; + if ($orderby == '') $orderby = 'id'; + else $orderby = strtolower($orderby); if ($orderWay == '') $orderWay = 'desc'; - if ($orderby == '') { - $orderby = 'default'; - } else { - $orderby = strtolower($orderby); - } //排序方式 $ordersql = ''; if ($orderby == "senddate") { @@ -392,7 +367,7 @@ class SgListView } else if ($orderby == "senddate") { $ordersql = " ORDER BY arc.senddate $orderWay"; } else if ($orderby == "id") { - $ordersql = " ORDER BY arc.id $orderWay"; + $ordersql = " ORDER BY arc.aid $orderWay"; } else if ($orderby == "hot" || $orderby == "click") { $ordersql = " ORDER BY arc.click $orderWay"; } else if($orderby == "weight") { @@ -408,7 +383,7 @@ class SgListView } $addField = 'arc.'.join(',arc.', $this->ListFields); //如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢 - if (preg_match('/senddate|pubdate|senddate|hot|click|weight|lastpost|rand/', $orderby) || $this->sAddTable) { + if (preg_match('/hot|click/', $orderby) || $this->sAddTable) { $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,mb.uname,mb.face,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb on arc.mid = mb.mid WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row"; } //普通情况先从arctiny表查出id,然后按id查询速度非常快 @@ -433,16 +408,16 @@ class SgListView $this->dsql->SetQuery($query); $this->dsql->Execute('al'); $t2 = ExecTime(); - $result = array(); $GLOBALS['autoindex'] = 0; + $result = array(); while ($row = $this->dsql->GetArray("al")) { $GLOBALS['autoindex']++; $ids[$row['aid']] = $row['id'] = $row['aid']; //处理一些特殊字段 - $row['infos'] = cn_substr($row['description'], $infolen); - if ($row['corank'] > 0 && $row['arcrank'] == 0) { - $row['arcrank'] = $row['corank']; - } + $row['ismake'] = 1; + $row['money'] = 0; + $row['arcrank'] = 0; + $row['filename'] = ''; $row['filename'] = $row['arcurl'] = GetFileUrl( $row['id'], $row['typeid'], @@ -476,28 +451,22 @@ class SgListView $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; } $row['picname'] = $row['litpic']; + $row['pubdate'] = $row['senddate']; $row['stime'] = GetDateMK($row['pubdate']); $row['typelink'] = "".$row['typename'].""; - $row['image'] = "<]/", "", $row['title'])."'>"; - $row['imglink'] = "".$row['image'].""; $row['fulltitle'] = $row['title']; $row['title'] = cn_substr($row['title'], $titlelen); - if ($row['color'] != '') { - $row['title'] = "".$row['title'].""; - } - if (preg_match('/c/', $row['flag'])) { + if (preg_match('/b/', $row['flag'])) { $row['title'] = "".$row['title'].""; } - $row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face']; $row['textlink'] = "".$row['title'].""; $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl']; $row['memberurl'] = $GLOBALS['cfg_memberurl']; - $row['userurl'] = $GLOBALS['cfg_memberurl'].'/index.php?uid='.$row['userid']; $row['templeturl'] = $GLOBALS['cfg_templeturl']; + $row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face']; + $row['userurl'] = $GLOBALS['cfg_memberurl'].'/index.php?uid='.$row['userid']; //编译附加表里的数据 - foreach ($row as $k => $v) { - $row[strtolower($k)] = $v; - } + foreach ($row as $k => $v) $row[strtolower($k)] = $v; foreach ($this->ChannelUnit->ChannelFields as $k => $arr) { if (isset($row[$k])) { $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]); @@ -533,9 +502,7 @@ class SgListView //跳转网址 return $this->Fields['typedir']; } - if ($this->TypeLink->TypeInfos['isdefault'] != -1) { - CreateDir(MfTypedir($this->Fields['typedir'])); - } + CreateDir(MfTypedir($this->Fields['typedir'])); $makeUrl = $this->GetMakeFileRule($this->Fields['id'], "index", MfTypedir($this->Fields['typedir']), $this->Fields['defaultname'], $this->Fields['namerule2']); $makeUrl = preg_replace("/\/{1,}/", "/", $makeUrl); $makeFile = $this->GetTruePath().$makeUrl; @@ -552,7 +519,6 @@ class SgListView * 显示单独模板页面 * * @access public - * @param string * @return void */ function DisplayPartTemplets() @@ -576,9 +542,7 @@ class SgListView header("Location:$gotourl"); exit(); } - if ($this->TypeLink->TypeInfos['isdefault'] != -1) { - CreateDir(MfTypedir($this->Fields['typedir'])); - } + CreateDir(MfTypedir($this->Fields['typedir'])); $makeUrl = $this->GetMakeFileRule($this->Fields['id'], "index", MfTypedir($this->Fields['typedir']), $this->Fields['defaultname'], $this->Fields['namerule2']); $makeFile = $this->GetTruePath().$makeUrl; if ($nmfa == 0) { @@ -606,11 +570,12 @@ class SgListView * 获得真实连接路径 * * @access public - * @param string $nurl 地址 + * @param string $nurl 连接地址 * @return string */ function GetTrueUrl($nurl) { + if (preg_match("/^http[s]?:\/\//", $nurl)) return $nurl; if ($this->Fields['moresite'] == 1) { if ($this->Fields['sitepath'] != '') { $nurl = preg_replace("/^".$this->Fields['sitepath']."/", '', $nurl); @@ -622,7 +587,7 @@ class SgListView /** * 解析模板,对固定的标记进行初始给值 * - * @access public + * @access private * @return void */ function ParseTempletsFirst() @@ -632,7 +597,6 @@ class SgListView } $GLOBALS['envs']['channelid'] = $this->TypeLink->TypeInfos['channeltype']; $GLOBALS['envs']['typeid'] = $this->TypeID; - $GLOBALS['envs']['topid'] = GetTopid($this->Fields['typeid']); $GLOBALS['envs']['cross'] = 1; MakeOneTag($this->dtp, $this); } @@ -640,7 +604,7 @@ class SgListView * 解析模板,对文档里的变动进行赋值 * * @access public - * @param int $PageNo 页数 + * @param int $PageNo 页码 * @param int $ismake 是否编译 * @return void */ @@ -667,9 +631,6 @@ class SgListView $row, $ctag->GetAtt("col"), $ctag->GetAtt("titlelen"), - $ctag->GetAtt("infolen"), - $ctag->GetAtt("imgwidth"), - $ctag->GetAtt("imgheight"), $ctag->GetAtt("listtype"), $ctag->GetAtt("orderby"), $InnerText, @@ -698,11 +659,11 @@ class SgListView * 获得要创建的文件名称规则 * * @access public - * @param int $typeid 栏目id + * @param string $typeid 栏目id * @param string $wname * @param string $typedir 栏目目录 * @param string $defaultname 默认名称 - * @param string $namerule2 栏目规则 + * @param string $namerule2 名称规则 * @return string */ function GetMakeFileRule($typeid, $wname, $typedir, $defaultname, $namerule2) @@ -735,44 +696,25 @@ class SgListView * @param string $orderWay 排序方式 * @return string */ - function GetArcList( - $limitstart = 0, - $row = 10, - $col = 1, - $titlelen = 30, - $infolen = 250, - $imgwidth = 120, - $imgheight = 90, - $listtype = "all", - $orderby = "default", - $innertext = "", - $tablewidth = "100", - $ismake = 1, - $orderWay = 'desc' - ) { + function GetArcList($limitstart = 0, $row = 10, $col = 1, $titlelen = 30, $listtype = "all", $orderby = "default", $innertext = "", $tablewidth = "100", $ismake = 1, $orderWay = 'desc') + { + global $cfg_list_son; + $typeid = $this->TypeID; if ($row == '') $row = 10; if ($limitstart == '') $limitstart = 0; if ($titlelen == '') $titlelen = 100; - if ($infolen == '') $infolen = 250; - if ($imgwidth == '') $imgwidth = 120; - if ($imgheight == '') $imgheight = 120; - if ($listtype == '') $listtype = 'all'; + if ($listtype == '') $listtype = "all"; + if ($orderby == '') $orderby = 'id'; + else $orderby = strtolower($orderby); if ($orderWay == '') $orderWay = 'desc'; - if ($orderby == '') { - $orderby = 'default'; - } else { - $orderby = strtolower($orderby); - } - $tablewidth = str_replace('%', '', $tablewidth); + $tablewidth = str_replace("%", "", $tablewidth); if ($tablewidth == '') $tablewidth = 100; if ($col == '') $col = 1; $colWidth = ceil(100 / $col); - $tablewidth = $tablewidth.'%'; - $colWidth = $colWidth.'%'; + $tablewidth = $tablewidth."%"; + $colWidth = $colWidth."%"; $innertext = trim($innertext); - if ($innertext == '') { - $innertext = GetSysTemplets('list_fulllist.htm'); - } + if ($innertext == '') $innertext = GetSysTemplets('list_sglist.htm'); //排序方式 $ordersql = ''; if ($orderby == "senddate") { @@ -782,7 +724,7 @@ class SgListView } else if ($orderby == "senddate") { $ordersql = " ORDER BY arc.senddate $orderWay"; } else if ($orderby == "id") { - $ordersql = " ORDER BY arc.id $orderWay"; + $ordersql = " ORDER BY arc.aid $orderWay"; } else if ($orderby == "hot" || $orderby == "click") { $ordersql = " ORDER BY arc.click $orderWay"; } else if($orderby == "weight") { @@ -798,7 +740,7 @@ class SgListView } $addField = 'arc.'.join(',arc.', $this->ListFields); //如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢 - if (preg_match('/senddate|pubdate|senddate|hot|click|weight|lastpost|rand/', $orderby) || $this->sAddTable) { + if (preg_match('/hot|click/', $orderby) || $this->sAddTable) { $query = "SELECT tp.typedir,tp.typename,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,arc.aid,arc.aid AS id,arc.typeid,mb.uname,mb.face,mb.userid,$addField FROM `{$this->AddTable}` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb on arc.mid = mb.mid WHERE {$this->addSql} $ordersql LIMIT $limitstart,$row"; } //普通情况先从arctiny表查出id,然后按id查询速度非常快 @@ -833,12 +775,12 @@ class SgListView for ($j = 0; $j < $col; $j++) { if ($row = $this->dsql->GetArray("al")) { $GLOBALS['autoindex']++; - $ids[$row['id']] = $row['id']; + $ids[$row['aid']] = $row['id'] = $row['aid']; //处理一些特殊字段 - $row['infos'] = cn_substr($row['description'], $infolen); - if ($row['corank'] > 0 && $row['arcrank'] == 0) { - $row['arcrank'] = $row['corank']; - } + $row['ismake'] = 1; + $row['money'] = 0; + $row['arcrank'] = 0; + $row['filename'] = ''; $row['filename'] = $row['arcurl'] = GetFileUrl( $row['id'], $row['typeid'], @@ -872,28 +814,22 @@ class SgListView $row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; } $row['picname'] = $row['litpic']; + $row['pubdate'] = $row['senddate']; $row['stime'] = GetDateMK($row['pubdate']); $row['typelink'] = "".$row['typename'].""; - $row['image'] = "<]/", "", $row['title'])."'>"; - $row['imglink'] = "".$row['image'].""; $row['fulltitle'] = $row['title']; $row['title'] = cn_substr($row['title'], $titlelen); - if ($row['color'] != '') { - $row['title'] = "".$row['title'].""; - } - if (preg_match('/c/', $row['flag'])) { + if (preg_match('/b/', $row['flag'])) { $row['title'] = "".$row['title'].""; } - $row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face']; $row['textlink'] = "".$row['title'].""; $row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl']; $row['memberurl'] = $GLOBALS['cfg_memberurl']; - $row['userurl'] = $GLOBALS['cfg_memberurl'].'/index.php?uid='.$row['userid']; $row['templeturl'] = $GLOBALS['cfg_templeturl']; + $row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face']; + $row['userurl'] = $GLOBALS['cfg_memberurl'].'/index.php?uid='.$row['userid']; //编译附加表里的数据 - foreach ($row as $k => $v) { - $row[strtolower($k)] = $v; - } + foreach ($row as $k => $v) $row[strtolower($k)] = $v; foreach ($this->ChannelUnit->ChannelFields as $k => $arr) { if (isset($row[$k])) { $row[$k] = $this->ChannelUnit->MakeField($k, $row[$k]); @@ -929,16 +865,17 @@ class SgListView * 获取静态的分页列表 * * @access public - * @param string $list_len 列表宽度 - * @param string $list_len 列表样式 + * @param int $list_len 列表宽度 + * @param string $listitem 列表样式 * @return string */ function GetPageListST($list_len, $listitem = "index,end,pre,next,pageno") { - $prepage = $nextpage = ''; + $prepage = ''; + $nextpage = ''; $prepagenum = $this->PageNo - 1; $nextpagenum = $this->PageNo + 1; - if ($list_len == '' || preg_match("/[^0-9]/", $list_len)) { + if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) { $list_len = 3; } $totalpage = ceil($this->TotalResult / $this->pagesize); @@ -968,19 +905,6 @@ class SgListView } //option链接 $optionlist = ''; - $optionlen = strlen($totalpage); - $optionlen = $optionlen * 12 + 18; - if ($optionlen < 36) $optionlen = 36; - if ($optionlen > 100) $optionlen = 100; - $optionlist = "
  • "; //获得数字链接 $listdd = ''; $total_list = $list_len * 2 + 1; @@ -1017,17 +941,20 @@ class SgListView * 获取动态的分页列表 * * @access public - * @param string $list_len 列表宽度 - * @param string $list_len 列表样式 + * @param int $list_len 列表宽度 + * @param string $listitem 列表样式 * @return string */ function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno") { - global $cfg_rewrite; + global $nativeplace, $infotype, $keyword, $cfg_rewrite; + if (empty($nativeplace)) $nativeplace = 0; + if (empty($infotype)) $infotype = 0; + if (empty($keyword)) $keyword = ''; $prepage = $nextpage = ''; $prepagenum = $this->PageNo - 1; $nextpagenum = $this->PageNo + 1; - if ($list_len == '' || preg_match("/[^0-9]/", $list_len)) { + if ($list_len == "" || preg_match("/[^0-9]/", $list_len)) { $list_len = 3; } $totalpage = ceil($this->TotalResult / $this->pagesize); @@ -1037,7 +964,6 @@ class SgListView if ($this->TotalResult == 0) { return "
  • 0页".$this->TotalResult."条
  • "; } - $maininfo = "
  • {$totalpage}页".$this->TotalResult."条
  • "; $purl = $this->GetCurUrl(); //开启伪静态对规则替换 if ($cfg_rewrite == 'Y') { @@ -1046,21 +972,25 @@ class SgListView $nowurls = explode("?", $nowurls); $purl = $nowurls[0]; } - $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&"; - $purl .= '?'.$geturl; - $optionlist = ''; + $geturl = "&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&"; + $hidenform = ""; + $hidenform = ""; + $hidenform = ""; + $hidenform = ""; + $hidenform .= ""; + $purl .= "?tid=".$this->TypeID."&"; //获得上页和下页的链接 if ($this->PageNo != 1) { - $prepage .= "
  • 上页
  • "; - $indexpage = "
  • 首页
  • "; + $prepage .= "
  • 上页
  • "; + $indexpage = "
  • 首页
  • "; } else { - $indexpage = "
  • 首页
  • "; + $indexpage = "
  • 首页
  • "; } if ($this->PageNo != $totalpage && $totalpage > 1) { - $nextpage .= "
  • 下页
  • "; - $endpage = "
  • 末页
  • "; + $nextpage .= "
  • 下页
  • "; + $endpage = "
  • 末页
  • "; } else { - $endpage = "
  • 末页
  • "; + $endpage = "
  • 末页
  • "; } //获得数字链接 $listdd = ''; @@ -1081,7 +1011,7 @@ class SgListView if ($j == $this->PageNo) { $listdd .= "
  • $j
  • "; } else { - $listdd .= "
  • $j
  • "; + $listdd .= "
  • $j
  • "; } } $plist = ''; @@ -1090,8 +1020,6 @@ class SgListView if (preg_match('/pageno/i', $listitem)) $plist .= $listdd; if (preg_match('/next/i', $listitem)) $plist .= $nextpage; if (preg_match('/end/i', $listitem)) $plist .= $endpage; - if (preg_match('/option/i', $listitem)) $plist .= $optionlist; - if (preg_match('/info/i', $listitem)) $plist .= $maininfo; //伪静态栏目分页 if ($cfg_rewrite == 'Y') { $plist = str_replace("?tid=", "", $plist); @@ -1103,17 +1031,17 @@ class SgListView /** * 获得当前的页面文件链接 * - * @access public + * @access private * @return string */ function GetCurUrl() { - if (!empty($_SERVER['REQUEST_URI'])) { - $nowurl = $_SERVER['REQUEST_URI']; - $nowurls = explode('?', $nowurl); + if (!empty($_SERVER["REQUEST_URI"])) { + $nowurl = $_SERVER["REQUEST_URI"]; + $nowurls = explode("?", $nowurl); $nowurl = $nowurls[0]; } else { - $nowurl = $_SERVER['PHP_SELF']; + $nowurl = $_SERVER["PHP_SELF"]; } return $nowurl; }