fix: nav
This commit is contained in:
@@ -176,6 +176,17 @@ class ParserController extends Controller
|
||||
$content = str_replace('{pboot:registerstatus}', $this->config('register_status') === '0' ? 0 : 1, $content); // 是否开启注册
|
||||
$content = str_replace('{pboot:loginstatus}', $this->config('login_status') === '0' ? 0 : 1, $content); // 是否开启登录
|
||||
$content = str_replace('{pboot:commentstatus}', $this->config('comment_status') === '0' ? 0 : 1, $content); // 是否开启评论
|
||||
|
||||
// 记录蜘蛛爬行
|
||||
if ($this->config('spiderlog') !== '0') {
|
||||
if ($this->config('tpl_html_cache')) { // 缓存时插入script,否则直接执行
|
||||
$spidercode = "<script src='" . Url::home('Spider', null, 'url=' . URL) . "' async='async'></script>";
|
||||
$content = preg_replace('/(<\/body>)/i', $spidercode . "\n$1", $content);
|
||||
} else {
|
||||
$spider = new SpiderController(URL);
|
||||
$spider->index();
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
@@ -184,8 +195,18 @@ class ParserController extends Controller
|
||||
public function parserSiteLabel($content)
|
||||
{
|
||||
$pattern = '/\{pboot:site([\w]+)(\s+[^}]+)?\}/';
|
||||
if (preg_match_all($pattern, $content, $matches)) {
|
||||
$data = array();
|
||||
|
||||
// 页面自适应标题避免多横线
|
||||
if (preg_match($pattern, $content)) {
|
||||
$data = $this->model->getSite();
|
||||
if (! $data->subtitle) {
|
||||
$content = str_replace('{pboot:sitetitle}-{pboot:sitesubtitle}', '{pboot:sitetitle}', $content);
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match_all($pattern, $content, $matches)) {
|
||||
$data = $data ?: $this->model->getSite();
|
||||
$count = count($matches[0]);
|
||||
for ($i = 0; $i < $count; $i ++) {
|
||||
$params = $this->parserParam($matches[2][$i]);
|
||||
@@ -386,6 +407,8 @@ class ParserController extends Controller
|
||||
}
|
||||
$parent = 0;
|
||||
$num = 0;
|
||||
$scode = 0;
|
||||
$scode_arr = array();
|
||||
foreach ($params as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'parent':
|
||||
@@ -394,14 +417,20 @@ class ParserController extends Controller
|
||||
case 'num':
|
||||
$num = $value;
|
||||
break;
|
||||
case 'scode':
|
||||
$scode = $value;
|
||||
$scode_arr = explode(',', $scode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($parent) { // 非顶级栏目起始
|
||||
if (isset($data['tree'][$parent]['son'])) {
|
||||
$out_data = $data['tree'][$parent]['son'];
|
||||
} else {
|
||||
$out_data = array();
|
||||
if ($parent) { // 非顶级栏目起始,调用子栏目
|
||||
$parent_arr = explode(',', $parent);
|
||||
$out_data = array();
|
||||
foreach ($parent_arr as $vp) {
|
||||
if (isset($data['tree'][trim($vp)]['son'])) {
|
||||
$out_data = array_merge($out_data, $data['tree'][trim($vp)]['son']);
|
||||
}
|
||||
}
|
||||
} else { // 顶级栏目起始
|
||||
$out_data = $data['top'];
|
||||
@@ -422,6 +451,9 @@ class ParserController extends Controller
|
||||
$out_html = '';
|
||||
$key = 1;
|
||||
foreach ($out_data as $value) { // 按查询的数据条数循环
|
||||
if ($scode_arr && ! in_array($value['scode'], $scode_arr)) {
|
||||
continue;
|
||||
}
|
||||
$one_html = $matches[2][$i];
|
||||
if ($count2) {
|
||||
for ($j = 0; $j < $count2; $j ++) { // 循环替换数据
|
||||
@@ -1505,6 +1537,7 @@ class ParserController extends Controller
|
||||
// 获取调节参数
|
||||
$params = $this->parserParam($matches[1][$i]);
|
||||
$id = - 1;
|
||||
$field = "pics";
|
||||
|
||||
if (! self::checkLabelLevel($params)) {
|
||||
$content = str_replace($matches[0][$i], '', $content);
|
||||
@@ -1525,12 +1558,15 @@ class ParserController extends Controller
|
||||
case 'num':
|
||||
$num = $value;
|
||||
break;
|
||||
case 'field':
|
||||
$field = $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 读取内容多图
|
||||
if (! ! $rs = $this->model->getContentPics(escape_string($id))) {
|
||||
$pics = explode(',', $rs->pics);
|
||||
if (! ! $rs = $this->model->getContentPics(escape_string($id), $field)) {
|
||||
$pics = explode(',', $rs->$field);
|
||||
$picstitle = explode(',', $rs->picstitle);
|
||||
} else {
|
||||
$pics = array();
|
||||
@@ -1552,7 +1588,7 @@ class ParserController extends Controller
|
||||
|
||||
$out_html = '';
|
||||
$key = 1;
|
||||
foreach ($pics as $key => $value) { // 按查询图片条数循环
|
||||
foreach ($pics as $vkey => $value) { // 按查询图片条数循环
|
||||
$one_html = $matches[2][$i];
|
||||
if (! $value)
|
||||
continue;
|
||||
@@ -1577,8 +1613,10 @@ class ParserController extends Controller
|
||||
}
|
||||
break;
|
||||
case 'title':
|
||||
$one_html = str_replace($matches2[0][$j], $this->adjustLabelData($params, isset($picstitle[$key]) ? $picstitle[$key] : ''), $one_html);
|
||||
$one_html = str_replace($matches2[0][$j], $this->adjustLabelData($params, isset($picstitle[$vkey]) ? $picstitle[$vkey] : ''), $one_html);
|
||||
break;
|
||||
default:
|
||||
$one_html = str_replace($matches2[0][$j], '', $one_html);
|
||||
}
|
||||
}
|
||||
$key ++;
|
||||
@@ -3270,7 +3308,7 @@ class ParserController extends Controller
|
||||
}
|
||||
|
||||
eval('if(' . $matches[1][$i] . '){$flag="if";}else{$flag="else";}');
|
||||
if (preg_match('/([\s\S]*)?\{else\}([\s\S]*)?/', $matches[2][$i], $matches2)) { // 判断是否存在else
|
||||
if (preg_match('/^([\s\S]*)\{else\}([\s\S]*)$/', $matches[2][$i], $matches2)) { // 判断是否存在else
|
||||
switch ($flag) {
|
||||
case 'if': // 条件为真
|
||||
if (isset($matches2[1])) {
|
||||
@@ -3870,12 +3908,13 @@ class ParserController extends Controller
|
||||
}
|
||||
|
||||
// 解析生成内容链接
|
||||
protected function parserLink($type, $urlname, $page, $scode, $sortfilename, $id, $contentfilename)
|
||||
public function parserLink($type, $urlname, $pagetype, $scode, $sortfilename, $id = '', $contentfilename = '')
|
||||
{
|
||||
$url_break_char = $this->config('url_break_char') ?: '_';
|
||||
$url_rule_sort_suffix = $this->config('url_rule_sort_suffix') ? true : null;
|
||||
$url_rule_content_path = $this->config('url_rule_content_path') ? true : false;
|
||||
|
||||
if ($type == 1) {
|
||||
if ($type == 1 || $pagetype == 'about') {
|
||||
$urlname = $urlname ?: 'about';
|
||||
if ($sortfilename) {
|
||||
$link = Url::home($sortfilename);
|
||||
@@ -3884,21 +3923,29 @@ class ParserController extends Controller
|
||||
}
|
||||
} else {
|
||||
$urlname = $urlname ?: 'list';
|
||||
if ($page == 'list') {
|
||||
if ($pagetype == 'list') {
|
||||
if ($sortfilename) {
|
||||
$link = Url::home($sortfilename);
|
||||
} else {
|
||||
$link = Url::home($urlname . $url_break_char . $scode);
|
||||
}
|
||||
} elseif ($page == 'content') {
|
||||
if ($sortfilename && $contentfilename) {
|
||||
$link = Url::home($sortfilename . '/' . $contentfilename, true);
|
||||
} elseif ($sortfilename) {
|
||||
$link = Url::home($sortfilename . '/' . $id, true);
|
||||
} elseif ($contentfilename) {
|
||||
$link = Url::home($urlname . $url_break_char . $scode . '/' . $contentfilename, true);
|
||||
} elseif ($pagetype == 'content') {
|
||||
if ($url_rule_content_path) {
|
||||
if ($contentfilename) {
|
||||
$link = Url::home($contentfilename, true);
|
||||
} else {
|
||||
$link = Url::home($id, true);
|
||||
}
|
||||
} else {
|
||||
$link = Url::home($urlname . $url_break_char . $scode . '/' . $id, true);
|
||||
if ($sortfilename && $contentfilename) {
|
||||
$link = Url::home($sortfilename . '/' . $contentfilename, true);
|
||||
} elseif ($sortfilename) {
|
||||
$link = Url::home($sortfilename . '/' . $id, true);
|
||||
} elseif ($contentfilename) {
|
||||
$link = Url::home($urlname . $url_break_char . $scode . '/' . $contentfilename, true);
|
||||
} else {
|
||||
$link = Url::home($urlname . $url_break_char . $scode . '/' . $id, true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$link = 'javascript:;';
|
||||
|
||||
Reference in New Issue
Block a user