Initial project files: BESCMS full source
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<IfModule authz_core_module>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !authz_core_module>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
<Files "*.php">
|
||||
Deny from all
|
||||
</Files>
|
||||
@@ -0,0 +1,6 @@
|
||||
<IfModule authz_core_module>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !authz_core_module>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'type' => 'app',
|
||||
'name' => '自定义资料',
|
||||
'author' => '迅睿云软件',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'uri' => 'block/home/index',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 缓存参数配置
|
||||
*
|
||||
* 模型名称 => 项目目录
|
||||
*
|
||||
* 站点表:安装时由 Install.php 创建;
|
||||
* 新站点或缺表时由 Models/Block::cache($siteid) 自动补建。
|
||||
**/
|
||||
|
||||
return [
|
||||
|
||||
'block' => 'block',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Block 站点表安装(原 Install_site.sql)
|
||||
* App::install 会先跑 Install.php;此处按站点创建 {siteid}_block
|
||||
*/
|
||||
$m = \Phpcmf\Service::M();
|
||||
$t = \Phpcmf\Service::M('table');
|
||||
$sites = !empty($m->site) ? $m->site : [SITE_ID => SITE_ID];
|
||||
foreach ($sites as $siteid) {
|
||||
$table = $m->dbprefix($siteid.'_block');
|
||||
if ($m->is_table_exists($table)) {
|
||||
continue;
|
||||
}
|
||||
$t->create_table($table, [
|
||||
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'name' => 'varchar(100) NOT NULL COMMENT \'名称\'',
|
||||
'code' => 'varchar(100) NOT NULL COMMENT \'别名\'',
|
||||
'hide' => 'tinyint(1) unsigned NOT NULL COMMENT \'隐藏\'',
|
||||
'content' => 'text NOT NULL COMMENT \'内容\'',
|
||||
], [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `code` (`code`)',
|
||||
], '资料块表');
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 菜单配置
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'admin' => [
|
||||
|
||||
'app' => [
|
||||
'left' => [
|
||||
'app-plugin' => [
|
||||
'link' => [
|
||||
[
|
||||
'name' => '自定义资料',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'uri' => 'block/home/index',
|
||||
],
|
||||
|
||||
]
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// 加载主程序的路由
|
||||
require COREPATH.'Config/Routes.php';
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* Block 站点表卸载(原 Uninstall_site.sql)
|
||||
*/
|
||||
$m = \Phpcmf\Service::M();
|
||||
$t = \Phpcmf\Service::M('table');
|
||||
$sites = !empty($m->site) ? $m->site : [SITE_ID => SITE_ID];
|
||||
foreach ($sites as $siteid) {
|
||||
$t->drop_table($m->dbprefix($siteid.'_block'), true);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 更新数据结构
|
||||
**/
|
||||
|
||||
$m = \Phpcmf\Service::M();
|
||||
$t = \Phpcmf\Service::M('table');
|
||||
$prefix = $m->prefix;
|
||||
|
||||
foreach ($this->site as $siteid) {
|
||||
$table = $prefix.$siteid.'_block';
|
||||
if ($m->is_table_exists($table) && !$m->is_field_exists($table, 'code')) {
|
||||
$t->add_field($table, 'code', 'VARCHAR(100)', 'NOT NULL', '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'id' => '360',
|
||||
'vip' => '',
|
||||
'cms' => '4.7.3',
|
||||
'version' => '3.8',
|
||||
'license' => '375C71349B295FBE2DCDCA9206F20A1703',
|
||||
'updatetime' => '2026-06-01 18:26:49',
|
||||
'downtime' => '2026-08-08 00:54:28',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,318 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
// 自定义资料
|
||||
class Home extends \Phpcmf\Table
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->tpl_name = 'block'; // 模板命名名称
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'自定义资料' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-th-large'],
|
||||
'添加' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/add', 'fa fa-plus'],
|
||||
'修改' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
|
||||
'文件存储' => ['add:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/file_edit', 'fa fa-file', '350px', '280px'],
|
||||
'更新缓存' => ['ajax:api/cache_update', 'fa fa-refresh'],
|
||||
'help' => [352],
|
||||
]
|
||||
),
|
||||
'type' => [
|
||||
'0' => dr_lang('单文本'),
|
||||
'1' => dr_lang('多文本'),
|
||||
'2' => dr_lang('富文本'),
|
||||
'3' => dr_lang('单文件'),
|
||||
'4' => dr_lang('多文件'),
|
||||
]
|
||||
]);
|
||||
// 支持附表存储
|
||||
$this->is_data = 0;
|
||||
$app = \Phpcmf\Service::M('app')->get_config(APP_DIR);
|
||||
$this->my_field = array(
|
||||
'name' => array(
|
||||
'ismain' => 1,
|
||||
'name' => dr_lang('名称'),
|
||||
'fieldname' => 'name',
|
||||
'fieldtype' => 'Text',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'width' => 200,
|
||||
),
|
||||
'validate' => array(
|
||||
'required' => 1,
|
||||
'tips' => dr_lang('显示名称'),
|
||||
'formattr' => ' onblur="d_topinyin(\'code\', \'name\')"'
|
||||
)
|
||||
)
|
||||
),
|
||||
'code' => array(
|
||||
'ismain' => 1,
|
||||
'name' => dr_lang('别名'),
|
||||
'fieldname' => 'code',
|
||||
'fieldtype' => 'Text',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'width' => 200,
|
||||
),
|
||||
'validate' => array(
|
||||
'required' => 1,
|
||||
'tips' => dr_lang('调用名称,由字母或数字组成,不得重复'),
|
||||
)
|
||||
)
|
||||
),
|
||||
'value_0' => array(
|
||||
'ismain' => 0,
|
||||
'fieldname' => 'value_0',
|
||||
'fieldtype' => 'Text',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'width' => '90%',
|
||||
),
|
||||
'validate' => array(
|
||||
'xss' => 1,
|
||||
),
|
||||
'is_right' => 2,
|
||||
)
|
||||
),
|
||||
'value_1' => array(
|
||||
'ismain' => 0,
|
||||
'fieldname' => 'value_1',
|
||||
'fieldtype' => 'Textarea',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'width' => '90%',
|
||||
'height' => 250,
|
||||
),
|
||||
'validate' => array(
|
||||
'xss' => 1,
|
||||
),
|
||||
'is_right' => 2,
|
||||
)
|
||||
),
|
||||
'value_2' => array(
|
||||
'ismain' => 0,
|
||||
'fieldtype' => 'Ueditor',
|
||||
'fieldname' => 'value_2',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'mode' => 1,
|
||||
'height' => 300,
|
||||
'div2p' => '1',
|
||||
'attachment' => intval($app['file']),
|
||||
'width' => '100%'
|
||||
),
|
||||
'is_right' => 2,
|
||||
)
|
||||
),
|
||||
'value_3' => array(
|
||||
'ismain' => 0,
|
||||
'fieldtype' => 'File',
|
||||
'fieldname' => 'value_3',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'ext' => '*',
|
||||
'input' => 1,
|
||||
'size' => 99999,
|
||||
'attachment' => intval($app['file']),
|
||||
),
|
||||
'is_right' => 2,
|
||||
)
|
||||
),
|
||||
'value_4' => array(
|
||||
'ismain' => 0,
|
||||
'fieldtype' => 'Files',
|
||||
'fieldname' => 'value_4',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'ext' => '*',
|
||||
'desc' => 1,
|
||||
'name' => 1,
|
||||
'input' => 1,
|
||||
'size' => 99999,
|
||||
'count' => 99999,
|
||||
'attachment' => intval($app['file']),
|
||||
),
|
||||
'is_right' => 2,
|
||||
)
|
||||
),
|
||||
);
|
||||
// 表单显示名称
|
||||
$this->name = dr_lang('自定义资料');
|
||||
// 初始化数据表
|
||||
$this->_init([
|
||||
'table' => SITE_ID.'_block',
|
||||
'field' => $this->my_field,
|
||||
'order_by' => 'id desc',
|
||||
]);
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'field' => $this->my_field,
|
||||
]);
|
||||
}
|
||||
|
||||
// 后台查看表单列表
|
||||
public function index() {
|
||||
// 新字段
|
||||
$table = \Phpcmf\Service::M()->dbprefix(SITE_ID.'_block');
|
||||
if (\Phpcmf\Service::M()->is_table_exists($table)) {
|
||||
if (!\Phpcmf\Service::M()->is_field_exists($table, 'hide')) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'hide', 'int(5)', 'DEFAULT 0', '');
|
||||
}
|
||||
}
|
||||
list($tpl, $data) = $this->_List();
|
||||
$data['list'] && $data['list'] = \Phpcmf\Service::M('Block', APP_DIR)->getValueAll($data['list']);
|
||||
\Phpcmf\Service::V()->assign($data);
|
||||
\Phpcmf\Service::V()->display($tpl);
|
||||
}
|
||||
|
||||
// 后台添加表单内容
|
||||
public function add() {
|
||||
list($tpl) = $this->_Post(0);
|
||||
\Phpcmf\Service::V()->display($tpl);
|
||||
}
|
||||
|
||||
// 后台修改表单内容
|
||||
public function edit() {
|
||||
list($tpl) = $this->_Post(intval(\Phpcmf\Service::L('Input')->get('id')));
|
||||
\Phpcmf\Service::V()->display($tpl);
|
||||
}
|
||||
|
||||
public function file_edit() {
|
||||
|
||||
$data = \Phpcmf\Service::M('app')->get_config(APP_DIR);
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
|
||||
\Phpcmf\Service::M('app')->save_config(APP_DIR, $post);
|
||||
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'data' => $data,
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'remote' => \Phpcmf\Service::C()->get_cache('attachment'),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('config.html');exit;
|
||||
}
|
||||
|
||||
// 调用代码
|
||||
public function show_index() {
|
||||
|
||||
$data =$this->_Data(intval(\Phpcmf\Service::L('Input')->get('id')));
|
||||
!$data && $this->_json(0, dr_lang('数据#%s不存在', $_GET['id']));
|
||||
|
||||
$key = $data['code'] ? $data['code'] : $data['id'];
|
||||
$code = '// 下面调用标题';
|
||||
$code.= PHP_EOL.'{dr_block(\''.$key.'\', 1)}';
|
||||
$code.= PHP_EOL.'// 下面调用内容';
|
||||
switch ($data['i']) {
|
||||
case 3:
|
||||
$code.= PHP_EOL.'{dr_get_file(dr_block(\''.$key.'\'))}';
|
||||
break;
|
||||
case 4:
|
||||
$code.= PHP_EOL.'{php $block=dr_block(\''.$key.'\');}';
|
||||
$code.= PHP_EOL.'{loop $block.file $i $file}';
|
||||
$code.= PHP_EOL.'文件地址: {dr_get_file($file)}';
|
||||
$code.= PHP_EOL.'文件标题: {$block[\'title\'][$i]}';
|
||||
$code.= PHP_EOL.'文件描述: {$block[\'description\'][$i]}';
|
||||
$code.= PHP_EOL.'{/loop}';
|
||||
break;
|
||||
default:
|
||||
$code.= PHP_EOL.'{dr_block(\''.$key.'\')}';
|
||||
break;
|
||||
}
|
||||
\Phpcmf\Service::V()->assign('code', $code);
|
||||
\Phpcmf\Service::V()->display('block_show.html');
|
||||
exit;
|
||||
}
|
||||
|
||||
// 保存
|
||||
protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
|
||||
return parent::_Save($id, $data, $old, function($id, $data, $old){
|
||||
$data[1]['code'] = dr_safe_replace($data[1]['code']);
|
||||
if (!$data[1]['code']) {
|
||||
return dr_return_data(0, dr_lang('别名不存在'));
|
||||
} elseif (\Phpcmf\Service::M()->table(SITE_ID.'_block')->is_exists($id, 'code', $data[1]['code'])) {
|
||||
return dr_return_data(0, dr_lang('别名已经存在'));
|
||||
}
|
||||
switch (intval($_POST['type'])) {
|
||||
case 0:
|
||||
// 文本内容
|
||||
$data[1]['content'] = '{i-0}:'.($data[0]['value_0'] ? $data[0]['value_0'] : '');
|
||||
break;
|
||||
case 1:
|
||||
// 文本内容
|
||||
$data[1]['content'] = $data[0]['value_1'] ? $data[0]['value_1'] : '';
|
||||
break;
|
||||
case 2:
|
||||
// 丰富文本
|
||||
$data[1]['content'] = '{i-2}:'.($data[0]['value_2'] ? $data[0]['value_2'] : '');
|
||||
break;
|
||||
case 3:
|
||||
// 单文件
|
||||
$data[1]['content'] = '{i-3}:'.($data[0]['value_3'] ? $data[0]['value_3'] : '');
|
||||
break;
|
||||
case 4:
|
||||
// 多文件
|
||||
$data[1]['content'] = '{i-4}:'.($data[0]['value_4'] ? dr_array2string($data[0]['value_4']) : '');
|
||||
break;
|
||||
}
|
||||
return dr_return_data(1, null, $data);
|
||||
}, function ($id, $data, $old) {
|
||||
// 更新缓存
|
||||
\Phpcmf\Service::M('block', APP_DIR)->cache();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// 隐藏或者启用
|
||||
public function hidden_edit() {
|
||||
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
$row = \Phpcmf\Service::M()->table(SITE_ID.'_block')->get($id);
|
||||
if (!$row) {
|
||||
$this->_json(0, dr_lang('数据不存在'));
|
||||
}
|
||||
|
||||
$v = $row['hide'] ? 0 : 1;
|
||||
\Phpcmf\Service::M()->table(SITE_ID.'_block')->update($id, ['hide' => $v]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
|
||||
exit($this->_json(1, dr_lang($v ? '已被禁用' : '已被启用'), ['value' => $v]));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内容
|
||||
* $id 内容id,新增为0
|
||||
* */
|
||||
protected function _Data($id = 0) {
|
||||
$data = parent::_Data($id);
|
||||
$data = \Phpcmf\Service::M('Block', APP_DIR)->getValue($data);
|
||||
if (!$id) {
|
||||
$data['hide'] = 0;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 后台删除表单内容
|
||||
public function del() {
|
||||
$this->_Del(
|
||||
\Phpcmf\Service::L('Input')->get_post_ids(),
|
||||
null,
|
||||
function ($r) {
|
||||
// 更新缓存
|
||||
\Phpcmf\Service::M('block', APP_DIR)->cache();
|
||||
},
|
||||
\Phpcmf\Service::M()->dbprefix($this->init['table'])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php namespace Phpcmf\Model\Block;
|
||||
|
||||
// 模型类
|
||||
|
||||
class Block extends \Phpcmf\Model
|
||||
{
|
||||
|
||||
// 格式化结果
|
||||
public function getValueAll($v) {
|
||||
|
||||
foreach ($v as $i => $value) {
|
||||
$v[$i] = $this->getValue($value);
|
||||
}
|
||||
|
||||
return $v;
|
||||
}
|
||||
|
||||
public function getValue($value) {
|
||||
|
||||
if (!$value['content']) {
|
||||
$value['i'] = 0;
|
||||
$value['value_0'] = '';
|
||||
} else {
|
||||
if (preg_match('/\{i-([0-9]+)\}:/U', $value['content'], $preg)) {
|
||||
$value['i'] = intval($preg[1]);
|
||||
$value['value_'.$value['i']] = str_replace((string)$preg[0], '', $value['content']);
|
||||
if ($value['i'] == 4) {
|
||||
$value['value_'.$value['i']] = dr_string2array($value['value_'.$value['i']]);
|
||||
}
|
||||
} else {
|
||||
$value['i'] = 1;
|
||||
$value['value_1'] = $value['content'];
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保当前站点的资料块表存在(替代 Install_site.sql)
|
||||
* 表名:{dbprefix}{siteid}_block
|
||||
*/
|
||||
protected function _ensure_site_table($siteid) {
|
||||
|
||||
$siteid = intval($siteid);
|
||||
$table = $siteid.'_block';
|
||||
$full = $this->dbprefix($table);
|
||||
if ($this->is_table_exists($full)) {
|
||||
return $table;
|
||||
}
|
||||
|
||||
$rt = \Phpcmf\Service::M('table')->create_table(
|
||||
$full,
|
||||
[
|
||||
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'name' => 'varchar(100) NOT NULL COMMENT \'名称\'',
|
||||
'code' => 'varchar(100) NOT NULL COMMENT \'别名\'',
|
||||
'hide' => 'tinyint(1) unsigned NOT NULL COMMENT \'隐藏\'',
|
||||
'content' => 'text NOT NULL COMMENT \'内容\'',
|
||||
],
|
||||
[
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `code` (`code`)',
|
||||
],
|
||||
'资料块表'
|
||||
);
|
||||
if (!$rt['code']) {
|
||||
log_message('error', 'Block 站点表创建失败['.$full.']:'.($rt['msg'] ?? ''));
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
// 缓存(按站点执行;缺表时自动建表)
|
||||
public function cache($siteid = SITE_ID) {
|
||||
|
||||
$this->_ensure_site_table($siteid);
|
||||
$table = \Phpcmf\Service::M()->dbprefix($siteid.'_block');
|
||||
if (!\Phpcmf\Service::M()->is_field_exists($table, 'hide')) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'hide', 'int(5)', 'DEFAULT 0', '');
|
||||
}
|
||||
$data = $this->table($siteid.'_block')->getAll();
|
||||
$cache = [];
|
||||
if ($data) {
|
||||
foreach ($data as $t) {
|
||||
if ($t['hide']) {
|
||||
continue;
|
||||
}
|
||||
$t = $this->getValue($t);
|
||||
if (!$t['code']) {
|
||||
// 填充默认code
|
||||
$t['code'] = $t['id'];
|
||||
$this->table($siteid.'_block')->update($t['id'], [
|
||||
'code' => $t['id'],
|
||||
]);
|
||||
}
|
||||
switch (intval($t['i'])) {
|
||||
case 0:
|
||||
// 文本内容
|
||||
$value = $t['value_0'];
|
||||
break;
|
||||
case 1:
|
||||
// 文本内容
|
||||
$value = $t['value_1'];
|
||||
break;
|
||||
case 2:
|
||||
// 丰富文本
|
||||
$value = htmlspecialchars_decode($t['value_2']);
|
||||
break;
|
||||
case 3:
|
||||
// 单文件
|
||||
$value = $t['value_3'];
|
||||
break;
|
||||
case 4:
|
||||
// 多文件
|
||||
$value = dr_string2array($t['value_4']);
|
||||
break;
|
||||
}
|
||||
$cache[$t['code']] = [
|
||||
1 => $t['name'],
|
||||
0 => $value
|
||||
];
|
||||
}
|
||||
}
|
||||
\Phpcmf\Service::L('cache')->set_file('block-'.$siteid, $cache);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
{template "header.html"}
|
||||
|
||||
|
||||
<div class="note note-danger" id="table-search-tool">
|
||||
<div class="row table-search-tool">
|
||||
<form action="{SELF}" method="get">
|
||||
{dr_form_search_hidden()}
|
||||
<div class="col-md-12 col-sm-12">
|
||||
<label>
|
||||
<select name="field" class="form-control">
|
||||
<option value="id"> Id </option>
|
||||
{loop $field $t}
|
||||
{if $t.ismain}
|
||||
<option value="{$t.fieldname}" {if $param.field==$t.fieldname}selected{/if}>{$t.name}</option>
|
||||
{/if}
|
||||
{/loop}
|
||||
</select>
|
||||
</label>
|
||||
<label><i class="fa fa-caret-right"></i></label>
|
||||
<label><input type="text" class="form-control" placeholder="" value="{$param['keyword']}" name="keyword" /></label>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 col-sm-12">
|
||||
<button type="submit" class="btn blue btn-sm onloading" name="submit" > <i class="fa fa-search"></i> {dr_lang('搜索')}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="right-card-box">
|
||||
|
||||
|
||||
<form class="form-horizontal" role="form" id="myform">
|
||||
{dr_form_hidden()}
|
||||
<div class="table-scrollable">
|
||||
<table class="table table-striped table-bordered table-hover table-checkable dataTable">
|
||||
<thead>
|
||||
<tr class="heading">
|
||||
{if $ci->_is_admin_auth('del')}
|
||||
<th class="myselect">
|
||||
<label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
|
||||
<input type="checkbox" class="group-checkable" data-set=".checkboxes" />
|
||||
<span></span>
|
||||
</label>
|
||||
</th>
|
||||
{/if}
|
||||
<th style="text-align:center" width="90" class="{dr_sorting('id')}" name="id">{dr_lang('Id')}</th>
|
||||
<th width="60" style="text-align:center"> {dr_lang('状态')} </th>
|
||||
<th style="text-align:center" width="80">{dr_lang('类型')}</th>
|
||||
<th width="200" class="{dr_sorting('code')}" name="code">{dr_lang('别名')}</th>
|
||||
<th class="{dr_sorting('name')}" name="name">{dr_lang('名称')}</th>
|
||||
<th>{dr_lang('操作')}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{loop $list $t}
|
||||
<tr class="odd gradeX" id="dr_row_{$t.id}">
|
||||
{if $ci->_is_admin_auth('del')}
|
||||
<td class="myselect">
|
||||
<label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
|
||||
<input type="checkbox" class="checkboxes" name="ids[]" value="{$t.id}" />
|
||||
<span></span>
|
||||
</label>
|
||||
</td>
|
||||
{/if}
|
||||
<td style="text-align:center"> {$t.id} </td>
|
||||
<td style="text-align:center">
|
||||
<a href="javascript:;" onclick="dr_ajax_open_close(this, '{dr_url(APP_DIR.'/home/hidden_edit', ['id'=>$t.id])}', 1);" class="badge badge-{if $t.hide}no{else}yes{/if}"><i class="fa fa-{if $t.no}times{else}check{/if}"></i></a>
|
||||
</td>
|
||||
<td style="text-align:center"> {$type[$t['i']]} </td>
|
||||
<td>{$t.code}</td>
|
||||
<td>{$t.name}</td>
|
||||
<td>
|
||||
{if $ci->_is_admin_auth('edit')}
|
||||
<label><a href="{dr_url($uriprefix.'/edit', ['id'=>$t.id])}" class="btn btn-xs green"> <i class="fa fa-edit"></i> {dr_lang('修改')}</a></label>
|
||||
{/if}
|
||||
<label><a href="javascript:dr_iframe_show('code', '{dr_url($uriprefix.'/show_index', ['id'=>$t.id])}', '400px', '50%');" class="btn btn-xs dark"> <i class="fa fa-code"></i> {dr_lang('调用代码')}</a></label>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="row fc-list-footer table-checkable ">
|
||||
<div class="col-md-5 fc-list-select">
|
||||
{if $ci->_is_admin_auth('del')}
|
||||
<label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
|
||||
<input type="checkbox" class="group-checkable" data-set=".checkboxes" />
|
||||
<span></span>
|
||||
</label>
|
||||
<button type="button" onclick="dr_ajax_option('{dr_url($uriprefix.'/del')}', '{dr_lang('你确定要删除它们吗?')}', 1)" class="btn red btn-sm"> <i class="fa fa-trash"></i> {dr_lang('删除')}</button>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="col-md-7 fc-list-page">
|
||||
{$mypages}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
{template "footer.html"}
|
||||
@@ -0,0 +1,65 @@
|
||||
{template "header.html"}
|
||||
<div class="note note-danger">
|
||||
<p><a href="javascript:dr_update_cache('block', 'system');">{dr_lang('更改数据之后需要更新缓存之后才能生效')}</a></p>
|
||||
</div>
|
||||
<script type="application/javascript">
|
||||
$(function(){
|
||||
dr_set_value({intval($i)});
|
||||
});
|
||||
function dr_set_value(i) {
|
||||
$('#dr_row_value_0').hide();
|
||||
$('#dr_row_value_1').hide();
|
||||
$('#dr_row_value_2').hide();
|
||||
$('#dr_row_value_3').hide();
|
||||
$('#dr_row_value_4').hide();
|
||||
$('#dr_row_value_'+i).show();
|
||||
}
|
||||
</script>
|
||||
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
|
||||
{$form}
|
||||
<div class="portlet bordered light myfbody">
|
||||
<div class="portlet-title">
|
||||
<div class="caption">
|
||||
<span class="caption-subject font-green-sharp">
|
||||
{dr_lang('自定义资料')}
|
||||
</span>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="btn-group">
|
||||
<a class="btn" href="{$reply_url}"> <i class="fa fa-mail-reply"></i> {dr_lang('返回')}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-body">
|
||||
<div class="form-body">
|
||||
|
||||
{$myfield}
|
||||
<div class="form-group {if $id}dr_block_type_html{/if}">
|
||||
<label class="col-md-2 control-label">{dr_lang('类别')}</label>
|
||||
<div class="col-md-9">
|
||||
<div class="mt-radio-inline">
|
||||
{loop $type $ii $name}
|
||||
<label class="mt-radio">
|
||||
<input onclick="dr_set_value({$ii})" {if $ii==$i}checked{/if} name="type" type="radio" value="{$ii}"> {$name}
|
||||
<span></span>
|
||||
</label>
|
||||
{/loop}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{$diyfield}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="portlet-body form myfooter">
|
||||
<div class="form-actions text-center">
|
||||
<button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存内容')}</button>
|
||||
<button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$post_url}')" class="btn green"> <i class="fa fa-plus"></i> {dr_lang('保存再添加')}</button>
|
||||
<button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$reply_url}')" class="btn yellow"> <i class="fa fa-mail-reply-all"></i> {dr_lang('保存并返回')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{template "footer.html"}
|
||||
@@ -0,0 +1,59 @@
|
||||
{template "header.html"}
|
||||
|
||||
<form class="form-horizontal" method="post" role="form" id="myform">
|
||||
|
||||
<div class="form-body">
|
||||
|
||||
|
||||
<link href="{THEME_PATH}assets/global/plugins/codemirror/lib/codemirror.css" rel="stylesheet" type="text/css" />
|
||||
<link href="{THEME_PATH}assets/global/plugins/codemirror/theme/neat.css" rel="stylesheet" type="text/css" />
|
||||
<link href="{THEME_PATH}assets/global/plugins/codemirror/theme/ambiance.css" rel="stylesheet" type="text/css" />
|
||||
<link href="{THEME_PATH}assets/global/plugins/codemirror/theme/material.css" rel="stylesheet" type="text/css" />
|
||||
<link href="{THEME_PATH}assets/global/plugins/codemirror/theme/neo.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script src="{THEME_PATH}assets/global/plugins/codemirror/lib/codemirror.js" type="text/javascript"></script>
|
||||
<script src="{THEME_PATH}assets/global/plugins/codemirror/mode/javascript/javascript.js" type="text/javascript"></script>
|
||||
<script src="{THEME_PATH}assets/global/plugins/codemirror/mode/htmlmixed/htmlmixed.js" type="text/javascript"></script>
|
||||
<script src="{THEME_PATH}assets/global/plugins/codemirror/mode/css/css.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var ComponentsCodeEditors = function () {
|
||||
|
||||
var handleDemo1 = function () {
|
||||
var myTextArea = document.getElementById('code_editor_demo_1');
|
||||
var myCodeMirror = CodeMirror.fromTextArea(myTextArea, {
|
||||
lineNumbers: false,
|
||||
matchBrackets: true,
|
||||
styleActiveLine: true,
|
||||
theme:"neo",
|
||||
mode: 'css',
|
||||
readOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
//main function to initiate the module
|
||||
init: function () {
|
||||
handleDemo1();
|
||||
}
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
ComponentsCodeEditors.init();
|
||||
});
|
||||
</script>
|
||||
<div class="form-group ">
|
||||
<div class="col-xs-12">
|
||||
<textarea id="code_editor_demo_1">{$code}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.CodeMirror {
|
||||
height:180px;
|
||||
}
|
||||
</style>
|
||||
{template "footer.html"}
|
||||
@@ -0,0 +1,21 @@
|
||||
{template "header.html"}
|
||||
|
||||
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
|
||||
{$form}
|
||||
<div class="form-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">{dr_lang('文件存储策略')}</label>
|
||||
<div class="col-md-9">
|
||||
<label><select class="form-control" name="data[file]">
|
||||
<option value="0"> {dr_lang('默认存储')} </option>
|
||||
{loop $remote $i $t}
|
||||
<option value="{$i}" {php echo ($i == $data['file'] ? 'selected' : '');}> {dr_lang($t['name'])} </option>
|
||||
{/loop}
|
||||
</select></label>
|
||||
<span class="help-block">资料中的文件存储位置选择</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
{template "footer.html"}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
// 栏目
|
||||
|
||||
if (!$dirname) {
|
||||
$dirname = 'share';
|
||||
}
|
||||
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
|
||||
if (!$module) {
|
||||
return $this->_return($system['return'], "模块({$dirname})尚未安装");
|
||||
} elseif (!$module['category']) {
|
||||
return $this->_return($system['return'], "模块({$dirname})没有栏目数据");
|
||||
}
|
||||
|
||||
$show = isset($param['show']) && $param['show'] ? 1 : 0; // 有show参数表示显示隐藏栏目
|
||||
$return = [];
|
||||
|
||||
if (isset($param['pid'])) {
|
||||
$param['pid'] = explode(',', (string)$param['pid']);
|
||||
}
|
||||
if (isset($param['catid']) && $param['catid']) {
|
||||
$param['id'] = $param['catid'];
|
||||
}
|
||||
if (isset($param['id']) && $param['id']) {
|
||||
$arr = explode(',', $param['id']);
|
||||
if ($arr) {
|
||||
$new = [];
|
||||
foreach ($arr as $t) {
|
||||
if ($t && isset($module['category'][$t]) && $module['category'][$t]) {
|
||||
$new[$t] = $module['category'][$t];
|
||||
}
|
||||
}
|
||||
$module['category'] = $new;
|
||||
}
|
||||
}
|
||||
|
||||
if ($module['category']) {
|
||||
foreach ($module['category'] as $t) {
|
||||
if (!$t['show'] && !$show) {
|
||||
continue;
|
||||
} elseif (isset($param['pid']) && !dr_in_array($t['pid'], $param['pid'])) {
|
||||
continue;
|
||||
} elseif (isset($param['mid']) && $t['mid'] != $param['mid']) {
|
||||
continue;
|
||||
} elseif (isset($param['tid']) && $t['tid'] != (int)$param['tid']) {
|
||||
continue;
|
||||
} elseif (isset($param['child']) && $t['child'] != (int)$param['child']) {
|
||||
continue;
|
||||
} elseif (isset($system['more']) && !$system['more']) {
|
||||
unset($t['field'], $t['setting']);
|
||||
}
|
||||
if ($t['tid'] == 2) {
|
||||
// 外链栏目
|
||||
} else {
|
||||
$t['url'] = dr_url_rel(dr_url_prefix($t['url'], $module['mid'], $system['site'], $this->_is_mobile));
|
||||
}
|
||||
$return[] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
// order
|
||||
if ($system['order']) {
|
||||
$arr = explode(',', $system['order']);
|
||||
foreach ($arr as $t) {
|
||||
$a = explode('_', $t);
|
||||
$b = strtolower(end($a));
|
||||
if (in_array($b, ['desc', 'asc', 'instr'])) {
|
||||
$a = str_replace('_'.$b, '', $t);
|
||||
} else {
|
||||
$a = $t;
|
||||
$b = 'desc';
|
||||
}
|
||||
if ($b == 'instr') {
|
||||
|
||||
} else {
|
||||
$return = dr_array_sort($return, $a, $b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// num参数
|
||||
if ($system['num']) {
|
||||
if (is_numeric($system['num'])) {
|
||||
$return = array_slice($return, 0, $system['num']);
|
||||
} elseif (strpos($system['num'], ',') !== false) {
|
||||
list($a, $b) = explode(',', $system['num']);
|
||||
$return = array_slice($return, max(0, $a - 1), $b);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$return) {
|
||||
return $this->_return($system['return'], '没有匹配到内容');
|
||||
}
|
||||
|
||||
return $this->_return($system['return'], $return, '');
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// 栏目搜索字段筛选
|
||||
|
||||
$catid = $system['catid'];
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
|
||||
if (!$module) {
|
||||
return $this->_return($system['return'], '模块('.$dirname.')未安装');
|
||||
} elseif (!$catid) {
|
||||
return $this->_return($system['return'], '没有catid值无法显示结果');
|
||||
} elseif (!isset($module['category'][$catid])) {
|
||||
return $this->_return($system['return'], '模块('.$dirname.')的栏目('.$catid.')不存在');
|
||||
} elseif (dr_count($module['category'][$catid]['field']) == 0) {
|
||||
return $this->_return($system['return'], '模块('.$dirname.')的栏目('.$catid.')没有分配模型字段');
|
||||
}
|
||||
|
||||
$return = [];
|
||||
|
||||
foreach ($module['category'][$catid]['field'] as $field) {
|
||||
$t = $module['category_data_field'][$field];
|
||||
if ($t) {
|
||||
$data = dr_format_option_array($t['setting']['option']['options']);
|
||||
if ($t['issearch'] && in_array($t['fieldtype'], ['Select', 'Selects', 'Radio', 'Checkbox']) && $data) {
|
||||
$list = [];
|
||||
foreach ($data as $value => $name) {
|
||||
$name && !is_null($value) && $list[] = array(
|
||||
'name' => trim($name),
|
||||
'value' => trim($value)
|
||||
);
|
||||
}
|
||||
$list && $return[] = array(
|
||||
'data' => $list,
|
||||
'name' => $t['name'],
|
||||
'field' => $t['fieldname'],
|
||||
'displayorder' => $t['displayorder'],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$system['order'] && $return = dr_array_sort($return, 'displayorder');
|
||||
|
||||
return $this->_return($system['return'], $return, '');
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// 模块内容详细页面
|
||||
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
|
||||
if (!$module) {
|
||||
return $this->_return($system['return'], "模块({$dirname})未安装");
|
||||
} elseif (!$param['id']) {
|
||||
return $this->_return($system['return'], "模块({$dirname})缺少id参数");
|
||||
}
|
||||
|
||||
$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
|
||||
if (!$tableinfo) {
|
||||
// 没有表结构缓存时返回空
|
||||
return $this->_return($system['return'], '表结构缓存不存在');
|
||||
}
|
||||
|
||||
$table = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module['dirname'], $system['site'])); // 模块主表`
|
||||
if (!isset($tableinfo[$table])) {
|
||||
return $this->_return($system['return'], '表('.$table.')结构缓存不存在');
|
||||
}
|
||||
|
||||
// 初始化数据表
|
||||
$db = \Phpcmf\Service::M('Content', $dirname);
|
||||
$db->_init($dirname, $system['site']);
|
||||
if ($module['category_data_field']) {
|
||||
$system['more'] = 1;
|
||||
}
|
||||
$data = $db->get_data(intval($param['id']), 0, [], $system['more']);
|
||||
|
||||
// 缓存查询结果
|
||||
if (is_array($data) && $data) {
|
||||
// 模块表的系统字段
|
||||
$fields = $module['field']; // 主表的字段
|
||||
if ($module['category_data_field']) {
|
||||
$fields = dr_array2array($fields, $module['category_data_field']);
|
||||
}
|
||||
$fields['inputtime'] = array('fieldtype' => 'Date');
|
||||
$fields['updatetime'] = array('fieldtype' => 'Date');
|
||||
// 格式化显示自定义字段内容
|
||||
$dfield = \Phpcmf\Service::L('Field')->app($module['dirname']);
|
||||
$data['url'] = dr_url_rel(dr_url_prefix($data['url'], $dirname, $system['site'], $this->_is_mobile));
|
||||
$data = $dfield->format_value($fields, $data, 1);
|
||||
|
||||
// 存储缓存
|
||||
$system['cache'] && $this->_save_cache_data($cache_name, [
|
||||
'data' => [$data],
|
||||
'sql' => '',
|
||||
'total' => 0,
|
||||
'pages' => 0,
|
||||
'pagesize' => 0,
|
||||
'page_used' => $this->_page_used,
|
||||
'page_urlrule' => $this->_page_urlrule,
|
||||
], $system['cache']);
|
||||
|
||||
}
|
||||
return $this->_return($system['return'], [$data]);
|
||||
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
// 模块数据
|
||||
|
||||
|
||||
// 通过栏目识别共享模块目录
|
||||
if ((!$dirname || $dirname == 'share') && $system['catid']) {
|
||||
$cat = dr_share_cat_value($system['catid']);
|
||||
if ($cat && $cat['mid']) {
|
||||
$dirname = $cat['mid'];
|
||||
unset($cat);
|
||||
}
|
||||
}
|
||||
if (!$dirname) {
|
||||
$return_data = $this->_return($system['return'], '模块参数module未填写');
|
||||
return;
|
||||
}
|
||||
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
|
||||
if (!$module) {
|
||||
if (strpos($system['module'], ',') || $system['module'] == 'all') {
|
||||
require 'Modules.php';
|
||||
return;
|
||||
}
|
||||
$return_data = $this->_return($system['return'], '模块('.$dirname.')未安装');
|
||||
return;
|
||||
}
|
||||
|
||||
$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
|
||||
|
||||
// 没有表结构缓存时返回空
|
||||
if (!$tableinfo) {
|
||||
$return_data = $this->_return($system['return'], '表结构缓存不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
$table = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module['dirname'], $system['site'])); // 模块主表`
|
||||
if (!isset($tableinfo[$table])) {
|
||||
$return_data = $this->_return($system['return'], '表('.$table.')结构缓存不存在');
|
||||
return;
|
||||
}
|
||||
|
||||
// 加上状态判断
|
||||
//$where[] = ['adj' => '', 'name' => 'status', 'value' => 9];
|
||||
|
||||
// 是否操作自定义where
|
||||
if ($param['where']) {
|
||||
$where[] = [
|
||||
'adj' => 'SQL',
|
||||
'value' => urldecode($param['where'])
|
||||
];
|
||||
unset($param['where']);
|
||||
}
|
||||
|
||||
$fields = $module['field']; // 主表的字段
|
||||
|
||||
// 排序操作
|
||||
if (!$system['order'] && isset($where['id']) && $where['id']['adj'] == 'IN' && $where['id']['value']) {
|
||||
// 按id序列来排序
|
||||
$system['order'] = strlen($where['id']['value']) < 10000 && $where['id']['value'] ? 'FIELD(`'.$table.'`.`id`, '.$where['id']['value'].')' : 'NULL';
|
||||
} else {
|
||||
// 默认排序参数
|
||||
!$system['order'] && ($system['order'] = $system['flag'] ? 'updatetime_desc' : ($action == 'hits' ? 'hits' : 'updatetime'));
|
||||
}
|
||||
|
||||
// 栏目筛选
|
||||
if ($system['catid']) {
|
||||
$fwhere = [];
|
||||
if (strpos($system['catid'], ',') !== FALSE) {
|
||||
$temp = explode(',', $system['catid']);
|
||||
if ($temp) {
|
||||
$catids = [];
|
||||
foreach ($temp as $i) {
|
||||
$catids = $module['category'][$i]['child'] ? array_merge($catids, $module['category'][$i]['catids']) : array_merge($catids, array($i));
|
||||
}
|
||||
$catids && $fwhere[] = '`'.$table.'`.`catid` IN ('.implode(',', $catids).')';
|
||||
}
|
||||
unset($temp);
|
||||
} elseif ($module['category'][$system['catid']]['child']) {
|
||||
$catids = explode(',', $module['category'][$system['catid']]['childids']);
|
||||
$fwhere[] = '`'.$table.'`.`catid` IN ('.$module['category'][$system['catid']]['childids'].')';
|
||||
} else {
|
||||
$fwhere[] = '`'.$table.'`.`catid` = '.(int)$system['catid'];
|
||||
$catids = [$system['catid']];
|
||||
}
|
||||
|
||||
// 副栏目判断
|
||||
if (isset($fields['catids']) && $fields['catids']['fieldtype'] = 'Catids') {
|
||||
foreach ($catids as $c) {
|
||||
$fwhere[] = \Phpcmf\Service::M()->where_json($table, 'catids', intval($c));
|
||||
}
|
||||
}
|
||||
$fwhere && $where[] = [
|
||||
'adj' => 'SQL',
|
||||
'value' => urldecode(count($fwhere) == 1 ? $fwhere[0] : '('.implode(' OR ', $fwhere).')')
|
||||
];
|
||||
unset($fwhere);
|
||||
unset($catids);
|
||||
}
|
||||
|
||||
// 查找mwhere目录
|
||||
$mwhere = \Phpcmf\Service::Mwhere_Apps();
|
||||
if ($mwhere) {
|
||||
$mid = $dirname;
|
||||
$field = $tableinfo[$table];
|
||||
$siteid = $system['site'];
|
||||
foreach ($mwhere as $mapp) {
|
||||
$w = require dr_get_app_dir($mapp).'Config/Mwhere.php';
|
||||
if ($w) {
|
||||
$where[] = ['adj' => 'sql', 'value' => $w];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// groupid查询
|
||||
if (isset($param['groupid']) && $param['groupid']) {
|
||||
|
||||
if (strpos($param['groupid'], ',') !== false) {
|
||||
$gwhere = ' `'.$table.'`.`uid` in (select uid from `'.\Phpcmf\Service::M()->dbprefix('member').'_group_index` where `gid` in ('.dr_safe_replace($param['groupid']).'))';
|
||||
} elseif (strpos($param['groupid'], '-') !== false) {
|
||||
$arr = explode('-', $param['groupid']);
|
||||
$gwhere = [];
|
||||
foreach ($arr as $t) {
|
||||
$t = intval($t);
|
||||
$t && $gwhere[] = ' `'.$table.'`.`uid` in (select uid from `'.\Phpcmf\Service::M()->dbprefix('member').'_group_index` where `gid` = '. $t.')';
|
||||
}
|
||||
$gwhere = $gwhere ? '('.implode(' AND ', $gwhere).')' : '';
|
||||
} else {
|
||||
$gwhere = ' `'.$table.'`.`uid` in (select uid from `'.\Phpcmf\Service::M()->dbprefix('member').'_group_index` where `gid` = '. intval($param['groupid']).')';
|
||||
}
|
||||
$gwhere && $where['id'] = [
|
||||
'adj' => 'SQL',
|
||||
'name' => 'id',
|
||||
'value' => $gwhere
|
||||
];
|
||||
unset($param['groupid']);
|
||||
}
|
||||
|
||||
$where = $this->_set_where_field_prefix($where, $tableinfo[$table], $table, $fields); // 给条件字段加上表前缀
|
||||
$system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table], $table); // 给显示字段加上表前缀
|
||||
|
||||
// 多表组合排序
|
||||
$_order = [];
|
||||
$_order[$table] = $tableinfo[$table];
|
||||
|
||||
// sql的from子句
|
||||
if ($action == 'hits') {
|
||||
$sql_from = '`'.$table.'` LEFT JOIN `'.$table.'_hits` ON `'.$table.'`.`id`=`'.$table.'_hits`.`id`';
|
||||
$table_more = $table.'_hits'; // hits表
|
||||
$system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table_more], $table_more); // 给显示字段加上表前缀
|
||||
$_order[$table_more] = $tableinfo[$table_more];
|
||||
if (!$system['field']) {
|
||||
$system['field'] = '`'.$table.'`.*';
|
||||
$fields_more = \Phpcmf\Service::M()->db->getFieldNames($table_more);
|
||||
if ($fields_more) {
|
||||
foreach ($fields_more as $f) {
|
||||
if (!in_array($f, ['id', 'catid', 'uid'])) {
|
||||
$system['field'].= ',`'.$table_more.'`.`'.$f.'`';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql_from = '`'.$table.'`';
|
||||
}
|
||||
|
||||
// 关联栏目模型表
|
||||
if ($system['more']) {
|
||||
$table_more = $table.'_category_data'; // 栏目模型表
|
||||
if (isset($module['category_data_field']) && $module['category_data_field']) {
|
||||
$fields = array_merge($fields, $module['category_data_field']);
|
||||
$where = $this->_set_where_field_prefix($where, $tableinfo[$table_more], $table_more, $fields); // 给条件字段加上表前缀
|
||||
$system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table_more], $table_more); // 给显示字段加上表前缀
|
||||
$_order[$table_more] = $tableinfo[$table_more];
|
||||
}
|
||||
$sql_from.= " LEFT JOIN $table_more ON `$table_more`.`id`=`$table`.`id`"; // sql的from子句
|
||||
if (!$system['field']) {
|
||||
$system['field'] = '`'.$table.'`.*';
|
||||
$fields_more = \Phpcmf\Service::M()->db->getFieldNames($table_more);
|
||||
if ($fields_more) {
|
||||
foreach ($fields_more as $f) {
|
||||
if (!in_array($f, ['id', 'catid', 'uid'])) {
|
||||
$system['field'].= ',`'.$table_more.'`.`'.$f.'`';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 关联表
|
||||
if ($system['join'] && $system['on']) {
|
||||
$rt = $this->_join_table($table, $system, $where, $_order, $sql_from);
|
||||
if (!$rt['code']) {
|
||||
$return_data = $this->_return($system['return'], $rt['msg']);
|
||||
return;
|
||||
}
|
||||
list($system, $where, $_order, $sql_from) = $rt['data'];
|
||||
}
|
||||
|
||||
$sql_limit = $pages = '';
|
||||
$sql_where = $this->_get_where($where); // sql的where子句
|
||||
|
||||
// 商品有效期
|
||||
// isset($fields['order_etime']) && ($system['oot'] ? $sql_where.= ' AND `order_etime` BETWEEN 1 AND '.SYS_TIME : $sql_where.= ' AND NOT (`order_etime` BETWEEN 1 AND '.SYS_TIME.')');
|
||||
|
||||
// 推荐位调用
|
||||
if ($system['flag']) {
|
||||
if ($system['show_flag']) {
|
||||
$sql_from.= ' LEFT JOIN `'.$table.'_flag'.'` ON `'.$table.'`.`id`=`'.$table.'_flag`.`id`';
|
||||
$sql_where = ($sql_where ? $sql_where.' AND' : '').' `'.$table.'_flag`.'.(strpos($system['flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['flag']).')' : '`flag`='.(int)$system['flag']);
|
||||
} else {
|
||||
$flag = "select `id` from `{$table}_flag` where ".(strpos($system['flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['flag']).')' : '`flag`='.(int)$system['flag']);
|
||||
$sql_where = ($sql_where ? $sql_where.' AND' : '')." `$table`.`id` IN (".$flag.")";
|
||||
unset($flag);
|
||||
}
|
||||
}
|
||||
// 排除推荐位
|
||||
if ($system['not_flag']) {
|
||||
$flag = "select `id` from `{$table}_flag` where ".(strpos($system['not_flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['not_flag']).')' : '`flag`='.(int)$system['not_flag']);
|
||||
$sql_where = ($sql_where ? $sql_where.' AND' : '')." `$table`.`id` NOT IN (".$flag.")";
|
||||
unset($flag);
|
||||
}
|
||||
|
||||
// 统计标签
|
||||
if ($this->_return_sql) {
|
||||
$sql = "SELECT ".$this->_select_rt_name." FROM $sql_from ".($sql_where ? "WHERE $sql_where" : "")." ORDER BY NULL";
|
||||
} else {
|
||||
$first_url = $system['firsturl'];
|
||||
if ($system['page']) {
|
||||
$page = $this->_get_page_id($system['page']);
|
||||
if ($system['catid'] && is_numeric($system['catid'])) {
|
||||
if (!$system['sbpage']) {
|
||||
if ($system['pagesize']) {
|
||||
$this->_list_error[] = '存在catid参数和page参数时,pagesize参数将会无效';
|
||||
}
|
||||
if ($system['urlrule']) {
|
||||
$this->_list_error[] = '存在catid参数和page参数时,urlrule参数将会无效';
|
||||
}
|
||||
if ($this->_is_mobile) {
|
||||
$system['pagesize'] = (int)$module['category'][$system['catid']]['setting']['template']['mpagesize'];
|
||||
} else {
|
||||
$system['pagesize'] = (int)$module['category'][$system['catid']]['setting']['template']['pagesize'];
|
||||
}
|
||||
// 防止栏目生成第一页问题
|
||||
if ($system['action'] == 'module') {
|
||||
$first_url = \Phpcmf\Service::L('router')->category_url($module, $module['category'][$system['catid']]);
|
||||
if (!$this->_is_pc || SITE_ID > 1) {
|
||||
$first_url = dr_url_prefix($first_url, $module['dirname']);
|
||||
}
|
||||
}
|
||||
$system['urlrule'] = \Phpcmf\Service::L('router')->category_url($module, $module['category'][$system['catid']], '{page}');
|
||||
if (!$this->_is_pc || SITE_ID > 1) {
|
||||
$system['urlrule'] = dr_url_prefix($system['urlrule'], $module['dirname']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($system['num']) {
|
||||
$this->_list_error[] = '存在page参数时,num参数将会无效';
|
||||
}
|
||||
$pagesize = (int)$system['pagesize'];
|
||||
!$pagesize && $pagesize = 10;
|
||||
// 数据量
|
||||
$sql = "SELECT count(*) as c FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . " ORDER BY NULL";
|
||||
$row = $this->_query($sql, $system, FALSE);
|
||||
$total = (int)$row['c'];
|
||||
if ($system['maxlimit'] && $total > $system['maxlimit']) {
|
||||
$total = $system['maxlimit']; // 最大限制
|
||||
if ($page * $pagesize > $total) {
|
||||
$return_data = $this->_return($system['return'], 'maxlimit设置最大显示'.$system['maxlimit'].'条,当前('.$total.')已超出', $sql, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 没有数据时返回空
|
||||
if (!$total) {
|
||||
$return_data = $this->_return($system['return'], '没有查询到内容', $sql, 0);
|
||||
return;
|
||||
}
|
||||
$system['firsturl'] = $first_url;
|
||||
$pages = $this->_new_pagination($system, $pagesize, $total);
|
||||
$sql_limit = 'LIMIT ' . intval($pagesize * ($page - 1)) . ',' . $pagesize;
|
||||
} elseif ($system['num']) {
|
||||
$pages = '';
|
||||
$sql_limit = "LIMIT {$system['num']}";
|
||||
}
|
||||
|
||||
$system['order'] = $this->_set_orders_field_prefix($system['order'], $_order); // 给排序字段加上表前缀
|
||||
$sql = "SELECT " .$this->_get_select_field($system['field'] ? $system['field'] : '*') . " FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . ($system['order'] == "null" || !$system['order'] ? "" : " ORDER BY {$system['order']}") . " $sql_limit";
|
||||
}
|
||||
|
||||
$data = $this->_query($sql, $system);
|
||||
|
||||
// 缓存查询结果
|
||||
if (is_array($data) && $data) {
|
||||
// 模块表的系统字段
|
||||
$fields['inputtime'] = ['fieldtype' => 'Date'];
|
||||
$fields['updatetime'] = ['fieldtype' => 'Date'];
|
||||
// 格式化显示自定义字段内容
|
||||
$dfield = \Phpcmf\Service::L('Field')->app($module['dirname']);
|
||||
foreach ($data as $i => $t) {
|
||||
$t['url'] = dr_url_rel(dr_url_prefix($t['url'], $dirname, $system['site'], $this->_is_mobile));
|
||||
$data[$i] = $dfield->format_value($fields, $t, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 存储缓存
|
||||
$system['cache'] && $this->_save_cache_data($cache_name, [
|
||||
'data' => $data,
|
||||
'sql' => $sql,
|
||||
'total' => $total,
|
||||
'pages' => $pages,
|
||||
'pagesize' => $pagesize,
|
||||
'page_used' => $this->_page_used,
|
||||
'page_urlrule' => $this->_page_urlrule,
|
||||
], $system['cache']);
|
||||
|
||||
$return_data = $this->_return($system['return'], $data, $sql, $total, $pages, $pagesize);
|
||||
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
// 多模块合并查询
|
||||
|
||||
$modules = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-content');
|
||||
if (!$modules) {
|
||||
return $return_data = $this->_return($system['return'], '站点('.$system['site'].')没有安装内容模块');
|
||||
}
|
||||
|
||||
if ($system['module'] == 'all') {
|
||||
$system['module'] = '';
|
||||
foreach ($modules as $t) {
|
||||
$system['module'].= $t['dirname'].',';
|
||||
$module_all[] = $t['dirname'];
|
||||
}
|
||||
$system['module'] = trim($system['module'], ',');
|
||||
} else {
|
||||
$module_all = explode(',', $system['module']);
|
||||
if (dr_count($module_all) == 1) {
|
||||
$rt = require 'Module.php';
|
||||
return $rt;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_return_sql) {
|
||||
$system['field'].= ',id,'.$system['sum'];
|
||||
}
|
||||
|
||||
if (!$system['field']) {
|
||||
return $return_data = $this->_return($system['return'], '必须传入field参数来指定显示字段');
|
||||
}
|
||||
|
||||
if ($system['more']) {
|
||||
$this->_list_error[] = '多模块查询时more参数将会无效';
|
||||
}
|
||||
|
||||
if ($system['join']) {
|
||||
$this->_list_error[] = '多模块查询时join参数将会无效';
|
||||
}
|
||||
|
||||
$system['field'] = trim($system['field'], ',');
|
||||
$field = explode(',', $system['field']);
|
||||
|
||||
// 是否操作自定义where
|
||||
if ($param['where']) {
|
||||
$where[] = [
|
||||
'adj' => 'SQL',
|
||||
'value' => urldecode($param['where'])
|
||||
];
|
||||
unset($param['where']);
|
||||
}
|
||||
|
||||
$form = [];
|
||||
|
||||
// 验证模块的有效性
|
||||
foreach ($module_all as $m) {
|
||||
if (!isset($modules[$m])) {
|
||||
return $return_data = $this->_return($system['return'], '站点('.$system['site'].')没有安装内容模块('.$m.')');
|
||||
}
|
||||
$table = \Phpcmf\Service::M()->dbprefix($system['site'].'_'.$m);
|
||||
$mfield = \Phpcmf\Service::M()->db->getFieldNames($table);
|
||||
$infield = array_diff($field, $mfield);
|
||||
if ($infield) {
|
||||
return $return_data = $this->_return($system['return'], '站点('.$system['site'].')的内容模块('.$m.')不存在的字段:'.implode(',', $infield));
|
||||
}
|
||||
$mywhere = [
|
||||
// '`status` = 9',
|
||||
];
|
||||
// 推荐位调用
|
||||
if ($system['flag']) {
|
||||
$mywhere[] = "`$table`.`id` IN (".("select `id` from `{$table}_flag` where ".(strpos($system['flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['flag']).')' : '`flag`='.(int)$system['flag'])).")";
|
||||
}
|
||||
// 排除推荐位
|
||||
if ($system['not_flag']) {
|
||||
$mywhere[] = "`$table`.`id` NOT IN (".("select `id` from `{$table}_flag` where ".(strpos($system['not_flag'], ',') ? '`flag` IN ('.$this->_get_where_in($system['not_flag']).')' : '`flag`='.(int)$system['not_flag'])).")";
|
||||
}
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$m);
|
||||
$fields = $module['field'];
|
||||
// 栏目筛选
|
||||
if ($system['catid']) {
|
||||
$fwhere = [];
|
||||
if (strpos($system['catid'], ',') !== FALSE) {
|
||||
$temp = explode(',', $system['catid']);
|
||||
if ($temp) {
|
||||
$catids = [];
|
||||
foreach ($temp as $i) {
|
||||
$cat = dr_cat_value($system['site'], $module['mid'], $i);
|
||||
$catids = $cat['child'] ? array_merge($catids, $cat['catids']) : array_merge($catids, array($i));
|
||||
}
|
||||
$catids && $fwhere[] = '`'.$table.'`.`catid` IN ('.implode(',', $catids).')';
|
||||
}
|
||||
unset($temp);
|
||||
} else {
|
||||
$cat = dr_cat_value($system['site'], $module['mid'], $system['catid']);
|
||||
if ($cat['child']) {
|
||||
$catids = explode(',', $cat['childids']);
|
||||
$fwhere[] = '`'.$table.'`.`catid` IN ('.$cat['childids'].')';
|
||||
} else {
|
||||
$fwhere[] = '`'.$table.'`.`catid` = '.(int)$system['catid'];
|
||||
$catids = [$system['catid']];
|
||||
}
|
||||
}
|
||||
|
||||
// 副栏目判断
|
||||
if (isset($fields['catids']) && $fields['catids']['fieldtype'] = 'Catids') {
|
||||
foreach ($catids as $c) {
|
||||
$fwhere[] = \Phpcmf\Service::M()->where_json($table, 'catids', intval($c));
|
||||
}
|
||||
}
|
||||
if ($fwhere) {
|
||||
$mywhere[] = ''.(count($fwhere) == 1 ? $fwhere[0] : '('.implode(' OR ', $fwhere).')');
|
||||
}
|
||||
unset($fwhere);
|
||||
unset($catids);
|
||||
}
|
||||
if ($mywhere) {
|
||||
$form[] = 'SELECT '.$system['field'].',\''.$m.'\' AS mid FROM `'.$table.'` WHERE '.implode(' AND ', $mywhere);
|
||||
} else {
|
||||
$form[] = 'SELECT '.$system['field'].',\''.$m.'\' AS mid FROM `'.$table.'`';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql_limit = $pages = '';
|
||||
$where = $this->_set_where_field_prefix($where, $field, 'my', $fields); // 给条件字段加上表前缀
|
||||
$sql_where = $this->_get_where($where); // sql的where子句
|
||||
|
||||
|
||||
$sql_from = '('. implode(' UNION ALL ', $form).') as my';
|
||||
|
||||
// 统计标签
|
||||
if ($this->_return_sql) {
|
||||
$sql = "SELECT ".$this->_select_rt_name." FROM $sql_from ".($sql_where ? "WHERE $sql_where" : "")." ORDER BY NULL";
|
||||
} else {
|
||||
if ($system['page']) {
|
||||
$page = $this->_get_page_id($system['page']);
|
||||
$pagesize = (int)$system['pagesize'];
|
||||
!$pagesize && $pagesize = 10;
|
||||
// 统计数量
|
||||
$sql = "SELECT count(*) as c FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . " ORDER BY NULL";
|
||||
$row = $this->_query($sql, $system, FALSE);
|
||||
$total = (int)$row['c'];
|
||||
if ($system['maxlimit'] && $total > $system['maxlimit']) {
|
||||
$total = $system['maxlimit']; // 最大限制
|
||||
if ($page * $pagesize > $total) {
|
||||
$return_data = $this->_return($system['return'], 'maxlimit设置最大显示'.$system['maxlimit'].'条,当前('.$total.')已超出', $sql, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 没有数据时返回空
|
||||
if (!$total) {
|
||||
return $return_data = $this->_return($system['return'], '没有查询到内容', $sql, 0);
|
||||
}
|
||||
// 计算分页标签
|
||||
$pages = $this->_new_pagination($system, $pagesize, $total);
|
||||
$sql_limit = 'LIMIT ' . intval($pagesize * ($page - 1)) . ',' . $pagesize;
|
||||
} elseif ($system['num']) {
|
||||
$pages = '';
|
||||
$sql_limit = "LIMIT {$system['num']}";
|
||||
}
|
||||
|
||||
$system['order'] = $this->_set_order_field_prefix($system['order'], $field, 'my'); // 给排序字段加上表前缀
|
||||
$sql = "SELECT " .$system['field'] . ",mid FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . ($system['order'] == "null" || !$system['order'] ? "" : " ORDER BY {$system['order']}") . " $sql_limit";
|
||||
}
|
||||
|
||||
$data = $this->_query($sql, $system);
|
||||
|
||||
// 缓存查询结果
|
||||
if (is_array($data) && $data) {
|
||||
// 模块表的系统字段
|
||||
$fields['inputtime'] = ['fieldtype' => 'Date'];
|
||||
$fields['updatetime'] = ['fieldtype' => 'Date'];
|
||||
// 格式化显示自定义字段内容
|
||||
$dfield = \Phpcmf\Service::L('Field')->app($m);
|
||||
foreach ($data as $i => $t) {
|
||||
$t['url'] = dr_url_rel(dr_url_prefix($t['url'], $t['mid'], $system['site'], $this->_is_mobile));
|
||||
$data[$i] = $dfield->format_value($fields, $t, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 存储缓存
|
||||
$system['cache'] && $this->_save_cache_data($cache_name, [
|
||||
'data' => $data,
|
||||
'sql' => $sql,
|
||||
'total' => $total,
|
||||
'pages' => $pages,
|
||||
'pagesize' => $pagesize,
|
||||
'page_used' => $this->_page_used,
|
||||
'page_urlrule' => $this->_page_urlrule,
|
||||
], $system['cache']);
|
||||
|
||||
$return_data = $this->_return($system['return'], $data, $sql, $total, $pages, $pagesize);
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// 模块的相关文章
|
||||
|
||||
if (!$param['tag']) {
|
||||
$return_data = $this->_return($system['return'], '没有传入tag参数的内容'); // 没有查询到内容
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = [];
|
||||
$array = explode(',', urldecode($param['tag']));
|
||||
$tfield = 'keywords';
|
||||
if (isset($param['tfield']) && $param['tfield']) {
|
||||
$tfield = $param['tfield'];
|
||||
unset($param['tfield']);
|
||||
}
|
||||
foreach ($array as $name) {
|
||||
$name && $sql[] = '(`title` LIKE "%'.dr_safe_replace($name).'%" OR `'.$tfield.'` LIKE "%'.dr_safe_replace($name).'%")';
|
||||
}
|
||||
$sql && $where[] = [
|
||||
'adj' => 'SQL',
|
||||
'value' => '('.implode(' OR ', $sql).')'
|
||||
];
|
||||
unset($param['tag']);
|
||||
if (isset($where['tag'])) {
|
||||
unset($where['tag']);
|
||||
}
|
||||
if (method_exists($this, 'add_load_tips')) {
|
||||
$this->add_load_tips('', 'Related标签适用于一万条数据以内的小数据量关联查询');
|
||||
}
|
||||
// 跳转到module方法
|
||||
if (strpos($system['module'], ',') || $system['module'] == 'all') {
|
||||
if (!$system['field']) {
|
||||
$system['field'] = 'id,title,url,'.$tfield;
|
||||
} elseif (strpos($system['field'], $tfield) === false) {
|
||||
$system['field'] = trim($system['field'], ',');
|
||||
$system['field'].= ','.$tfield;
|
||||
}
|
||||
require 'Modules.php';
|
||||
} else {
|
||||
require 'Module.php';
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
// 模块的搜索
|
||||
|
||||
$this->_is_list_search = 1;
|
||||
|
||||
$total = (int)$system['total'];
|
||||
unset($system['total']);
|
||||
|
||||
// 没有数据时返回空
|
||||
if (!$total) {
|
||||
return $this->_return($system['return'], 'total参数为空', '', 0);
|
||||
} elseif (!$dirname) {
|
||||
return $this->_return($system['return'], 'module参数不能为空');
|
||||
} elseif (!$param['id']) {
|
||||
return $this->_return($system['return'], 'id参数为空', '', 0);
|
||||
}
|
||||
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
|
||||
if (!$module) {
|
||||
return $this->_return($system['return'], '模块('.$dirname.')未安装');
|
||||
}
|
||||
|
||||
$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
|
||||
// 没有表结构缓存时返回空
|
||||
if (!$tableinfo) {
|
||||
return $this->_return($system['return'], '表结构缓存不存在');
|
||||
}
|
||||
|
||||
$table = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module['dirname'], $system['site'])); // 模块主表`
|
||||
if (!isset($tableinfo[$table])) {
|
||||
return $this->_return($system['return'], '表('.$table.')结构缓存不存在');
|
||||
}
|
||||
|
||||
if ($where) {
|
||||
foreach ($where as $i => $t) {
|
||||
if ($t['name'] == 'id') {
|
||||
unset($where[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$index = \Phpcmf\Service::L('cache')->get_data('module-search-'.$dirname.'-'.$param['id']);
|
||||
if (!$index) {
|
||||
$index = $this->_query('SELECT `params` FROM `'.$table.'_search` WHERE `id`="'.$param['id'].'"', $system, 0);
|
||||
if ($index) {
|
||||
$p = dr_string2array($index['params']);
|
||||
$index['sql'] = $p['sql'];
|
||||
$index['where'] = $p['where'];
|
||||
} else {
|
||||
return $this->_return($system['return'], '没有搜索结果', '', 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($index['where']) && $index['where']) {
|
||||
$where[] = [
|
||||
'adj' => 'SQL',
|
||||
'value' => $index['where']
|
||||
];
|
||||
} elseif (isset($index['sql']) && $index['sql']) {
|
||||
$where[] = [
|
||||
'adj' => 'SQL',
|
||||
'value' => '(`'.$table.'`.`id` IN('.$index['sql'].'))'
|
||||
];
|
||||
} else {
|
||||
return $this->_return($system['return'], '没有查询到内容', $index['sql'], 0);
|
||||
}
|
||||
|
||||
unset($param['id']);
|
||||
|
||||
// 排序操作
|
||||
if (!$system['order'] && isset($where['id']) && $where['id']['adj'] == 'IN' && $where['id']['value']) {
|
||||
// 按id序列来排序
|
||||
$system['order'] = strlen($where['id']['value']) < 10000 && $where['id']['value'] ? 'FIELD(`'.$table.'`.`id`, '.$where['id']['value'].')' : 'NULL';
|
||||
} else {
|
||||
// 默认排序参数
|
||||
!$system['order'] && ($system['order'] = $system['flag'] ? 'updatetime_desc' : ($action == 'hits' ? 'hits' : 'updatetime'));
|
||||
}
|
||||
|
||||
$fields = $module['field']; // 主表的字段
|
||||
$_order = [$table => $tableinfo[$table]];
|
||||
$sql_from = '`'.$table.'`';
|
||||
$sql_where = $this->_get_where($where); // sql的where子句
|
||||
|
||||
// 关联栏目模型表
|
||||
if ($system['more'] && isset($module['category_data_field']) && $module['category_data_field']) {
|
||||
$fields = array_merge($fields, $module['category_data_field']);
|
||||
$table_more = $table.'_category_data'; // 栏目模型表
|
||||
$sql_from.= " LEFT JOIN $table_more ON `$table_more`.`id`=`$table`.`id`"; // sql的from子句
|
||||
$_order[$table_more] = $tableinfo[$table_more];
|
||||
if (!$system['field']) {
|
||||
$system['field'] = '`'.$table.'`.*';
|
||||
$fields_more = \Phpcmf\Service::M()->db->getFieldNames($table_more);
|
||||
if ($fields_more) {
|
||||
foreach ($fields_more as $f) {
|
||||
if (!in_array($f, ['id', 'catid', 'uid'])) {
|
||||
$system['field'].= ',`'.$table_more.'`.`'.$f.'`';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$system['order'] = $this->_set_orders_field_prefix($system['order'], $_order); // 给排序字段加上表前缀
|
||||
|
||||
// 分页处理
|
||||
$page = $this->_get_page_id($system['page']);
|
||||
$pagesize = (int)$system['pagesize'];
|
||||
!$pagesize && $pagesize = 10;
|
||||
if ($module['setting']['search']['max'] && $page * $pagesize > $module['setting']['search']['max']) {
|
||||
$return_data = $this->_return($system['return'], '搜索设置最大显示'.$module['setting']['search']['max'].'条,当前('.($page * $pagesize).')已超出', '', 0);
|
||||
return;
|
||||
}
|
||||
isset($index['params']) && $index['params'] && $system['firsturl'] = \Phpcmf\Service::L('Router')->search_url($index['params']);
|
||||
$pages = $this->_new_pagination($system, $pagesize, $total);
|
||||
$sql_limit = 'LIMIT ' . intval($pagesize * ($page - 1)) . ',' . $pagesize;
|
||||
|
||||
// 查询结果
|
||||
$sql = "SELECT " .$this->_get_select_field($system['field'] ? $system['field'] : '*') . " FROM $sql_from " . ($sql_where ? "WHERE $sql_where" : "") . ($system['order'] == "null" || !$system['order'] ? "" : " ORDER BY {$system['order']}") . " $sql_limit";
|
||||
$data = $this->_query($sql, $system);
|
||||
|
||||
// 缓存查询结果
|
||||
if (is_array($data) && $data) {
|
||||
// 模块表的系统字段
|
||||
$fields['inputtime'] = ['fieldtype' => 'Date'];
|
||||
$fields['updatetime'] = ['fieldtype' => 'Date'];
|
||||
// 格式化显示自定义字段内容
|
||||
$dfield = \Phpcmf\Service::L('Field')->app($module['dirname']);
|
||||
foreach ($data as $i => $t) {
|
||||
$t['url'] = dr_url_rel(dr_url_prefix($t['url'], $dirname, $system['site'], $this->_is_mobile));
|
||||
$data[$i] = $dfield->format_value($fields, $t, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// 存储缓存
|
||||
$system['cache'] && $this->_save_cache_data($cache_name, [
|
||||
'data' => $data,
|
||||
'sql' => $sql,
|
||||
'total' => $total,
|
||||
'pages' => $pages,
|
||||
'pagesize' => $pagesize,
|
||||
'page_used' => $this->_page_used,
|
||||
'page_urlrule' => $this->_page_urlrule,
|
||||
], $system['cache']);
|
||||
|
||||
return $this->_return($system['return'], $data, $sql, $total, $pages, $pagesize);
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'type' => 'app',
|
||||
'name' => '建站系统大众版',
|
||||
'author' => '迅睿云软件',
|
||||
'icon' => 'fa fa-th-large',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
// 自动加载识别文件
|
||||
|
||||
return [
|
||||
|
||||
/**
|
||||
* 命名空间映射关系
|
||||
*/
|
||||
'psr4' => [
|
||||
|
||||
|
||||
],
|
||||
|
||||
/**
|
||||
* 类名映射关系
|
||||
*/
|
||||
'classmap' => [
|
||||
|
||||
'Phpcmf\Member\Module' => IS_USE_MODULE.'Extends/Member/Module.php',
|
||||
|
||||
],
|
||||
|
||||
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
if (!method_exists(\Phpcmf\Service::M('table'), 'install_schema')) {
|
||||
return dr_return_data(0, '请先升级迅睿系统后再安装本插件');
|
||||
}
|
||||
|
||||
if (\Phpcmf\Service::M()->is_table_exists('module')) {
|
||||
// 表示模块表已经操作,手动安装模块
|
||||
$rs = file_put_contents(dr_get_app_dir('module').'/install.lock', 'fix');
|
||||
if (!$rs) {
|
||||
return dr_return_data(0, '目录('.dr_get_app_dir('module').')无法写入');
|
||||
}
|
||||
return dr_return_data(0, '【建站系统】插件已被安装');
|
||||
}
|
||||
|
||||
return dr_return_data(1, 'ok');
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
$add = [];
|
||||
$module_more = $module = $cname = [];
|
||||
$cname[] = '更新模块域名目录';
|
||||
if (dr_is_app('module')) {
|
||||
$add['module1'] = ['手动重建内容搜索索引', 'update_search_index'];
|
||||
$cname[] = '更新模块域名目录';
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
|
||||
if ($module) {
|
||||
$module = dr_array_sort($module, 'share', 'asc');
|
||||
$limit = 10;
|
||||
if (is_array($module) && dr_count($module) > $limit) {
|
||||
$module_more = array_slice($module, $limit);
|
||||
$module = array_slice($module, 0, $limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (dr_is_app('sites')) {
|
||||
$cname[] = '更新子站目录';
|
||||
}
|
||||
if (dr_is_app('client')) {
|
||||
$cname[] = '更新终端目录';
|
||||
}
|
||||
if ($cname) {
|
||||
$add['module2'] = [implode('、', $cname), 'update_site_config'];
|
||||
}
|
||||
?>
|
||||
{loop $add $id $t}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="badge badge-success"> {$key} </span>
|
||||
</td>
|
||||
<td>
|
||||
{dr_lang($t[0])}
|
||||
</td>
|
||||
<td style="overflow:auto">
|
||||
<label>
|
||||
<a href="javascript:my_update_cache('{$id}', '{$t[1]}');" class="btn red btn-xs"><i class="fa fa-refresh"></i> {dr_lang('立即执行')} </a>
|
||||
</label>
|
||||
<label id="dr_{$id}_result" >
|
||||
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{php $key=$key+1;}
|
||||
{/loop}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="badge badge-success">{$key++}</span>
|
||||
</td>
|
||||
<td>
|
||||
{dr_lang('新增或变更栏目后,需要更新栏目缓存数据')}
|
||||
</td>
|
||||
<td style="overflow:auto">
|
||||
<label>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang('更新共享栏目')}', '{dr_url('module/api/update_category_repair')}&all=1&mid=share', '500px', '300px');" class="btn blue btn-xs"><i class="fa fa-cog"></i> {dr_lang('共享栏目')} </a>
|
||||
</label>
|
||||
{loop $module $c}
|
||||
{if !$c.share}
|
||||
<label>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('module/api/update_category_repair')}&all=1&mid={$c.dirname}', '500px', '300px');" class="btn blue btn-xs"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</label>
|
||||
{/if}
|
||||
{/loop}
|
||||
{if $module_more}
|
||||
<div class="btn-group" style="margin-top:0; margin-left: 10px">
|
||||
<button type="button" class="btn btn-xs btn-default ">{dr_lang('更多')}</button>
|
||||
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
{loop $module_more $c}
|
||||
{if !$c.share}
|
||||
<li>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('module/api/update_category_repair')}&all=1&mid={$c.dirname}', '500px', '300px');"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</li>
|
||||
{/if}
|
||||
{/loop}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="badge badge-success">{$key++}</span>
|
||||
</td>
|
||||
<td>
|
||||
{dr_lang('内容地址与设置地址不同步时,更新内容URL地址')}
|
||||
</td>
|
||||
<td style="overflow:auto">
|
||||
{loop $module $c}
|
||||
<label>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('api/update_url')}&mid={$c.dirname}', '500px', '300px');" class="btn blue btn-xs"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</label>
|
||||
{/loop}
|
||||
{if $module_more}
|
||||
<div class="btn-group" style="margin-top:0; margin-left: 10px">
|
||||
<button type="button" class="btn btn-xs btn-default ">{dr_lang('更多')}</button>
|
||||
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
{loop $module_more $c}
|
||||
<li>
|
||||
<a href="javascript:dr_iframe_show('{dr_lang($c.name)}', '{dr_url('api/update_url')}&mid={$c.dirname}', '500px', '300px');"><i class="{dr_icon($c.icon)}"></i> {dr_lang($c.name)} </a>
|
||||
</li>
|
||||
{/loop}
|
||||
</ul>
|
||||
</div>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 缓存参数配置
|
||||
*
|
||||
* 模型名称 => 项目目录
|
||||
*
|
||||
**/
|
||||
|
||||
return [
|
||||
|
||||
|
||||
];
|
||||
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/**
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件
|
||||
**/
|
||||
|
||||
/**
|
||||
* 模块内容表结构及字段
|
||||
* table:规范化 Schema(fields / indexes / comment);亦兼容 Dever 导出的 CREATE SQL 字符串
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'table' => [
|
||||
|
||||
1 => [
|
||||
'comment' => '内容主表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'catid' => 'smallint(5) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'title' => 'varchar(255) DEFAULT NULL COMMENT \'主题\'',
|
||||
'thumb' => 'varchar(255) DEFAULT NULL COMMENT \'缩略图\'',
|
||||
'keywords' => 'varchar(255) DEFAULT NULL COMMENT \'关键字\'',
|
||||
'description' => 'text COMMENT \'描述\'',
|
||||
'hits' => 'int(10) unsigned DEFAULT NULL COMMENT \'浏览数\'',
|
||||
'uid' => 'int(10) unsigned NOT NULL COMMENT \'作者id\'',
|
||||
'author' => 'varchar(50) NOT NULL COMMENT \'笔名\'',
|
||||
'status' => 'tinyint(2) NOT NULL COMMENT \'状态(已废弃)\'',
|
||||
'url' => 'varchar(255) DEFAULT NULL COMMENT \'地址\'',
|
||||
'link_id' => 'int(10) DEFAULT NULL DEFAULT \'0\' COMMENT \'同步id\'',
|
||||
'tableid' => 'smallint(5) unsigned NOT NULL COMMENT \'附表id\'',
|
||||
'inputip' => 'varchar(200) DEFAULT NULL COMMENT \'录入者ip\'',
|
||||
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'录入时间\'',
|
||||
'updatetime' => 'int(10) unsigned NOT NULL COMMENT \'更新时间\'',
|
||||
'displayorder' => 'int(10) DEFAULT \'0\' COMMENT \'排序值\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
'KEY `link_id` (`link_id`)',
|
||||
'KEY `status` (`status`)',
|
||||
'KEY `updatetime` (`updatetime`)',
|
||||
'KEY `hits` (`hits`)',
|
||||
'KEY `category` (`catid`, `status`)',
|
||||
'KEY `displayorder` (`displayorder`)',
|
||||
],
|
||||
],
|
||||
|
||||
0 => [
|
||||
'comment' => '内容附表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'catid' => 'smallint(5) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'content' => 'mediumtext COMMENT \'内容\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'UNIQUE KEY `id` (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
'field' => [
|
||||
|
||||
1 => array (
|
||||
0 =>
|
||||
array (
|
||||
'fieldname' => 'title',
|
||||
'fieldtype' => 'Text',
|
||||
'relatedname' => 'module',
|
||||
'isedit' => '1',
|
||||
'ismain' => '1',
|
||||
'issystem' => '1',
|
||||
'ismember' => '1',
|
||||
'issearch' => '1',
|
||||
'disabled' => '0',
|
||||
'setting' =>
|
||||
array (
|
||||
'option' =>
|
||||
array (
|
||||
'width' => 400,
|
||||
'fieldtype' => 'VARCHAR',
|
||||
'fieldlength' => '255',
|
||||
),
|
||||
'validate' =>
|
||||
array (
|
||||
'xss' => 1,
|
||||
'required' => 1,
|
||||
'formattr' => 'onblur="check_title();get_keywords(\'keywords\');"',
|
||||
),
|
||||
),
|
||||
'displayorder' => '0',
|
||||
'textname' => dr_lang('标题'),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'fieldname' => 'thumb',
|
||||
'fieldtype' => 'File',
|
||||
'relatedid' => '28',
|
||||
'relatedname' => 'module',
|
||||
'isedit' => '1',
|
||||
'ismain' => '1',
|
||||
'issystem' => 1,
|
||||
'ismember' => '1',
|
||||
'issearch' => '1',
|
||||
'disabled' => '0',
|
||||
'setting' =>
|
||||
array (
|
||||
'option' =>
|
||||
array (
|
||||
'ext' => 'jpg,gif,png',
|
||||
'size' => 10,
|
||||
'width' => 400,
|
||||
'fieldtype' => 'VARCHAR',
|
||||
'fieldlength' => '255',
|
||||
),
|
||||
),
|
||||
'displayorder' => '0',
|
||||
'textname' => dr_lang('缩略图'),
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'fieldname' => 'keywords',
|
||||
'fieldtype' => 'Text',
|
||||
'relatedid' => '28',
|
||||
'relatedname' => 'module',
|
||||
'isedit' => '1',
|
||||
'ismain' => '1',
|
||||
'issystem' => 1,
|
||||
'ismember' => '1',
|
||||
'issearch' => '1',
|
||||
'disabled' => '0',
|
||||
'setting' =>
|
||||
array (
|
||||
'option' =>
|
||||
array (
|
||||
'width' => 400,
|
||||
'fieldtype' => 'VARCHAR',
|
||||
'fieldlength' => '255',
|
||||
),
|
||||
'validate' =>
|
||||
array (
|
||||
'xss' => 1,
|
||||
'formattr' => ' data-role="tagsinput"', // tag属性
|
||||
),
|
||||
),
|
||||
'displayorder' => '0',
|
||||
'textname' => dr_lang('关键字'),
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'fieldname' => 'description',
|
||||
'fieldtype' => 'Textarea',
|
||||
'relatedid' => '28',
|
||||
'relatedname' => 'module',
|
||||
'isedit' => '1',
|
||||
'ismain' => '1',
|
||||
'issystem' => 1,
|
||||
'ismember' => '1',
|
||||
'issearch' => '1',
|
||||
'disabled' => '0',
|
||||
'setting' =>
|
||||
array (
|
||||
'option' =>
|
||||
array (
|
||||
'width' => 500,
|
||||
'height' => 60,
|
||||
'fieldtype' => 'VARCHAR',
|
||||
'fieldlength' => '255',
|
||||
),
|
||||
'validate' =>
|
||||
array (
|
||||
'xss' => 1,
|
||||
'filter' => 'dr_filter_description',
|
||||
),
|
||||
),
|
||||
'displayorder' => '0',
|
||||
'textname' => dr_lang('描述'),
|
||||
),
|
||||
4 =>
|
||||
array (
|
||||
'fieldname' => 'author',
|
||||
'fieldtype' => 'Text',
|
||||
'relatedname' => 'module',
|
||||
'isedit' => '1',
|
||||
'ismain' => '1',
|
||||
'issystem' => 1,
|
||||
'ismember' => '1',
|
||||
'issearch' => '1',
|
||||
'disabled' => '0',
|
||||
'setting' =>
|
||||
array (
|
||||
'is_right' => 1,
|
||||
'option' =>
|
||||
array (
|
||||
'width' => 200,
|
||||
'fieldtype' => 'VARCHAR',
|
||||
'fieldlength' => '255',
|
||||
'value' => '{name}'
|
||||
),
|
||||
'validate' =>
|
||||
array (
|
||||
'xss' => 1,
|
||||
),
|
||||
),
|
||||
'displayorder' => '0',
|
||||
'textname' => dr_lang('笔名'),
|
||||
),
|
||||
),
|
||||
|
||||
0 => array (
|
||||
0 =>
|
||||
array (
|
||||
'fieldname' => 'content',
|
||||
'fieldtype' => 'Editor',
|
||||
'relatedname' => 'module',
|
||||
'isedit' => '1',
|
||||
'ismain' => '0',
|
||||
'issystem' => 1,
|
||||
'ismember' => '1',
|
||||
'issearch' => '1',
|
||||
'disabled' => '0',
|
||||
'setting' =>
|
||||
array (
|
||||
'option' =>
|
||||
array (
|
||||
'mode' => 1,
|
||||
'show_bottom_boot' => 1,
|
||||
'div2p' => 1,
|
||||
'width' => '100%',
|
||||
'height' => 400,
|
||||
),
|
||||
'validate' =>
|
||||
array (
|
||||
'xss' => 1,
|
||||
'required' => 1,
|
||||
),
|
||||
),
|
||||
'displayorder' => '0',
|
||||
'textname' => dr_lang('内容'),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
$code = file_get_contents(CMSPATH.'Control/Api/Run.php');
|
||||
if ($code && strpos($code, 'post_time')) {
|
||||
return; // 老程序不执行
|
||||
}
|
||||
|
||||
// 批量执行站点动作
|
||||
foreach ($this->site_info as $siteid => $site) {
|
||||
// 模块
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-content');
|
||||
if ($module) {
|
||||
foreach ($module as $dir => $mod) {
|
||||
// 删除模块首页
|
||||
if ($mod['is_index_html']) {
|
||||
if ($mod['domain']) {
|
||||
// 绑定域名时
|
||||
$file = 'index.html';
|
||||
} else {
|
||||
$file = ltrim(\Phpcmf\Service::L('Router')->remove_domain($mod['url']), '/'); // 从地址中获取要生成的文件名;
|
||||
}
|
||||
if ($file) {
|
||||
unlink(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath($siteid, $dir, $file) : WEBPATH.$file);
|
||||
unlink(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath($siteid, $dir, 'mobile/'.$file) : WEBPATH.'mobile/'.$file);
|
||||
}
|
||||
}
|
||||
// 定时发布动作
|
||||
$times = \Phpcmf\Service::M()->table($siteid.'_'.$dir.'_time')->where('posttime > 0 and posttime < '.SYS_TIME)->getAll(1);
|
||||
if ($times) {
|
||||
$lockFile = WRITEPATH."config/module_cron_".$siteid.$dir.".lock";
|
||||
if (file_exists($lockFile)) {
|
||||
$ctime = intval(filectime($lockFile));
|
||||
if (SYS_TIME - $ctime > 1000) {
|
||||
unlink($lockFile);
|
||||
} else {
|
||||
CI_DEBUG && log_message('debug', '定时发布文件锁定:'.date("Y-m-d H:i:s", $ctime));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$fp = fopen($lockFile, 'w');
|
||||
if ($fp) {
|
||||
// 获取锁成功,执行你的代码
|
||||
chmod($lockFile, 0666); // 确保文件有足够权限
|
||||
$this->_module_init($dir, $siteid, 1);
|
||||
\Phpcmf\Service::C()->module = $this->module;
|
||||
\Phpcmf\Service::C()->content_model->siteid = $siteid;
|
||||
\Phpcmf\Service::C()->content_model->_init($dir, $siteid);
|
||||
foreach ($times as $t) {
|
||||
$rt = $this->content_model->post_time($t);
|
||||
if (!$rt['code']) {
|
||||
echo '模块【'.$dir.'】定时发布('.$t['id'].')失败'.PHP_EOL;
|
||||
CI_DEBUG && log_message('error', '模块【'.$dir.'】定时发布('.$t['id'].')失败:'.$rt['msg']);
|
||||
} else {
|
||||
\Phpcmf\Service::M()->table($siteid.'_'.$dir.'_time')->update($t['id'], [
|
||||
'posttime' => 0,
|
||||
]);
|
||||
echo '模块【'.$dir.'】定时发布('.$rt['code'].')成功'.PHP_EOL;
|
||||
}
|
||||
sleep(10);
|
||||
}
|
||||
// 执行完毕后释放锁
|
||||
fclose($fp);
|
||||
unlink($lockFile);
|
||||
break;
|
||||
} else {
|
||||
CI_DEBUG && log_message('debug', '定时发布文件上锁成功:'.date("Y-m-d H:i:s"));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* CSRF过滤白名单
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'home' => [
|
||||
'cms/api/related',
|
||||
'cms/api/related',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,948 @@
|
||||
<?php
|
||||
|
||||
\Phpcmf\Hooks::on('index_page', function() {
|
||||
if (is_file(COREPATH.'Control/Html.php')) {
|
||||
require COREPATH.'Control/Html.php';
|
||||
$ci = \Phpcmf\Service::C();
|
||||
// 跳过构造函数:避免 IS_COMMON 下重复初始化,且不覆盖 Common 单例
|
||||
$ref = new \ReflectionClass(\Phpcmf\Control\Html::class);
|
||||
$c = $ref->newInstanceWithoutConstructor();
|
||||
// 同步当前控制器的 public 属性(site_info、member 等)
|
||||
foreach (get_object_vars($ci) as $key => $value) {
|
||||
$c->$key = $value;
|
||||
}
|
||||
if (method_exists($c, 'index')) {
|
||||
$c->index();
|
||||
return dr_return_data(1, 'ok');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
/**
|
||||
* 模块首页地址
|
||||
* $dir 模块目录
|
||||
*/
|
||||
function dr_module_url($dir) {
|
||||
|
||||
if (defined('MOD_DIR') && $dir == MOD_DIR) {
|
||||
return MODULE_URL;
|
||||
}
|
||||
|
||||
return \Phpcmf\Service::L('cache')->get('module-'.dr_module_siteid().'-'.$dir, 'url');
|
||||
}
|
||||
|
||||
function dr_module_category_data_field($cat, $field, $module) {
|
||||
if (!$cat['ismain']) {
|
||||
// 非主栏目继承上级
|
||||
$cat = dr_cat_value(
|
||||
$module['mid'],
|
||||
\Phpcmf\Service::L('category', 'module')->get_ismain_id($module['mid'], $cat)
|
||||
);
|
||||
}
|
||||
if ($cat) {
|
||||
if (isset($module['setting']['module_category_hide']) && $module['setting']['module_category_hide']) {
|
||||
if ($module['category_data_field']) {
|
||||
foreach ($module['category_data_field'] as $f => $v) {
|
||||
if (!dr_in_array($f, $cat['field'])) {
|
||||
$field[$f] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($cat['field']) {
|
||||
foreach ($cat['field'] as $f) {
|
||||
if ($module['category_data_field'][$f]) {
|
||||
$field[$f] = $module['category_data_field'][$f];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $field;
|
||||
}
|
||||
function dr_module_param($mid, $name) {
|
||||
|
||||
if (!$mid) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return \Phpcmf\Service::L('cache')->get('module-'.dr_module_siteid().'-'.$mid, 'setting', 'param', $name);
|
||||
}
|
||||
// 获取所属站点id
|
||||
function dr_module_siteid() {
|
||||
if (isset(XR_C()->content_model->siteid) && (XR_C()->content_model->siteid)) {
|
||||
return XR_C()->content_model->siteid;
|
||||
}
|
||||
return SITE_ID;
|
||||
}
|
||||
|
||||
if (!function_exists('dr_is_double_search')) {
|
||||
// 判断搜索值是否是多重选择时的选中状态 1选中 0不选
|
||||
function dr_is_double_search($param, $value) {
|
||||
|
||||
if (!$param) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$arr = explode('|', $param);
|
||||
if (in_array($value, $arr)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dr_get_double_search')) {
|
||||
// 获取多重选择是的参数值
|
||||
function dr_get_double_search($param, $value) {
|
||||
|
||||
if (!$param) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$arr = explode('|', $param);
|
||||
if (in_array($value, $arr)) {
|
||||
// 如果存在,那么久移除他
|
||||
$arr = array_merge(array_diff($arr, array($value)));
|
||||
} else {
|
||||
// 没有就加上
|
||||
$arr[] = $value;
|
||||
}
|
||||
|
||||
return $arr ? @implode('|', $arr) : '';
|
||||
}
|
||||
}
|
||||
|
||||
// 获取内容的tags
|
||||
function dr_get_content_tags($value) {
|
||||
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
} elseif (!$value) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rt = [];
|
||||
$tag = explode(',', $value);
|
||||
foreach ($tag as $t) {
|
||||
$t = trim($t);
|
||||
if ($t) {
|
||||
// 读缓存
|
||||
if (dr_is_app('tag')) {
|
||||
$obj = \Phpcmf\Service::M('tag', 'tag');
|
||||
if (method_exists($obj, 'get_tag_url')) {
|
||||
$url = $obj->get_tag_url($t);
|
||||
if ($url) {
|
||||
$rt[$t] = $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rt;
|
||||
}
|
||||
|
||||
// 获取内容的搜索词
|
||||
function dr_get_content_kws($value, $mid = '') {
|
||||
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
} elseif (!$value) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rt = [];
|
||||
$mid = $mid ? $mid : (defined('MOD_DIR') ? MOD_DIR : '');
|
||||
$tag = explode(',', $value);
|
||||
foreach ($tag as $t) {
|
||||
$t = trim($t);
|
||||
if ($t) {
|
||||
$rt[$t] = \Phpcmf\Service::L('router')->search_url([], 'keyword', $t, $mid);
|
||||
}
|
||||
}
|
||||
|
||||
return $rt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 内容文章显示内链
|
||||
*/
|
||||
function dr_content_link($tags, $content, $num = 0, $blank = 1) {
|
||||
|
||||
if (!$tags || !$content) {
|
||||
return $content;
|
||||
} elseif (!is_array($tags)) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
foreach ($tags as $name => $url) {
|
||||
if ($name && $url) {
|
||||
$content = @preg_replace(
|
||||
'\'(?!((<.*?)|(<a.*?)|(<strong.*?)))('.str_replace(["'", '-'], ["\'", '\-'], preg_quote($name)).')(?!(([^<>]*?)>)|([^>]*?</a>)|([^>]*?</strong>))\'si',
|
||||
'<a title="'.$name.'" href="'.$url.'"'.($blank ? ' target="_blank"' : '').'>'.$name.'</a>',
|
||||
$content,
|
||||
$num ? $num : -1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
// 内容加内链
|
||||
function dr_neilian($content, $blank = 1, $num = 0) {
|
||||
|
||||
if (!$content) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (dr_is_app('tag')) {
|
||||
$obj = \Phpcmf\Service::M('tag', 'tag');
|
||||
if (method_exists($obj, 'neilian')) {
|
||||
return $obj->neilian($content, $blank, $num);
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
// 获取模块数据及自定义字段
|
||||
function dr_mod_value(...$get) {
|
||||
|
||||
if (empty($get)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_numeric($get[0]) && defined('MOD_DIR') && MOD_DIR) {
|
||||
// 值是栏目id时,表示当前模块
|
||||
$name = 'module-'.dr_module_siteid().'-'.MOD_DIR;
|
||||
} else {
|
||||
// 指定模块
|
||||
$name = strpos($get[0], '-') ? 'module-'.$get[0] : 'module-'.dr_module_siteid().'-'.$get[0];
|
||||
unset($get[0]);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$param = [];
|
||||
foreach ($get as $t) {
|
||||
if ($i == 0) {
|
||||
$param[] = $name;
|
||||
}
|
||||
$param[] = $t;
|
||||
$i = 1;
|
||||
}
|
||||
|
||||
return call_user_func_array([\Phpcmf\Service::C(), 'get_cache'], $param);
|
||||
}
|
||||
|
||||
|
||||
// 获取栏目数据及自定义字段
|
||||
function dr_page_value($id, $field, $site = SITE_ID) {
|
||||
|
||||
if (empty($id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return \Phpcmf\Service::C()->get_cache('page-'.$site, 'data', $id, $field);
|
||||
}
|
||||
|
||||
// 获取栏目数据及自定义字段
|
||||
function dr_cat_value(...$get) {
|
||||
|
||||
if (empty($get)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$mid = '';
|
||||
if (is_numeric($get[0])) {
|
||||
// 值是栏目id时,表示当前模块
|
||||
if (defined('MOD_DIR') && MOD_DIR) {
|
||||
$mid = MOD_DIR;
|
||||
$name = 'module-'.dr_module_siteid().'-'.MOD_DIR;
|
||||
} else {
|
||||
$name = 'module-'.dr_module_siteid().'-share';
|
||||
}
|
||||
} else {
|
||||
// 指定模块
|
||||
$mid = $get[0] ? $get[0] : 'share';
|
||||
$name = strpos($mid, '-') ? 'module-'.$mid : 'module-'.dr_module_siteid().'-'.$mid;
|
||||
unset($get[0]);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$param = [];
|
||||
foreach ($get as $t) {
|
||||
if ($i == 0) {
|
||||
$param[] = $name;
|
||||
$param[] = 'category';
|
||||
}
|
||||
$param[] = $t;
|
||||
$i = 1;
|
||||
}
|
||||
|
||||
$rt = call_user_func_array([\Phpcmf\Service::C(), 'get_cache'], $param);
|
||||
if (end($param) == 'url' && $rt) {
|
||||
$rt = dr_url_rel(dr_url_prefix($rt, $mid));
|
||||
}
|
||||
|
||||
return $rt;
|
||||
}
|
||||
|
||||
// 获取共享栏目数据及自定义字段
|
||||
function dr_share_cat_value($id, $field='') {
|
||||
|
||||
$get = func_get_args();
|
||||
if (empty($get)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$param = [];
|
||||
foreach ($get as $t) {
|
||||
if ($i == 0) {
|
||||
$param[] = 'module-'.dr_module_siteid().'-share';
|
||||
$param[] = 'category';
|
||||
}
|
||||
$param[] = $t;
|
||||
$i = 1;
|
||||
}
|
||||
|
||||
$rt = call_user_func_array(array(\Phpcmf\Service::C(), 'get_cache'), $param);
|
||||
|
||||
return $field == 'url' && $rt ? dr_url_rel(dr_url_prefix($rt)) : $rt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模块栏目面包屑导航
|
||||
*
|
||||
* @param intval $catid 栏目id
|
||||
* @param string $symbol 面包屑间隔符号
|
||||
* @param string $url 是否显示URL
|
||||
* @param string $html 格式替换
|
||||
* @return string
|
||||
*/
|
||||
function dr_catpos($catid, $symbol = ' > ', $url = true, $html= '', $dirname = 'MOD_DIR', $url_call_func = '') {
|
||||
|
||||
if (!$catid) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$mid = $dirname == 'MOD_DIR' && defined('MOD_DIR') && MOD_DIR ? MOD_DIR : (!$dirname || $dirname == 'MOD_DIR' ? 'share' : $dirname);
|
||||
$cat = \Phpcmf\Service::L('cache')->get('module-'.dr_module_siteid().'-'.$mid, 'category');
|
||||
if (!isset($cat[$catid])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$name = [];
|
||||
$array = explode(',', $cat[$catid]['pids']);
|
||||
$array[] = $catid;
|
||||
foreach ($array as $id) {
|
||||
if ($id && $cat[$id]) {
|
||||
if ($url_call_func && function_exists($url_call_func)) {
|
||||
$murl = $url_call_func($cat[$id]);
|
||||
} else {
|
||||
$murl = dr_url_rel(dr_url_prefix($cat[$id]['url'], $mid));
|
||||
//$murl = dr_url_prefix($cat[$id]['url'], MOD_DIR, dr_module_siteid(), \Phpcmf\Service::IS_MOBILE_TPL())
|
||||
}
|
||||
$name[] = $url ? ($html ? str_replace(['[url]', '[name]'], [$murl, $cat[$id]['name']], $html): "<a href=\"{$murl}\">{$cat[$id]['name']}</a>") : $cat[$id]['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return implode($symbol, array_unique($name));
|
||||
}
|
||||
|
||||
|
||||
// 打赏支付
|
||||
function dr_donation($id, $title = '', $dir = '', $remove_div = 1) {
|
||||
if (!dr_is_app('pay')) {
|
||||
return '没有安装「支付系统」插件';
|
||||
}
|
||||
!$dir && $dir = defined('MOD_DIR') ? MOD_DIR : 'share';
|
||||
return \Phpcmf\Service::M('Pay', 'pay')->payform('my-shang_buy-'.$id.'_'.$dir.'-'.dr_module_siteid(), 0, $title, '', $remove_div);
|
||||
}
|
||||
|
||||
// 是否存在收藏夹中 1收藏了 2没有收藏
|
||||
function dr_is_favorite($dir, $id, $uid = 0) {
|
||||
|
||||
!$uid && $uid = \Phpcmf\Service::C()->uid;
|
||||
|
||||
if (!$uid) {
|
||||
return 0;
|
||||
} elseif (!$dir) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return \Phpcmf\Service::M()->db->table(dr_module_table_prefix($dir).'_favorite')->where('uid', $uid)->where('cid', $id)->countAllResults();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模块内容阅读量显示js
|
||||
*
|
||||
* @param intval $id
|
||||
* @return string
|
||||
*/
|
||||
if (!function_exists('dr_show_hits')) {
|
||||
function dr_show_hits($id, $dom = "", $dir = 'MOD_DIR') {
|
||||
$is = $dom;
|
||||
!$dom && $dom = "dr_show_hits_{$id}";
|
||||
$html = $is ? "" : "<span class=\"{$dom}\">0</span>";
|
||||
if (defined('MODULE_MYSHOW')) {
|
||||
return $html;
|
||||
}
|
||||
$dir = $dir == 'MOD_DIR' && defined('MOD_DIR') && MOD_DIR ? MOD_DIR : $dir;
|
||||
$rt = "$(\".{$dom}\").html(data.msg);";
|
||||
if ($is) {
|
||||
$rt.= "$(\"#{$dom}\").html(data.msg);";
|
||||
}
|
||||
return $html."<script type=\"text/javascript\">var apiurl=\"".dr_web_prefix("index.php?s=api&c=module&siteid=".dr_module_siteid()."&app=".$dir)."\"; $.ajax({ type: \"GET\", url:apiurl+\"&m=hits&id={$id}\", dataType: \"jsonp\", success: function(data){ if (data.code) { ".$rt." } else { dr_tips(0, data.msg); } } }); </script>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 栏目下级或者同级栏目
|
||||
* $data 整个栏目数组
|
||||
* $catid 当前栏目id
|
||||
*/
|
||||
function dr_related_cat($data, $catid) {
|
||||
|
||||
if (!$data) {
|
||||
return [[], []];
|
||||
}
|
||||
|
||||
$my = $data[$catid];
|
||||
$related = $parent = [];
|
||||
|
||||
if ($my['child']) {
|
||||
// 当存在子栏目时就显示下级子栏目
|
||||
$parent = $my['pid'] ? $data[$my['pid']] : $my;
|
||||
foreach ($data as $t) {
|
||||
if (!$t['show']) {
|
||||
continue;
|
||||
}
|
||||
if ($t['pid'] == $my['id']) {
|
||||
$t['url'] = dr_url_prefix($t['url'], defined('MOD_DIR') ? MOD_DIR : '');
|
||||
$related[$t['id']] = $t;
|
||||
}
|
||||
}
|
||||
} elseif ($my['pid']) {
|
||||
// 当属于子栏目时就显示同级别栏目
|
||||
foreach ($data as $t) {
|
||||
if (!$t['show']) {
|
||||
continue;
|
||||
}
|
||||
if ($t['pid'] == $my['pid']) {
|
||||
$t['url'] = dr_url_prefix($t['url'], defined('MOD_DIR') ? MOD_DIR : '');
|
||||
$related[$t['id']] = $t;
|
||||
$parent = $data[$t['pid']];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 显示顶级栏目
|
||||
if (!$data) {
|
||||
return [[], []];
|
||||
}
|
||||
$parent = $my;
|
||||
foreach ($data as $t) {
|
||||
if (!$t['show']) {
|
||||
continue;
|
||||
}
|
||||
if ($t['pid'] == 0) {
|
||||
$t['url'] = dr_url_prefix($t['url'], defined('MOD_DIR') ? MOD_DIR : '');
|
||||
$related[$t['id']] = $t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$parent && $parent['url'] = dr_url_prefix($parent['url'], defined('MOD_DIR') ? MOD_DIR : '');
|
||||
|
||||
return [$parent, $related];
|
||||
}
|
||||
|
||||
/**
|
||||
* 模块栏目层次关系
|
||||
*
|
||||
* @param array $mod
|
||||
* @param array $cat
|
||||
* @param string $symbol
|
||||
*/
|
||||
function dr_get_cat_pname($mod, $catid, $symbol = '_') {
|
||||
|
||||
$cat = $mod['category'][$catid];
|
||||
|
||||
if (!$cat['pids']) {
|
||||
return $cat['name'];
|
||||
}
|
||||
|
||||
$name = [];
|
||||
$array = explode(',', $cat['pids']);
|
||||
|
||||
foreach ($array as $id) {
|
||||
if ($id && $mod['category'][$id]) {
|
||||
$name[] = $mod['category'][$id]['name'];
|
||||
}
|
||||
}
|
||||
|
||||
$name[] = $cat['name'];
|
||||
|
||||
$name = array_unique($name);
|
||||
|
||||
krsort($name);
|
||||
|
||||
return implode($symbol, $name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* url转为相对路径
|
||||
*/
|
||||
if (!function_exists('dr_url_rel')) {
|
||||
|
||||
/**
|
||||
* url转为相对路径
|
||||
*/
|
||||
function dr_url_rel($url, $prefix = '') {
|
||||
|
||||
if ((IS_API_HTTP && (!defined('SYS_API_REL') || !SYS_API_REL)) || IS_ADMIN) {
|
||||
return $url;
|
||||
} elseif (defined('SYS_URL_REL') && SYS_URL_REL) {
|
||||
$surl = FC_NOW_HOST;
|
||||
if (defined('SC_HTML_FILE') && SITE_IS_MOBILE_HTML
|
||||
&& \Phpcmf\Service::V()->_is_mobile
|
||||
&& strpos(SITE_MURL, SITE_URL) === false
|
||||
) {
|
||||
// 静态生成,移动端域名模式下
|
||||
$surl = SITE_MURL;
|
||||
}
|
||||
$url = str_replace($surl, '/', $url);
|
||||
if (IS_DEV && strpos($url, 'http') === 0) {
|
||||
$url.= '#站外域名不能转为相对路径(本提示信息关闭开发者模式时不显示)';
|
||||
}
|
||||
$prefix && $url = str_replace($prefix, '/', $url);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 内容中的转为相对路径
|
||||
*/
|
||||
if (!function_exists('dr_text_rel')) {
|
||||
|
||||
|
||||
/**
|
||||
* 内容中的转为相对路径
|
||||
*/
|
||||
function dr_text_rel($text, $prefix = '') {
|
||||
|
||||
if ((IS_API_HTTP && (!defined('SYS_API_REL') || !SYS_API_REL)) || IS_ADMIN) {
|
||||
return $text;
|
||||
} elseif (defined('SYS_URL_REL') && SYS_URL_REL) {
|
||||
$surl = FC_NOW_HOST;
|
||||
if (defined('SC_HTML_FILE') && SITE_IS_MOBILE_HTML
|
||||
&& \Phpcmf\Service::V()->_is_mobile
|
||||
&& strpos(SITE_MURL, SITE_URL) === false
|
||||
) {
|
||||
// 静态生成,移动端域名模式下
|
||||
$surl = SITE_MURL;
|
||||
}
|
||||
$text = str_replace('href="'.$surl, 'href="/', $text);
|
||||
$text = str_replace('href=\''.$surl, 'href="/', $text);
|
||||
$text = str_replace('src="'.$surl, 'src="/', $text);
|
||||
$text = str_replace('src=\''.$surl, 'src="/', $text);
|
||||
if ($prefix) {
|
||||
$surl = $prefix;
|
||||
$text = str_replace('href="'.$surl, 'href="/', $text);
|
||||
$text = str_replace('href=\''.$surl, 'href="/', $text);
|
||||
$text = str_replace('src="'.$surl, 'src="/', $text);
|
||||
$text = str_replace('src=\''.$surl, 'src="/', $text);
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模块栏目URL地址
|
||||
*
|
||||
* @param array $mod
|
||||
* @param array $data
|
||||
* @param intval $page
|
||||
* @return string
|
||||
*/
|
||||
function dr_module_category_url($mod, $data, $page = 0, $fid = 0) {
|
||||
|
||||
if (!$mod) {
|
||||
return '栏目所属模块不存在';
|
||||
} elseif (!$data) {
|
||||
return '栏目数据不存在';
|
||||
}
|
||||
|
||||
// 是否分页
|
||||
$page && $data['page'] = $page = is_numeric($page) ? max((int)$page, 1) : $page;
|
||||
!$page && $page = 1;
|
||||
$is_page = $page > 1 || strpos($page, 'page') !== false;
|
||||
|
||||
// 动态地址
|
||||
$php_url = \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $data, $fid) . 'c=category&id=' . (isset($data['id']) ? $data['id'] : 0) . ($is_page ? '&page=' . $page : '');
|
||||
|
||||
// 获取自定义URL
|
||||
$url = '';
|
||||
$rule = isset($data['setting']['urlrule']) ? \Phpcmf\Service::L('cache')->get('urlrule', (int)$data['setting']['urlrule'], 'value') : 0;
|
||||
if ($is_page) {
|
||||
if (isset($data['myurl_page']) && $data['myurl_page']) {
|
||||
$url = ltrim($data['myurl_page'], '/');
|
||||
$myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $data, $fid));
|
||||
dr_save_rewrite_routes($my_url, trim($php_url, '/'));
|
||||
return $myurl;
|
||||
} elseif ($rule && $rule['list_page']) {
|
||||
$url = ltrim($rule['list_page'], '/');
|
||||
}
|
||||
} else {
|
||||
if (isset($data['myurl']) && $data['myurl']) {
|
||||
$url = ltrim($data['myurl'], '/');
|
||||
$myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $data, $fid));
|
||||
dr_save_rewrite_routes($my_url, trim($php_url, '/'));
|
||||
return $myurl;
|
||||
} elseif ($rule && $rule['list']) {
|
||||
$url = ltrim($rule['list'], '/');
|
||||
}
|
||||
}
|
||||
|
||||
if ($url) {
|
||||
// URL模式为自定义,且已经设置规则
|
||||
$data['fid'] = $fid;
|
||||
$data['modname'] = $mod['share'] ? '共享栏目不能使用modname标签' : $mod['dirname'];
|
||||
$data['pdirname'].= $data['dirname'];
|
||||
$data['pdirname'] = str_replace('/', $rule['catjoin'], $data['pdirname']);
|
||||
$data['otdirname'] = $data['opdirname'] = $data['dirname'];
|
||||
if ($data['pid']) {
|
||||
$pcat = dr_cat_value($mod['mid'], $data['pid']);
|
||||
if ($pcat) {
|
||||
$data['opdirname'] = $pcat['dirname'];
|
||||
}
|
||||
}
|
||||
if ($data['topid']) {
|
||||
$pcat = dr_cat_value($mod['mid'], $data['topid']);
|
||||
if ($pcat) {
|
||||
$data['otdirname'] = $pcat['dirname'];
|
||||
}
|
||||
}
|
||||
$myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $data, $fid));
|
||||
dr_save_rewrite_routes($myurl, trim($php_url, '/'));
|
||||
return $myurl;
|
||||
}
|
||||
|
||||
return \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $data, $fid) . 'c=category&id=' . (isset($data['id']) ? $data['id'] : 0) . ($is_page ? '&page=' . $page : '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 模块内容URL地址
|
||||
*
|
||||
* @param array $mod
|
||||
* @param array $data
|
||||
* @param mod $page
|
||||
* @return string
|
||||
*/
|
||||
function dr_module_show_url($mod, $data, $page = 0) {
|
||||
|
||||
if (!$mod) {
|
||||
return 'mod参数不存在';
|
||||
} elseif (!$data) {
|
||||
return 'data参数不完整';
|
||||
}
|
||||
|
||||
$cat = dr_cat_value($mod['mid'], $data['catid']);
|
||||
|
||||
$page && $data['page'] = $page = is_numeric($page) ? max((int)$page, 1) : $page;
|
||||
!$page && $page = 1;
|
||||
$is_page = $page > 1 || strpos($page, 'page') !== false;
|
||||
|
||||
$url = '';
|
||||
$rule = \Phpcmf\Service::L('cache')->get('urlrule', (int)$cat['setting']['urlrule'], 'value');
|
||||
if ($is_page) {
|
||||
if (isset($data['myurl_page']) && $data['myurl_page']) {
|
||||
$url = ltrim($data['myurl_page'], '/');
|
||||
return \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $cat));
|
||||
} elseif ($rule && $rule['show_page']) {
|
||||
$url = ltrim($rule['show_page'], '/');
|
||||
}
|
||||
} else {
|
||||
if (isset($data['myurl']) && $data['myurl']) {
|
||||
$url = ltrim($data['myurl'], '/');
|
||||
return \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $cat));
|
||||
} elseif ($rule && $rule['show']) {
|
||||
$url = ltrim($rule['show'], '/');
|
||||
}
|
||||
}
|
||||
|
||||
$php_url = \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $cat) . 'c=show&id=' . $data['id'] . ($is_page ? '&page=' . $page : '');
|
||||
|
||||
if ($url) {
|
||||
// URL模式为自定义,且已经设置规则
|
||||
$data['cat'] = $cat;
|
||||
$data['modname'] = $mod['dirname'];
|
||||
$cat['pdirname'].= $cat['dirname'];
|
||||
$data['dirname'] = $cat['dirname'];
|
||||
$inputtime = isset($data['_inputtime']) ? $data['_inputtime'] : $data['inputtime'];
|
||||
$data['y'] = date('Y', $inputtime);
|
||||
$data['yy'] = date('y', $inputtime);
|
||||
$data['m'] = date('m', $inputtime);
|
||||
$data['d'] = date('d', $inputtime);
|
||||
$data['pdirname'] = str_replace('/', $rule['catjoin'], $cat['pdirname']);
|
||||
$data['otdirname'] = $data['opdirname'] = $cat['dirname'];
|
||||
if ($cat['pid']) {
|
||||
$pcat = dr_cat_value($mod['mid'], $cat['pid']);
|
||||
if ($pcat) {
|
||||
$data['opdirname'] = $pcat['dirname'];
|
||||
}
|
||||
}
|
||||
if ($cat['topid']) {
|
||||
$pcat = dr_cat_value($mod['mid'], $cat['topid']);
|
||||
if ($pcat) {
|
||||
$data['otdirname'] = $pcat['dirname'];
|
||||
}
|
||||
}
|
||||
|
||||
$data['url'] = $myurl = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod, $cat));
|
||||
dr_save_rewrite_routes($myurl, trim($php_url, '/'));
|
||||
} else {
|
||||
$data['url'] = \Phpcmf\Service::L('router')->url_prefix('module_php', $mod, $cat) . 'c=show&id=' . $data['id'] . ($is_page ? '&page=' . $page : '');
|
||||
}
|
||||
|
||||
// 挂钩点 模块内容url地址获取
|
||||
$rt = \Phpcmf\Hooks::trigger_callback('module_update_url', $data);
|
||||
if ($rt && isset($rt['code']) && $rt['code']) {
|
||||
$data['url'] = $rt['data'];
|
||||
dr_save_rewrite_routes($data['url'], trim($php_url, '/'));
|
||||
}
|
||||
|
||||
return $data['url'];
|
||||
}
|
||||
// 模块URL
|
||||
function dr_module_index_url($mod, $sid) {
|
||||
|
||||
// 绑定域名的情况下
|
||||
if ($mod['site'][$sid]['domain']) {
|
||||
return dr_http_prefix($mod['site'][$sid]['domain']) . '/';
|
||||
}
|
||||
$php_url = dr_web_prefix('index.php?s=' . $mod['dirname']);
|
||||
|
||||
// 自定义规则的情况下
|
||||
$rule = \Phpcmf\Service::L('cache')->get('urlrule', (int)$mod['urlrule'], 'value', 'module');
|
||||
if ($rule) {
|
||||
$url = dr_web_prefix(str_replace('{modname}', $mod['dirname'], $rule));
|
||||
dr_save_rewrite_routes($url, 'index.php?s=' . $mod['dirname']);
|
||||
return $url;
|
||||
}
|
||||
|
||||
return dr_web_prefix('index.php?s=' . $mod['dirname']);
|
||||
}
|
||||
/**
|
||||
* 搜索url组合
|
||||
*
|
||||
* @param array $params 搜索参数数组
|
||||
* @param string|array $name 当前参数名称
|
||||
* @param string|array $value 当前参数值
|
||||
* @param string $mid 强制定位到模块
|
||||
* @param string $fid 指定fid
|
||||
* @return string
|
||||
*/
|
||||
function dr_module_search_url($params = [], $name = '', $value = '', $mid = '', $fid = SITE_FID) {
|
||||
|
||||
|
||||
// 模块目录识别
|
||||
defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
|
||||
$mid && $dir = $mid;
|
||||
|
||||
$mod = \Phpcmf\Service::L('cache')->get('module-' . dr_module_siteid() . '-' . $dir);
|
||||
if (!$mod) {
|
||||
return '模块[' . $dir . ']缓存不存在';
|
||||
}
|
||||
|
||||
if ($name) {
|
||||
if (is_array($name)) {
|
||||
foreach ($name as $i => $_name) {
|
||||
if (isset($value[$i]) && strlen((string)$value[$i])) {
|
||||
$params[$_name] = $value[$i];
|
||||
} else {
|
||||
unset($params[$_name]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (strlen((string)$value)) {
|
||||
$params[$name] = $value;
|
||||
} else {
|
||||
unset($params[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $i => $t) {
|
||||
if (strlen((string)$t) == 0) {
|
||||
unset($params[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$php_url = \Phpcmf\Service::L('router')->url_prefix('php', $mod, [], $fid) . trim('c=search&' . (is_array($params) ? http_build_query($params) : ''), '&');
|
||||
|
||||
$rule = \Phpcmf\Service::L('cache')->get('urlrule', (int)$mod['urlrule'], 'value');
|
||||
if ($rule && $rule['search']) {
|
||||
$fid && $data['fid'] = $fid;
|
||||
$data['modname'] = $mod['dirname'];
|
||||
$data['param'] = dr_search_rewrite_encode($params, $mod['setting']['search']);
|
||||
if ($params && !$data['param']) {
|
||||
log_message('debug', '模块['.$mod['dirname'].']无法通过[搜索参数字符串规则]获得参数');
|
||||
}
|
||||
$url = ltrim($data['param'] ? $rule['search_page'] : $rule['search'], '/');
|
||||
$my_url = \Phpcmf\Service::L('router')->get_url_value($data, $url, \Phpcmf\Service::L('router')->url_prefix('rewrite', $mod));
|
||||
dr_save_rewrite_routes($my_url, trim($php_url, '/'));
|
||||
return dr_url_rel(dr_url_prefix($my_url, $mod['dirname']));
|
||||
} else {
|
||||
return dr_url_rel(dr_url_prefix(\Phpcmf\Service::L('router')->url_prefix('php', $mod, [], $fid) . trim('c=search&' . (is_array($params) ? http_build_query($params) : ''), '&'), $mod['dirname']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function dr_module_checktitle() {
|
||||
// 获取参数
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
$title = dr_safe_replace(htmlspecialchars((string)\Phpcmf\Service::L('input')->get('title')));
|
||||
$module = dr_safe_filename(\Phpcmf\Service::L('input')->get('module'));
|
||||
$cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$module);
|
||||
|
||||
// 判断参数
|
||||
if (!$title || !$module || !$cache) {
|
||||
exit('');
|
||||
}
|
||||
|
||||
// 判断是否重复存在
|
||||
if (\Phpcmf\Service::M()->db->table(dr_module_table_prefix($module))->where('id<>'.$id)->where('title', $title)->countAllResults()) {
|
||||
exit(dr_lang('已经有相同的%s存在', isset($cache['field']['title']['name']) ? $cache['field']['title']['name'] : dr_lang('主题')));
|
||||
}
|
||||
|
||||
exit('');
|
||||
}
|
||||
|
||||
function dr_module_api_search() {
|
||||
|
||||
$dir = dr_safe_filename(\Phpcmf\Service::L('input')->get('dir'));
|
||||
if (!$dir) {
|
||||
\Phpcmf\Service::C()->_msg(0, dr_lang('模块参数不能为空'));
|
||||
} elseif (!dr_is_module($dir)) {
|
||||
\Phpcmf\Service::C()->goto_404_page(dr_lang('模块[%s]未安装', $dir));
|
||||
}
|
||||
|
||||
$get = \Phpcmf\Service::L('input')->get();
|
||||
$cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
|
||||
$cache['field']['catdir'] = true;
|
||||
$cache['field']['catid'] = true;
|
||||
$cache['field']['order'] = true;
|
||||
|
||||
$param = [];
|
||||
foreach ($get as $key => $value) {
|
||||
if ($cache['field'] && isset($cache['field'][$key])) {
|
||||
$param[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转url
|
||||
dr_redirect(\Phpcmf\Service::L('Router')->search_url(
|
||||
$param,
|
||||
'keyword',
|
||||
dr_safe_replace(\Phpcmf\Service::L('input')->get('keyword')),
|
||||
$dir
|
||||
));
|
||||
}
|
||||
|
||||
// 评论名称
|
||||
if (!function_exists('dr_comment_cname')) {
|
||||
function dr_comment_cname($name) {
|
||||
|
||||
if (!$name) {
|
||||
return dr_lang('评论');
|
||||
}
|
||||
|
||||
return dr_lang($name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取描述信息过滤函数
|
||||
*/
|
||||
|
||||
if (! function_exists('dr_filter_description')) {
|
||||
function dr_filter_description($value, $data = [], $old = []) {
|
||||
return dr_get_description($value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('dr_get_description')) {
|
||||
/**
|
||||
* 提取描述信息
|
||||
*/
|
||||
function dr_get_description($text, $limit = 0) {
|
||||
|
||||
$rs = \Phpcmf\Hooks::trigger_callback('cms_get_description', $text);
|
||||
if ($rs && isset($rs['code']) && $rs['code'] && $rs['msg']) {
|
||||
$text = $rs['msg'];
|
||||
}
|
||||
|
||||
if (!$limit) {
|
||||
$limit = isset(\Phpcmf\Service::C()->module['setting']['desc_limit']) && \Phpcmf\Service::C()->module['setting']['desc_limit'] ? \Phpcmf\Service::C()->module['setting']['desc_limit'] : 200;
|
||||
}
|
||||
|
||||
if (isset(\Phpcmf\Service::C()->module['setting']['desc_clear']) && \Phpcmf\Service::C()->module['setting']['desc_clear']) {
|
||||
$text = str_replace(' ', '', $text);
|
||||
$text = str_replace(' ', '', $text);
|
||||
}
|
||||
|
||||
return trim(dr_strcut(dr_clearhtml($text), $limit, ''));
|
||||
}
|
||||
}
|
||||
if (! function_exists('dr_get_keywords')) {
|
||||
/**
|
||||
* 提取关键字
|
||||
*/
|
||||
function dr_get_keywords($kw, $siteid = SITE_ID)
|
||||
{
|
||||
|
||||
if (!$kw) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$rs = \Phpcmf\Hooks::trigger_callback('cms_get_keywords', $kw, $siteid);
|
||||
if ($rs && isset($rs['code']) && $rs['code'] && $rs['msg']) {
|
||||
return $rs['msg'];
|
||||
}
|
||||
|
||||
if (is_file(FCPATH.'ThirdParty/WordAnalysis/phpanalysis.class.php')) {
|
||||
require_once FCPATH.'ThirdParty/WordAnalysis/phpanalysis.class.php';
|
||||
\PhpAnalysis::$loadInit = false;
|
||||
$pa = new \PhpAnalysis ( 'utf-8', 'utf-8', false );
|
||||
$pa->LoadDict ();
|
||||
$pa->SetSource ($kw);
|
||||
$pa->StartAnalysis ( true );
|
||||
|
||||
$tags = $pa->GetFinallyKeywords (20);
|
||||
if ($tags) {
|
||||
return $tags;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Cms_free 安装:urlrule/module + 站点共享表 + 免费版默认数据
|
||||
*/
|
||||
$rt = \Phpcmf\Service::M('table')->install_schema([
|
||||
'tables' => [
|
||||
'urlrule' => [
|
||||
'comment' => 'URL规则表',
|
||||
'fields' => [
|
||||
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'type' => 'tinyint(1) unsigned NOT NULL COMMENT \'规则类型\'',
|
||||
'name' => 'varchar(50) NOT NULL COMMENT \'规则名称\'',
|
||||
'value' => 'text NOT NULL COMMENT \'详细规则\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `type` (`type`)',
|
||||
],
|
||||
],
|
||||
'module' => [
|
||||
'comment' => '模块表',
|
||||
'fields' => [
|
||||
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'site' => 'mediumtext NULL COMMENT \'站点划分\'',
|
||||
'dirname' => 'varchar(50) NOT NULL COMMENT \'目录名称\'',
|
||||
'share' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'是否共享模块\'',
|
||||
'setting' => 'text NULL COMMENT \'配置信息\'',
|
||||
'comment' => 'text NULL COMMENT \'评论信息\'',
|
||||
'disabled' => 'tinyint(1) NOT NULL DEFAULT \'0\' COMMENT \'禁用?\'',
|
||||
'displayorder' => 'smallint(5) DEFAULT \'0\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'UNIQUE KEY `dirname` (`dirname`)',
|
||||
'KEY `disabled` (`disabled`)',
|
||||
'KEY `displayorder` (`displayorder`)',
|
||||
],
|
||||
],
|
||||
'admin_verify' => [
|
||||
'comment' => '审核管理表',
|
||||
'fields' => [
|
||||
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'name' => 'text NOT NULL COMMENT \'名称\'',
|
||||
'verify' => 'text NOT NULL COMMENT \'审核部署\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
],
|
||||
],
|
||||
],
|
||||
'seeds' => [
|
||||
['table' => 'admin_verify', 'data' => ['id' => 1, 'name' => '默认审核', 'verify' => '{"edit":"1","role":{"1":"2"}}']],
|
||||
],
|
||||
]);
|
||||
if (empty($rt['code'])) {
|
||||
log_message('error', 'Cms_free install_schema: '.($rt['msg'] ?? ''));
|
||||
return dr_return_data(0, dr_lang('安装失败').':'.($rt['msg'] ?? ''));
|
||||
}
|
||||
|
||||
foreach ($this->site as $siteid) {
|
||||
$catTable = $this->dbprefix($siteid.'_share_category');
|
||||
if (!$this->is_table_exists($catTable)) {
|
||||
$crt = \Phpcmf\Service::M('table')->create_table(
|
||||
$catTable,
|
||||
[
|
||||
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'tid' => 'tinyint(1) NOT NULL COMMENT \'栏目类型,0单页,1模块,2外链\'',
|
||||
'pid' => 'smallint(5) unsigned NOT NULL DEFAULT \'0\' COMMENT \'上级id\'',
|
||||
'mid' => 'varchar(20) NOT NULL COMMENT \'模块目录\'',
|
||||
'pids' => 'varchar(255) NOT NULL COMMENT \'所有上级id\'',
|
||||
'name' => 'varchar(255) NOT NULL COMMENT \'栏目名称\'',
|
||||
'dirname' => 'varchar(255) NOT NULL COMMENT \'栏目目录\'',
|
||||
'pdirname' => 'varchar(255) NOT NULL COMMENT \'上级目录\'',
|
||||
'child' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'是否有下级\'',
|
||||
'disabled' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'是否禁用\'',
|
||||
'ismain' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'是否主栏目\'',
|
||||
'childids' => 'text NOT NULL COMMENT \'下级所有id\'',
|
||||
'thumb' => 'varchar(255) NOT NULL COMMENT \'栏目图片\'',
|
||||
'show' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'是否显示\'',
|
||||
'content' => 'mediumtext NOT NULL COMMENT \'单页内容\'',
|
||||
'setting' => 'mediumtext NOT NULL COMMENT \'属性配置\'',
|
||||
'displayorder' => 'smallint(5) NOT NULL DEFAULT \'0\'',
|
||||
],
|
||||
[
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `mid` (`mid`)',
|
||||
'KEY `tid` (`tid`)',
|
||||
'KEY `show` (`show`)',
|
||||
'KEY `disabled` (`disabled`)',
|
||||
'KEY `ismain` (`ismain`)',
|
||||
'KEY `dirname` (`dirname`)',
|
||||
'KEY `module` (`pid`,`displayorder`,`id`)',
|
||||
],
|
||||
'共享模块栏目表'
|
||||
);
|
||||
if (empty($crt['code'])) {
|
||||
log_message('error', 'Cms_free create table failed['.$catTable.']: '.($crt['msg'] ?? ''));
|
||||
return dr_return_data(0, dr_lang('安装失败').':'.($crt['msg'] ?? '无法创建表 '.$catTable));
|
||||
}
|
||||
}
|
||||
|
||||
$idxTable = $this->dbprefix($siteid.'_share_index');
|
||||
if (!$this->is_table_exists($idxTable)) {
|
||||
$crt = \Phpcmf\Service::M('table')->create_table(
|
||||
$idxTable,
|
||||
[
|
||||
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'mid' => 'varchar(20) NOT NULL COMMENT \'模块目录\'',
|
||||
],
|
||||
[
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `mid` (`mid`)',
|
||||
],
|
||||
'共享模块内容索引表'
|
||||
);
|
||||
if (empty($crt['code'])) {
|
||||
log_message('error', 'Cms_free create table failed['.$idxTable.']: '.($crt['msg'] ?? ''));
|
||||
return dr_return_data(0, dr_lang('安装失败').':'.($crt['msg'] ?? '无法创建表 '.$idxTable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents(CONFIGPATH.'rewrite.php', file_get_contents(dr_get_app_dir('cms').'Config/Rewrite.php'));
|
||||
|
||||
file_put_contents(WRITEPATH.'is_module_install.lock', 1);
|
||||
|
||||
$json = [];
|
||||
$json[] = '{"id":"5","type":"3","name":"不带栏目路径","value":"{\"list\":\"list-{dirname}.html\",\"list_page\":\"list-{dirname}-{page}.html\",\"show\":\"show-{id}.html\",\"show_page\":\"\",\"catjoin\":\"/\"}"}';
|
||||
$json[] = '{"id":"4","type":"3","name":"带栏目路径","value":"{\"list\":\"{dirname}/\",\"list_page\":\"{dirname}/p{page}.html\",\"show\":\"{dirname}/{id}.html\",\"show_page\":\"\",\"catjoin\":\"/\"}"}';
|
||||
$json[] = '{"id":"8","type":"2","name":"共享模块搜索","value":"{\"search\":\"search/{modname}.html\",\"search_page\":\"search/{modname}/{param}.html\",\"catjoin\":\"/\"}"}';
|
||||
foreach ($json as $t) {
|
||||
$data = dr_string2array($t);
|
||||
unset($data['id']);
|
||||
$this->table('urlrule')->insert($data);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('module', 'cms')->install('news', null, 0, 1);
|
||||
|
||||
// 默认站点信息字段
|
||||
$site_field = [];
|
||||
$site_field['yqlj'] = '{"name":"友情链接","fieldname":"yqlj","fieldtype":"Ftable","isedit":"1","ismain":"1","issystem":"0","ismember":"1","issearch":"0","disabled":"0","setting":{"option":{"is_add":"1","is_first_hang":"0","count":"","first_cname":"","hang":{"1":{"name":""},"2":{"name":""},"3":{"name":""},"4":{"name":""},"5":{"name":""}},"field":{"1":{"type":"1","name":"网站名称","width":"200","option":""},"2":{"type":"1","name":"网站地址","width":"","option":""},"3":{"type":"0","name":"","width":"","option":""},"4":{"type":"0","name":"","width":"","option":""},"5":{"type":"0","name":"","width":"","option":""},"6":{"type":"0","name":"","width":"","option":""},"7":{"type":"0","name":"","width":"","option":""},"8":{"type":"0","name":"","width":"","option":""},"9":{"type":"0","name":"","width":"","option":""},"10":{"type":"0","name":"","width":"","option":""}},"width":"","height":"","css":""},"validate":{"required":"0","pattern":"","errortips":"","xss":"1","check":"","filter":"","tips":"","formattr":""},"is_right":"0"},"displayorder":"0"}';
|
||||
$site_field['hdtp'] = '{"name":"幻灯图片","fieldname":"hdtp","fieldtype":"Ftable","isedit":"1","ismain":"1","issystem":"0","ismember":"1","issearch":"0","disabled":"0","setting":{"option":{"is_add":"1","is_first_hang":"0","count":"","first_cname":"","hang":{"1":{"name":""},"2":{"name":""},"3":{"name":""},"4":{"name":""},"5":{"name":""}},"field":{"1":{"type":"3","name":"图片","width":"200","option":""},"2":{"type":"1","name":"名称","width":"200","option":""},"3":{"type":"1","name":"跳转地址","width":"","option":""},"4":{"type":"0","name":"","width":"","option":""},"5":{"type":"0","name":"","width":"","option":""},"6":{"type":"0","name":"","width":"","option":""},"7":{"type":"0","name":"","width":"","option":""},"8":{"type":"0","name":"","width":"","option":""},"9":{"type":"0","name":"","width":"","option":""},"10":{"type":"0","name":"","width":"","option":""}},"width":"","height":"","css":""},"validate":{"required":"0","pattern":"","errortips":"","xss":"1","check":"","filter":"","tips":"","formattr":""},"is_right":"0"},"displayorder":"0"}';
|
||||
foreach ($site_field as $fname => $t) {
|
||||
$value = dr_string2array($t);
|
||||
if (!$value) {
|
||||
continue;
|
||||
}
|
||||
$value['setting'] = dr_string2array($value['setting']);
|
||||
\Phpcmf\Service::M('Field')->relatedid = SITE_ID;
|
||||
\Phpcmf\Service::M('Field')->relatedname = 'site';
|
||||
if (\Phpcmf\Service::M()->table('field')
|
||||
->where('relatedid', \Phpcmf\Service::M('Field')->relatedid)
|
||||
->where('relatedname', \Phpcmf\Service::M('Field')->relatedname)
|
||||
->where('fieldname', $fname)->counts()
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
$field = \Phpcmf\Service::L('field')->get($value['fieldtype']);
|
||||
\Phpcmf\Service::M('Field')->add($value, $field);
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 菜单配置
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
|
||||
'admin' => [
|
||||
|
||||
'config' => [
|
||||
'name' => '设置',
|
||||
'icon' => 'fa fa-cogs',
|
||||
'displayorder' => '-2',
|
||||
'left' => [
|
||||
'config-web' => [
|
||||
'name' => '网站设置',
|
||||
'icon' => 'fa fa-cog',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '网站设置',
|
||||
'icon' => 'fa fa-cog',
|
||||
'uri' => 'cms/site_config/index',
|
||||
],
|
||||
[
|
||||
'name' => '手机设置',
|
||||
'icon' => 'fa fa-mobile',
|
||||
'uri' => 'cms/site_mobile/index',
|
||||
],
|
||||
[
|
||||
'name' => '域名绑定',
|
||||
'icon' => 'fa fa-globe',
|
||||
'uri' => 'cms/site_domain/index',
|
||||
],
|
||||
],
|
||||
'displayorder' => -1,
|
||||
],
|
||||
|
||||
'config-content' => [
|
||||
'name' => '内容设置',
|
||||
'icon' => 'fa fa-navicon',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '创建模块',
|
||||
'icon' => 'fa fa-plus',
|
||||
'uri' => 'cms/module_create/index',
|
||||
'displayorder' => -1,
|
||||
],
|
||||
[
|
||||
'name' => '模块管理',
|
||||
'icon' => 'fa fa-gears',
|
||||
'uri' => 'cms/module/index',
|
||||
'displayorder' => -1,
|
||||
],
|
||||
[
|
||||
'name' => '模块搜索',
|
||||
'icon' => 'fa fa-search',
|
||||
'uri' => 'cms/module_search/index',
|
||||
'displayorder' => -1,
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
'config-qx' => [
|
||||
'name' => '权限设置',
|
||||
'icon' => 'fa fa-user',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '审核流程',
|
||||
'icon' => 'fa fa-sort-numeric-asc',
|
||||
'uri' => 'cms/admin_verify/index',
|
||||
],
|
||||
[
|
||||
'name' => '内容权限',
|
||||
'icon' => 'fa fa-table',
|
||||
'uri' => 'cms/auth/index',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
'config-seo' => [
|
||||
'name' => 'SEO设置',
|
||||
'icon' => 'fa fa-internet-explorer',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '站点SEO',
|
||||
'icon' => 'fa fa-cog',
|
||||
'uri' => 'cms/seo_site/index',
|
||||
],
|
||||
[
|
||||
'name' => '模块SEO',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'uri' => 'cms/seo_module/index',
|
||||
],
|
||||
[
|
||||
'name' => '栏目SEO',
|
||||
'icon' => 'fa fa-reorder',
|
||||
'uri' => 'cms/seo_category/index',
|
||||
],
|
||||
[
|
||||
'name' => 'URL规则',
|
||||
'icon' => 'fa fa-link',
|
||||
'uri' => 'cms/urlrule/index',
|
||||
],
|
||||
[
|
||||
'name' => '伪静态解析',
|
||||
'icon' => 'bi bi-code-square',
|
||||
'uri' => 'cms/urlrule/rewrite_index',
|
||||
],
|
||||
]
|
||||
],
|
||||
'config-help' => [
|
||||
'name' => '操作指南',
|
||||
'icon' => 'fa fa-question-circle',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '基础操作',
|
||||
'icon' => 'bi bi-code-square',
|
||||
'uri' => 'cms/help/index',
|
||||
],
|
||||
[
|
||||
'name' => '模板制作',
|
||||
'icon' => 'bi bi-code-square',
|
||||
'uri' => 'cms/help/template',
|
||||
],
|
||||
[
|
||||
'name' => 'SEO用法',
|
||||
'icon' => 'bi bi-code-square',
|
||||
'uri' => 'cms/help/seo',
|
||||
],
|
||||
[
|
||||
'name' => '自定义URL',
|
||||
'icon' => 'bi bi-code-square',
|
||||
'uri' => 'cms/help/url',
|
||||
],
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
|
||||
|
||||
'content' => [
|
||||
'name' => '内容',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'displayorder' => '-1',
|
||||
'left' => [
|
||||
'content-module' => [
|
||||
'name' => '内容管理',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '共享栏目',
|
||||
'icon' => 'fa fa-reorder',
|
||||
'uri' => 'category/index',
|
||||
],
|
||||
[
|
||||
'name' => '网站信息',
|
||||
'icon' => 'fa fa-edit',
|
||||
'uri' => 'cms/site_param/index',
|
||||
],
|
||||
]
|
||||
],
|
||||
'content-verify' => [
|
||||
'name' => '内容审核',
|
||||
'icon' => 'fa fa-edit',
|
||||
'link' => [
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
|
||||
],
|
||||
|
||||
|
||||
'admin_min' => [
|
||||
'home' => [
|
||||
'link' => [
|
||||
[
|
||||
'name' => '网站设置',
|
||||
'icon' => 'fa fa-cog',
|
||||
'uri' => 'module/site_param/index',
|
||||
],
|
||||
[
|
||||
'name' => '图片设置',
|
||||
'icon' => 'fa fa-photo',
|
||||
'uri' => 'module/site_image/index',
|
||||
],
|
||||
],
|
||||
],
|
||||
'config-seo' => [
|
||||
'name' => 'SEO设置',
|
||||
'icon' => 'fa fa-internet-explorer',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '站点SEO',
|
||||
'icon' => 'fa fa-cog',
|
||||
'uri' => 'module/seo_site/index',
|
||||
],
|
||||
[
|
||||
'name' => '模块SEO',
|
||||
'icon' => 'fa fa-gears',
|
||||
'uri' => 'module/seo_module/index',
|
||||
],
|
||||
[
|
||||
'name' => '栏目SEO',
|
||||
'icon' => 'fa fa-reorder',
|
||||
'uri' => 'module/seo_category/index',
|
||||
],
|
||||
[
|
||||
'name' => 'URL规则',
|
||||
'icon' => 'fa fa-link',
|
||||
'uri' => 'module/urlrule/index',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
'content-module' => [
|
||||
'name' => '内容管理',
|
||||
'icon' => 'fa fa-th-large',
|
||||
'link' => [
|
||||
[
|
||||
'name' => '共享栏目',
|
||||
'icon' => 'fa fa-reorder',
|
||||
'uri' => 'category/index',
|
||||
],
|
||||
]
|
||||
],
|
||||
|
||||
]
|
||||
|
||||
];
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
!$dirname && $dirname = APP_DIR;
|
||||
|
||||
if ($this->is_module_init == $dirname.'-'.$siteid) {
|
||||
// 防止模块重复初始化
|
||||
return 1;
|
||||
}
|
||||
|
||||
$this->is_module_init = $dirname.'-'.$siteid;
|
||||
|
||||
// 判断模块是否安装在站点中
|
||||
$cache = \Phpcmf\Service::L('cache')->get('module-'.$siteid);
|
||||
$this->module = [];
|
||||
if ($dirname == 'share' || (isset($cache[$dirname]) && $cache[$dirname])) {
|
||||
$this->module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-'.$dirname);
|
||||
}
|
||||
|
||||
// 判断模块是否存在
|
||||
if (!$this->module) {
|
||||
// 重新生成一次缓存
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->module = \Phpcmf\Service::L('cache')->get('module-'.$siteid.'-'.$dirname);
|
||||
if (!$this->module) {
|
||||
if (IS_ADMIN) {
|
||||
if ($dirname == 'share') {
|
||||
if ($rt) {
|
||||
return 0;
|
||||
} else {
|
||||
CI_DEBUG && log_message('debug', $dirname.' - '.dr_lang('系统未安装共享模块,无法使用栏目'));
|
||||
if (SITE_ID > 1) {
|
||||
$this->_admin_msg(0, dr_lang('系统未安装共享模块,无法使用栏目').'<br>'.dr_lang('点击下方链接进行装载共享模块'), dr_url('module/module/index'), 10);
|
||||
} else {
|
||||
$this->_admin_msg(0, dr_lang('系统未安装共享模块,无法使用栏目'), dr_url('module/module/index'), 10);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($rt) {
|
||||
return 0;
|
||||
} else {
|
||||
CI_DEBUG && log_message('error', $dirname.' - '.dr_lang('模块【%s】不存在', $dirname));
|
||||
$this->_admin_msg(0, dr_lang('模块缓存【%s】不存在', $dirname));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($rt) {
|
||||
return 0;
|
||||
} else {
|
||||
CI_DEBUG && log_message('error', $dirname.' - '.dr_lang('模块【%s】不存在', $dirname));
|
||||
$this->goto_404_page(dr_lang('模块缓存【%s】不存在', $dirname));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 无权限访问模块
|
||||
if (!defined('SC_HTML_FILE') && !IS_ADMIN && !IS_MEMBER && IS_USE_MEMBER
|
||||
&& \Phpcmf\Service::M('member_auth', 'cms')->module_auth($dirname, 'show', $this->member)) {
|
||||
if ($rt) {
|
||||
CI_DEBUG && log_message('debug', $dirname.' - '.dr_lang('您的用户组无权限访问模块'));
|
||||
return 0;
|
||||
}
|
||||
$this->_msg(0, dr_lang('您的用户组无权限访问模块'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
|
||||
}
|
||||
|
||||
// 初始化数据表
|
||||
$this->content_model = \Phpcmf\Service::M('Content', $dirname);
|
||||
$this->content_model->_init($dirname, $siteid, $this->module['share']);
|
||||
|
||||
// 共享模块时,单页界面时,排除
|
||||
if ($dirname == 'share') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->module['comment'] = dr_is_app('comment') && \Phpcmf\Service::L('cache')->get('app-comment-'.SITE_ID, 'module', $dirname, 'use') ? 1 : 0;
|
||||
|
||||
// 兼容老版本
|
||||
define('MOD_DIR', $dirname);
|
||||
define('IS_SHARE', $this->module['share']);
|
||||
define('IS_COMMENT', $this->module['comment']);
|
||||
define('MODULE_URL', $this->module['share'] ? '/' : $this->module['url']); // 共享模块没有模块url
|
||||
define('MODULE_NAME', dr_lang($this->module['name']));
|
||||
|
||||
$this->content_model->is_hcategory = $this->is_hcategory = isset($this->module['config']['hcategory']) && $this->module['config']['hcategory'];
|
||||
|
||||
// 设置模板到模块下
|
||||
!$this->module['url'] && \Phpcmf\Service::V()->module($dirname);
|
||||
|
||||
// 初始化加载
|
||||
$this->init_file($dirname);
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* URL解析规则
|
||||
* 例如: 114.html 对应 index.php?s=demo&c=show&id=114
|
||||
* 可以解析: "114.html" => 'index.php?s=demo&c=show&id=114',
|
||||
* 动态id解析: "([0-9]+).html" => 'index.php?s=demo&c=show&id=$1',
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
"list-([A-za-z0-9 \-\_]+)-([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2", //【不带栏目路径】模块栏目列表(分页)(list-{dirname}-{page}.html)
|
||||
"list-([A-za-z0-9 \-\_]+)\.html" => "index.php?c=category&dir=$1", //【不带栏目路径】模块栏目列表(list-{dirname}.html)
|
||||
"show-([0-9]+)\.html" => "index.php?c=show&id=$1", //【不带栏目路径】模块内容页(show-{id}.html)
|
||||
|
||||
"search\/([a-z]+)\/(.+)\.html" => "index.php?s=$1&c=search&rewrite=$2", //【共享模块搜索】模块搜索页(分页)(search/{modname}/{param}.html)
|
||||
"search\/([a-z]+)\.html" => "index.php?s=$1&c=search", //【共享模块搜索】模块搜索页(search/{modname}.html)
|
||||
|
||||
|
||||
"([A-za-z0-9 \-\_]+)\/p([0-9]+)\.html" => "index.php?c=category&dir=$1&page=$2", //【带栏目路径】模块栏目列表(分页)({dirname}/p{page}.html)
|
||||
"([A-za-z0-9 \-\_]+)\/([0-9]+)\.html" => "index.php?c=show&id=$2", //【带栏目路径】模块内容页({dirname}/{id}.html)
|
||||
"([A-za-z0-9 \-\_]+)" => "index.php?c=category&dir=$1", //【带栏目路径】模块栏目列表({dirname})
|
||||
|
||||
];
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// 加载主程序的路由
|
||||
require COREPATH.'Config/Routes.php';
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
$client = \Phpcmf\Service::R(WRITEPATH.'config/domain_client.php'); // 电脑域名对应的手机域名
|
||||
|
||||
// 开启自动跳转手机端(api、admin、member不跳转)
|
||||
if (!IS_API // api不跳转
|
||||
&& !IS_ADMIN // 后台不跳转
|
||||
&& !IS_MEMBER // 会员中心不跳
|
||||
&& !IS_API_HTTP // API请求不跳
|
||||
&& !IS_CLIENT // 终端不跳
|
||||
//&& !defined('IS_NOT_301') // 定义禁止301不跳
|
||||
//&& !defined('IS_NOT_301') // 定义禁止301不跳
|
||||
&& $client // 没有客户端不跳
|
||||
&& $this->site_info[SITE_ID]['SITE_MOBILE'] // 没有绑定移动端域名不跳
|
||||
//&& !in_array(DOMAIN_NAME, $client) // 当前域名不存在于客户端中时
|
||||
&& $this->site_info[SITE_ID]['SITE_AUTO'] // 开启自动识别跳转
|
||||
) {
|
||||
$domain = trim(DOMAIN_NAME.WEB_DIR, '/');
|
||||
if (\Phpcmf\Service::IS_MOBILE_USER()) {
|
||||
// 这是移动端
|
||||
if (isset($client[$domain])) {
|
||||
// 表示这个域名属于电脑端,需要跳转到移动端
|
||||
\Phpcmf\Service::L('Router')->auto_redirect(str_replace(dr_http_prefix($domain), dr_http_prefix($client[$domain]), dr_now_url()));
|
||||
}
|
||||
} else {
|
||||
// 这是电脑端
|
||||
if (dr_in_array($domain, $client)) {
|
||||
// 表示这个域名属于移动端,需要跳转到pc
|
||||
$arr = array_flip($client);
|
||||
\Phpcmf\Service::L('Router')->auto_redirect(str_replace(dr_http_prefix($domain), dr_http_prefix($arr[$domain]), dr_now_url()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断网站是否关闭
|
||||
if (!IS_DEV && !IS_ADMIN && !IS_API
|
||||
&& $this->site_info[SITE_ID]['SITE_CLOSE']
|
||||
&& (!$this->member || !$this->member['is_admin'])) {
|
||||
// 挂钩点 网站关闭时
|
||||
\Phpcmf\Hooks::trigger('cms_close');
|
||||
$this->_msg(0, $this->get_cache('site', SITE_ID, 'config', 'SITE_CLOSE_MSG'));
|
||||
}
|
||||
|
||||
// 站群系统接入
|
||||
if (is_file(ROOTPATH.'api/fclient/sync.php')) {
|
||||
$sync = \Phpcmf\Service::R(ROOTPATH.'api/fclient/sync.php') ;
|
||||
if ($sync['status'] == 4) {
|
||||
if ($sync['close_url']) {
|
||||
dr_redirect($sync['close_url']);
|
||||
} else {
|
||||
$this->_msg(0, '网站被关闭');
|
||||
}
|
||||
} elseif ($sync['status'] == 3 || ($sync['endtime'] && SYS_TIME > $sync['endtime'])) {
|
||||
if ($sync['pay_url']) {
|
||||
dr_redirect($sync['pay_url']);
|
||||
} else {
|
||||
$this->_msg(0, '网站已过期');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
/**
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件
|
||||
**/
|
||||
|
||||
/**
|
||||
* 系统模块表(规范化 Schema:fields / indexes / comment)
|
||||
* Module 安装时走 Table::create_table → 驱动 createTable
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'_draft' => [
|
||||
'comment' => '内容草稿表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'cid' => 'int(10) unsigned NOT NULL COMMENT \'内容id\'',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'content' => 'mediumtext NOT NULL COMMENT \'具体内容\'',
|
||||
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `cid` (`cid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_verify' => [
|
||||
'comment' => '内容审核表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'vid' => 'tinyint(2) NOT NULL COMMENT \'审核id号\'',
|
||||
'isnew' => 'tinyint(1) unsigned NOT NULL COMMENT \'0修改1新增2删除\'',
|
||||
'islock' => 'tinyint(1) unsigned NOT NULL COMMENT \'是否锁定\'',
|
||||
'author' => 'varchar(50) NOT NULL COMMENT \'作者\'',
|
||||
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'status' => 'tinyint(2) NOT NULL COMMENT \'审核状态\'',
|
||||
'content' => 'mediumtext NOT NULL COMMENT \'具体内容\'',
|
||||
'backuid' => 'mediumint(8) unsigned NOT NULL COMMENT \'操作人uid\'',
|
||||
'backinfo' => 'text NOT NULL COMMENT \'操作退回信息\'',
|
||||
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'UNIQUE KEY `id` (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `vid` (`vid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
'KEY `status` (`status`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
'KEY `backuid` (`backuid`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_hits' => [
|
||||
'comment' => '时段点击量统计',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL COMMENT \'文章id\'',
|
||||
'hits' => 'int(10) unsigned NOT NULL COMMENT \'总点击数\'',
|
||||
'day_hits' => 'int(10) unsigned NOT NULL COMMENT \'本日点击\'',
|
||||
'week_hits' => 'int(10) unsigned NOT NULL COMMENT \'本周点击\'',
|
||||
'month_hits' => 'int(10) unsigned NOT NULL COMMENT \'本月点击\'',
|
||||
'year_hits' => 'int(10) unsigned NOT NULL COMMENT \'年点击量\'',
|
||||
'day_time' => 'int(10) unsigned NOT NULL COMMENT \'本日\'',
|
||||
'week_time' => 'int(10) unsigned NOT NULL COMMENT \'本周\'',
|
||||
'month_time' => 'int(10) unsigned NOT NULL COMMENT \'本月\'',
|
||||
'year_time' => 'int(10) unsigned NOT NULL COMMENT \'年\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'UNIQUE KEY `id` (`id`)',
|
||||
'KEY `day_hits` (`day_hits`)',
|
||||
'KEY `week_hits` (`week_hits`)',
|
||||
'KEY `month_hits` (`month_hits`)',
|
||||
'KEY `year_hits` (`year_hits`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_index' => [
|
||||
'comment' => '内容索引表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'status' => 'tinyint(2) NOT NULL COMMENT \'审核状态\'',
|
||||
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
'KEY `status` (`status`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_category' => [
|
||||
'comment' => '栏目表',
|
||||
'fields' => [
|
||||
'id' => 'mediumint(8) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'pid' => 'mediumint(8) unsigned NOT NULL DEFAULT \'0\' COMMENT \'上级id\'',
|
||||
'pids' => 'varchar(255) NOT NULL COMMENT \'所有上级id\'',
|
||||
'name' => 'varchar(255) NOT NULL COMMENT \'栏目名称\'',
|
||||
'dirname' => 'varchar(255) NOT NULL COMMENT \'栏目目录\'',
|
||||
'pdirname' => 'varchar(255) NOT NULL COMMENT \'上级目录\'',
|
||||
'child' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'是否有下级\'',
|
||||
'disabled' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'是否禁用\'',
|
||||
'ismain' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'是否主栏目\'',
|
||||
'childids' => 'text NOT NULL COMMENT \'下级所有id\'',
|
||||
'thumb' => 'varchar(255) NOT NULL COMMENT \'栏目图片\'',
|
||||
'show' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'是否显示\'',
|
||||
'setting' => 'mediumtext NOT NULL COMMENT \'属性配置\'',
|
||||
'displayorder' => 'mediumint(8) NOT NULL DEFAULT \'0\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `show` (`show`)',
|
||||
'KEY `disabled` (`disabled`)',
|
||||
'KEY `ismain` (`ismain`)',
|
||||
'KEY `module` (`pid`,`displayorder`,`id`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_category_data' => [
|
||||
'comment' => '栏目模型表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'catid' => 'int(3) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_flag' => [
|
||||
'comment' => '标记表',
|
||||
'fields' => [
|
||||
'flag' => 'tinyint(2) unsigned NOT NULL DEFAULT \'1\' COMMENT \'文档标记id\'',
|
||||
'id' => 'int(10) unsigned NOT NULL COMMENT \'文档内容id\'',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'KEY `flag` (`flag`,`id`,`uid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_search' => [
|
||||
'comment' => '搜索表',
|
||||
'fields' => [
|
||||
'id' => 'varchar(32) NOT NULL',
|
||||
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'params' => 'text NOT NULL COMMENT \'参数数组\'',
|
||||
'keyword' => 'varchar(255) NOT NULL COMMENT \'关键字\'',
|
||||
'contentid' => 'int(10) unsigned NOT NULL COMMENT \'字段改成了结果数量值\'',
|
||||
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'搜索时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'UNIQUE KEY `id` (`id`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
'KEY `keyword` (`keyword`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_recycle' => [
|
||||
'comment' => '内容回收站表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'cid' => 'int(10) unsigned NOT NULL COMMENT \'内容id\'',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'catid' => 'tinyint(3) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'content' => 'mediumtext NOT NULL COMMENT \'具体内容\'',
|
||||
'result' => 'text NOT NULL COMMENT \'删除理由\'',
|
||||
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `cid` (`cid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
|
||||
'_time' => [
|
||||
'comment' => '内容定时发布表',
|
||||
'fields' => [
|
||||
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者uid\'',
|
||||
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
|
||||
'content' => 'mediumtext NOT NULL COMMENT \'具体内容\'',
|
||||
'result' => 'text NOT NULL COMMENT \'处理结果\'',
|
||||
'error' => 'tinyint(1) unsigned NOT NULL COMMENT \'是否错误\'',
|
||||
'posttime' => 'int(10) unsigned NOT NULL COMMENT \'定时发布时间\'',
|
||||
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'录入时间\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
'KEY `uid` (`uid`)',
|
||||
'KEY `catid` (`catid`)',
|
||||
'KEY `error` (`error`)',
|
||||
'KEY `posttime` (`posttime`)',
|
||||
'KEY `inputtime` (`inputtime`)',
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// 无固定业务表;模块挂载表由插件后台卸载逻辑处理
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 更新数据结构
|
||||
**/
|
||||
|
||||
$prefix = \Phpcmf\Service::M()->prefix;
|
||||
|
||||
// 审核流程表
|
||||
if (!\Phpcmf\Service::M()->is_table_exists('admin_verify')) {
|
||||
$rt = \Phpcmf\Service::M('table')->install_schema([
|
||||
'tables' => [
|
||||
'admin_verify' => [
|
||||
'comment' => '审核管理表',
|
||||
'fields' => [
|
||||
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
|
||||
'name' => 'text NOT NULL COMMENT \'名称\'',
|
||||
'verify' => 'text NOT NULL COMMENT \'审核部署\'',
|
||||
],
|
||||
'indexes' => [
|
||||
'PRIMARY KEY (`id`)',
|
||||
],
|
||||
],
|
||||
],
|
||||
'seeds' => [
|
||||
['table' => 'admin_verify', 'data' => ['id' => 1, 'name' => '默认审核', 'verify' => '{"edit":"1","role":{"1":"2"}}']],
|
||||
],
|
||||
]);
|
||||
if (empty($rt['code'])) {
|
||||
log_message('error', 'Cms_free update admin_verify: '.($rt['msg'] ?? ''));
|
||||
}
|
||||
}
|
||||
|
||||
// 模块
|
||||
$is_module = \Phpcmf\Service::M()->is_table_exists('module');
|
||||
if ($is_module) {
|
||||
$module = \Phpcmf\Service::M()->table('module')->order_by('displayorder ASC,id ASC')->getAll();
|
||||
// 栏目模型字段修正
|
||||
\Phpcmf\Service::M()->db->table('field')->where('relatedname', 'share-'.SITE_ID)->update(['relatedname' => 'catmodule-share']);
|
||||
if ($module) {
|
||||
foreach ($module as $m) {
|
||||
if (!\Phpcmf\Service::M()->table('field')->where('relatedname', 'module')
|
||||
->where('relatedid', $m['id'])->where('fieldname', 'author')->counts()) {
|
||||
\Phpcmf\Service::M()->db->table('field')->insert(array(
|
||||
'name' => '笔名',
|
||||
'fieldname' => 'author',
|
||||
'fieldtype' => 'Text',
|
||||
'relatedid' => $m['id'],
|
||||
'relatedname' => 'module',
|
||||
'isedit' => 1,
|
||||
'ismain' => 1,
|
||||
'ismember' => 1,
|
||||
'issystem' => 1,
|
||||
'issearch' => 1,
|
||||
'disabled' => 0,
|
||||
'setting' => dr_array2string(array(
|
||||
'is_right' => 1,
|
||||
'option' => array(
|
||||
'width' => 200, // 表单宽度
|
||||
'fieldtype' => 'VARCHAR', // 字段类型
|
||||
'fieldlength' => '255', // 字段长度
|
||||
'value' => '{name}'
|
||||
),
|
||||
'validate' => array(
|
||||
'xss' => 1, // xss过滤
|
||||
)
|
||||
)),
|
||||
'displayorder' => 0,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 站点
|
||||
foreach ($this->site as $siteid) {
|
||||
// 升级栏目表
|
||||
if ($is_module) {
|
||||
$table = $prefix . $siteid . '_share_category';
|
||||
if (\Phpcmf\Service::M()->is_table_exists($table)) {
|
||||
// 创建字段 代码
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('disabled', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'disabled', 'tinyint(1)', 'DEFAULT \'0\'', '');
|
||||
\Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0');
|
||||
}
|
||||
\Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0 WHERE `disabled` IS NULL ');
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('ismain', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'ismain', 'tinyint(1)', 'DEFAULT \'0\'', '');
|
||||
\Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `ismain` = 1');
|
||||
}
|
||||
}
|
||||
if ($module) {
|
||||
foreach ($module as $m) {
|
||||
$mtable = $prefix . $siteid . '_' . $m['dirname'];
|
||||
if (!\Phpcmf\Service::M()->is_table_exists($mtable)) {
|
||||
continue;
|
||||
}
|
||||
// 附表字段是否同步
|
||||
$tables = [];
|
||||
$otable = $mtable.'_data_0'; // 母表
|
||||
list($a, $sql) = \Phpcmf\Service::M('table')->create_table_sql($otable);
|
||||
|
||||
$old = \Phpcmf\Service::M('table')->show_full_colunms($otable);
|
||||
|
||||
// 模块附表
|
||||
for ($i = 1; $i < 200; $i ++) {
|
||||
// 新表是否存在
|
||||
if (!\Phpcmf\Service::M()->is_table_exists($mtable.'_data_'.$i)) {
|
||||
break;
|
||||
}
|
||||
$new = \Phpcmf\Service::M('table')->show_full_colunms($mtable.'_data_'.$i);
|
||||
foreach ($old as $t) {
|
||||
$td = 0;
|
||||
foreach ($new as $n) {
|
||||
if ($t['Field'] == $n['Field']) {
|
||||
$td = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($td == 0 && $sql[$t['Field']] && !\Phpcmf\Service::M()->db->fieldExists($t['Field'], $mtable.'_data_'.$i)) {
|
||||
// 新增表字段
|
||||
$def = preg_replace('/^`'.preg_quote($t['Field'], '/').'`\s+/', '', trim($sql[$t['Field']]));
|
||||
\Phpcmf\Service::M('table')->add_field($mtable.'_data_'.$i, $t['Field'], $def, '', '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 增加长度
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'];
|
||||
if (\Phpcmf\Service::M()->db->fieldExists('inputip', $table)) {
|
||||
\Phpcmf\Service::M('table')->edit_field($table, 'inputip', 'VARCHAR(100)', 'NOT NULL', '客户端ip信息');
|
||||
}
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'] . '_time';
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('error', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'error', 'tinyint(1)', 'DEFAULT 0', '');
|
||||
}
|
||||
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'] . '_recycle';
|
||||
if (\Phpcmf\Service::M()->is_table_exists($table)) {
|
||||
// 创建字段 删除理由
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('result', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'result', 'Text', 'NOT NULL', '');
|
||||
}
|
||||
}
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'] . '_support';
|
||||
if (\Phpcmf\Service::M()->is_table_exists($table)) {
|
||||
// 创建字段 游客点赞
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('agent', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'agent', 'VARCHAR(200)', 'DEFAULT NULL', '');
|
||||
}
|
||||
}
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'] . '_oppose';
|
||||
if (\Phpcmf\Service::M()->is_table_exists($table)) {
|
||||
// 创建字段 游客点赞
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('agent', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'agent', 'VARCHAR(200)', 'DEFAULT NULL', '');
|
||||
}
|
||||
}
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'] . '_verify';
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('vid', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'vid', 'INT(10)', 'DEFAULT NULL', '');
|
||||
}
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('islock', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'islock', 'tinyint(1)', 'DEFAULT NULL', '');
|
||||
}
|
||||
// 点击时间
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'] . '_hits';
|
||||
foreach (['day_time', 'week_time', 'month_time', 'year_time'] as $a) {
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists($a, $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, $a, 'INT(10)', 'DEFAULT NULL', '');
|
||||
}
|
||||
}
|
||||
$table = $prefix . $siteid . '_' . $m['dirname'] . '_category';
|
||||
if (\Phpcmf\Service::M()->is_table_exists($table)) {
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('disabled', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'disabled', 'tinyint(1)', 'DEFAULT \'0\'', '');
|
||||
\Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0');
|
||||
}
|
||||
\Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `disabled` = 0 WHERE `disabled` IS NULL ');
|
||||
if (!\Phpcmf\Service::M()->db->fieldExists('ismain', $table)) {
|
||||
\Phpcmf\Service::M('table')->add_field($table, 'ismain', 'tinyint(1)', 'DEFAULT \'0\'', '');
|
||||
\Phpcmf\Service::M()->query('UPDATE `' . $table . '` SET `ismain` = 1');
|
||||
}
|
||||
}
|
||||
// 栏目模型字段修正
|
||||
\Phpcmf\Service::M()->db->table('field')->where('relatedname', $m['dirname'] . '-' . $siteid)->update(['relatedname' => 'catmodule-' . $m['dirname']]);
|
||||
// 无符号修正
|
||||
//\Phpcmf\Service::M()->query('ALTER TABLE `'.$prefix.$siteid.'_'.$m['dirname'].'` CHANGE `updatetime` `updatetime` INT(10) NOT NULL COMMENT \'更新时间\'');
|
||||
//\Phpcmf\Service::M()->query('ALTER TABLE `'.$prefix.$siteid.'_'.$m['dirname'].'` CHANGE `inputtime` `inputtime` INT(10) NOT NULL COMMENT \'更新时间\'');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 程序版本控制
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'id' => '928',
|
||||
'version' => '4.1',
|
||||
'license' => '00000000000000000',
|
||||
'updatetime' => '2023-3-1',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
// 审核流程
|
||||
class Admin_verify extends \Phpcmf\Table
|
||||
{
|
||||
|
||||
public $role;
|
||||
public $type;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'审核流程' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-sort-numeric-asc'],
|
||||
'添加' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/add', 'fa fa-plus'],
|
||||
'修改' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
|
||||
'help' => ['825'],
|
||||
]
|
||||
),
|
||||
'is_vip' => is_file(IS_USE_MODULE.'/Models/Verify.php'),
|
||||
]);
|
||||
// 支持附表存储
|
||||
$this->is_data = 0;
|
||||
$this->my_field = array(
|
||||
'name' => array(
|
||||
'ismain' => 1,
|
||||
'name' => dr_lang('名称'),
|
||||
'fieldname' => 'name',
|
||||
'fieldtype' => 'Text',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'width' => 200,
|
||||
),
|
||||
'validate' => array(
|
||||
'required' => 1,
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
// url显示名称
|
||||
$this->name = dr_lang('审核流程');
|
||||
// 初始化数据表
|
||||
$this->_init([
|
||||
'table' => 'admin_verify',
|
||||
'field' => $this->my_field,
|
||||
'order_by' => 'id desc',
|
||||
]);
|
||||
$this->role = \Phpcmf\Service::M('Auth')->get_role_all();
|
||||
}
|
||||
|
||||
// 后台查看url列表
|
||||
public function index() {
|
||||
|
||||
$this->_List([], -1);
|
||||
\Phpcmf\Service::V()->display('verify_index.html');
|
||||
}
|
||||
|
||||
// 后台添加url内容
|
||||
public function add() {
|
||||
$this->_Post(0);
|
||||
\Phpcmf\Service::V()->display('verify_add.html');
|
||||
}
|
||||
|
||||
// 后台修改url内容
|
||||
public function edit() {
|
||||
$this->_Post(intval(\Phpcmf\Service::L('input')->get('id')));
|
||||
\Phpcmf\Service::V()->display('verify_add.html');
|
||||
}
|
||||
|
||||
// 复制
|
||||
public function copy_edit() {
|
||||
|
||||
$id = intval(\Phpcmf\Service::L('input')->get('id'));
|
||||
$data = \Phpcmf\Service::M()->db->table('admin_verify')->where('id', $id)->get()->getRowArray();
|
||||
if (!$data) {
|
||||
$this->_json(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
|
||||
unset($data['id']);
|
||||
$data['name'].= '_copy';
|
||||
|
||||
$rt = \Phpcmf\Service::M()->table('admin_verify')->insert($data);
|
||||
if (!$rt['code']) {
|
||||
$this->_json(0, dr_lang($rt['msg']));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, dr_lang('复制成功'));
|
||||
}
|
||||
|
||||
|
||||
// 保存
|
||||
protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
|
||||
return parent::_Save($id, $data, $old, function($id, $data){
|
||||
// 保存前的格式化
|
||||
$value = \Phpcmf\Service::L('input')->post('value');
|
||||
if ($value['role']) {
|
||||
foreach ($value['role'] as $i => $ids) {
|
||||
if (!$ids) {
|
||||
unset($value['role'][$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$data[1]['verify'] = dr_array2string($value);
|
||||
return dr_return_data(1, 'ok', $data);
|
||||
}, function ($id, $data, $old) {
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内容
|
||||
* $id 内容id,新增为0
|
||||
* */
|
||||
protected function _Data($id = 0) {
|
||||
|
||||
$data = parent::_Data($id);
|
||||
$data['value'] = dr_string2array($data['verify']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 后台删除url内容
|
||||
public function del() {
|
||||
$this->_Del(
|
||||
\Phpcmf\Service::L('input')->get_post_ids(),
|
||||
null,
|
||||
function ($r) {
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
class Api extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
public function __construct($object = NULL)
|
||||
{
|
||||
parent::__construct();
|
||||
if ($object) {
|
||||
foreach ($object as $var => $value) {
|
||||
$this->$var = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 统计
|
||||
public function mtotal() {
|
||||
|
||||
$t1 = $t2 = $t3 = $t4 = $t5 = 0;
|
||||
$dir = dr_safe_filename(\Phpcmf\Service::L('input')->get('dir'));
|
||||
$prefix = dr_module_table_prefix($dir);
|
||||
if (is_dir(dr_get_app_dir($dir))) {
|
||||
$this->_module_init($dir);
|
||||
$t1 = \Phpcmf\Service::M()->table($prefix)->where($this->content_model->get_admin_list_where($prefix))->where('DATEDIFF(from_unixtime(inputtime),now())=0')->counts();
|
||||
$t2 = \Phpcmf\Service::M()->table($prefix)->where($this->content_model->get_admin_list_where($prefix))->counts();
|
||||
$t3 = \Phpcmf\Service::M()->table($prefix.'_verify')->where($this->content_model->get_admin_list_verify_where($this->content_model->get_admin_list_where($prefix.'_verify')))->counts();
|
||||
$t4 = \Phpcmf\Service::M()->table($prefix.'_recycle')->where($this->content_model->get_admin_list_where($prefix.'_recycle'))->counts();
|
||||
$t5 = \Phpcmf\Service::M()->table($prefix.'_time')->where($this->content_model->get_admin_list_where($prefix.'_time'))->counts();
|
||||
}
|
||||
echo '$("#'.$dir.'_today").html('.$t1.');';
|
||||
echo '$("#'.$dir.'_all").html('.$t2.');';
|
||||
echo '$("#'.$dir.'_verify").html('.$t3.');';
|
||||
echo '$("#'.$dir.'_recycle").html('.$t4.');';
|
||||
echo '$("#'.$dir.'_timing").html('.$t5.');';
|
||||
exit;
|
||||
}
|
||||
|
||||
// 更新url
|
||||
public function update_url() {
|
||||
|
||||
$mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
|
||||
if (!$mid) {
|
||||
$this->_html_msg(0, dr_lang('mid参数不能为空'));
|
||||
}
|
||||
|
||||
$this->_module_init($mid);
|
||||
|
||||
$page = (int)\Phpcmf\Service::L('input')->get('page');
|
||||
$total = (int)\Phpcmf\Service::L('input')->get('total');
|
||||
|
||||
if (!$page) {
|
||||
// 计算数量
|
||||
$total = \Phpcmf\Service::M()->db->table($this->content_model->mytable)->countAllResults();
|
||||
if (!$total) {
|
||||
$this->_html_msg(0, dr_lang('无可用内容更新'));
|
||||
}
|
||||
|
||||
$url = dr_url('module/api/'.\Phpcmf\Service::L('Router')->method, ['mid' => $mid]);
|
||||
$this->_html_msg(1, dr_lang('正在执行中...'), $url.'&total='.$total.'&page='.($page+1));
|
||||
}
|
||||
|
||||
$psize = 300; // 每页处理的数量
|
||||
if (isset($this->module['setting']['update_psize'])) {
|
||||
$psize = max((int)$this->module['setting']['update_psize'], 100);
|
||||
}
|
||||
|
||||
$tpage = ceil($total / $psize); // 总页数
|
||||
|
||||
// 更新完成
|
||||
if ($page > $tpage) {
|
||||
\Phpcmf\Service::M('cache')->update_data_cache();
|
||||
$this->_html_msg(1, dr_lang('更新完成'));
|
||||
}
|
||||
|
||||
$update = [];
|
||||
$data = \Phpcmf\Service::M()->db->table($this->content_model->mytable)->limit($psize, $psize * ($page - 1))->orderBy('id DESC')->get()->getResultArray();
|
||||
foreach ($data as $t) {
|
||||
if ($t['link_id'] && $t['link_id'] >= 0) {
|
||||
// 同步栏目的数据
|
||||
$i = $t['id'];
|
||||
$t = \Phpcmf\Service::M()->db->table($this->content_model->mytable)->where('id', (int)$t['link_id'])->get()->getRowArray();
|
||||
if (!$t) {
|
||||
continue;
|
||||
}
|
||||
$url = \Phpcmf\Service::L('Router')->show_url($this->module, $t);
|
||||
$t['id'] = $i; // 替换成当前id
|
||||
} else {
|
||||
$url = \Phpcmf\Service::L('Router')->show_url($this->module, $t);
|
||||
}
|
||||
$t['url'] != $url && $update[] = [
|
||||
'id' => (int)$t['id'],
|
||||
'url'=> $url,
|
||||
];
|
||||
}
|
||||
$update && \Phpcmf\Service::M()->table($this->content_model->mytable)->update_batch($update);
|
||||
|
||||
$this->_html_msg( 1, dr_lang('正在执行中【%s】...', "$tpage/$page"),
|
||||
dr_url('module/api/'.\Phpcmf\Service::L('Router')->method, ['mid' => $mid,'total' => $total, 'page' => $page + 1])
|
||||
);
|
||||
}
|
||||
|
||||
// 统计栏目
|
||||
public function ctotal() {
|
||||
|
||||
$rt = '';
|
||||
if (IS_POST) {
|
||||
$ids = dr_string2array(\Phpcmf\Service::L('input')->post('cid'));
|
||||
if ($ids) {
|
||||
foreach ($ids as $t) {
|
||||
list($id, $mid) = explode('-', $t);
|
||||
if ($id && $mid && dr_is_module($mid) ) {
|
||||
$db = \Phpcmf\Service::M()->table(dr_module_table_prefix($mid).'_index');
|
||||
$mod = $this->get_cache('module-'.SITE_ID.'-'.$mid);
|
||||
if ($mod['category'][$id]['childids']) {
|
||||
$db->where('catid in ('.$mod['category'][$id]['childids'].')');
|
||||
} else {
|
||||
$db->where('catid', $id);
|
||||
}
|
||||
$num = $db->where('status=9')->counts();
|
||||
if ($num) {
|
||||
$rt.= '$(".cat-total-'.$id.'").html("'.dr_lang('(约%s)', $num).'");';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->_json(1, $rt);
|
||||
}
|
||||
|
||||
// 更新栏目缓存配置
|
||||
public function update_category_repair() {
|
||||
|
||||
$mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
|
||||
if (!$mid) {
|
||||
$cdir = 'share';
|
||||
} else {
|
||||
$cdir = $mid;
|
||||
}
|
||||
if (\Phpcmf\Service::M()->table(SITE_ID.'_'.$cdir.'_category')->counts() > MAX_CATEGORY) {
|
||||
\Phpcmf\Service::M('module')->update_category_cache(SITE_ID, $cdir);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache();
|
||||
|
||||
$this->_html_msg(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
public function update_category_cache() {
|
||||
|
||||
$mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
|
||||
if (!$mid) {
|
||||
$cdir = 'share';
|
||||
} else {
|
||||
$cdir = $mid;
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('module')->update_category_cache(SITE_ID, $cdir);
|
||||
\Phpcmf\Service::M('cache')->sync_cache();
|
||||
|
||||
dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-child');
|
||||
dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-data');
|
||||
dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-min');
|
||||
dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-main');
|
||||
dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-'.$cdir.'-select');
|
||||
dr_dir_delete(WRITEPATH.'module/category-'.SITE_ID.'-share-select');
|
||||
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
// 查看审核流程
|
||||
public function verify() {
|
||||
|
||||
$id = intval(\Phpcmf\Service::L('input')->get('id'));
|
||||
if (!$id) {
|
||||
$this->_json(0, dr_lang('审核流程id不存在'));
|
||||
}
|
||||
|
||||
$data = \Phpcmf\Service::M()->db->table('admin_verify')->where('id', $id)->get()->getRowArray();
|
||||
if (!$data) {
|
||||
$this->_json(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'role' => \Phpcmf\Service::M('Auth')->get_role_all(),
|
||||
'value' => dr_string2array($data['verify']),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('verify_show.html');exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,981 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
/**
|
||||
* 内容权限设置(模块 / 栏目)
|
||||
* 用户侧权限仍在 Member 插件 member/auth
|
||||
*/
|
||||
class Auth extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
if (!IS_USE_MEMBER) {
|
||||
$this->_admin_msg(0, dr_lang('未安装用户系统,无法设置内容权限'));
|
||||
}
|
||||
}
|
||||
|
||||
// 当前可配置的内容模块
|
||||
protected function _content_modules() {
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
|
||||
if (!$module) {
|
||||
return [];
|
||||
}
|
||||
foreach ($module as $dir => $t) {
|
||||
if ($t['hlist'] == 1) {
|
||||
unset($module[$dir]);
|
||||
}
|
||||
}
|
||||
return $module;
|
||||
}
|
||||
|
||||
// 构建用户组 / 等级列
|
||||
protected function _auth_columns($auth_type) {
|
||||
|
||||
$group = [
|
||||
0 => [
|
||||
'id' => 0,
|
||||
'name' => dr_lang('游客'),
|
||||
'use' => 1,
|
||||
]
|
||||
];
|
||||
foreach ($this->member_cache['group'] as $t) {
|
||||
$group[$t['id']] = [
|
||||
'id' => $t['id'],
|
||||
'name' => dr_lang($t['name']),
|
||||
'use' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
$level = [
|
||||
0 => [
|
||||
'id' => 0,
|
||||
'name' => dr_lang('游客'),
|
||||
'group_name' => '',
|
||||
'level_name' => dr_lang('游客'),
|
||||
'use' => 1,
|
||||
]
|
||||
];
|
||||
foreach ($this->member_cache['group'] as $t) {
|
||||
$gname = dr_lang($t['name']);
|
||||
$level[$t['id']] = [
|
||||
'id' => $t['id'],
|
||||
'name' => $gname,
|
||||
'group_name' => '',
|
||||
'level_name' => $gname,
|
||||
'use' => 1,
|
||||
];
|
||||
if ($t['level']) {
|
||||
foreach ($t['level'] as $lv) {
|
||||
$lname = dr_lang($lv['name']);
|
||||
$level[$t['id'].'-'.$lv['id']] = [
|
||||
'id' => $t['id'].'-'.$lv['id'],
|
||||
'name' => $gname.' / '.$lname,
|
||||
'group_name' => $gname,
|
||||
'level_name' => $lname,
|
||||
'use' => 1,
|
||||
];
|
||||
$level[$t['id']]['use'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($auth_type == 1) {
|
||||
return $group;
|
||||
}
|
||||
if ($auth_type == 2) {
|
||||
$columns = [];
|
||||
foreach ($level as $i => $t) {
|
||||
if ($t['use']) {
|
||||
$columns[$i] = $t;
|
||||
}
|
||||
}
|
||||
return $columns;
|
||||
}
|
||||
return [
|
||||
'public' => [
|
||||
'id' => 'public',
|
||||
'name' => dr_lang('全局'),
|
||||
'use' => 1,
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
protected function _get_auth_row($auth_data, $aid) {
|
||||
$key = (string)$aid;
|
||||
if (isset($auth_data[$aid]) && is_array($auth_data[$aid])) {
|
||||
return $auth_data[$aid];
|
||||
}
|
||||
if (isset($auth_data[$key]) && is_array($auth_data[$key])) {
|
||||
return $auth_data[$key];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
protected function _get_post_row($post, $aid) {
|
||||
$key = (string)$aid;
|
||||
if (isset($post[$aid]) && is_array($post[$aid])) {
|
||||
return $post[$aid];
|
||||
}
|
||||
if (isset($post[$key]) && is_array($post[$key])) {
|
||||
return $post[$key];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// 未勾选的 checkbox 不会出现在 POST 中,显式写成 0,避免关闭验证码等无效
|
||||
protected function _normalize_category_auth_flags($auth) {
|
||||
if (!is_array($auth)) {
|
||||
$auth = [];
|
||||
}
|
||||
foreach (['show', 'add', 'edit', 'del', 'code'] as $f) {
|
||||
$auth[$f] = empty($auth[$f]) ? 0 : 1;
|
||||
}
|
||||
return $auth;
|
||||
}
|
||||
|
||||
// 表头:用户组 / 等级列
|
||||
protected function _auth_thead_html($columns) {
|
||||
$html = '<th class="fc-auth-name">'.dr_lang('权限项').'</th>';
|
||||
foreach ($columns as $aid => $col) {
|
||||
$key = (string)$aid;
|
||||
if ($key === '0') {
|
||||
$title = '<span class="font-red">'.htmlspecialchars((string)$col['name']).'</span>';
|
||||
} elseif (!empty($col['group_name'])) {
|
||||
$title = '<span class="fc-auth-gname">'.htmlspecialchars((string)$col['group_name']).'</span>'
|
||||
.'<span class="fc-auth-lname">'.htmlspecialchars((string)$col['level_name']).'</span>';
|
||||
} else {
|
||||
$title = htmlspecialchars((string)$col['name']);
|
||||
}
|
||||
$html .= '<th class="fc-auth-col">'.$title.'</th>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _auth_form_switch($label, $input_name, $checked, $help = '') {
|
||||
$html = '<div class="form-group">'
|
||||
.'<label class="col-md-2 control-label">'.$label.'</label>'
|
||||
.'<div class="col-md-9">'
|
||||
.'<input type="checkbox" name="'.$input_name.'" value="1"'
|
||||
.($checked ? ' checked' : '')
|
||||
.' data-on-text="'.dr_lang('禁止').'" data-off-text="'.dr_lang('开放').'"'
|
||||
.' data-on-color="danger" data-off-color="success" class="make-switch" data-size="small">';
|
||||
if ($help) {
|
||||
$html .= '<span class="help-block">'.$help.'</span>';
|
||||
}
|
||||
$html .= '</div></div>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
protected function _auth_matrix_wrap($thead, $tbody) {
|
||||
return '<div class="table-scrollable fc-auth-wrap">'
|
||||
.'<table class="table table-striped table-bordered table-hover fc-auth-table">'
|
||||
.'<thead><tr class="heading">'.$thead.'</tr></thead>'
|
||||
.'<tbody>'.$tbody.'</tbody>'
|
||||
.'</table></div>';
|
||||
}
|
||||
|
||||
// 栏目权限弹窗按钮
|
||||
protected function _auth_category_btn($aid, $page, $title, $btn_class = 'btn blue btn-xs', $btn_text = '') {
|
||||
$url = dr_url('cms/auth/add', ['aid' => $aid, 'page' => $page]);
|
||||
$js_title = str_replace(["\\", "'"], ["\\\\", "\\'"], (string)$title);
|
||||
if ($btn_text === '') {
|
||||
$btn_text = dr_lang('设置');
|
||||
}
|
||||
return '<button type="button" class="'.$btn_class.'" onclick="dr_iframe_show(\''.$js_title.'\', \''.$url.'\', \'85%\', \'90%\')">'
|
||||
.'<i class="fa fa-cog"></i> '.$btn_text
|
||||
.'</button>';
|
||||
}
|
||||
|
||||
// 栏目权限入口(全局表单)
|
||||
protected function _auth_category_form($columns, $page = 'cms') {
|
||||
$aid = 'public';
|
||||
$name = dr_lang('全局');
|
||||
foreach ($columns as $k => $col) {
|
||||
$aid = (string)$k;
|
||||
$name = (string)$col['name'];
|
||||
break;
|
||||
}
|
||||
return '<div class="form-group">'
|
||||
.'<label class="col-md-2 control-label">'.dr_lang('栏目权限').'</label>'
|
||||
.'<div class="col-md-9">'
|
||||
.$this->_auth_category_btn($aid, $page, dr_lang('[%s]栏目权限', $name), 'btn blue btn-sm', dr_lang('设置栏目发布/审核等权限'))
|
||||
.'<span class="help-block">'.dr_lang('访问、发布、修改、删除及投稿限制等').'</span>'
|
||||
.'</div></div>';
|
||||
}
|
||||
|
||||
// 栏目权限矩阵行
|
||||
protected function _auth_category_row($columns, $page = 'cms') {
|
||||
$html = '<tr><td class="fc-auth-name">'.dr_lang('栏目权限').'</td>';
|
||||
foreach ($columns as $aid => $col) {
|
||||
$key = (string)$aid;
|
||||
$html .= '<td class="fc-auth-col">'
|
||||
.$this->_auth_category_btn($key, $page, dr_lang('[%s]栏目权限', $col['name']))
|
||||
.'</td>';
|
||||
}
|
||||
$html .= '</tr>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
||||
$v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth_type')->get()->getRowArray();
|
||||
$auth_type = intval($v['value']);
|
||||
$columns = $this->_auth_columns($auth_type);
|
||||
$modules = $this->_content_modules();
|
||||
|
||||
$row = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
|
||||
$value = $row ? dr_string2array($row['value']) : [];
|
||||
if (!is_array($value)) {
|
||||
$value = [];
|
||||
}
|
||||
$auth_data = isset($value[SITE_ID]) && is_array($value[SITE_ID]) ? $value[SITE_ID] : [];
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
if (!is_array($post)) {
|
||||
$post = [];
|
||||
}
|
||||
|
||||
foreach ($columns as $aid => $col) {
|
||||
$old = $this->_get_auth_row($auth_data, $aid);
|
||||
$post_row = $this->_get_post_row($post, $aid);
|
||||
|
||||
$home = isset($old['home']) && is_array($old['home']) ? $old['home'] : [];
|
||||
$home['show'] = empty($post_row['home']['show']) ? 0 : 1;
|
||||
$old['home'] = $home;
|
||||
|
||||
$mod = isset($old['module']) && is_array($old['module']) ? $old['module'] : [];
|
||||
foreach ($modules as $mid => $m) {
|
||||
if (!isset($mod[$mid]) || !is_array($mod[$mid])) {
|
||||
$mod[$mid] = [];
|
||||
}
|
||||
$mod[$mid]['show'] = empty($post_row['module'][$mid]['show']) ? 0 : 1;
|
||||
$mod[$mid]['search'] = empty($post_row['module'][$mid]['search']) ? 0 : 1;
|
||||
}
|
||||
$old['module'] = $mod;
|
||||
|
||||
$auth_data[$aid] = $old;
|
||||
}
|
||||
|
||||
$value[SITE_ID] = $auth_data;
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth2',
|
||||
'value' => dr_array2string($value)
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$is_single = dr_count($columns) <= 1;
|
||||
$page = \Phpcmf\Service::L('input')->get('page');
|
||||
if (!$page) {
|
||||
$page = 'site';
|
||||
}
|
||||
if ($page !== 'site' && !isset($modules[$page])) {
|
||||
$page = 'site';
|
||||
}
|
||||
|
||||
$tabs = [];
|
||||
|
||||
// —— 整站 ——
|
||||
$site_html = '';
|
||||
if ($is_single) {
|
||||
$aid = 'public';
|
||||
foreach ($columns as $k => $col) {
|
||||
$aid = (string)$k;
|
||||
break;
|
||||
}
|
||||
$data = $this->_get_auth_row($auth_data, $aid);
|
||||
$aid_attr = htmlspecialchars($aid);
|
||||
$site_html .= $this->_auth_form_switch(
|
||||
dr_lang('禁止整站访问'),
|
||||
'data['.$aid_attr.'][home][show]',
|
||||
!empty($data['home']['show']),
|
||||
dr_lang('针对整个网站的前端界面访问权限')
|
||||
);
|
||||
$site_html .= $this->_auth_category_form($columns, 'cms');
|
||||
} else {
|
||||
$tbody = '<tr><td class="fc-auth-name">'.dr_lang('禁止整站访问').'</td>';
|
||||
foreach ($columns as $aid => $col) {
|
||||
$key = (string)$aid;
|
||||
$data = $this->_get_auth_row($auth_data, $aid);
|
||||
$checked = !empty($data['home']['show']) ? ' checked' : '';
|
||||
$tbody .= '<td class="fc-auth-col">'
|
||||
.'<input type="checkbox" class="fc-auth-check" name="data['.htmlspecialchars($key).'][home][show]" value="1"'.$checked.' />'
|
||||
.'</td>';
|
||||
}
|
||||
$tbody .= '</tr>';
|
||||
$tbody .= $this->_auth_category_row($columns, 'cms');
|
||||
$site_html .= $this->_auth_matrix_wrap($this->_auth_thead_html($columns), $tbody);
|
||||
}
|
||||
$tabs['site'] = [
|
||||
'id' => 'site',
|
||||
'name' => dr_lang('整站'),
|
||||
'dirname' => '',
|
||||
'icon' => 'fa fa-globe',
|
||||
'html' => $site_html,
|
||||
];
|
||||
|
||||
// —— 各内容模块 ——
|
||||
foreach ($modules as $mid => $m) {
|
||||
$mname = dr_lang($m['name']);
|
||||
$icon = !empty($m['icon']) ? $m['icon'] : 'fa fa-folder';
|
||||
$mod_html = '';
|
||||
if ($is_single) {
|
||||
$aid = 'public';
|
||||
foreach ($columns as $k => $col) {
|
||||
$aid = (string)$k;
|
||||
break;
|
||||
}
|
||||
$data = $this->_get_auth_row($auth_data, $aid);
|
||||
$aid_attr = htmlspecialchars($aid);
|
||||
$mid_attr = htmlspecialchars($mid);
|
||||
$mod_html .= $this->_auth_form_switch(
|
||||
dr_lang('禁止访问'),
|
||||
'data['.$aid_attr.'][module]['.$mid_attr.'][show]',
|
||||
!empty($data['module'][$mid]['show']),
|
||||
dr_lang('禁止后无法访问本模块前台')
|
||||
);
|
||||
$mod_html .= $this->_auth_form_switch(
|
||||
dr_lang('禁止搜索'),
|
||||
'data['.$aid_attr.'][module]['.$mid_attr.'][search]',
|
||||
!empty($data['module'][$mid]['search']),
|
||||
dr_lang('禁止后无法使用本模块搜索')
|
||||
);
|
||||
if (empty($m['share'])) {
|
||||
$mod_html .= $this->_auth_category_form($columns, $mid);
|
||||
} else {
|
||||
$mod_html .= '<div class="form-group"><label class="col-md-2 control-label">'.dr_lang('栏目权限').'</label>'
|
||||
.'<div class="col-md-9"><span class="help-block" style="margin-top:8px;">'
|
||||
.dr_lang('本模块使用共享栏目,请到「整站」中设置栏目权限')
|
||||
.'</span></div></div>';
|
||||
}
|
||||
} else {
|
||||
$tbody = '';
|
||||
$tbody .= '<tr><td class="fc-auth-name">'.dr_lang('禁止访问').'</td>';
|
||||
foreach ($columns as $aid => $col) {
|
||||
$key = (string)$aid;
|
||||
$data = $this->_get_auth_row($auth_data, $aid);
|
||||
$checked = !empty($data['module'][$mid]['show']) ? ' checked' : '';
|
||||
$tbody .= '<td class="fc-auth-col">'
|
||||
.'<input type="checkbox" class="fc-auth-check" name="data['.htmlspecialchars($key).'][module]['.htmlspecialchars($mid).'][show]" value="1"'.$checked.' />'
|
||||
.'</td>';
|
||||
}
|
||||
$tbody .= '</tr>';
|
||||
$tbody .= '<tr><td class="fc-auth-name">'.dr_lang('禁止搜索').'</td>';
|
||||
foreach ($columns as $aid => $col) {
|
||||
$key = (string)$aid;
|
||||
$data = $this->_get_auth_row($auth_data, $aid);
|
||||
$checked = !empty($data['module'][$mid]['search']) ? ' checked' : '';
|
||||
$tbody .= '<td class="fc-auth-col">'
|
||||
.'<input type="checkbox" class="fc-auth-check" name="data['.htmlspecialchars($key).'][module]['.htmlspecialchars($mid).'][search]" value="1"'.$checked.' />'
|
||||
.'</td>';
|
||||
}
|
||||
$tbody .= '</tr>';
|
||||
if (empty($m['share'])) {
|
||||
$tbody .= $this->_auth_category_row($columns, $mid);
|
||||
}
|
||||
$mod_html .= $this->_auth_matrix_wrap($this->_auth_thead_html($columns), $tbody);
|
||||
if (!empty($m['share'])) {
|
||||
$mod_html .= '<p class="help-block" style="margin-top:12px;">'
|
||||
.dr_lang('本模块使用共享栏目,请到「整站」中设置栏目权限')
|
||||
.'</p>';
|
||||
}
|
||||
}
|
||||
$tabs[$mid] = [
|
||||
'id' => $mid,
|
||||
'name' => $mname,
|
||||
'dirname' => $mid,
|
||||
'icon' => $icon,
|
||||
'html' => $mod_html,
|
||||
];
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'内容权限' => ['cms/auth/index', 'fa fa-table'],
|
||||
'help' => [801],
|
||||
]
|
||||
),
|
||||
'auth_type' => $auth_type,
|
||||
'page' => $page,
|
||||
'tabs' => $tabs,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('auth_index.html');
|
||||
}
|
||||
|
||||
// 存储模式值
|
||||
public function save_edit() {
|
||||
|
||||
$value = intval(\Phpcmf\Service::L('input')->get('value'));
|
||||
if (!$value) {
|
||||
$msg = dr_lang('已切换至按全局配置模式');
|
||||
} elseif ($value == 1) {
|
||||
$msg = dr_lang('已切换至按用户组配置模式');
|
||||
} elseif ($value == 2) {
|
||||
$msg = dr_lang('已切换至按用户组等级配置模式');
|
||||
} else {
|
||||
$this->_json(0, dr_lang('未知模式'));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth_type',
|
||||
'value' => $value
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
|
||||
$this->_json(1, $msg);
|
||||
}
|
||||
|
||||
// 初始化组权限(仅清空内容相关配置,保留用户权限)
|
||||
public function init_edit() {
|
||||
|
||||
$v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
|
||||
$aid = \Phpcmf\Service::L('input')->get('aid');
|
||||
if ($aid === null || $aid === false || $aid === '') {
|
||||
$this->_json(0, dr_lang('参数错误'));
|
||||
}
|
||||
if ($aid !== 'public' && $aid !== '0' && $aid !== 0
|
||||
&& !preg_match('/^\d+(-\d+)?$/', (string)$aid)) {
|
||||
$this->_json(0, dr_lang('参数错误'));
|
||||
}
|
||||
$value = $v ? dr_string2array($v['value']) : [];
|
||||
if (!is_array($value)) {
|
||||
$value = [];
|
||||
}
|
||||
$old = isset($value[SITE_ID][$aid]) && is_array($value[SITE_ID][$aid]) ? $value[SITE_ID][$aid] : [];
|
||||
if (!$old && is_numeric($aid) && isset($value[SITE_ID][intval($aid)]) && is_array($value[SITE_ID][intval($aid)])) {
|
||||
$old = $value[SITE_ID][intval($aid)];
|
||||
}
|
||||
$keep = [];
|
||||
if (isset($old['member'])) {
|
||||
$keep['member'] = $old['member'];
|
||||
}
|
||||
if (isset($old['app'])) {
|
||||
$keep['app'] = $old['app'];
|
||||
}
|
||||
$value[SITE_ID][$aid] = $keep;
|
||||
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth2',
|
||||
'value' => dr_array2string($value)
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
|
||||
$this->_json(1, dr_lang('本组内容权限初始化完成'));
|
||||
}
|
||||
|
||||
// 栏目等详细权限设置
|
||||
public function add() {
|
||||
|
||||
$aid = \Phpcmf\Service::L('input')->get('aid');
|
||||
if ($aid == 'public') {
|
||||
$name = dr_lang('全局');
|
||||
} elseif (!$aid && $aid !== '0' && $aid !== 0) {
|
||||
$aid = 0;
|
||||
$name = dr_lang('游客');
|
||||
} elseif (strpos((string)$aid, '-') !== false) {
|
||||
list($gid, $lid) = explode('-', $aid);
|
||||
if (!$this->member_cache['group'][$gid]) {
|
||||
$this->_admin_msg(0, dr_lang('此用户组不存在'));
|
||||
} elseif (!$this->member_cache['group'][$gid]['level'][$lid]) {
|
||||
$this->_admin_msg(0, dr_lang('此用户组等级不存在'));
|
||||
}
|
||||
$name = $this->member_cache['group'][$gid]['name'].'-'.$this->member_cache['group'][$gid]['level'][$lid]['name'];
|
||||
} else {
|
||||
if ($aid !== '0' && $aid !== 0 && !$this->member_cache['group'][$aid]) {
|
||||
$this->_admin_msg(0, dr_lang('此用户组不存在'));
|
||||
}
|
||||
$name = ($aid === '0' || $aid === 0) ? dr_lang('游客') : $this->member_cache['group'][$aid]['name'];
|
||||
}
|
||||
|
||||
// 共享栏目
|
||||
$share_module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share');
|
||||
$share_categroy = [];
|
||||
if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
|
||||
$share_module['category'] = \Phpcmf\Service::L('category', 'module')->get_category('share');
|
||||
}
|
||||
if ($share_module['category']) {
|
||||
foreach ($share_module['category'] as $t) {
|
||||
if ($t['tid'] != 2) {
|
||||
$t['is_post'] = 0;
|
||||
if (!$t['child'] && $t['tid'] == 1) {
|
||||
$t['is_post'] = 1;
|
||||
}
|
||||
$share_categroy[$t['id']] = $t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 模块部分
|
||||
$module = $this->_content_modules();
|
||||
if ($module) {
|
||||
foreach ($module as $dir => $t) {
|
||||
if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
|
||||
$module[$dir]['category'] = \Phpcmf\Service::L('tree', 'module')
|
||||
->init(\Phpcmf\Service::L('category', 'module')->get_category($dir))
|
||||
->html_icon()->get_tree_array(0);
|
||||
} else {
|
||||
$module[$dir]['category'] = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir, 'category');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
|
||||
$value = $v ? dr_string2array($v['value']) : [];
|
||||
if (!is_array($value)) {
|
||||
$value = [];
|
||||
}
|
||||
$data = isset($value[SITE_ID][$aid]) && is_array($value[SITE_ID][$aid]) ? $value[SITE_ID][$aid] : [];
|
||||
$auth = [
|
||||
'share_category' => is_array($data['share_category_public'] ?? null) ? $data['share_category_public'] : [],
|
||||
'category' => is_array($data['category_public'] ?? null) ? $data['category_public'] : [],
|
||||
];
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
if (!is_array($post)) {
|
||||
$post = [];
|
||||
}
|
||||
$save = $data;
|
||||
|
||||
// 栏目模式与统一栏目权限
|
||||
if (isset($post['home']['is_category'])) {
|
||||
if (!isset($save['home']) || !is_array($save['home'])) {
|
||||
$save['home'] = [];
|
||||
}
|
||||
$save['home']['is_category'] = empty($post['home']['is_category']) ? 0 : 1;
|
||||
}
|
||||
$share_public = \Phpcmf\Service::L('input')->post('share_category');
|
||||
if (is_array($share_public)) {
|
||||
$save['share_category_public'] = $this->_normalize_category_auth_flags($share_public);
|
||||
}
|
||||
$cat_public = \Phpcmf\Service::L('input')->post('category');
|
||||
if (is_array($cat_public)) {
|
||||
if (!isset($save['category_public']) || !is_array($save['category_public'])) {
|
||||
$save['category_public'] = [];
|
||||
}
|
||||
foreach ($cat_public as $cmid => $crow) {
|
||||
// 模板里的 hidden test 字段不算权限配置
|
||||
if (!is_array($crow) || (dr_count($crow) === 1 && isset($crow['test']))) {
|
||||
continue;
|
||||
}
|
||||
$save['category_public'][$cmid] = $this->_normalize_category_auth_flags($crow);
|
||||
}
|
||||
}
|
||||
if (isset($post['module']) && is_array($post['module'])) {
|
||||
if (!isset($save['module']) || !is_array($save['module'])) {
|
||||
$save['module'] = [];
|
||||
}
|
||||
foreach ($post['module'] as $mid => $row) {
|
||||
if (!isset($save['module'][$mid]) || !is_array($save['module'][$mid])) {
|
||||
$save['module'][$mid] = [];
|
||||
}
|
||||
if (isset($row['is_category'])) {
|
||||
$save['module'][$mid]['is_category'] = empty($row['is_category']) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 保留用户权限 / 应用权限 / 访问禁止项 / 按栏目独立设置
|
||||
if (isset($data['member'])) {
|
||||
$save['member'] = $data['member'];
|
||||
}
|
||||
if (isset($data['app'])) {
|
||||
$save['app'] = $data['app'];
|
||||
}
|
||||
if (isset($data['home']['show'])) {
|
||||
if (!isset($save['home']) || !is_array($save['home'])) {
|
||||
$save['home'] = [];
|
||||
}
|
||||
$save['home']['show'] = $data['home']['show'];
|
||||
}
|
||||
if (isset($data['module']) && is_array($data['module'])) {
|
||||
foreach ($data['module'] as $mid => $row) {
|
||||
if (!isset($save['module'][$mid]) || !is_array($save['module'][$mid])) {
|
||||
$save['module'][$mid] = [];
|
||||
}
|
||||
if (isset($row['show'])) {
|
||||
$save['module'][$mid]['show'] = $row['show'];
|
||||
}
|
||||
if (isset($row['search'])) {
|
||||
$save['module'][$mid]['search'] = $row['search'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($data['share_category'])) {
|
||||
$save['share_category'] = $data['share_category'];
|
||||
}
|
||||
if (isset($data['category'])) {
|
||||
$save['category'] = $data['category'];
|
||||
}
|
||||
|
||||
$value[SITE_ID][$aid] = $save;
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth2',
|
||||
'value' => dr_array2string($value)
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = trim(\Phpcmf\Service::L('input')->get('page'));
|
||||
if (!$page) {
|
||||
$page = 'cms';
|
||||
}
|
||||
|
||||
// 弹窗只展示当前入口对应的栏目(共享 / 单个模块)
|
||||
$is_share_page = ($page === 'cms' || $page === 'site');
|
||||
$mid = '';
|
||||
$m = [];
|
||||
if ($is_share_page) {
|
||||
$page = 'cms';
|
||||
$page_name = dr_lang('共享栏目');
|
||||
} elseif (isset($module[$page])) {
|
||||
$mid = $page;
|
||||
$m = $module[$page];
|
||||
$page_name = dr_lang($m['name']);
|
||||
// 共享型模块无独立栏目,回退到共享栏目
|
||||
if (!empty($m['share'])) {
|
||||
$is_share_page = true;
|
||||
$page = 'cms';
|
||||
$mid = '';
|
||||
$m = [];
|
||||
$page_name = dr_lang('共享栏目');
|
||||
}
|
||||
} else {
|
||||
$this->_admin_msg(0, dr_lang('模块不存在'));
|
||||
}
|
||||
|
||||
$verify = [];
|
||||
if (\Phpcmf\Service::M()->is_table_exists('admin_verify')) {
|
||||
$verify = \Phpcmf\Service::M()->table('admin_verify')->getAll();
|
||||
}
|
||||
|
||||
$diy = $this->_get_diy();
|
||||
if ($is_share_page) {
|
||||
$diy['module'] = [];
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'aid' => $aid,
|
||||
'diy' => $diy,
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
dr_lang('%s:%s栏目权限', $name, $page_name) => ['cms/auth/add{aid='.$aid.'&page='.$page.'}', 'fa fa-table'],
|
||||
'help' => [801],
|
||||
]
|
||||
),
|
||||
'page' => $page,
|
||||
'page_name' => $page_name,
|
||||
'is_share_page' => $is_share_page,
|
||||
'mid' => $mid,
|
||||
'm' => $m,
|
||||
'data' => $data,
|
||||
'auth' => $auth,
|
||||
'verify' => $verify,
|
||||
'is_ajax_edit' => 0,
|
||||
'share_categroy' => \Phpcmf\Service::L('tree')->init($share_categroy)->html_icon()->get_tree_array(0),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('auth_setting.html');
|
||||
}
|
||||
|
||||
// 弹出设置单独权限
|
||||
public function edit() {
|
||||
|
||||
$at = dr_safe_filename(\Phpcmf\Service::L('input')->get('at'));
|
||||
if (!$at || !in_array($at, ['share_category', 'category'])) {
|
||||
$this->_json(0, dr_lang('at参数错误'));
|
||||
}
|
||||
|
||||
$v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
|
||||
$aid = \Phpcmf\Service::L('input')->get('aid');
|
||||
!$aid && $aid !== '0' && $aid = 0;
|
||||
$value = $v ? dr_string2array($v['value']) : [];
|
||||
if (!is_array($value)) {
|
||||
$value = [];
|
||||
}
|
||||
|
||||
$id = intval(\Phpcmf\Service::L('input')->get('id'));
|
||||
if (!$id) {
|
||||
$this->_json(0, dr_lang('id参数错误'));
|
||||
}
|
||||
|
||||
$mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
if ($at == 'category') {
|
||||
$post = \Phpcmf\Service::L('input')->post($at);
|
||||
$row = is_array($post[$mid] ?? null) ? $post[$mid] : [];
|
||||
$value[SITE_ID][$aid][$at][$mid][$id] = $this->_normalize_category_auth_flags($row);
|
||||
} else {
|
||||
$row = \Phpcmf\Service::L('input')->post($at);
|
||||
$value[SITE_ID][$aid][$at][$id] = $this->_normalize_category_auth_flags($row);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth2',
|
||||
'value' => dr_array2string($value)
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
if ($at == 'category') {
|
||||
$auth = [$at => [$mid => $value[SITE_ID][$aid][$at][$mid][$id]]];
|
||||
} else {
|
||||
$auth = [$at => $value[SITE_ID][$aid][$at][$id]];
|
||||
}
|
||||
|
||||
$verify = [];
|
||||
if (\Phpcmf\Service::M()->is_table_exists('admin_verify')) {
|
||||
$verify = \Phpcmf\Service::M()->table('admin_verify')->getAll();
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'mid' => $mid,
|
||||
'diy' => $this->_get_diy(),
|
||||
'auth' => $auth,
|
||||
'verify' => $verify,
|
||||
'is_ajax_edit' => 1,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('auth_'.$at.'.html');
|
||||
}
|
||||
|
||||
// 复制动作
|
||||
public function copy_edit() {
|
||||
|
||||
$id = intval(\Phpcmf\Service::L('input')->get('id'));
|
||||
$at = dr_safe_filename(\Phpcmf\Service::L('input')->get('at'));
|
||||
if (!$at) {
|
||||
$this->_json(0, dr_lang('at参数错误'));
|
||||
}
|
||||
|
||||
$v = \Phpcmf\Service::M()->db->table('member_setting')->where('name', 'auth2')->get()->getRowArray();
|
||||
$aid = \Phpcmf\Service::L('input')->get('aid');
|
||||
!$aid && $aid !== '0' && $aid = 0;
|
||||
$value = $v ? dr_string2array($v['value']) : [];
|
||||
if (!is_array($value)) {
|
||||
$value = [];
|
||||
}
|
||||
|
||||
switch ($at) {
|
||||
|
||||
case 'level':
|
||||
case 'group':
|
||||
$group = [
|
||||
0 => [
|
||||
'id' => 0,
|
||||
'name' => dr_lang('游客'),
|
||||
],
|
||||
];
|
||||
foreach ($this->member_cache['group'] as $t) {
|
||||
if ($at == 'level') {
|
||||
$group[$t['id']] = [
|
||||
'id' => $t['id'],
|
||||
'name' => dr_lang($t['name']),
|
||||
];
|
||||
if ($t['level']) {
|
||||
foreach ($t['level'] as $lv) {
|
||||
$group[$t['id'].'-'.$lv['id']] = [
|
||||
'id' => $t['id'].'-'.$lv['id'],
|
||||
'name' => ' └ '.dr_lang($lv['name']),
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$group[$t['id']] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$auth = $value[SITE_ID][$aid];
|
||||
if (!$auth) {
|
||||
$this->_json(0, dr_lang('当前用户组没有配置权限规则'));
|
||||
}
|
||||
|
||||
$catids = \Phpcmf\Service::L('input')->post('catid');
|
||||
if (!$catids) {
|
||||
$this->_json(0, dr_lang('你还没有选择用户组呢'));
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
if (isset($catids[0]) && $catids[0] == 0) {
|
||||
foreach ($group as $gid => $t) {
|
||||
$c++;
|
||||
$value[SITE_ID][$gid] = $auth;
|
||||
}
|
||||
} else {
|
||||
foreach ($catids as $gid) {
|
||||
$c++;
|
||||
$value[SITE_ID][$gid] = $auth;
|
||||
}
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth2',
|
||||
'value' => dr_array2string($value)
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
$this->_json(1, dr_lang('共复制%s个用户组', $c));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'form' => dr_form_hidden(),
|
||||
'select' => \Phpcmf\Service::L('tree')->select_category(
|
||||
$group,
|
||||
0,
|
||||
'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" style="height:200px"',
|
||||
'',
|
||||
0,
|
||||
0
|
||||
),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('auth_copy_group.html');exit;
|
||||
|
||||
case 'share_category':
|
||||
$share_module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share');
|
||||
if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
|
||||
$share_module['category'] = \Phpcmf\Service::L('category', 'module')->get_category('share');
|
||||
}
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$auth = $value[SITE_ID][$aid]['share_category'][$id];
|
||||
if (!$auth) {
|
||||
$this->_json(0, dr_lang('当前栏目没有配置权限规则'));
|
||||
}
|
||||
|
||||
$catids = \Phpcmf\Service::L('input')->post('catid');
|
||||
if (!$catids) {
|
||||
$this->_json(0, dr_lang('你还没有选择栏目呢'));
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
if (isset($catids[0]) && $catids[0] == 0) {
|
||||
foreach ($share_module['category'] as $cid => $t) {
|
||||
$c++;
|
||||
$value[SITE_ID][$aid]['share_category'][$cid] = $auth;
|
||||
}
|
||||
} else {
|
||||
foreach ($catids as $cid) {
|
||||
$c++;
|
||||
$value[SITE_ID][$aid]['share_category'][$cid] = $auth;
|
||||
}
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth2',
|
||||
'value' => dr_array2string($value)
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
$this->_json(1, dr_lang('共复制%s个栏目', $c));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'form' => dr_form_hidden(),
|
||||
'select' => \Phpcmf\Service::L('tree')->select_category(
|
||||
$share_module['category'],
|
||||
0,
|
||||
'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" style="height:200px"',
|
||||
dr_lang('全部栏目'),
|
||||
0,
|
||||
0
|
||||
),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('auth_copy_category.html');exit;
|
||||
|
||||
case 'category':
|
||||
$mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$mid);
|
||||
if (is_file(dr_get_app_dir('module').'Libraries/Category.php')) {
|
||||
$module['category'] = \Phpcmf\Service::L('category', 'module')->get_category($mid);
|
||||
}
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$auth = $value[SITE_ID][$aid]['category'][$mid][$id];
|
||||
if (!$auth) {
|
||||
$this->_json(0, dr_lang('当前栏目没有配置权限规则'));
|
||||
}
|
||||
|
||||
$catids = \Phpcmf\Service::L('input')->post('catid');
|
||||
if (!$catids) {
|
||||
$this->_json(0, dr_lang('你还没有选择栏目呢'));
|
||||
}
|
||||
|
||||
$c = 0;
|
||||
if (isset($catids[0]) && $catids[0] == 0) {
|
||||
foreach ($module['category'] as $cid => $t) {
|
||||
$c++;
|
||||
$value[SITE_ID][$aid]['category'][$mid][$cid] = $auth;
|
||||
}
|
||||
} else {
|
||||
foreach ($catids as $cid) {
|
||||
$c++;
|
||||
$value[SITE_ID][$aid]['category'][$mid][$cid] = $auth;
|
||||
}
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M()->db->table('member_setting')->replace([
|
||||
'name' => 'auth2',
|
||||
'value' => dr_array2string($value)
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('member');
|
||||
$this->_json(1, dr_lang('共复制%s个栏目', $c));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'form' => dr_form_hidden(),
|
||||
'select' => \Phpcmf\Service::L('category', 'module')->select(
|
||||
$module['mid'],
|
||||
0,
|
||||
'id=\'dr_catid\' name=\'catid[]\' multiple="multiple" style="height:200px"',
|
||||
dr_lang('全部栏目'),
|
||||
0,
|
||||
0
|
||||
),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('auth_copy_category.html');exit;
|
||||
}
|
||||
|
||||
$this->_json(0, dr_lang('未知类型'));
|
||||
}
|
||||
|
||||
private function _get_diy() {
|
||||
|
||||
$diy = [
|
||||
'module' => [],
|
||||
'category' => [],
|
||||
];
|
||||
|
||||
$local = \Phpcmf\Service::Apps(1);
|
||||
foreach ($local as $dir => $path) {
|
||||
if (is_file($path.'Config/Auth.php')) {
|
||||
$_data = require $path.'Config/Auth.php';
|
||||
if ($_data) {
|
||||
foreach ($_data as $key => $val) {
|
||||
if ($val && isset($diy[$key])) {
|
||||
foreach ($val as $file) {
|
||||
if (is_file($path.'Views/auth/'.$file)) {
|
||||
$diy[$key][] = [
|
||||
'app' => $dir,
|
||||
'file' => $path.'Views/auth/'.$file,
|
||||
];
|
||||
} else {
|
||||
log_message('error', '应用插件['.$dir.']权限模板文件不存在:'.$path.'Views/auth/'.$file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $diy;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Field extends \Phpcmf\Common {
|
||||
|
||||
public function index() {
|
||||
|
||||
$list = [];
|
||||
$local = \Phpcmf\Service::Apps();
|
||||
foreach ($local as $dir => $path) {
|
||||
if (is_file(dr_get_app_dir($dir).'Config/App.php')) {
|
||||
$key = strtolower($dir);
|
||||
$cfg = require dr_get_app_dir($dir).'Config/App.php';
|
||||
if ($cfg['type'] == 'module' || $cfg['ftype'] == 'module') {
|
||||
if (isset($cfg['hlist']) && $cfg['hlist']) {
|
||||
// 不在列表显示
|
||||
continue;
|
||||
}
|
||||
$cfg['dirname'] = $key;
|
||||
$list[$key] = $cfg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$my = [];
|
||||
$module = \Phpcmf\Service::M('Module')->All(); // 库中已安装模块
|
||||
if ($module) {
|
||||
foreach ($module as $t) {
|
||||
$dir = $t['dirname'];
|
||||
if ($list[$dir]) {
|
||||
$t['name'] = dr_lang($list[$dir]['name']);
|
||||
$t['mtype'] = $list[$dir]['mtype'];
|
||||
$t['system'] = $list[$dir]['system'];
|
||||
$t['version'] = $list[$dir]['version'];
|
||||
$site = dr_string2array($t['site']);
|
||||
$t['install'] = isset($site[SITE_ID]) && $site[SITE_ID] ? 1 : 0;
|
||||
$my[$dir] = $t;
|
||||
unset($list[$dir]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'my' => $my,
|
||||
'list' => $list,
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'自定义字段' => [APP_DIR.'/field/index', 'fa fa-code'],
|
||||
]
|
||||
),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('field.html');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
// 操作指南
|
||||
class Help extends \Phpcmf\Common {
|
||||
|
||||
public function index() {
|
||||
|
||||
$page = max(0, (int)\Phpcmf\Service::L('input')->get('page'));
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
|
||||
'基础操作' => [APP_DIR.'/help/index', 'fa fa-book'],
|
||||
]),
|
||||
'title' => dr_lang('建站系统 - 基础操作'),
|
||||
'page' => $page,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('help_index.html');
|
||||
}
|
||||
|
||||
public function template() {
|
||||
|
||||
$page = max(0, (int)\Phpcmf\Service::L('input')->get('page'));
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
|
||||
'模板制作' => [APP_DIR.'/help/template', 'fa fa-code'],
|
||||
]),
|
||||
'title' => dr_lang('建站系统 - 模板制作'),
|
||||
'page' => $page,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('help_template.html');
|
||||
}
|
||||
|
||||
public function seo() {
|
||||
|
||||
$page = max(0, (int)\Phpcmf\Service::L('input')->get('page'));
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
|
||||
'SEO用法' => [APP_DIR.'/help/seo', 'fa fa-internet-explorer'],
|
||||
]),
|
||||
'title' => dr_lang('建站系统 - SEO用法'),
|
||||
'page' => $page,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('help_seo.html');
|
||||
}
|
||||
|
||||
public function url() {
|
||||
|
||||
$page = max(0, (int)\Phpcmf\Service::L('input')->get('page'));
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
|
||||
'自定义URL用法' => [APP_DIR.'/help/url', 'fa fa-link'],
|
||||
]),
|
||||
'title' => dr_lang('建站系统 - 自定义URL用法'),
|
||||
'page' => $page,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('help_url.html');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
class Module extends \Phpcmf\Common {
|
||||
|
||||
private $dir;
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
|
||||
$menu = [
|
||||
'内容模块' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-cogs'],
|
||||
'创建模块' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'_create/index', 'fa fa-plus'],
|
||||
'模块配置' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-cog'],
|
||||
'推荐位配置' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/flag_edit', 'fa fa-flag'],
|
||||
'help' => [57]
|
||||
];
|
||||
if (!IS_DEV) {
|
||||
unset($menu['创建模块']);
|
||||
}
|
||||
if (strpos(\Phpcmf\Service::L('Router')->method, 'flag') !== false) {
|
||||
$menu['help'] = [440];
|
||||
} elseif (strpos(\Phpcmf\Service::L('Router')->method, 'edit') !== false) {
|
||||
$menu['help'] = [1040];
|
||||
}
|
||||
\Phpcmf\Service::V()->assign('menu', \Phpcmf\Service::M('auth')->_admin_menu($menu));
|
||||
}
|
||||
|
||||
// 安装模块
|
||||
public function install() {
|
||||
|
||||
$dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
|
||||
$type = (int)\Phpcmf\Service::L('input')->get('type');
|
||||
|
||||
if (!preg_match('/^[a-z]+$/U', $dir)) {
|
||||
$this->_json(0, dr_lang('模块目录[%s]格式不正确', $dir));
|
||||
} elseif (\Phpcmf\Service::M('app')->is_sys_dir($dir)) {
|
||||
$this->_json(0, dr_lang('模块目录[%s]名称是系统保留名称,请重命名', $dir));
|
||||
}
|
||||
|
||||
$path = dr_get_app_dir($dir);
|
||||
if (!is_dir($path)) {
|
||||
$this->_json(0, dr_lang('模块目录[%s]不存在', $path));
|
||||
}
|
||||
|
||||
// 对当前模块属性判断
|
||||
$cfg = require $path.'Config/App.php';
|
||||
if (!$cfg) {
|
||||
$this->_json(0, dr_lang('文件[%s]不存在', 'App/'.ucfirst($dir).'/Config/App.php'));
|
||||
}
|
||||
|
||||
$cfg['share'] = $type ? 0 : 1;
|
||||
|
||||
$rt = \Phpcmf\Service::M('module')->install($dir, $cfg);
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
$this->_json($rt['code'], $rt['msg'], $rt['data']);
|
||||
}
|
||||
|
||||
// 卸载模块
|
||||
public function uninstall() {
|
||||
|
||||
$dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
|
||||
if (!preg_match('/^[a-z]+$/U', $dir)) {
|
||||
$this->_json(0, dr_lang('模块目录[%s]格式不正确', $dir));
|
||||
}
|
||||
|
||||
$path = dr_get_app_dir($dir);
|
||||
if (!is_dir($path)) {
|
||||
$this->_json(0, dr_lang('模块目录[%s]不存在', $path));
|
||||
}
|
||||
|
||||
$cfg = require $path.'Config/App.php';
|
||||
if (!$cfg) {
|
||||
$this->_json(0, dr_lang('文件[%s]不存在', 'App/'.ucfirst($dir).'/Config/App.php'));
|
||||
}
|
||||
|
||||
$rt = \Phpcmf\Service::M('Module')->uninstall($dir, $cfg);
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
$this->_json($rt['code'], $rt['msg']);
|
||||
|
||||
}
|
||||
|
||||
// 模块管理
|
||||
public function index() {
|
||||
|
||||
$list = [];
|
||||
$local = \Phpcmf\Service::Apps();
|
||||
foreach ($local as $dir => $path) {
|
||||
if (is_file(dr_get_app_dir($dir).'Config/App.php')) {
|
||||
$key = strtolower($dir);
|
||||
$cfg = require dr_get_app_dir($dir).'Config/App.php';
|
||||
if ($cfg['type'] == 'module' || $cfg['ftype'] == 'module') {
|
||||
if (isset($cfg['hlist']) && $cfg['hlist']) {
|
||||
// 不在列表显示
|
||||
continue;
|
||||
}
|
||||
$cfg['dirname'] = $key;
|
||||
$list[$key] = $cfg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$my = [];
|
||||
$module = \Phpcmf\Service::M('Module')->All(); // 库中已安装模块
|
||||
if ($module) {
|
||||
foreach ($module as $t) {
|
||||
$dir = $t['dirname'];
|
||||
if ($list[$dir]) {
|
||||
$t['name'] = dr_lang($list[$dir]['name']);
|
||||
$t['mtype'] = $list[$dir]['mtype'];
|
||||
$t['system'] = $list[$dir]['system'];
|
||||
$t['version'] = $list[$dir]['version'];
|
||||
$site = dr_string2array($t['site']);
|
||||
$t['install'] = isset($site[SITE_ID]) && $site[SITE_ID] ? 1 : 0;
|
||||
$my[$dir] = $t;
|
||||
unset($list[$dir]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'my' => $my,
|
||||
'list' => $list,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('module_list.html');
|
||||
}
|
||||
|
||||
// 重命名
|
||||
public function name_edit() {
|
||||
|
||||
$mid = dr_safe_filename($_GET['dir']);
|
||||
$file = dr_get_app_dir($mid).'Config/App.php';
|
||||
if (!is_file($file)) {
|
||||
$this->_json(0, dr_lang('当前模块配置文件不存在'));
|
||||
}
|
||||
|
||||
$config = require $file;
|
||||
|
||||
if (IS_POST) {
|
||||
|
||||
$data = \Phpcmf\Service::L('input')->post('data');
|
||||
|
||||
// 参数判断
|
||||
if (!$data['name']) {
|
||||
$this->_json(0, dr_lang('名称不能为空'), ['field' => 'name']);
|
||||
} elseif (!$data['icon']) {
|
||||
$this->_json(0, dr_lang('模块图标不能为空'), ['field' => 'icon']);
|
||||
} elseif (!dr_check_put_path(dirname($file))) {
|
||||
$this->_json(0, dr_lang('目录[%s]没有创建文件权限', dirname($file)), ['field' => 'dirname']);
|
||||
}
|
||||
|
||||
$old = $config['name'];
|
||||
$config['name'] = dr_safe_filename($data['name']);
|
||||
$config['icon'] = dr_safe_replace($data['icon']);
|
||||
file_put_contents($file, '<?php return '.var_export($config, true).';');
|
||||
|
||||
// 变更菜单
|
||||
\Phpcmf\Service::M('menu', 'module')->update_module_name($mid, $old, $config['name'], $config['icon']);
|
||||
|
||||
// 重置Zend OPcache
|
||||
function_exists('opcache_reset') && opcache_reset();
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
|
||||
\Phpcmf\Service::L('input')->system_log('模块['.$mid.']名称变更');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'form' => dr_form_hidden(),
|
||||
'config' => $config,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('module_name_edit.html');exit;
|
||||
}
|
||||
|
||||
// 排序
|
||||
public function displayorder_edit() {
|
||||
|
||||
// 查询数据
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
$row = \Phpcmf\Service::M('Module')->table('module')->get($id);
|
||||
if (!$row) {
|
||||
$this->_json(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
|
||||
$value = (int)\Phpcmf\Service::L('input')->get('value');
|
||||
$rt = \Phpcmf\Service::M('Module')->table('module')->save($id, 'displayorder', $value);
|
||||
if (!$rt['code']) {
|
||||
$this->_json(0, $rt['msg']);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
\Phpcmf\Service::L('input')->system_log('修改模块('.$row['dirname'].')的排序值为'.$value);
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
// 隐藏或者启用
|
||||
public function hidden_edit() {
|
||||
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
$row = \Phpcmf\Service::M('Module')->table('module')->get($id);
|
||||
if (!$row) {
|
||||
$this->_json(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
|
||||
$v = $row['disabled'] ? 0 : 1;
|
||||
\Phpcmf\Service::M('Module')->table('module')->update($id, ['disabled' => $v]);
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
$this->_json(1, dr_lang($v ? '模块已被禁用' : '模块已被启用'), ['value' => $v]);
|
||||
}
|
||||
|
||||
// 模块配置
|
||||
public function edit() {
|
||||
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
if ($this->dir) {
|
||||
$data = \Phpcmf\Service::M()->table('module')->where('dirname', $this->dir)->getRow();
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
$id = $data['id'];
|
||||
} else {
|
||||
$data = \Phpcmf\Service::M()->table('module')->get($id);
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
}
|
||||
|
||||
// 格式转换
|
||||
$data['site'] = dr_string2array($data['site']);
|
||||
$data['setting'] = dr_string2array($data['setting']);
|
||||
|
||||
// 判断站点
|
||||
if (!$data['site'][SITE_ID]) {
|
||||
$this->_admin_msg(0, dr_lang('当前站点尚未安装'));
|
||||
}
|
||||
|
||||
// 主表字段
|
||||
$field = \Phpcmf\Service::M()->db->table('field')
|
||||
->where('disabled', 0)
|
||||
->where('ismain', 1)
|
||||
->where('relatedname', 'module')
|
||||
->where('relatedid', $id)
|
||||
->orderBy('displayorder ASC,id ASC')
|
||||
->get()->getResultArray();
|
||||
$sys_field = \Phpcmf\Service::L('Field')->sys_field(['id', 'catid', 'uid', 'inputtime', 'inputip', 'updatetime', 'hits', 'displayorder']);
|
||||
$field = dr_list_field_value($data['setting']['list_field'], $sys_field, $field);
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$this->init_file($data['dirname']);
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
if ($post['setting']['list_field']) {
|
||||
foreach ($post['setting']['list_field'] as $t) {
|
||||
if ($t['func']) {
|
||||
if (method_exists(\Phpcmf\Service::L('Function_list'), $t['func'])) {
|
||||
} elseif (!function_exists($t['func'])) {
|
||||
$this->_json(0, dr_lang('列表回调函数[%s]未定义', $t['func']));
|
||||
} elseif (strpos($t['func'], 'dr_') === false && strpos($t['func'], 'my_') === false) {
|
||||
$this->_json(0, '函数【'.$t['func'].'】必须以dr_或者my_开头');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($post['setting']['search_time'] && !isset($field[$post['setting']['search_time']])) {
|
||||
$this->_json(0, dr_lang('后台列表时间搜索字段%s不存在', $post['setting']['search_time']));
|
||||
}
|
||||
if ($post['setting']['order']) {
|
||||
if (strpos($post['setting']['order'], '(') or strpos($post['setting']['order'], ')')) {
|
||||
$this->_json(0, dr_lang('后台列表的默认排序字段不允许特殊符号'));
|
||||
}
|
||||
$arr = explode(',', trim($post['setting']['order']));
|
||||
foreach ($arr as $t) {
|
||||
list($a) = explode(' ', trim($t));
|
||||
if ($a && !isset($field[$a])) {
|
||||
$this->_json(0, dr_lang('后台列表的默认排序字段%s不存在', $a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rt = \Phpcmf\Service::M('Module')->config($data, $post);
|
||||
if ($rt['code']) {
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
$this->_json(1, '操作成功');
|
||||
} else {
|
||||
$this->_json(0, $rt['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
$config = require dr_get_app_dir($data['dirname']).'Config/App.php';
|
||||
|
||||
if (!$data['site'][SITE_ID]['title']) {
|
||||
$data['site'][SITE_ID]['title'] = $config['name'];
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'data' => $data,
|
||||
'site' => $data['site'][SITE_ID],
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'field' => $field,
|
||||
'is_hcategory' => isset($config['hcategory']) && $config['hcategory'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('module_edit.html');
|
||||
}
|
||||
|
||||
// 推荐位
|
||||
public function flag_edit() {
|
||||
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
if ($this->dir) {
|
||||
$data = \Phpcmf\Service::M()->table('module')->where('dirname', $this->dir)->getRow();
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
} else {
|
||||
$data = \Phpcmf\Service::M()->table('module')->get($id);
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
}
|
||||
|
||||
// 格式转换
|
||||
$data['setting'] = dr_string2array($data['setting']);
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$post = \Phpcmf\Service::L('input')->post('flag');
|
||||
if ($post) {
|
||||
$role = \Phpcmf\Service::L('input')->post('role');
|
||||
foreach ($post as $fid => $t) {
|
||||
$post[$fid]['role'] = [];
|
||||
if (isset($role[$fid]) && $role[$fid]) {
|
||||
foreach ($role[$fid] as $fid2 => $aid) {
|
||||
$post[$fid]['role'][$aid] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$rt = \Phpcmf\Service::M('Module')->config($data, null, [
|
||||
'flag' => $post,
|
||||
]);
|
||||
if ($rt['code']) {
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
$this->_json(1, '操作成功');
|
||||
} else {
|
||||
$this->_json(0, $rt['msg']);
|
||||
}
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'flag' => $data['setting']['flag'],
|
||||
'form' => dr_form_hidden(),
|
||||
'role' => \Phpcmf\Service::C()->get_cache('auth'),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('module_flag.html');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Module_category extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
$mid = \Phpcmf\Service::L('input')->get('dir');
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
|
||||
if (!$module) {
|
||||
$this->_admin_msg(0, dr_lang('系统没有安装内容模块'), dr_url('module/module/index'));
|
||||
}
|
||||
|
||||
$share = 0;
|
||||
|
||||
// 设置url
|
||||
foreach ($module as $dir => $t) {
|
||||
if ($t['share']) {
|
||||
$share = 1;
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
} elseif ($t['system'] == 2) {
|
||||
// 自定义菜单的
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
} elseif ($t['hcategory']) {
|
||||
// 禁止使用栏目
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
if ($mid && $mid != $dir) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
$module[$dir]['name'] = dr_lang('%s栏目', $t['name']);
|
||||
$module[$dir]['url'] = \Phpcmf\Service::L('Router')->url($dir.'/category/index');
|
||||
}
|
||||
|
||||
if ($share) {
|
||||
$tmp['share'] = [
|
||||
'name' => '共享栏目',
|
||||
'icon' => 'fa fa-share-alt',
|
||||
'title' => '共享',
|
||||
'url' => \Phpcmf\Service::L('Router')->url('category/index'),
|
||||
'dirname' => 'share',
|
||||
];
|
||||
$one = $tmp['share'];
|
||||
$module = dr_array22array($tmp, $module);
|
||||
} else {
|
||||
$one = reset($module);
|
||||
}
|
||||
|
||||
if (!$module) {
|
||||
$this->_admin_msg(0, dr_lang('系统没有可用内容模块'), dr_url('module/module/index'));
|
||||
}
|
||||
|
||||
// 只存在一个项目
|
||||
dr_count($module) == 1 && dr_redirect($one['url']);
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'url' => $one['url'],
|
||||
'menu' => \Phpcmf\Service::M('auth')->_iframe_menu($module, $one['dirname']),
|
||||
'module' => $module,
|
||||
'dirname' => $one['dirname'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('iframe_content.html');exit;
|
||||
}
|
||||
|
||||
public function field_index() {
|
||||
|
||||
$dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
|
||||
if (!$dir) {
|
||||
$this->_admin_msg(0, dr_lang('系统没有可用内容模块'));
|
||||
}
|
||||
|
||||
$module = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
|
||||
if (!$module) {
|
||||
$this->_admin_msg(0, dr_lang('数据#%s不存在', $dir));
|
||||
}
|
||||
|
||||
$list = [];
|
||||
|
||||
// 字段查询
|
||||
$mid = $dir;
|
||||
$like = ['catmodule-'.$dir];
|
||||
if ($module['share']) {
|
||||
$like[] = 'catmodule-share';
|
||||
$mid = 'share';
|
||||
}
|
||||
$setting = dr_string2array($module['setting']);
|
||||
$field = \Phpcmf\Service::M()->db->table('field')
|
||||
->where('ismain', 1)
|
||||
->where('disabled', 0)
|
||||
->whereIn('relatedname', $like)
|
||||
->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
|
||||
if ($field) {
|
||||
$module['category'] = $this->get_cache('module-'.SITE_ID.'-'.$dir, 'category');
|
||||
foreach ($field as $f) {
|
||||
/*
|
||||
$f['setting'] = dr_string2array($f['setting']);
|
||||
if ($f['relatedid']) {
|
||||
$f['setting']['diy']['cat_field_catids'][] = $f['relatedid'];
|
||||
}*/
|
||||
$catids = [];
|
||||
foreach ($module['category'] as $t) {
|
||||
if ($t['setting']['module_field'] && isset($t['setting']['module_field'][$f['fieldname']])) {
|
||||
$catids[] = $t['id'];
|
||||
}
|
||||
}
|
||||
$f['select'] = \Phpcmf\Service::L('Tree')->ismain(1)->select_category(
|
||||
$module['category'],
|
||||
$catids,
|
||||
'name=\'data['.$f['fieldname'].'][]\' multiple="multiple" data-actions-box="true"',
|
||||
'',
|
||||
0,
|
||||
0
|
||||
);
|
||||
$list[$f['id']] = $f;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_POST) {
|
||||
$setting['module_category_hide'] = (int)\Phpcmf\Service::L('input')->post('hide');
|
||||
\Phpcmf\Service::M()->table('module')->update($module['id'], ['setting' => dr_array2string($setting)]);
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
$table = $module['share'] ? 'share_category' : $module['dirname'].'_category';
|
||||
foreach ($module['category'] as $t) {
|
||||
//if ($t['ismain']) {
|
||||
$setting = dr_string2array($t['setting']);
|
||||
$setting['module_field'] = [];
|
||||
if ($post) {
|
||||
foreach ($post as $fname => $catids) {
|
||||
if (in_array($t['id'], $catids)) {
|
||||
$setting['module_field'][$fname] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
\Phpcmf\Service::M()->table_site($table)->update($t['id'], ['setting' => dr_array2string($setting)]);
|
||||
//}
|
||||
}
|
||||
// 自动更新缓存
|
||||
\Phpcmf\Service::M('cache')->sync_cache();
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'mid' => $mid,
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'内容模块' => ['module/module/index', 'fa fa-cogs'],
|
||||
'模块【'.$module['dirname'].'】栏目模型字段' => ['module/module_category/field_index{dir='.$dir.'}', 'fa fa-code', 'module_category/field_index'],
|
||||
'自定义字段' => ['url:'.\Phpcmf\Service::L('Router')->url('field/index', ['rname'=>'catmodule-'.$dir, 'rid'=>0]), 'fa fa-code', 'field/add'],
|
||||
'help' => [798],
|
||||
]
|
||||
),
|
||||
'list' => $list,
|
||||
'hide' => $setting['module_category_hide'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('module_category_field.html');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Module_create extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
// 创建模块
|
||||
public function index() {
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
if (!IS_DEV) {
|
||||
$this->_json(0, '禁止操作');
|
||||
}
|
||||
|
||||
$data = \Phpcmf\Service::L('input')->post('data');
|
||||
|
||||
// 参数判断
|
||||
if (!$data['name']) {
|
||||
$this->_json(0, dr_lang('名称不能为空'), ['field' => 'name']);
|
||||
} elseif (!$data['dirname']) {
|
||||
$this->_json(0, dr_lang('目录不能为空'), ['field' => 'dirname']);
|
||||
}
|
||||
|
||||
$data['dirname'] = strtolower($data['dirname']);
|
||||
if (!preg_match('/^[a-z]+$/i', $data['dirname'])) {
|
||||
$this->_json(0, dr_lang('目录只能是英文字母'), ['field' => 'dirname']);
|
||||
} elseif (is_dir(APPSPATH.ucfirst($data['dirname']))) {
|
||||
$this->_json(0, dr_lang('此目录已经存在'), ['field' => 'dirname']);
|
||||
} elseif (!$data['icon']) {
|
||||
$this->_json(0, dr_lang('模块图标不能为空'), ['field' => 'icon']);
|
||||
} elseif (!dr_check_put_path(APPSPATH)) {
|
||||
$this->_json(0, dr_lang('服务器没有创建目录的权限'), ['field' => 'dirname']);
|
||||
} elseif (\Phpcmf\Service::M('app')->is_sys_dir($data['dirname'])) {
|
||||
$this->_json(0, dr_lang('目录[%s]名称是系统保留名称,请重命名', $data['dirname']));
|
||||
}
|
||||
|
||||
// 开始复制到指定目录
|
||||
$path = APPSPATH.ucfirst($data['dirname']).'/';
|
||||
\Phpcmf\Service::L('File')->copy_file(APPPATH.'Temps/Module/', $path);
|
||||
if (!is_file($path.'Config/App.php')) {
|
||||
$this->_json(0, dr_lang('目录创建失败,请检查文件权限'), ['field' => 'dirname']);
|
||||
}
|
||||
|
||||
// 替换模块配置文件
|
||||
$app = file_get_contents($path.'Config/App.php');
|
||||
$app = str_replace(['{name}', '{icon}'], [dr_safe_filename($data['name']), dr_safe_replace($data['icon'])], $app);
|
||||
file_put_contents($path.'Config/App.php', $app);
|
||||
|
||||
$this->_json(1, dr_lang('模块创建成功'), [
|
||||
'url' => dr_url('module/module/index')
|
||||
]);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'form' => dr_form_hidden(),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu([
|
||||
'模块管理' => [APP_DIR.'/module/index', 'fa fa-cogs'],
|
||||
'创建模块' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-plus'],
|
||||
'help' => [24]
|
||||
])
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('module_create.html');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Module_param extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Module_search extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
$mid = \Phpcmf\Service::L('input')->get('dir');
|
||||
$all = \Phpcmf\Service::M('Module')->get_module_info();
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
|
||||
|
||||
// 设置url
|
||||
if ($module) {
|
||||
foreach ($module as $dir => $t) {
|
||||
if ($t['hlist'] == 1) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
if (!$all[$dir]) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
if ($mid && $mid != $dir) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
$data = $all[$dir];
|
||||
|
||||
// 搜索字段
|
||||
$data['search_field'] = [
|
||||
'catid' => dr_lang('栏目'),
|
||||
'keyword' => dr_lang('搜索词'),
|
||||
'order' => dr_lang('排序'),
|
||||
'page' => dr_lang('分页'),
|
||||
];
|
||||
if (!$data['setting']['search']['field']) {
|
||||
$data['setting']['search']['field'] = 'title,keywords';
|
||||
}
|
||||
$field = \Phpcmf\Service::M()->db->table('field')
|
||||
->where('disabled', 0)
|
||||
->where('ismain', 1)
|
||||
->where('relatedname', 'module')
|
||||
->where('relatedid', $data['id'])
|
||||
->orderBy('displayorder ASC,id ASC')
|
||||
->get()->getResultArray();
|
||||
foreach ($field as $f) {
|
||||
$data['search_field'][$f['fieldname']] = $f['name'];
|
||||
}
|
||||
$module[$dir] = $data;
|
||||
$module[$dir]['field'] = $field;
|
||||
$module[$dir]['save_url'] = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]);
|
||||
}
|
||||
} else {
|
||||
$this->_admin_msg(0, dr_lang('系统没有安装内容模块'));
|
||||
}
|
||||
|
||||
|
||||
$one = reset($module);
|
||||
$page = \Phpcmf\Service::L('input')->get('page');
|
||||
if (!$page) {
|
||||
$page = $one['dirname'];
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'form' => dr_form_hidden(),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'模块搜索设置' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-search'],
|
||||
'help' => [1041],
|
||||
]
|
||||
),
|
||||
'module' => $module,
|
||||
'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('module_search.html');
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
|
||||
$dir = \Phpcmf\Service::L('input')->get('dir');
|
||||
$cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
|
||||
if (!$cache[$dir]) {
|
||||
$this->_json(0, dr_lang('模块#%s不存在', $dir));
|
||||
}
|
||||
|
||||
$all = \Phpcmf\Service::M('Module')->get_module_info();
|
||||
if (!$all[$dir]) {
|
||||
$this->_json(0, dr_lang('模块#%s不存在', $dir));
|
||||
}
|
||||
|
||||
if (IS_POST) {
|
||||
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
foreach ($post as $dir => $t) {
|
||||
$all[$dir]['setting']['search'] = $t;
|
||||
$all[$dir]['setting']['search']['field'] = implode(',', $_POST['search_field'][$dir]);
|
||||
\Phpcmf\Service::M()->db->table('module')->where('dirname', $dir)->update([
|
||||
'setting' => dr_array2string($all[$dir]['setting']),
|
||||
]);
|
||||
}
|
||||
|
||||
// 自动更新缓存
|
||||
\Phpcmf\Service::M('cache')->sync_cache();
|
||||
|
||||
$this->_json(1, dr_lang('操作成功'), [
|
||||
'url' => dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', ['page' => $dir])
|
||||
]);
|
||||
}
|
||||
|
||||
$this->_json(0, dr_lang('请求错误'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Seo extends \Phpcmf\Common {
|
||||
|
||||
public function index() {
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$rt = \Phpcmf\Service::M('Site')->config(
|
||||
SITE_ID,
|
||||
'seo',
|
||||
\Phpcmf\Service::L('input')->post('data', true)
|
||||
);
|
||||
\Phpcmf\Service::M('Site')->config_value(SITE_ID, 'config', [
|
||||
'SITE_INDEX_HTML' => intval(\Phpcmf\Service::L('input')->post('SITE_INDEX_HTML'))
|
||||
]);
|
||||
if (!is_array($rt)) {
|
||||
$this->_json(0, dr_lang('网站SEO(#%s)不存在', SITE_ID));
|
||||
}
|
||||
\Phpcmf\Service::L('input')->system_log('设置网站SEO');
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
$data = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'data' => $data['seo'],
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'站点SEO' => [APP_DIR.'/seo/index', 'fa fa-cog'],
|
||||
'help' => [494],
|
||||
]
|
||||
),
|
||||
'module' => \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content'),
|
||||
'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
|
||||
'SITE_INDEX_HTML' => $data['config']['SITE_INDEX_HTML'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('seo.html');
|
||||
}
|
||||
|
||||
public function sync_index() {
|
||||
|
||||
$url = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/'.\Phpcmf\Service::L('Router')->method);
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
if (!$page) {
|
||||
// 计算数量
|
||||
$total = \Phpcmf\Service::M()->db->table('module')->countAllResults();
|
||||
if (!$total) {
|
||||
$this->_html_msg(0, dr_lang('无可用模块更新'));
|
||||
}
|
||||
$this->_html_msg(1, dr_lang('正在执行中...'), $url.'&total='.$total.'&page=1');
|
||||
}
|
||||
|
||||
$psize = 100; // 每页处理的数量
|
||||
$total = (int)\Phpcmf\Service::L('input')->get('total');
|
||||
$tpage = ceil($total / $psize); // 总页数
|
||||
|
||||
// 更新完成
|
||||
if ($page > $tpage) {
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_html_msg(1, dr_lang('更新完成'));
|
||||
}
|
||||
|
||||
$category = \Phpcmf\Service::M()->db->table('module')->limit($psize, $psize * ($page - 1))->orderBy('id DESC')->get()->getResultArray();
|
||||
if ($category) {
|
||||
$site = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
$update = [];
|
||||
foreach ($category as $data) {
|
||||
$data['site'] = dr_string2array($data['site']);
|
||||
$data['site'][SITE_ID]['show_title'] = $site['seo']['show_title'];
|
||||
$data['site'][SITE_ID]['show_keywords'] = $site['seo']['show_keywords'];
|
||||
$data['site'][SITE_ID]['show_description'] = $site['seo']['show_description'];
|
||||
$update[] = [
|
||||
'id' => (int)$data['id'],
|
||||
'site'=> dr_array2string($data['site']),
|
||||
];
|
||||
}
|
||||
$update && \Phpcmf\Service::M()->table('module')->update_batch($update);
|
||||
}
|
||||
|
||||
$this->_html_msg(1, dr_lang('正在执行中【%s】...', "$tpage/$page"), $url.'&total='.$total.'&page='.($page+1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
class Seo_category extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
|
||||
if (!$module) {
|
||||
$this->_admin_msg(0, dr_lang('系统没有安装内容模块'));
|
||||
}
|
||||
|
||||
$page = \Phpcmf\Service::L('input')->get('page');
|
||||
$share = 0;
|
||||
|
||||
// 设置url
|
||||
foreach ($module as $dir => $t) {
|
||||
if ($t['share']) {
|
||||
$share = 1;
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
} elseif ($t['hlist'] == 1) {
|
||||
//1表示不出现在模块管理、评论tab、搜索tab、内容维护tab的列表之中
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
} elseif ($t['hcategory']) {
|
||||
//1表示不使用栏目功能和发布权限功能
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
$cache = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
|
||||
if (!$cache) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
} elseif ($cache['setting']['search']['catsync']) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
if (!isset($cache['site'][SITE_ID]['is_cat']) || !$cache['site'][SITE_ID]['is_cat']) {
|
||||
if ($page && $page == $dir) {
|
||||
$this->_admin_msg(0, dr_lang('此模块没有开启按栏目分别设置SEO选项'));
|
||||
}
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$module[$dir]['name'] = dr_lang('%s栏目', $t['name']);
|
||||
$module[$dir]['list'] = $this->_get_tree_list(
|
||||
$dir,
|
||||
\Phpcmf\Service::M('category')->init(['table' => dr_module_table_prefix($dir).'_category'])->cat_data(0)
|
||||
);
|
||||
$module[$dir]['save_url'] = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]);
|
||||
}
|
||||
|
||||
if ($share) {
|
||||
$tmp['share'] = [
|
||||
'name' => '共享栏目',
|
||||
'icon' => 'fa fa-share-alt',
|
||||
'title' => '共享',
|
||||
'save_url' => dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => 'share']),
|
||||
'dirname' => 'share',
|
||||
'list' => $this->_get_tree_list(
|
||||
'share',
|
||||
\Phpcmf\Service::M('category')->init(['table' => dr_module_table_prefix('share').'_category'])->cat_data(0)
|
||||
),
|
||||
];
|
||||
$module = dr_array22array($tmp, $module);
|
||||
}
|
||||
|
||||
$one = reset($module);
|
||||
if (!$page) {
|
||||
$page = $one['dirname'];
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'form' => dr_form_hidden(),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'栏目SEO' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-reorder'],
|
||||
'help' => [496],
|
||||
]
|
||||
),
|
||||
'module' => $module,
|
||||
'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('seo_category.html');
|
||||
}
|
||||
|
||||
// 选择规则
|
||||
private function _select_rule($dir, $rule, $t) {
|
||||
|
||||
if ($dir != 'share') {
|
||||
if ($t['setting']['urlrule']
|
||||
&& isset($rule[$t['setting']['urlrule']])
|
||||
&& $rule[$t['setting']['urlrule']]) {
|
||||
$html = '<label class="label label-success">'.dr_lang($rule[$t['setting']['urlrule']]['name']).'</label>';
|
||||
} else {
|
||||
$html = '<label class="label label-default">'.dr_lang('动态地址').'</label>';
|
||||
}
|
||||
} else {
|
||||
$html = '<label>';
|
||||
$html.= '<select class="form-control" onchange="dr_save_urlrule(\''.$dir.'\', \''.$t['id'].'\', this.value)">';
|
||||
$html.= '<option value="0"> '.dr_lang('动态地址').' </option>';
|
||||
if ($rule) {
|
||||
foreach ($rule as $b) {
|
||||
$select = isset($t['setting']['urlrule']) && $t['setting']['urlrule'] == $b['id'] ? 'selected' : '';
|
||||
if ($dir == 'share') {
|
||||
if ($b['type'] == 3) {
|
||||
$html.= '<option '.$select.' value="'.$b['id'].'"> '.dr_lang($b['name']).' </option>';
|
||||
}
|
||||
} elseif ($b['type'] == 1) {
|
||||
$html.= '<option '.$select.' value="'.$b['id'].'"> '.dr_lang($b['name']).' </option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
$html.= '</select>';
|
||||
$html.= '</label>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
// 获取树形结构列表
|
||||
private function _get_tree_list($dir, $data) {
|
||||
|
||||
$str = "<tr class='\$class'>";
|
||||
$str.= "<td style='text-align:center'>\$id</td>";
|
||||
$str.= "<td>\$spacer<a target='_blank' href='\$url'>\$name</a> </td>";
|
||||
$str.= "<td>\$html</td>";
|
||||
if (dr_is_app('chtml')) {
|
||||
$str .= "<td style='text-align:center'>\$is_page_html</td>";
|
||||
$str .= "<td style='text-align:center'>\$is_page_html2</td>";
|
||||
}
|
||||
$str.= "<td>\$option</td>";
|
||||
$str.= "</tr>";
|
||||
|
||||
$rule = $this->get_cache('urlrule');
|
||||
if ($dir != 'share') {
|
||||
$mod = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
|
||||
if (!$mod) {
|
||||
$this->_admin_msg(0, dr_lang('模块#%s不存在', $dir));
|
||||
}
|
||||
$mod['site'] = dr_string2array($mod['site']);
|
||||
} else {
|
||||
$mod = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share');
|
||||
}
|
||||
|
||||
$tree = '';
|
||||
foreach($data as $t) {
|
||||
$t['name'] = dr_strcut($t['name'], 30);
|
||||
$t['setting'] = dr_string2array($t['setting']);
|
||||
$t['option'] = '<a class="btn btn-xs green" href="javascript:edit_seo('.$t['id'].', \''.$t['name'].'\', \''.$dir.'\');"> <i class="fa fa-edit"></i> '.dr_lang('设置SEO').'</a>';
|
||||
$t['option'].= '<a class="btn btn-xs red" href="javascript:dr_iframe(\''.dr_lang('复制').'\', \''.dr_url(($dir == 'share' ? '' : $dir).'/category/copy_edit').'&at=seo&catid='.$t['id'].'\', \'\', \'500px\', \'nogo\');"> <i class="fa fa-copy"></i> '.dr_lang('同步到其他栏目').'</a>';
|
||||
// 判断是否生成静态
|
||||
if (dr_is_app('chtml')) {
|
||||
$is_html = intval($t['setting']['html']);
|
||||
$is_html2 = intval($t['setting']['chtml']);
|
||||
$t['is_page_html'] = '<a href="javascript:;" onclick="dr_cat_ajax_open_close(this, \''.\Phpcmf\Service::L('Router')->url(($dir == 'share' ? '' : $dir).'/category/html_edit', ['id'=>$t['id']]).'\', 0);" class="dr_is_page_html badge badge-'.(!$is_html ? 'no' : 'yes').'"><i class="fa fa-'.(!$is_html ? 'times' : 'check').'"></i></a>';
|
||||
$t['is_page_html2'] = '<a href="javascript:;" onclick="dr_cat_ajax_open_close(this, \''.\Phpcmf\Service::L('Router')->url(($dir == 'share' ? '' : $dir).'/category/html_edit', ['tid'=>1, 'id'=>$t['id']]).'\', 0);" class="dr_is_page_html badge badge-'.(!$is_html2 ? 'no' : 'yes').'"><i class="fa fa-'.(!$is_html2 ? 'times' : 'check').'"></i></a>';
|
||||
}
|
||||
if ($mod && isset($mod['site'][SITE_ID]['urlrule'])) {
|
||||
$t['setting']['urlrule'] = $mod['site'][SITE_ID]['urlrule'];
|
||||
}
|
||||
$t['html'] = $this->_select_rule($dir, $rule, $t);
|
||||
|
||||
$pid = explode(',', $t['pids']);
|
||||
$mod['category'][$t['id']]['topid'] = $t['topid'] = isset($pid[1]) ? $pid[1] : $t['id'];
|
||||
$t['url'] = $t['tid'] == 2 && $t['setting']['linkurl'] ? dr_url_prefix($t['setting']['linkurl']) : dr_url_prefix(\Phpcmf\Service::L('router')->category_url($mod, $t));
|
||||
|
||||
if ($t['child'] || $t['pcatpost']) {
|
||||
$t['spacer'] = $this->_get_spacer($t['pids']).'<a href="javascript:dr_tree_data(\''.$dir.'\', '.$t['id'].');" class="blue select-cat-'.$dir.'-'.$t['id'].'">[+]</a> ';
|
||||
} else {
|
||||
$t['spacer'] = $this->_get_spacer($t['pids']);
|
||||
}
|
||||
|
||||
$t['class'] = 'dr_catid_'.$dir.'_'.$t['id']. ' dr_pid_'.$dir.'_'.$t['pid'];
|
||||
$arr = explode(',', $t['pids']);
|
||||
if ($arr) {
|
||||
foreach ($arr as $a) {
|
||||
$t['class'].= ' dr_pid_'.$dir.'_'.$a;
|
||||
}
|
||||
}
|
||||
extract($t);
|
||||
eval("\$nstr = \"$str\";");
|
||||
$tree.= $nstr;
|
||||
}
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
public function list_index() {
|
||||
$pid = intval(\Phpcmf\Service::L('input')->get('pid'));
|
||||
$mid = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
|
||||
$b = $this->_get_tree_list($mid, \Phpcmf\Service::M('category')->init(['table' => dr_module_table_prefix($mid).'_category'])->cat_data($pid));
|
||||
$this->_json(1, $b);
|
||||
}
|
||||
|
||||
// 替换空格填充符号
|
||||
private function _get_spacer($str) {
|
||||
$rt = '';
|
||||
$num = substr_count((string)$str, ',') * 2;
|
||||
if ($num) {
|
||||
for ($i = 0; $i < $num; $i ++) {
|
||||
$rt.= ' ';
|
||||
}
|
||||
}
|
||||
return $rt;
|
||||
}
|
||||
|
||||
|
||||
public function show_index() {
|
||||
|
||||
$dir = \Phpcmf\Service::L('input')->get('dir');
|
||||
$this->module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
|
||||
if (!$this->module) {
|
||||
$this->_admin_msg(0, dr_lang('模块[%s]缓存不存在', $dir));
|
||||
return;
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'list' => $this->_get_tree_list($this->module['category']),
|
||||
'dirname' => $dir,
|
||||
'save_url' => dr_url('module/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]),
|
||||
'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('seo_category.html');
|
||||
}
|
||||
|
||||
public function rule_edit() {
|
||||
|
||||
$dir = \Phpcmf\Service::L('input')->get('dir');
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
|
||||
if (!$module) {
|
||||
$this->_admin_msg(0, dr_lang('模块[%s]缓存不存在', $dir));
|
||||
return;
|
||||
}
|
||||
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
$value = (int)\Phpcmf\Service::L('input')->get('value');
|
||||
|
||||
if ($dir == 'share') {
|
||||
$data = \Phpcmf\Service::M()->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->getRow();
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('栏目#%s不存在', $id));
|
||||
}
|
||||
$data['setting'] = dr_string2array($data['setting']);
|
||||
$data['setting']['urlrule'] = $value;
|
||||
\Phpcmf\Service::M()->db->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->update([
|
||||
'setting' => dr_array2string($data['setting']),
|
||||
]);
|
||||
} else {
|
||||
$data = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('模块#%s不存在', $dir));
|
||||
}
|
||||
|
||||
$data['site'] = dr_string2array($data['site']);
|
||||
$data['site'][SITE_ID]['urlrule'] = $value;
|
||||
|
||||
\Phpcmf\Service::M()->db->table('module')->where('dirname', $dir)->update([
|
||||
'site' => dr_array2string($data['site']),
|
||||
]);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, '操作成功,更新缓存生效');
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
|
||||
$dir = \Phpcmf\Service::L('input')->get('dir');
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-'.$dir);
|
||||
if (!$module) {
|
||||
$this->_admin_msg(0, dr_lang('模块[%s]缓存不存在', $dir));
|
||||
return;
|
||||
}
|
||||
|
||||
$id = (int)\Phpcmf\Service::L('input')->get('id');
|
||||
$data = \Phpcmf\Service::M()->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->getRow();
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('栏目#%s不存在', $id));
|
||||
}
|
||||
$data['setting'] = dr_string2array($data['setting']);
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$seo = \Phpcmf\Service::L('input')->post('seo');
|
||||
$set = \Phpcmf\Service::L('input')->post('setting');
|
||||
if (!isset($data['setting']['seo']) || !$data['setting']['seo']) {
|
||||
$data['setting']['seo'] = [];
|
||||
}
|
||||
foreach (['list_title', 'list_keywords', 'list_description'] as $name) {
|
||||
$data['setting']['seo'][$name] = isset($seo[$name]) ? $seo[$name] : '';
|
||||
}
|
||||
$data['setting']['html'] = isset($set['html']) ? (int)$set['html'] : 0;
|
||||
$data['setting']['chtml'] = isset($set['chtml']) ? (int)$set['chtml'] : 0;
|
||||
$data['setting']['urlrule'] = isset($set['urlrule']) ? (int)$set['urlrule'] : 0;
|
||||
\Phpcmf\Service::M()->db->table(dr_module_table_prefix($dir).'_category')->where('id', $id)->update([
|
||||
'setting' => dr_array2string($data['setting']),
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, '操作成功,更新缓存生效');
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'data' => $data,
|
||||
'dirname' => $dir,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('seo_category_edit.html');exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Seo_module extends \Phpcmf\Common {
|
||||
|
||||
public function index() {
|
||||
|
||||
$mid = \Phpcmf\Service::L('input')->get('dir');
|
||||
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
|
||||
|
||||
// 设置url
|
||||
if ($module) {
|
||||
foreach ($module as $dir => $t) {
|
||||
if ($t['hlist'] == 1) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
if ($mid && $mid != $dir) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
$data = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
|
||||
if (!$data) {
|
||||
unset($module[$dir]);
|
||||
continue;
|
||||
}
|
||||
$site = dr_string2array($data['site']);
|
||||
$module[$dir]['site'] = $site[SITE_ID];
|
||||
$module[$dir]['setting'] = dr_string2array($data['setting']);
|
||||
$module[$dir]['save_url'] = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', ['dir' => $dir]);
|
||||
}
|
||||
} else {
|
||||
$this->_admin_msg(0, dr_lang('系统没有安装内容模块'));
|
||||
}
|
||||
|
||||
$one = reset($module);
|
||||
$page = \Phpcmf\Service::L('input')->get('page');
|
||||
if (!$page) {
|
||||
$page = $one['dirname'];
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'form' => dr_form_hidden(),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'内容模块SEO' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-cogs'],
|
||||
'help' => [398],
|
||||
]
|
||||
),
|
||||
'module' => $module,
|
||||
'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('seo_module.html');
|
||||
}
|
||||
|
||||
// 存储指定的模块
|
||||
public function edit() {
|
||||
|
||||
$dir = \Phpcmf\Service::L('input')->get('dir');
|
||||
$data = \Phpcmf\Service::M()->table('module')->where('dirname', $dir)->getRow();
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('模块#%s不存在', $dir));
|
||||
}
|
||||
|
||||
$data['site'] = dr_string2array($data['site']);
|
||||
$data['setting'] = dr_string2array($data['setting']);
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$site = \Phpcmf\Service::L('input')->post('site');
|
||||
foreach (['html', 'urlrule', 'is_cat',
|
||||
'show_title', 'show_keywords', 'show_description',
|
||||
'list_title', 'list_keywords', 'list_description',
|
||||
'search_title', 'search_keywords', 'search_description',
|
||||
'module_title', 'module_keywords', 'module_description'] as $name) {
|
||||
$data['site'][SITE_ID][$name] = $site[$name];
|
||||
}
|
||||
$data['setting']['module_index_html'] = intval($_POST['module_index_html']);
|
||||
\Phpcmf\Service::M()->db->table('module')->where('dirname', $dir)->update([
|
||||
'site' => dr_array2string($data['site']),
|
||||
'setting' => dr_array2string($data['setting']),
|
||||
]);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, dr_lang('操作成功'), [
|
||||
'url' => dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', ['page' => $dir])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Seo_site extends \Phpcmf\Common {
|
||||
|
||||
public function index() {
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$rt = \Phpcmf\Service::M('Site')->config(
|
||||
SITE_ID,
|
||||
'seo',
|
||||
\Phpcmf\Service::L('input')->post('data', true)
|
||||
);
|
||||
\Phpcmf\Service::M('Site')->config_value(SITE_ID, 'config', [
|
||||
'SITE_INDEX_HTML' => intval(\Phpcmf\Service::L('input')->post('SITE_INDEX_HTML'))
|
||||
]);
|
||||
if (!is_array($rt)) {
|
||||
$this->_json(0, dr_lang('网站SEO(#%s)不存在', SITE_ID));
|
||||
}
|
||||
\Phpcmf\Service::L('input')->system_log('设置网站SEO');
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
$data = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'data' => $data['seo'],
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'站点SEO' => [APP_DIR.'/'.'seo_site/index', 'fa fa-cog'],
|
||||
'help' => [494],
|
||||
]
|
||||
),
|
||||
'module' => \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content'),
|
||||
'site_name' => $this->site_info[SITE_ID]['SITE_NAME'],
|
||||
'SITE_INDEX_HTML' => $data['config']['SITE_INDEX_HTML'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('seo_site.html');
|
||||
}
|
||||
|
||||
public function sync_index() {
|
||||
|
||||
$ct = intval(\Phpcmf\Service::L('input')->get('ct'));
|
||||
$value = intval(\Phpcmf\Service::L('input')->get('value'));
|
||||
$url = dr_url(APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/'.\Phpcmf\Service::L('Router')->method, ['ct' => $ct, 'value' => $value]);
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
if (!$page) {
|
||||
// 计算数量
|
||||
$total = \Phpcmf\Service::M()->db->table(SITE_ID.'_share_category')->countAllResults();
|
||||
if (!$total) {
|
||||
$this->_html_msg(0, dr_lang('无可用栏目更新'));
|
||||
}
|
||||
$this->_html_msg(1, dr_lang('正在执行中...'), $url.'&total='.$total.'&page=1');
|
||||
}
|
||||
|
||||
$psize = 100; // 每页处理的数量
|
||||
$total = (int)\Phpcmf\Service::L('input')->get('total');
|
||||
$tpage = ceil($total / $psize); // 总页数
|
||||
|
||||
// 更新完成
|
||||
if ($page > $tpage) {
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_html_msg(1, dr_lang('更新完成'));
|
||||
}
|
||||
|
||||
$category = \Phpcmf\Service::M()->db->table(SITE_ID.'_share_category')->limit($psize, $psize * ($page - 1))->orderBy('id DESC')->get()->getResultArray();
|
||||
if ($category) {
|
||||
$update = [];
|
||||
foreach ($category as $data) {
|
||||
$data['setting'] = dr_string2array($data['setting']);
|
||||
if ($ct == 1) {
|
||||
$data['setting']['urlrule'] = $value;
|
||||
} elseif ($ct == 2) {
|
||||
$data['setting']['template']['pagesize'] = $value;
|
||||
} elseif ($ct == 3) {
|
||||
$data['setting']['template']['mpagesize'] = $value;
|
||||
}
|
||||
$update[] = [
|
||||
'id' => (int)$data['id'],
|
||||
'setting'=> dr_array2string($data['setting']),
|
||||
];
|
||||
}
|
||||
$update && \Phpcmf\Service::M()->table_site('share_category')->update_batch($update);
|
||||
}
|
||||
|
||||
$this->_html_msg(1, dr_lang('正在执行中【%s】...', "$tpage/$page"), $url.'&total='.$total.'&page='.($page+1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
|
||||
class Site_config extends \Phpcmf\Common
|
||||
{
|
||||
public function index() {
|
||||
|
||||
$data = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
if (isset($_POST['theme']) && $_POST['theme']) {
|
||||
// 远程资源
|
||||
$post['SITE_THEME'] = $post['SITE_THEME2'];
|
||||
} else {
|
||||
// 本地资源
|
||||
}
|
||||
|
||||
// 防止参数丢失
|
||||
$data['config']['SITE_NAME'] = $post['SITE_NAME'];
|
||||
$data['config']['SITE_CLOSE'] = $post['SITE_CLOSE'];
|
||||
$data['config']['SITE_INDEX_HTML'] = $post['SITE_INDEX_HTML'];
|
||||
$data['config']['SITE_CLOSE_MSG'] = $post['SITE_CLOSE_MSG'];
|
||||
$data['config']['SITE_LANGUAGE'] = $post['SITE_LANGUAGE'];
|
||||
$data['config']['SITE_TEMPLATE'] = $post['SITE_TEMPLATE'];
|
||||
$data['config']['SITE_TIMEZONE'] = $post['SITE_TIMEZONE'];
|
||||
$data['config']['SITE_TIME_FORMAT'] = $post['SITE_TIME_FORMAT'];
|
||||
$data['config']['SITE_THEME'] = $post['SITE_THEME'];
|
||||
$data['config']['SITE_INDEX_TIME'] = $post['SITE_INDEX_TIME'];
|
||||
|
||||
$rt = \Phpcmf\Service::M('Site')->config(SITE_ID, 'config', $data['config']);
|
||||
if (!is_array($rt)) {
|
||||
$this->_json(0, dr_lang('网站信息(#%s)不存在', SITE_ID));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::L('input')->system_log('设置网站参数');
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
$run_time = '';
|
||||
if (is_file(WRITEPATH.'config/run_time.php')) {
|
||||
$run_time = file_get_contents(WRITEPATH.'config/run_time.php');
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'data' => $data['config'],
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'lang' => dr_dir_map(ROOTPATH.'api/language/', 1),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'网站设置' => ['module/site_config/index', 'fa fa-cog'],
|
||||
'help' => [505],
|
||||
]
|
||||
),
|
||||
'theme' => dr_get_theme(),
|
||||
'run_time' => $run_time,
|
||||
'is_theme' => dr_strpos($data['config']['SITE_THEME'], '/') !== false ? 1 : 0,
|
||||
'template_path' => dr_dir_map(TPLPATH.'pc/', 1),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('site_config.html');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
class Site_domain extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$data = $post = \Phpcmf\Service::L('input')->post('data');
|
||||
if ($data['site_domain'] == $data['mobile_domain']) {
|
||||
$this->_json(0, dr_lang('手机域名不能与电脑相同'));
|
||||
}
|
||||
foreach ($post as $name => $value) {
|
||||
unset($data[$name]);
|
||||
if ($value) {
|
||||
if (strpos($name, 'webpath') === 0) {
|
||||
// 目录不验证
|
||||
} elseif ($name == 'site_domain') {
|
||||
if (!\Phpcmf\Service::L('Form')->check_domain_dir($value)) {
|
||||
$this->_json(0, dr_lang('域名(%s)格式不正确', $value));
|
||||
}
|
||||
} else {
|
||||
// 验证域名可用性
|
||||
if (dr_in_array($value, $data)) {
|
||||
$this->_json(0, dr_lang('域名(%s)绑定重复', $value));
|
||||
} elseif (!\Phpcmf\Service::L('Form')->check_domain($value)) {
|
||||
$this->_json(0, dr_lang('域名(%s)格式不正确', $value));
|
||||
}
|
||||
list($cname, $mid) = explode('_', $name);
|
||||
if ($cname == 'module' && $mid != 'mobile' && $post['module_'.$mid] && !$post['webpath_'.$mid]) {
|
||||
$this->_json(0, dr_lang('模块(%s)的Web目录必须填写', $mid));
|
||||
}
|
||||
}
|
||||
}
|
||||
$data[$name] = $value;
|
||||
}
|
||||
\Phpcmf\Service::M('Site')->domain($post);
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
\Phpcmf\Service::L('input')->system_log('设置域名参数');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
list($module, $data) = \Phpcmf\Service::M('Site')->domain();
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'data' => $data,
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'域名设置' => ['module/site_domain/index', 'fa fa-cog'],
|
||||
'help' => ['407'],
|
||||
]
|
||||
),
|
||||
'module' => $module,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('site_domain.html');
|
||||
}
|
||||
|
||||
public function bang_index() {
|
||||
$this->index();
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
|
||||
$name = '';
|
||||
$is_fclient = is_file(ROOTPATH.'api/fclient/index.php');
|
||||
if ($is_fclient && is_file(MYPATH . 'Config/License.php')) {
|
||||
$license = require MYPATH . 'Config/License.php';
|
||||
$name = $license['name'];
|
||||
}
|
||||
|
||||
!$name && $name = dr_lang('软件服务商');
|
||||
|
||||
if (IS_POST) {
|
||||
|
||||
if ($is_fclient) {
|
||||
$this->_json(0, dr_lang('当前网站不能修改主域名'));
|
||||
}
|
||||
|
||||
$domain = trim(\Phpcmf\Service::L('input')->post('domain'));
|
||||
if (!\Phpcmf\Service::L('Form')->check_domain($domain)) {
|
||||
$this->_json(0, dr_lang('域名(%s)格式不正确', $domain));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('Site')->edit_domain($domain);
|
||||
\Phpcmf\Service::L('input')->system_log('变更网站主域名');
|
||||
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
|
||||
|
||||
$this->_json(1, dr_lang('操作成功,请更新全站缓存'), [
|
||||
'tourl' => dr_url('cache/index')
|
||||
]);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'form' => dr_form_hidden(),
|
||||
'fcname' => $name,
|
||||
'is_fclient' => $is_fclient,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('site_domain_edit.html');exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
require CMSPATH.'Control/Admin/Site_image.php';
|
||||
|
||||
class Site_image extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
$obj = new \Phpcmf\Control\Admin\Site_image();
|
||||
$obj->index();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
class Site_mobile extends \Phpcmf\Common
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
if (!$post['mode']) {
|
||||
if (!\Phpcmf\Service::L('Form')->check_domain($post['domain'])) {
|
||||
$this->_json(0, dr_lang('域名(%s)格式不正确', $post['domain']));
|
||||
} elseif ($this->site_info[SITE_ID]['SITE_DOMAIN'] == $post['domain']) {
|
||||
$this->_json(0, dr_lang('手机域名不能与电脑相同'));
|
||||
}
|
||||
}
|
||||
if ($post['mode'] == -1) {
|
||||
$post['auto'] = $post['auto2'];
|
||||
$post['tohtml'] = 0;
|
||||
$post['dirname'] = $post['domain'] = '';
|
||||
} elseif ($post['mode'] == 1) {
|
||||
// 生成手机目录
|
||||
$rt = \Phpcmf\Service::M('cache')->update_mobile_webpath(WEBPATH, $post['dirname']);
|
||||
if ($rt) {
|
||||
$this->_json(0, dr_lang($rt));
|
||||
}
|
||||
}
|
||||
$rt = \Phpcmf\Service::M('Site')->config(SITE_ID, 'mobile', $post);
|
||||
if (!is_array($rt)) {
|
||||
$this->_json(0, dr_lang('网站信息(#%s)不存在', SITE_ID));
|
||||
}
|
||||
\Phpcmf\Service::L('input')->system_log('设置手机网站参数');
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
$data = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
|
||||
if (!isset($data['mobile']['dirname']) || !$data['mobile']['dirname']) {
|
||||
$data['mobile']['dirname'] = 'mobile';
|
||||
}
|
||||
if (!isset($data['mobile']['mode']) || (!$data['mobile']['mode'] && !$data['mobile']['domain'])) {
|
||||
$data['mobile']['mode'] = -1;
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'data' => $data['mobile'],
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'手机网站' => ['module/site_mobile/index', 'fa fa-mobile'],
|
||||
'help' => [506],
|
||||
]
|
||||
),
|
||||
'is_tpl' => is_file(TPLPATH.'mobile/'.SITE_TEMPLATE.'/home/index.html'),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('site_mobile.html');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
class Site_param extends \Phpcmf\Common {
|
||||
|
||||
public function index() {
|
||||
|
||||
$logo = [
|
||||
'logo' => [
|
||||
'ismain' => 1,
|
||||
'fieldtype' => 'File',
|
||||
'fieldname' => 'logo',
|
||||
'setting' => ['option' => ['ext' => 'jpg,gif,png,jpeg,webp,svg', 'size' => 10, 'input' => 1]]
|
||||
]
|
||||
];
|
||||
|
||||
$data = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
$field = \Phpcmf\Service::M('field')->get_mysite_field(SITE_ID);
|
||||
|
||||
// 初始化自定义字段类
|
||||
\Phpcmf\Service::L('Field')->app('');
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
|
||||
$post = \Phpcmf\Service::L('input')->post('data', false);
|
||||
|
||||
// param
|
||||
if ($field) {
|
||||
list($save, $return, $attach, $notfield) = \Phpcmf\Service::L('form')->validation($post, null, $field, $data['param']);
|
||||
// 输出错误
|
||||
if ($return) {
|
||||
$this->_json(0, $return['error'], ['field' => $return['name']]);
|
||||
}
|
||||
if ($notfield) {
|
||||
// 保留无权限的字段值
|
||||
foreach ($notfield as $t) {
|
||||
$save[1][$t] = $data['param'][$t];
|
||||
}
|
||||
}
|
||||
$rt = \Phpcmf\Service::M('Site')->config(
|
||||
SITE_ID,
|
||||
'param',
|
||||
$save[1]
|
||||
);
|
||||
if (!is_array($rt)) {
|
||||
$this->_json(0, dr_lang('网站信息(#%s)不存在', SITE_ID));
|
||||
}
|
||||
// 附件归档
|
||||
if (SYS_ATTACHMENT_DB) {
|
||||
$attach && \Phpcmf\Service::M('Attachment')->handle($this->member['id'], \Phpcmf\Service::M()->dbprefix('site'), $attach);
|
||||
}
|
||||
foreach ($field as $t) {
|
||||
if (isset($post[$t['fieldname']])) {
|
||||
unset($post[$t['fieldname']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// config
|
||||
$config = \Phpcmf\Service::L('input')->post('data');
|
||||
$config['SITE_TONGJI'] = isset($_POST['data']['SITE_TONGJI']) ? trim($_POST['data']['SITE_TONGJI']) : '';
|
||||
// 防止参数丢失
|
||||
$config['SITE_CLOSE'] = $data['config']['SITE_CLOSE'];
|
||||
$config['SITE_INDEX_HTML'] = $data['config']['SITE_INDEX_HTML'];
|
||||
$config['SITE_CLOSE_MSG'] = $data['config']['SITE_CLOSE_MSG'];
|
||||
$config['SITE_LANGUAGE'] = $data['config']['SITE_LANGUAGE'];
|
||||
$config['SITE_TEMPLATE'] = $data['config']['SITE_TEMPLATE'];
|
||||
$config['SITE_TIMEZONE'] = $data['config']['SITE_TIMEZONE'];
|
||||
$config['SITE_TIME_FORMAT'] = $data['config']['SITE_TIME_FORMAT'];
|
||||
$config['SITE_THEME'] = $data['config']['SITE_THEME'];
|
||||
$rt = \Phpcmf\Service::M('Site')->config(SITE_ID, 'config', $config);
|
||||
if (!is_array($rt)) {
|
||||
$this->_json(0, dr_lang('网站信息(#%s)不存在', SITE_ID));
|
||||
}
|
||||
// 附件归档
|
||||
if (SYS_ATTACHMENT_DB) {
|
||||
list($post, $return, $attach) = \Phpcmf\Service::L('form')->validation($config, null, $logo);
|
||||
$attach && \Phpcmf\Service::M('Attachment')->handle($this->member['id'], \Phpcmf\Service::M()->dbprefix('site'), $attach);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::L('input')->system_log('设置网站自定义参数');
|
||||
\Phpcmf\Service::M('cache')->sync_cache('');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'网站信息' => ['module/site_param/index', 'fa fa-edit'],
|
||||
'自定义字段' => ['url:'.\Phpcmf\Service::L('Router')->url('field/index', ['rname' => 'site', 'rid' => SITE_ID]), 'fa fa-code'],
|
||||
'help' => [1125],
|
||||
]
|
||||
),
|
||||
'data' => $data['config'],
|
||||
'field' => $field,
|
||||
'myfield' => $field ? \Phpcmf\Service::L('Field')->toform(0, $field, $data['param']) : '',
|
||||
'mymerge' => $field ? \Phpcmf\Service::L('Field')->merge : '',
|
||||
'logofield' => dr_fieldform($logo['logo'], $data['config']['logo']),
|
||||
'my_site_info' => is_file(MYPATH.'View/site_info.html') ? MYPATH.'View/site_info.html' : '',
|
||||
]);
|
||||
|
||||
\Phpcmf\Service::V()->display('site_param.html');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,767 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
// URL规则
|
||||
class Urlrule extends \Phpcmf\Table
|
||||
{
|
||||
public $type;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->type = array(
|
||||
//0 => dr_lang('自定义页面插件'),
|
||||
1 => dr_lang('独立模块'),
|
||||
2 => dr_lang('共享模块搜索'),
|
||||
3 => dr_lang('共享栏目和内容页'),
|
||||
//5 => dr_lang('模块表单'),
|
||||
);
|
||||
if (!dr_is_app('page')) {
|
||||
unset($this->type[0]);
|
||||
}
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'URL规则' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-link'],
|
||||
'添加' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/add', 'fa fa-plus'],
|
||||
'修改' => ['hide:'.APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/edit', 'fa fa-edit'],
|
||||
'伪静态' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/rewrite_index', 'fa fa-cog'],
|
||||
'导入' => ['add:'.APP_DIR.'/urlrule/import_add', 'fa fa-sign-in', '60%', '70%'],
|
||||
'help' => [418],
|
||||
]
|
||||
),
|
||||
]);
|
||||
// 支持附表存储
|
||||
$this->is_data = 0;
|
||||
$this->my_field = array(
|
||||
'name' => array(
|
||||
'ismain' => 1,
|
||||
'name' => dr_lang('名称'),
|
||||
'fieldname' => 'name',
|
||||
'fieldtype' => 'Text',
|
||||
'setting' => array(
|
||||
'option' => array(
|
||||
'width' => 200,
|
||||
),
|
||||
'validate' => array(
|
||||
'required' => 1,
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
// url显示名称
|
||||
$this->name = dr_lang('URL规则');
|
||||
// 初始化数据表
|
||||
$this->_init([
|
||||
'table' => 'urlrule',
|
||||
'field' => $this->my_field,
|
||||
'order_by' => 'id desc',
|
||||
]);
|
||||
}
|
||||
|
||||
// 后台查看url列表
|
||||
public function index() {
|
||||
|
||||
$this->_List([], -1);
|
||||
\Phpcmf\Service::V()->assign('color', [
|
||||
0 => 'default',
|
||||
1 => 'info',
|
||||
2 => 'success',
|
||||
3 => 'warning',
|
||||
4 => 'danger',
|
||||
5 => '',
|
||||
6 => 'primary',
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('urlrule_index.html');
|
||||
}
|
||||
|
||||
// 伪静态
|
||||
public function rewrite_index() {
|
||||
|
||||
$domain = [];
|
||||
list($module, $site) = \Phpcmf\Service::M('Site')->domain();
|
||||
$domain[$site['site_domain']] = dr_lang('本站电脑域名');
|
||||
$site['mobile_domain'] && $domain[$site['mobile_domain']] = dr_lang('本站手机域名');
|
||||
if ($module) {
|
||||
foreach ($module as $dir => $t) {
|
||||
if ($site['module_'.$dir]) {
|
||||
$domain[$site['module_'.$dir]] = dr_lang('%s电脑域名', $t['name']);
|
||||
}
|
||||
if ($site['module_mobile_'.$dir]) {
|
||||
$domain[$site['module_mobile_'.$dir]] = dr_lang('%s手机域名', $t['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$site = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
if ($site['client']) {
|
||||
foreach ($site['client'] as $t) {
|
||||
if ($t['domain']) {
|
||||
$domain[$t['domain']] = dr_lang('%s终端域名', $t['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($site['config']['SITE_DOMAIN'], '/') !== false) {
|
||||
list($a, $b) = explode('/', $site['config']['SITE_DOMAIN']);
|
||||
$root = '/'.$b;
|
||||
} else {
|
||||
$root = '';
|
||||
}
|
||||
$server = strtolower($_SERVER['SERVER_SOFTWARE']);
|
||||
if (strpos($server, 'apache') !== FALSE) {
|
||||
$name = 'Apache';
|
||||
$note = '<font color=red><b>'.dr_lang('将以下内容保存为.htaccess文件,放到每个域名所绑定的根目录').'</b></font>';
|
||||
$code = '';
|
||||
|
||||
// 子目录
|
||||
$code.= '###当存在多个子目录格式的域名时,需要多写几组RewriteBase标签:RewriteBase /目录/ '.PHP_EOL;
|
||||
if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
|
||||
$code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
|
||||
$code.= 'RewriteBase /'.$site['mobile']['dirname'].'/'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
|
||||
.'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /'.$site['mobile']['dirname'].'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
|
||||
$code.= '####以上目录需要单独保持到/'.$site['mobile']['dirname'].'/.htaccess文件中';
|
||||
}
|
||||
// 主目录
|
||||
$code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
|
||||
$code.= 'RewriteBase '.$root.'/'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
|
||||
.'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ '.$root.'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
|
||||
} elseif (strpos($server, 'nginx') !== FALSE) {
|
||||
$name = $server;
|
||||
$note = '<font color=red><b>'.dr_lang('将以下代码放到Nginx配置文件中去(如果是绑定了域名,所绑定目录也要配置下面的代码)').'</b></font>';
|
||||
// 子目录
|
||||
$code = '###当存在多个子目录格式的域名时,需要多写几组location标签:location /目录/ '.PHP_EOL;
|
||||
if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
|
||||
$code.= 'location '.$root.'/'.$site['mobile']['dirname'].'/ { '.PHP_EOL
|
||||
.' if (-f $request_filename) {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if (!-e $request_filename) {'.PHP_EOL
|
||||
.' rewrite . '.$root.'/'.$site['mobile']['dirname'].'/index.php last;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.'}'.PHP_EOL.PHP_EOL;
|
||||
}
|
||||
// 主目录
|
||||
$code.= 'location '.$root.'/ { '.PHP_EOL
|
||||
.' if (-f $request_filename) {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if (!-e $request_filename) {'.PHP_EOL
|
||||
.' rewrite . '.$root.'/index.php last;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.'}'.PHP_EOL;
|
||||
} else {
|
||||
$name = $server;
|
||||
$note = '<font color=red><b>'.dr_lang('无法为此服务器提供伪静态规则,建议让运营商帮你把下面的Apache规则做转换').'</b></font>';
|
||||
$code = 'RewriteEngine On'.PHP_EOL
|
||||
.'RewriteBase /'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
|
||||
.'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]';
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'name' => $name,
|
||||
'code' => $code,
|
||||
'note' => $note,
|
||||
'site' => $site,
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'URL规则' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-link'],
|
||||
'伪静态' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/rewrite_index', 'fa fa-cog'],
|
||||
'help' => [21],
|
||||
]
|
||||
),
|
||||
'count' => $code ? dr_count(explode(PHP_EOL, $code)) : 0,
|
||||
'domain' => $domain,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('urlrule_rewrite.html');
|
||||
}
|
||||
|
||||
// 后台添加url内容
|
||||
public function add() {
|
||||
$this->_Post(0);
|
||||
\Phpcmf\Service::V()->display('urlrule_add.html');
|
||||
}
|
||||
|
||||
// 后台修改url内容
|
||||
public function edit() {
|
||||
$this->_Post(intval(\Phpcmf\Service::L('input')->get('id')));
|
||||
\Phpcmf\Service::V()->display('urlrule_add.html');
|
||||
}
|
||||
|
||||
// 复制url
|
||||
public function copy_edit() {
|
||||
|
||||
$id = intval(\Phpcmf\Service::L('input')->get('id'));
|
||||
$data = \Phpcmf\Service::M()->db->table('urlrule')->where('id', $id)->get()->getRowArray();
|
||||
if (!$data) {
|
||||
$this->_json(0, dr_lang('数据#%s不存在', $id));
|
||||
}
|
||||
|
||||
unset($data['id']);
|
||||
$data['name'].= '_copy';
|
||||
|
||||
$rt = \Phpcmf\Service::M()->table('urlrule')->insert($data);
|
||||
if (!$rt['code']) {
|
||||
$this->_json(0, dr_lang($rt['msg']));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
|
||||
$this->_json(1, dr_lang('复制成功'));
|
||||
}
|
||||
|
||||
// 保存
|
||||
protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
|
||||
return parent::_Save($id, $data, $old, function($id, $data){
|
||||
// 保存前的格式化
|
||||
$type = (int)\Phpcmf\Service::L('input')->post('type');
|
||||
$value = \Phpcmf\Service::L('input')->post('value');
|
||||
if ($value[$type]) {
|
||||
foreach ($value[$type] as $i => $t) {
|
||||
if (strpos($t, '?') !== false) {
|
||||
$this->_json(0, dr_lang('URL规则中不能包含%s号', '?'));
|
||||
} elseif (strpos($t, '#') !== false) {
|
||||
$this->_json(0, dr_lang('URL规则中不能包含%s号', '#'));
|
||||
} elseif (strpos($t, '(')
|
||||
&& preg_match('/\{([a-z0-9_]+)\(\$data\)\}/iU', $t, $mt)) {
|
||||
if (!function_exists($mt[1])) {
|
||||
$this->_json(0, dr_lang('URL规则中函数%s未定义', $mt[1]));
|
||||
}
|
||||
}
|
||||
$value[$type][$i] = trim($t);
|
||||
}
|
||||
}
|
||||
$data[1]['type'] = $type;
|
||||
$join = \Phpcmf\Service::L('input')->post('catjoin');
|
||||
$value[$type]['catjoin'] = $join ? $join : '/';
|
||||
$data[1]['value'] = dr_array2string($value[$type]);
|
||||
return dr_return_data(1, 'ok', $data);
|
||||
}, function ($id, $data, $old) {
|
||||
\Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
|
||||
});
|
||||
}
|
||||
|
||||
// 导出
|
||||
public function export_edit() {
|
||||
|
||||
$id = intval(\Phpcmf\Service::L('input')->get('id'));
|
||||
$data = \Phpcmf\Service::M()->table('urlrule')->get($id);
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('URL规则(%s)不存在', $id));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'data' => dr_array2string($data),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('api_export_code.html');exit;
|
||||
}
|
||||
|
||||
// 导入
|
||||
public function import_add() {
|
||||
|
||||
if (IS_AJAX_POST) {
|
||||
$data = \Phpcmf\Service::L('input')->post('code');
|
||||
$data = dr_string2array($data);
|
||||
if (!is_array($data)) {
|
||||
$this->_json(0, dr_lang('导入信息验证失败'));
|
||||
} elseif (!$data['value']) {
|
||||
$this->_json(0, dr_lang('导入信息不完整'));
|
||||
}
|
||||
unset($data['id']);
|
||||
$rt = \Phpcmf\Service::M()->table('urlrule')->insert($data);
|
||||
if (!$rt['code']) {
|
||||
$this->_json(0, $rt['msg']);
|
||||
}
|
||||
\Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
|
||||
$this->_json(1, dr_lang('操作成功'));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'data' => '',
|
||||
'form' => dr_form_hidden(),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('api_export_code.html');
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内容
|
||||
* $id 内容id,新增为0
|
||||
* */
|
||||
protected function _Data($id = 0) {
|
||||
$data = parent::_Data($id);
|
||||
$data['value'] = dr_string2array($data['value']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 后台删除url内容
|
||||
public function del() {
|
||||
$this->_Del(
|
||||
\Phpcmf\Service::L('input')->get_post_ids(),
|
||||
null,
|
||||
function ($r) {
|
||||
\Phpcmf\Service::M('cache')->sync_cache('urlrule', 'module');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// 生成伪静态解析文件规则
|
||||
public function rewrite_add() {
|
||||
$rt = $this->get_rewrite_code();
|
||||
$this->_json($rt['code'], $rt['msg'], $rt['data']);
|
||||
}
|
||||
|
||||
// 生成伪静态解析代码
|
||||
private function get_rewrite_code() {
|
||||
|
||||
$data = \Phpcmf\Service::M()->table('urlrule')->getAll();
|
||||
if (!$data) {
|
||||
return dr_return_data(0, dr_lang('你没有设置URL规则'));
|
||||
}
|
||||
|
||||
$code = '';
|
||||
$error = '';
|
||||
$write = []; // 防止重复
|
||||
foreach ($data as $r) {
|
||||
$value = dr_string2array($r['value']);
|
||||
if ($r['type'] == 1) {
|
||||
// 独立模块
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----开始'.PHP_EOL;
|
||||
if ($value['module']) {
|
||||
$rule = $value['module'];
|
||||
$cname = "【".$r['name']."】模块首页({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (!isset($rname['{modname}'])) {
|
||||
$rule = 'index.php?s=手动填写模块目录';
|
||||
} else {
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'];
|
||||
}
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname.'(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['list_page']) {
|
||||
$rule = $value['list_page'];
|
||||
$cname = "【".$r['name']."】模块栏目列表(分页)({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{page}'])) {
|
||||
$error.= "<p>".$cname."缺少{page}标签,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
|
||||
$error.= "<p>".$cname."缺少{dirname}或{id}或{pdirname}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (!isset($rname['{modname}'])) {
|
||||
$rname['{modname}'] = '{modname}';
|
||||
}
|
||||
if (isset($rname['{dirname}'])) {
|
||||
// 目录格式
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{dirname}'].'&page=$'.$rname['{page}'];
|
||||
} elseif (isset($rname['{pdirname}'])) {
|
||||
// 层次目录格式
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{pdirname}'].'&page=$'.$rname['{page}'];
|
||||
} else {
|
||||
// id模式
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
|
||||
}
|
||||
$rule = str_replace('${modname}', '手动填写模块目录', $rule);
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname.'(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['list']) {
|
||||
$rule = $value['list'];
|
||||
$cname = "【".$r['name']."】模块栏目列表({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
|
||||
$error.= "<p>".$cname."缺少{dirname}或{id}或{pdirname}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (!isset($rname['{modname}'])) {
|
||||
$rname['{modname}'] = '{modname}';
|
||||
}
|
||||
if (isset($rname['{dirname}'])) {
|
||||
// 目录格式
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{dirname}'];
|
||||
} elseif (isset($rname['{pdirname}'])) {
|
||||
// 层次目录格式
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&dir=$'.$rname['{pdirname}'];
|
||||
} else {
|
||||
// id模式
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=category&id=$'.$rname['{id}'];
|
||||
}
|
||||
$rule = str_replace('${modname}', '手动填写模块目录', $rule);
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['show_page']) {
|
||||
$rule = $value['show_page'];
|
||||
$cname = "【".$r['name']."】模块内容页(分页)({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{id}'])) {
|
||||
$error.= "<p>".$cname."缺少{id}标签,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{page}'])) {
|
||||
$error.= "<p>".$cname."缺少{page}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (!isset($rname['{modname}'])) {
|
||||
$rname['{modname}'] = '{modname}';
|
||||
}
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=show&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
|
||||
$rule = str_replace('${modname}', '手动填写模块目录', $rule);
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['show']) {
|
||||
$rule = $value['show'];
|
||||
$cname = "【".$r['name']."】模块内容页({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{id}'])) {
|
||||
$error.= "<p>".$cname."缺少{id}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (!isset($rname['{modname}'])) {
|
||||
$rname['{modname}'] = '{modname}';
|
||||
}
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=show&id=$'.$rname['{id}'];
|
||||
$rule = str_replace('${modname}', '手动填写模块目录', $rule);
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['search_page']) {
|
||||
$rule = $value['search_page'];
|
||||
$cname = "【".$r['name']."】模块搜索页(分页)({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{param}']) && !isset($rname['{rewrite}'])) {
|
||||
$error.= "<p>".$cname."缺少{param}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (!isset($rname['{modname}'])) {
|
||||
$rname['{modname}'] = '{modname}';
|
||||
}
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=search&rewrite=$'.($rname['{param}'] ? $rname['{param}'] : $rname['{rewrite}']);
|
||||
$rule = str_replace('${modname}', '手动填写模块目录', $rule);
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['search']) {
|
||||
$rule = $value['search'];
|
||||
$cname = "【".$r['name']."】模块搜索页({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (!isset($rname['{modname}'])) {
|
||||
$rname['{modname}'] = '{modname}';
|
||||
}
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=search';
|
||||
$rule = str_replace('${modname}', '手动填写模块目录', $rule);
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----结束'.PHP_EOL;
|
||||
} elseif ($r['type'] == 3 ) {
|
||||
// 共享栏目
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----开始'.PHP_EOL;
|
||||
if ($value['list_page']) {
|
||||
$rule = $value['list_page'];
|
||||
$cname = "【".$r['name']."】模块栏目列表(分页)({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg || !$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{page}'])) {
|
||||
$error.= "<p>".$cname."缺少{page}标签,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
|
||||
$error.= "<p>".$cname."缺少{dirname}或{id}或{pdirname}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (isset($rname['{dirname}'])) {
|
||||
// 目录格式
|
||||
$rule = 'index.php?c=category&dir=$'.$rname['{dirname}'].'&page=$'.$rname['{page}'];
|
||||
} elseif (isset($rname['{pdirname}'])) {
|
||||
// 层次目录格式
|
||||
$rule = 'index.php?c=category&dir=$'.$rname['{pdirname}'].'&page=$'.$rname['{page}'];
|
||||
} else {
|
||||
// id模式
|
||||
$rule = 'index.php?c=category&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
|
||||
}
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['list']) {
|
||||
$rule = $value['list'];
|
||||
$cname = "【".$r['name']."】模块栏目列表({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg || !$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{dirname}']) && !isset($rname['{id}']) && !isset($rname['{pdirname}'])) {
|
||||
$error.= "<p>".$cname."缺少{dirname}或{id}或{pdirname}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
if (isset($rname['{dirname}'])) {
|
||||
// 目录格式
|
||||
$rule = 'index.php?c=category&dir=$'.$rname['{dirname}'];
|
||||
} elseif (isset($rname['{pdirname}'])) {
|
||||
// 层次目录格式
|
||||
$rule = 'index.php?c=category&dir=$'.$rname['{pdirname}'];
|
||||
} else {
|
||||
// id模式
|
||||
$rule = 'index.php?c=category&id=$'.$rname['{id}'];
|
||||
}
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['show_page']) {
|
||||
$rule = $value['show_page'];
|
||||
$cname = "【".$r['name']."】模块内容页(分页)({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg || !$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{page}'])) {
|
||||
$error.= "<p>".$cname."缺少{page}标签,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{id}'])) {
|
||||
$error.= "<p>".$cname."缺少{id}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$rule = 'index.php?c=show&id=$'.$rname['{id}'].'&page=$'.$rname['{page}'];
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['show']) {
|
||||
$rule = $value['show'];
|
||||
$cname = "【".$r['name']."】模块内容页({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg || !$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{id}'])) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$rule = 'index.php?c=show&id=$'.$rname['{id}'];
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----结束'.PHP_EOL;
|
||||
} elseif ($r['type'] == 2 ) {
|
||||
// 共享模块
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----开始'.PHP_EOL;
|
||||
if ($value['search_page']) {
|
||||
$rule = $value['search_page'];
|
||||
$cname = "【".$r['name']."】模块搜索页(分页)({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg || !$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{modname}'])) {
|
||||
$error.= "<p>".$cname."缺少{modname}标签,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{param}'])) {
|
||||
$error.= "<p>".$cname."缺少{param}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=search&rewrite=$'.$rname['{param}'];
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($value['search']) {
|
||||
$rule = $value['search'];
|
||||
$cname = "【".$r['name']."】模块搜索页({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg || !$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{modname}'])) {
|
||||
$error.= "<p>".$cname."缺少{modname}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$rule = 'index.php?s=$'.$rname['{modname}'].'&c=search';
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----结束'.PHP_EOL;
|
||||
} elseif ($r['type'] == 4 ) {
|
||||
// 关键词库插件
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----开始'.PHP_EOL;
|
||||
if ($value['tag']) {
|
||||
$rule = $value['tag'];
|
||||
$cname = "【".$r['name']."】TagURL({$rule})";
|
||||
list($preg, $rname) = $this->_rule_preg_value($rule);
|
||||
if (!$preg || !$rname) {
|
||||
$error.= "<p>".$cname."无法识别,需要手动写解析规则</p>";
|
||||
} elseif (!isset($rname['{tag}'])) {
|
||||
$error.= "<p>".$cname."缺少{tag}标签,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$rule = 'index.php?s=tag&name=$'.$rname['{tag}'];
|
||||
if (isset($write[$preg])) {
|
||||
$error.= "<p>".$cname."与".$write[$preg]."规则存在冲突,需要手动写解析规则</p>";
|
||||
} else {
|
||||
$write[$preg] = $cname;
|
||||
$code.= '<textarea class="form-control" rows="1"> "'.$preg.'" => "'.$rule.'", //'.$cname."(此规则由系统生成,不一定会准确,请开发者自行调整)</textarea>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$code.= PHP_EOL.' // '.$r['name'].'---解析规则----结束'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
return dr_return_data(1, dr_lang('生成成功'), [
|
||||
'code' => nl2br($code),
|
||||
'error' => $error,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 正则解析
|
||||
private function _rule_preg_value($rule) {
|
||||
|
||||
$rule = trim(trim($rule, '/'));
|
||||
|
||||
if (preg_match_all('/\{(.*)\}/U', $rule, $match)) {
|
||||
|
||||
$value = [];
|
||||
foreach ($match[0] as $k => $v) {
|
||||
$value[$v] = ($k + 1);
|
||||
}
|
||||
|
||||
$preg = preg_replace(
|
||||
[
|
||||
'#\{id\}#U',
|
||||
'#\{uid\}#U',
|
||||
'#\{mid\}#U',
|
||||
'#\{fid\}#U',
|
||||
'#\{page\}#U',
|
||||
|
||||
'#\{pdirname\}#Ui',
|
||||
'#\{dirname\}#Ui',
|
||||
'#\{opdirname\}#Ui',
|
||||
'#\{otdirname\}#Ui',
|
||||
'#\{modname\}#Ui',
|
||||
'#\{name\}#Ui',
|
||||
|
||||
'#\{tag\}#U',
|
||||
'#\{param\}#U',
|
||||
'#\{rewrite\}#U',
|
||||
|
||||
'#\{y\}#U',
|
||||
'#\{m\}#U',
|
||||
'#\{d\}#U',
|
||||
|
||||
'#\{\.+}#U',
|
||||
'#/#'
|
||||
],
|
||||
[
|
||||
'([0-9]+)',
|
||||
'([0-9]+)',
|
||||
'(\d+)',
|
||||
'(\w+)',
|
||||
'([0-9]+)',
|
||||
|
||||
'([\w\/]+)',
|
||||
'([A-za-z0-9 \-\_]+)',
|
||||
'([A-za-z0-9 \-\_]+)',
|
||||
'([A-za-z0-9 \-\_]+)',
|
||||
'([a-z]+)',
|
||||
'([a-z]+)',
|
||||
|
||||
'(.+)',
|
||||
'(.+)',
|
||||
'(.+)',
|
||||
|
||||
'([0-9]{4})',
|
||||
'([0-9]{2})',
|
||||
'([0-9]{2})',
|
||||
|
||||
'(.+)',
|
||||
'\/'
|
||||
],
|
||||
$rule
|
||||
);
|
||||
|
||||
// 替换特殊的结果
|
||||
$preg = str_replace(
|
||||
['(.+))}-', '.html'],
|
||||
['(.+)-', '\.html'],
|
||||
$preg
|
||||
);
|
||||
|
||||
return [$preg, $value];
|
||||
}
|
||||
|
||||
return [$rule, []];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
class Urlrule_code extends \Phpcmf\App
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
$domain = [];
|
||||
list($module, $site) = \Phpcmf\Service::M('Site')->domain();
|
||||
$domain[$site['site_domain']] = dr_lang('本站电脑域名');
|
||||
$site['mobile_domain'] && $domain[$site['mobile_domain']] = dr_lang('本站手机域名');
|
||||
if ($module) {
|
||||
foreach ($module as $dir => $t) {
|
||||
if ($site['module_'.$dir]) {
|
||||
$domain[$site['module_'.$dir]] = dr_lang('%s电脑域名', $t['name']);
|
||||
}
|
||||
if ($site['module_mobile_'.$dir]) {
|
||||
$domain[$site['module_mobile_'.$dir]] = dr_lang('%s手机域名', $t['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$site = \Phpcmf\Service::M('Site')->config(SITE_ID);
|
||||
if ($site['client']) {
|
||||
foreach ($site['client'] as $t) {
|
||||
if ($t['domain']) {
|
||||
$domain[$t['domain']] = dr_lang('%s终端域名', $t['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strpos($site['config']['SITE_DOMAIN'], '/') !== false) {
|
||||
list($a, $b) = explode('/', $site['config']['SITE_DOMAIN']);
|
||||
$root = '/'.$b;
|
||||
} else {
|
||||
$root = '';
|
||||
}
|
||||
$server = strtolower($_SERVER['SERVER_SOFTWARE']);
|
||||
if (strpos($server, 'apache') !== FALSE) {
|
||||
$name = 'Apache';
|
||||
$note = '<font color=red><b>将以下内容保存为.htaccess文件,放到每个域名所绑定的根目录</b></font>';
|
||||
$code = '';
|
||||
|
||||
// 子目录
|
||||
$code.= '###当存在多个子目录格式的域名时,需要多写几组RewriteBase标签:RewriteBase /目录/ '.PHP_EOL;
|
||||
if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
|
||||
$code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
|
||||
$code.= 'RewriteBase /'.$site['mobile']['dirname'].'/'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
|
||||
.'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /'.$site['mobile']['dirname'].'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
|
||||
$code.= '####以上目录需要单独保持到/'.$site['mobile']['dirname'].'/.htaccess文件中';
|
||||
}
|
||||
// 主目录
|
||||
$code.= 'RewriteEngine On'.PHP_EOL.PHP_EOL;
|
||||
$code.= 'RewriteBase '.$root.'/'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
|
||||
.'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ '.$root.'/index.php [NC,L]'.PHP_EOL.PHP_EOL;
|
||||
} elseif (strpos($server, 'nginx') !== FALSE) {
|
||||
$name = $server;
|
||||
$note = '<font color=red><b>将以下代码放到Nginx配置文件中去(如果是绑定了域名,所绑定目录也要配置下面的代码)</b></font>';
|
||||
// 子目录
|
||||
$code = '###当存在多个子目录格式的域名时,需要多写几组location标签:location /目录/ '.PHP_EOL;
|
||||
if (isset($site['mobile']['mode']) && $site['mobile']['mode'] && $site['mobile']['dirname']) {
|
||||
$code.= 'location '.$root.'/'.$site['mobile']['dirname'].'/ { '.PHP_EOL
|
||||
.' if (-f $request_filename) {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if (!-e $request_filename) {'.PHP_EOL
|
||||
.' rewrite . '.$root.'/'.$site['mobile']['dirname'].'/index.php last;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.'}'.PHP_EOL.PHP_EOL;
|
||||
}
|
||||
// 主目录
|
||||
$code.= 'location '.$root.'/ { '.PHP_EOL
|
||||
.' if (-f $request_filename) {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if ($request_filename ~* "\.(js|ico|gif|jpe?g|bmp|png|css)$") {'.PHP_EOL
|
||||
.' break;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.' if (!-e $request_filename) {'.PHP_EOL
|
||||
.' rewrite . '.$root.'/index.php last;'.PHP_EOL
|
||||
.' }'.PHP_EOL
|
||||
.'}'.PHP_EOL;
|
||||
} else {
|
||||
$name = $server;
|
||||
$note = '<font color=red><b>无法为此服务器提供伪静态规则,建议让运营商帮你把下面的Apache规则做转换</b></font>';
|
||||
$code = 'RewriteEngine On'.PHP_EOL
|
||||
.'RewriteBase /'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-f'.PHP_EOL
|
||||
.'RewriteCond %{REQUEST_FILENAME} !-d'.PHP_EOL
|
||||
.'RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]';
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'name' => $name,
|
||||
'code' => $code,
|
||||
'note' => $note,
|
||||
'domain' => $domain,
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'伪静态代码' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-link'],
|
||||
]
|
||||
),
|
||||
'count' => $code ? dr_count(explode(PHP_EOL, $code)) : 0,
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('urlrule_code.html');exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
<?php namespace Phpcmf\Controllers;
|
||||
|
||||
class Api extends \Phpcmf\App
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function category() {
|
||||
|
||||
$dirname = dr_safe_filename(\Phpcmf\Service::L('input')->get('mid'));
|
||||
if (!$dirname) {
|
||||
$dirname = dr_safe_filename(\Phpcmf\Service::L('input')->get('module'));
|
||||
}
|
||||
if (!$dirname) {
|
||||
$this->_json(0, dr_lang('module参数不存在'));
|
||||
}
|
||||
|
||||
$site = max(1, (int)\Phpcmf\Service::L('input')->get('site'));
|
||||
if (!$site) {
|
||||
$site = SITE_ID;
|
||||
}
|
||||
|
||||
// 独立模块填目录 / 共享模块填 share
|
||||
$category = \Phpcmf\Service::L('category', 'module')->get_category($dirname, $site);
|
||||
if (!$category) {
|
||||
$this->_json(0, dr_lang('栏目不存在或未生成缓存'), []);
|
||||
}
|
||||
|
||||
// 模块是否共享(缓存)
|
||||
$mod_share = [];
|
||||
|
||||
$list = [];
|
||||
foreach ($category as $id => $t) {
|
||||
if (!$t || !is_array($t)) {
|
||||
continue;
|
||||
}
|
||||
$tid = (int)($t['tid'] ?? 0);
|
||||
// 外链栏目不输出
|
||||
if ($tid === 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cid = (int)($t['id'] ?? $id);
|
||||
$cmid = dr_safe_filename((string)($t['mid'] ?? ''));
|
||||
|
||||
// show_url:基础路径,站点域名与 api_token 由客户端自行组装
|
||||
if ($dirname !== 'share') {
|
||||
$t['show_url'] = 'index.php?s='.$dirname.'&c=category&id='.$cid;
|
||||
} else {
|
||||
$use_s = false;
|
||||
if ($cmid !== '') {
|
||||
if (!isset($mod_share[$cmid])) {
|
||||
$mod = \Phpcmf\Service::L('cache')->get('module-'.$site.'-'.$cmid);
|
||||
$mod_share[$cmid] = ($mod && empty($mod['share'])) ? 0 : 1;
|
||||
}
|
||||
// share=0 表示独立模块
|
||||
$use_s = ($mod_share[$cmid] === 0);
|
||||
}
|
||||
if ($use_s) {
|
||||
$t['show_url'] = 'index.php?s='.$cmid.'&c=category&id='.$cid;
|
||||
} else {
|
||||
$t['show_url'] = 'index.php?c=category&id='.$cid;
|
||||
}
|
||||
}
|
||||
|
||||
// list_url:模块栏目才有列表
|
||||
if ($tid === 1 && $cmid !== '') {
|
||||
$t['list_url'] = 'index.php?s='.$cmid.'&c=search&catid='.$cid;
|
||||
} else {
|
||||
$t['list_url'] = '';
|
||||
}
|
||||
|
||||
$list[$id] = $t;
|
||||
}
|
||||
|
||||
$this->_json(1, 'ok', $list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 内容关联字段数据读取
|
||||
*/
|
||||
public function related() {
|
||||
|
||||
// 强制将模板设置为后台
|
||||
\Phpcmf\Service::V()->admin();
|
||||
|
||||
// 登陆判断
|
||||
/*
|
||||
if (!$this->uid) {
|
||||
$this->_json(0, dr_lang('会话超时,请重新登录'));
|
||||
}*/
|
||||
|
||||
// 参数判断
|
||||
$dirname = dr_safe_filename(\Phpcmf\Service::L('input')->get('module'));
|
||||
if (!$dirname) {
|
||||
$this->_json(0, dr_lang('module参数不存在'));
|
||||
}
|
||||
|
||||
// 站点选择
|
||||
$site = max(1, (int)\Phpcmf\Service::L('input')->get('site'));
|
||||
$pagesize = (int)\Phpcmf\Service::L('input')->get('pagesize');
|
||||
if (!$pagesize) {
|
||||
$pagesize = 10;
|
||||
}
|
||||
|
||||
// 模块缓存判断
|
||||
$module = $this->get_cache('module-'.$site.'-'.$dirname);
|
||||
if (!$module) {
|
||||
$this->_json(0, dr_lang('模块(%s)不存在', $dirname));
|
||||
}
|
||||
|
||||
$module['field']['id'] = [
|
||||
'name' => 'Id',
|
||||
'ismain' => 1,
|
||||
'fieldtype' => 'Text',
|
||||
'fieldname' => 'id',
|
||||
];
|
||||
|
||||
$param = $data = \Phpcmf\Service::L('input')->get('', true);
|
||||
|
||||
$diy = dr_safe_filename($data['diy']);
|
||||
|
||||
if (IS_POST) {
|
||||
$ids = \Phpcmf\Service::L('input')->get_post_ids();
|
||||
if (!$ids) {
|
||||
$this->_json(0, dr_lang('没有选择项'));
|
||||
}
|
||||
$id = [];
|
||||
foreach ($ids as $i) {
|
||||
$id[] = (int)$i;
|
||||
}
|
||||
$builder = \Phpcmf\Service::M()->db->table($site.'_'.$dirname);
|
||||
$builder->whereIn('id', $id);
|
||||
$mylist = $builder->orderBy('updatetime DESC')->get()->getResultArray();
|
||||
if (!$mylist) {
|
||||
$this->_json(0, dr_lang('没有相关数据'));
|
||||
}
|
||||
$name = dr_safe_filename(\Phpcmf\Service::L('input')->get('name'));
|
||||
if (!$name) {
|
||||
$this->_json(0, dr_lang('name参数不能为空'));
|
||||
}
|
||||
|
||||
$mid = $dirname;
|
||||
$ids = [];
|
||||
foreach ($mylist as $t) {
|
||||
$ids[] = $t['id'];
|
||||
}
|
||||
|
||||
$file = \Phpcmf\Service::V()->code2php(
|
||||
file_get_contents(is_file(MYPATH.'View/api_related_field_'.$diy.'.html') ? MYPATH.'View/api_related_field_'.$diy.'.html' : COREPATH.'View/api_related_field.html')
|
||||
);
|
||||
ob_start();
|
||||
require $file;
|
||||
$code = ob_get_clean();
|
||||
$html = explode('<!--list-->', $code);
|
||||
|
||||
$this->_json(1, dr_lang('操作成功'), ['ids' => $ids, 'html' => $html[1]]);
|
||||
}
|
||||
|
||||
$my = intval($data['my']);
|
||||
$where = [];
|
||||
if ($my) {
|
||||
$where[] = 'uid = '.$this->uid;
|
||||
} elseif ($this->member && $this->member['adminid'] > 0) {
|
||||
$module['field']['uid'] = [
|
||||
'name' => dr_lang('账号'),
|
||||
'ismain' => 1,
|
||||
'fieldtype' => 'Text',
|
||||
'fieldname' => 'uid',
|
||||
];
|
||||
}
|
||||
if ($data['search']) {
|
||||
$catid = (int)$data['catid'];
|
||||
if ($catid) {
|
||||
$cat = dr_cat_value($module['mid'], $catid);
|
||||
if ($cat['catids']) {
|
||||
$where[] = '`catid` in('.implode(',', $cat['catids']).')';
|
||||
}
|
||||
}
|
||||
$data['keyword'] = dr_safe_replace(urldecode($data['keyword']));
|
||||
if (isset($data['keyword']) && $data['keyword'] && $data['field'] && isset($module['field'][$data['field']])) {
|
||||
$data['keyword'] = dr_safe_replace(urldecode($data['keyword']));
|
||||
if ($data['field'] == 'id') {
|
||||
// id搜索
|
||||
$id = [];
|
||||
$ids = explode(',', $data['keyword']);
|
||||
foreach ($ids as $i) {
|
||||
$id[] = (int)$i;
|
||||
}
|
||||
$where[] = 'id in('.implode(',', $id).')';
|
||||
} else if ($data['field'] == 'uid') {
|
||||
$uid = \Phpcmf\Service::M('member')->uid($data['keyword']);
|
||||
$where[] = 'uid = '.intval($uid);
|
||||
} else {
|
||||
// 其他模糊搜索
|
||||
$where[] = $data['field'].' LIKE "%'.$data['keyword'].'%"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort($module['field']);
|
||||
$rules = $data;
|
||||
$rules['page'] = '{page}';
|
||||
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'diy' => $data['diy'],
|
||||
'mid' => $dirname,
|
||||
'mmid' => $module['mid'],
|
||||
'site' => $site,
|
||||
'param' => $data,
|
||||
'field' => $module['field'],
|
||||
'where' => $where ? urlencode(implode(' AND ', $where)) : '',
|
||||
'search' => dr_form_search_hidden(['search' => 1, 'is_iframe' => 1, 'module' => $dirname, 'site' => $site, 'diy' => $data['diy'], 'my' => $my, 'pagesize' => $pagesize]),
|
||||
'select' => \Phpcmf\Service::L('category', 'module')->select(
|
||||
$module['dirname'],
|
||||
$data['catid'],
|
||||
'name="catid"',
|
||||
'--'
|
||||
),
|
||||
'urlrule' => '/index.php?s=module&c=api&m=related&'.http_build_query($rules),
|
||||
'pagesize' => $pagesize,
|
||||
]);
|
||||
if (is_file(MYPATH.'View/api_related_'.$diy.'.html')) {
|
||||
\Phpcmf\Service::V()->display('api_related_'.$diy.'.html');
|
||||
} else {
|
||||
\Phpcmf\Service::V()->display('api_related.html');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php namespace Phpcmf\Controllers;
|
||||
|
||||
class Home extends \Phpcmf\App
|
||||
{
|
||||
|
||||
public function index() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,54 @@
|
||||
<?php namespace Phpcmf\Admin;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
// 属性配置
|
||||
class Config extends \Phpcmf\Common {
|
||||
|
||||
// 模块自由属性配置
|
||||
private $fix_admin_tpl_path;
|
||||
|
||||
protected function _Module_Param() {
|
||||
|
||||
// 初始化模块
|
||||
$this->_module_init(APP_DIR);
|
||||
|
||||
$data = \Phpcmf\Service::M()->table('module')->where('dirname', APP_DIR)->getRow();
|
||||
if (!$data) {
|
||||
$this->_admin_msg(0, dr_lang('模块#%s不存在', APP_DIR));
|
||||
}
|
||||
|
||||
|
||||
$data['setting'] = dr_string2array($data['setting']);
|
||||
if (!isset($data['setting']['param'])) {
|
||||
$data['setting']['param'] = [];
|
||||
}
|
||||
|
||||
if (IS_POST) {
|
||||
$post = \Phpcmf\Service::L('input')->post('data');
|
||||
$data['setting']['param'] = $post;
|
||||
\Phpcmf\Service::M()->db->table('module')->where('dirname', APP_DIR)->update([
|
||||
'setting' => dr_array2string($data['setting']),
|
||||
]);
|
||||
$this->_json(1, '操作成功');
|
||||
}
|
||||
|
||||
$page = intval(\Phpcmf\Service::L('input')->get('page'));
|
||||
$this->fix_admin_tpl_path = dr_get_app_dir('module').'Views/';
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'page' => $page,
|
||||
'form' => dr_form_hidden(['page' => $page]),
|
||||
'data' => $data['setting']['param'],
|
||||
'menu' => \Phpcmf\Service::M('auth')->_admin_menu(
|
||||
[
|
||||
'参数配置' => [APP_DIR.'/'.\Phpcmf\Service::L('Router')->class.'/index', 'fa fa-cog'],
|
||||
]
|
||||
),
|
||||
]);
|
||||
\Phpcmf\Service::V()->display('param.html');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,858 @@
|
||||
<?php namespace Phpcmf\Home;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
// 用于前端模块内容显示
|
||||
class Module extends \Phpcmf\Common {
|
||||
|
||||
public $module; // 模块信息
|
||||
public $is_prev_next_page = 1; // 启用内容页上下页计算
|
||||
|
||||
// 模块首页
|
||||
public function _Index($html = 0) {
|
||||
|
||||
if (IS_POST) {
|
||||
$this->_json(0, '禁止提交,请检查提交地址是否有误');
|
||||
}
|
||||
|
||||
// 初始化模块
|
||||
$this->_module_init();
|
||||
|
||||
// 执行自定义方法
|
||||
$this->content_model->_call_index();
|
||||
|
||||
// 共享模块时禁止访问首页
|
||||
if ($this->module['share']) {
|
||||
$this->goto_404_page(dr_lang('共享模块没有首页功能'));
|
||||
}
|
||||
|
||||
if ($this->module['setting']['search']['indexsync']) {
|
||||
// 集成搜索
|
||||
return $this->_Search(0);
|
||||
} else {
|
||||
// 判断URL重复问题
|
||||
if (!$html) {
|
||||
\Phpcmf\Service::L('Router')->is_redirect_url(dr_url_prefix(MODULE_URL, $this->module['dirname']), 1);
|
||||
}
|
||||
|
||||
// 模板变量
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'indexm' => 1,
|
||||
'pageid' => max(1, max(1, (int)\Phpcmf\Service::L('input')->get('page'))),
|
||||
'fix_html_now_url' => defined('IS_MOBILE') && IS_MOBILE ? $this->module['murl'] : $this->module['url'],
|
||||
]);
|
||||
\Phpcmf\Service::V()->assign($this->content_model->_format_home_seo($this->module));
|
||||
\Phpcmf\Hooks::trigger('module_index');
|
||||
|
||||
// 系统开启静态首页
|
||||
if (!defined('SC_HTML_FILE') && $this->module['setting']['module_index_html']) {
|
||||
|
||||
ob_start();
|
||||
\Phpcmf\Service::V()->display('index.html');
|
||||
$html = ob_get_clean();
|
||||
|
||||
if ($this->module['domain']) {
|
||||
// 绑定域名时
|
||||
$file = 'index.html';
|
||||
} else {
|
||||
$file = ltrim(\Phpcmf\Service::L('Router')->remove_domain(MODULE_URL), '/'); // 从地址中获取要生成的文件名;
|
||||
}
|
||||
|
||||
if (!$file) {
|
||||
// 静态文件失败就输出当前页面
|
||||
echo $html;exit;
|
||||
}
|
||||
|
||||
if (IS_CLIENT) {
|
||||
// 终端下不生成
|
||||
} elseif (defined('IS_MOBILE') && IS_MOBILE) {
|
||||
// 移动端访问
|
||||
if (SITE_IS_MOBILE || $this->module['mobile_domain']) {
|
||||
file_put_contents(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath(SITE_ID, $this->module['dirname'], SITE_MOBILE_DIR.'/'.$file) : WEBPATH.SITE_MOBILE_DIR.'/'.$file, $html);
|
||||
}
|
||||
} else {
|
||||
// 电脑端访问
|
||||
file_put_contents(dr_is_app('chtml') ? \Phpcmf\Service::L('html', 'chtml')->get_webpath(SITE_ID, $this->module['dirname'], $file) : WEBPATH.$file, $html);
|
||||
}
|
||||
echo $html;
|
||||
} else {
|
||||
\Phpcmf\Service::V()->display('index.html');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 模块搜索
|
||||
protected function _Search($_catid = 0, $rt = 0) {
|
||||
|
||||
if (IS_POST) {
|
||||
$this->_json(0, '禁止提交,请检查提交地址是否有误');
|
||||
}
|
||||
|
||||
// 模型类
|
||||
$search = \Phpcmf\Service::M('Search', $this->module['dirname'])->init($this->module['dirname']);
|
||||
|
||||
// 搜索参数
|
||||
list($catid, $get) = $search->get_param($this->module);
|
||||
!$catid && $_catid && $catid = $_catid;
|
||||
$catid = intval($catid);
|
||||
|
||||
// 非http请求之下
|
||||
if (!IS_API_HTTP) {
|
||||
if (!isset($this->module['setting']['search']['use']) || !$this->module['setting']['search']['use']) {
|
||||
$this->_msg(0, dr_lang('此模块已经关闭了搜索功能'));
|
||||
} elseif (IS_USE_MEMBER && \Phpcmf\Service::M('member_auth', 'cms')->module_auth($this->module['dirname'], 'search', $this->member)) {
|
||||
$this->_msg(0, dr_lang('您的用户组无权限搜索'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
|
||||
} elseif ($get['keyword'] && $this->module['setting']['search']['length']
|
||||
&& dr_strlen($get['keyword']) < (int)$this->module['setting']['search']['length']) {
|
||||
$this->_msg(0, dr_lang('关键字不得少于系统规定的长度'));
|
||||
} elseif ($get['keyword'] && $this->module['setting']['search']['maxlength']
|
||||
&& dr_strlen($get['keyword']) > (int)$this->module['setting']['search']['maxlength']) {
|
||||
$this->_msg(0, dr_lang('关键字不得大于系统规定的长度'));
|
||||
}
|
||||
}
|
||||
|
||||
//搜索参数为空时不显示结果
|
||||
$null = 0;
|
||||
if (isset($this->module['setting']['search']['search_param']) && $this->module['setting']['search']['search_param']) {
|
||||
if (!$get) {
|
||||
$null = 1;
|
||||
} else {
|
||||
$null = 1;
|
||||
foreach ($get as $t) {
|
||||
if ($t) {
|
||||
$null = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($null) {
|
||||
$data = [
|
||||
'id' => 0,
|
||||
'catid' => $catid,
|
||||
'params' => $get,
|
||||
'keyword' => $get['keyword'],
|
||||
'contentid' => 0,
|
||||
'inputtime' => SYS_TIME
|
||||
];
|
||||
} else {
|
||||
// 搜索数据
|
||||
$data = $search->get_data();
|
||||
if (isset($data['code']) && $data['code'] == 0 && $data['msg']) {
|
||||
$this->_msg(0, $data['msg']);
|
||||
}
|
||||
unset($data['params']['page']);
|
||||
}
|
||||
|
||||
// 格式化数据
|
||||
$data = $this->content_model->_call_search($data);
|
||||
|
||||
// 挂钩点 搜索完成之后
|
||||
$rt2 = \Phpcmf\Hooks::trigger_callback('module_search_data', $data);
|
||||
if ($rt2 && isset($rt2['code']) && $rt2['code']) {
|
||||
$data = $rt2['data'];
|
||||
}
|
||||
|
||||
// 获取同级栏目及父级栏目
|
||||
list($parent, $related) = dr_related_cat(
|
||||
!$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
|
||||
$catid
|
||||
);
|
||||
|
||||
// 获取搜索总量
|
||||
$sototal = intval($data['contentid']);
|
||||
|
||||
//开启后遇到搜索内容为空时直接跳转404页面
|
||||
if (!$null && !$sototal && isset($this->module['setting']['search']['search_404']) && $this->module['setting']['search']['search_404']) {
|
||||
\Phpcmf\Service::C()->goto_404_page('内容匹配结果为空');
|
||||
}
|
||||
|
||||
// 存储缓存以便标签中使用
|
||||
if ($data['id'] && $sototal) {
|
||||
\Phpcmf\Service::L('cache')->set_data('module-search-'.$this->module['dirname'].'-'.$data['id'], $data, 3600);
|
||||
}
|
||||
|
||||
$list = [];
|
||||
// 移动端请求时
|
||||
if (IS_API_HTTP && $data['id']) {
|
||||
$rt2 = \Phpcmf\Service::V()->list_tag('search module='.$this->module['dirname']
|
||||
.' id='.$data['id'].' total='.$sototal
|
||||
.' order='.$data['params']['order'].' catid='.$catid
|
||||
.(isset($_GET['more']) && $_GET['more'] ? ' more=1' : '')
|
||||
.' page=1 pagesize='.intval(\Phpcmf\Service::L('input')->request('pagesize'))
|
||||
.' urlrule=test');
|
||||
$list = $rt2['return'];
|
||||
}
|
||||
|
||||
// 栏目格式化
|
||||
$cat = $catid && $this->module['category'][$catid] ? $this->module['category'][$catid] : [];
|
||||
$cat && $cat['url'] = dr_url_prefix($cat['url'], MOD_DIR);
|
||||
$top = $cat;
|
||||
if ($catid && $cat['topid']) {
|
||||
$top = $this->module['category'][$cat['topid']];
|
||||
$cat['url'] = dr_url_prefix($cat['url'], MOD_DIR);
|
||||
}
|
||||
|
||||
// 分页地址
|
||||
$urlrule = dr_module_search_url($data['params'], 'page', '{page}');
|
||||
|
||||
// 识别自定义地址,301定向
|
||||
if (dr_is_sys_301() && !IS_API_HTTP && !isset($_GET['ajax_page'])
|
||||
&& strpos(FC_NOW_URL, 'index.php') !== false && strpos($urlrule, 'index.php') === false) {
|
||||
$get['page'] > 1 && $data['params']['page'] = $get['page'];
|
||||
dr_redirect(dr_module_search_url($data['params']), 'auto', 301);exit;
|
||||
}
|
||||
|
||||
\Phpcmf\Service::V()->assign($this->content_model->_format_search_seo(
|
||||
$this->module,
|
||||
$catid,
|
||||
($sototal or (!$sototal && isset($this->module['setting']['search']['show_seo']) && $this->module['setting']['search']['show_seo'])) ? $data['params'] : [],
|
||||
$get['page'])
|
||||
);
|
||||
|
||||
$search_data = [
|
||||
'cat' => $cat,
|
||||
'top' => $top,
|
||||
'get' => $get,
|
||||
'list' => $list,
|
||||
'catid' => $catid,
|
||||
'parent' => $parent,
|
||||
'pageid' => max(1, $get['page']),
|
||||
'params' => dr_htmlspecialchars($data['params']),
|
||||
'keyword' => dr_htmlspecialchars($data['keyword']),
|
||||
'related' => $related,
|
||||
'urlrule' => $urlrule,
|
||||
'sototal' => $sototal,
|
||||
'searchid' => $data['id'],
|
||||
'search_id' => $data['id'],
|
||||
'search_sql' => $data['sql'],
|
||||
'is_search_page' => 1,
|
||||
];
|
||||
\Phpcmf\Service::V()->assign($search_data);
|
||||
\Phpcmf\Service::V()->module($this->module['dirname']);
|
||||
|
||||
$tpl = '';
|
||||
if (isset($_GET['ajax_page']) && $_GET['ajax_page']) {
|
||||
$tpl = dr_safe_filename($_GET['ajax_page']);
|
||||
if (!is_file(\Phpcmf\Service::V()->get_dir().$tpl)) {
|
||||
log_message('debug', '搜索模板参数ajax_page值对应的模板('.\Phpcmf\Service::V()->get_dir().$tpl.')不存在,将加载默认的搜索模板');
|
||||
$tpl = ''; // 自定义模板不存在
|
||||
}
|
||||
} elseif (isset($this->module['setting']['search']['tpl_field'])
|
||||
&& $this->module['setting']['search']['tpl_field']
|
||||
&& isset($get[$this->module['setting']['search']['tpl_field']])
|
||||
&& $get[$this->module['setting']['search']['tpl_field']]
|
||||
) {
|
||||
$tpl = dr_safe_filename('search_'.$get[$this->module['setting']['search']['tpl_field']].'.html');
|
||||
if (!is_file(\Phpcmf\Service::V()->get_dir().$tpl)) {
|
||||
$msg = '搜索模板字段'.$this->module['setting']['search']['tpl_field'].'参数值对应的模板('.\Phpcmf\Service::V()->get_dir().$tpl.')不存在,将加载默认的搜索模板';
|
||||
log_message('debug', $msg);
|
||||
//\Phpcmf\Service::V()->add_load_tips($tpl, $msg);
|
||||
}
|
||||
}
|
||||
if (!$tpl) {
|
||||
$tpl = $catid && $this->module['category'][$catid]['setting']['template']['search'] ? $this->module['category'][$catid]['setting']['template']['search'] : 'search.html';
|
||||
}
|
||||
|
||||
// 输出方式
|
||||
if (!$rt) {
|
||||
\Phpcmf\Service::V()->display($tpl);
|
||||
} else {
|
||||
$search_data['phpcmf_tpl'] = $search_data['tpl'] = $tpl;
|
||||
return $search_data;
|
||||
}
|
||||
}
|
||||
|
||||
// 模块栏目页
|
||||
public function _Category($catid = 0, $catdir = null, $page = 1, $rt = 0) {
|
||||
|
||||
if (IS_POST) {
|
||||
$this->_json(0, '禁止提交,请检查提交地址是否有误');
|
||||
}
|
||||
|
||||
if ($catid) {
|
||||
$category = $this->module['category'][$catid];
|
||||
if (!$category) {
|
||||
$this->goto_404_page(dr_lang('模块【%s】栏目(%s)不存在', $this->module['dirname'], $catid));
|
||||
return;
|
||||
}
|
||||
} elseif ($catdir) {
|
||||
$catid = intval($this->module['category_dir'][$catdir]);
|
||||
$category = $this->module['category'][$catid];
|
||||
if (!$category) {
|
||||
// 无法通过目录找到栏目时,尝试多及目录
|
||||
foreach ($this->module['category'] as $t) {
|
||||
if ($t['setting']['urlrule']) {
|
||||
$rule = \Phpcmf\Service::L('cache')->get('urlrule', $t['setting']['urlrule']);
|
||||
$rule['value']['catjoin'] = '/';
|
||||
if ($rule['value']['catjoin'] && strpos($catdir, $rule['value']['catjoin'])) {
|
||||
$catdir = trim(strchr($catdir, $rule['value']['catjoin']), $rule['value']['catjoin']);
|
||||
if (isset($this->module['category_dir'][$catdir])) {
|
||||
$catid = $this->module['category_dir'][$catdir];
|
||||
$category = $this->module['category'][$catid];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 返回无法找到栏目
|
||||
if (!$category) {
|
||||
$this->goto_404_page(dr_lang('模块【%s】栏目(%s)不存在', $this->module['dirname'], $catdir));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->goto_404_page(dr_lang('模块【%s】栏目不存在', $this->module['dirname']));
|
||||
return;
|
||||
}
|
||||
|
||||
// 格式化栏目数据
|
||||
$category = $this->content_model->_call_category($category);
|
||||
|
||||
// 挂钩点 格式化栏目数据
|
||||
$rt2 = \Phpcmf\Hooks::trigger_callback('module_category_data', $category);
|
||||
if ($rt2 && isset($rt2['code']) && $rt2['code']) {
|
||||
$category = $rt2['data'];
|
||||
}
|
||||
|
||||
// 判断是否外链
|
||||
if ($category['tid'] == 2) {
|
||||
dr_redirect(dr_url_prefix($category['url'], $this->module['dirname'], SITE_ID), 'refresh');exit;
|
||||
}
|
||||
|
||||
// 验证是否存在子栏目,是否将下级第一个栏目作为当前页
|
||||
if ($category['tid'] != 2 && $category['child'] && $category['setting']['getchild']) {
|
||||
$temp = explode(',', $category['childids']);
|
||||
if ($temp) {
|
||||
foreach ($temp as $i) {
|
||||
if ($i != $catid && $this->module['category'][$i]['show']
|
||||
&& $this->module['category'][$i]['tid'] != 2
|
||||
&& !$this->module['category'][$i]['setting']['getchild']) {
|
||||
$catid = $i;
|
||||
$category = $this->module['category'][$i];
|
||||
if (!$rt) {
|
||||
$url = dr_url_prefix($category['url'], $this->module['dirname']);
|
||||
if (defined('IS_MY_ADMIN')) {
|
||||
// 是否自定义后台域名
|
||||
}
|
||||
if (SITE_ID > 1) {
|
||||
// 多站点
|
||||
$url = str_replace(SITE_URL, trim(FC_NOW_HOST, '/').WEB_DIR, $url);
|
||||
} elseif (IS_CLIENT) {
|
||||
// 自由参数时 终端时 替换当前域名
|
||||
$url = str_replace(SITE_URL, FC_NOW_HOST, $url);
|
||||
} elseif (SYS_301) {
|
||||
// 自由参数时 替换当前域名
|
||||
$url = str_replace(SITE_URL, WEB_DIR, $url);
|
||||
}
|
||||
if (defined('SC_HTML_FILE')) {
|
||||
\Phpcmf\Service::V()->assign('goto_url', $url);
|
||||
\Phpcmf\Service::V()->display('goto_url');
|
||||
return $category;
|
||||
} elseif (!IS_API_HTTP){
|
||||
if (IS_DEV) {
|
||||
// 自动识别
|
||||
\Phpcmf\Service::C()->_admin_msg(1, '开发者模式:<br>当前URL['.dr_now_url().']<br>已开启集成下级栏目['.$url.']<br>正在自动跳转下级栏目地址(关闭开发者模式时即可自动跳转)', $url, 9);
|
||||
}
|
||||
dr_redirect($url, 'location', '301');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// 初始化模块
|
||||
$this->_module_init($category['mid'] ? $category['mid'] : 'share');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转到搜索页面
|
||||
if (!defined('SC_HTML_FILE')
|
||||
&& isset($this->module['setting']['search']['catsync'])
|
||||
&& $this->module['setting']['search']['catsync']
|
||||
&& $category['tid'] == 1) {
|
||||
$_GET = [
|
||||
'catid' => $catid
|
||||
];
|
||||
return $this->_Search($catid);
|
||||
}
|
||||
|
||||
// 无权限访问栏目
|
||||
if (IS_USE_MEMBER && !defined('SC_HTML_FILE')) {
|
||||
if (($this->module['share']) && $category['tid'] == 0) {
|
||||
// 识别栏目单网页
|
||||
if (!\Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'show', $this->member)) {
|
||||
$this->_msg(0, dr_lang('您的用户组无权限访问栏目'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!\Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'show', $this->member)) {
|
||||
$this->_msg(0, dr_lang('您的用户组无权限访问栏目'), $this->uid || !defined('SC_HTML_FILE') ? '' : dr_member_url('login/index'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$category['url'] = dr_url_prefix($category['url'], $this->module['dirname']);
|
||||
$top = $category;
|
||||
if ($catid && $category['topid']) {
|
||||
$top = $this->module['category'][$category['topid']];
|
||||
$top['url'] = dr_url_prefix($top['url'], $this->module['dirname']);
|
||||
}
|
||||
|
||||
// 判断内容唯一性
|
||||
!$rt && \Phpcmf\Service::L('Router')->is_redirect_url(
|
||||
$page > 1 ? dr_url_prefix(dr_module_category_url($this->module, $category, $page), $this->module['dirname']) : $category['url'],
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
// 获取同级栏目及父级栏目
|
||||
list($parent, $related) = dr_related_cat(
|
||||
!$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
|
||||
$catid
|
||||
);
|
||||
|
||||
// 传入模板
|
||||
\Phpcmf\Service::V()->assign($this->content_model->_format_category_seo($this->module, $catid, $page));
|
||||
\Phpcmf\Service::V()->assign(array(
|
||||
'id' => $catid,
|
||||
'cat' => $category,
|
||||
'top' => $top,
|
||||
'catid' => $catid,
|
||||
'params' => ['catid' => $catid],
|
||||
'pageid' => max(1, $page),
|
||||
'parent' => $parent,
|
||||
'related' => $related,
|
||||
'urlrule' => \Phpcmf\Service::L('Router')->category_url($this->module, $category, '[page]'),
|
||||
'fix_html_now_url' => defined('SC_HTML_FILE') ? dr_url_prefix(\Phpcmf\Service::L('Router')->category_url($this->module, $category, $page), $this->module['dirname'], SITE_ID, \Phpcmf\Service::IS_MOBILE_TPL()) : '', // 修复静态下的当前url变量
|
||||
));
|
||||
|
||||
// 识别栏目单网页模板
|
||||
if (($this->module['share'] || (isset($this->module['config']['scategory']) && $this->module['config']['scategory'])) && $category['tid'] == 0) {
|
||||
\Phpcmf\Service::V()->assign($category);
|
||||
$tpl = !$category['setting']['template']['page'] ? 'page.html' : $category['setting']['template']['page'];
|
||||
} else {
|
||||
if ($this->module['dirname'] != 'share') {
|
||||
\Phpcmf\Service::V()->module($this->module['dirname']);
|
||||
}
|
||||
if ($category['child']) {
|
||||
$tpl = $category['setting']['template']['category'] ? $category['setting']['template']['category'] : 'category.html';
|
||||
} else {
|
||||
$tpl = $category['setting']['template']['list'] ? $category['setting']['template']['list'] : 'list.html';
|
||||
}
|
||||
}
|
||||
|
||||
// 输出方式
|
||||
if (!$rt) {
|
||||
\Phpcmf\Service::V()->display($tpl);
|
||||
} else {
|
||||
$category['phpcmf_tpl'] = $category['tpl'] = $tpl;
|
||||
return $category;
|
||||
}
|
||||
}
|
||||
|
||||
// 模块内容页
|
||||
// $param 自定义字段检索
|
||||
public function _Show($id = 0, $param = [], $page = 1, $rt = 0) {
|
||||
|
||||
if (IS_POST) {
|
||||
$this->_json(0, '禁止提交,请检查提交地址是否有误');
|
||||
}
|
||||
|
||||
// 通过自定义字段查找id
|
||||
$is_id = 1;
|
||||
if (!$id && isset($param['field']) && isset($param['value'])) {
|
||||
$id = md5($param['field'].$param['value']);
|
||||
$is_id = 0;
|
||||
}
|
||||
|
||||
$name = 'module_'.$this->module['dirname'].'_show_id_'.$id.($this->is_mobile ? '_m' : '').($page > 1 ? '_p'.$page : '');
|
||||
$data = \Phpcmf\Service::L('cache')->get_data($name);
|
||||
if (!$data) {
|
||||
$data = $this->content_model->get_data($is_id ? $id : 0, 0, $param);
|
||||
if (!$data) {
|
||||
$this->goto_404_page(dr_lang('%s内容(#%s)不存在', $this->module['name'], $id));
|
||||
return;
|
||||
}
|
||||
|
||||
// 检测转向字段
|
||||
if (!$rt) {
|
||||
foreach ($this->module['field'] as $t) {
|
||||
if ($t['fieldtype'] == 'Redirect' && $data[$t['fieldname']]) {
|
||||
// 存在转向字段时的情况
|
||||
\Phpcmf\Service::M()->db->table(dr_module_table_prefix($this->module['dirname']))->where('id', $id)->set('hits', 'hits+1', FALSE)->update();
|
||||
\Phpcmf\Service::V()->assign('goto_url', $data[$t['fieldname']]);
|
||||
\Phpcmf\Service::V()->display('goto_url');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化字段
|
||||
$data = $this->_Show_Data($data, $page);
|
||||
|
||||
// 缓存结果
|
||||
if ($data['uid'] != $this->uid && SYS_CACHE) {
|
||||
if ($this->member && $this->member['is_admin']) {
|
||||
// 管理员时不进行缓存
|
||||
\Phpcmf\Service::L('cache')->init()->delete($name);
|
||||
} else {
|
||||
\Phpcmf\Service::L('cache')->set_data($name, $data, SYS_CACHE_SHOW * 3600);
|
||||
if (!$is_id) {
|
||||
// 表示自定义查询,再缓存一次ID
|
||||
\Phpcmf\Service::L('cache')->set_data(str_replace($id, $data['id'], $name), $data, SYS_CACHE_SHOW * 3600);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if ($data['status'] == 10 && !($this->uid == $data['uid'] || $this->member['is_admin'])) {
|
||||
$this->goto_404_page(dr_lang('内容被删除,暂时无法访问'));
|
||||
return $data;
|
||||
}*/
|
||||
|
||||
$catid = $data['catid'];
|
||||
|
||||
if ($this->is_hcategory) {
|
||||
$parent = $related = [];
|
||||
$rt2 = $this->content_model->_hcategory_member_show_auth();
|
||||
if (!$rt2['code']) {
|
||||
$this->_msg(0, $rt2['msg'], $rt2['data']);
|
||||
}
|
||||
} else {
|
||||
// 无权限访问栏目内容
|
||||
if (IS_USE_MEMBER && !defined('SC_HTML_FILE')
|
||||
&& !\Phpcmf\Service::M('member_auth', 'cms')->category_auth($this->module, $catid, 'show', $this->member)) {
|
||||
$this->_msg(0, dr_lang('您的用户组无权限访问栏目'), $this->uid ? '' : dr_member_url('login/index'));
|
||||
return $data;
|
||||
}
|
||||
// 判断是否同步栏目
|
||||
if ($data['link_id'] && $data['link_id'] > 0) {
|
||||
\Phpcmf\Service::V()->assign('gotu_url', dr_url_prefix($data['url'], $this->module['dirname']));
|
||||
\Phpcmf\Service::V()->display('go.html', 'admin');
|
||||
return $data;
|
||||
}
|
||||
// 获取同级栏目及父级栏目
|
||||
list($parent, $related) = dr_related_cat(
|
||||
!$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
|
||||
$data['catid']
|
||||
);
|
||||
}
|
||||
|
||||
// 判断分页
|
||||
if ($page && $data['content_page'] && !$data['content_page'][$page]) {
|
||||
$this->goto_404_page(dr_lang('内容(#%s)分页[%s]不存在', $id, $page));
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 判断内容唯一性
|
||||
!$rt && \Phpcmf\Service::L('Router')->is_redirect_url(
|
||||
dr_url_prefix($page > 1 ? dr_module_show_url($this->module, $data, $page) : $data['url'], $this->module['dirname']),
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
$cat = $this->module['category'][$catid];
|
||||
$cat['url'] = dr_url_prefix($cat['url'], $this->module['dirname']);
|
||||
$top = $cat;
|
||||
if ($catid && $cat['topid']) {
|
||||
$top = $this->module['category'][$cat['topid']];
|
||||
$top['url'] = dr_url_prefix($top['url'], $this->module['dirname']);
|
||||
}
|
||||
|
||||
if (method_exists($this->content_model, '_call_show_after')) {
|
||||
$data = $this->content_model->_call_show_after($data);
|
||||
}
|
||||
|
||||
// 挂钩点
|
||||
$data['cat'] = $cat;
|
||||
$rt2 = \Phpcmf\Hooks::trigger_callback('module_show', $data);
|
||||
if ($rt2 && isset($rt2['code']) && $rt2['code']) {
|
||||
$data = $rt2['data'];
|
||||
}
|
||||
|
||||
$data = dr_array22array($data, $this->content_model->_format_show_seo($this->module, $data, $page));
|
||||
|
||||
// 传入模板
|
||||
\Phpcmf\Service::V()->assign($data);
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'top' => $top,
|
||||
'pageid' => max(1, $page),
|
||||
'params' => ['catid' => $catid],
|
||||
'parent' => $parent,
|
||||
'related' => $related,
|
||||
'urlrule' => \Phpcmf\Service::L('Router')->show_url($this->module, $data, '[page]'),
|
||||
'fix_html_now_url' => defined('SC_HTML_FILE') ? dr_url_prefix(\Phpcmf\Service::L('Router')->show_url($this->module, $data, $page), $this->module['dirname'], SITE_ID, \Phpcmf\Service::IS_MOBILE_TPL()) : '', // 修复静态下的当前url变量
|
||||
]);
|
||||
\Phpcmf\Service::V()->module($this->module['dirname']);
|
||||
|
||||
$data['phpcmf_tpl'] = isset($data['template']) && strpos($data['template'], '.html') !== FALSE && is_file(\Phpcmf\Service::V()->get_dir().$data['template']) ? $data['template'] : ($cat['setting']['template']['show'] ? $cat['setting']['template']['show'] : 'show.html');
|
||||
!$rt && \Phpcmf\Service::V()->display($data['phpcmf_tpl']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 模块草稿、审核、定时、内容页
|
||||
protected function _MyShow($type, $id = 0, $page = 1) {
|
||||
|
||||
if (IS_POST) {
|
||||
$this->_json(0, '禁止提交,请检查提交地址是否有误');
|
||||
}
|
||||
|
||||
// 标记字符
|
||||
define('MODULE_MYSHOW', $type);
|
||||
|
||||
// 按类型加载内容
|
||||
switch($type) {
|
||||
|
||||
case 'time':
|
||||
$row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_time')->get($id);
|
||||
$data = dr_string2array($row['content']);
|
||||
if (!$data) {
|
||||
$this->goto_404_page(dr_lang('定时内容#%s不存在', $id));
|
||||
} elseif (($this->uid != $data['uid'] && !$this->member['is_admin'])) {
|
||||
$this->goto_404_page(dr_lang('定时内容只能自己访问'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'recycle':
|
||||
$row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_recycle')->get($id);
|
||||
$row = dr_string2array($row['content']);
|
||||
if (!$row) {
|
||||
$this->goto_404_page(dr_lang('回收站内容#%s不存在', $id));
|
||||
} elseif (!$row[SITE_ID.'_'.$this->module['dirname']]) {
|
||||
$this->goto_404_page(dr_lang('回收站内容#%s格式不规范', $id));
|
||||
} elseif (!$this->member['is_admin']) {
|
||||
$this->goto_404_page(dr_lang('无权限访问回收站的内容'));
|
||||
}
|
||||
$data = $row[SITE_ID.'_'.$this->module['dirname']];
|
||||
if (isset($row[SITE_ID.'_'.$this->module['dirname'].'_data_'.intval($data['tableid'])])
|
||||
&& $row[SITE_ID.'_'.$this->module['dirname'].'_data_'.intval($data['tableid'])]) {
|
||||
$data = array_merge($data, $row[SITE_ID.'_'.$this->module['dirname'].'_data_'.intval($data['tableid'])]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'verify':
|
||||
$row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_verify')->get($id);
|
||||
$data = dr_string2array($row['content']);
|
||||
if (!$data) {
|
||||
$this->goto_404_page(dr_lang('审核内容#%s不存在', $id));
|
||||
} elseif (!$this->uid) {
|
||||
$this->goto_404_page(dr_lang('需要登录之后才能查看'));
|
||||
} elseif (($this->uid != $data['uid'] && !$this->member['is_admin'])) {
|
||||
$this->goto_404_page(dr_lang('无权限访问审核中的内容'));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'draft':
|
||||
$row = \Phpcmf\Service::M()->table(dr_module_table_prefix($this->module['dirname']).'_draft')->get($id);
|
||||
$data = dr_string2array($row['content']);
|
||||
if (!$data) {
|
||||
$this->goto_404_page( dr_lang('草稿内容#%s不存在', $id));
|
||||
} elseif (!$this->uid) {
|
||||
$this->goto_404_page(dr_lang('需要登录之后才能查看'));
|
||||
} elseif (($this->uid != $data['uid'] && !$this->member['is_admin'])) {
|
||||
$this->goto_404_page(dr_lang('无权限访问别人的草稿箱内容'));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->goto_404_page(dr_lang('未定义的操作'));exit;
|
||||
}
|
||||
|
||||
$data['id'] = 0;
|
||||
|
||||
// 格式化字段
|
||||
$data = $this->_Show_Data($data, $page);
|
||||
|
||||
// 判断分页
|
||||
if ($page && $data['content_page'] && !$data['content_page'][$page]) {
|
||||
$this->goto_404_page(dr_lang('该分页不存在'));
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取同级栏目及父级栏目
|
||||
list($parent, $related) = dr_related_cat(
|
||||
!$this->module['share'] ? $this->module['category'] : \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-share', 'category'),
|
||||
$data['catid']
|
||||
);
|
||||
|
||||
\Phpcmf\Service::V()->assign($data);
|
||||
\Phpcmf\Service::V()->assign(\Phpcmf\Service::L('Seo')->show($this->module, $data, $page));
|
||||
\Phpcmf\Service::V()->assign([
|
||||
'cat' => $this->module['category'][$data['catid']],
|
||||
'pageid' => max(1, $page),
|
||||
'params' => ['catid' => $data['catid']],
|
||||
'parent' => $parent,
|
||||
'related' => $related,
|
||||
'urlrule' => \Phpcmf\Service::L('Router')->show_url($this->module, $data, '[page]'),
|
||||
]);
|
||||
\Phpcmf\Service::V()->module($this->module['dirname']);
|
||||
\Phpcmf\Service::V()->display(is_file(dr_tpl_path().'show_'.$type.'.html') ? 'show_'.$type.'.html' : 'show.html');
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 内容页面的字段格式化处理
|
||||
protected function _Show_Data($data, $page) {
|
||||
|
||||
|
||||
// 格式化输出自定义字段
|
||||
$fields = $this->module['category_data_field'] ? array_merge($this->module['field'], $this->module['category_data_field']) : $this->module['field'];
|
||||
$fields['inputtime'] = ['fieldtype' => 'Date'];
|
||||
$fields['updatetime'] = ['fieldtype' => 'Date'];
|
||||
|
||||
// 格式化字段
|
||||
$data = \Phpcmf\Service::L('Field')->app($this->module['dirname'])->format_value($fields, $data, $page);
|
||||
|
||||
// 处理关键字标签
|
||||
$data['tag'] = $data['keywords'] = isset($data['keywords']) && $data['keywords'] ? trim((string)$data['keywords']) : '';
|
||||
$data['kws'] = [];
|
||||
$data['tags'] = [];
|
||||
|
||||
if (dr_is_app('tag')) {
|
||||
// 是否安装tag
|
||||
$obj = \Phpcmf\Service::M('tag', 'tag');
|
||||
if (!method_exists($obj, 'get_tag_url')) {
|
||||
$obj = false;
|
||||
}
|
||||
$tfield = 'keywords';
|
||||
if (method_exists($obj, 'tag_field')) {
|
||||
$tfield = \Phpcmf\Service::M('tag', 'tag')->tag_field(MOD_DIR);
|
||||
}
|
||||
if ($tfield && isset($data[$tfield]) && $data[$tfield]) {
|
||||
$tag = explode(',', (string)$data[$tfield]);
|
||||
foreach ($tag as $t) {
|
||||
$t = trim($t);
|
||||
if ($t) {
|
||||
// 读缓存
|
||||
if ($obj) {
|
||||
$url = $obj->get_tag_url($t);
|
||||
if ($url) {
|
||||
$data['tags'][$t] = dr_url_rel($url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['keywords']) {
|
||||
$kw = explode(',', $data['keywords']);
|
||||
foreach ($kw as $t) {
|
||||
$t = trim($t);
|
||||
if ($t) {
|
||||
$data['kws'][$t] = dr_module_search_url([], 'keyword', $t, MOD_DIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 挂钩点 内容读取之后
|
||||
$rt2 = \Phpcmf\Hooks::trigger_callback('module_show_data', $data);
|
||||
if ($rt2 && isset($rt2['code']) && $rt2['code']) {
|
||||
$data = $rt2['data'];
|
||||
}
|
||||
|
||||
// 模块的回调处理
|
||||
$data = $this->content_model->_call_show($data);
|
||||
|
||||
// 防止被外部修改
|
||||
if ($this->is_prev_next_page) {
|
||||
// 关闭插件嵌入
|
||||
$is_fstatus = dr_is_app('fstatus') && isset($this->module['field']['fstatus']) && $this->module['field']['fstatus']['ismain'] ? 1 : 0;
|
||||
|
||||
// 上一篇文章
|
||||
$builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable);
|
||||
$builder->where('catid', (int)$data['catid']);//->where('status', 9)
|
||||
$is_fstatus && $builder->where('fstatus', 1);
|
||||
$builder->where('id<'. (int)$data['id'])->orderBy('id desc');
|
||||
$data['prev_page'] = $builder->limit(1)->get()->getRowArray();
|
||||
if (isset($data['prev_page']['url']) && $data['prev_page']['url']) {
|
||||
$data['prev_page']['url'] = dr_url_rel(dr_url_prefix($data['prev_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile));
|
||||
}
|
||||
|
||||
// 下一篇文章
|
||||
$builder = \Phpcmf\Service::M()->db->table($this->content_model->mytable);
|
||||
$builder->where('catid', (int)$data['catid']);//->where('status', 9)
|
||||
$is_fstatus && $builder->where('fstatus', 1);
|
||||
$builder->where('id>'. (int)$data['id'])->orderBy('id asc');
|
||||
$data['next_page'] = $builder->limit(1)->get()->getRowArray();
|
||||
if (isset($data['next_page']['url']) && $data['next_page']['url']) {
|
||||
$data['next_page']['url'] = dr_url_rel(dr_url_prefix($data['next_page']['url'], $this->module['dirname'], SITE_ID, $this->is_mobile));
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 前端模块回调处理类
|
||||
protected function _Call_Show($data) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 模块打赏
|
||||
protected function _Donation($id = 0, $rt = 0) {
|
||||
// 从框架中移除打赏插件的支持代码
|
||||
$this->goto_404_page('请升级打赏插件,此功能不再支持');
|
||||
}
|
||||
|
||||
|
||||
//==================生成静态部分 - 单个文件生成(继承,用于增加修改时实时生成)=========================
|
||||
|
||||
|
||||
// 生成栏目静态页
|
||||
protected function _Category_Html_File() {
|
||||
if (dr_is_app('chtml')) {
|
||||
\Phpcmf\Service::L('html', 'chtml')->_Category_Html_File($this, APP_DIR);
|
||||
} else {
|
||||
$this->_json(0, '没有安装官方版【静态生成】插件');
|
||||
}
|
||||
}
|
||||
|
||||
// 生成内容静态单页
|
||||
protected function _Show_Html_File() {
|
||||
if (dr_is_app('chtml')) {
|
||||
\Phpcmf\Service::L('html', 'chtml')->_Show_Html_File($this, APP_DIR);
|
||||
} else {
|
||||
$this->_json(0, '没有安装官方版【静态生成】插件');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==================生成静态部分 - 后台操作Ajax生成执行=========================
|
||||
|
||||
|
||||
// 生成首页静态选项列表
|
||||
protected function _Index_Html() {
|
||||
if (dr_is_app('chtml')) {
|
||||
\Phpcmf\Service::L('html', 'chtml')->_Index_Html($this);
|
||||
} else {
|
||||
$this->_json(0, '没有安装官方版【静态生成】插件');
|
||||
}
|
||||
}
|
||||
|
||||
// 生成内容静态选项列表
|
||||
protected function _Show_Html() {
|
||||
if (dr_is_app('chtml')) {
|
||||
\Phpcmf\Service::L('html', 'chtml')->_Show_Html($this, APP_DIR);
|
||||
} else {
|
||||
$this->_json(0, '没有安装官方版【静态生成】插件');
|
||||
}
|
||||
}
|
||||
|
||||
// 生成内容静态选项列表
|
||||
protected function _Category_Html() {
|
||||
if (dr_is_app('chtml')) {
|
||||
\Phpcmf\Service::L('html', 'chtml')->_Category_Html($this, APP_DIR);
|
||||
} else {
|
||||
$this->_json(0, '没有安装官方版【静态生成】插件');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,128 @@
|
||||
<?php namespace Phpcmf\Field;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
class Cat extends \Phpcmf\Library\A_Field {
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct(...$params) {
|
||||
parent::__construct(...$params);
|
||||
$this->fieldtype = ['INT' => 10];
|
||||
$this->defaulttype = 'INT';
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段相关属性参数
|
||||
*
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function option($option) {
|
||||
|
||||
$_option = '';
|
||||
$_module = \Phpcmf\Service::C()->get_cache('module-'.SITE_ID.'-content');
|
||||
if ($_module) {
|
||||
$_option.= '<option value="share" '.('share' == $option['module'] ? 'selected' : '').'>'.dr_lang('共享栏目').'</option>';
|
||||
foreach ($_module as $dir => $t) {
|
||||
if (!$t['share']) {
|
||||
$_option.= '<option value="'.$dir.'" '.($dir == $option['module'] ? 'selected' : '').'>'.$t['name'].'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ['<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('内容模块').'</label>
|
||||
<div class="col-md-9">
|
||||
<label><select class="form-control" name="data[setting][option][module]">
|
||||
'.$_option.'
|
||||
</select></label>
|
||||
<span class="help-block">'.dr_lang('必须选择一个模块作为栏目的数据源').'</span>
|
||||
</div>
|
||||
</div><div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('选择父栏目').'</label>
|
||||
<div class="col-md-9">
|
||||
<input type="checkbox" name="data[setting][option][parent]" '.($option['parent'] ? 'checked' : '').' value="1" data-on-text="'.dr_lang('已开启').'" data-off-text="'.dr_lang('已关闭').'" data-on-color="success" data-off-color="danger" class="make-switch" data-size="small">
|
||||
<span class="help-block">'.dr_lang('开启之后可以选择父级栏目').'</span>
|
||||
</div>
|
||||
</div><div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('启用选项搜索').'</label>
|
||||
<div class="col-md-9">
|
||||
<input type="checkbox" name="data[setting][option][is_search]" '.($option['is_search'] ? 'checked' : '').' value="1" data-on-text="'.dr_lang('已开启').'" data-off-text="'.dr_lang('已关闭').'" data-on-color="success" data-off-color="danger" class="make-switch" data-size="small">
|
||||
|
||||
<span class="help-block">'.dr_lang('当选项值过多时,可以在选择框中搜索选项值').'</span>
|
||||
</div>
|
||||
</div>', ''];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字段输出
|
||||
*/
|
||||
public function output($value) {
|
||||
return intval($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段入库值
|
||||
*
|
||||
* @param array $field 字段信息
|
||||
* @return void
|
||||
*/
|
||||
public function insert_value($field) {
|
||||
\Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = intval(\Phpcmf\Service::L('Field')->post[$field['fieldname']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单输入
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function input($field, $value = null) {
|
||||
|
||||
// 字段禁止修改时就返回显示字符串
|
||||
if ($this->_not_edit($field, $value)) {
|
||||
return $this->show($field, $value);
|
||||
}
|
||||
|
||||
// 字段存储名称
|
||||
$name = $field['fieldname'];
|
||||
|
||||
// 字段显示名称
|
||||
$text = ($field['setting']['validate']['required'] ? '<span class="required" aria-required="true"> * </span>' : '').dr_lang($field['name']);
|
||||
|
||||
// 字段提示信息
|
||||
$tips = ($name == 'title' && APP_DIR) || $field['setting']['validate']['tips'] ? '<span class="help-block" id="dr_'.$field['fieldname'].'_tips">'.$field['setting']['validate']['tips'].'</span>' : '';
|
||||
|
||||
// 开始输出
|
||||
$str = '';
|
||||
$str.= '<label style="min-width: 200px">'.\Phpcmf\Service::L('category', 'module')->select(
|
||||
$field['setting']['option']['module'],
|
||||
intval($value),
|
||||
' name=\'data['.$field['fieldname'].']\' data-actions-box="true" '.(isset($field['setting']['option']['is_search']) && $field['setting']['option']['is_search'] ? ' data-live-search="true" ' : ''),
|
||||
'', (isset($field['setting']['option']['parent']) && $field['setting']['option']['parent'] ? 0 : 1), 0
|
||||
).'</label>';
|
||||
$str.= '<span class="help-block">'.$tips.'</span>';
|
||||
return $this->input_format($name, $text, $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单显示
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function show($field, $value = null) {
|
||||
|
||||
return $this->input_format($field['fieldname'], $field['name'], '<div class="form-control-static">'.dr_catpos($value, ' - ', false, '', $field['setting']['option']['module']).'</div>');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
<?php namespace Phpcmf\Field;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
class Catids extends \Phpcmf\Library\A_Field {
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct(...$params) {
|
||||
parent::__construct(...$params);
|
||||
$this->fieldtype = ['TEXT' => ''];
|
||||
$this->defaulttype = 'TEXT';
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段相关属性参数
|
||||
*
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function option($option) {
|
||||
|
||||
|
||||
return ['
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('重要提醒').'</label>
|
||||
<div class="col-md-9"><label class="form-control-static">本字段名一定要是catids才能参与搜索</label></div>
|
||||
</div>
|
||||
', '<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('控件宽度').'</label>
|
||||
<div class="col-md-9">
|
||||
<label><input type="text" class="form-control" size="10" name="data[setting][option][width]" value="'.$option['width'].'"></label>
|
||||
<span class="help-block">'.dr_lang('[整数]表示固定宽度;[整数%]表示百分比').'</span>
|
||||
</div>
|
||||
</div>'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字段输出
|
||||
*/
|
||||
public function output($value) {
|
||||
return dr_string2array($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段入库值
|
||||
*
|
||||
* @param array $field 字段信息
|
||||
* @return void
|
||||
*/
|
||||
public function insert_value($field) {
|
||||
$save = [];
|
||||
$data = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
|
||||
if ($data) {
|
||||
$data = dr_string2array($data);
|
||||
if (!IS_ADMIN) {
|
||||
// 验证发布权限
|
||||
$category = \Phpcmf\Service::C()->_get_module_member_category(\Phpcmf\Service::C()->module, 'add');
|
||||
if (!$category) {
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('模块[%s]没有可用栏目权限', \Phpcmf\Service::C()->module['dirname']));
|
||||
}
|
||||
foreach ($data as $t) {
|
||||
if ($t) {
|
||||
$save[] = $t;
|
||||
if (!$category[$t]) {
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('模块[%s]没有栏目(%s)权限', \Phpcmf\Service::C()->module['dirname'], $t));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach ($data as $t) {
|
||||
if ($t) {
|
||||
$save[] = $t;
|
||||
}
|
||||
}
|
||||
}
|
||||
$save = array_unique($save);
|
||||
}
|
||||
\Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = dr_array2string($save);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单输入
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function input($field, $value = null) {
|
||||
|
||||
// 字段禁止修改时就返回显示字符串
|
||||
if ($this->_not_edit($field, $value)) {
|
||||
return $this->show($field, $value);
|
||||
}
|
||||
|
||||
// 字段存储名称
|
||||
$name = $field['fieldname'];
|
||||
|
||||
// 字段显示名称
|
||||
$text = ($field['setting']['validate']['required'] ? '<span class="required" aria-required="true"> * </span>' : '').dr_lang($field['name']);
|
||||
|
||||
// 字段提示信息
|
||||
$tips = ($name == 'title' && APP_DIR) || $field['setting']['validate']['tips'] ? '<span class="help-block" id="dr_'.$field['fieldname'].'_tips">'.$field['setting']['validate']['tips'].'</span>' : '';
|
||||
|
||||
// 开始输出
|
||||
$str = '';
|
||||
$str.= '<label style="min-width: 200px">'.\Phpcmf\Service::L('category', 'module')->select(
|
||||
\Phpcmf\Service::C()->module['dirname'],
|
||||
dr_string2array($value),
|
||||
' name=\'data['.$field['fieldname'].'][]\' multiple="multiple" data-actions-box="true"',
|
||||
'', 1, 1
|
||||
).'</label>';
|
||||
$str.= '<span class="help-block">'.$tips.'</span>';
|
||||
return $this->input_format($name, $text, $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单显示
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function show($field, $value = null) {
|
||||
|
||||
|
||||
return $this->input_format($field['fieldname'], $field['name'], '<div class="form-control-static">'.dr_linkagepos($field['setting']['option']['linkage'], $value, ' - ').'</div>');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php namespace Phpcmf\Field;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
class Cats extends \Phpcmf\Field\Cat {
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct(...$params) {
|
||||
parent::__construct(...$params);
|
||||
$this->fieldtype = ['TEXT' => ''];
|
||||
$this->defaulttype = 'TEXT';
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段输出
|
||||
*/
|
||||
public function output($value) {
|
||||
return dr_string2array($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段入库值
|
||||
*
|
||||
* @param array $field 字段信息
|
||||
* @return void
|
||||
*/
|
||||
public function insert_value($field) {
|
||||
$value = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
|
||||
if (is_array($value)) {
|
||||
$value = dr_array2string($value);
|
||||
}
|
||||
\Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单输入
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function input($field, $value = null) {
|
||||
|
||||
// 字段禁止修改时就返回显示字符串
|
||||
if ($this->_not_edit($field, $value)) {
|
||||
return $this->show($field, $value);
|
||||
}
|
||||
|
||||
// 字段存储名称
|
||||
$name = $field['fieldname'];
|
||||
|
||||
// 字段显示名称
|
||||
$text = ($field['setting']['validate']['required'] ? '<span class="required" aria-required="true"> * </span>' : '').dr_lang($field['name']);
|
||||
|
||||
// 字段提示信息
|
||||
$tips = ($name == 'title' && APP_DIR) || $field['setting']['validate']['tips'] ? '<span class="help-block" id="dr_'.$field['fieldname'].'_tips">'.$field['setting']['validate']['tips'].'</span>' : '';
|
||||
|
||||
// 开始输出
|
||||
$str = '';
|
||||
$str.= '<label style="min-width: 200px">'.\Phpcmf\Service::L('category', 'module')->select(
|
||||
$field['setting']['option']['module'],
|
||||
dr_string2array($value),
|
||||
' name=\'data['.$field['fieldname'].'][]\' multiple="multiple" data-actions-box="true" '.(isset($field['setting']['option']['is_search']) && $field['setting']['option']['is_search'] ? ' data-live-search="true" ' : ''),
|
||||
'', (isset($field['setting']['option']['parent']) && $field['setting']['option']['parent'] ? 0 : 1), 0
|
||||
).'</label>';
|
||||
$str.= \Phpcmf\Service::L('Field')->get('select')->get_select_search_code().'<span class="help-block">'.$tips.'</span>';
|
||||
return $this->input_format($name, $text, $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单显示
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function show($field, $value = null) {
|
||||
|
||||
$html = '';
|
||||
$value = dr_string2array($value);
|
||||
if ($value) {
|
||||
foreach ($value as $t) {
|
||||
$html.= '<label class="btn btn-xs default">'.dr_catpos($t, ' - ', false, '', $field['setting']['option']['module']).'</label>';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->input_format($field['fieldname'], $field['name'], '<div class="form-control-static">'.$html.'</div>');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
[
|
||||
'id' => 'Redirect',
|
||||
'name' => '转向链接',
|
||||
'used' => ['module'],
|
||||
],
|
||||
|
||||
[
|
||||
'id' => 'Catids',
|
||||
'name' => '副栏目',
|
||||
'used' => ['module'],
|
||||
],
|
||||
|
||||
[
|
||||
'id' => 'Cat',
|
||||
'name' => '模块栏目(单选)',
|
||||
],
|
||||
|
||||
[
|
||||
'id' => 'Cats',
|
||||
'name' => '模块栏目(多选)',
|
||||
],
|
||||
|
||||
[
|
||||
'id' => 'Related',
|
||||
'name' => '内容关联',
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php namespace Phpcmf\Field;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
class Redirect extends \Phpcmf\Library\A_Field {
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct(...$params) {
|
||||
parent::__construct(...$params);
|
||||
$this->fieldtype = TRUE;
|
||||
$this->defaulttype = 'TEXT';
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段相关属性参数
|
||||
*
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function option($option) {
|
||||
$option['width'] = isset($option['width']) ? $option['width'] : 400;
|
||||
return ['<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('适应范围').'</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-static">'.dr_lang('此字段只能用于模块内容自定义字段').'</p>
|
||||
</div>
|
||||
</div>', '
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('控件宽度').'</label>
|
||||
<div class="col-md-9">
|
||||
<label><input type="text" class="form-control" size="10" name="data[setting][option][width]" value="'.$option['width'].'"></label>
|
||||
<span class="help-block">'.dr_lang('[整数]表示固定宽度;[整数%]表示百分比').'</span>
|
||||
</div>
|
||||
</div>
|
||||
'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段入库值
|
||||
*
|
||||
* @param array $field 字段信息
|
||||
* @return void
|
||||
*/
|
||||
public function insert_value($field) {
|
||||
|
||||
$value = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
|
||||
$value && $value = stripos($value, 'https://') === 0 || stripos($value, 'http://') === 0 ? $value : 'http://'.$value;
|
||||
\Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单输入
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function input($field, $value = null) {
|
||||
|
||||
// 字段禁止修改时就返回显示字符串
|
||||
if ($this->_not_edit($field, $value)) {
|
||||
return $this->show($field, $value);
|
||||
}
|
||||
|
||||
// 字段存储名称
|
||||
$name = $field['fieldname'];
|
||||
|
||||
// 字段显示名称
|
||||
$text = ($field['setting']['validate']['required'] ? '<span class="required" aria-required="true"> * </span>' : '').dr_lang($field['name']);
|
||||
|
||||
// 表单宽度设置
|
||||
$width = \Phpcmf\Service::IS_MOBILE_USER() ? '100%' : ($field['setting']['option']['width'] ? $field['setting']['option']['width'] : 200);
|
||||
|
||||
// 风格
|
||||
$style = 'style="width:'.$width.(is_numeric($width) ? 'px' : '').';"';
|
||||
|
||||
// 表单附加参数
|
||||
$attr = $field['setting']['validate']['formattr'];
|
||||
|
||||
// 字段提示信息
|
||||
$tips = isset($field['setting']['validate']['tips']) && $field['setting']['validate']['tips'] ? '<span class="help-block" id="dr_'.$name.'_tips">'.$field['setting']['validate']['tips'].'</span>' : '';
|
||||
|
||||
// 字段默认值
|
||||
$value = $value && strlen($value) ? $value : $this->get_default_value($field['setting']['option']['value']);
|
||||
|
||||
// 当字段必填时,加入html5验证标签
|
||||
isset($field['setting']['validate']['required']) && $field['setting']['validate']['required'] == 1 && $attr.= ' required="required"';
|
||||
|
||||
$str = '<input class="form-control" type="text" name="data['.$name.']" id="dr_'.$name.'" value="'.$value.'" '.$style.' '.$attr.' />'.$tips;
|
||||
return $this->input_format($name, $text, $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单显示
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function show($field, $value = null) {
|
||||
|
||||
|
||||
return $this->input_format($field['fieldname'], $field['name'], '<div class="form-control-static"><a href="'.$value.'" target="_blank">'.$value.'</a></div>');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
<?php namespace Phpcmf\Field;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
class Related extends \Phpcmf\Library\A_Field {
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public function __construct(...$params) {
|
||||
parent::__construct(...$params);
|
||||
$this->fieldtype = ['TEXT' => '']; // TRUE表全部可用字段类型,自定义格式为 array('可用字段类型名称' => '默认长度', ... )
|
||||
$this->defaulttype = 'TEXT'; // 当用户没有选择字段类型时的缺省值
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段相关属性参数
|
||||
*
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function option($option) {
|
||||
|
||||
$_option = '';
|
||||
$_module = \Phpcmf\Service::C()->get_cache('module-'.SITE_ID.'-content');
|
||||
if ($_module) {
|
||||
foreach ($_module as $dir => $t) {
|
||||
$_option.= '<option value="'.$dir.'" '.($dir == $option['module'] ? 'selected' : '').'>'.$t['name'].'</option>';
|
||||
}
|
||||
}
|
||||
|
||||
return [$this->_search_field().'<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('内容模块').'</label>
|
||||
<div class="col-md-9">
|
||||
<label><select class="form-control" name="data[setting][option][module]">
|
||||
'.$_option.'
|
||||
</select></label>
|
||||
<span class="help-block">'.dr_lang('必须选择一个模块作为关联数据源').'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('显示归属内容').'</label>
|
||||
<div class="col-md-9">
|
||||
<input type="checkbox" name="data[setting][option][my]" '.($option['my'] ? 'checked' : '').' value="1" data-on-text="'.dr_lang('已开启').'" data-off-text="'.dr_lang('已关闭').'" data-on-color="success" data-off-color="danger" class="make-switch" data-size="small">
|
||||
<span class="help-block">'.dr_lang('开启之后只显示当前登录的用户自己所发布的内容').'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('主题显示名称').'</label>
|
||||
<div class="col-md-9">
|
||||
<label><input type="text" class="form-control" size="10" name="data[setting][option][title]" value="'.($option['title'] ? $option['title'] : dr_lang('主题')).'"></label>
|
||||
<span class="help-block">'.dr_lang('用于显示管理的主题字段名称,默认是:主题').'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('最大选择数').'</label>
|
||||
<div class="col-md-9">
|
||||
<label><input type="text" class="form-control" size="10" name="data[setting][option][limit]" value="'.$option['limit'].'"></label>
|
||||
<span class="help-block">'.dr_lang('最大能选择的数量限制').'</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label">'.dr_lang('每页显示条数').'</label>
|
||||
<div class="col-md-9">
|
||||
<label><input type="text" class="form-control" size="10" name="data[setting][option][pagesize]" value="'.$option['pagesize'].'"></label>
|
||||
<span class="help-block">'.dr_lang('选择列表分页条数,按多少条数据分页').'</span>
|
||||
</div>
|
||||
</div>'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段输出
|
||||
*/
|
||||
public function output($value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段入库值
|
||||
*/
|
||||
public function insert_value($field) {
|
||||
|
||||
$data = \Phpcmf\Service::L('Field')->post[$field['fieldname']];
|
||||
$limit = intval($field['setting']['option']['limit']);
|
||||
if ($limit && $data && count($data) > $limit) {
|
||||
// 超限了
|
||||
$value = implode(',', dr_arraycut($data, $limit));
|
||||
} else {
|
||||
$value = !$data ? '' : implode(',', $data);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::L('Field')->data[$field['ismain']][$field['fieldname']] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单输入
|
||||
*
|
||||
* @param string $cname 字段别名
|
||||
* @param string $name 字段名称
|
||||
* @param array $cfg 字段配置
|
||||
* @param string $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function input($field, $value = '') {
|
||||
|
||||
// 字段禁止修改时就返回显示字符串
|
||||
if ($this->_not_edit($field, $value)) {
|
||||
return $this->show($field, $value);
|
||||
}
|
||||
|
||||
if (!IS_USE_MODULE) {
|
||||
return '使用本字段类别需要安装【建站系统】插件';
|
||||
}
|
||||
|
||||
$is_show = 0;
|
||||
|
||||
// 字段存储名称
|
||||
$name = $field['fieldname'];
|
||||
// 字段提示信息
|
||||
$tips = isset($field['setting']['validate']['tips']) && $field['setting']['validate']['tips'] ? '<span class="help-block" id="dr_'.$name.'_tips">'.$field['setting']['validate']['tips'].'</span>' : '';
|
||||
// 区域大小
|
||||
$area = \Phpcmf\Service::IS_MOBILE_USER() ? '["95%", "90%"]' : '["50%", "65%"]';
|
||||
// 模块名称
|
||||
$module = $mid = isset($field['setting']['option']['module']) ? $field['setting']['option']['module'] : '';
|
||||
// 字段显示名称
|
||||
$text = ($field['setting']['validate']['required'] ? '<span class="required" aria-required="true"> * </span>' : '').dr_lang($field['name']);
|
||||
// 选择数量限制
|
||||
$limit = intval($field['setting']['option']['limit']);
|
||||
!$limit && $limit = 99999;
|
||||
// 输出信息
|
||||
$cname = ($field['setting']['option']['title'] ? $field['setting']['option']['title'] : dr_lang('主题'));
|
||||
|
||||
if (!$module) {
|
||||
if (CI_DEBUG) {
|
||||
return $this->input_format($name, $text, '<div class="form-control-static" style="color:red">关联字段没有设置关联模块</div>');
|
||||
}
|
||||
return $this->input_format($name, $text, '');
|
||||
} elseif (!dr_is_module($module)) {
|
||||
if (CI_DEBUG) {
|
||||
return $this->input_format($name, $text, '<div class="form-control-static" style="color:red">关联字段设置的模块【'.$module.'】没有被安装</div>');
|
||||
}
|
||||
return $this->input_format($name, $text, '');
|
||||
}
|
||||
|
||||
$value = $value ? trim($value, ',') : '';
|
||||
$mylist = [];
|
||||
if ($value && is_string($value)) {
|
||||
$arr = explode(',', $value);
|
||||
if ($arr) {
|
||||
$value = '';
|
||||
foreach ($arr as $a) {
|
||||
$a = intval($a);
|
||||
if ($a) {
|
||||
$value.= ','.$a;
|
||||
}
|
||||
}
|
||||
if ($value) {
|
||||
$value = trim($value, ',');
|
||||
$db = \Phpcmf\Service::M()->db->query('select id,title,catid,updatetime,uid,url from '.\Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module)).' where id IN ('.$value.') order by FIELD(id, '.$value.')');
|
||||
$mylist = $db ? $db->getResultArray() : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = is_file(MYPATH.'View/api_related_field_'.$field['fieldname'].'.html') ? MYPATH.'View/api_related_field_'.$field['fieldname'].'.html' : COREPATH.'View/api_related_field.html';
|
||||
if (!is_file($tpl)) {
|
||||
if (CI_DEBUG) {
|
||||
return $this->input_format($name, $text, '<div class="form-control-static" style="color:red">模板文件【'.$tpl.'】不存在</div>');
|
||||
}
|
||||
return $this->input_format($name, $text, '');
|
||||
}
|
||||
$code = file_get_contents($tpl);
|
||||
if (!$code) {
|
||||
if (CI_DEBUG) {
|
||||
return $this->input_format($name, $text, '<div class="form-control-static" style="color:red">模板文件【'.$tpl.'】内容为空</div>');
|
||||
}
|
||||
return $this->input_format($name, $text, '');
|
||||
}
|
||||
$file = \Phpcmf\Service::V()->code2php($code);
|
||||
ob_start();
|
||||
require $file;
|
||||
$str = ob_get_clean();
|
||||
|
||||
$str.= $tips;
|
||||
$js = \Phpcmf\Service::L('js_packer');
|
||||
$str.= $js->pack('
|
||||
<script type="text/javascript">
|
||||
|
||||
dr_slimScroll_init(".scroller_'.$name.'_files", 300);
|
||||
$("#related_'.$name.'-sort-items").sortable();
|
||||
function dr_add_related_'.$name.'() {
|
||||
var len = $(\'#related_'.$name.'-sort-items tr\').length;
|
||||
if (len >= '.$limit.') {
|
||||
dr_tips(0, "'.dr_lang('关联数量超限').'");
|
||||
return;
|
||||
}
|
||||
var url = "'.dr_web_prefix('index.php?s=module&c=api&m=related&name=').$name.'&site='.SITE_ID.'&module='.$module.'&diy='.$field['fieldname'].'&my='.intval($field['setting']['option']['my']).'&pagesize='.intval($field['setting']['option']['pagesize']).'&is_iframe=1";
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: \'<i class="fa fa-cog"></i> '.dr_lang('关联内容').'\',
|
||||
fix:true,
|
||||
shadeClose: true,
|
||||
shade: 0,
|
||||
area: '.$area.',
|
||||
btn: ["'.dr_lang('关联').'"],
|
||||
success: function (json) {
|
||||
if (json.code == 0) {
|
||||
layer.close();
|
||||
dr_tips(json.code, json.msg);
|
||||
}
|
||||
},
|
||||
yes: function(index, layero){
|
||||
var body = layer.getChildFrame(\'body\', index);
|
||||
// 延迟加载
|
||||
var loading = layer.load(2, {
|
||||
time: 10000
|
||||
});
|
||||
$.ajax({type: "POST",dataType:"json", url: url, data: $(body).find(\'#myform\').serialize(),
|
||||
success: function(json) {
|
||||
layer.close(loading);
|
||||
if (json.code == 1) {
|
||||
layer.close(index);
|
||||
if (len + json.data.ids.length > '.$limit.') {
|
||||
dr_tips(0, "'.dr_lang('关联数量超限').'");
|
||||
return;
|
||||
}
|
||||
for(var i in json.data.ids){
|
||||
var vid = json.data.ids[i];
|
||||
if (typeof vid != "undefined") {
|
||||
if($("#dr_items_'.$name.'_"+vid).length>0) {
|
||||
dr_tips(0, "'.dr_lang('已经存在').'");
|
||||
return;
|
||||
}
|
||||
if ($(\'#related_'.$name.'-sort-items tr\').length >= '.$limit.') {
|
||||
dr_tips(0, "'.dr_lang('关联数量超限').'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
$(\'#related_'.$name.'-sort-items\').append(json.data.html);
|
||||
dr_slimScroll_init(".scroller_'.$name.'_files", 300);
|
||||
dr_tips(1, json.msg);
|
||||
} else {
|
||||
dr_tips(0, json.msg);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
content: url
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
</script>', 0);
|
||||
|
||||
return $this->input_format($name, $text, $str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字段表单显示
|
||||
*
|
||||
* @param string $field 字段数组
|
||||
* @param array $value 值
|
||||
* @return string
|
||||
*/
|
||||
public function show($field, $value = null) {
|
||||
|
||||
|
||||
$cname = ($field['setting']['option']['title'] ? $field['setting']['option']['title'] : dr_lang('主题'));
|
||||
$value = @trim($value, ',');
|
||||
$mylist = [];
|
||||
$is_show = 1;
|
||||
$module = $mid = isset($field['setting']['option']['module']) ? $field['setting']['option']['module'] : '';
|
||||
if ($value && is_string($value) && $module) {
|
||||
$arr = explode(',', $value);
|
||||
if ($arr) {
|
||||
$value = '';
|
||||
foreach ($arr as $a) {
|
||||
$a = intval($a);
|
||||
if ($a) {
|
||||
$value.= ','.$a;
|
||||
}
|
||||
}
|
||||
if ($value) {
|
||||
$value = trim($value, ',');
|
||||
$db = \Phpcmf\Service::M()->db->query('select id,title,catid,updatetime,uid,url from '.\Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($module)).' where id IN ('.$value.') order by FIELD(id, '.$value.')');
|
||||
$mylist = $db ? $db->getResultArray() : [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = $field['fieldname'];
|
||||
$file = \Phpcmf\Service::V()->code2php(
|
||||
file_get_contents(is_file(MYPATH.'View/api_related_field_'.$tpl.'.html') ? MYPATH.'View/api_related_field_'.$tpl.'.html' : COREPATH.'View/api_related_field.html')
|
||||
);
|
||||
ob_start();
|
||||
require $file;
|
||||
$str = ob_get_clean();
|
||||
|
||||
return $this->input_format($field['fieldname'], $field['name'], $str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php namespace Phpcmf\Library\Cms;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
class Category {
|
||||
|
||||
protected $ismain = 0;
|
||||
protected $siteid = 0;
|
||||
|
||||
public function ismain($v) {
|
||||
$this->ismain = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function site($v) {
|
||||
$this->siteid = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function select($mid, $id = '', $str = '', $default = ' -- ', $onlysub = 0, $is_push = 0, $is_first = 0) {
|
||||
$siteid = $this->siteid ? $this->siteid : SITE_ID;
|
||||
$select = \Phpcmf\Service::L('Tree')->ismain($this->ismain)->select_category($this->get_category($mid, $siteid), $id, $str, $default, $onlysub, $is_push, $is_first);
|
||||
$this->siteid = 0;
|
||||
return $select;
|
||||
}
|
||||
|
||||
// 获取全部栏目
|
||||
public function get_category($mid, $siteid = SITE_ID) {
|
||||
return \Phpcmf\Service::C()->get_cache('module-'.$siteid.'-'.$mid, 'category');
|
||||
}
|
||||
|
||||
// 获取栏目自定义字段
|
||||
public function get_category_field($cdir) {
|
||||
|
||||
$category_field = [];
|
||||
|
||||
$field = $this->db->table('field')
|
||||
->where('disabled', 0)
|
||||
->where('relatedname', 'category-'.$cdir)
|
||||
->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
|
||||
if ($field) {
|
||||
foreach ($field as $f) {
|
||||
$f['setting'] = dr_string2array($f['setting']);
|
||||
$category_field[$f['fieldname']] = $f;
|
||||
}
|
||||
}
|
||||
|
||||
return $category_field;
|
||||
}
|
||||
|
||||
// 获取下级子栏目
|
||||
public function get_child($mid, $catid, $siteid = SITE_ID) {
|
||||
|
||||
$cats = \Phpcmf\Service::C()->get_cache('module-'.$siteid.'-'.$mid, 'category');
|
||||
if (!$cats) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rt = [];
|
||||
foreach ($cats as $c) {
|
||||
if ($c['pid'] == $catid) {
|
||||
$rt[] = $c['id'];
|
||||
}
|
||||
}
|
||||
|
||||
return $rt;
|
||||
}
|
||||
|
||||
// 通过目录找id
|
||||
public function get_catid($mid, $dir, $siteid = SITE_ID) {
|
||||
|
||||
$cats = \Phpcmf\Service::C()->get_cache('module-'.$siteid.'-'.$mid, 'category_dir');
|
||||
if (!$cats) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return isset($cats[$dir]) ? $cats[$dir] : 0;
|
||||
}
|
||||
|
||||
// 查询所属主栏目
|
||||
public function get_ismain_id($mid, $cat) {
|
||||
|
||||
return $cat['id'];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,466 @@
|
||||
<?php namespace Phpcmf\Library\Cms;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
class Tree {
|
||||
|
||||
protected $data;
|
||||
protected $result_array;
|
||||
protected $icon;
|
||||
protected $nbsp = "{spacer}";
|
||||
protected $nbsp_str;
|
||||
protected $deep = 1;
|
||||
protected $ret;
|
||||
protected $cache = 1;
|
||||
protected $result;
|
||||
protected $ismain = 0;
|
||||
protected $mid = 0;
|
||||
|
||||
// 初始化函数
|
||||
public function __construct() {
|
||||
$this->icon();
|
||||
}
|
||||
|
||||
// 释放变量
|
||||
public function __destruct()
|
||||
{
|
||||
unset($this->data);
|
||||
unset($this->cache);
|
||||
unset($this->ret);
|
||||
unset($this->icon);
|
||||
unset($this->result_array);
|
||||
unset($this->nbsp_str);
|
||||
unset($this->nbsp);
|
||||
unset($this->result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置html标签
|
||||
*/
|
||||
public function html_icon() {
|
||||
$this->nbsp_str = '<span class="tree-icon"></span>';
|
||||
$this->icon = [
|
||||
$this->nbsp_str,
|
||||
'<span class="tree-icon">├ </span>',
|
||||
'<span class="tree-icon">└ </span>'
|
||||
];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置普通标签
|
||||
*/
|
||||
public function icon() {
|
||||
$this->nbsp_str = ' ';
|
||||
$this->icon = [
|
||||
$this->nbsp_str,
|
||||
'├ ',
|
||||
'└ '
|
||||
];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化类
|
||||
*/
|
||||
public function init($arr) {
|
||||
$this->ret = '';
|
||||
$this->data = $arr;
|
||||
$this->result = [];
|
||||
return $this;
|
||||
}
|
||||
|
||||
// 创建数据
|
||||
public function get($data) {
|
||||
$this->data = $data;
|
||||
$this->result = [];
|
||||
$this->create(0);
|
||||
return $this->result_array;
|
||||
}
|
||||
|
||||
// 设置数据
|
||||
protected function _data($data) {
|
||||
$this->ret = '';
|
||||
$this->data = $data;
|
||||
$this->deep = 1;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// 设置缓存
|
||||
public function cache($is) {
|
||||
$this->cache = $is;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到子级数组
|
||||
* @param int
|
||||
* @return array
|
||||
*/
|
||||
protected function get_child($k_id) {
|
||||
|
||||
$arrays = [];
|
||||
|
||||
if ($this->mid) {
|
||||
$child = \Phpcmf\Service::L('category', 'module')->get_child($this->mid, $k_id);
|
||||
if ($child) {
|
||||
foreach ($child as $id) {
|
||||
$this->data[$id] && $arrays[$id] = $this->data[$id];
|
||||
}
|
||||
return $arrays;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($this->data)) {
|
||||
foreach($this->data as $id => $a) {
|
||||
if ($a['pid'] == $k_id) {
|
||||
$arrays[$id] = $a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->deep++;
|
||||
|
||||
return $arrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到树型数组
|
||||
*/
|
||||
public function create($k_id = 0, $adds = '') {
|
||||
|
||||
if ($this->deep > 5000) {
|
||||
return; // 防止死循环
|
||||
}
|
||||
|
||||
$child = $this->get_child($k_id); // 获取子数据
|
||||
$number = 1;
|
||||
|
||||
if (is_array($child)) {
|
||||
$total = dr_count($child);
|
||||
foreach($child as $id => $a) {
|
||||
$k = $adds ? $this->nbsp : '';
|
||||
$j = $number == $total ? $this->icon[2] : $this->icon[1];
|
||||
$a['spacer'] = $this->_get_spacer($adds ? $adds.$j : '');
|
||||
$this->result_array[] = $a;
|
||||
$this->create($a['id'], $adds.$k.$this->nbsp);
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
|
||||
$this->deep = 1;
|
||||
}
|
||||
|
||||
// 替换空格填充符号
|
||||
protected function _get_spacer($str) {
|
||||
$num = substr_count($str, $this->nbsp) * 2;
|
||||
if ($num) {
|
||||
$str = str_replace($this->nbsp, '', $str);
|
||||
for ($i = 0; $i < $num; $i ++) {
|
||||
$str = $this->nbsp_str.$str;
|
||||
}
|
||||
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
// 替换逗号
|
||||
protected function _have($list, $item){
|
||||
return(strpos(',,'.$list.',', ','.$item.','));
|
||||
}
|
||||
|
||||
public function ismain($v) {
|
||||
$this->ismain = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function mid($v) {
|
||||
$this->mid = $v;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 栏目选择
|
||||
*
|
||||
* @param array $data 栏目数据
|
||||
* @param intval/array $id 被选中的ID
|
||||
* @param string $str 属性
|
||||
* @param string $default 默认选项
|
||||
* @param intval $onlysub 只可选择子栏目
|
||||
* @param intval $is_push 是否验证权限
|
||||
* @param intval $is_first 是否返回第一个可用栏目id
|
||||
* @return string
|
||||
*/
|
||||
public function select_category($data, $id = '', $str = '', $default = ' -- ', $onlysub = 0, $is_push = 0, $is_first = 0) {
|
||||
|
||||
if (dr_count($data) > 30) {
|
||||
$string = '<select class="bs-select form-control" data-live-search="true" '.$str.'>'.PHP_EOL;
|
||||
} else {
|
||||
$string = '<select class="form-control" '.$str .'>'.PHP_EOL;
|
||||
}
|
||||
|
||||
$default && $string.= "<option value='0'>$default</option>".PHP_EOL;
|
||||
|
||||
$tree = [];
|
||||
$first = 0; // 第一个可用栏目
|
||||
if (is_array($data)) {
|
||||
foreach($data as $t) {
|
||||
// 只显示主栏目
|
||||
if ($this->ismain && !$t['ismain']) {
|
||||
continue;
|
||||
}
|
||||
// 用于发布内容时【单页和外链】且为最终栏目时,不显示
|
||||
if ($is_push && in_array($t['tid'], [2, 0]) && !$t['child']) {
|
||||
continue;
|
||||
}
|
||||
// 验证权限
|
||||
if (IS_ADMIN && dr_is_app('cqx') && \Phpcmf\Service::M('content', 'cqx')->is_edit($t['id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 栏目发布权限判断,主要筛选栏目下是否有空白选项
|
||||
if ($is_push && $t['child'] == 1 && $t['catids']) {
|
||||
if ($t['is_post']) {
|
||||
$ispost = 1; // 允许发布的父栏目
|
||||
} else {
|
||||
$ispost = 0;
|
||||
foreach ($t['catids'] as $i) {
|
||||
// 当此栏目还存在下级栏目时,逐步判断全部下级栏目是否具备发布权限
|
||||
if (isset($data[$i]) && $data[$i]['child'] == 0) {
|
||||
$ispost = 1; // 可以发布 表示此栏目可用
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$ispost) {
|
||||
// ispost = 0 表示此栏目没有发布权限
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 选中操作
|
||||
$t['selected'] = (is_array($id) ? dr_in_array($t['id'], $id) : $id == $t['id']) ? 'selected' : '';
|
||||
//$t['selected'] = '_selected_'.$t['id'].'_';
|
||||
// 是否可选子栏目
|
||||
if (isset($t['pcatpost']) && $t['pcatpost']) {
|
||||
$t['html_disabled'] = 0;
|
||||
} else {
|
||||
$t['html_disabled'] = $onlysub && $t['child'] ? 1 : 0;
|
||||
}
|
||||
if (isset($t['setting'])) {
|
||||
unset($t['setting']);
|
||||
}
|
||||
$tree[$t['id']] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
$string.= $this->icon()->_data($tree)->_category_tree_result(0, "<option \$selected value='\$id'>\$spacer\$name</option>".PHP_EOL);
|
||||
$string.= '</select>'.PHP_EOL;
|
||||
|
||||
if ($is_first) {
|
||||
// 第一个子栏目
|
||||
$temp = str_replace("disabled value='", '', $string);
|
||||
$mark = "value='";
|
||||
$first = (int)substr($temp, strpos($temp, $mark) + strlen($mark));
|
||||
}
|
||||
|
||||
$data = $is_first ? [$string, $first] : $string;
|
||||
|
||||
unset($this->ret);
|
||||
unset($this->data);
|
||||
|
||||
$this->ismain = 0;
|
||||
$this->mid = '';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于栏目选择框
|
||||
*
|
||||
* @param integer $myid 要查询的ID
|
||||
* @param string $str HTML代码方式
|
||||
* @param integer $sid 默认选中
|
||||
* @param integer $adds 前缀
|
||||
*/
|
||||
protected function _category_tree_result($myid, $str, $str2 = '', $sid = 0, $adds = '') {
|
||||
|
||||
if ($this->deep > 5000) {
|
||||
return $this->ret; // 防止死循环
|
||||
}
|
||||
|
||||
$number = 1;
|
||||
$mychild = $this->get_child($myid);
|
||||
|
||||
if (is_array($mychild)) {
|
||||
|
||||
$mytotal = count($mychild);
|
||||
foreach ($mychild as $id => $phpcmf_a) {
|
||||
|
||||
$j = $k = '';
|
||||
if ($number == $mytotal) {
|
||||
$j.= $this->icon[2];
|
||||
} else {
|
||||
$j.= $this->icon[1];
|
||||
$k = $adds ? $this->icon[0] : '';
|
||||
}
|
||||
|
||||
$spacer = $this->_get_spacer($adds ? $adds.$j : '');
|
||||
$selected = $this->_have($sid, $id) ? 'selected' : '';
|
||||
$html_disabled = '';
|
||||
extract($phpcmf_a);
|
||||
|
||||
//$now = $this->get_child($id);
|
||||
// 如果没有子栏目且当前禁用就不再显示
|
||||
//if (!$now && $html_disabled) continue;
|
||||
|
||||
if ($html_disabled) {
|
||||
$selected = ' disabled';
|
||||
}
|
||||
|
||||
eval("\$this->ret.= \"$str\";");
|
||||
|
||||
$number++;
|
||||
|
||||
// 如果有下级菜单就递归
|
||||
if ($phpcmf_a['child']) {
|
||||
$this->_category_tree_result($id, $str, null, $sid, $adds.$k.$this->nbsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到树型结构
|
||||
*
|
||||
* @param int ID,表示获得这个ID下的所有子级
|
||||
* @param string 生成树型结构的基本代码,例如:"<option value=\$id \$selected>\$spacer\$name</option>"
|
||||
* @param int 被选中的ID,比如在做树型下拉框的时候需要用到
|
||||
* @return string
|
||||
*/
|
||||
public function get_tree($myid, $str, $sid = 0, $adds = '', $str_group = '') {
|
||||
|
||||
if ($this->deep > 5000) {
|
||||
return $this->ret; // 防止死循环
|
||||
}
|
||||
|
||||
$pid = 0;
|
||||
$nstr = '';
|
||||
$number = 1;
|
||||
$mychild = $this->get_child($myid);
|
||||
//$mychild = $this->data[$myid]['catids'];
|
||||
$mytotal = dr_count($mychild);
|
||||
|
||||
if (is_array($mychild)) {
|
||||
foreach ($mychild as $id => $phpcmf_a) {
|
||||
$j = $k = '';
|
||||
if ($number == $mytotal) {
|
||||
$j.= $this->icon[2];
|
||||
} else {
|
||||
$j.= $this->icon[1];
|
||||
$k = $adds ? $this->nbsp : '';
|
||||
}
|
||||
|
||||
$spacer = $this->_get_spacer($adds ? $adds.$j : '');
|
||||
$selected = $id == $sid ? 'selected' : '';
|
||||
$class = 'dr_catid_'.$phpcmf_a['id'];
|
||||
$childs = isset($phpcmf_a['childids']) ? $phpcmf_a['childids'] : (implode(',', $phpcmf_a['catids']));
|
||||
$parent = defined('SYS_CAT_ZSHOW') && SYS_CAT_ZSHOW ? (!$phpcmf_a['child'] ? '' : '<a href="javascript:void();" class="blue select-cat" childs="'.$childs.'" action="open" catid='.$id.'>[-]</a> ') : '';
|
||||
|
||||
extract($phpcmf_a);
|
||||
|
||||
$pid == 0 && $str_group ? eval("\$nstr = \"$str_group\";") : eval("\$nstr = \"$str\";");
|
||||
$this->ret.= $nstr;
|
||||
$this->get_tree($id, $str, $sid, $adds.$k.$this->nbsp, $str_group);
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 得到树型结构
|
||||
*
|
||||
* @param int ID,表示获得这个ID下的所有子级
|
||||
* @return array
|
||||
*/
|
||||
public function get_tree_array($myid, $str = '', $sid = 0, $adds = '', $str_group = '') {
|
||||
|
||||
if ($this->deep > 5000) {
|
||||
return $this->result; // 防止死循环
|
||||
}
|
||||
|
||||
$mychild = $this->get_child($myid);
|
||||
$mytotal = dr_count($mychild);
|
||||
$number = 1;
|
||||
|
||||
if (is_array($mychild)) {
|
||||
foreach ($mychild as $id => $value) {
|
||||
$j = $k = '';
|
||||
if ($number == $mytotal) {
|
||||
$j.= $this->icon[2];
|
||||
} else {
|
||||
$j.= $this->icon[1];
|
||||
$k = $adds ? $this->icon[0] : '';
|
||||
}
|
||||
|
||||
$value['spacer'] = $this->_get_spacer($adds ? $adds.$j : '');
|
||||
|
||||
$this->result[$id] = $value;
|
||||
$this->get_tree_array($id, $str, $sid, $adds.$k.$this->nbsp, $str_group);
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同上一方法类似,但允许多选
|
||||
*/
|
||||
public function get_tree_multi($myid, $str, $sid = 0, $adds = '') {
|
||||
|
||||
if ($this->deep > 5000) {
|
||||
return $this->ret; // 防止死循环
|
||||
}
|
||||
|
||||
$nstr = '';
|
||||
$number = 1;
|
||||
$mychild = $this->get_child($myid);
|
||||
|
||||
if (is_array($mychild)) {
|
||||
$mytotal = count($mychild);
|
||||
foreach ($mychild as $id => $phpcmf_a) {
|
||||
|
||||
$j = $k = '';
|
||||
if ($number == $mytotal) {
|
||||
$j.= $this->icon[2];
|
||||
} else {
|
||||
$j.= $this->icon[1];
|
||||
$k = $adds ? $this->icon[0] : '';
|
||||
}
|
||||
|
||||
$spacer = $this->_get_spacer($adds ? $adds.$j : '');
|
||||
$selected = $this->_have($sid, $id) ? 'selected' : '';
|
||||
|
||||
extract($phpcmf_a);
|
||||
|
||||
eval("\$nstr = \"$str\";");
|
||||
$this->ret.= $nstr;
|
||||
$this->get_tree_multi($id, $str, $sid, $adds.$k.$this->nbsp);
|
||||
$number++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $this->ret;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,489 @@
|
||||
<?php namespace Phpcmf\Model\Cms;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
// 栏目模型类
|
||||
|
||||
class Category extends \Phpcmf\Model {
|
||||
|
||||
protected $tablename;
|
||||
protected $categorys;
|
||||
protected $categorys_dir;
|
||||
|
||||
// 初始化模型
|
||||
public function init($data) {
|
||||
parent::init($data);
|
||||
$this->tablename = $data['table'];
|
||||
return $this;
|
||||
}
|
||||
|
||||
// 检查目录是否可用
|
||||
public function check_dirname($id, $pid, $value) {
|
||||
|
||||
if (!$value) {
|
||||
return dr_return_data(0, dr_lang('目录不能为空'));
|
||||
} elseif (!preg_match('/^[a-z0-9 \_\-]*$/i', $value)) {
|
||||
return dr_return_data(0, dr_lang('目录格式不能包含特殊符号或文字'));
|
||||
} elseif ($this->table($this->tablename)->counts() > MAX_CATEGORY) {
|
||||
return dr_return_data(0, dr_lang('网站栏目数量已达到上限'));
|
||||
} elseif (defined('SYS_CAT_RNAME') && SYS_CAT_RNAME) {
|
||||
return dr_return_data(1);
|
||||
} else {
|
||||
if ($pid) {
|
||||
$pcat = $this->table($this->tablename)->get($pid);
|
||||
if ($pcat && $this->table($this->tablename)->where('id<>'.$id)
|
||||
->where('pdirname', $pcat['dirname'].'/')
|
||||
->where('dirname', $value)->counts()) {
|
||||
return dr_return_data(0, dr_lang('目录不能重复(可以在栏目属性设置中关闭重复验证)'));
|
||||
}
|
||||
} elseif ($this->table($this->tablename)->where('id<>'.$id)
|
||||
->where('pdirname=""')->where('dirname', $value)->counts()) {
|
||||
return dr_return_data(0, dr_lang('目录不能重复(可以在栏目属性设置中关闭重复验证)'));
|
||||
}
|
||||
}
|
||||
|
||||
return dr_return_data(1);
|
||||
}
|
||||
|
||||
// 检查栏目上限
|
||||
public function check_counts($id, $fix = 0) {
|
||||
|
||||
if ($id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 找出子目录列表
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
protected function get_categorys($data = array()) {
|
||||
|
||||
if (is_array($data) && !empty($data)) {
|
||||
foreach ($data as $catid => $c) {
|
||||
$result = [];
|
||||
$this->categorys[$catid] = $c;
|
||||
foreach ($this->categorys as $_k => $_v) {
|
||||
if ($_v['pid']) {
|
||||
$result[] = $_v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父栏目ID列表
|
||||
*
|
||||
* @param integer $catid 栏目ID
|
||||
* @param array $pids 父目录ID
|
||||
* @param integer $n 查找的层次
|
||||
* @return string
|
||||
*/
|
||||
protected function get_pids($catid, $pids = '', $n = 1) {
|
||||
|
||||
if ($n > 100 || !is_array($this->categorys)
|
||||
|| !isset($this->categorys[$catid])) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$pid = $this->categorys[$catid]['pid'];
|
||||
$pids = $pids ? $pid.','.$pids : $pid;
|
||||
if ($pid) {
|
||||
$pids = $this->get_pids($pid, $pids, ++$n);
|
||||
}
|
||||
// : $this->categorys[$catid]['pids'] = $pids;
|
||||
|
||||
return $pids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子栏目ID列表
|
||||
*
|
||||
* @param $catid 栏目ID
|
||||
* @return string
|
||||
*/
|
||||
protected function get_childids($catid, $n = 1) {
|
||||
|
||||
$childids = $catid;
|
||||
|
||||
if ($n > 100 || !is_array($this->categorys) || !isset($this->categorys[$catid])) {
|
||||
return $childids;
|
||||
}
|
||||
|
||||
if (is_array($this->categorys)) {
|
||||
foreach ($this->categorys as $id => $cat) {
|
||||
if ($cat['pid'] && $id != $catid && $cat['pid'] == $catid) {
|
||||
$childids.= ','.$this->get_childids($id, ++$n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $childids;
|
||||
}
|
||||
|
||||
// 获取栏目下级ids
|
||||
protected function _get_next_ids($catid) {
|
||||
|
||||
$rt = [];
|
||||
|
||||
if (is_array($this->categorys)) {
|
||||
foreach ($this->categorys as $id => $cat) {
|
||||
if ($cat['pid'] == $catid) {
|
||||
$rt[] = $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $rt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有父目录
|
||||
*
|
||||
* @param $catid ��ĿID
|
||||
* @return string
|
||||
*/
|
||||
public function get_pdirname($catid) {
|
||||
|
||||
if ($this->categorys[$catid]['pid']==0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$t = $this->categorys[$catid];
|
||||
$pids = $t['pids'];
|
||||
$pids = explode(',', $pids);
|
||||
$catdirs = [];
|
||||
krsort($pids);
|
||||
|
||||
foreach ($pids as $id) {
|
||||
if ($id == 0) {
|
||||
continue;
|
||||
}
|
||||
$catdirs[] = $this->categorys[$id]['dirname'];
|
||||
if ($this->categorys[$id]['pdirname'] == '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
krsort($catdirs);
|
||||
|
||||
return implode('/', $catdirs).'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部父级的mid值, 或者更新
|
||||
*/
|
||||
public function get_parent_mid($category, $id, $update = 0) {
|
||||
|
||||
if (!isset($category[$id])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$mid = '';
|
||||
$ids = dr_array2array(explode(',', $category[$id]['childids']), explode(',', $category[$id]['pids']));
|
||||
foreach ($ids as $id) {
|
||||
if ($id && $category[$id] && $category[$id]['mid']) {
|
||||
$mid = $category[$id]['mid'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [$mid, $ids];
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化父级栏目模块mid
|
||||
*/
|
||||
public function update_parent_mid($category, $catid) {
|
||||
|
||||
if (!isset($category[$catid])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ids = explode(',', $category[$catid]['childids']);
|
||||
if (!$ids) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mid = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
$id
|
||||
&& $category[$id]
|
||||
&& $category[$id]['tid'] == 1
|
||||
&& $category[$id]['mid']
|
||||
&& $mid[] = $category[$id]['mid'];
|
||||
}
|
||||
|
||||
/* 当栏目下面存在多个模块时
|
||||
$mid && dr_count(array_unique($mid)) > 1 && $this->table($this->tablename)->update((int)$catid, array(
|
||||
'mid' => '',
|
||||
'tid' => 0
|
||||
));*/
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取菜单数据
|
||||
*/
|
||||
public function cat_data($pid) {
|
||||
return $this->table($this->tablename)->where('pid', $pid)->order_by('displayorder ASC,id ASC')->getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修复菜单数据
|
||||
*/
|
||||
public function repair($_data = [], $dirname = '') {
|
||||
|
||||
$this->categorys = $this->categorys_dir = $categorys = [];
|
||||
!$_data && $_data = $this->table($this->tablename)->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
|
||||
if (!$_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 全部栏目数据
|
||||
foreach ($_data as $t) {
|
||||
$t['setting'] = dr_string2array($t['setting']);
|
||||
$this->categorys[$t['id']] = $categorys[$t['id']] = $t;
|
||||
}
|
||||
|
||||
foreach ($this->categorys as $catid => $cat) {
|
||||
|
||||
$this->categorys[$catid]['pids'] = $this->get_pids($catid);
|
||||
$this->categorys[$catid]['childids'] = $this->get_childids($catid);
|
||||
$this->categorys[$catid]['child'] = is_numeric($this->categorys[$catid]['childids']) ? 0 : 1;
|
||||
$this->categorys[$catid]['pdirname'] = $this->get_pdirname($catid);
|
||||
//$this->categorys[$catid]['next_ids'] = $this->_get_next_ids($catid);
|
||||
|
||||
if ($cat['pdirname'] != $this->categorys[$catid]['pdirname']
|
||||
|| $cat['pids'] != $this->categorys[$catid]['pids']
|
||||
|| $cat['childids'] != $this->categorys[$catid]['childids']
|
||||
|| $cat['child'] != $this->categorys[$catid]['child']) {
|
||||
// 当库中与实际不符合才更新数据表
|
||||
// 更新数据库
|
||||
$this->table($this->tablename)->update($cat['id'], [
|
||||
'pids' => $this->categorys[$catid]['pids'],
|
||||
'child' => $this->categorys[$catid]['child'],
|
||||
'childids' => $this->categorys[$catid]['childids'],
|
||||
'pdirname' => $this->categorys[$catid]['pdirname']
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->categorys[$catid]['child'] == 1 && $this->categorys[$catid]['catids']) {
|
||||
$ispost = 0;
|
||||
foreach ($t['catids'] as $i) {
|
||||
// 当此栏目还存在下级栏目时,逐步判断全部下级栏目是否具备发布权限
|
||||
if (isset($cat[$i]) && $cat[$i]['child'] == 0) {
|
||||
$ispost = 1; // 可以发布 表示此栏目可用
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$ispost) {
|
||||
// ispost = 0 表示此栏目没有发布权限
|
||||
//$is_cks = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 共享栏目是更新mid值
|
||||
if ($dirname == 'share' && $this->categorys[$catid]['child']) {
|
||||
$this->update_parent_mid($this->categorys, $catid);
|
||||
}
|
||||
$this->categorys_dir[$t['dirname']] = $t['id'];
|
||||
}
|
||||
|
||||
return $this->categorys;
|
||||
}
|
||||
|
||||
// 用于删除时获取的数据
|
||||
public function data_for_delete() {
|
||||
|
||||
$cache = [];
|
||||
// 全部栏目
|
||||
$data = $this->db->table($this->tablename)->orderBy('displayorder ASC,id ASC')->get()->getResultArray();
|
||||
if ($data) {
|
||||
foreach ($data as $t) {
|
||||
$cache[$t['id']] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
// 用于移动时获取的数据
|
||||
public function data_for_move() {
|
||||
|
||||
$cache = [];
|
||||
// 全部栏目
|
||||
$data = $this->db->table($this->tablename)->orderBy('displayorder ASC,id ASC')->get()->getResultArray();
|
||||
if ($data) {
|
||||
foreach ($data as $t) {
|
||||
$cache[$t['id']] = $t;
|
||||
}
|
||||
}
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
// 复制属性
|
||||
public function copy_value($at, $setting, $id) {
|
||||
|
||||
$row = $this->table($this->tablename)->get($id);
|
||||
if (!$row) {
|
||||
return;
|
||||
}
|
||||
|
||||
$save = $row['setting'] = dr_string2array($row['setting']);
|
||||
$arr = explode(',', $at);
|
||||
foreach ($arr as $at) {
|
||||
if ($at == 'tpl') {
|
||||
$save['template'] = $setting['template'];
|
||||
$save['template']['pagesize'] = $row['setting']['template']['pagesize'];
|
||||
$save['template']['mpagesize'] = $row['setting']['template']['mpagesize'];
|
||||
} elseif ($at == 'url') {
|
||||
$save['urlrule'] = $setting['urlrule'];
|
||||
} elseif ($at == 'html') {
|
||||
$save['html'] = $setting['html'];
|
||||
$save['chtml'] = $setting['chtml'];
|
||||
} elseif ($at == 'seo') {
|
||||
$save['seo'] = $setting['seo'];
|
||||
} elseif ($at == 'size') {
|
||||
$save['template']['pagesize'] = $setting['template']['pagesize'];
|
||||
$save['template']['mpagesize'] = $setting['template']['mpagesize'];
|
||||
} elseif ($at == 'cat_field') {
|
||||
$save['cat_field'] = $setting['cat_field'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->table($this->tablename)->update($id, [
|
||||
'setting' => dr_array2string($save),
|
||||
]);
|
||||
}
|
||||
|
||||
// 删除内容模块
|
||||
public function delete_content($cats, $module) {
|
||||
|
||||
if (!$cats) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($module['share']) {
|
||||
// 共享模块单独删除
|
||||
foreach ($cats as $t) {
|
||||
$mod = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content', $t['mid']);
|
||||
if ($mod && $t['mid']) {
|
||||
// 删除栏目模型字段
|
||||
$this->db->table('field')->where('relatedid', $t['id'])
|
||||
->where('relatedname', 'share-'.SITE_ID)->delete();
|
||||
if (!$this->db->tableExists($this->dbprefix(dr_module_table_prefix($t['mid'])))) {
|
||||
continue;
|
||||
}
|
||||
// 删除内容
|
||||
$this->table(dr_module_table_prefix($t['mid']))->where('catid', $t['id'])->delete();
|
||||
$this->table(dr_module_table_prefix($t['mid']).'_draft')->where('catid', $t['id'])->delete();
|
||||
$this->table(dr_module_table_prefix($t['mid']).'_flag')->where('catid', $t['id'])->delete();
|
||||
$this->table(dr_module_table_prefix($t['mid']).'_index')->where('catid', $t['id'])->delete();
|
||||
$this->table(dr_module_table_prefix($t['mid']).'_time')->where('catid', $t['id'])->delete();
|
||||
$this->table(dr_module_table_prefix($t['mid']).'_verify')->where('catid', $t['id'])->delete();
|
||||
$this->table(dr_module_table_prefix($t['mid']).'_category_data')->where('catid', $t['id'])->delete();
|
||||
// 附表分表删除
|
||||
for ($i = 0; $i <= 255 ;$i++) {
|
||||
$table = $this->dbprefix(dr_module_table_prefix($t['mid']).'_data_'.$i);
|
||||
if (!$this->db->tableExists($table)) {
|
||||
continue;
|
||||
}
|
||||
$this->table($table)->where('catid', $t['id'])->delete();
|
||||
}
|
||||
for ($i = 0; $i <= 255 ;$i++) {
|
||||
$table = $this->dbprefix(dr_module_table_prefix($t['mid']).'_category_data_'.$i);
|
||||
if (!$this->db->tableExists($table)) {
|
||||
continue;
|
||||
}
|
||||
$this->table($table)->where('catid', $t['id'])->delete();
|
||||
}
|
||||
// 删除表单
|
||||
if ($mod['form']) {
|
||||
foreach ($mod['form'] as $form) {
|
||||
$ftable = dr_module_table_prefix($t['mid']).'_form_'.$form['table'];
|
||||
$this->table($ftable)->where('catid', $t['id'])->delete();
|
||||
for ($i = 0; $i <= 255 ;$i++) {
|
||||
$table = $this->dbprefix($ftable.'_data_'.$i);
|
||||
if (!$this->db->tableExists($table)) {
|
||||
continue;
|
||||
}
|
||||
$this->table($table)->where('catid', $t['id'])->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
// 独立模块批量删除
|
||||
$catids = [];
|
||||
foreach ($cats as $t) {
|
||||
$catids[] = $t['id'];
|
||||
// 删除栏目模型字段
|
||||
$this->db->table('field')->where('relatedid', $t['id'])
|
||||
->where('relatedname', APP_DIR.'-'.SITE_ID)->delete();
|
||||
}
|
||||
// 批量删除
|
||||
$this->table(dr_module_table_prefix(APP_DIR))->where_in('catid', $catids)->delete();
|
||||
$this->table(dr_module_table_prefix(APP_DIR).'_draft')->where_in('catid', $catids)->delete();
|
||||
$this->table(dr_module_table_prefix(APP_DIR).'_flag')->where_in('catid', $catids)->delete();
|
||||
$this->table(dr_module_table_prefix(APP_DIR).'_index')->where_in('catid', $catids)->delete();
|
||||
$this->table(dr_module_table_prefix(APP_DIR).'_time')->where_in('catid', $catids)->delete();
|
||||
$this->table(dr_module_table_prefix(APP_DIR).'_verify')->where_in('catid', $catids)->delete();
|
||||
$this->table(dr_module_table_prefix(APP_DIR).'_category_data')->where_in('catid', $catids)->delete();
|
||||
// 附表分表删除
|
||||
for ($i = 0; $i <= 255 ;$i++) {
|
||||
$table = $this->dbprefix(dr_module_table_prefix(APP_DIR).'_data_'.$i);
|
||||
if (!$this->db->tableExists($table)) {
|
||||
continue;
|
||||
}
|
||||
$this->table($table)->where_in('catid', $catids)->delete();
|
||||
}
|
||||
for ($i = 0; $i <= 255 ;$i++) {
|
||||
$table = $this->dbprefix(dr_module_table_prefix(APP_DIR).'_category_data_'.$i);
|
||||
if (!$this->db->tableExists($table)) {
|
||||
continue;
|
||||
}
|
||||
$this->table($table)->where_in('catid', $catids)->delete();
|
||||
}
|
||||
// 删除表单
|
||||
if ($module['form']) {
|
||||
foreach ($module['form'] as $form) {
|
||||
$ftable = dr_module_table_prefix(APP_DIR).'_form_'.$form['table'];
|
||||
$this->table($ftable)->where_in('catid', $catids)->delete();
|
||||
for ($i = 0; $i <= 255 ;$i++) {
|
||||
$table = $this->dbprefix($ftable.'_data_'.$i);
|
||||
if (!$this->db->tableExists($table)) {
|
||||
continue;
|
||||
}
|
||||
$this->table($table)->where_in('catid', $catids)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容老版本
|
||||
public function get_tree_category($data) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 找到主栏目id
|
||||
public function get_ismain_id($cats, $id) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,139 @@
|
||||
<?php namespace Phpcmf\Model\Cms;
|
||||
|
||||
/**
|
||||
* 内容权限(站点 / 模块 / 栏目)
|
||||
* 调用:\Phpcmf\Service::M('member_auth', 'cms')
|
||||
*/
|
||||
class Member_auth extends \Phpcmf\Model {
|
||||
|
||||
public $auth;
|
||||
public $auth_type;
|
||||
public $is_category_public;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->_reload_auth();
|
||||
}
|
||||
|
||||
// 每次从会员缓存重新读取,避免单例构造过早导致 auth 为空
|
||||
protected function _reload_auth() {
|
||||
$this->auth = isset(\Phpcmf\Service::C()->member_cache['auth2'][SITE_ID])
|
||||
? \Phpcmf\Service::C()->member_cache['auth2'][SITE_ID] : [];
|
||||
$auth_type = \Phpcmf\Service::C()->member_cache['auth_type'] ?? 0;
|
||||
// [] / null / "" 都按全局 0 处理(dr_string2array("0") 会得到 [])
|
||||
$this->auth_type = is_numeric($auth_type) ? intval($auth_type) : 0;
|
||||
}
|
||||
|
||||
// 当前登录会员的权限标识
|
||||
protected function _get_groupid($member) {
|
||||
|
||||
$auth_type = is_numeric($this->auth_type) ? intval($this->auth_type) : 0;
|
||||
|
||||
if ($auth_type == 1) {
|
||||
$groupid = $member && !empty($member['groupid']) ? $member['groupid'] : [0];
|
||||
} elseif ($auth_type == 2) {
|
||||
$groupid = $member && !empty($member['authid']) ? $member['authid'] : [0];
|
||||
} else {
|
||||
$groupid = ['public'];
|
||||
}
|
||||
|
||||
if (!is_array($groupid)) {
|
||||
$groupid = [$groupid];
|
||||
}
|
||||
|
||||
return $groupid ? array_values($groupid) : [0];
|
||||
}
|
||||
|
||||
// 取某一 aid 下的栏目权限配置
|
||||
protected function _category_auth_row($gid, $module, $catid) {
|
||||
|
||||
$mid = isset($module['dirname']) ? $module['dirname'] : '';
|
||||
if (!$mid && defined('APP_DIR')) {
|
||||
$mid = APP_DIR;
|
||||
}
|
||||
|
||||
if (!empty($module['share'])) {
|
||||
if (!empty($this->auth[$gid]['home']['is_category'])) {
|
||||
$this->is_category_public = 0;
|
||||
return isset($this->auth[$gid]['share_category'][$catid])
|
||||
? $this->auth[$gid]['share_category'][$catid] : [];
|
||||
}
|
||||
$this->is_category_public = 1;
|
||||
return isset($this->auth[$gid]['share_category_public'])
|
||||
? $this->auth[$gid]['share_category_public'] : [];
|
||||
}
|
||||
|
||||
if (!empty($this->auth[$gid]['module'][$mid]['is_category'])) {
|
||||
$this->is_category_public = 0;
|
||||
return isset($this->auth[$gid]['category'][$mid][$catid])
|
||||
? $this->auth[$gid]['category'][$mid][$catid] : [];
|
||||
}
|
||||
$this->is_category_public = 1;
|
||||
return isset($this->auth[$gid]['category_public'][$mid])
|
||||
? $this->auth[$gid]['category_public'][$mid] : [];
|
||||
}
|
||||
|
||||
// 站点权限
|
||||
public function home_auth($name, $member = []) {
|
||||
|
||||
$this->_reload_auth();
|
||||
$values = [];
|
||||
foreach ($this->_get_groupid($member) as $gid) {
|
||||
if (isset($this->auth[$gid]['home'][$name])) {
|
||||
$values[] = $this->auth[$gid]['home'][$name];
|
||||
}
|
||||
}
|
||||
|
||||
return $values ? max($values) : null;
|
||||
}
|
||||
|
||||
// 模块权限
|
||||
public function module_auth($mid, $name, $member = []) {
|
||||
|
||||
$this->_reload_auth();
|
||||
$values = [];
|
||||
foreach ($this->_get_groupid($member) as $gid) {
|
||||
if (isset($this->auth[$gid]['module'][$mid][$name])) {
|
||||
$values[] = $this->auth[$gid]['module'][$mid][$name];
|
||||
}
|
||||
}
|
||||
|
||||
return $values ? max($values) : null;
|
||||
}
|
||||
|
||||
// 栏目权限
|
||||
public function category_auth($module, $catid, $name, $member = []) {
|
||||
|
||||
$this->_reload_auth();
|
||||
$values = [];
|
||||
$this->is_category_public = 0;
|
||||
$groupid = $this->_get_groupid($member);
|
||||
$has_config = false;
|
||||
|
||||
foreach ($groupid as $gid) {
|
||||
$auth = $this->_category_auth_row($gid, $module, $catid);
|
||||
if ($auth) {
|
||||
// 本组已有栏目权限配置:未勾选的项视为关闭,不能再回退 public
|
||||
$has_config = true;
|
||||
if (isset($auth[$name])) {
|
||||
$values[] = $auth[$name];
|
||||
}
|
||||
} elseif ($name === 'show') {
|
||||
$values[] = 1; // 默认没勾选时访问开放
|
||||
}
|
||||
}
|
||||
|
||||
// 按用户组/等级时,仅当本组完全没有栏目权限配置,才回退 public
|
||||
if (!$has_config && !$values && !in_array('public', $groupid, true) && isset($this->auth['public'])) {
|
||||
$auth = $this->_category_auth_row('public', $module, $catid);
|
||||
if (isset($auth[$name])) {
|
||||
$values[] = $auth[$name];
|
||||
} elseif (!$auth && $name === 'show') {
|
||||
$values[] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return $values ? max($values) : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php namespace Phpcmf\Model\Cms;
|
||||
|
||||
// 菜单控制模型
|
||||
|
||||
class Menu extends \Phpcmf\Model {
|
||||
|
||||
// 变更模块名称
|
||||
public function update_module_name($mid, $old, $new, $icon) {
|
||||
|
||||
$replace = '`icon`="'.$icon.'", `name`=REPLACE(`name`, \''.addslashes($old).'\', \''.addslashes($new).'\')';
|
||||
|
||||
$this->is_table_exists('member_menu') && $this->db->query('UPDATE `'.$this->dbprefix('member_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/home/index"');
|
||||
|
||||
$this->db->query('UPDATE `'.$this->dbprefix('admin_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/home/index"');
|
||||
$this->db->query('UPDATE `'.$this->dbprefix('admin_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/verify/index"');
|
||||
$this->db->query('UPDATE `'.$this->dbprefix('admin_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/comment_verify/index"');
|
||||
|
||||
$this->db->query('UPDATE `'.$this->dbprefix('admin_min_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/home/index"');
|
||||
$this->db->query('UPDATE `'.$this->dbprefix('admin_min_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/verify/index"');
|
||||
$this->db->query('UPDATE `'.$this->dbprefix('admin_min_menu').'` SET '.$replace.' WHERE uri="'.$mid.'/comment_verify/index"');
|
||||
}
|
||||
|
||||
// 从模块中更新菜单
|
||||
public function update_module($mdir, $config, $form) {
|
||||
|
||||
// 作为应用模块时且不操作menu.php时,不需要菜单
|
||||
if (isset($config['ftpye']) && $config['ftpye'] == 'module'
|
||||
&& is_file(dr_get_app_dir($mdir).'Config/Menu.php')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 内容模块 入库后台菜单
|
||||
if ($config['system'] == 1) {
|
||||
foreach (['admin', 'admin_min'] as $table) {
|
||||
$left = $this->db->table($table.'_menu')->where('mark', 'content-module')->get()->getRowArray();
|
||||
if ($left) {
|
||||
// 查询模块菜单
|
||||
$menu = $this->db->table($table.'_menu')->where('mark', 'module-'.$mdir)->get()->getRowArray();
|
||||
$save = [
|
||||
'uri' => $mdir.'/home/index',
|
||||
'mark' => 'module-'.$mdir,
|
||||
'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s管理', $config['name']),
|
||||
'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($config['icon']),
|
||||
'displayorder' => $menu ? intval($menu['displayorder']) : '-1',
|
||||
];
|
||||
$menu ? \Phpcmf\Service::M('menu')->_edit($table, $menu['id'], $save) : \Phpcmf\Service::M('menu')->_add($table, $left['id'], $save);
|
||||
}
|
||||
// 入库后台审核菜单
|
||||
$left = $this->db->table($table.'_menu')->where('mark', 'content-verify')->get()->getRowArray();
|
||||
if ($left) {
|
||||
// 内容模块入库
|
||||
if ($config['system'] == 1) {
|
||||
$menu = $this->db->table($table.'_menu')->where('mark', 'verify-module-'.$mdir)->get()->getRowArray();
|
||||
$save = [
|
||||
'uri' => $mdir.'/verify/index',
|
||||
'mark' => 'verify-module-'.$mdir,
|
||||
'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s审核', $config['name']),
|
||||
'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($config['icon']),
|
||||
'displayorder' => $menu ? intval($menu['displayorder']) : '-1',
|
||||
];
|
||||
$menu ? \Phpcmf\Service::M('menu')->_edit($table, $menu['id'], $save) : \Phpcmf\Service::M('menu')->_add($table, $left['id'], $save);
|
||||
}
|
||||
// 表单入库
|
||||
if ($form && dr_is_app('mform')) {
|
||||
\Phpcmf\Service::M('mform', 'mform')->link_menu($form, $table, $mdir, $config, $left);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 内容模块入库用户菜单
|
||||
if ($config['system'] == 1 && $this->is_table_exists('member_menu')) {
|
||||
$left = $this->db->table('member_menu')->where('mark', 'content-module')->get()->getRowArray();
|
||||
if ($left) {
|
||||
// 查询模块菜单
|
||||
$menu = $this->db->table('member_menu')->where('mark', 'module-'.$mdir)->get()->getRowArray();
|
||||
$save = [
|
||||
'uri' => $mdir.'/home/index',
|
||||
'mark' => 'module-'.$mdir,
|
||||
'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s管理', $config['name']),
|
||||
'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($config['icon']),
|
||||
'displayorder' => $menu ? intval($menu['displayorder']) : '-1',
|
||||
];
|
||||
$menu ? \Phpcmf\Service::M('menu')->_edit('member', $menu['id'], $save) : \Phpcmf\Service::M('menu')->_add('member', $left['id'], $save);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,345 @@
|
||||
<?php namespace Phpcmf\Model\Cms;
|
||||
|
||||
// 模块搜索类
|
||||
class Search extends \Phpcmf\Model {
|
||||
|
||||
public $mytable; // 模块表名称
|
||||
public $module; // 模块属性
|
||||
public $catid; // 栏目id
|
||||
public $get; // 搜索参数
|
||||
|
||||
// 初始化搜索主表
|
||||
public function init($table) {
|
||||
$this->mytable = dr_module_table_prefix($table, SITE_ID);
|
||||
return $this;
|
||||
}
|
||||
|
||||
// 获取搜索参数
|
||||
public function get_param($module) {
|
||||
|
||||
$get = $_GET;
|
||||
$get = isset($get['rewrite']) ? dr_search_rewrite_decode($get['rewrite'], $module['setting']['search']) : $get;
|
||||
if ($get) {
|
||||
$get = \Phpcmf\Service::L('input')->xss_clean($get);
|
||||
}
|
||||
|
||||
$get['s'] = $get['c'] = $get['m'] = $get['id'] = null;
|
||||
unset($get['s'], $get['c'], $get['m'], $get['id']);
|
||||
if (!$get && IS_API_HTTP) {
|
||||
$get = \Phpcmf\Service::L('input')->xss_clean($_POST);
|
||||
}
|
||||
|
||||
$_GET['page'] = $get['page'] = (int)$get['page'];
|
||||
if (isset($get['catdir']) && $get['catdir']) {
|
||||
$catid = (int)$module['category_dir'][$get['catdir']];
|
||||
unset($get['catid']);
|
||||
} else {
|
||||
$catid = (int)$get['catid'];
|
||||
isset($get['catid']) && $get['catid'] = $catid;
|
||||
}
|
||||
|
||||
// 固定模式下的填充
|
||||
if ($get && $this->module['setting']['search']['param_rule']) {
|
||||
foreach ($get as $i => $t) {
|
||||
if ((string)$this->module['setting']['search']['param_join_default_value'] === $t) {
|
||||
unset($get[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->get = $get;
|
||||
$this->catid = $catid;
|
||||
$this->module = $module;
|
||||
|
||||
// 挂钩点 搜索之前对参数处理
|
||||
\Phpcmf\Hooks::trigger('search_param', $get);
|
||||
|
||||
return [$catid, $get];
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据并设置缓存
|
||||
*/
|
||||
public function get_data() {
|
||||
|
||||
// 模块表名称
|
||||
$table = $this->dbprefix($this->mytable);
|
||||
|
||||
// 挂钩点 自定义返回数据
|
||||
$rt2 = \Phpcmf\Hooks::trigger_callback('module_search_get_data');
|
||||
if ($rt2 && isset($rt2['code']) && $rt2['code']) {
|
||||
return $rt2['data'];
|
||||
}
|
||||
|
||||
// 排序查询参数
|
||||
ksort($this->get);
|
||||
$param = $this->get;
|
||||
$catid = $this->catid;
|
||||
$param_new = [];
|
||||
$this->get['order'] = $this->get['page'] = null;
|
||||
unset($this->get['order'], $this->get['page']);
|
||||
|
||||
// 查询缓存
|
||||
$id = md5($table.dr_array2string($this->get).$catid);
|
||||
if (!IS_DEV && SYS_CACHE_SEARCH) {
|
||||
$data = $this->db->table($this->mytable.'_search')->where('id', $id)->get()->getRowArray();
|
||||
$time = SYS_CACHE_SEARCH * 3600;
|
||||
if ($data && $data['inputtime'] + $time < SYS_TIME) {
|
||||
$data = [];
|
||||
}
|
||||
$this->db->table($this->mytable.'_search')->where('inputtime <'. (SYS_TIME - $time))->delete();
|
||||
} else {
|
||||
$data = [];
|
||||
$this->db->table($this->mytable.'_search')->where('inputtime <'. (SYS_TIME - 3600))->delete();
|
||||
}
|
||||
|
||||
$is_like = intval($this->module['setting']['search']['is_like']);
|
||||
|
||||
// 缓存不存在重新入库更新缓存
|
||||
if (!$data) {
|
||||
|
||||
$this->get['keyword'] = $this->get['catid'] = null;
|
||||
unset($this->get['keyword'], $this->get['catid']);
|
||||
|
||||
// 主表的字段
|
||||
$field = \Phpcmf\Service::L('cache')->get('table-'.SITE_ID, $this->dbprefix($this->mytable));
|
||||
if (!$field) {
|
||||
return dr_return_data(0, dr_lang('主表【%s】字段不存在', $this->mytable));
|
||||
}
|
||||
|
||||
$mod_field = $this->module['field'];
|
||||
foreach ($field as $i) {
|
||||
if (!isset($mod_field[$i])) {
|
||||
$mod_field[$i] = ['ismain' => 1];
|
||||
}
|
||||
}
|
||||
|
||||
// 默认搜索条件
|
||||
$where = [
|
||||
//'status' => '`'.$table.'`.`status` = 9'
|
||||
];
|
||||
|
||||
// 栏目的字段
|
||||
if ($catid) {
|
||||
$more = 0;
|
||||
$cat_field = $this->module['category'][$catid]['field'];
|
||||
// 副栏目判断
|
||||
if (isset($this->module['field']['catids']) && $this->module['field']['catids']['fieldtype'] == 'Catids') {
|
||||
$fwhere = [];
|
||||
if ($this->module['category'][$catid]['child'] && $this->module['category'][$catid]['childids']) {
|
||||
$fwhere[] = '`'.$table.'`.`catid` IN ('.$this->module['category'][$catid]['childids'].')';
|
||||
$catids = explode(',', $this->module['category'][$catid]['childids']);
|
||||
} else {
|
||||
$fwhere[] = '`'.$table.'`.`catid` = '.$catid;
|
||||
$catids = [ $catid ];
|
||||
}
|
||||
foreach ($catids as $c) {
|
||||
$fwhere[] = \Phpcmf\Service::M()->where_json($table, 'catids', intval($c));
|
||||
}
|
||||
$fwhere && $where['catid'] = '('.implode(' OR ', $fwhere).')';
|
||||
} else {
|
||||
// 无副栏目时
|
||||
$where['catid'] = '`'.$table.'`.`catid`'.($this->module['category'][$catid]['child'] ? 'IN ('.$this->module['category'][$catid]['childids'].')' : '='.(int)$catid);
|
||||
}
|
||||
|
||||
if ($cat_field) {
|
||||
// 栏目模型表
|
||||
$more_where = [];
|
||||
$table_more = $this->dbprefix($this->mytable.'_category_data');
|
||||
foreach ($cat_field as $name) {
|
||||
if (isset($this->get[$name]) && strlen($this->get[$name])) {
|
||||
$more = 1;
|
||||
$r = $this->mywhere($table_more, $name, $this->get[$name], $this->module['category_data_field'][$name], $is_like);
|
||||
if ($r) {
|
||||
$more_where[] = $r;
|
||||
$param_new[$name] = $this->get[$name];
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (isset($_order_by[$name])) {
|
||||
$more = 1;
|
||||
$order_by[] = '`'.$table.'`.`'.$name.'` '.$_order_by[$name];
|
||||
}*/
|
||||
}
|
||||
$more && $where[] = '`'.$table.'`.`id` IN (SELECT `id` FROM `'.$table_more.'` WHERE '.implode(' AND ', $more_where).')';
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (dr_is_app('fstatus') && isset($this->module['field']['fstatus']) && $this->module['field']['fstatus']['ismain']) {
|
||||
$where[] = [ '`'.$table.'`.`fstatus` = 1' ];
|
||||
}*/
|
||||
// 查找mwhere目录
|
||||
$mwhere = \Phpcmf\Service::Mwhere_Apps();
|
||||
if ($mwhere) {
|
||||
list($siteid, $mid) = explode('_', $this->mytable);
|
||||
foreach ($mwhere as $mapp) {
|
||||
$w = require dr_get_app_dir($mapp).'Config/Mwhere.php';
|
||||
if ($w) {
|
||||
$where[] = $w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 关键字匹配条件
|
||||
if ($param['keyword'] != '') {
|
||||
$temp = [];
|
||||
$sfield = explode(',', $this->module['setting']['search']['field'] ? $this->module['setting']['search']['field'] : 'title,keywords');
|
||||
$search_keyword = explode('|', addslashes((string)$param['keyword']));
|
||||
foreach ($search_keyword as $kw) {
|
||||
$is = 0;
|
||||
if ($sfield) {
|
||||
foreach ($sfield as $t) {
|
||||
if ($t && dr_in_array($t, $field)) {
|
||||
$is = 1;
|
||||
$temp[] = $this->module['setting']['search']['complete'] ? '`'.$table.'`.`'.$t.'` = "'.$kw.'"' : '`'.$table.'`.`'.$t.'` LIKE "%'.$kw.'%"';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$is) {
|
||||
$temp[] = $this->module['setting']['search']['complete'] ? '`'.$table.'`.`title` = "'.$kw.'"' : '`'.$table.'`.`title` LIKE "%'.$kw.'%"';
|
||||
}
|
||||
}
|
||||
$where['keyword'] = $temp ? '('.implode(' OR ', $temp).')' : '';
|
||||
$param_new['keyword'] = $search_keyword;
|
||||
}
|
||||
|
||||
// 模块字段过滤
|
||||
foreach ($mod_field as $name => $field) {
|
||||
if (isset($field['ismain']) && !$field['ismain']) {
|
||||
continue;
|
||||
}
|
||||
if (isset($this->get[$name]) && strlen($this->get[$name])) {
|
||||
$r = $this->mywhere($table, $name, $this->get[$name], $field, $is_like);
|
||||
if ($r) {
|
||||
$where[$name] = $r;
|
||||
$param_new[$name] = $this->get[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_USE_MEMBER) {
|
||||
// 会员字段过滤
|
||||
$member_where = [];
|
||||
if (\Phpcmf\Service::C()->member_cache['field']) {
|
||||
foreach (\Phpcmf\Service::C()->member_cache['field'] as $name => $field) {
|
||||
if (isset($field['ismain']) && !$field['ismain']) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($mod_field[$name]) && isset($this->get[$name]) && strlen($this->get[$name])) {
|
||||
$r = $this->mywhere($this->dbprefix('member_data'), $name, $this->get[$name], $field, $is_like);
|
||||
if ($r) {
|
||||
$member_where[] = $r;
|
||||
$param_new[$name] = $this->get[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 按会员组搜索时
|
||||
if ($param['groupid'] != '') {
|
||||
$member_where[] = '`'.$this->dbprefix('member_data').'`.`id` IN (SELECT `uid` FROM `'.$this->dbprefix('member').'_group_index` WHERE gid='.intval($param['groupid']).')';
|
||||
$param_new['groupid'] = $this->get['groupid'];
|
||||
}
|
||||
// 组合会员字段
|
||||
if ($member_where) {
|
||||
$where[] = '`'.$table.'`.`uid` IN (select `id` from `'.$this->dbprefix('member_data').'` where '.implode(' AND ', $member_where).')';
|
||||
}
|
||||
}
|
||||
|
||||
// flag
|
||||
if (isset($param['flag']) && $param['flag']) {
|
||||
$wh = [];
|
||||
$arr = explode('|', $param['flag']);
|
||||
foreach ($arr as $k) {
|
||||
$wh[] = intval($k);
|
||||
}
|
||||
$where[] = '`'.$table.'`.`id` IN (select `id` from `'.$table.'_flag` where `flag` in ('.implode(',', $wh).'))';
|
||||
$param_new['flag'] = $param['flag'];
|
||||
}
|
||||
|
||||
// 筛选空值
|
||||
foreach ($where as $i => $t) {
|
||||
if (dr_strlen($t) == 0) {
|
||||
unset($where[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
// 自定义组合查询
|
||||
isset($param['catid']) && $param_new['catid'] = $param['catid'];
|
||||
isset($param['catdir']) && $param_new['catdir'] = $param['catdir'];
|
||||
isset($param['keyword']) && $param_new['keyword'] = $param['keyword'];
|
||||
$param_new = $this->myparam($param_new);
|
||||
$where = $this->mysearch($this->module, $where, $param_new);
|
||||
$where = $where ? implode(' AND ', $where) : '';
|
||||
$where_sql = $where ? 'WHERE '.$where : '';
|
||||
|
||||
// 组合sql查询结果
|
||||
$sql = "SELECT `{$table}`.`id` FROM `".$table."` {$where_sql} ORDER BY NULL ";
|
||||
|
||||
// 统计搜索数量
|
||||
$ct = $this->db->query("SELECT count(*) as t FROM `".$table."` {$where_sql} ORDER BY NULL ")->getRowArray();
|
||||
$data = [
|
||||
'id' => $id,
|
||||
'catid' => intval($catid),
|
||||
'params' => dr_array2string(['param' => $param_new, 'sql' => $sql, 'where' => $where]),
|
||||
'keyword' => $param['keyword'] ? $param['keyword'] : '',
|
||||
'contentid' => intval($ct['t']),
|
||||
'inputtime' => SYS_TIME
|
||||
];
|
||||
if ($ct['t']) {
|
||||
// 存储数据
|
||||
$this->db->table($this->mytable.'_search')->replace($data);
|
||||
}
|
||||
} else {
|
||||
$this->db->table($this->mytable.'_search')->where('id', $data['id'])->update([
|
||||
'inputtime' => SYS_TIME
|
||||
]);
|
||||
}
|
||||
|
||||
// 格式化值
|
||||
$p = dr_string2array($data['params']);
|
||||
$data['sql'] = $p['sql'];
|
||||
$data['where'] = $p['where'];
|
||||
$data['params'] = $p['param'];
|
||||
if (isset($param['catdir']) && $param['catdir'] && $catid) {
|
||||
# 目录栏目模式
|
||||
unset($data['params']['catid']);
|
||||
} elseif ($catid) {
|
||||
$data['params']['catid'] = $catid;
|
||||
}
|
||||
// order 参数
|
||||
if (isset($param['order']) && $param['order']) {
|
||||
$data['params']['order'] = dr_rp(dr_safe_filename($param['order']), '`', '');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// 重组搜索条件
|
||||
protected function mywhere($table, $name, $value, $field, $is_like = false) {
|
||||
$is_double_like = intval($this->module['setting']['search']['is_double_like']);
|
||||
if ($is_double_like && isset($field['fieldtype']) && in_array($field['fieldtype'], [
|
||||
'Selects' , 'Checkbox', 'Cats', 'Radio', 'Select', 'Linkages', 'Linkage'
|
||||
])) {
|
||||
$value.= '||';
|
||||
}
|
||||
$where = $this->_where($table, $name, $value, $field, $is_like);
|
||||
return $where;
|
||||
}
|
||||
|
||||
// 自定义组合参数
|
||||
protected function myparam($get) {
|
||||
return $get;
|
||||
}
|
||||
|
||||
// 自定义组合查询条件
|
||||
protected function mysearch($module, $where, $get) {
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace Phpcmf\Model;
|
||||
class Search extends \Phpcmf\Model\Cms\Search {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,680 @@
|
||||
<?php namespace Phpcmf\Model\Cms;
|
||||
|
||||
|
||||
class Site extends \Phpcmf\Model {
|
||||
|
||||
// 设置风格
|
||||
public function set_theme($name, $siteid) {
|
||||
|
||||
$site = $this->table('site')->get($siteid);
|
||||
if (!$site) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$site['setting'] = dr_string2array($site['setting']);
|
||||
$site['setting']['config']['SITE_THEME'] = $name;
|
||||
|
||||
$this->table('site')->update($siteid, [
|
||||
'setting' => dr_array2string($site['setting']),
|
||||
]);
|
||||
}
|
||||
|
||||
// 设置模板
|
||||
public function set_template($name, $siteid) {
|
||||
|
||||
$site = $this->table('site')->get($siteid);
|
||||
if (!$site) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$site['setting'] = dr_string2array($site['setting']);
|
||||
$site['setting']['config']['SITE_TEMPLATE'] = $name;
|
||||
|
||||
$this->table('site')->update($siteid, [
|
||||
'setting' => dr_array2string($site['setting']),
|
||||
]);
|
||||
}
|
||||
|
||||
// 获取网站配置
|
||||
public function config($siteid, $name = '', $data = []) {
|
||||
|
||||
!$siteid && $siteid = SITE_ID;
|
||||
$site = $this->table('site')->get($siteid);
|
||||
if (!$site) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$site['setting'] = dr_string2array($site['setting']);
|
||||
$site['setting']['config']['SITE_NAME'] = $site['name'];
|
||||
$site['setting']['config']['SITE_DOMAIN'] = strtolower((string)$site['domain']);
|
||||
|
||||
if ($name && $data) {
|
||||
// 更新数据
|
||||
if ($data['SITE_NAME']) {
|
||||
$site['name'] = $data['SITE_NAME'];
|
||||
}
|
||||
if ($data['SITE_DOMAIN']) {
|
||||
$site['domain'] = $data['SITE_DOMAIN'];
|
||||
}
|
||||
$site['setting'][$name] = $data;
|
||||
$this->table('site')->update($siteid, [
|
||||
'name' => $site['name'],
|
||||
'domain' => strtolower((string)$site['domain']),
|
||||
'setting' => dr_array2string($site['setting']),
|
||||
]);
|
||||
}
|
||||
|
||||
return $site['setting'];
|
||||
}
|
||||
|
||||
// 存储网站配置
|
||||
public function save_config($siteid, $name, $data) {
|
||||
|
||||
!$siteid && $siteid = SITE_ID;
|
||||
$site = $this->table('site')->get($siteid);
|
||||
if (!$site) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$site['setting'] = dr_string2array($site['setting']);
|
||||
$site['setting']['config']['SITE_NAME'] = $site['name'];
|
||||
$site['setting']['config']['SITE_DOMAIN'] = strtolower((string)$site['domain']);
|
||||
|
||||
// 更新数据
|
||||
if ($data['SITE_NAME']) {
|
||||
$site['name'] = $data['SITE_NAME'];
|
||||
}
|
||||
if ($data['SITE_DOMAIN']) {
|
||||
$site['domain'] = $data['SITE_DOMAIN'];
|
||||
}
|
||||
$site['setting'][$name] = $data;
|
||||
$this->table('site')->update($siteid, [
|
||||
'name' => $site['name'],
|
||||
'domain' => strtolower((string)$site['domain']),
|
||||
'setting' => dr_array2string($site['setting']),
|
||||
]);
|
||||
|
||||
return $site['setting'];
|
||||
}
|
||||
|
||||
// 设置网站单个配置
|
||||
public function config_value($siteid, $group, $value) {
|
||||
|
||||
!$siteid && $siteid = SITE_ID;
|
||||
$site = $this->table('site')->get($siteid);
|
||||
if (!$site || !$value) {
|
||||
return;
|
||||
}
|
||||
|
||||
$site['setting'] = dr_string2array($site['setting']);
|
||||
|
||||
foreach ($value as $n => $v) {
|
||||
$site['setting'][$group][$n] = $v;
|
||||
}
|
||||
|
||||
$this->table('site')->update($siteid, [
|
||||
'setting' => dr_array2string($site['setting']),
|
||||
]);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 新增
|
||||
public function create($data) {
|
||||
|
||||
$save = [
|
||||
'name' => $data['name'],
|
||||
'domain' => (string)$data['domain'],
|
||||
'setting' => dr_array2string([
|
||||
'webpath' => $data['webpath'],
|
||||
]),
|
||||
'disabled' => 0,
|
||||
'displayorder' => 0,
|
||||
];
|
||||
if (defined('IS_INSTALL')) {
|
||||
$save['id'] = 1;
|
||||
}
|
||||
$this->db->table('site')->replace($save);
|
||||
|
||||
$siteid = $this->db->insertID();
|
||||
|
||||
if ($siteid == 1) {
|
||||
return $siteid; // 安装不执行后面操作
|
||||
}
|
||||
|
||||
if (dr_is_app('sites')) {
|
||||
$obj = \Phpcmf\Service::M('sites', 'sites');
|
||||
if (method_exists($obj, 'create')) {
|
||||
$obj->create($siteid, $data);
|
||||
}
|
||||
}
|
||||
|
||||
return $siteid;
|
||||
}
|
||||
|
||||
// 变更主域名
|
||||
public function edit_domain($value) {
|
||||
|
||||
$site = $this->config(1);
|
||||
$value = trim(strtolower($value), '/');
|
||||
$this->db->table('site')->where('id', 1)->update([
|
||||
'domain' => $value,
|
||||
'setting' => dr_array2string($site),
|
||||
]);
|
||||
// 替换栏目编辑器域名
|
||||
$table = $this->dbprefix(SITE_ID.'_share_category');
|
||||
if ($this->is_table_exists($table)) {
|
||||
$this->db->query('UPDATE `'.$table.'` SET `content`=REPLACE(`content`, \''.$site['config']['SITE_DOMAIN'].'\', \''.$value.'\')');
|
||||
}
|
||||
}
|
||||
|
||||
// 设置域名
|
||||
public function domain($value = []) {
|
||||
|
||||
$data = [];
|
||||
$site = $this->config(SITE_ID);
|
||||
if ($value) {
|
||||
$site['webpath'] = $value['webpath'];
|
||||
$this->db->table('site')->where('id', SITE_ID)->update([
|
||||
'domain' => trim(strtolower($value['site_domain'] ? $value['site_domain'] : $site['domain']), '/'),
|
||||
'setting' => dr_array2string($site),
|
||||
]);
|
||||
}
|
||||
|
||||
$data['webpath'] = $site['webpath'];
|
||||
$data['site_domain'] = strtolower((string)$site['config']['SITE_DOMAIN']);
|
||||
|
||||
// 识别手机域名
|
||||
if (isset($site['mobile']['mode']) && $site['mobile']['mode'] != -1) {
|
||||
if (!$site['mobile']['mode']) {
|
||||
$data['mobile_domain'] = $site['mobile']['domain'];
|
||||
} else {
|
||||
$data['mobile_domain'] = $site['config']['SITE_DOMAIN'].'/'.trim($site['mobile']['dirname'] ? $site['mobile']['dirname'] : 'mobile');
|
||||
}
|
||||
} else {
|
||||
$data['mobile_domain'] = $site['mobile']['domain'];
|
||||
}
|
||||
|
||||
if ($site['client']) {
|
||||
foreach ($site['client'] as $c) {
|
||||
if ($c['name'] && $c['domain']) {
|
||||
$data['client_'.$c['name']] = $c['domain'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 模块域名
|
||||
$my = [];
|
||||
if (IS_USE_MODULE) {
|
||||
list($my, $data) = \Phpcmf\Service::M('module', 'cms')->domian($value, $my, $data);
|
||||
}
|
||||
|
||||
return [$my, $data];
|
||||
}
|
||||
|
||||
// 站点缓存缓存
|
||||
public function cache($siteid = null, $data = null, $module = null) {
|
||||
|
||||
!$data && $data = $this->table('site')->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
|
||||
$sso_domain = $client_domain = $webpath = $app_domain = $site_domain = $config = $cache = [];
|
||||
if ($data) {
|
||||
foreach ($data as $t) {
|
||||
if ($t['id'] > 1 && !dr_is_app('sites')) {
|
||||
break;
|
||||
}
|
||||
|
||||
$t['setting'] = dr_string2array($t['setting']);
|
||||
$mobile_dirname = 'mobile';
|
||||
|
||||
// 识别手机域名
|
||||
if (isset($t['setting']['mobile']['mode']) && $t['setting']['mobile']['mode'] != -1) {
|
||||
if (!$t['setting']['mobile']['mode']) {
|
||||
$mobile_domain = (string)$t['setting']['mobile']['domain'];
|
||||
} else {
|
||||
$mobile_dirname = trim($t['setting']['mobile']['dirname'] ? $t['setting']['mobile']['dirname'] : 'mobile');
|
||||
$mobile_domain = $t['domain'].'/'.$mobile_dirname;
|
||||
}
|
||||
} else {
|
||||
$mobile_domain = (string)$t['setting']['mobile']['domain'];
|
||||
}
|
||||
|
||||
$config[$t['id']] = [
|
||||
'SITE_NAME' => $t['name'],
|
||||
'SITE_DOMAIN' => strtolower($t['domain']),
|
||||
'SITE_LOGO' => $t['setting']['config']['logo'] ? dr_get_file($t['setting']['config']['logo']) : ROOT_THEME_PATH.'assets/logo-web.png',
|
||||
'SITE_MOBILE' => $mobile_domain,
|
||||
'SITE_MOBILE_DIR' => $mobile_dirname,
|
||||
'SITE_AUTO' => (string)$t['setting']['mobile']['auto'],
|
||||
'SITE_IS_MOBILE_HTML' => (string)$t['setting']['mobile']['tohtml'],
|
||||
'SITE_MOBILE_NOT_PAD' => (string)$t['setting']['mobile']['not_pad'],
|
||||
'SITE_CLOSE' => $t['setting']['config']['SITE_CLOSE'],
|
||||
'SITE_THEME' => $t['setting']['config']['SITE_THEME'],
|
||||
'SITE_TEMPLATE' => $t['setting']['config']['SITE_TEMPLATE'],
|
||||
'SITE_REWRITE' => $t['setting']['seo']['SITE_REWRITE'],
|
||||
'SITE_SEOJOIN' => $t['setting']['seo']['SITE_SEOJOIN'],
|
||||
'SITE_LANGUAGE' => $t['setting']['config']['SITE_LANGUAGE'],
|
||||
'SITE_TIMEZONE' => $t['setting']['config']['SITE_TIMEZONE'],
|
||||
'SITE_TIME_FORMAT' => $t['setting']['config']['SITE_TIME_FORMAT'],
|
||||
'SITE_INDEX_HTML' => (string)$t['setting']['config']['SITE_INDEX_HTML'],
|
||||
'SITE_THUMB_WATERMARK' => (int)$t['setting']['watermark']['thumb'],
|
||||
];
|
||||
unset($t['setting']['mobile']['auto'],
|
||||
$t['setting']['mobile']['domain'],
|
||||
$t['setting']['seo']['SITE_REWRITE'],
|
||||
$t['setting']['seo']['SITE_SEOJOIN'],
|
||||
$t['setting']['config']['SITE_THEME'],
|
||||
$t['setting']['config']['SITE_TEMPLATE'],
|
||||
$t['setting']['config']['SITE_LANGUAGE'],
|
||||
$t['setting']['config']['SITE_TIME_FORMAT'],
|
||||
$t['setting']['config']['SITE_NAME'],
|
||||
$t['setting']['config']['SITE_TIMEZONE'],
|
||||
$t['setting']['config']['SITE_DOMAIN'],
|
||||
$t['setting']['config']['SITE_CLOSE']
|
||||
);
|
||||
// 本站的全部域名归属
|
||||
$site_domain[$t['domain']] = $t['id'];
|
||||
$sso_domain[] = $t['domain'];
|
||||
if ($config[$t['id']]['SITE_MOBILE']) {
|
||||
$site_domain[$config[$t['id']]['SITE_MOBILE']] = $t['id'];
|
||||
$client_domain[$t['domain']] = $config[$t['id']]['SITE_MOBILE'];
|
||||
$sso_domain[] = $config[$t['id']]['SITE_MOBILE'];
|
||||
}
|
||||
// 自定义终端
|
||||
if ($t['setting']['client']) {
|
||||
$_save = [];
|
||||
foreach ($t['setting']['client'] as $c) {
|
||||
$site_domain[$c['domain']] = $t['id'];
|
||||
$_save[$c['name']] = $sso_domain[] = $c['domain'];
|
||||
}
|
||||
$t['setting']['client'] = $_save;
|
||||
}
|
||||
|
||||
// 网站路径
|
||||
$webpath[$t['id']] = [
|
||||
'site' => ROOTPATH,
|
||||
];
|
||||
if ($t['id'] > 1 && $t['setting']['webpath']) {
|
||||
$webpath[$t['id']]['site'] = dr_get_dir_path($t['setting']['webpath']);
|
||||
if (!is_dir($webpath[$t['id']]['site'])) {
|
||||
log_message('error', '多站点:站点【'.$t['id'].'】目录【'.$webpath[$t['id']]['site'].'】不存在');
|
||||
//continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 自定义站点字段
|
||||
$field = \Phpcmf\Service::M('field')->get_mysite_field($t['id']);
|
||||
if ($field && $t['setting']['param']) {
|
||||
$t['setting']['param'] = \Phpcmf\Service::L('Field')->app('')->format_value($field, $t['setting']['param'], 1);
|
||||
}
|
||||
|
||||
// 删除首页静态文件
|
||||
//unlink($webpath[$t['id']]['site'].'index.html');
|
||||
//unlink($webpath[$t['id']]['site'].$mobile_dirname.'/index.html');
|
||||
|
||||
$cache[$t['id']] = $t['setting'];
|
||||
}
|
||||
|
||||
list($webpath, $site_domain, $app_domain, $sso_domain, $client_domain) = \Phpcmf\Service::M('module', 'cms')->sync_site_cache(
|
||||
$module,
|
||||
$webpath,
|
||||
$site_domain,
|
||||
$app_domain,
|
||||
$sso_domain,
|
||||
$client_domain,
|
||||
[],
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::L('Cache')->set_file('site', $cache);
|
||||
\Phpcmf\Service::L('Config')->file(WRITEPATH.'config/site.php', '站点配置文件', 32)->to_require($config);
|
||||
\Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_sso.php', '同步域名配置文件', 32)->to_require_one($sso_domain);
|
||||
\Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_app.php', '网站域名配置文件', 32)->to_require_one($app_domain);
|
||||
\Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_site.php', '站点域名配置文件', 32)->to_require_one($site_domain);
|
||||
\Phpcmf\Service::L('Config')->file(WRITEPATH.'config/domain_client.php', '客户端域名配置文件', 32)->to_require_one($client_domain);
|
||||
\Phpcmf\Service::L('Config')->file(WRITEPATH.'config/webpath.php', '入口文件目录配置文件', 32)->to_require($webpath);
|
||||
}
|
||||
|
||||
|
||||
// 更新全部网站缓存
|
||||
public function update_site_cache() {
|
||||
|
||||
$site_cache = $this->table('site')->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
|
||||
$module_cache = $this->table('module')->order_by('displayorder ASC,id ASC')->getAll();
|
||||
|
||||
// 按网站更新的缓存
|
||||
$cache = [];
|
||||
|
||||
if (is_file(MYPATH.'/Config/Cache.php')) {
|
||||
$_cache = require MYPATH.'/Config/Cache.php';
|
||||
$_cache && $cache = dr_array22array($cache, $_cache);
|
||||
}
|
||||
|
||||
// 执行插件自己的缓存程序
|
||||
$menu = \Phpcmf\Service::M('menu');
|
||||
$local = \Phpcmf\Service::Apps(1);
|
||||
$app_cache = [];
|
||||
foreach ($local as $dir => $path) {
|
||||
if (is_file($path.'Config/Cache.php')) {
|
||||
$_cache = require $path.'Config/Cache.php';
|
||||
$_cache && $app_cache[$dir] = $_cache;
|
||||
}
|
||||
// 更新新增菜单
|
||||
if (method_exists($menu, 'update_app')) {
|
||||
$menu->update_app($dir);
|
||||
}
|
||||
}
|
||||
|
||||
$page = intval($_GET['page']);
|
||||
$tpage = dr_count($site_cache);
|
||||
|
||||
if (!$page) {
|
||||
// 全局系统缓存
|
||||
#dr_dir_delete(WRITEPATH.'data');
|
||||
\Phpcmf\Service::M('site')->cache(0, $site_cache, $module_cache);
|
||||
foreach (['auth', 'email', 'member', 'attachment', 'system'] as $m) {
|
||||
\Phpcmf\Service::M($m)->cache();
|
||||
}
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('正在缓存数据'), 1);
|
||||
}
|
||||
|
||||
$key = $page - 1;
|
||||
if (!isset($site_cache[$key])) {
|
||||
\Phpcmf\Service::M('menu')->cache();
|
||||
\Phpcmf\Service::M('cache')->update_data_cache();
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('更新完成'));
|
||||
}
|
||||
|
||||
foreach ([ $site_cache[$key] ] as $t) {
|
||||
|
||||
\Phpcmf\Service::M('table')->cache($t['id'], $module_cache);
|
||||
\Phpcmf\Service::M('module')->cache($t['id'], $module_cache);
|
||||
|
||||
foreach ($cache as $m => $namespace) {
|
||||
\Phpcmf\Service::M($m, $namespace)->cache($t['id']);
|
||||
}
|
||||
|
||||
// 插件缓存
|
||||
$apps = [];
|
||||
if ($app_cache) {
|
||||
foreach ($app_cache as $namespace => $c) {
|
||||
\Phpcmf\Service::C()->init_file($namespace);
|
||||
foreach ($c as $i => $apt) {
|
||||
$class = is_numeric($i) ? $apt : $i;
|
||||
$apps[] = '['.$namespace.'-'.$class.']';
|
||||
\Phpcmf\Service::M($class, $namespace)->cache($t['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
CI_DEBUG && \Phpcmf\Service::L('input')->system_log('更新[网站#'.$t['id'].']缓存: '.implode(' - ', $apps));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('正在更新中(%s/%s)', $page+1, $tpage), $page + 1);
|
||||
}
|
||||
|
||||
// 更新当前网站缓存
|
||||
public function update_cache() {
|
||||
|
||||
$site_cache = $this->table('site')->where('disabled', 0)->order_by('displayorder ASC,id ASC')->getAll();
|
||||
$module_cache = $this->table('module')->order_by('displayorder ASC,id ASC')->getAll();
|
||||
\Phpcmf\Service::M('site')->cache(0, $site_cache, $module_cache);
|
||||
|
||||
// 全局缓存
|
||||
foreach (['auth', 'email', 'member', 'attachment', 'system'] as $m) {
|
||||
\Phpcmf\Service::M($m)->cache();
|
||||
}
|
||||
|
||||
// 按网站更新的缓存
|
||||
$cache = [];
|
||||
|
||||
if (is_file(MYPATH.'/Config/Cache.php')) {
|
||||
$_cache = require MYPATH.'/Config/Cache.php';
|
||||
$_cache && $cache = dr_array22array($cache, $_cache);
|
||||
}
|
||||
|
||||
// 执行插件自己的缓存程序
|
||||
$menu = \Phpcmf\Service::M('menu');
|
||||
$local = \Phpcmf\Service::Apps(1);
|
||||
$app_cache = [];
|
||||
foreach ($local as $dir => $path) {
|
||||
if (is_file($path.'Config/Cache.php')) {
|
||||
$_cache = require $path.'Config/Cache.php';
|
||||
$_cache && $app_cache[$dir] = $_cache;
|
||||
}
|
||||
// 更新新增菜单
|
||||
if (method_exists($menu, 'update_app')) {
|
||||
$menu->update_app($dir);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($site_cache as $t) {
|
||||
|
||||
if (!in_array($t['id'], [SITE_ID, 1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('table')->cache($t['id'], $module_cache);
|
||||
\Phpcmf\Service::M('module')->cache($t['id'], $module_cache);
|
||||
|
||||
if ($cache) {
|
||||
foreach ($cache as $m => $namespace) {
|
||||
$obj = \Phpcmf\Service::M($m, $namespace);
|
||||
if ($obj && method_exists($obj, 'cache')) {
|
||||
$obj->cache($t['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 插件缓存
|
||||
$apps = [];
|
||||
if ($app_cache) {
|
||||
foreach ($app_cache as $namespace => $c) {
|
||||
\Phpcmf\Service::C()->init_file($namespace);
|
||||
foreach ($c as $i => $apt) {
|
||||
$class = is_numeric($i) ? $apt : $i;
|
||||
$obj = \Phpcmf\Service::M($class, $namespace);
|
||||
if ($obj && method_exists($obj, 'cache')) {
|
||||
$apps[] = '['.$namespace.'-'.$class.']';
|
||||
$obj->cache($t['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
CI_DEBUG && \Phpcmf\Service::L('input')->system_log('更新[网站#'.$t['id'].']缓存: '.implode(' - ', $apps));
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('menu')->cache();
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 重建索引
|
||||
public function update_search_index() {
|
||||
|
||||
$site_cache = $this->table('site')->where('disabled', 0)->getAll();
|
||||
$module_cache = $this->table('module')->getAll();
|
||||
if (!$module_cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($site_cache as $t) {
|
||||
foreach ($module_cache as $m ) {
|
||||
$table = dr_module_table_prefix($m['dirname'], $t['id']);
|
||||
// 判断是否存在表
|
||||
if (!$this->db->tableExists($table)) {
|
||||
continue;
|
||||
}
|
||||
$this->db->table($table.'_search')->truncate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 重建子站配置文件
|
||||
public function update_site_config() {
|
||||
|
||||
$page = intval($_GET['page']);
|
||||
if (!$page) {
|
||||
$site_cache = $this->table('site')->where('disabled', 0)->getAll();
|
||||
foreach ($site_cache as $t) {
|
||||
$t['setting'] = dr_string2array($t['setting']);
|
||||
if ($t['id'] > 1 && $t['setting']['webpath']) {
|
||||
$rt = $this->update_webpath('Web', $t['setting']['webpath'], [
|
||||
'SITE_ID' => $t['id'],
|
||||
'FIX_WEB_DIR' => strpos($t['setting']['webpath'], '/') === false && strpos($t['domain'], $t['setting']['webpath']) !== false ? $t['setting']['webpath'] : '',
|
||||
'MOBILE_DIR' => $t['setting']['mobile']['mode'] == 1 ? $t['setting']['mobile']['dirname'] : '',
|
||||
]);
|
||||
if ($rt) {
|
||||
$this->_error_msg('网站['.$t['domain'].']: '.$rt);
|
||||
}
|
||||
$path = rtrim($t['setting']['webpath'], '/').'/';
|
||||
} else {
|
||||
$path = ROOTPATH;
|
||||
}
|
||||
if ($t['setting']['client'] && !dr_is_app('client')) {
|
||||
foreach ($t['setting']['client'] as $c) {
|
||||
if ($c['name'] && $c['domain']) {
|
||||
$rt = $this->update_webpath('Client', $path.$c['name'].'/', [
|
||||
'CLIENT' => $c['name'],
|
||||
'SITE_ID' => $t['id'],
|
||||
'FIX_WEB_DIR' => $c['domain'] == $t['domain'].'/'.$c['name'] ? $c['name'] : '',
|
||||
'SITE_FIX_WEB_DIR' => $t['setting']['webpath'] && strpos($t['setting']['webpath'], '/') === false && strpos($t['domain'], $t['setting']['webpath']) !== false ? $t['setting']['webpath'] : '',
|
||||
]);
|
||||
if ($rt) {
|
||||
$this->_error_msg('网站['.$t['domain'].']的终端['.$c['name'].']: '.$rt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
\Phpcmf\Service::L('cache')->set_auth_data('update_site_config', $this->table('module')->where('share', 0)->getAll());
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('正在准备更新'), 1);
|
||||
}
|
||||
|
||||
$module = \Phpcmf\Service::L('cache')->get_auth_data('update_site_config');
|
||||
if (!$module) {
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('无可用更新'), 0);
|
||||
}
|
||||
|
||||
$key = $page - 1;
|
||||
if (!isset($module[$key])) {
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('更新完成'), 0);
|
||||
}
|
||||
|
||||
\Phpcmf\Service::M('module', 'cms')->update_site_config($module[$key]);
|
||||
|
||||
\Phpcmf\Service::C()->_json(1, dr_lang('正在更新中(%s)', $page), $page + 1);
|
||||
}
|
||||
|
||||
// 生成目录式手机目录
|
||||
public function update_mobile_webpath($path, $dirname) {
|
||||
|
||||
foreach (['api.php', 'index.php'] as $file) {
|
||||
if (is_file(IS_USE_MODULE.'Temps/Web/mobile/'.$file)) {
|
||||
$dst = $path.$dirname.'/'.$file;
|
||||
dr_mkdirs(dirname($dst));
|
||||
$size = file_put_contents($dst, str_replace([
|
||||
'{FIX_WEB_DIR}'
|
||||
], [
|
||||
(defined('FIX_WEB_DIR') && FIX_WEB_DIR ? FIX_WEB_DIR.'/' : '').$dirname
|
||||
], file_get_contents(IS_USE_MODULE.'Temps/Web/mobile/'.$file)));
|
||||
if (!$size) {
|
||||
return '文件['.$dst.']无法写入';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新网站
|
||||
public function update_webpath($name, $path, $value, $root = IS_USE_MODULE.'Temps/') {
|
||||
|
||||
if (!$path) {
|
||||
return '目录为空';
|
||||
} elseif (strpos($path, ' ') === 0) {
|
||||
return '不能用空格开头';
|
||||
}
|
||||
|
||||
$path = dr_get_dir_path($path);
|
||||
if (!$path) {
|
||||
return '目录为空';
|
||||
}
|
||||
|
||||
dr_mkdirs($path);
|
||||
if (!is_dir($path)) {
|
||||
return '目录['.$path.']不存在';
|
||||
}
|
||||
|
||||
// 创建入口文件
|
||||
//(defined('FIX_WEB_DIR') && FIX_WEB_DIR ? FIX_WEB_DIR.'/' : '').
|
||||
|
||||
foreach ([
|
||||
'admin.php',
|
||||
'index.php',
|
||||
'api.php',
|
||||
'mobile/api.php',
|
||||
'mobile/index.php',
|
||||
] as $file) {
|
||||
if (is_file($root.$name.'/'.$file)) {
|
||||
if ($file == 'admin.php') {
|
||||
$dst = $path.(SELF == 'index.php' ? 'admin.php' : SELF);
|
||||
} else {
|
||||
$dst = $path.$file;
|
||||
}
|
||||
$fix_web_dir = isset($value['FIX_WEB_DIR']) && $value['FIX_WEB_DIR'] ? $value['FIX_WEB_DIR'] : '';
|
||||
if (isset($value['SITE_ID']) && $value['SITE_ID'] > 1) {
|
||||
if (strpos($file, 'mobile') !== false
|
||||
&& isset($value['MOBILE_DIR']) && $value['MOBILE_DIR']) {
|
||||
$fix_web_dir.= '/'.$value['MOBILE_DIR'];
|
||||
} elseif ($fix_web_dir) {
|
||||
// 移动端加二级
|
||||
if (strpos($file, 'mobile/') !== false) {
|
||||
$fix_web_dir.= '/mobile';
|
||||
}
|
||||
// 终端加二级
|
||||
if ( $name == 'Client') {
|
||||
$fix_web_dir= (isset($value['SITE_FIX_WEB_DIR']) && $value['SITE_FIX_WEB_DIR'] ? $value['SITE_FIX_WEB_DIR'].'/' : '').$fix_web_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
dr_mkdirs(dirname($dst));
|
||||
$size = file_put_contents($dst, str_replace([
|
||||
'{CLIENT}',
|
||||
'{ROOTPATH}',
|
||||
'{MOD_DIR}',
|
||||
'{SITE_ID}',
|
||||
'{FIX_WEB_DIR}'
|
||||
], [
|
||||
$value['CLIENT'],
|
||||
ROOTPATH,
|
||||
$value['MOD_DIR'],
|
||||
$value['SITE_ID'],
|
||||
trim($fix_web_dir, '/')
|
||||
], file_get_contents($root.$name.'/'.$file)));
|
||||
if (!$size) {
|
||||
return '文件['.$dst.']无法写入';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 复制百度编辑器到当前目录
|
||||
//$this->cp_ueditor_file($path);
|
||||
|
||||
// 复制百度编辑器到移动端网站
|
||||
//if (is_dir($path.'mobile')) {
|
||||
//$this->cp_ueditor_file($path.'mobile/');
|
||||
//}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// 错误输出
|
||||
public function _error_msg($msg) {
|
||||
echo dr_array2string(dr_return_data(0, $msg));exit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php namespace Phpcmf\Model\Cms;
|
||||
/**
|
||||
* https://www.besyun.com
|
||||
* BESCMS
|
||||
* 本代码基于MIT开源协议,协议规定此处版权信息不可去除
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
// 模型类
|
||||
|
||||
class Urlrule extends \Phpcmf\Model {
|
||||
|
||||
// 缓存
|
||||
public function cache($site = SITE_ID) {
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<?php namespace Phpcmf\Model\Cms;
|
||||
/**
|
||||
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
|
||||
**/
|
||||
|
||||
// 审核类
|
||||
class Verify extends \Phpcmf\Model {
|
||||
|
||||
// 验证是否具有审核状态
|
||||
public function _get_verify_status_edit($vid, $status) {
|
||||
|
||||
if (dr_in_array(1, $this->admin['roleid'])) {
|
||||
return 1; // 超管用户
|
||||
} elseif ($status == 0) {
|
||||
return 1; // 退稿的可以看到
|
||||
} elseif (\Phpcmf\Service::M('auth')->is_post_user()) {
|
||||
return 0; // 投稿者不允许编辑审核
|
||||
}
|
||||
|
||||
if (!IS_USE_MEMBER) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
$verify = \Phpcmf\Service::C()->get_cache('verify');
|
||||
if (!$verify) {
|
||||
return 0; // 没有审核流程时
|
||||
}
|
||||
|
||||
$my = [];
|
||||
foreach ($verify as $t) {
|
||||
if ($t['value']['role']) {
|
||||
$rid = [];
|
||||
foreach ($t['value']['role'] as $c) {
|
||||
if (is_array($c)) {
|
||||
$rid = array_merge($rid, $c);
|
||||
} elseif (is_numeric($c)) {
|
||||
$rid[] = $c;
|
||||
}
|
||||
}
|
||||
if (dr_array_intersect($rid, $this->admin['roleid'])) {
|
||||
$my[] = $t['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$my) {
|
||||
// 此管理员没有管理权限
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 有权限了
|
||||
if (dr_in_array($vid, $my)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 获取当前栏目的时候流程
|
||||
public function _get_verify($vid) {
|
||||
|
||||
$rt = [];
|
||||
$cache = \Phpcmf\Service::C()->get_cache('verify');
|
||||
if ($cache && $vid && $cache[$vid]) {
|
||||
$verify = $cache[$vid];
|
||||
if ($verify['value']['role']) {
|
||||
$role = \Phpcmf\Service::C()->get_cache('auth');
|
||||
foreach ($verify['value']['role'] as $id => $rid) {
|
||||
if (!is_array($rid)) {
|
||||
if (isset($role[$rid]) && $role[$rid]) {
|
||||
$rt[$id] = [
|
||||
'rid' => $rid,
|
||||
'name' => dr_lang($role[$rid]['name'] ? $role[$rid]['name'] : '管理员'),
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$ns = [];
|
||||
foreach ($rid as $r) {
|
||||
if (isset($role[$r]) && $role[$r]) {
|
||||
$ns[] = dr_lang($role[$r]['name'] ? $role[$r]['name'] : '管理员');
|
||||
}
|
||||
}
|
||||
if ($ns) {
|
||||
$ns = array_unique($ns);
|
||||
$rt[$id] = [
|
||||
'rid' => $r,
|
||||
'name' => implode('、', $ns),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$rt[9] = [
|
||||
'name' => dr_lang('完成'),
|
||||
];
|
||||
|
||||
return $rt;
|
||||
}
|
||||
|
||||
// 审核时候的权限组,返回可用权限组的id
|
||||
// array(
|
||||
// * to_uid 指定人
|
||||
// * to_rid 指定角色组
|
||||
// * )
|
||||
public function _get_verify_roleid($catid, $status, $member) {
|
||||
|
||||
$verify = \Phpcmf\Service::C()->get_cache('verify');
|
||||
if (!$verify) {
|
||||
return ['to_uid' => 0, 'to_rid' => 0, 'verify_id' => 0];
|
||||
}
|
||||
|
||||
if (IS_MEMBER) {
|
||||
// 前端找用户设置
|
||||
$auth = \Phpcmf\Service::M('member_auth', 'cms')->category_auth(\Phpcmf\Service::C()->module, $catid, 'verify', $member);
|
||||
} else {
|
||||
// 后台投稿者
|
||||
$auth = \Phpcmf\Service::M('auth')->is_post_user_status();
|
||||
}
|
||||
|
||||
if ($auth && isset($verify[$auth]) && $verify[$auth]) {
|
||||
$v = $verify[$auth];
|
||||
$status = max(1, $status);
|
||||
if (isset($v['value']['role'][$status]) && $v['value']['role'][$status]) {
|
||||
if (is_array($v['value']['role'][$status])) {
|
||||
return ['to_uid' => 0, 'to_rid' => implode(',', $v['value']['role'][$status]), 'verify_id' => $v['id']];
|
||||
} else {
|
||||
return ['to_uid' => 0, 'to_rid' => $v['value']['role'][$status], 'verify_id' => $v['id']];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ['to_uid' => 0, 'to_rid' => 0, 'verify_id' => 0];
|
||||
}
|
||||
|
||||
// 后台内容审核列表的权限的sql语句
|
||||
public function get_admin_verify_status_list() {
|
||||
|
||||
if (dr_in_array(1, \Phpcmf\Service::C()->admin['roleid'])) {
|
||||
return '`status`>=0'; // 超管用户
|
||||
} elseif (!IS_USE_MEMBER && !\Phpcmf\Service::M('auth')->is_post_user()) {
|
||||
return '`status`>=0'; // 普通管理员
|
||||
}
|
||||
|
||||
$verify = \Phpcmf\Service::C()->get_cache('verify');
|
||||
if (!$verify) {
|
||||
return '`status`=0'; // 没有审核流程时
|
||||
}
|
||||
|
||||
$where = [];
|
||||
foreach ($verify as $t) {
|
||||
if ($t['value']['role']) {
|
||||
foreach ($t['value']['role'] as $status => $rid) {
|
||||
if (is_array($rid)) {
|
||||
if (dr_array_intersect($rid, \Phpcmf\Service::C()->admin['roleid'])) {
|
||||
$where[] = '(`status`='.$status.' and `vid`='.$t['id'].')';
|
||||
}
|
||||
} else {
|
||||
if (dr_in_array($rid, \Phpcmf\Service::C()->admin['roleid'])) {
|
||||
$where[] = '(`status`='.$status.' and `vid`='.$t['id'].')';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 此管理员没有管理权限
|
||||
if (!$where) {
|
||||
return 'status=0';
|
||||
}
|
||||
|
||||
return '`status` = 0 OR '.implode(' OR ', $where);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
'type' => 'module',
|
||||
'name' => '{name}',
|
||||
'icon' => '{icon}',
|
||||
'system' => '1',
|
||||
|
||||
];
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
// 加载主程序的路由
|
||||
require COREPATH.'Config/Routes.php';
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
/**
|
||||
* 二次开发时可以修改本文件,不影响升级覆盖
|
||||
*/
|
||||
|
||||
class Category extends \Phpcmf\Admin\Category
|
||||
{
|
||||
|
||||
public function index() {
|
||||
$this->_Admin_List();
|
||||
}
|
||||
|
||||
public function all_add() {
|
||||
$this->_Admin_All_Add();
|
||||
}
|
||||
|
||||
public function add() {
|
||||
$this->_Admin_Add();
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
$this->_Admin_Edit();
|
||||
}
|
||||
|
||||
public function url_edit() {
|
||||
$this->_Admin_Url_Edit();
|
||||
}
|
||||
|
||||
public function move_edit() {
|
||||
$this->_Admin_Move_Edit();
|
||||
}
|
||||
|
||||
public function show_edit() {
|
||||
$this->_Admin_Show_Edit();
|
||||
}
|
||||
|
||||
public function displayorder_edit() {
|
||||
$this->_Admin_Order();
|
||||
}
|
||||
|
||||
public function html_edit() {
|
||||
$this->_Admin_Html_Edit();
|
||||
}
|
||||
|
||||
public function del() {
|
||||
$this->_Admin_Del();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
/**
|
||||
* 二次开发时可以修改本文件,不影响升级覆盖
|
||||
*/
|
||||
|
||||
class Draft extends \Phpcmf\Admin\Module
|
||||
{
|
||||
|
||||
public function index() {
|
||||
$this->_Admin_Draft_List();
|
||||
}
|
||||
|
||||
public function del() {
|
||||
$this->_Admin_Draft_Del();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php namespace Phpcmf\Controllers\Admin;
|
||||
|
||||
/**
|
||||
* 二次开发时可以修改本文件,不影响升级覆盖
|
||||
*/
|
||||
|
||||
class Flag extends \Phpcmf\Admin\Module
|
||||
{
|
||||
|
||||
public function index() {
|
||||
$this->_Admin_Flag_List();
|
||||
}
|
||||
|
||||
public function edit() {
|
||||
$this->_Admin_Edit();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user