<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年2月14日
* 标签解析引擎控制器
*/
namespace app\home\controller;
use core\basic\Controller;
use app\home\model\ParserModel;
use core\basic\Url;
class ParserController extends Controller
{
protected $model;
protected $pre = array();
protected $var = array();
public function __construct()
{
$this->model = new ParserModel();
}
public function _empty()
{
error('您访问的地址有误,请核对后重试!');
}
// 解析全局前置公共标签
public function parserBefore($content)
{
// 处理模板中不需要解析的标签
$content = $this->savePreLabel($content);
return $content;
}
// 解析全局后置公共标签
public function parserAfter($content)
{
// 默认页面信息替换
$content = str_replace('{pboot:pagetitle}', '{pboot:sitetitle}-{pboot:sitesubtitle}', $content);
$content = str_replace('{pboot:pagekeywords}', '{pboot:sitekeywords}', $content);
$content = str_replace('{pboot:pagedescription}', '{pboot:sitedescription}', $content);
$content = $this->parserSingleLabel($content); // 单标签解析
$content = $this->parserSiteLabel($content); // 站点标签
$content = $this->parserCompanyLabel($content); // 公司标签
$content = $this->parserUserLabel($content); // 自定义标签
$content = $this->parserNavLabel($content); // 分类列表
$content = $this->parserSelectAllLabel($content); // CMS筛选全部标签解析
$content = $this->parserSelectLabel($content); // CMS筛选标签解析
$content = $this->parserSpecifySortLabel($content); // 指定分类
$content = $this->parserListLabel($content); // 指定列表
$content = $this->parserSpecifyContentLabel($content); // 指定内容
$content = $this->parserContentPicsLabel($content); // 内容多图
$content = $this->parserContentCheckboxLabel($content); // 内容多选调取
$content = $this->parserContentTagsLabel($content); // 内容tags调取
$content = $this->parserSlideLabel($content); // 幻灯片
$content = $this->parserLinkLabel($content); // 友情链接
$content = $this->parserMessageLabel($content); // 留言板
$content = $this->parserFormLabel($content); // 自定义表单
$content = $this->parserSubmitFormLabel($content); // 自定义表单提交
$content = $this->parserQrcodeLabel($content); // 二维码生成
$content = $this->parserPageLabel($content); // CMS分页标签解析(需置后)
$content = $this->parserLoopLabel($content); // LOOP语句(需置后)
$content = $this->parserIfLabel($content); // IF语句(需置最后)
$content = $this->restorePreLabel($content); // 还原不需要解析的内容
$content = $this->parserReplaceKeyword($content); // 页面关键词替换
return $content;
}
// 保存保留内容
public function savePreLabel($content)
{
$pattern = '/\{pboot:pre}([\s\S]*?)\{\/pboot:pre\}/';
if (preg_match_all($pattern, $content, $matches)) {
$count = count($matches[0]);
for ($i = 0; $i < $count; $i ++) {
$this->pre[] = $matches[1][$i];
end($this->pre);
$content = str_replace($matches[0][$i], '#pre:' . key($this->pre) . '#', $content);
}
}
return $content;
}
// 还原保留内容
public function restorePreLabel($content)
{
$pattern = '/\#pre:([0-9]+)\#/';
if (preg_match_all($pattern, $content, $matches)) {
$count = count($matches[0]);
for ($i = 0; $i < $count; $i ++) {
$content = str_replace($matches[0][$i], $this->pre[$matches[1][$i]], $content);
}
}
return $content;
}
// 解析单标签
public function parserSingleLabel($content)
{
$content = str_replace('{pboot:msgaction}', Url::home('home/Index/addMsg'), $content); // 留言提交路径
$content = str_replace('{pboot:scaction}', Url::home('home/Index/search'), $content); // 搜索提交路径
$content = str_replace('{pboot:checkcode}', CORE_DIR . '/code.php', $content); // 验证码路径
$content = str_replace('{pboot:lgpath}', Url::get('home/Do/area'), $content); // 多语言切换前置路径,如{pboot:lgpath}?lg=cn
$content = str_replace('{pboot:appid}', $this->config('api_appid'), $content); // API认证用户
$content = str_replace('{pboot:timestamp}', time(), $content); // 认证时间戳
$content = str_replace('{pboot:signature}', md5(md5($this->config('api_appid') . $this->config('api_secret') . time())), $content); // API认证密钥
$content = str_replace('{pboot:httpurl}', get_http_url(), $content); // 当前访问的域名地址
$content = str_replace('{pboot:pageurl}', get_current_url(), $content); // 当前页面的地址
$content = str_replace('{pboot:keyword}', get('keyword', 'vars'), $content); // 当前搜索的关键字
$content = str_replace('{pboot:checkcodestatus}', $this->config('message_check_code'), $content); // 是否开启验证码
return $content;
}
// 解析站点标签
public function parserSiteLabel($content)
{
$pattern = '/\{pboot:site([\w]+)(\s+[^}]+)?\}/';
if (preg_match_all($pattern, $content, $matches)) {
$data = $this->model->getSite();
$count = count($matches[0]);
for ($i = 0; $i < $count; $i ++) {
$params = $this->parserParam($matches[2][$i]);
switch ($matches[1][$i]) {
case 'index':
$content = str_replace($matches[0][$i], Url::home('home/Index/'), $content);
break;
case 'path':
$content = str_replace($matches[0][$i], SITE_DIR, $content);
break;
case 'logo':
if (isset($data->logo) && $data->logo) {
if (! preg_match('/^http/', $data->logo)) {
$content = str_replace($matches[0][$i], $this->adjustLabelData($params, SITE_DIR . $data->logo), $content);
} else {
$content = str_replace($matches[0][$i], $this->adjustLabelData($params, $data->logo), $content);
}
} else {
$content = str_replace($matches[0][$i], STATIC_DIR . '/images/logo.png', $content);
}
break;
case 'tplpath':
$content = str_replace($matches[0][$i], APP_THEME_DIR, $content);
break;
case 'language':
$content = str_replace($matches[0][$i], get_lg(), $content);
break;
case 'statistical':
if (isset($data->statistical)) {
$content = str_replace($matches[0][$i], decode_string($data->statistical), $content);
} else {
$content = str_replace($matches[0][$i], '', $content);
}
case 'copyright':
if (isset($data->copyright)) {
$content = str_replace($matches[0][$i], decode_string($data->copyright), $content);
} else {
$content = str_replace($matches[0][$i], '', $content);
}
default:
if (isset($data->{$matches
没有合适的资源?快使用搜索试试~ 我知道了~
各行业通用网站开源源码
共1612个文件
png:561个
js:205个
jpg:177个
需积分: 0 3 下载量 79 浏览量
2023-03-21
15:25:31
上传
评论
收藏 65.18MB ZIP 举报
温馨提示
各行业通用企业网站开源源码,互联网软件开发公司官网、设计服务行业企业网站模板源码,开源源码免费
资源推荐
资源详情
资源评论
收起资源包目录
各行业通用网站开源源码 (1612个子文件)
web.config 721B
freedns.css 76KB
layui.css 71KB
main.css 67KB
iconfont.css 59KB
iconfont.css 59KB
iconfont_fun.css 55KB
iconfont_index.css 55KB
animate.min.css 52KB
ueditor.css 45KB
ueditor.css 43KB
yunu.css 37KB
font-awesome.css 37KB
index.css 35KB
font.css 34KB
font.css 34KB
ueditor.min.css 34KB
ueditor.min.css 34KB
font-awesome.min.css 30KB
baseLayOut.css 27KB
baseLayOut.css 27KB
video-js.css 22KB
extension.css 22KB
serverPrice.css 21KB
video-js.css 21KB
swiper.min.css 19KB
swiper.min.css 19KB
image.css 19KB
image.css 18KB
video.css 15KB
attachment.css 15KB
video.css 15KB
layer.css 14KB
attachment.css 14KB
swiper.min.css 14KB
iconfont.css 13KB
video-js.min.css 11KB
video-js.min.css 11KB
ssl.css 11KB
layui.mobile.css 10KB
font_844077_ft22imrq7oe.css 9KB
comon.css 9KB
global.css 9KB
product.css 8KB
midaut.css 8KB
homepage1.css 8KB
aboutus.css 8KB
about.css 8KB
product.css 8KB
laydate.css 7KB
shCoreDefault.css 7KB
shCoreDefault.css 7KB
channelProxy.css 6KB
customize_style.css 6KB
solution.css 5KB
extension.css 5KB
ssl.css 4KB
vmd_css.css 4KB
comm.css 4KB
scrawl.css 4KB
scrawl.css 4KB
serverPrice.css 4KB
right.css 4KB
codemirror.css 3KB
codemirror.css 3KB
charts.css 3KB
market.css 3KB
charts.css 3KB
background.css 2KB
background.css 2KB
base.css 2KB
list_service.css 2KB
assiatant.css 2KB
emotion.css 2KB
emotion.css 2KB
dialogbase.css 2KB
music.css 2KB
list_article.css 2KB
dialogbase.css 2KB
music.css 2KB
channelProxy.css 2KB
customize.css 2KB
login.css 2KB
vmd.css 1KB
edittable.css 1KB
edittable.css 1KB
code.css 1KB
template.css 1KB
template.css 1KB
jquery.treetable.css 652B
webuploader.css 543B
webuploader.css 515B
help.css 395B
help.css 389B
iframe.css 42B
iframe.css 41B
87ad4d8a288b2c188bd99ed03920be26_20200319153154.db 792KB
jyteam_database.db 792KB
fontawesome-webfont.eot 162KB
iconfont.eot 41KB
共 1612 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
海创平承科技
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功