@@ -193,9 +193,11 @@ class Archives | |||||
$this->Fields['body'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['body']); | $this->Fields['body'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['body']); | ||||
$this->Fields['body'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\" ",$this->Fields['body']); | $this->Fields['body'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\" ",$this->Fields['body']); | ||||
//图片模型正文图片注释自动为标题 | //图片模型正文图片注释自动为标题 | ||||
$this->Fields['imgurls'] = str_ireplace(array('alt=""','alt=\'\''),'',$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\"",$this->Fields['imgurls']); | |||||
if (isset($this->Fields['imgurls']) && is_array($this->Fields['imgurls'])) { | |||||
$this->Fields['imgurls'] = str_ireplace(array('alt=""','alt=\'\''),'',$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\"",$this->Fields['imgurls']); | |||||
} | |||||
//移除文档模型正文图片宽度和高度,适配自适应/响应式网站 | //移除文档模型正文图片宽度和高度,适配自适应/响应式网站 | ||||
$this->Fields['body'] = preg_replace("/style=\"width\:(.*)\"/","",$this->Fields['body']); | $this->Fields['body'] = preg_replace("/style=\"width\:(.*)\"/","",$this->Fields['body']); | ||||
} | } | ||||
@@ -493,7 +495,7 @@ class Archives | |||||
if ($GLOBALS['cfg_jump_once'] == 'N') { | if ($GLOBALS['cfg_jump_once'] == 'N') { | ||||
$pageHtml = "<html>\r\n<head>\r\n<meta charset=".$GLOBALS['cfg_soft_lang']."\">\r\n<title>".$this->Fields['title']."</title>\r\n"; | $pageHtml = "<html>\r\n<head>\r\n<meta charset=".$GLOBALS['cfg_soft_lang']."\">\r\n<title>".$this->Fields['title']."</title>\r\n"; | ||||
$pageHtml .= "<meta http-equiv=\"refresh\" content=\"3;URL=".$this->Fields['redirecturl']."\">\r\n</head>\r\n<body>\r\n"; | $pageHtml .= "<meta http-equiv=\"refresh\" content=\"3;URL=".$this->Fields['redirecturl']."\">\r\n</head>\r\n<body>\r\n"; | ||||
$pageHtml .= "正在跳转文档:".$this->Fields['title']."<br><br>\r\n文档描述:".$this->Fields['description']."\r\n</body>\r\n</html>\r\n"; | |||||
$pageHtml .= "正在前往文档:".$this->Fields['title']."<br><br>\r\n文档描述:".$this->Fields['description']."\r\n</body>\r\n</html>\r\n"; | |||||
echo $pageHtml; | echo $pageHtml; | ||||
} else { | } else { | ||||
header("location:{$this->Fields['redirecturl']}"); | header("location:{$this->Fields['redirecturl']}"); | ||||
@@ -1009,7 +1011,7 @@ function _highlightkeywords($matches) | |||||
{ | { | ||||
return _highlight($matches[2], $GLOBALS['_dd_karr'], $GLOBALS['_dd_kaarr'], $matches[1]); | return _highlight($matches[2], $GLOBALS['_dd_karr'], $GLOBALS['_dd_kaarr'], $matches[1]); | ||||
} | } | ||||
//高亮专用,替换多次是可能不能达到最多次 | |||||
//高亮专用 | |||||
function _highlight($string, $words, $result, $pre) | function _highlight($string, $words, $result, $pre) | ||||
{ | { | ||||
global $cfg_replace_num; | global $cfg_replace_num; | ||||
@@ -107,7 +107,7 @@ class ArchivesMobile | |||||
} | } | ||||
$this->addTableRow = $this->dsql->GetOne($query); | $this->addTableRow = $this->dsql->GetOne($query); | ||||
} | } | ||||
//issystem==-1 表示自定义模型,自定义模型不支持redirecturl这类参数,因此限定文档普通模型才进行下面查询 | |||||
//issystem==-1表示自定义模型,自定义模型不支持redirecturl这类参数,因此限定文档普通模型才进行下面查询 | |||||
if ($this->ChannelUnit->ChannelInfos['addtable'] != '' && $this->ChannelUnit->ChannelInfos['issystem'] != -1) { | if ($this->ChannelUnit->ChannelInfos['addtable'] != '' && $this->ChannelUnit->ChannelInfos['issystem'] != -1) { | ||||
if (is_array($this->addTableRow)) { | if (is_array($this->addTableRow)) { | ||||
$this->Fields['redirecturl'] = $this->addTableRow['redirecturl']; | $this->Fields['redirecturl'] = $this->addTableRow['redirecturl']; | ||||
@@ -195,9 +195,11 @@ class ArchivesMobile | |||||
$this->Fields['body'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['body']); | $this->Fields['body'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['body']); | ||||
$this->Fields['body'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\" ",$this->Fields['body']); | $this->Fields['body'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\" ",$this->Fields['body']); | ||||
//图片模型正文图片注释自动为标题 | //图片模型正文图片注释自动为标题 | ||||
$this->Fields['imgurls'] = str_ireplace(array('alt=""','alt=\'\''),'',$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\"",$this->Fields['imgurls']); | |||||
if (isset($this->Fields['imgurls']) && is_array($this->Fields['imgurls'])) { | |||||
$this->Fields['imgurls'] = str_ireplace(array('alt=""','alt=\'\''),'',$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = preg_replace("@ [\s]{0,}alt[\s]{0,}=[\"'\s]{0,}[\s\S]{0,}[\"'\s] @isU","",$this->Fields['imgurls']); | |||||
$this->Fields['imgurls'] = str_ireplace("<img","<img alt=\"".$this->Fields['title']."\" title=\"".$this->Fields['title']."\"",$this->Fields['imgurls']); | |||||
} | |||||
//移除文档模型正文图片宽度和高度,适配自适应/响应式网站 | //移除文档模型正文图片宽度和高度,适配自适应/响应式网站 | ||||
$this->Fields['body'] = preg_replace("/style=\"width\:(.*)\"/","",$this->Fields['body']); | $this->Fields['body'] = preg_replace("/style=\"width\:(.*)\"/","",$this->Fields['body']); | ||||
} | } | ||||
@@ -325,7 +327,7 @@ class ArchivesMobile | |||||
$filenames = explode("/", $filename); | $filenames = explode("/", $filename); | ||||
$this->NameFirst = preg_replace("/\.".$this->ShortName."$/i", "", $filenames[count($filenames) - 1]); | $this->NameFirst = preg_replace("/\.".$this->ShortName."$/i", "", $filenames[count($filenames) - 1]); | ||||
if ($this->NameFirst == '') { | if ($this->NameFirst == '') { | ||||
$this->NameFirst = $this->arcID; | |||||
$this->NameFirst = $this->ArcID; | |||||
} | } | ||||
//获得当前文档的全名 | //获得当前文档的全名 | ||||
$filenameFull = GetFileUrl( | $filenameFull = GetFileUrl( | ||||
@@ -501,7 +503,7 @@ class ArchivesMobile | |||||
if ($GLOBALS['cfg_jump_once'] == 'N') { | if ($GLOBALS['cfg_jump_once'] == 'N') { | ||||
$pageHtml = "<html>\r\n<head>\r\n<meta charset=".$GLOBALS['cfg_soft_lang']."\">\r\n<title>".$this->Fields['title']."</title>\r\n"; | $pageHtml = "<html>\r\n<head>\r\n<meta charset=".$GLOBALS['cfg_soft_lang']."\">\r\n<title>".$this->Fields['title']."</title>\r\n"; | ||||
$pageHtml .= "<meta http-equiv=\"refresh\" content=\"3;URL=".$this->Fields['redirecturl']."\">\r\n</head>\r\n<body>\r\n"; | $pageHtml .= "<meta http-equiv=\"refresh\" content=\"3;URL=".$this->Fields['redirecturl']."\">\r\n</head>\r\n<body>\r\n"; | ||||
$pageHtml .= "正在跳转文档:".$this->Fields['title']."<br><br>\r\n文档描述:".$this->Fields['description']."\r\n</body>\r\n</html>\r\n"; | |||||
$pageHtml .= "正在前往文档:".$this->Fields['title']."<br><br>\r\n文档描述:".$this->Fields['description']."\r\n</body>\r\n</html>\r\n"; | |||||
echo $pageHtml; | echo $pageHtml; | ||||
} else { | } else { | ||||
header("location:{$this->Fields['redirecturl']}"); | header("location:{$this->Fields['redirecturl']}"); | ||||
@@ -1017,7 +1019,7 @@ function _highlightkeywords($matches) | |||||
{ | { | ||||
return _highlight($matches[2], $GLOBALS['_dd_karr'], $GLOBALS['_dd_kaarr'], $matches[1]); | return _highlight($matches[2], $GLOBALS['_dd_karr'], $GLOBALS['_dd_kaarr'], $matches[1]); | ||||
} | } | ||||
//高亮专用,替换多次是可能不能达到最多次 | |||||
//高亮专用 | |||||
function _highlight($string, $words, $result, $pre) | function _highlight($string, $words, $result, $pre) | ||||
{ | { | ||||
global $cfg_replace_num; | global $cfg_replace_num; | ||||
@@ -33,15 +33,18 @@ class ListView | |||||
var $CrossID; | var $CrossID; | ||||
var $IsReplace; | var $IsReplace; | ||||
var $remoteDir; | var $remoteDir; | ||||
var $mod; | |||||
var $_parms = array('tid','TotalResult','PageNo','PageSize','mod','timestamp','sign'); | |||||
/** | /** | ||||
* php5构造函数 | * php5构造函数 | ||||
* | * | ||||
* @access public | * @access public | ||||
* @param int $typeid 栏目id | |||||
* @param int $uppage 上一页 | |||||
* @param int $typeid 栏目id | |||||
* @param int $uppage 上一页 | |||||
* @param int $mod 渲染类型 0:HTML 1:JSON | |||||
* @return string | * @return string | ||||
*/ | */ | ||||
function __construct($typeid, $uppage = 1) | |||||
function __construct($typeid, $uppage = 1, $mod = 0) | |||||
{ | { | ||||
global $dsql, $envs; | global $dsql, $envs; | ||||
$envs['url_type'] = 1; | $envs['url_type'] = 1; | ||||
@@ -58,6 +61,7 @@ class ListView | |||||
$this->TypeLink = new TypeLink($typeid); | $this->TypeLink = new TypeLink($typeid); | ||||
$this->upPageType = $uppage; | $this->upPageType = $uppage; | ||||
$this->remoteDir = ''; | $this->remoteDir = ''; | ||||
$this->mod = $mod; | |||||
$this->TotalResult = is_numeric($this->TotalResult) ? $this->TotalResult : ""; | $this->TotalResult = is_numeric($this->TotalResult) ? $this->TotalResult : ""; | ||||
if (!is_array($this->TypeLink->TypeInfos)) { | if (!is_array($this->TypeLink->TypeInfos)) { | ||||
$this->IsError = true; | $this->IsError = true; | ||||
@@ -71,13 +75,39 @@ class ListView | |||||
//添加联动单筛选 | //添加联动单筛选 | ||||
if (isset($_REQUEST['tid'])) { | if (isset($_REQUEST['tid'])) { | ||||
foreach($_GET as $key => $value) { | foreach($_GET as $key => $value) { | ||||
if ($key!="tid" && $key!="TotalResult" && $key!="PageNo") { | |||||
if (!in_array($key,$this->_parms)) { | |||||
$this->Fields[string_filter($key)] = string_filter(urldecode($value)); | $this->Fields[string_filter($key)] = string_filter(urldecode($value)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
//设置一些全局参数的值 | //设置一些全局参数的值 | ||||
foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; | foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; | ||||
//api相关逻辑处理 | |||||
if ($this->mod == 1 && empty($this->Fields['apikey'])) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "api key is empty", | |||||
)); | |||||
exit; | |||||
} | |||||
if ($this->mod == 1) { | |||||
if (empty($GLOBALS['sign'])) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "sign is empty", | |||||
)); | |||||
exit; | |||||
} | |||||
//验签算法md5(typeid+timestamp+apikey+PageNo+PageSize) | |||||
$sign = md5($this->TypeID.$GLOBALS['timestamp'].$this->Fields['apikey'].$GLOBALS['PageNo'].$GLOBALS['PageSize']); | |||||
if ($sign !== $GLOBALS['sign']) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "sign check failed", | |||||
)); | |||||
exit; | |||||
} | |||||
} | |||||
$this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; | $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; | ||||
//设置环境变量 | //设置环境变量 | ||||
SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); | SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); | ||||
@@ -104,9 +134,9 @@ class ListView | |||||
}//!error | }//!error | ||||
} | } | ||||
//php4构造函数 | //php4构造函数 | ||||
function ListView($typeid, $uppage = 0) | |||||
function ListView($typeid, $uppage = 0, $mod = 0) | |||||
{ | { | ||||
$this->__construct($typeid, $uppage); | |||||
$this->__construct($typeid, $uppage, $mod); | |||||
} | } | ||||
//关闭相关资源 | //关闭相关资源 | ||||
function Close() | function Close() | ||||
@@ -148,7 +178,7 @@ class ListView | |||||
} | } | ||||
if (isset($_REQUEST['tid'])) { | if (isset($_REQUEST['tid'])) { | ||||
foreach ($_GET as $key => $value) { | foreach ($_GET as $key => $value) { | ||||
$filtersql .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo") ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
$filtersql .= (!in_array($key,$this->_parms)) ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
@@ -211,36 +241,41 @@ class ListView | |||||
$this->TotalResult = 0; | $this->TotalResult = 0; | ||||
} | } | ||||
} | } | ||||
//初始化列表模板,并统计页面总数 | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']; | |||||
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile); | |||||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||||
if (defined('DEDEMOB')) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm"; | |||||
if ($this->mod === 0) { | |||||
//初始化列表模板,并统计页面总数 | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']; | |||||
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile); | |||||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||||
if (defined('DEDEMOB')) { | if (defined('DEDEMOB')) { | ||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | $tempfile = str_replace('.htm', '_m.htm', $tempfile); | ||||
} | } | ||||
} | |||||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||||
echo "主题模板文件不存在,无法发布文档"; | |||||
exit(); | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
$ctag = $this->dtp->GetTag("page"); | |||||
if (!is_object($ctag)) { | |||||
$ctag = $this->dtp->GetTag("list"); | |||||
} | |||||
if (!is_object($ctag)) { | |||||
$this->pagesize = 30; | |||||
} else { | |||||
if ($ctag->GetAtt("pagesize") != "") { | |||||
$this->pagesize = $ctag->GetAtt("pagesize"); | |||||
} else { | |||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm"; | |||||
if (defined('DEDEMOB')) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
} | |||||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||||
echo "主题模板文件不存在,无法发布文档"; | |||||
exit(); | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
$ctag = $this->dtp->GetTag("page"); | |||||
if (!is_object($ctag)) { | |||||
$ctag = $this->dtp->GetTag("list"); | |||||
} | |||||
if (!is_object($ctag)) { | |||||
$this->pagesize = 30; | $this->pagesize = 30; | ||||
} else { | |||||
if ($ctag->GetAtt("pagesize") != "") { | |||||
$this->pagesize = $ctag->GetAtt("pagesize"); | |||||
} else { | |||||
$this->pagesize = 30; | |||||
} | |||||
} | } | ||||
} else { | |||||
$this->pagesize = isset($GLOBALS['PageSize'])? intval($GLOBALS['PageSize']) : 10; | |||||
$this->pagesize = $this->pagesize > 20? 20 : $this->pagesize; | |||||
} | } | ||||
$this->TotalPage = ceil($this->TotalResult / $this->pagesize); | $this->TotalPage = ceil($this->TotalResult / $this->pagesize); | ||||
} | } | ||||
@@ -325,30 +360,220 @@ class ListView | |||||
*/ | */ | ||||
function Display() | function Display() | ||||
{ | { | ||||
if ($this->TypeLink->TypeInfos['ispart'] > 0) { | |||||
$this->DisplayPartTemplets(); | |||||
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 (defined('DEDEMOB')) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
if ($this->mod === 0) { | |||||
if ($this->TypeLink->TypeInfos['ispart'] > 0) { | |||||
$this->DisplayPartTemplets(); | |||||
return; | |||||
} | } | ||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm"; | |||||
$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 (defined('DEDEMOB')) { | if (defined('DEDEMOB')) { | ||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | $tempfile = str_replace('.htm', '_m.htm', $tempfile); | ||||
} | } | ||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm"; | |||||
if (defined('DEDEMOB')) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
} | |||||
$this->ParseTempletsFirst(); | |||||
$this->ParseDMFields($this->PageNo, 0); | |||||
$this->dtp->Display(); | |||||
} else { | |||||
$this->CountRecord(); | |||||
$result = $this->GetAPIList($this->PageNo,$this->pagesize); | |||||
if (!is_array($result)) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "none result", | |||||
)); | |||||
} else { | |||||
echo json_encode(array( | |||||
"code" => 0, | |||||
"msg" => "", | |||||
"lists" => $result, | |||||
"total" => intval($this->TotalResult), | |||||
)); | |||||
} | } | ||||
$this->dtp->LoadTemplate($tempfile); | |||||
} | } | ||||
$this->ParseTempletsFirst(); | |||||
$this->ParseDMFields($this->PageNo, 0); | |||||
$this->dtp->Display(); | |||||
} | |||||
/** | |||||
* GetAPIList | |||||
* | |||||
* @param mixed $PageNo 页码 | |||||
* @param mixed $row 条数 | |||||
* @param mixed $titlelen 标题字符长度 | |||||
* @param mixed $infolen 描述字符长度 | |||||
* @param mixed $orderby 排序 | |||||
* @param mixed $orderWay 排序方式 | |||||
* @return array | |||||
*/ | |||||
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 ($infolen == '') $infolen = 250; | |||||
if ($orderWay == '') $orderWay = 'desc'; | |||||
if ($orderby == '') { | |||||
$orderby = 'default'; | |||||
} else { | |||||
$orderby = strtolower($orderby); | |||||
} | |||||
//排序方式 | |||||
$ordersql = ''; | |||||
if ($orderby == "senddate" || $orderby == "id") { | |||||
$ordersql = " ORDER BY arc.id $orderWay"; | |||||
} else if ($orderby == "hot" || $orderby == "click") { | |||||
$ordersql = " ORDER BY arc.click $orderWay"; | |||||
} else if ($orderby == "lastpost") { | |||||
$ordersql = " ORDER BY arc.lastpost $orderWay"; | |||||
} else { | |||||
$ordersql = " ORDER BY arc.sortrank $orderWay"; | |||||
} | |||||
//获得附加表的相关信息 | |||||
$addtable = $this->ChannelUnit->ChannelInfos['addtable']; | |||||
$filtersql = ""; | |||||
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; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
//添加联动单筛选 | |||||
if (isset($_REQUEST['tid'])) { | |||||
foreach($_GET as $key => $value) | |||||
{ | |||||
$filtersql .= (!in_array($key,$this->_parms)) ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
} | |||||
} | |||||
} else { | |||||
$addField = ''; | |||||
$addJoin = ''; | |||||
} | |||||
//如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢 | |||||
if (preg_match('/hot|click|lastpost/', $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 $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} $filtersql $ordersql LIMIT $limitstart,$row"; | |||||
} | |||||
//普通情况先从arctiny表查出id,然后按di查询速度非常快 | |||||
else { | |||||
$t1 = ExecTime(); | |||||
$ids = array(); | |||||
$query = "SELECT id FROM `#@__arctiny` arc $addJoin WHERE {$this->addSql} $filtersql $ordersql LIMIT $limitstart,$row"; | |||||
$this->dsql->SetQuery($query); | |||||
$this->dsql->Execute(); | |||||
while ($arr = $this->dsql->GetArray()) { | |||||
$ids[] = $arr['id']; | |||||
} | |||||
$idstr = join(',', $ids); | |||||
if ($idstr == '') { | |||||
return ''; | |||||
} else { | |||||
$query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,mb.uname,mb.face $addField FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb ON arc.mid=mb.mid $addJoin WHERE arc.id in($idstr) $ordersql "; | |||||
} | |||||
$t2 = ExecTime(); | |||||
} | |||||
$this->dsql->SetQuery($query); | |||||
$this->dsql->Execute('al'); | |||||
$t2 = ExecTime(); | |||||
$result = array(); | |||||
$GLOBALS['autoindex'] = 0; | |||||
while ($row = $this->dsql->GetArray("al")) { | |||||
$GLOBALS['autoindex']++; | |||||
$ids[$row['id']] = $row['id']; | |||||
//处理一些特殊字段 | |||||
$row['infos'] = cn_substr($row['description'], $infolen); | |||||
$row['id'] = $row['id']; | |||||
if ($row['corank'] > 0 && $row['arcrank'] == 0) { | |||||
$row['arcrank'] = $row['corank']; | |||||
} | |||||
$row['filename'] = $row['arcurl'] = GetFileUrl( | |||||
$row['id'], | |||||
$row['typeid'], | |||||
$row['senddate'], | |||||
$row['title'], | |||||
$row['ismake'], | |||||
$row['arcrank'], | |||||
$row['namerule'], | |||||
$row['typedir'], | |||||
$row['money'], | |||||
$row['filename'], | |||||
$row['moresite'], | |||||
$row['siteurl'], | |||||
$row['sitepath'] | |||||
); | |||||
$row['typeurl'] = GetTypeUrl( | |||||
$row['typeid'], | |||||
MfTypedir($row['typedir']), | |||||
$row['isdefault'], | |||||
$row['defaultname'], | |||||
$row['ispart'], | |||||
$row['namerule2'], | |||||
$row['moresite'], | |||||
$row['siteurl'], | |||||
$row['sitepath'] | |||||
); | |||||
if ($row['litpic'] == '-' || $row['litpic'] == '') { | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; | |||||
} | |||||
/*if (!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { | |||||
$row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; | |||||
}*/ | |||||
$row['picname'] = $row['litpic']; | |||||
$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 ($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']; | |||||
//编译附加表里的数据 | |||||
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]); | |||||
} | |||||
} | |||||
$result[] = $row; | |||||
}//if hasRow | |||||
$t3 = ExecTime(); | |||||
$this->dsql->FreeResult('al'); | |||||
return $result; | |||||
} | } | ||||
/** | /** | ||||
* 创建单独模板页面 | * 创建单独模板页面 | ||||
@@ -663,7 +888,7 @@ class ListView | |||||
if (isset($_REQUEST['tid'])) { | if (isset($_REQUEST['tid'])) { | ||||
foreach($_GET as $key => $value) | foreach($_GET as $key => $value) | ||||
{ | { | ||||
$filtersql .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo") ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
$filtersql .= (!in_array($key,$this->_parms)) ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
@@ -905,12 +1130,12 @@ class ListView | |||||
} | } | ||||
$totalpage = ceil($this->TotalResult / $this->pagesize); | $totalpage = ceil($this->TotalResult / $this->pagesize); | ||||
if ($totalpage <= 1 && $this->TotalResult > 0) { | if ($totalpage <= 1 && $this->TotalResult > 0) { | ||||
return "<li class='d-none d-sm-block page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>\r\n"; | |||||
return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>\r\n"; | |||||
} | } | ||||
if ($this->TotalResult == 0) { | if ($this->TotalResult == 0) { | ||||
return "<li class='d-none d-sm-block page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>\r\n"; | |||||
return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>\r\n"; | |||||
} | } | ||||
$maininfo = "<li class='d-none d-sm-block page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n"; | |||||
$maininfo = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n"; | |||||
$purl = $this->GetCurUrl(); | $purl = $this->GetCurUrl(); | ||||
//如果开启为静态,则对规则进行替换 | //如果开启为静态,则对规则进行替换 | ||||
if ($cfg_rewrite == 'Y') { | if ($cfg_rewrite == 'Y') { | ||||
@@ -924,7 +1149,7 @@ class ListView | |||||
//添加联动单筛选 | //添加联动单筛选 | ||||
$pageaddurl = ""; | $pageaddurl = ""; | ||||
foreach($_GET as $key => $value) { | foreach($_GET as $key => $value) { | ||||
$pageaddurl .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo") ? "&".string_filter($key)."=".string_filter($value) : ''; | |||||
$pageaddurl .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo" && $key!="PageSize" && $key!="mod") ? "&".string_filter($key)."=".string_filter($value) : ''; | |||||
} | } | ||||
//获得上一页和下一页的链接 | //获得上一页和下一页的链接 | ||||
if ($this->PageNo != 1) { | if ($this->PageNo != 1) { | ||||
@@ -1,9 +1,9 @@ | |||||
<?php | <?php | ||||
if (!defined('DEDEINC')) exit ('dedebiz'); | if (!defined('DEDEINC')) exit ('dedebiz'); | ||||
/** | /** | ||||
* 手机端文档列表 | |||||
* 文档列表 | |||||
* | * | ||||
* @version $id:listview.m.class.php 10:46 2023年1月10日 xushubieli $ | |||||
* @version $id:listview.class.php 2 15:15 2010年7月7日 tianya $ | |||||
* @package DedeBIZ.Libraries | * @package DedeBIZ.Libraries | ||||
* @copyright Copyright (c) 2022 DedeBIZ.COM | * @copyright Copyright (c) 2022 DedeBIZ.COM | ||||
* @license https://www.dedebiz.com/license | * @license https://www.dedebiz.com/license | ||||
@@ -12,7 +12,7 @@ if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
require_once(DEDEINC.'/archive/partview.class.php'); | require_once(DEDEINC.'/archive/partview.class.php'); | ||||
helper('cache'); | helper('cache'); | ||||
@set_time_limit(0); | @set_time_limit(0); | ||||
class ListViewMobile | |||||
class ListView | |||||
{ | { | ||||
var $dsql; | var $dsql; | ||||
var $dtp; | var $dtp; | ||||
@@ -34,15 +34,18 @@ class ListViewMobile | |||||
var $IsReplace; | var $IsReplace; | ||||
var $remoteDir; | var $remoteDir; | ||||
var $is_mobile; | var $is_mobile; | ||||
var $mod; | |||||
var $_parms = array('tid','TotalResult','PageNo','PageSize','mod','timestamp','sign'); | |||||
/** | /** | ||||
* php5构造函数 | * php5构造函数 | ||||
* | * | ||||
* @access public | * @access public | ||||
* @param int $typeid 栏目id | |||||
* @param int $uppage 上一页 | |||||
* @param int $typeid 栏目id | |||||
* @param int $uppage 上一页 | |||||
* @param int $mod 渲染类型 0:HTML 1:JSON | |||||
* @return string | * @return string | ||||
*/ | */ | ||||
function __construct($typeid, $uppage = 1) | |||||
function __construct($typeid, $uppage = 1, $mod = 0) | |||||
{ | { | ||||
global $dsql, $envs; | global $dsql, $envs; | ||||
$envs['url_type'] = 1; | $envs['url_type'] = 1; | ||||
@@ -60,6 +63,7 @@ class ListViewMobile | |||||
$this->upPageType = $uppage; | $this->upPageType = $uppage; | ||||
$this->remoteDir = ''; | $this->remoteDir = ''; | ||||
$this->is_mobile = true; | $this->is_mobile = true; | ||||
$this->mod = $mod; | |||||
$this->TotalResult = is_numeric($this->TotalResult) ? $this->TotalResult : ""; | $this->TotalResult = is_numeric($this->TotalResult) ? $this->TotalResult : ""; | ||||
if (!is_array($this->TypeLink->TypeInfos)) { | if (!is_array($this->TypeLink->TypeInfos)) { | ||||
$this->IsError = true; | $this->IsError = true; | ||||
@@ -73,13 +77,39 @@ class ListViewMobile | |||||
//添加联动单筛选 | //添加联动单筛选 | ||||
if (isset($_REQUEST['tid'])) { | if (isset($_REQUEST['tid'])) { | ||||
foreach($_GET as $key => $value) { | foreach($_GET as $key => $value) { | ||||
if ($key!="tid" && $key!="TotalResult" && $key!="PageNo") { | |||||
if (!in_array($key,$this->_parms)) { | |||||
$this->Fields[string_filter($key)] = string_filter(urldecode($value)); | $this->Fields[string_filter($key)] = string_filter(urldecode($value)); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
//设置一些全局参数的值 | //设置一些全局参数的值 | ||||
foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; | foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; | ||||
//api相关逻辑处理 | |||||
if ($this->mod == 1 && empty($this->Fields['apikey'])) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "api key is empty", | |||||
)); | |||||
exit; | |||||
} | |||||
if ($this->mod == 1) { | |||||
if (empty($GLOBALS['sign'])) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "sign is empty", | |||||
)); | |||||
exit; | |||||
} | |||||
//验签算法md5(typeid+timestamp+apikey+PageNo+PageSize) | |||||
$sign = md5($this->TypeID.$GLOBALS['timestamp'].$this->Fields['apikey'].$GLOBALS['PageNo'].$GLOBALS['PageSize']); | |||||
if ($sign !== $GLOBALS['sign']) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "sign check failed", | |||||
)); | |||||
exit; | |||||
} | |||||
} | |||||
$this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; | $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; | ||||
//设置环境变量 | //设置环境变量 | ||||
SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); | SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); | ||||
@@ -106,9 +136,9 @@ class ListViewMobile | |||||
}//!error | }//!error | ||||
} | } | ||||
//php4构造函数 | //php4构造函数 | ||||
function ListView($typeid, $uppage = 0) | |||||
function ListView($typeid, $uppage = 0, $mod = 0) | |||||
{ | { | ||||
$this->__construct($typeid, $uppage); | |||||
$this->__construct($typeid, $uppage, $mod); | |||||
} | } | ||||
//关闭相关资源 | //关闭相关资源 | ||||
function Close() | function Close() | ||||
@@ -150,7 +180,7 @@ class ListViewMobile | |||||
} | } | ||||
if (isset($_REQUEST['tid'])) { | if (isset($_REQUEST['tid'])) { | ||||
foreach ($_GET as $key => $value) { | foreach ($_GET as $key => $value) { | ||||
$filtersql .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo") ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
$filtersql .= (!in_array($key,$this->_parms)) ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
@@ -213,36 +243,41 @@ class ListViewMobile | |||||
$this->TotalResult = 0; | $this->TotalResult = 0; | ||||
} | } | ||||
} | } | ||||
//初始化列表模板,并统计页面总数 | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']; | |||||
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile); | |||||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||||
if ($this->is_mobile) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm"; | |||||
if ($this->mod === 0) { | |||||
//初始化列表模板,并统计页面总数 | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']; | |||||
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile); | |||||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||||
if ($this->is_mobile) { | if ($this->is_mobile) { | ||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | $tempfile = str_replace('.htm', '_m.htm', $tempfile); | ||||
} | } | ||||
} | |||||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||||
echo "主题模板文件不存在,无法发布文档"; | |||||
exit(); | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
$ctag = $this->dtp->GetTag("page"); | |||||
if (!is_object($ctag)) { | |||||
$ctag = $this->dtp->GetTag("list"); | |||||
} | |||||
if (!is_object($ctag)) { | |||||
$this->pagesize = 30; | |||||
} else { | |||||
if ($ctag->GetAtt("pagesize") != "") { | |||||
$this->pagesize = $ctag->GetAtt("pagesize"); | |||||
} else { | |||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default.htm"; | |||||
if ($this->is_mobile) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
} | |||||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||||
echo "主题模板文件不存在,无法发布文档"; | |||||
exit(); | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
$ctag = $this->dtp->GetTag("page"); | |||||
if (!is_object($ctag)) { | |||||
$ctag = $this->dtp->GetTag("list"); | |||||
} | |||||
if (!is_object($ctag)) { | |||||
$this->pagesize = 30; | $this->pagesize = 30; | ||||
} else { | |||||
if ($ctag->GetAtt("pagesize") != "") { | |||||
$this->pagesize = $ctag->GetAtt("pagesize"); | |||||
} else { | |||||
$this->pagesize = 30; | |||||
} | |||||
} | } | ||||
} else { | |||||
$this->pagesize = isset($GLOBALS['PageSize'])? intval($GLOBALS['PageSize']) : 10; | |||||
$this->pagesize = $this->pagesize > 20? 20 : $this->pagesize; | |||||
} | } | ||||
$this->TotalPage = ceil($this->TotalResult / $this->pagesize); | $this->TotalPage = ceil($this->TotalResult / $this->pagesize); | ||||
} | } | ||||
@@ -257,14 +292,13 @@ class ListViewMobile | |||||
*/ | */ | ||||
function MakeHtml($startpage = 1, $makepagesize = 0, $isremote = 0) | function MakeHtml($startpage = 1, $makepagesize = 0, $isremote = 0) | ||||
{ | { | ||||
global $dedebiz_path, $dedebiz_typerule, $dedebiz_usetype; | |||||
if (empty($startpage)) { | if (empty($startpage)) { | ||||
$startpage = 1; | $startpage = 1; | ||||
} | } | ||||
//创建封面模板文件 | //创建封面模板文件 | ||||
if ($this->TypeLink->TypeInfos['isdefault'] == -1) { | if ($this->TypeLink->TypeInfos['isdefault'] == -1) { | ||||
echo '这个是动态栏目'; | echo '这个是动态栏目'; | ||||
return '../m/list.php?tid='.$this->TypeLink->TypeInfos['id']; | |||||
return '../apps/list.php?tid='.$this->TypeLink->TypeInfos['id']; | |||||
} | } | ||||
//单独页面 | //单独页面 | ||||
else if ($this->TypeLink->TypeInfos['ispart'] > 0) { | else if ($this->TypeLink->TypeInfos['ispart'] > 0) { | ||||
@@ -278,17 +312,6 @@ class ListViewMobile | |||||
if ($totalpage == 0) { | if ($totalpage == 0) { | ||||
$totalpage = 1; | $totalpage = 1; | ||||
} | } | ||||
//栏目规则 | |||||
$dedebiz_path = rtrim($dedebiz_path,'/') ? rtrim($dedebiz_path,'/') : '/m'; | |||||
if ($dedebiz_usetype==0 && $dedebiz_typerule) { | |||||
$typedir = str_replace("{cmspath}","",$this->Fields['typedir']); | |||||
$this->Fields['typedir'] = '{cmspath}'.$dedebiz_path.$typedir; | |||||
$this->Fields['typedir'] = substr($this->Fields['typedir'],0,9).$dedebiz_path.substr($this->Fields['typedir'],9); | |||||
$this->Fields['namerule2'] = $dedebiz_typerule; | |||||
} else { | |||||
$typedir = str_replace("{cmspath}","",$this->Fields['typedir']); | |||||
$this->Fields['typedir'] = '{cmspath}'.$dedebiz_path.$typedir; | |||||
} | |||||
CreateDir(MfTypedir($this->Fields['typedir'])); | CreateDir(MfTypedir($this->Fields['typedir'])); | ||||
$murl = ''; | $murl = ''; | ||||
if ($makepagesize > 0) { | if ($makepagesize > 0) { | ||||
@@ -339,30 +362,220 @@ class ListViewMobile | |||||
*/ | */ | ||||
function Display() | function Display() | ||||
{ | { | ||||
if ($this->TypeLink->TypeInfos['ispart'] > 0) { | |||||
$this->DisplayPartTemplets(); | |||||
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 ($this->is_mobile) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
if ($this->mod === 0) { | |||||
if ($this->TypeLink->TypeInfos['ispart'] > 0) { | |||||
$this->DisplayPartTemplets(); | |||||
return; | |||||
} | } | ||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm"; | |||||
$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 ($this->is_mobile) { | if ($this->is_mobile) { | ||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | $tempfile = str_replace('.htm', '_m.htm', $tempfile); | ||||
} | } | ||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $tmpdir."/".$GLOBALS['cfg_df_style']."/index_default.htm"; | |||||
if ($this->is_mobile) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
} | |||||
$this->ParseTempletsFirst(); | |||||
$this->ParseDMFields($this->PageNo, 0); | |||||
$this->dtp->Display(); | |||||
} else { | |||||
$this->CountRecord(); | |||||
$result = $this->GetAPIList($this->PageNo,$this->pagesize); | |||||
if (!is_array($result)) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "none result", | |||||
)); | |||||
} else { | |||||
echo json_encode(array( | |||||
"code" => 0, | |||||
"msg" => "", | |||||
"lists" => $result, | |||||
"total" => intval($this->TotalResult), | |||||
)); | |||||
} | } | ||||
$this->dtp->LoadTemplate($tempfile); | |||||
} | } | ||||
$this->ParseTempletsFirst(); | |||||
$this->ParseDMFields($this->PageNo, 0); | |||||
$this->dtp->Display(); | |||||
} | |||||
/** | |||||
* GetAPIList | |||||
* | |||||
* @param mixed $PageNo 页码 | |||||
* @param mixed $row 条数 | |||||
* @param mixed $titlelen 标题字符长度 | |||||
* @param mixed $infolen 描述字符长度 | |||||
* @param mixed $orderby 排序 | |||||
* @param mixed $orderWay 排序方式 | |||||
* @return array | |||||
*/ | |||||
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 ($infolen == '') $infolen = 250; | |||||
if ($orderWay == '') $orderWay = 'desc'; | |||||
if ($orderby == '') { | |||||
$orderby = 'default'; | |||||
} else { | |||||
$orderby = strtolower($orderby); | |||||
} | |||||
//排序方式 | |||||
$ordersql = ''; | |||||
if ($orderby == "senddate" || $orderby == "id") { | |||||
$ordersql = " ORDER BY arc.id $orderWay"; | |||||
} else if ($orderby == "hot" || $orderby == "click") { | |||||
$ordersql = " ORDER BY arc.click $orderWay"; | |||||
} else if ($orderby == "lastpost") { | |||||
$ordersql = " ORDER BY arc.lastpost $orderWay"; | |||||
} else { | |||||
$ordersql = " ORDER BY arc.sortrank $orderWay"; | |||||
} | |||||
//获得附加表的相关信息 | |||||
$addtable = $this->ChannelUnit->ChannelInfos['addtable']; | |||||
$filtersql = ""; | |||||
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; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
//添加联动单筛选 | |||||
if (isset($_REQUEST['tid'])) { | |||||
foreach($_GET as $key => $value) | |||||
{ | |||||
$filtersql .= (!in_array($key,$this->_parms)) ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
} | |||||
} | |||||
} else { | |||||
$addField = ''; | |||||
$addJoin = ''; | |||||
} | |||||
//如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢 | |||||
if (preg_match('/hot|click|lastpost/', $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 $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} $filtersql $ordersql LIMIT $limitstart,$row"; | |||||
} | |||||
//普通情况先从arctiny表查出id,然后按di查询速度非常快 | |||||
else { | |||||
$t1 = ExecTime(); | |||||
$ids = array(); | |||||
$query = "SELECT id FROM `#@__arctiny` arc $addJoin WHERE {$this->addSql} $filtersql $ordersql LIMIT $limitstart,$row"; | |||||
$this->dsql->SetQuery($query); | |||||
$this->dsql->Execute(); | |||||
while ($arr = $this->dsql->GetArray()) { | |||||
$ids[] = $arr['id']; | |||||
} | |||||
$idstr = join(',', $ids); | |||||
if ($idstr == '') { | |||||
return ''; | |||||
} else { | |||||
$query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule,tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath,mb.uname,mb.face $addField FROM `#@__archives` arc LEFT JOIN `#@__arctype` tp ON arc.typeid=tp.id LEFT JOIN `#@__member` mb ON arc.mid=mb.mid $addJoin WHERE arc.id in($idstr) $ordersql "; | |||||
} | |||||
$t2 = ExecTime(); | |||||
} | |||||
$this->dsql->SetQuery($query); | |||||
$this->dsql->Execute('al'); | |||||
$t2 = ExecTime(); | |||||
$result = array(); | |||||
$GLOBALS['autoindex'] = 0; | |||||
while ($row = $this->dsql->GetArray("al")) { | |||||
$GLOBALS['autoindex']++; | |||||
$ids[$row['id']] = $row['id']; | |||||
//处理一些特殊字段 | |||||
$row['infos'] = cn_substr($row['description'], $infolen); | |||||
$row['id'] = $row['id']; | |||||
if ($row['corank'] > 0 && $row['arcrank'] == 0) { | |||||
$row['arcrank'] = $row['corank']; | |||||
} | |||||
$row['filename'] = $row['arcurl'] = GetFileUrl( | |||||
$row['id'], | |||||
$row['typeid'], | |||||
$row['senddate'], | |||||
$row['title'], | |||||
$row['ismake'], | |||||
$row['arcrank'], | |||||
$row['namerule'], | |||||
$row['typedir'], | |||||
$row['money'], | |||||
$row['filename'], | |||||
$row['moresite'], | |||||
$row['siteurl'], | |||||
$row['sitepath'] | |||||
); | |||||
$row['typeurl'] = GetTypeUrl( | |||||
$row['typeid'], | |||||
MfTypedir($row['typedir']), | |||||
$row['isdefault'], | |||||
$row['defaultname'], | |||||
$row['ispart'], | |||||
$row['namerule2'], | |||||
$row['moresite'], | |||||
$row['siteurl'], | |||||
$row['sitepath'] | |||||
); | |||||
if ($row['litpic'] == '-' || $row['litpic'] == '') { | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; | |||||
} | |||||
/*if (!preg_match("/^http:\/\//i", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { | |||||
$row['litpic'] = $GLOBALS['cfg_mainsite'].$row['litpic']; | |||||
}*/ | |||||
$row['picname'] = $row['litpic']; | |||||
$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 ($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']; | |||||
//编译附加表里的数据 | |||||
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]); | |||||
} | |||||
} | |||||
$result[] = $row; | |||||
}//if hasRow | |||||
$t3 = ExecTime(); | |||||
$this->dsql->FreeResult('al'); | |||||
return $result; | |||||
} | } | ||||
/** | /** | ||||
* 创建单独模板页面 | * 创建单独模板页面 | ||||
@@ -689,7 +902,7 @@ class ListViewMobile | |||||
if (isset($_REQUEST['tid'])) { | if (isset($_REQUEST['tid'])) { | ||||
foreach($_GET as $key => $value) | foreach($_GET as $key => $value) | ||||
{ | { | ||||
$filtersql .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo") ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
$filtersql .= (!in_array($key,$this->_parms)) ? " AND $addtable.".string_filter($key)." = '".string_filter(urldecode($value))."'" : ''; | |||||
} | } | ||||
} | } | ||||
} else { | } else { | ||||
@@ -931,12 +1144,12 @@ class ListViewMobile | |||||
} | } | ||||
$totalpage = ceil($this->TotalResult / $this->pagesize); | $totalpage = ceil($this->TotalResult / $this->pagesize); | ||||
if ($totalpage <= 1 && $this->TotalResult > 0) { | if ($totalpage <= 1 && $this->TotalResult > 0) { | ||||
return "<li class='d-none d-sm-block page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>\r\n"; | |||||
return "<li class='page-item disabled'><span class='page-link'>1页".$this->TotalResult."条</span></li>\r\n"; | |||||
} | } | ||||
if ($this->TotalResult == 0) { | if ($this->TotalResult == 0) { | ||||
return "<li class='d-none d-sm-block page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>\r\n"; | |||||
return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>\r\n"; | |||||
} | } | ||||
$maininfo = "<li class='d-none d-sm-block page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n"; | |||||
$maininfo = "<li class='page-item disabled'><span class='page-link'>{$totalpage}页".$this->TotalResult."条</span></li>\r\n"; | |||||
$purl = $this->GetCurUrl(); | $purl = $this->GetCurUrl(); | ||||
//如果开启为静态,则对规则进行替换 | //如果开启为静态,则对规则进行替换 | ||||
if ($cfg_rewrite == 'Y') { | if ($cfg_rewrite == 'Y') { | ||||
@@ -950,7 +1163,7 @@ class ListViewMobile | |||||
//添加联动单筛选 | //添加联动单筛选 | ||||
$pageaddurl = ""; | $pageaddurl = ""; | ||||
foreach($_GET as $key => $value) { | foreach($_GET as $key => $value) { | ||||
$pageaddurl .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo") ? "&".string_filter($key)."=".string_filter($value) : ''; | |||||
$pageaddurl .= ($key!="tid" && $key!="TotalResult" && $key!="PageNo" && $key!="PageSize" && $key!="mod") ? "&".string_filter($key)."=".string_filter($value) : ''; | |||||
} | } | ||||
//获得上一页和下一页的链接 | //获得上一页和下一页的链接 | ||||
if ($this->PageNo != 1) { | if ($this->PageNo != 1) { | ||||
@@ -531,7 +531,7 @@ class SearchView | |||||
$this->dsql->Execute("al"); | $this->dsql->Execute("al"); | ||||
$artlist = ""; | $artlist = ""; | ||||
if ($col > 1) { | if ($col > 1) { | ||||
$artlist = "<table width='$tablewidth' cellspacing='0' cellpadding='0'>\r\n"; | |||||
$artlist = "<table width='$tablewidth'>\r\n"; | |||||
} | } | ||||
$this->dtp2->LoadSource($innertext); | $this->dtp2->LoadSource($innertext); | ||||
for ($i = 0; $i < $row; $i++) { | for ($i = 0; $i < $row; $i++) { | ||||
@@ -9,8 +9,8 @@ if (!defined('DEDEINC')) exit ('dedebiz'); | |||||
* @license https://www.dedebiz.com/license | * @license https://www.dedebiz.com/license | ||||
* @link https://www.dedebiz.com | * @link https://www.dedebiz.com | ||||
*/ | */ | ||||
@set_time_limit(0); | |||||
require_once(DEDEINC."/archive/partview.class.php"); | require_once(DEDEINC."/archive/partview.class.php"); | ||||
@set_time_limit(0); | |||||
class SgListView | class SgListView | ||||
{ | { | ||||
var $dsql; | var $dsql; | ||||
@@ -34,15 +34,17 @@ class SgListView | |||||
var $ListFields; | var $ListFields; | ||||
var $searchArr; | var $searchArr; | ||||
var $sAddTable; | var $sAddTable; | ||||
var $mod; | |||||
/** | /** | ||||
* php5构造函数 | * php5构造函数 | ||||
* | * | ||||
* @access public | * @access public | ||||
* @param int $typeid 栏目id | |||||
* @param int $typeid 栏目id | |||||
* @param array $searchArr 检索数组 | * @param array $searchArr 检索数组 | ||||
* @param int $mod 渲染类型 0:HTML 1:JSON | |||||
* @return void | * @return void | ||||
*/ | */ | ||||
function __construct($typeid, $searchArr = array()) | |||||
function __construct($typeid, $searchArr = array(), $mod = 0) | |||||
{ | { | ||||
global $dsql, $envs; | global $dsql, $envs; | ||||
$envs['url_type'] = 1; | $envs['url_type'] = 1; | ||||
@@ -59,6 +61,7 @@ class SgListView | |||||
$this->dtp2->SetNameSpace("field", "[", "]"); | $this->dtp2->SetNameSpace("field", "[", "]"); | ||||
$this->TypeLink = new TypeLink($typeid); | $this->TypeLink = new TypeLink($typeid); | ||||
$this->searchArr = $searchArr; | $this->searchArr = $searchArr; | ||||
$this->mod = $mod; | |||||
if (!is_array($this->TypeLink->TypeInfos)) { | if (!is_array($this->TypeLink->TypeInfos)) { | ||||
$this->IsError = true; | $this->IsError = true; | ||||
} | } | ||||
@@ -75,6 +78,32 @@ class SgListView | |||||
//设置一些全局参数的值 | //设置一些全局参数的值 | ||||
foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; | foreach ($GLOBALS['PubFields'] as $k => $v) $this->Fields[$k] = $v; | ||||
$this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; | $this->Fields['rsslink'] = $GLOBALS['cfg_cmsurl']."/static/rss/".$this->TypeID.".xml"; | ||||
//api相关逻辑处理 | |||||
if ($this->mod == 1 && empty($this->Fields['apikey'])) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "api key is empty", | |||||
)); | |||||
exit; | |||||
} | |||||
if ($this->mod == 1) { | |||||
if (empty($GLOBALS['sign'])) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "sign is empty", | |||||
)); | |||||
exit; | |||||
} | |||||
//验签算法md5(typeid+timestamp+apikey+PageNo+PageSize) | |||||
$sign = md5($this->TypeID.$GLOBALS['timestamp'].$this->Fields['apikey'].$GLOBALS['PageNo'].$GLOBALS['PageSize']); | |||||
if ($sign !== $GLOBALS['sign']) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "sign check failed", | |||||
)); | |||||
exit; | |||||
} | |||||
} | |||||
//设置环境变量 | //设置环境变量 | ||||
SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); | SetSysEnv($this->TypeID, $this->Fields['typename'], 0, '', 'list'); | ||||
$this->Fields['typeid'] = $this->TypeID; | $this->Fields['typeid'] = $this->TypeID; | ||||
@@ -100,9 +129,9 @@ class SgListView | |||||
} //!error | } //!error | ||||
} | } | ||||
//php4构造函数 | //php4构造函数 | ||||
function SgListView($typeid, $searchArr = array()) | |||||
function SgListView($typeid, $searchArr = array(), $mod = 0) | |||||
{ | { | ||||
$this->__construct($typeid, $searchArr); | |||||
$this->__construct($typeid, $searchArr, $mod); | |||||
} | } | ||||
//关闭相关资源 | //关闭相关资源 | ||||
function Close() | function Close() | ||||
@@ -171,36 +200,41 @@ class SgListView | |||||
$this->TotalResult = 0; | $this->TotalResult = 0; | ||||
} | } | ||||
} | } | ||||
//初始化列表模板,并统计页面总数 | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']; | |||||
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile); | |||||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||||
if (defined('DEDEMOB')) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default_sg.htm"; | |||||
if ($this->mod === 0) { | |||||
//初始化列表模板,并统计页面总数 | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$this->TypeLink->TypeInfos['templist']; | |||||
$tempfile = str_replace("{tid}", $this->TypeID, $tempfile); | |||||
$tempfile = str_replace("{cid}", $this->ChannelUnit->ChannelInfos['nid'], $tempfile); | |||||
if (defined('DEDEMOB')) { | if (defined('DEDEMOB')) { | ||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | $tempfile = str_replace('.htm', '_m.htm', $tempfile); | ||||
} | } | ||||
} | |||||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||||
echo "主题模板文件不存在,无法发布文档"; | |||||
exit(); | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
$ctag = $this->dtp->GetTag("page"); | |||||
if (!is_object($ctag)) { | |||||
$ctag = $this->dtp->GetTag("list"); | |||||
} | |||||
if (!is_object($ctag)) { | |||||
$this->pagesize = 20; | |||||
} else { | |||||
if ($ctag->GetAtt('pagesize') != '') { | |||||
$this->pagesize = $ctag->GetAtt('pagesize'); | |||||
} else { | |||||
if (!file_exists($tempfile)) { | |||||
$tempfile = $GLOBALS['cfg_basedir'].$GLOBALS['cfg_templets_dir']."/".$GLOBALS['cfg_df_style']."/list_default_sg.htm"; | |||||
if (defined('DEDEMOB')) { | |||||
$tempfile = str_replace('.htm', '_m.htm', $tempfile); | |||||
} | |||||
} | |||||
if (!file_exists($tempfile) || !is_file($tempfile)) { | |||||
echo "主题模板文件不存在,无法发布文档"; | |||||
exit(); | |||||
} | |||||
$this->dtp->LoadTemplate($tempfile); | |||||
$ctag = $this->dtp->GetTag("page"); | |||||
if (!is_object($ctag)) { | |||||
$ctag = $this->dtp->GetTag("list"); | |||||
} | |||||
if (!is_object($ctag)) { | |||||
$this->pagesize = 20; | $this->pagesize = 20; | ||||
} else { | |||||
if ($ctag->GetAtt('pagesize') != '') { | |||||
$this->pagesize = $ctag->GetAtt('pagesize'); | |||||
} else { | |||||
$this->pagesize = 20; | |||||
} | |||||
} | } | ||||
} else { | |||||
$this->pagesize = isset($GLOBALS['PageSize'])? intval($GLOBALS['PageSize']) : 10; | |||||
$this->pagesize = $this->pagesize > 20? 20 : $this->pagesize; | |||||
} | } | ||||
$this->TotalPage = ceil($this->TotalResult / $this->pagesize); | $this->TotalPage = ceil($this->TotalResult / $this->pagesize); | ||||
} | } | ||||
@@ -287,14 +321,154 @@ class SgListView | |||||
*/ | */ | ||||
function Display() | function Display() | ||||
{ | { | ||||
if ($this->TypeLink->TypeInfos['ispart'] > 0 && count($this->searchArr) == 0) { | |||||
$this->DisplayPartTemplets(); | |||||
return; | |||||
if ($this->mod === 0) { | |||||
if ($this->TypeLink->TypeInfos['ispart'] > 0 && count($this->searchArr) == 0) { | |||||
$this->DisplayPartTemplets(); | |||||
return; | |||||
} | |||||
$this->CountRecord(); | |||||
$this->ParseTempletsFirst(); | |||||
$this->ParseDMFields($this->PageNo, 0); | |||||
$this->dtp->Display(); | |||||
} else { | |||||
$this->CountRecord(); | |||||
$result = $this->GetAPIList($this->PageNo,$this->pagesize); | |||||
if (!is_array($result)) { | |||||
echo json_encode(array( | |||||
"code" => -1, | |||||
"msg" => "none result", | |||||
)); | |||||
} else { | |||||
echo json_encode(array( | |||||
"code" => 0, | |||||
"msg" => "", | |||||
"lists" => $result, | |||||
"total" => intval($this->TotalResult), | |||||
)); | |||||
} | |||||
} | } | ||||
$this->CountRecord(); | |||||
$this->ParseTempletsFirst(); | |||||
$this->ParseDMFields($this->PageNo, 0); | |||||
$this->dtp->Display(); | |||||
} | |||||
/** | |||||
* GetAPIList | |||||
* | |||||
* @param mixed $PageNo 页码 | |||||
* @param mixed $row 行数 | |||||
* @param mixed $titlelen 标题宽度 | |||||
* @param mixed $orderby 排序 | |||||
* @param mixed $orderWay 排序方式 | |||||
* @return void | |||||
*/ | |||||
function GetAPIList($PageNo, $row = 10, $titlelen = 30, $orderby = "default", $orderWay = 'desc') | |||||
{ | |||||
$limitstart = ($PageNo - 1) * $row; | |||||
if ($titlelen == '') $titlelen = 100; | |||||
if ($orderby == '') $orderby = 'id'; | |||||
else $orderby = strtolower($orderby); | |||||
if ($orderWay == '') $orderWay = 'desc'; | |||||
//排序方式 | |||||
$ordersql = ''; | |||||
if ($orderby == 'senddate' || $orderby == 'id') { | |||||
$ordersql = " ORDER BY arc.aid $orderWay"; | |||||
} else if ($orderby == 'hot' || $orderby == 'click') { | |||||
$ordersql = " ORDER BY arc.click $orderWay"; | |||||
} else { | |||||
$ordersql = " ORDER BY arc.aid $orderWay"; | |||||
} | |||||
$addField = 'arc.'.join(',arc.', $this->ListFields); | |||||
//如果不用默认的sortrank或id排序,使用联合查询数据量大时非常缓慢 | |||||
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查询速度非常快 | |||||
else { | |||||
$t1 = ExecTime(); | |||||
$ids = array(); | |||||
$nordersql = str_replace('.aid', '.id', $ordersql); | |||||
$query = "SELECT id FROM `#@__arctiny` arc WHERE {$this->addSql} $nordersql LIMIT $limitstart,$row"; | |||||
$this->dsql->SetQuery($query); | |||||
$this->dsql->Execute(); | |||||
while ($arr = $this->dsql->GetArray()) { | |||||
$ids[] = $arr['id']; | |||||
} | |||||
$idstr = join(',', $ids); | |||||
if ($idstr == '') { | |||||
return ''; | |||||
} else { | |||||
$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 arc.aid IN($idstr) AND arc.arcrank >-1 $ordersql"; | |||||
} | |||||
$t2 = ExecTime(); | |||||
} | |||||
$this->dsql->SetQuery($query); | |||||
$this->dsql->Execute('al'); | |||||
$t2 = ExecTime(); | |||||
$GLOBALS['autoindex'] = 0; | |||||
$result = array(); | |||||
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['filename'] = $row['arcurl'] = GetFileUrl( | |||||
$row['id'], | |||||
$row['typeid'], | |||||
$row['senddate'], | |||||
$row['title'], | |||||
$row['ismake'], | |||||
$row['arcrank'], | |||||
$row['namerule'], | |||||
$row['typedir'], | |||||
$row['money'], | |||||
$row['filename'], | |||||
$row['moresite'], | |||||
$row['siteurl'], | |||||
$row['sitepath'] | |||||
); | |||||
$row['typeurl'] = GetTypeUrl( | |||||
$row['typeid'], | |||||
MfTypedir($row['typedir']), | |||||
$row['isdefault'], | |||||
$row['defaultname'], | |||||
$row['ispart'], | |||||
$row['namerule2'], | |||||
$row['moresite'], | |||||
$row['siteurl'], | |||||
$row['sitepath'] | |||||
); | |||||
if ($row['litpic'] == '-' || $row['litpic'] == '') { | |||||
$row['litpic'] = $GLOBALS['cfg_cmspath'].'/static/web/img/thumbnail.jpg'; | |||||
} | |||||
if (!preg_match("/^http:\/\//", $row['litpic']) && $GLOBALS['cfg_multi_site'] == 'Y') { | |||||
$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['fulltitle'] = $row['title']; | |||||
$row['title'] = cn_substr($row['title'], $titlelen); | |||||
if (preg_match('/b/', $row['flag'])) { | |||||
$row['title'] = "".$row['title'].""; | |||||
} | |||||
$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']; | |||||
//编译附加表里的数据 | |||||
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]); | |||||
} | |||||
} | |||||
$result[] = $row; | |||||
} //if hasRow | |||||
$t3 = ExecTime(); | |||||
$this->dsql->FreeResult('al'); | |||||
return $result; | |||||
} | } | ||||
/** | /** | ||||
* 创建单独模板页面 | * 创建单独模板页面 | ||||