報(bào)錯(cuò) /core/library/think/template/taglib/eyou/TagDiyurl.php 第 77 行左右
代碼:、
<?php
/**
* 易優(yōu)CMS
* ============================================================================
* 版權(quán)所有 2016-2028 海南贊贊網(wǎng)絡(luò)科技有限公司,并保留所有權(quán)利。
* 網(wǎng)站地址: http://www.xiuhaier.com
* ----------------------------------------------------------------------------
* 如果商業(yè)用途務(wù)必到官方購(gòu)買正版授權(quán), 以免引起不必要的法律糾紛.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace think\template\taglib\eyou;
class TagDiyurl extends Base
{
protected function _initialize()
{
parent::_initialize();
}
public function getDiyurl($type = 'tags', $link = '', $vars = '', $suffix = '', $domain = '', $seo_pseudo = '', $seo_pseudo_format = '', $seo_inlet = '', $Class = 'ey_active')
{
$suffix = !empty($suffix) ? $suffix : true;
$domain = !empty($domain) ? $domain : false;
$seo_pseudo = !empty($seo_pseudo) ? $seo_pseudo : null;
$seo_pseudo_format = !empty($seo_pseudo_format) ? $seo_pseudo_format : null;
$seo_inlet = !empty($seo_inlet) ? $seo_inlet : null;
$parseStr = "";
if (in_array($this->request->controller(), ['Search', 'Lists'])) {
// 獲取URL鏈接上的所有參數(shù)
$Param = $this->request->param();
// 獲取已處理好的 tid
$Param['tid'] = !empty($this->tid) ? $this->tid : '';
// 排序條件
$SortAsc = !empty($Param['sort_asc']) && 'desc' == $Param['sort_asc'] ? 'asc' : 'desc';
// 偽靜態(tài)下則獲取 request 數(shù)據(jù)
$Param['m'] = !empty($Param['m']) ? $Param['m'] : $this->request->module();
$Param['c'] = !empty($Param['c']) ? $Param['c'] : $this->request->controller();
$Param['a'] = !empty($Param['a']) ? $Param['a'] : $this->request->action();
// 當(dāng)前模型、控制器、方法
$DynamicURL = "{$Param['m']}/{$Param['c']}/{$Param['a']}";
// 刪除指定參數(shù)
unset($Param['m'], $Param['c'], $Param['a'], $Param['sort_asc']);
if (!empty($type) && 'DefaultUrl' == $type) {
// 默認(rèn)排序
$urlList['DefaultUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'default');
} else if (!empty($type) && 'NewUrl' == $type) {
// 最新排序
$urlList['NewUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'new');
} else if (!empty($type) && 'AppraiseUrl' == $type) {
// 評(píng)價(jià)數(shù)排序(默認(rèn)高到低排序)
$urlList['AppraiseUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'appraise');
} else if (!empty($type) && 'SalesUrl' == $type) {
// 銷量數(shù)排序(默認(rèn)高到低排序)
$urlList['SalesUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'sales');
} else if (!empty($type) && 'CollectionUrl' == $type) {
// 收藏?cái)?shù)排序(默認(rèn)高到低排序)
$urlList['CollectionUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'collection');
} else if (!empty($type) && 'ClickUrl' == $type) {
// 點(diǎn)擊數(shù)排序(默認(rèn)高到低排序)
$urlList['ClickUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'click');
} else if (!empty($type) && 'DownloadUrl' == $type) {
// 下載數(shù)排序(默認(rèn)高到低排序)
$urlList['DownloadUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'download');
} else if (!empty($type) && 'PriceUrl' == $type) {
// 價(jià)格排序
$urlList['PriceUrl'] = $this->GetSortHtmlCode($DynamicURL, $Param, $Class, 'price', $SortAsc);
}
// 取出指定的URL
$parseStr = !empty($urlList[$type]) ? $urlList[$type] : '';
}
if (empty($parseStr)) {
switch ($type) {
case "tags": // 標(biāo)簽主頁(yè)
$parseStr = url('home/Tags/index');
break;
case "login": // 登錄
$parseStr = url('user/Users/login');
break;
case "reg": // 注冊(cè)
$parseStr = url('user/Users/reg');
break;
case "mobile": // 發(fā)送手機(jī)短信方法
case "Mobile": // 發(fā)送手機(jī)短信方法
$parseStr = url('api/Ajax/SendMobileCode');
break;
case "sindex": // 搜索主頁(yè)
$parseStr = url('home/Search/index');
break;
default:
{
if (stristr($link, '/')) {
$parseStr = url($link, $vars, $suffix, $domain, $seo_pseudo, $seo_pseudo_format, $seo_inlet);
} else {
$parseStr = "";
}
}
break;
}
}
return $parseStr;
}
// --------------------陳風(fēng)任----------------------- //
// 獲取URL后封裝成HTML代碼返回
private function GetSortHtmlCode($DynamicURL = '', $Param = [], $Class = '', $Sort = '', $SortAsc = '')
{
// 判斷當(dāng)前選中的排序方式進(jìn)行樣式標(biāo)記
$ClassNew = $this->GetClassValue($Param, $Class, $Sort);
// 整合參數(shù)數(shù)組
$ParamNew = !empty($Sort) ? array_merge($Param, ['sort' => $Sort]) : $Param;
// 若存在排序條件則執(zhí)行
if (!empty($SortAsc)) $ParamNew['sort_asc'] = $SortAsc;
// 獲取動(dòng)態(tài)URL
$DynamicURL = $this->DynamicURL($DynamicURL, $ParamNew);
// 獲取HTML代碼返回
return $this->GetHtmlCode($DynamicURL, $Param, $Class, $ClassNew, $Sort);
}
// 判斷當(dāng)前選中的排序方式進(jìn)行樣式標(biāo)記
private function GetClassValue($Param = [], $Class = '', $Sort = '')
{
$ClassNew = '';
if (!empty($Param['sort']) && 'new' == $Param['sort'] && 'new' == $Sort) {
$ClassNew = $Class;
} else if (!empty($Param['sort']) && 'appraise' == $Param['sort'] && 'appraise' == $Sort) {
$ClassNew = $Class;
} else if (!empty($Param['sort']) && 'sales' == $Param['sort'] && 'sales' == $Sort) {
$ClassNew = $Class;
} else if (!empty($Param['sort']) && 'collection' == $Param['sort'] && 'collection' == $Sort) {
$ClassNew = $Class;
} else if (!empty($Param['sort']) && 'click' == $Param['sort'] && 'click' == $Sort) {
$ClassNew = $Class;
} else if (!empty($Param['sort']) && 'download' == $Param['sort'] && 'download' == $Sort) {
$ClassNew = $Class;
} else if (!empty($Param['sort']) && 'price' == $Param['sort'] && 'price' == $Sort) {
$ClassNew = $Class;
} else if (!empty($Param['sort']) && 'default' == $Param['sort'] && 'default' == $Sort) {
$ClassNew = $Class;
}
return $ClassNew;
}
// 封裝純動(dòng)態(tài)url
private function DynamicURL($DynamicURL = '', $ParamNew = [])
{
// 拆分URL
$GetMCA = !empty($DynamicURL) ? explode('/', $DynamicURL) : [];
if (empty($GetMCA)) {
$ReturnUrl = ROOT_DIR . '/index.php?m=home&c=Lists&a=index';
} else {
$ReturnUrl = ROOT_DIR . '/index.php?m=' . $GetMCA[0] . '&c=' . $GetMCA[1] . '&a=' . $GetMCA[2];
}
// 拼裝URL及參數(shù)
if (!empty($ParamNew)) $ReturnUrl .= '&' . http_build_query($ParamNew);
// 返回URL
return urldecode($ReturnUrl);
}
// 封裝HTML代碼
private function GetHtmlCode($DynamicURL = '', $Param = [], $Class = '', $ClassNew = '', $Sort = '')
{
if (empty($DynamicURL)) return false;
// 選中默認(rèn)或初始時(shí)執(zhí)行
if (empty($Param['sort'])) $Param['sort'] = 'default';
if ('default' == $Param['sort'] && 'default' == $Sort) $ClassNew = $Class;
// 返回已封裝的HTML代碼
return " href=\"JavaScript:void(0);\" onclick=\"window.location.href='{$DynamicURL}';\" class=\"{$ClassNew}\" ";
}
// --------------------分割線----------------------- //
}