Преглед изворни кода

提交细节优化,列表视图

tags/6.5.8
叙述、别离 пре 1 недеља
родитељ
комит
94f4de2337
4 измењених фајлова са 196 додато и 148 уклоњено
  1. +1
    -1
      src/admin/index_testenv.php
  2. +1
    -1
      src/static/web/css/admin.css
  3. +3
    -31
      src/system/archive/listview.class.php
  4. +191
    -115
      src/system/archive/sglistview.class.php

+ 1
- 1
src/admin/index_testenv.php Прегледај датотеку

@@ -129,7 +129,7 @@ if (!IsSSL()) {
$safeMsg[] = '检测到网址非安全链接,建议您部署https';
}
if (IsWritable(DEDEDATA.'/common.inc.php')) {
$safeMsg[] = '检测到data/common.inc.php数据库配置文件权限可以写入,建议您权限设置禁止写入和执行';
$safeMsg[] = '检测到data/common.inc.php数据库配置文件权限可以写入,建议您以最高管理员权限设置禁止写入和执行';
}
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$safeMsg[] = '检测到php版本过低会无法正常使用后台,建议您升级到php8.x';


+ 1
- 1
src/static/web/css/admin.css Прегледај датотеку

@@ -194,7 +194,7 @@ textarea {
width:100%;
height:60px;
line-height:60px;
background:linear-gradient(90deg,var(--green) 45%,var(--success-800) 100%)
background:linear-gradient(45deg,var(--green) 15%,var(--success-800) 100%)
}
.admin-head .logo {
padding-left:1rem;


+ 3
- 31
src/system/archive/listview.class.php Прегледај датотеку

@@ -1,5 +1,5 @@
<?php
if (!defined('DEDEINC')) exit('dedebiz');
if (!defined('DEDEINC')) exit ('dedebiz');
/**
* 文档列表
*
@@ -145,33 +145,6 @@ 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'];
@@ -219,8 +192,7 @@ class ListView
}
}
if ($this->TotalResult==-1) {
//添加联动单筛选
$cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc $addJoin WHERE ".$this->addSql;
$cquery = "SELECT COUNT(*) AS dd FROM `#@__arctiny` arc WHERE ".$this->addSql;
$row = $this->dsql->GetOne($cquery);
if (is_array($row)) {
$this->TotalResult = $row['dd'];
@@ -873,7 +845,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,然后按di查询速度非常快
//普通情况先从arctiny表查出id,然后按id查询速度非常快
else {
$t1 = ExecTime();
$ids = array();


+ 191
- 115
src/system/archive/sglistview.class.php Прегледај датотеку

@@ -1,5 +1,5 @@
<?php
if (!defined('DEDEINC')) exit('dedebiz');
if (!defined('DEDEINC')) exit ('dedebiz');
/**
* 自定义模型列表
*
@@ -9,7 +9,8 @@ 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");
require_once(DEDEINC.'/archive/partview.class.php');
helper('cache');
@set_time_limit(0);
class SgListView
{
@@ -62,6 +63,7 @@ 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;
}
@@ -77,7 +79,6 @@ 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(
@@ -104,6 +105,7 @@ 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;
@@ -113,9 +115,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 != '') {
@@ -141,51 +143,59 @@ class SgListView
* 统计列表里的记录
*
* @access public
* @param string
* @return void
*/
function CountRecord()
{
global $cfg_list_son;
global $cfg_list_son, $cfg_need_typeid2, $cfg_cross_sectypeid;
if (empty($cfg_need_typeid2)) $cfg_need_typeid2 = 'N';
//统计数据库记录
$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 ";
//栏目id条件
if (!empty($this->TypeID)) {
if ($cfg_list_son == 'N') {
$typeid2like = " '%,{$this->TypeID},%' ";
if ($cfg_list_son == 'N') {
if ($cfg_need_typeid2 == '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 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)."'";
if ($this->CrossID == '') {
$this->addSql .= " AND ( (arc.typeid='".$this->TypeID."') OR CONCAT(',', arc.typeid2, ',') LIKE $typeid2like) ";
} else {
$naddQuery .= "AND arc.nativeplace = '{$this->searchArr['nativeplace']}'";
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)";
}
}
}
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 {
$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 ) ";
} else {
$naddQuery .= "AND arc.infotype = '{$this->searchArr['infotype']}'";
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) ";
}
}
}
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) {
@@ -218,12 +228,12 @@ class SgListView
$ctag = $this->dtp->GetTag("list");
}
if (!is_object($ctag)) {
$this->pagesize = 20;
$this->pagesize = 30;
} else {
if ($ctag->GetAtt('pagesize') != '') {
$this->pagesize = $ctag->GetAtt('pagesize');
if ($ctag->GetAtt("pagesize") != "") {
$this->pagesize = $ctag->GetAtt("pagesize");
} else {
$this->pagesize = 20;
$this->pagesize = 30;
}
}
} else {
@@ -237,7 +247,7 @@ class SgListView
*
* @access public
* @param string $startpage 开始页面
* @param string $makepagesize 生成尺寸
* @param string $makepagesize 创建文件数目
* @return string
*/
function MakeHtml($startpage = 1, $makepagesize = 0)
@@ -261,7 +271,9 @@ class SgListView
if ($totalpage == 0) {
$totalpage = 1;
}
CreateDir(MfTypedir($this->Fields['typedir']));
if ($this->TypeLink->TypeInfos['isdefault'] != -1) {
CreateDir(MfTypedir($this->Fields['typedir']));
}
$murl = '';
if ($makepagesize > 0) {
$endpage = $startpage + $makepagesize;
@@ -287,15 +299,12 @@ class SgListView
$murl = $this->GetTrueUrl($murl);
$this->dtp->SaveTo($makeFile);
if (PHP_SAPI === 'cli') {
DedeCli::showProgress(ceil(($this->PageNo / $endpage) * 100), 100);
DedeCli::showProgress(ceil(($this->PageNo / ($endpage-1)) * 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;
@@ -320,6 +329,16 @@ 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();
@@ -345,19 +364,25 @@ class SgListView
* GetAPIList
*
* @param mixed $PageNo 页码
* @param mixed $row 行数
* @param mixed $titlelen 标题宽度
* @param mixed $row 条数
* @param mixed $titlelen 标题字符长度
* @param mixed $infolen 描述字符长度
* @param mixed $orderby 排序
* @param mixed $orderWay 排序方式
* @return array
*/
function GetAPIList($PageNo, $row = 10, $titlelen = 30, $orderby = "default", $orderWay = 'desc')
{
function GetAPIList($PageNo = 1,$row = 10,$titlelen = 30,$infolen = 250,$orderby = "default",$orderWay = 'desc') {
$limitstart = ($PageNo - 1) * $row;
if ($row == '') $row = 10;
if ($limitstart == '') $limitstart = 0;
if ($titlelen == '') $titlelen = 100;
if ($orderby == '') $orderby = 'id';
else $orderby = strtolower($orderby);
if ($infolen == '') $infolen = 250;
if ($orderWay == '') $orderWay = 'desc';
if ($orderby == '') {
$orderby = 'default';
} else {
$orderby = strtolower($orderby);
}
//排序方式
$ordersql = '';
if ($orderby == "senddate") {
@@ -367,7 +392,7 @@ class SgListView
} else if ($orderby == "senddate") {
$ordersql = " ORDER BY arc.senddate $orderWay";
} else if ($orderby == "id") {
$ordersql = " ORDER BY arc.aid $orderWay";
$ordersql = " ORDER BY arc.id $orderWay";
} else if ($orderby == "hot" || $orderby == "click") {
$ordersql = " ORDER BY arc.click $orderWay";
} else if($orderby == "weight") {
@@ -383,7 +408,7 @@ class SgListView
}
$addField = 'arc.'.join(',arc.', $this->ListFields);
//如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢
if (preg_match('/hot|click/', $orderby) || $this->sAddTable) {
if (preg_match('/senddate|pubdate|senddate|hot|click|weight|lastpost|rand/', $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查询速度非常快
@@ -408,16 +433,16 @@ class SgListView
$this->dsql->SetQuery($query);
$this->dsql->Execute('al');
$t2 = ExecTime();
$GLOBALS['autoindex'] = 0;
$result = array();
$GLOBALS['autoindex'] = 0;
while ($row = $this->dsql->GetArray("al")) {
$GLOBALS['autoindex']++;
$ids[$row['aid']] = $row['id'] = $row['aid'];
//处理一些特殊字段
$row['ismake'] = 1;
$row['money'] = 0;
$row['arcrank'] = 0;
$row['filename'] = '';
$row['infos'] = cn_substr($row['description'], $infolen);
if ($row['corank'] > 0 && $row['arcrank'] == 0) {
$row['arcrank'] = $row['corank'];
}
$row['filename'] = $row['arcurl'] = GetFileUrl(
$row['id'],
$row['typeid'],
@@ -451,22 +476,28 @@ class SgListView
$row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
}
$row['picname'] = $row['litpic'];
$row['pubdate'] = $row['senddate'];
$row['stime'] = GetDateMK($row['pubdate']);
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' title='".preg_replace("/['><]/", "", $row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['fulltitle'] = $row['title'];
$row['title'] = cn_substr($row['title'], $titlelen);
if (preg_match('/b/', $row['flag'])) {
if ($row['color'] != '') {
$row['title'] = "<span style='color:".$row['color']."'>".$row['title']."</span>";
}
if (preg_match('/c/', $row['flag'])) {
$row['title'] = "".$row['title']."";
}
$row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face'];
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
$row['memberurl'] = $GLOBALS['cfg_memberurl'];
$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'];
$row['templeturl'] = $GLOBALS['cfg_templeturl'];
//编译附加表里的数据
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]);
@@ -502,7 +533,9 @@ class SgListView
//跳转网址
return $this->Fields['typedir'];
}
CreateDir(MfTypedir($this->Fields['typedir']));
if ($this->TypeLink->TypeInfos['isdefault'] != -1) {
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;
@@ -519,6 +552,7 @@ class SgListView
* 显示单独模板页面
*
* @access public
* @param string
* @return void
*/
function DisplayPartTemplets()
@@ -542,7 +576,9 @@ class SgListView
header("Location:$gotourl");
exit();
}
CreateDir(MfTypedir($this->Fields['typedir']));
if ($this->TypeLink->TypeInfos['isdefault'] != -1) {
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) {
@@ -570,12 +606,11 @@ 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);
@@ -587,7 +622,7 @@ class SgListView
/**
* 解析模板,对固定的标记进行初始给值
*
* @access private
* @access public
* @return void
*/
function ParseTempletsFirst()
@@ -597,6 +632,7 @@ 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);
}
@@ -604,7 +640,7 @@ class SgListView
* 解析模板,对文档里的变动进行赋值
*
* @access public
* @param int $PageNo 页
* @param int $PageNo 页
* @param int $ismake 是否编译
* @return void
*/
@@ -631,6 +667,9 @@ 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,
@@ -659,11 +698,11 @@ class SgListView
* 获得要创建的文件名称规则
*
* @access public
* @param string $typeid 栏目id
* @param int $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)
@@ -696,25 +735,44 @@ class SgListView
* @param string $orderWay 排序方式
* @return string
*/
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;
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'
) {
if ($row == '') $row = 10;
if ($limitstart == '') $limitstart = 0;
if ($titlelen == '') $titlelen = 100;
if ($listtype == '') $listtype = "all";
if ($orderby == '') $orderby = 'id';
else $orderby = strtolower($orderby);
if ($infolen == '') $infolen = 250;
if ($imgwidth == '') $imgwidth = 120;
if ($imgheight == '') $imgheight = 120;
if ($listtype == '') $listtype = 'all';
if ($orderWay == '') $orderWay = 'desc';
$tablewidth = str_replace("%", "", $tablewidth);
if ($orderby == '') {
$orderby = 'default';
} else {
$orderby = strtolower($orderby);
}
$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_sglist.htm');
if ($innertext == '') {
$innertext = GetSysTemplets('list_fulllist.htm');
}
//排序方式
$ordersql = '';
if ($orderby == "senddate") {
@@ -724,7 +782,7 @@ class SgListView
} else if ($orderby == "senddate") {
$ordersql = " ORDER BY arc.senddate $orderWay";
} else if ($orderby == "id") {
$ordersql = " ORDER BY arc.aid $orderWay";
$ordersql = " ORDER BY arc.id $orderWay";
} else if ($orderby == "hot" || $orderby == "click") {
$ordersql = " ORDER BY arc.click $orderWay";
} else if($orderby == "weight") {
@@ -740,7 +798,7 @@ class SgListView
}
$addField = 'arc.'.join(',arc.', $this->ListFields);
//如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢
if (preg_match('/hot|click/', $orderby) || $this->sAddTable) {
if (preg_match('/senddate|pubdate|senddate|hot|click|weight|lastpost|rand/', $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查询速度非常快
@@ -775,12 +833,12 @@ class SgListView
for ($j = 0; $j < $col; $j++) {
if ($row = $this->dsql->GetArray("al")) {
$GLOBALS['autoindex']++;
$ids[$row['aid']] = $row['id'] = $row['aid'];
$ids[$row['id']] = $row['id'];
//处理一些特殊字段
$row['ismake'] = 1;
$row['money'] = 0;
$row['arcrank'] = 0;
$row['filename'] = '';
$row['infos'] = cn_substr($row['description'], $infolen);
if ($row['corank'] > 0 && $row['arcrank'] == 0) {
$row['arcrank'] = $row['corank'];
}
$row['filename'] = $row['arcurl'] = GetFileUrl(
$row['id'],
$row['typeid'],
@@ -814,22 +872,28 @@ class SgListView
$row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic'];
}
$row['picname'] = $row['litpic'];
$row['pubdate'] = $row['senddate'];
$row['stime'] = GetDateMK($row['pubdate']);
$row['typelink'] = "<a href='".$row['typeurl']."'>".$row['typename']."</a>";
$row['image'] = "<img src='".$row['picname']."' width='$imgwidth' height='$imgheight' title='".preg_replace("/['><]/", "", $row['title'])."'>";
$row['imglink'] = "<a href='".$row['filename']."'>".$row['image']."</a>";
$row['fulltitle'] = $row['title'];
$row['title'] = cn_substr($row['title'], $titlelen);
if (preg_match('/b/', $row['flag'])) {
if ($row['color'] != '') {
$row['title'] = "<span style='color:".$row['color']."'>".$row['title']."</span>";
}
if (preg_match('/c/', $row['flag'])) {
$row['title'] = "".$row['title']."";
}
$row['face'] = empty($row['face'])? $GLOBALS['cfg_mainsite'].'/static/web/img/admin.png' : $row['face'];
$row['textlink'] = "<a href='".$row['filename']."'>".$row['title']."</a>";
$row['plusurl'] = $row['phpurl'] = $GLOBALS['cfg_phpurl'];
$row['memberurl'] = $GLOBALS['cfg_memberurl'];
$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'];
$row['templeturl'] = $GLOBALS['cfg_templeturl'];
//编译附加表里的数据
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]);
@@ -865,17 +929,16 @@ class SgListView
* 获取静态的分页列表
*
* @access public
* @param int $list_len 列表宽度
* @param string $listitem 列表样式
* @param string $list_len 列表宽度
* @param string $list_len 列表样式
* @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);
@@ -905,6 +968,19 @@ class SgListView
}
//option链接
$optionlist = '';
$optionlen = strlen($totalpage);
$optionlen = $optionlen * 12 + 18;
if ($optionlen < 36) $optionlen = 36;
if ($optionlen > 100) $optionlen = 100;
$optionlist = "<li><select name='sldd' style='width:{$optionlen}px' onchange='location.href=this.options[this.selectedIndex].value;'>";
for ($mjj = 1; $mjj <= $totalpage; $mjj++) {
if ($mjj == $this->PageNo) {
$optionlist .= "<option value='".str_replace("{page}", $mjj, $tnamerule)."' selected>$mjj</option>";
} else {
$optionlist .= "<option value='".str_replace("{page}", $mjj, $tnamerule)."'>$mjj</option>";
}
}
$optionlist .= "</select></li>";
//获得数字链接
$listdd = '';
$total_list = $list_len * 2 + 1;
@@ -941,20 +1017,17 @@ class SgListView
* 获取动态的分页列表
*
* @access public
* @param int $list_len 列表宽度
* @param string $listitem 列表样式
* @param string $list_len 列表宽度
* @param string $list_len 列表样式
* @return string
*/
function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno")
{
global $nativeplace, $infotype, $keyword, $cfg_rewrite;
if (empty($nativeplace)) $nativeplace = 0;
if (empty($infotype)) $infotype = 0;
if (empty($keyword)) $keyword = '';
global $cfg_rewrite;
$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);
@@ -964,6 +1037,7 @@ class SgListView
if ($this->TotalResult == 0) {
return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
}
$maininfo = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>";
$purl = $this->GetCurUrl();
//开启伪静态对规则替换
if ($cfg_rewrite == 'Y') {
@@ -977,16 +1051,16 @@ class SgListView
$optionlist = '';
//获得上页和下页的链接
if ($this->PageNo != 1) {
$prepage .= "<li class='page-item'><a href='".$purl."PageNo=$prepagenum' class='page-link'>上页</a></li>";
$prepage .= "<li class='page-item'><a href='".$purl."PageNo=".$prepagenum."' class='page-link'>上页</a></li>";
$indexpage = "<li class='page-item'><a href='".$purl."PageNo=1' class='page-link'>首页</a></li>";
} else {
$indexpage = "<li class='page-item disabled'><span class='page-link'>首页</span></li>";
$indexpage = "<li class='page-item'><span class='page-link'>首页</span></li>";
}
if ($this->PageNo != $totalpage && $totalpage > 1) {
$nextpage .= "<li class='page-item'><a href='".$purl."PageNo=$nextpagenum' class='page-link'>下页</a></li>";
$endpage = "<li class='page-item'><a href='".$purl."PageNo=$totalpage' class='page-link'>末页</a></li>";
$nextpage .= "<li class='page-item'><a href='".$purl."PageNo=".$nextpagenum."' class='page-link'>下页</a></li>";
$endpage = "<li class='page-item'><a href='".$purl."PageNo=".$totalpage."' class='page-link'>末页</a></li>";
} else {
$endpage = "<li class='page-item disabled'><span class='page-link'>末页</span></li>";
$endpage = "<li class='page-item'><span class='page-link'>末页</span></li>";
}
//获得数字链接
$listdd = '';
@@ -1007,7 +1081,7 @@ class SgListView
if ($j == $this->PageNo) {
$listdd .= "<li class='page-item active'><span class='page-link'>$j</span></li>";
} else {
$listdd .= "<li class='page-item'><a href='".$purl."PageNo=$j' class='page-link'>$j</a></li>";
$listdd .= "<li class='page-item'><a href='".$purl."PageNo=".$j."' class='page-link'>$j</a></li>";
}
}
$plist = '';
@@ -1016,6 +1090,8 @@ 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);
@@ -1027,17 +1103,17 @@ class SgListView
/**
* 获得当前的页面文件链接
*
* @access private
* @access public
* @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;
}


Loading…
Откажи
Сачувај