Initial project files: BESCMS full source

This commit is contained in:
bes
2026-08-13 23:37:46 +08:00
parent fa6cddb540
commit 2e26f85723
2166 changed files with 396625 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
<?php
return [
'type' => 'app',
'name' => '内容复制',
'author' => '迅睿云软件',
'icon' => 'fa fa-copy',
];
+14
View File
@@ -0,0 +1,14 @@
<?php
return [
[
'name' => '复制', // 站点权限是插件的链接名称
'icon' => 'fa fa-copy', // 图标
'color' => 'green', // 颜色class red green blue
'url' => 'javascript:dr_ajax_confirm_url(\''.dr_url('copy/api/content_edit', ['dir'=>'{mid}', 'id'=>'{cid}']).'\', \''.dr_lang('复制将把此内容生成一条新内容').'\');', // 后台的链接:对于点击的地址mid是模块目录,cid是内容id
'uri' => '', // 对应的uri权限判断,后面章节会介绍权限写法
'field' => '', // 统计数量的字段,填写模块内容的主表字段,只能填写int数字类型的字段
],
];
+14
View File
@@ -0,0 +1,14 @@
<?php
return [
[
'name' => '复制', // 站点权限是插件的链接名称
'icon' => 'fa fa-copy', // 图标
'color' => 'green', // 颜色class red green blue
'url' => 'javascript:dr_ajax_confirm_url(\''.dr_url('copy/api/form_edit', ['dir'=>'{fid}', 'id'=>'{id}']).'\', \''.dr_lang('复制将把此内容生成一条新内容').'\');', // 对于点击的地址fid是表单目录,id是内容id
'uri' => '', // 对应的uri权限判断,后面章节会介绍权限写法
'field' => '', // 统计数量的字段,填写模块内容的主表字段,只能填写int数字类型的字段
],
];
+14
View File
@@ -0,0 +1,14 @@
<?php
return [
[
'name' => '复制', // 站点权限是插件的链接名称
'icon' => 'fa fa-copy', // 图标
'color' => 'green', // 颜色class red green blue
'url' => 'javascript:dr_ajax_confirm_url(\''.dr_url('copy/api/mform_edit', ['mid'=>'{mid}', 'dir'=>'{fid}', 'cid'=>'{cid}', 'id'=>'{id}']).'\', \''.dr_lang('复制将把此内容生成一条新内容').'\');', // 对于点击的地址 mid是模块目录 fid是表单目录,id是内容id
'uri' => '', // 对应的uri权限判断,后面章节会介绍权限写法
'field' => '', // 统计数量的字段,填写模块内容的主表字段,只能填写int数字类型的字段
],
];
+34
View File
@@ -0,0 +1,34 @@
<?php
/**
* 菜单配置
*/
return [
'admin' => [
'app' => [
'left' => [
'app-plugin' => [
'link' => [
[
'name' => '内容复制',
'icon' => 'fa fa-copy',
'uri' => 'copy/home/index',
],
]
],
],
],
],
];
+4
View File
@@ -0,0 +1,4 @@
<?php
// 加载主程序的路由
require COREPATH.'Config/Routes.php';
+13
View File
@@ -0,0 +1,13 @@
<?php
return [
'id' => '389',
'vip' => '',
'cms' => '4.7.3',
'version' => '2.3',
'license' => '375C71349B295FBE2DCDCA9206F20A1703',
'updatetime' => '2026-06-01 18:29:28',
'downtime' => '2026-08-08 00:54:28',
];
+133
View File
@@ -0,0 +1,133 @@
<?php namespace Phpcmf\Controllers\Admin;
class Api extends \Phpcmf\Common
{
// 后台复制模块内容
public function content_edit() {
$dir = dr_safe_filename($_GET['dir']);
$this->_module_init($dir);
$id = intval(\Phpcmf\Service::L('Input')->get('id'));
list($data, $tables, $cdata) = $this->content_model->get_data($id, 1);
if (!$data) {
$this->_json(0, dr_lang('数据#%s不存在', $id));
}
$save = [
1 => [],
0 => [],
];
foreach ($cdata as $table => $data) {
foreach ($data as $i => $t) {
if (strpos($table, '_data_') !== false) {
if (\Phpcmf\Service::M()->db->fieldExists($i, \Phpcmf\Service::M()->dbprefix(SITE_ID.'_'.$dir.'_data_0'))) {
$save[0][$i] = $t;
}
} else {
if (\Phpcmf\Service::M()->db->fieldExists($i, \Phpcmf\Service::M()->dbprefix(SITE_ID.'_'.$dir))) {
$save[1][$i] = $t;
}
}
}
}
$save[1]['updatetime'] = $save[1]['inputtime'] = SYS_TIME;
$save[1]['title'].= '_'.dr_lang('复制');
$rt = $this->content_model->save_content(0, $save);
if (!$rt['code']) {
$this->_json(0, $rt['msg']);
}
// 联动操作
$this->content_model->_content_copy_after($rt['code'], $save);
$this->_json(1, dr_lang('内容复制成功'), ['url' => dr_url($dir.'/home/index')]);
}
// 后台复制表单内容
public function form_edit() {
$dir = dr_safe_filename($_GET['dir']);
$cache = \Phpcmf\Service::L('cache')->get('form-'.SITE_ID);
!$cache[$dir] && $this->_admin_msg(0, dr_lang('网站表单【%s】不存在', $dir));
$table = SITE_ID.'_form_'.$dir;
$id = intval(\Phpcmf\Service::L('Input')->get('id'));
$data = \Phpcmf\Service::M()->table($table)->get($id);
if (!$data) {
$this->_json(0, dr_lang('数据#%s不存在', $id));
}
$data['title'].= '_'.dr_lang('复制');
$data['inputtime'] = SYS_TIME;
unset($data['id']);
$rt = \Phpcmf\Service::M()->table($table)->insert($data);
if (!$rt['code']) {
$this->_json(0, $rt['msg']);
}
$data2 = \Phpcmf\Service::M()->table($table.'_data_'.intval($data['tableid']))->get($id);
if ($data2) {
$data2['id'] = $rt['code'];
$rt = \Phpcmf\Service::M()->table($table.'_data_'.intval($data['tableid']))->insert($data2);
if (!$rt['code']) {
$this->_json(0, $rt['msg']);
}
}
$this->_json(1, dr_lang('内容复制成功'), ['url' => dr_url('form/'.$dir.'/index')]);
}
// 后台复制模块表单内容
public function mform_edit() {
$dir = dr_safe_filename($_GET['dir']);
$cid = dr_safe_filename($_GET['cid']);
$mid = dr_safe_filename($_GET['mid']);
$this->_module_init($mid);
$this->form = $this->module['form'][$dir];
!$this->form && $this->_admin_msg(0, dr_lang('模块表单【%s】不存在', $dir));
$table = dr_module_table_prefix($mid).'_form_'.$this->form['table'];
$id = intval(\Phpcmf\Service::L('Input')->get('id'));
$data = \Phpcmf\Service::M()->table($table)->get($id);
if (!$data) {
$this->_json(0, dr_lang('数据#%s不存在', $id));
}
$data['title'].= '_'.dr_lang('复制');
$data['inputtime'] = SYS_TIME;
unset($data['id']);
$rt = \Phpcmf\Service::M()->table($table)->insert($data);
if (!$rt['code']) {
$this->_json(0, $rt['msg']);
}
$data2 = \Phpcmf\Service::M()->table($table.'_data_'.intval($data['tableid']))->get($id);
if ($data2) {
$data2['id'] = $rt['code'];
$rt = \Phpcmf\Service::M()->table($table.'_data_'.intval($data['tableid']))->insert($data2);
if (!$rt['code']) {
$this->_json(0, $rt['msg']);
}
}
$this->_json(1, dr_lang('内容复制成功'), ['url' => dr_url($mid.'/'.$dir.'/index', ['cid'=>$cid])]);
}
}
@@ -0,0 +1,22 @@
<?php namespace Phpcmf\Controllers\Admin;
class Home extends \Phpcmf\Common
{
public function index() {
$version = [];
if (is_file(MYPATH.'Config/Version.php')) {
$version = require MYPATH.'Config/Version.php';
}
\Phpcmf\Service::V()->assign('menu', \Phpcmf\Service::M('auth')->_admin_menu(
[
'插件介绍' => ['copy/home/index', 'fa fa-cog'],
]
));
\Phpcmf\Service::V()->assign('is_old', isset($version['downtime']) ? 0 : 1);
\Phpcmf\Service::V()->display('config.html');
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php namespace Phpcmf\Model\Copy;
// 权限验证
class Auth extends \Phpcmf\Model
{
// 判断底部链接的显示权限
public function is_bottom_auth($mid) {
return 1;
}
// 判断右侧链接的显示权限
public function is_link_auth($mid) {
// $mid 是当前模块的目录名称
// 这里的程序体,显示返回1,不显示返回0
// 不存在
if (!\Phpcmf\Service::C()->_is_admin_auth($mid.'/home/edit')) {
return 0;
}
return 1;
}
// 判断底部链接的显示权限
public function is_auth($c, $m) {
return 1;
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php namespace Phpcmf\Model\Copy;
// 权限验证
class Auth_form extends \Phpcmf\Model
{
// 判断底部链接的显示权限
public function is_bottom_auth($mid) {
return 1;
}
// 判断右侧链接的显示权限
public function is_link_auth($mid) {
// $mid 在表单验证里面无效
$fid = \Phpcmf\Service::C()->form['table']; // fid是表单表名称
// 这里的程序体,显示返回1,不显示返回0
// 不存在
if (!\Phpcmf\Service::C()->_is_admin_auth($fid.'/home/edit')) {
return 0;
}
return 1;
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php namespace Phpcmf\Model\Copy;
// 权限验证
class Auth_mform extends \Phpcmf\Model
{
// 判断底部链接的显示权限
public function is_bottom_auth($mid) {
return 1;
}
// 判断右侧链接的显示权限
public function is_link_auth($mid) {
// $mid 模块目录
$fid = \Phpcmf\Service::C()->form['table']; // fid是表单表名称
// 这里的程序体,显示返回1,不显示返回0
// 不存在
if (!\Phpcmf\Service::C()->_is_admin_auth($mid.'/'.$fid.'/edit')) {
return 0;
}
return 1;
}
}
+12
View File
@@ -0,0 +1,12 @@
{template "header.html"}
<div class="note note-danger">
<p>1、网站表单复制:将网站表单主表和附表一起复制为一条新数据</p>
<p>2、模块内容复制:将模块内容主表、附表、附加表一起复制为一条新数据(不复制评论、子内容等)</p>
<p>3、模块表单复制:将模块子表单主表和附表一起复制为一条新数据</p>
</div>
{if $is_old}
<p style="color: red">主程序版本过低,请前往官网下载升级包进行升级之后再使用本插件</p>
{/if}
<p>本插件安装成功后无需配置,直接在内容列表中即可看到复制按钮</p>
<p>如果需要复制模块内容时进行联动其他表也进行复制,需要开发者对内容模型类方法_content_copy_after进行重写</p>
{template "footer.html"}