Browse Source

单表支持伪静态

tags/6.2.8
tianya 10 months ago
parent
commit
f593750e04
2 changed files with 91 additions and 23 deletions
  1. +21
    -8
      src/system/archive/sglistview.class.php
  2. +70
    -15
      src/system/taglib/infolink.lib.php

+ 21
- 8
src/system/archive/sglistview.class.php View File

@@ -931,7 +931,7 @@ class SgListView
*/
function GetPageListDM($list_len, $listitem = "index,end,pre,next,pageno")
{
global $nativeplace, $infotype, $keyword;
global $nativeplace, $infotype, $keyword,$cfg_rewrite;
if (empty($nativeplace)) $nativeplace = 0;
if (empty($infotype)) $infotype = 0;
if (empty($keyword)) $keyword = '';
@@ -949,23 +949,30 @@ class SgListView
return "<li class='page-item disabled'><span class='page-link'>0页".$this->TotalResult."条</span></li>";
}
$purl = $this->GetCurUrl();
$geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&";
//开启伪静态对规则替换
if ($cfg_rewrite == 'Y') {
$purl = str_replace("/apps", "", $purl);
$nowurls = preg_replace("/\-/", ".php?", $purl);
$nowurls = explode("?", $nowurls);
$purl = $nowurls[0];
}
$geturl = "&TotalResult=".$this->TotalResult."&nativeplace=$nativeplace&infotype=$infotype&keyword=".urlencode($keyword)."&";
$hidenform = "<input type='hidden' name='tid' value='".$this->TypeID."' />\r\n";
$hidenform = "<input type='hidden' name='nativeplace' value='$nativeplace' />\r\n";
$hidenform = "<input type='hidden' name='infotype' value='$infotype' />\r\n";
$hidenform = "<input type='hidden' name='keyword' value='$keyword' />\r\n";
$hidenform .= "<input type='hidden' name='TotalResult' value='".$this->TotalResult."' />\r\n";
$purl .= "?".$geturl;
$purl .= "?tid=".$this->TypeID."&";
//获得上一页和下一页的链接
if ($this->PageNo != 1) {
$prepage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$prepagenum'>上一页</a></li>\r\n";
$indexpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=1'>首页</a></li>\r\n";
$prepage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$prepagenum{$geturl}'>上一页</a></li>\r\n";
$indexpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=1{$geturl}'>首页</a></li>\r\n";
} else {
$indexpage = "<li class='page-item disabled'><a class='page-link'>首页</a></li>\r\n";
}
if ($this->PageNo != $totalpage && $totalpage > 1) {
$nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$nextpagenum'>下一页</a></li>\r\n";
$endpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$totalpage'>末页</a></li>\r\n";
$nextpage .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$nextpagenum{$geturl}'>下一页</a></li>\r\n";
$endpage = "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$totalpage{$geturl}'>末页</a></li>\r\n";
} else {
$endpage = "<li class='page-item disabled'><a class='page-link'>末页</a></li>";
}
@@ -988,10 +995,16 @@ class SgListView
if ($j == $this->PageNo) {
$listdd .= "<li class='page-item active'><a class='page-link'>$j</a></li>\r\n";
} else {
$listdd .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$j'>".$j."</a></li>\r\n";
$listdd .= "<li class='page-item'><a class='page-link' href='".$purl."PageNo=$j{$geturl}'>".$j."</a></li>\r\n";
}
}
$plist = $indexpage.$prepage.$listdd.$nextpage.$endpage;
//伪静态栏目分页
if ($cfg_rewrite == 'Y') {
$plist = str_replace(".php?tid=", "-", $plist);
$plist = preg_replace("/&PageNo=(\d+)/i", "-\\1", $plist);
$plist = preg_replace("/&TotalResult=(\d+)&/i", "?", $plist);//去掉分页数值
}
return $plist;
}
/**


+ 70
- 15
src/system/taglib/infolink.lib.php View File

@@ -25,7 +25,7 @@ function is_str_float($value){
}
function lib_infolink(&$ctag, &$refObj)
{
global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite, $em_nativeplaces, $em_infotypes;
global $dsql, $nativeplace, $infotype, $cfg_rewrite, $cfg_cmspath, $cfg_mainsite, $em_nativeplaces, $em_infotypes;
//属性处理
//$attlist="row|12,titlelen|30";
//FillAttsDefault($ctag->CAttribute->Items,$attlist);
@@ -54,18 +54,31 @@ function lib_infolink(&$ctag, &$refObj)
'channelid' => $channelid, 'linkallplace' => '', 'linkalltype' => ''
);
$fields['nativeplace'] = $fields['infotype'] = '';
$fields['linkallplace'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";
$fields['linkalltype'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";
if ($cfg_rewrite == 'Y') {
$fields['linkallplace'] = "<a href='{$baseurl}list-{$typeid}?infotype={$infotype}&channelid={$channelid}'>不限</a>";
$fields['linkalltype'] = "<a href='{$baseurl}list-{$typeid}?nativeplace={$nativeplace}&channelid={$channelid}'>不限</a>";
} else {
$fields['linkallplace'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$infotype}'>不限</a>";
$fields['linkalltype'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}'>不限</a>";
}
//地区链接
if (empty($nativeplace)) {
foreach ($em_nativeplaces as $eid => $em) {
if ($eid % 500 != 0) continue;
$fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$fields['nativeplace'] .= " <a href='{$baseurl}list-{$typeid}?nativeplace={$eid}&infotype={$infotype}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
}
}
} else {
$sontype = (($nativeplace % 500 != 0) ? $nativeplace : 0); //子集
$toptype = (($nativeplace % 500 == 0) ? (int)$nativeplace : (int)($nativeplace - ($nativeplace % 500))); //顶级联动分类
$fields['nativeplace'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> {$em_nativeplaces[$toptype]}</a> -";
if ($cfg_rewrite == 'Y') {
$fields['nativeplace'] = "<a href='{$baseurl}list-{$typeid}?nativeplace={$toptype}&infotype={$infotype}&channelid={$channelid}'> {$em_nativeplaces[$toptype]}</a> -";
} else {
$fields['nativeplace'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$toptype}&infotype={$infotype}'> {$em_nativeplaces[$toptype]}</a> -";
}
if ($nativeplace % 500 == 0) {
//1级分类
foreach ($em_nativeplaces as $eid => $em) {
@@ -74,7 +87,11 @@ function lib_infolink(&$ctag, &$refObj)
if ($eid == $nativeplace) {
$fields['nativeplace'] .= " {$em}\r\n";
} else {
$fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$fields['nativeplace'] .= " <a href='{$baseurl}list-{$typeid}?nativeplace={$eid}&infotype={$infotype}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
}
}
}
} else if (!is_str_float($nativeplace)) {
@@ -91,7 +108,12 @@ function lib_infolink(&$ctag, &$refObj)
if ($eid === $nativeplace) {
$ff .= " {$em}\r\n";
} else {
$ff .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$ff .= " <a href='{$baseurl}list-{$typeid}?nativeplace={$eid}&infotype={$infotype}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$ff .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
}
}
}
}
@@ -100,14 +122,22 @@ function lib_infolink(&$ctag, &$refObj)
} else {
//3级分类
$t = intval($nativeplace);
$fields['nativeplace'] .= "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$t}&infotype={$infotype}'> {$em_nativeplaces[$t]}</a> -";
if ($cfg_rewrite == 'Y') {
$fields['nativeplace'] .= "<a href='{$baseurl}list-{$typeid}?nativeplace={$t}&infotype={$infotype}&channelid={$channelid}'> {$em_nativeplaces[$t]}</a> -";
} else {
$fields['nativeplace'] .= "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$t}&infotype={$infotype}'> {$em_nativeplaces[$t]}</a> -";
}
foreach ($em_nativeplaces as $eid => $em) {
if ($eid < $t + 1 && $eid > $t)
{
if ($eid === $nativeplace) {
$fields['nativeplace'] .= " {$em}\r\n";
} else {
$fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$fields['nativeplace'] .= " <a href='{$baseurl}list-{$typeid}?nativeplace={$eid}&infotype={$infotype}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$fields['nativeplace'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$eid}&infotype={$infotype}'>{$em}</a>\r\n";
}
}
}
}
@@ -121,13 +151,21 @@ function lib_infolink(&$ctag, &$refObj)
if ($eid == $infotype) {
$fields['infotype'] .= " {$em}\r\n";
} else {
$fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$fields['infotype'] .= " <a href='{$baseurl}list-{$typeid}?infotype={$eid}&nativeplace={$nativeplace}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$eid}&nativeplace={$nativeplace}'>{$em}</a>\r\n";
}
}
}
} else {
$sontype = (($infotype % 500 != 0) ? $infotype : 0);
$toptype = (($infotype % 500 == 0) ? (int)$infotype : (int)($infotype - ($infotype % 500)));
$fields['infotype'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'>{$em_infotypes[$toptype]}</a> - ";
if ($cfg_rewrite == 'Y') {
$fields['infotype'] = "<a href='{$baseurl}list-{$typeid}?infotype={$toptype}&nativeplace={$nativeplace}&channelid={$channelid}'>{$em_infotypes[$toptype]}</a> - ";
} else {
$fields['infotype'] = "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&infotype={$toptype}&nativeplace={$nativeplace}'>{$em_infotypes[$toptype]}</a> - ";
}
if ($infotype % 500 == 0) {
//1级分类
foreach ($em_infotypes as $eid => $em) {
@@ -136,7 +174,11 @@ function lib_infolink(&$ctag, &$refObj)
if ($eid == $infotype) {
$fields['infotype'] .= " {$em}\r\n";
} else {
$fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$fields['infotype'] .= " <a href='{$baseurl}list-{$typeid}?nativeplace={$nativeplace}&infotype={$eid}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
}
}
}
} else if (!is_str_float($infotype)) {
@@ -153,7 +195,12 @@ function lib_infolink(&$ctag, &$refObj)
if ($eid === $infotype) {
$ff .= " {$em}\r\n";
} else {
$ff .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$ff .= " <a href='{$baseurl}list-{$typeid}?nativeplace={$nativeplace}&infotype={$eid}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$ff .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
}
}
}
}
@@ -162,14 +209,22 @@ function lib_infolink(&$ctag, &$refObj)
} else {
//3级分类
$t = intval($infotype);
$fields['infotype'] .= "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$t}'> {$em_infotypes[$t]}</a> -";
if ($cfg_rewrite == 'Y') {
$fields['infotype'] .= "<a href='{$baseurl}list-{$typeid}?nativeplace={$nativeplace}&infotype={$t}&channelid={$channelid}'> {$em_infotypes[$t]}</a> -";
} else {
$fields['infotype'] .= "<a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$t}'> {$em_infotypes[$t]}</a> -";
}
foreach ($em_infotypes as $eid => $em) {
if ($eid < $t + 1 && $eid > $t)
{
if ($eid === $infotype) {
$fields['infotype'] .= " {$em}\r\n";
} else {
$fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
if ($cfg_rewrite == 'Y') {
$fields['infotype'] .= " <a href='{$baseurl}/list-{$typeid}?nativeplace={$nativeplace}&infotype={$eid}&channelid={$channelid}'>{$em}</a>\r\n";
} else {
$fields['infotype'] .= " <a href='{$baseurl}apps/list.php?channelid={$channelid}&tid={$typeid}&nativeplace={$nativeplace}&infotype={$eid}'>{$em}</a>\r\n";
}
}
}
}


Loading…
Cancel
Save