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
+147
View File
@@ -0,0 +1,147 @@
<?php
$mid = $system['form'];
$module = \Phpcmf\Service::L('cache')->get('module-'.$system['site'].'-'.$dirname);
// 判断是否存在
if (!isset($module['form'][$mid]) || !$module['form'][$mid]) {
return $this->_return($system['return'], "模块{$dirname}表单({$mid})不存在"); // 参数判断
}
$form = $module['form'][$mid];
$tableinfo = \Phpcmf\Service::L('cache')->get('table-'.$system['site']);
if (!$tableinfo) {
// 没有表结构缓存时返回空
return $this->_return($system['return'], '表结构缓存不存在');
}
if (isset($param['cid']) && $param['cid']) {
$table = \Phpcmf\Service::M()->dbprefix(dr_mform_ctable($dirname, $form['table'], $param['cid'], $system['site'])); // 模块主表
} else {
$table = \Phpcmf\Service::M()->dbprefix(dr_mform_table_prefix($dirname, $form['table'], $system['site'])); // 模块主表
}
if (!isset($tableinfo[$table])) {
return $this->_return($system['return'], '表('.$table.')结构缓存不存在');
}
// 默认条件
$where[] = array(
'adj' => '',
'name' => 'status',
'value' => 1
);
// 是否操作自定义where
if ($param['where']) {
$where[] = [
'adj' => 'SQL',
'value' => urldecode($param['where'])
];
unset($param['where']);
}
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']];
}
}
$fwhere && $where[] = [
'adj' => 'SQL',
'value' => urldecode(count($fwhere) == 1 ? $fwhere[0] : '('.implode(' OR ', $fwhere).')')
];
unset($fwhere);
unset($catids);
}
$fields = $form['fields'];
$system['order'] = !$system['order'] ? 'inputtime_desc' : $system['order']; // 默认排序参数
$where = $this->_set_where_field_prefix($where, $tableinfo[$table], $table, $fields); // 给条件字段加上表前缀
$system['field'] = $this->_set_select_field_prefix($system['field'], $tableinfo[$table], $table); // 给显示字段加上表前缀
$system['order'] = $this->_set_order_field_prefix($system['order'], $tableinfo[$table], $table); // 给排序字段加上表前缀
// 多表组合排序
$_order = [];
$_order[$table] = $tableinfo[$table];
$sql_from = $table; // sql的from子句
// 关联表
if ($system['join'] && $system['on']) {
$rt = $this->_join_table($table, $system, $where, $_order, $sql_from);
if (!$rt['code']) {
return $this->_return($system['return'], $rt['msg']);
}
list($system, $where, $_order, $sql_from) = $rt['data'];
}
$total = 0;
$fields = $form['field']; // 主表的字段
$sql_where = $this->_get_where($where); // sql的where子句
$sql_limit = $pages = '';
// 统计标签
if ($this->_return_sql) {
$sql = "SELECT _XUNRUICMS_RT_ 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 ? $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 (!$total) {
return $this->_return($system['return'], '没有查询到内容', $sql, 0);
}
$sql_limit = 'LIMIT ' . $pagesize * ($page - 1) . ',' . $pagesize;
$pages = $this->_get_pagination($system['urlrule'], $pagesize, $total, $system['pagefile']);
} elseif ($system['num']) {
$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'] ? "ORDER BY {$system['order']}" : "") . " $sql_limit";
}
$data = $this->_query($sql, $system);
if (is_array($data) && $data) {
// 表的系统字段
$fields['inputtime'] = array('fieldtype' => 'Date');
$dfield = \Phpcmf\Service::L('Field')->app($dirname);
foreach ($data as $i => $t) {
$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);
+21
View File
@@ -0,0 +1,21 @@
<?php namespace Phpcmf\Controllers;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class $NAME$ extends \Phpcmf\Home\Mform
{
public function index() {
$this->_Home_List();
}
public function show() {
$this->_Home_Show();
}
public function post() {
$this->_Home_Post();
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php namespace Phpcmf\Controllers\Admin;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class $NAME$ extends \Phpcmf\Admin\Mform
{
public function index() {
$this->_Admin_List();
}
public function add() {
$this->_Admin_Add();
}
public function edit() {
$this->_Admin_Edit();
}
public function show_index() {
$this->_Admin_Show();
}
public function order_edit() {
$this->_Admin_Order();
}
public function del() {
$this->_Admin_Del();
}
}
@@ -0,0 +1,33 @@
<?php namespace Phpcmf\Controllers\Admin;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class $NAME$_verify extends \Phpcmf\Admin\Mform
{
public function index() {
$this->_Admin_List();
}
public function edit() {
$this->_Admin_Edit();
}
public function show_index() {
$this->_Admin_Show();
}
public function order_edit() {
$this->_Admin_Order();
}
public function del() {
$this->_Admin_Del();
}
public function status_index() {
$this->_Admin_Status();
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php namespace Phpcmf\Controllers\Member;
/**
* 二次开发时可以修改本文件,不影响升级覆盖
*/
class $NAME$ extends \Phpcmf\Member\Mform
{
public function index() {
$this->_Member_List();
}
public function add() {
$this->_Member_Add();
}
public function edit() {
$this->_Member_Edit();
}
public function order_edit() {
$this->_Member_Order();
}
public function del() {
$this->_Member_Del();
}
}
+11
View File
@@ -0,0 +1,11 @@
<?php
return [
'type' => 'app',
'name' => '模块内容表单',
'author' => '迅睿云软件',
'icon' => 'fa fa-table',
'uri' => 'mform/module/index'
];
+27
View File
@@ -0,0 +1,27 @@
<?php
// 自动加载识别文件
return [
/**
* 命名空间映射关系
*/
'psr4' => [
],
/**
* 类名映射关系
*/
'classmap' => [
'Phpcmf\Admin\Mform' => dr_get_app_dir('mform').'Control/Admin/Mform.php',
'Phpcmf\Member\Mform' => dr_get_app_dir('mform').'Control/Member/Mform.php',
'Phpcmf\Home\Mform' => dr_get_app_dir('mform').'Control/Home/Mform.php',
],
];
+7
View File
@@ -0,0 +1,7 @@
<?php
if (!method_exists(\Phpcmf\Service::M('table'), 'install_schema')) {
return dr_return_data(0, '请先升级迅睿系统后再安装本插件');
}
return dr_return_data(1, 'ok');
+30
View File
@@ -0,0 +1,30 @@
<?php
if (!function_exists('dr_mform_status_name')) {
function dr_mform_status_name($value, $param = [], $data = [], $field = []) {
if ($value == 0) {
//待审核
return '<span class="label label-success"> '.dr_lang('待审核').' </span>';
} elseif ($value == 1) {
//已通过
return '<span class="label label-success"> '.dr_lang('已通过').' </span>';
} else {
//未通过
return '<span class="label label-danger"> '.dr_lang('未通过').' </span>';
}
}
}
if (!function_exists('dr_mform_ctable')) {
function dr_mform_ctable($mid, $tid, $cid, $siteid = SITE_ID) {
return ($siteid ? $siteid.'_' : '').$mid.'_form_'.$tid;
if ($cid && $tid && $mid) {
$tableid = substr($cid, -1, 1);
return ($siteid ? $siteid.'_' : '').$mid.'_form_'.$tid.'_'.($tableid ? $tableid : 0);
}
return ($siteid ? $siteid.'_' : '').$mid.'_form_'.$tid;
}
}
+2
View File
@@ -0,0 +1,2 @@
<?php
+25
View File
@@ -0,0 +1,25 @@
<?php
$rt = \Phpcmf\Service::M('table')->install_schema([
'tables' => [
'module_form' => [
'comment' => '模块表单表',
'fields' => [
'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
'name' => 'varchar(50) NOT NULL COMMENT \'表单名称\'',
'table' => 'varchar(50) NOT NULL COMMENT \'表单表名称\'',
'module' => 'varchar(50) NOT NULL COMMENT \'模块目录\'',
'disabled' => 'tinyint(1) unsigned NOT NULL COMMENT \'是否禁用\'',
'setting' => 'text NOT NULL COMMENT \'表单配置\'',
],
'indexes' => [
'PRIMARY KEY (`id`)',
'KEY `table` (`table`)',
'KEY `disabled` (`disabled`)',
],
],
],
'seeds' => [],
]);
if (empty($rt['code'])) {
log_message('error', 'Mform install_schema: '.($rt['msg'] ?? ''));
}
View File
+30
View File
@@ -0,0 +1,30 @@
<?php
/**
* 菜单配置
*/
return [
'admin' => [
'config' => [
'left' => [
'config-content' => [
'link' => [
'app-mform' => [
'name' => '模块内容表单',
'icon' => 'fa fa-list-alt',
'uri' => 'mform/module/index',
],
],
],
],
],
],
];
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* http://www.xunruicms.com
* 本文件是框架系统文件,二次开发时不可以修改本文件
**/
/**
* 通知动作注册配置
*
* 动作字符 => 动作名称
*
**/
$cfg = [
'module_form_verify_1' => '[所有]审核后通知表单作者',
'module_form_verify_0' => '[所有]被拒绝后通知表单作者',
'module_form_verify_2' => '[所有]审核后通知主体作者',
'module_form_post_2' => '[所有]前台提交(直接通过时)通知主体作者',
'module_form_post_1' => '[所有]前台提交(直接通过时)通知表单作者',
];
return $cfg;
+4
View File
@@ -0,0 +1,4 @@
<?php
// 加载主程序的路由
require COREPATH.'Config/Routes.php';
+12
View File
@@ -0,0 +1,12 @@
<?php
// 同步执行就脚本
// App/AppName/Config/Sync.php
return [
'delete_content' => [
'mform' => 'delete_content',
// 模型文件 => 方法名称
],
];
+2
View File
@@ -0,0 +1,2 @@
<?php
\Phpcmf\Service::M('table')->drop_table(\Phpcmf\Service::M()->dbprefix('module_form'), true);
+13
View File
@@ -0,0 +1,13 @@
<?php
return [
'id' => '711',
'vip' => '',
'cms' => '4.7.3',
'version' => '1.28',
'license' => '375C71349B295FBE2DCDCA9206F20A1703',
'updatetime' => '2026-06-01 17:45:05',
'downtime' => '2026-08-08 00:54:28',
];
+479
View File
@@ -0,0 +1,479 @@
<?php namespace Phpcmf\Admin;
// 内容模块表单操作类 基于 Ftable
class Mform extends \Phpcmf\Table
{
public $cid; // 内容id
public $index; //
public $form; // 表单信息
public $is_verify; // 判断是否来自审核控制器
protected $is_add_menu = 1; //允许有添加菜单
// 上级公共类
public function __construct() {
parent::__construct();
$this->_Extend_Init();
$this->fix_admin_tpl_path = dr_get_app_dir('mform').'Views/';
}
// 继承类初始化
protected function _Extend_Init() {
// 初始化模块
$this->_module_init(APP_DIR);
// 判断是否来自审核控制器
$this->is_verify = strpos(\Phpcmf\Service::L('Router')->class, '_verify') !== false;
// 判断表单是否操作
$this->form = $this->module['form'][str_replace('_verify', '',\Phpcmf\Service::L('Router')->class)];
if (!$this->form) {
$this->_admin_msg(0, dr_lang('模块表单【%s】不存在', str_replace('_verify', '',\Phpcmf\Service::L('Router')->class)));
}
// 支持附表存储
$this->is_data = 1;
// 模板前缀(避免混淆)
$this->tpl_prefix = 'share_mform_';
// 单独模板命名
$this->tpl_name = $this->form['table'];
// 模块显示名称
$this->name = dr_lang('内容模块[%s]表单(%s', APP_DIR, $this->form['name']);
// 获取父级内容
$this->url_params['cid'] = $this->cid = intval(\Phpcmf\Service::L('input')->get('cid'));
$this->index = $this->cid ? $this->content_model->get_data( $this->cid) : [];
// 自定义条件
$where = $this->is_verify ? 'status<>1' : 'status=1';
$this->cid && $where.= ' and cid='. $this->cid;
$cwhere = $this->content_model->get_admin_list_where();
$cwhere && $where.= ' AND '. $cwhere;
$sysfield = ['inputtime', 'inputip', 'displayorder', 'uid', 'status'];
if ($this->is_verify) {
if (is_array($this->form['setting']['list_field'])) {
$this->form['setting']['list_field']['status'] = [
'use' => '1', // 1是显示,0是不显示
'name' => dr_lang('状态'), //显示名称
'width' => '100', // 显示宽度
'func' => 'dr_mform_status_name', // 回调函数见:http://help.xunruicms.com/463.html
'center' => '1', // 1是居中,0是默认
];
}
}
// 初始化数据表
$this->_init([
'field' => $this->form['field'],
'table' => SITE_ID.'_'.APP_DIR.'_form_'.$this->form['table'],
'sys_field' => $sysfield,
'date_field' => $this->form['setting']['search_time'] ? $this->form['setting']['search_time'] : 'inputtime',
'show_field' => 'title',
'list_field' => $this->form['setting']['list_field'],
'order_by' => $this->form['setting']['order'] ? dr_safe_replace($this->form['setting']['order']) : 'displayorder DESC,inputtime DESC',
'where_list' => $where,
]);
// 写入模板
\Phpcmf\Service::V()->assign([
'menu' => $this->_get_menu(),
'mform' => $this->form,
'index' => $this->index,
'field' => $this->init['field'],
'form_url' => \Phpcmf\Service::L('Router')->url(APP_DIR.'/'.$this->form['table'].'/index', ['cid' => $this->cid]),
'is_verify' => $this->is_verify,
'form_table' => $this->form['table'],
]);
if ($this->module['setting']['is_hide_search_bar']) {
$this->is_show_search_bar = 0;
}
}
protected function _get_menu() {
if ($this->is_verify) {
if ($this->cid) {
$menu = [
dr_lang('%s管理', $this->module['name']) => [MOD_DIR.'/home/index', dr_icon($this->module['setting']['icon'])],
dr_lang('%s管理', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
dr_lang('%s审核', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'_verify/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
];
} else {
$menu = [
dr_lang('%s审核', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'/index', 'fa fa-edit'],
];
}
} else {
$menu = [
dr_lang('%s管理', $this->module['name']) => [MOD_DIR.'/home/index', dr_icon($this->module['setting']['icon'])],
dr_lang('%s管理', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
dr_lang('%s审核', $this->form['name']) => [MOD_DIR.'/'.$this->form['table'].'_verify/index{cid='.$this->cid.'}', dr_icon($this->form['setting']['icon'])],
];
if ($this->cid && $this->is_add_menu) {
$menu[dr_lang('添加')] = [APP_DIR.'/'.$this->form['table'].'/add{cid='.$this->cid.'}', 'fa fa-plus'];
$menu[dr_lang('修改')] = ['hide:'.APP_DIR.'/'.$this->form['table'].'/edit', 'fa fa-edit'];
}
}
return \Phpcmf\Service::M('auth')->_admin_menu($menu);
}
// ========================
// 后台查看列表
protected function _Admin_List() {
$this->init['table'] = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
list($tpl) = $this->_List(['cid' => $this->cid]);
if ($this->_is_admin_auth('edit')) {
if ($this->is_verify) {
} else {
$this->mytable['link_var'].= 'html = html.replace(/\{cid\}/g, "'.$this->index['id'].'");';
$this->mytable['link_var'].= 'html = html.replace(/\{mid\}/g, "'.APP_DIR.'");';
$this->mytable['link_var'].= 'html = html.replace(/\{fid\}/g, "'.$this->form['table'].'");';
$clink = $this->_app_clink('mform');
if ($clink) {
foreach ($clink as $a) {
if ($a['model'] && $a['check']
&& method_exists($a['model'], $a['check'])
&& call_user_func(array($a['model'], $a['check']), APP_DIR, []) == 0) {
continue;
}
$this->mytable['link_tpl'].= ' <label><a class="btn '.$a['color'].' btn-xs" href="'.$a['url'].'"><i class="'.$a['icon'].'"></i> '.dr_lang($a['name']);
if ($a['field'] && \Phpcmf\Service::M()->is_field_exists($this->init['table'], $a['field'])) {
$this->mytable['link_tpl'].= '{'.$a['field'].'}';
$this->mytable['link_var'].= 'html = html.replace(/\{'.$a['field'].'\}/g, row.'.$a['field'].');';
}
$this->mytable['link_tpl'].= '</a></label>';
}
}
$cbottom = $this->_app_cbottom('mform');
if ($cbottom) {
$this->mytable['foot_tpl'].= '<label>
<div class="btn-group dropup">
<a class="btn blue btn-sm dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true" aria-expanded="false" href="javascript:;"> '.dr_lang('批量').'
<i class="fa fa-angle-up"></i>
</a>
<ul class="dropdown-menu">';
foreach ($cbottom as $a) {
$this->mytable['foot_tpl'].= '<li>
<a href="'.urldecode($a['url']).'"> <i class="'.$a['icon'].'"></i> '.dr_lang($a['name']).' </a>
</li>';
}
$this->mytable['foot_tpl'].= '
</ul>
</div>
</label>';
}
}
}
\Phpcmf\Service::V()->assign([
'mytable' => $this->mytable,
]);
\Phpcmf\Service::V()->assign([
'p' => ['cid' => $this->cid],
]);
return \Phpcmf\Service::V()->display($tpl);
}
// 后台添加内容
protected function _Admin_Add() {
if (!$this->cid) {
$this->_admin_msg(0, dr_lang('缺少cid参数'));
}
list($tpl) = $this->_Post(0);
\Phpcmf\Service::V()->assign([
'form' => dr_form_hidden(),
]);
\Phpcmf\Service::V()->display($tpl);
}
// 后台修改内容
protected function _Admin_Edit() {
$id = intval(\Phpcmf\Service::L('input')->get('id'));
list($tpl, $data) = $this->_Post($id);
if (!$this->cid) {
$this->_admin_msg(0, dr_lang('缺少cid参数'));
}
if (!$data) {
$this->_admin_msg(0, dr_lang('数据不存在: '.$id));
} elseif ($this->cid != $data['cid']) {
$this->_admin_msg(0, dr_lang('cid不匹配'));
} elseif ($this->is_verify && $data['status'] == 1) {
$this->_admin_msg(0, dr_lang('已经通过了审核'));
}
\Phpcmf\Service::V()->assign([
'form' => dr_form_hidden(),
]);
\Phpcmf\Service::V()->display($tpl);
}
// 后台查看内容
protected function _Admin_Show() {
$id = intval(\Phpcmf\Service::L('input')->get('id'));
list($tpl, $data) = $this->_Show($id);
if (!$this->cid) {
$this->_admin_msg(0, dr_lang('缺少cid参数'));
}
if (!$data) {
$this->_admin_msg(0, dr_lang('数据不存在: '.$id));
} elseif ($this->cid != $data['cid']) {
$this->_admin_msg(0, dr_lang('cid不匹配'));
} elseif ($this->is_verify && $data['status']) {
$this->_admin_msg(0, dr_lang('已经通过了审核'));
}
\Phpcmf\Service::V()->assign([
'form' => dr_form_hidden(),
]);
\Phpcmf\Service::V()->display($tpl);
}
// 后台批量保存排序值
protected function _Admin_Order() {
$this->_Display_Order(
intval(\Phpcmf\Service::L('input')->get('id')),
intval(\Phpcmf\Service::L('input')->get('value')),
function ($t) {
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
if ($table != $this->init['table']) {
// 备用表
$value = intval(\Phpcmf\Service::L('input')->get('value'));
\Phpcmf\Service::M()->table($table)->update($t['id'], ['displayorder' => $value]);
}
}
);
}
// 后台删除内容
protected function _Admin_Del() {
$this->_Del(
\Phpcmf\Service::L('input')->get_post_ids(),
null,
function ($rows) {
// 对应删除提醒
foreach ($rows as $t) {
\Phpcmf\Service::M('member')->delete_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$t['cid'].'/id/'.$t['id'], SITE_ID);// clear
\Phpcmf\Service::L('cache')->clear('module_'.MOD_DIR.'_from_'.$this->form['table'].'_show_id_'.$t['id']);
// 统计数量
\Phpcmf\Service::M('mform', 'mform')->update_form_total($t['cid'], $this->form['table']);
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
if ($table != $this->init['table']) {
// 备用表
\Phpcmf\Service::M()->table($table)->delete($t['id']);
}
}
},
\Phpcmf\Service::M()->dbprefix($this->init['table'])
);
}
// 后台批量审核
protected function _Admin_Status() {
$tid = intval(\Phpcmf\Service::L('input')->get('tid'));
$ids = \Phpcmf\Service::L('input')->get_post_ids();
if (!$ids) {
$this->_json(0, dr_lang('所选数据不存在'));
}
// 格式化
$in = [];
foreach ($ids as $i) {
$i && $in[] = intval($i);
}
if (!$in) {
$this->_json(0, dr_lang('所选数据不存在'));
}
$rows = \Phpcmf\Service::M()->db->table($this->init['table'])->whereIn('id', $in)->get()->getResultArray();
if (!$rows) {
$this->_json(0, dr_lang('所选数据不存在'));
}
foreach ($rows as $row) {
if ($row['status'] != 1) {
if ($tid) {
// 拒绝
$this->_verify_refuse($row);
} else {
// 通过
$this->_verify($row);
}
\Phpcmf\Service::M('mform', 'mform')->update_form_total($row['cid'], $this->form['table']);
}
}
$this->_json(1, dr_lang('操作成功'));
}
// ===========================
/**
* 获取内容
* $id 内容id,新增为0
* */
protected function _Data($id = 0) {
$row = $this->content_model->get_form_row($id, $this->form['table']);
if (!$row) {
return [];
}
$this->cid = $row['cid'];
if (!$this->index) {
$this->index = $this->content_model->get_data($row['cid']);
\Phpcmf\Service::V()->assign([
'menu' => $this->_get_menu(),
'index' => $this->index,
]);
}
return $row;
}
// 格式化保存数据 保存之前
protected function _Format_Data($id, $data, $old) {
// 验证父数据
if (!$this->index) {
$this->_json(0, dr_lang('关联内容不存在'));
}
// 默认数据
$data[1]['uid'] = intval($data[1]['uid']);
$data[0]['uid'] = (int)$data[1]['uid'];
$data[1]['cid'] = $data[0]['cid'] = $this->cid;
$data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
// 后台添加时默认通过
if (!$id) {
// !$this->is_verify &&
$data[1]['status'] = 1;
$data[1]['tableid'] = 0;
}
return $data;
}
/**
* 保存内容
* $id 内容id,新增为0
* $data 提交内容数组,留空为自动获取
* $func 格式化提交的数据
* */
protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
return parent::_Save($id, $data, $old, null,
function ($id, $data, $old) {
if ($this->is_verify) {
if ($data[1]['status'] == 1) {
// 审核通过时
$data[1]['status'] = 0;
$this->_verify($data[1]);
} elseif ($data[1]['status'] == 2) {
$data[1]['status'] = 0;
$this->_verify_refuse($data[1]);
}
}
// 保存之后的更新total字段
\Phpcmf\Service::M('mform', 'mform')->update_form_total( $this->cid, $this->form['table']);
\Phpcmf\Service::M('member')->todo_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$old['cid'].'/id/'.$old['id'], SITE_ID);
// clear
\Phpcmf\Service::L('cache')->clear('module_'.MOD_DIR.'_from_'.$this->form['table'].'_show_id_'.$id);
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
if ($table != $this->init['table']) {
// 备用表
\Phpcmf\Service::M()->table($table)->replace($data[1]);
}
$row = dr_array2array($data[1], $data[0]);
$row['index'] = $this->index;
if (!$old) {
// 挂钩点
\Phpcmf\Hooks::trigger('module_form_post_after', $row);
} else {
\Phpcmf\Hooks::trigger('module_form_edit_after', $row, $old);
}
}
);
}
// 审核拒绝
protected function _verify_refuse($row) {
if ($row['status'] == 2) {
return;
}
$row['form'] = $this->form;
$row['index'] = $this->index;
$row['module'] = $this->module;
\Phpcmf\Service::M()->db->table($this->init['table'])->where('id', $row['id'])->update(['status' => 2]);
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
if ($table != $this->init['table']) {
// 备用表
$value = intval(\Phpcmf\Service::L('input')->get('value'));
\Phpcmf\Service::M()->table($table)->update($row['id'], ['status' => 2]);
}
\Phpcmf\Service::M('member')->todo_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$row['cid'].'/id/'.$row['id'], SITE_ID);
\Phpcmf\Service::L('Notice')->send_notice('module_form_verify_0', $row);
}
// 审核通过
protected function _verify($row) {
if ($row['status'] == 1) {
return;
}
/*
// 增减金币
$score = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'score', $this->member);
$score && \Phpcmf\Service::M('member')->add_score($row['uid'], $score, dr_lang('%s: %s发布', MODULE_NAME, $this->form['name']), $row['curl']);
// 增减经验
$exp = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'exp', $this->member);
$exp && \Phpcmf\Service::M('member')->add_experience($row['uid'], $exp, dr_lang('%s: %s发布', MODULE_NAME, $this->form['name']), $row['curl']);
*/
\Phpcmf\Service::M('member')->todo_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$row['cid'].'/id/'.$row['id'], SITE_ID);
\Phpcmf\Service::M()->db->table($this->init['table'])->where('id', $row['id'])->update(['status' => 1]);
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
if ($table != $this->init['table']) {
// 备用表
$value = intval(\Phpcmf\Service::L('input')->get('value'));
\Phpcmf\Service::M()->table($table)->update($row['id'], ['status' => 1]);
}
if (!$this->index) {
$this->index = $this->content_model->get_data($row['cid']);
}
$row['form'] = $this->form;
$row['index'] = $this->index;
$row['module'] = $this->module;
\Phpcmf\Service::L('Notice')->send_notice('module_form_verify_1', $row);
$row['muid'] = $row['uid'];
$row['uid'] = $this->index['uid'];
\Phpcmf\Service::L('Notice')->send_notice('module_form_verify_2', $row);
}
}
+406
View File
@@ -0,0 +1,406 @@
<?php namespace Phpcmf\Home;
/**
* http://www.xunruicms.com
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
**/
// 内容模块表单操作类 基于 Ftable
class Mform extends \Phpcmf\Table
{
public $cid; // 内容id
public $form; // 表单信息
public $index; // 模块内容信息
// 上级公共类
public function __construct() {
parent::__construct();
$this->_Extend_Init();
}
// 继承类初始化
protected function _Extend_Init() {
// 初始化模块
$this->_module_init(APP_DIR);
// 判断表单是否操作
$this->form = $this->module['form'][\Phpcmf\Service::L('Router')->class];
if (!$this->form) {
$this->_msg(0, dr_lang('模块表单【%s】不存在',\Phpcmf\Service::L('Router')->class));
}
// 支持附表存储
$this->is_data = 1;
// 模板前缀(避免混淆)
$this->tpl_name = $this->form['table'];
$this->tpl_prefix = 'mform_';
// 预留cid
$this->cid = intval(\Phpcmf\Service::L('input')->get('cid'));
\Phpcmf\Service::V()->module(MOD_DIR);
}
// ========================
// 内容列表
protected function _Home_List() {
// 无权限访问表单
/*
if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'show', $this->member)) {
$this->_msg(0, dr_lang('您的用户组无权限访问表单'), $this->uid ? '' : dr_member_url('login/index'));
return;
}*/
// 获取父级内容
$this->index = $this->_Module_Row($this->cid);
if (!$this->index) {
$this->_msg(0, dr_lang('模块内容【id#%s】不存在', $this->cid));
}
// 初始化数据表
$this->_init([
'table' => dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['cid']),
'field' => $this->form['field'],
'show_field' => 'title'
]);
// 写入模板
\Phpcmf\Service::V()->assign([
'form_name' => $this->form['name'],
'form_table' => $this->form['table'],
]);
// seo
\Phpcmf\Service::V()->assign([
'meta_title' => dr_lang($this->form['name']).SITE_SEOJOIN.$this->index['title'],
'meta_keywords' => $this->index['keywords'],
'meta_description' => $this->index['description'],
]);
\Phpcmf\Service::V()->assign([
'index' => $this->index,
'catid' => intval($this->index['catid']),
'markid' => 'module-'.MOD_DIR.'-'.intval($this->index['catid']),
'urlrule' =>\Phpcmf\Service::L('Router')->mform_list_url($this->form['table'], $this->index['id'], MOD_DIR, '[page]'),
]);
\Phpcmf\Service::V()->display($this->_tpl_filename('list'));
}
// 添加内容
protected function _Home_Post() {
if ($this->form['setting']['is_close_post']) {
$this->_msg(0, dr_lang('禁止前端提交表单'));
}
// 无权限访问表单
/*
if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'add', $this->member)) {
$this->_msg(0, dr_lang('您的用户组无发布权限'), $this->uid ? '' : dr_member_url('login/index'));
return;
}*/
// 判断会员权限
//$this->member && $this->_member_option(0);
// 是否有验证码
$this->is_post_code = $this->form['setting']['is_post_code'] ? 0 : 1;
// 获取父级内容
$this->index = $this->_Module_Row($this->cid);
if (!$this->index) {
$this->_msg(0, dr_lang('所属主题【cid#%s】不存在', $this->cid));
};
// 初始化数据表
$this->_init([
'table' => dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['cid']),
'field' => $this->form['field'],
'show_field' => 'title'
]);
list($tpl) = $this->_Post(0);
// seo
\Phpcmf\Service::V()->assign([
'meta_title' => dr_lang($this->form['name']).SITE_SEOJOIN.$this->index['title'],
'meta_keywords' => $this->index['keywords'],
'meta_description' => $this->index['description'],
]);
\Phpcmf\Service::V()->assign([
'form' => dr_form_hidden(),
'index' => $this->index,
'catid' => intval($this->index['catid']),
'markid' => 'module-'.MOD_DIR.'-'.intval($this->index['catid']),
'rt_url' => $this->form['setting']['rt_url'] ? '' : dr_now_url(),
'is_post_code' => $this->is_post_code,
]);
\Phpcmf\Service::V()->display($tpl);
}
// 显示内容
protected function _Home_Show() {
/*
if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'show', $this->member)) {
$this->_msg(0, dr_lang('您的用户组无权限访问表单'), $this->uid ? '' : dr_member_url('login/index'));
return;
}*/
$id = intval(\Phpcmf\Service::L('input')->get('id'));
$name = 'module_'.MOD_DIR.'_form_'.$this->form['table'].'_show_id_'.$id;
$cache = \Phpcmf\Service::L('cache')->get_data($name);
if (!$cache) {
// 初始化数据表
$this->_init([
'table' => dr_mform_ctable(APP_DIR, $this->form['table'], 0),
'field' => $this->form['field'],
'show_field' => 'title'
]);
list($tpl, $data) = $this->_Show($id);
if (!$data) {
$this->_msg(0, dr_lang('表单内容【id#%s】不存在', $id));
}
// 获取父级内容
$this->cid = intval($data['cid']);
$this->index = $this->_Module_Row($this->cid);
if (!$this->index) {
$this->_msg(0, dr_lang('模块内容【id#%s】不存在', $this->cid));
}
// 模块的处理
$data = $this->_Call_Show($data);
$cache = [
$tpl,
$data,
$this->cid,
$this->index,
];
// 缓存结果
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, $cache, SYS_CACHE_SHOW * 3600);
}
}
} else {
list($tpl, $data, $this->cid, $this->index) = $cache;
}
// 无权限访问表单
if ($this->form['setting']['is_read'] && !in_array($this->uid, [$data['uid'], $this->index['uid']])) {
$this->_msg(0, dr_lang('无权限访问表单'));
}
if ($data['status'] != 1) {
$this->_msg(0, dr_lang('内容正在审核中'));
}
$data['cat'] = [];
if (isset($data['catid']) && $data['catid']) {
$data['cat'] = dr_cat_value($this->module['mid'], $data['catid']);
}
\Phpcmf\Service::V()->assign($data);
$data['cat'] = [];
$data['catname'] = $data['catpname'] = '';
if (isset($data['catid']) && $data['catid']) {
$data['cat'] = dr_cat_value($this->module['mid'], $data['catid']);
$data['catname'] = $data['cat']['name'];
$data['catpname'] = dr_get_cat_pname($this->module, $data['catid'], SITE_SEOJOIN);
} else {
}
$data['formname'] = dr_lang($this->form['name']);
$data['modulename'] = $data['modname'] = dr_lang($this->module['name']);
// seo
\Phpcmf\Service::V()->assign(\Phpcmf\Service::L('Seo')->get_seo_value($data, [
'meta_title' => isset($this->form['setting']['seo']['title']) && $this->form['setting']['seo']['title'] ? $this->form['setting']['seo']['title'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
'meta_keywords' => isset($this->form['setting']['seo']['keywords']) && $this->form['setting']['seo']['keywords'] ? $this->form['setting']['seo']['keywords'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
'meta_description' => isset($this->form['setting']['seo']['description']) && $this->form['setting']['seo']['description'] ? $this->form['setting']['seo']['description'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
]));
\Phpcmf\Service::V()->assign([
'index' => $this->index,
'catid' => intval($this->index['catid']),
'markid' => 'module-'.MOD_DIR.'-'.intval($this->index['catid']),
'urlrule' =>\Phpcmf\Service::L('Router')->mform_show_url($this->form['table'], $this->index['id'], MOD_DIR, '[page]'),
]);
\Phpcmf\Service::V()->display($tpl);
}
// ===========================
/**
* 获取内容
* $id 内容id,新增为0
* */
/*
protected function _Data($id = 0) {
if (!$id) {
return [];
}
$name = 'module_'.MOD_DIR.'_formxx_'.$this->form['table'].'_show_id_'.$id;
$data = \Phpcmf\Service::L('cache')->get_data($name);
if (!$data) {
// 处理缓存机制
$data = $this->content_model->get_form_row($id, $this->form['table']);
if (!$data) {
return [];
}
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);
}
}
}
return $data;
}*/
// 格式化保存数据 保存之前
protected function _Format_Data($id, $data, $old) {
// 验证父数据
if (!$this->index) {
$this->_json(0, dr_lang('关联内容不存在'));
}
if ($this->uid) {
// 判断日发布量
/*
$day_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'day_post', $this->member);
if ($day_post && \Phpcmf\Service::M()->db
->table($this->init['table'])
->where('uid', $this->uid)
->where('DATEDIFF(from_unixtime(inputtime),now())=0')
->countAllResults() >= $day_post) {
$this->_json(0, dr_lang('每天发布数量不能超过%s个', $day_post));
}
// 判断发布总量
$total_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'total_post', $this->member);
if ($total_post && \Phpcmf\Service::M()->db
->table($this->init['table'])
->where('uid', $this->uid)
->countAllResults() >= $total_post) {
$this->_json(0, dr_lang('发布数量不能超过%s个', $total_post));
}*/
}
// 审核状态
$data[1]['status'] = $this->form['setting']['is_verify'] ? 1 : 0;
// 默认数据
$data[0]['uid'] = $data[1]['uid'] = (int)$this->member['uid'];
//$data[1]['author'] = $this->member['username'] ? $this->member['username'] : 'guest';
$data[1]['cid'] = $data[0]['cid'] = $this->cid;
$data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
$data[1]['inputip'] = \Phpcmf\Service::L('input')->ip_info();
$data[1]['inputtime'] = SYS_TIME;
$data[1]['tableid'] = $data[1]['displayorder'] = 0;
return $data;
}
/**
* 保存内容
* $id 内容id,新增为0
* $data 提交内容数组,留空为自动获取
* $func 格式化提交的数据
* */
protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
return parent::_Save($id, $data, $old, null,
function ($id, $data, $old) {
// 保存之后
//审核通知
if ($data[1]['status']) {
/*
// 增减金币
$score = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'score', $this->member);
$score && \Phpcmf\Service::M('member')->add_score($this->member['uid'], $score, dr_lang('%s[%s]: %s发布', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
// 增减经验
$exp = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'exp', $this->member);
$exp && \Phpcmf\Service::M('member')->add_experience($this->member['uid'], $exp, dr_lang('%s[%s]: %s发布', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
*/
$row = dr_array2array($data[1], $data[0]);
$row['muid'] = $row['uid'];
$row['form'] = $this->form;
$row['index'] = $this->index;
$row['module'] = $this->module;
\Phpcmf\Service::L('Notice')->send_notice('module_form_post_1', $row);
$row['uid'] = $this->index['uid'];
\Phpcmf\Service::L('Notice')->send_notice('module_form_post_2', $row);
} else {
\Phpcmf\Service::M('member')->admin_notice(SITE_ID, 'content', $this->member, dr_lang('%s[%s]: %s提交内容审核', MODULE_NAME, $this->index['title'], $this->form['name']), MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'. $this->cid.'/id/'.$id);
}
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
if ($table != $this->init['table']) {
// 备用表
\Phpcmf\Service::M()->table($table)->replace($data[1]);
}
//更新total字段
\Phpcmf\Service::M('mform', 'mform')->update_form_total( $this->cid, $this->form['table']);
// 挂钩点
$row = dr_array2array($data[1], $data[0]);
$row['index'] = $this->index;
\Phpcmf\Hooks::trigger('module_form_post_after', $row);
}
);
}
// 操作主内容
protected function _Module_Row($id) {
$data = \Phpcmf\Service::L('cache')->get_data('module_'.MOD_DIR.'_show_id_'.$id);
if ($data) {
return $data;
}
$data = $this->content_model->get_data($id);
if (!$data) {
return [];
}
// 格式化输出自定义字段
$cat = dr_cat_value($this->module['mid'], $data['catid']);
$fields = $cat['field'] ? array_merge($this->module['field'], $cat['field']) : $this->module['field'];
$fields['inputtime'] = ['fieldtype' => 'Date'];
$fields['updatetime'] = ['fieldtype' => 'Date'];
$data['url'] = dr_url_prefix($data['url'], MOD_DIR);
return \Phpcmf\Service::L('Field')->app(MOD_DIR)->format_value($fields, $data);
}
/**
* 回调处理结果
* $data
* */
protected function _Call_Post($data) {
$data['url'] = $this->form['setting']['rt_url'] ? str_replace(['{id}', '{cid}'], [$data[1]['id'], $data[1]['cid']], $this->form['setting']['rt_url']) : '';
if ($data[1]['status']) {
return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text'] ? $this->form['setting']['rt_text'] : '操作成功'), $data);
} else {
return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text2'] ? $this->form['setting']['rt_text2'] : '操作成功,等待管理员审核'), $data);
}
}
// 前端回调处理类
protected function _Call_Show($data) {
return $data;
}
}
+333
View File
@@ -0,0 +1,333 @@
<?php namespace Phpcmf\Member;
/**
* http://www.xunruicms.com
* 本文件是框架系统文件,二次开发时不可以修改本文件,可以通过继承类方法来重写此文件
**/
// 内容模块表单操作类 基于 Ftable
class Mform extends \Phpcmf\Table
{
public $cid; // 内容id
public $form; // 表单信息
public $index; // 模块内容信息
protected $is_verify; // 判断是否来自审核控制器
protected $is_add_menu = 1; //允许有添加菜单
// 上级公共类
public function __construct() {
parent::__construct();
$this->_Extend_Init();
}
// 继承类初始化
protected function _Extend_Init() {
// 初始化模块
$this->_module_init(APP_DIR);
// 判断表单是否操作
$this->form = $this->module['form'][\Phpcmf\Service::L('Router')->class];
if (!$this->form) {
$this->_msg(0, dr_lang('模块表单【%s】不存在', \Phpcmf\Service::L('Router')->class));
} elseif (!$this->form['setting']['is_member']) {
$this->_msg(0, dr_lang('模块表单【%s】没有开启管理内容功能', \Phpcmf\Service::L('Router')->class));
}
// 支持附表存储
$this->is_data = 1;
// 模板前缀(避免混淆)
$this->tpl_prefix = 'mform_';
// 单独模板命名
$this->tpl_name = $this->form['table'];
// 模块显示名称
$this->name = dr_lang('内容模块[%s]表单(%s', APP_DIR, $this->form['name']);
// 获取父级内容
$this->url_params['cid'] = $this->cid = intval(\Phpcmf\Service::L('input')->get('cid'));
if ($this->cid) {
$this->index = $this->content_model->get_data($this->cid);
} else {
//$this->_msg(0, dr_lang('模块表单【%s】没有cid参数', $this->form['name']));
}
// 初始化数据表
$this->_init([
'field' => $this->form['field'],
'table' => dr_mform_ctable(APP_DIR, $this->form['table'], $this->cid),
'date_field' => 'inputtime',
'show_field' => 'title',
'list_field' => $this->form['setting']['list_field'],
'order_by' => 'displayorder DESC,inputtime DESC',
'where_list' => $this->cid ? 'cid='. $this->cid : ($this->form['setting']['is_member_user'] ? ' cid in (select id from '.
\Phpcmf\Service::M()->dbprefix(SITE_ID.'_'.APP_DIR.'_index').' where uid='.$this->uid.')' : 'uid='.$this->uid), // 自定义条件,显示本内容的表单
]);
$this->edit_where = $this->delete_where = $this->cid ? 'cid='. $this->cid : 'uid='.$this->uid;
// 是否有验证码
$this->is_post_code = $this->form['setting']['is_post_code'] ? 0 : 1;
// 写入模板
\Phpcmf\Service::V()->assign([
'mform' => $this->form,
'index' => $this->index,
'field' => $this->init['field'],
'form_url' => dr_member_url(APP_DIR.'/'.$this->form['table'].'/index', ['cid' => $this->cid]),
'is_verify' => $this->is_verify,
'is_post_code' => $this->is_post_code,
]);
}
// ========================
// 查看列表
protected function _Member_List() {
if ($this->cid) {
if ($this->index) {
if (!$this->form['setting']['is_member_user'] && $this->index['uid'] != $this->uid) {
$this->_msg(0, dr_lang('模块表单【%s】父内容[%s]不是你创建', $this->form['name'], $this->cid));
}
} else {
$this->_msg(0, dr_lang('模块表单【%s】父内容[%s]不存在', $this->form['name'], $this->cid));
}
}
$this->init['table'] = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
list($tpl) = $this->_List(['cid' => $this->cid]);
\Phpcmf\Service::V()->assign([
'p' => ['cid' => $this->cid],
'is_delete' => 0,
]);
return \Phpcmf\Service::V()->display($tpl);
}
// 添加内容
protected function _Member_Add() {
/*
if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'add', $this->member)) {
$this->_msg(0, dr_lang('您的用户组无发布权限'));
}*/
list($tpl) = $this->_Post(0);
\Phpcmf\Service::V()->assign([
'form' => dr_form_hidden(),
]);
\Phpcmf\Service::V()->display($tpl);
}
// 修改内容
protected function _Member_Edit() {
/*
if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'edit', $this->member)) {
$this->_msg(0, dr_lang('您的用户组无修改权限'));
}*/
$id = intval(\Phpcmf\Service::L('input')->get('id'));
list($tpl, $data) = $this->_Post($id);
if (!$data) {
$this->_msg(0, dr_lang('数据不存在: '.$id));
} elseif ($this->cid != $data['cid']) {
$this->_msg(0, dr_lang('所属主题cid不匹配'));
}
if ($this->form['setting']['is_member_user']) {
if (!in_array($this->uid, [$data['uid'], $this->index['uid']])) {
$this->_msg(0, dr_lang('无权限修改'));
}
} elseif ($this->uid != $data['uid']) {
$this->_msg(0, dr_lang('无权限修改'));
}
\Phpcmf\Service::V()->assign([
'form' => dr_form_hidden(),
]);
\Phpcmf\Service::V()->display($tpl);
}
// 批量保存排序值
protected function _Member_Order() {
$this->_Display_Order(
intval(\Phpcmf\Service::L('input')->get('id')),
intval(\Phpcmf\Service::L('input')->get('value')),
function ($t) {
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
if ($table != $this->init['table']) {
// 备用表
$value = intval(\Phpcmf\Service::L('input')->get('value'));
\Phpcmf\Service::M()->table($table)->update($t['id'], ['displayorder' => $value]);
}
}
);
}
// 删除内容
protected function _Member_Del() {
/*
if (!\Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'del', $this->member)) {
$this->_msg(0, dr_lang('您的用户组无删除权限'));
}*/
$this->_Del(
\Phpcmf\Service::L('input')->get_post_ids(),
null,
function ($rows) {
// 对应删除提醒
foreach ($rows as $t) {
\Phpcmf\Service::M('member')->delete_admin_notice(MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'.$t['cid'].'/id/'.$t['id'], SITE_ID);// clear
\Phpcmf\Service::L('cache')->clear('module_'.MOD_DIR.'_from_'.$this->form['table'].'_show_id_'.$t['id']);
// 统计数量
\Phpcmf\Service::M('mform', 'mform')->update_form_total($t['cid'], $this->form['table']);
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $t['cid']);
if ($table != $this->init['table']) {
// 备用表
\Phpcmf\Service::M()->table($table)->delete($t['id']);
}
}
},
\Phpcmf\Service::M()->dbprefix($this->init['table'])
);
}
// ===========================
/**
* 获取内容
* $id 内容id,新增为0
* */
protected function _Data($id = 0) {
$row = $this->content_model->get_form_row($id, $this->form['table']);
if (!$row) {
return [];
}
return $row;
}
// 格式化保存数据 保存之前
protected function _Format_Data($id, $data, $old) {
if (!$this->cid) {
$this->_json(0, dr_lang('所属主题cid参数不能为空'));
}
// 默认数据
$data[0]['uid'] = (int)$data[1]['uid'];
$data[1]['cid'] = $data[0]['cid'] = $this->cid;
$data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
if (!$id) {
// 发布时
if ($this->uid) {
/*
// 判断日发布量
$day_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'day_post', $this->member);
if ($day_post && \Phpcmf\Service::M()->db
->table($this->init['table'])
->where('uid', $this->uid)
->where('DATEDIFF(from_unixtime(inputtime),now())=0')
->countAllResults() >= $day_post) {
$this->_json(0, dr_lang('每天发布数量不能超过%s个', $day_post));
}
// 判断发布总量
$total_post = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'total_post', $this->member);
if ($total_post && \Phpcmf\Service::M()->db
->table($this->init['table'])
->where('uid', $this->uid)
->countAllResults() >= $total_post) {
$this->_json(0, dr_lang('发布数量不能超过%s个', $total_post));
}
*/
}
// 审核状态
$data[1]['status'] = $this->form['setting']['is_verify'] ? 1 : 0;
// 默认数据
$data[0]['uid'] = $data[1]['uid'] = (int)$this->member['uid'];
//$data[1]['author'] = $this->member['username'] ? $this->member['username'] : 'guest';
$data[1]['cid'] = $data[0]['cid'] = $this->cid;
$data[1]['catid'] = $data[0]['catid'] = (int)$this->index['catid'];
$data[1]['inputip'] = \Phpcmf\Service::L('input')->ip_info();
$data[1]['inputtime'] = SYS_TIME;
$data[1]['tableid'] = $data[1]['displayorder'] = 0;
} else {
// 修改时
// 审核状态
$data[1]['status'] = $this->form['setting']['is_verify'] ? 1 : 0;
}
return $data;
}
/**
* 保存内容
* $id 内容id,新增为0
* $data 提交内容数组,留空为自动获取
* $func 格式化提交的数据
* */
protected function _Save($id = 0, $data = [], $old = [], $func = null, $func2 = null) {
return parent::_Save($id, $data, $old, null,
function ($id, $data, $old) {
// 保存之后
$member = dr_member_info($data[1]['uid']);
//审核通知
if ($data[1]['status']) {
// 增减金币
/*
$score = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'score', $member);
$score && \Phpcmf\Service::M('member')->add_score($member['uid'], $score, dr_lang('%s[%s]: %s发布', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
// 增减经验
$exp = \Phpcmf\Service::M('member_auth')->mform_auth(MOD_DIR, $this->form['id'], 'exp', $member);
$exp && \Phpcmf\Service::M('member')->add_experience($member['uid'], $exp, dr_lang('%s[%s]: %s发布', MODULE_NAME, $this->index['title'], $this->form['name']), $this->index['curl']);
*/
$row = dr_array2array($data[1], $data[0]);
$row['muid'] = $row['uid'];
$row['form'] = $this->form;
$row['index'] = $this->index;
$row['module'] = $this->module;
\Phpcmf\Service::L('Notice')->send_notice('module_form_post_1', $row);
$row['uid'] = $this->index['uid'];
\Phpcmf\Service::L('Notice')->send_notice('module_form_post_2', $row);
} else {
\Phpcmf\Service::M('member')->admin_notice(SITE_ID, 'content', $member, dr_lang('%s[%s]: %s提交内容审核', MODULE_NAME, $this->index['title'], $this->form['name']), MOD_DIR.'/'.$this->form['table'].'_verify/edit:cid/'. $this->cid.'/id/'.$id);
}
$table = dr_mform_ctable(APP_DIR, $this->form['table'], $this->index['id']);
if ($table != $this->init['table']) {
// 备用表
\Phpcmf\Service::M()->table($table)->replace($data[1]);
}
//更新total字段
\Phpcmf\Service::M('mform', 'mform')->update_form_total( $this->cid, $this->form['table']);
$row = dr_array2array($data[1], $data[0]);
$row['index'] = $this->index;
if (!$old) {
// 挂钩点
\Phpcmf\Hooks::trigger('module_form_post_after', $row);
} else {
\Phpcmf\Hooks::trigger('module_form_edit_after', $row, $old);
}
}
);
}
/**
* 回调处理结果
* $data
* */
protected function _Call_Post($data) {
$data['url'] = $this->form['setting']['rt_url'] ? str_replace(['{id}', '{cid}'], [$data[1]['id'], $data[1]['cid']], $this->form['setting']['rt_url']) : '';
if ($data[1]['status']) {
return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text'] ? $this->form['setting']['rt_text'] : '操作成功'), $data);
} else {
return dr_return_data($data[1]['id'], dr_lang($this->form['setting']['rt_text2'] ? $this->form['setting']['rt_text2'] : '操作成功,等待管理员审核'), $data);
}
}
}
@@ -0,0 +1,280 @@
<?php namespace Phpcmf\Controllers\Admin;
/**
* http://www.xunruicms.com
* 本文件是框架系统文件,二次开发时不可以修改本文件
**/
class Module extends \Phpcmf\Common
{
private $dir;
private $form;
public function __construct() {
parent::__construct();
$this->dir = dr_safe_replace(\Phpcmf\Service::L('input')->get('dir'));
$menu = [
'内容模块' => ['module/module/index', 'fa fa-cogs'],
'模块表单' => ['mform/module/index', 'fa fa-cogs'],
];
$menu['表单配置'] = ['hide:mform/module/form_edit', 'fa fa-cog'];
$menu['重建表单'] = ['ajax:mform/module/form_init_index', 'fa fa-refresh'];
$menu['help'] = [98];
\Phpcmf\Service::V()->assign('menu', \Phpcmf\Service::M('auth')->_admin_menu($menu));
// 表单验证配置
$this->form = [
'name' => [
'name' => '表单名称',
'rule' => [
'empty' => dr_lang('表单名称不能为空')
],
'filter' => [],
'length' => '200'
],
'table' => [
'name' => '表单别名',
'rule' => [
'empty' => dr_lang('表单别名不能为空'),
'table' => dr_lang('表单别名格式不正确'),
],
'filter' => [],
'length' => '200'
],
];
}
// 模块管理
public function index() {
$module = \Phpcmf\Service::L('cache')->get('module-'.SITE_ID.'-content');
if (!$module) {
$this->_admin_msg(0, dr_lang('未安装任何内容模块'));
}
\Phpcmf\Service::V()->assign([
'module' => $module,
]);
\Phpcmf\Service::V()->display('module.html');
}
// 隐藏或者启用
public function mhidden_edit() {
$id = (int)\Phpcmf\Service::L('input')->get('id');
$row = \Phpcmf\Service::M()->table('module_form')->get($id);
if (!$row) {
$this->_json(0, dr_lang('数据#%s不存在', $id));
}
$v = $row['disabled'] ? 0 : 1;
\Phpcmf\Service::M()->table('module_form')->update($id, ['disabled' => $v]);
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
$this->_json(1, dr_lang($v ? '模块表单已被禁用' : '模块表单已被启用'), ['value' => $v]);
}
// 创建模块表单
public function form_add() {
if (IS_AJAX_POST) {
$data = \Phpcmf\Service::L('input')->post('data');
if (!preg_match('/^[a-z]+[a-z0-9\_]+$/i', $data['table'])) {
$this->_json(0, dr_lang('表单别名不规范'));
} elseif (\Phpcmf\Service::M('app')->is_sys_dir($data['table'])) {
$this->_json(0, dr_lang('名称[%s]是系统保留名称,请重命名', $data['table']));
}
$this->_validation(0, $data);
\Phpcmf\Service::L('input')->system_log('创建模块['.$this->dir.']表单('.$data['name'].')');
$rt = \Phpcmf\Service::M('mform', 'mform')->create_form($this->dir, $data);
if ($rt['code']) {
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
$this->_json(1, dr_lang('操作成功,请刷新后台页面'));
} else {
$this->_json(0, $rt['msg']);
}
}
\Phpcmf\Service::V()->assign([
'form' => dr_form_hidden()
]);
\Phpcmf\Service::V()->display('module_form_add.html');
exit;
}
// 修改模块表单
public function form_edit() {
$id = intval(\Phpcmf\Service::L('input')->get('id'));
$data = \Phpcmf\Service::M()->table('module_form')->get($id);
if (!$data) {
$this->_admin_msg(0, dr_lang('模块表单(%s)不存在', $id));
}
$data['setting'] = dr_string2array($data['setting']);
!$data['setting']['list_field'] && $data['setting']['list_field'] = [
'title' => [
'use' => 1,
'name' => dr_lang('主题'),
'func' => 'title',
'width' => 0,
'order' => 1,
],
'uid' => [
'use' => 1,
'name' => dr_lang('账号'),
'func' => 'uid',
'width' => 100,
'order' => 2,
],
'inputtime' => [
'use' => 1,
'name' => dr_lang('录入时间'),
'func' => 'datetime',
'width' => 160,
'order' => 3,
],
];
if (IS_AJAX_POST) {
$data = \Phpcmf\Service::L('input')->post('data');
if ($data['setting']['list_field']) {
foreach ($data['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 ($data['setting']['order']) {
if (strpos($data['setting']['order'], '(') or strpos($data['setting']['order'], ')')) {
$this->_json(0, dr_lang('后台列表的默认排序字段不允许特殊符号'));
}
}
\Phpcmf\Service::M()->table('module_form')->update($id,
[
'name' => $data['name'],
'setting' => dr_array2string($data['setting'])
]
);
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
\Phpcmf\Service::L('input')->system_log('修改模块['.$this->dir.']表单('.$data['name'].')配置');
$this->_json(1, dr_lang('操作成功'));
}
// 主表字段
$field = \Phpcmf\Service::M()->db->table('field')
->where('disabled', 0)
->where('ismain', 1)
->where('relatedname', 'mform-'.$this->dir)
->where('relatedid', $id)
->orderBy('displayorder ASC,id ASC')
->get()->getResultArray();
$sys_field = \Phpcmf\Service::L('Field')->sys_field(['id', 'uid', 'inputtime', 'inputip', 'displayorder']);
// 关联信息
$field['cid'] = [
'name' => dr_lang('关联'),
'ismain' => 1,
'ismember' => 1,
'fieldtype' => 'Cid',
'fieldname' => 'cid',
'setting' => []
];
if (!$data['setting']['list_field']['cid']['func']) {
$data['setting']['list_field']['cid']['func'] = 'ctitle';
}
$page = intval(\Phpcmf\Service::L('input')->get('page'));
\Phpcmf\Service::V()->assign([
'data' => $data,
'page' => $page,
'form' => dr_form_hidden(['page' => $page]),
'field' => dr_list_field_value($data['setting']['list_field'], $sys_field, $field),
'diy_tpl' => is_file(dr_get_app_dir($this->dir).'Views/diy_'.$data['table'].'.html') ? dr_get_app_dir($this->dir).'Views/diy_'.$data['table'].'.html' : '',
]);
\Phpcmf\Service::V()->display('module_form_edit.html');
}
// 删除表单
public function del() {
$id = (int)\Phpcmf\Service::L('input')->get('id');
if (!$id) {
$this->_json(0, dr_lang('你还没有选择呢'));
}
$rt = \Phpcmf\Service::M('mform', 'mform')->delete_form([$id]);
if (!$rt['code']) {
$this->_json(0, $rt['msg']);
}
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
\Phpcmf\Service::L('input')->system_log('删除模块表单: '. $id);
$this->_json(1, dr_lang('操作成功'));
}
// 验证数据
private function _validation($id, $data) {
list($data, $return) = \Phpcmf\Service::L('Form')->validation($data, $this->form);
if ($return) {
$this->_json(0, $return['error'], ['field' => $return['name']]);
}
if (\Phpcmf\Service::M()->table('module_form')->where('module', $this->dir)->is_exists($id, 'table', $data['table'])) {
$this->_json(0, dr_lang('数据表名称已经存在'), ['field' => 'table']);
}
}
// 表单初始化
public function form_init_index() {
$data = \Phpcmf\Service::M()->table('module_form')->getAll();
if (!$data) {
$this->_json(0, dr_lang('没有任何可用表单'));
}
$ct = $file = 0;
foreach ($data as $t) {
$par = \Phpcmf\Service::M()->dbprefix(dr_module_table_prefix($t['module'], SITE_ID)); // 父级表
if (!\Phpcmf\Service::M()->is_table_exists($par)) {
continue; // 当前站点没有安装
}
$rt = \Phpcmf\Service::M('mform', 'mform')->create_form_file($t['module'], $t['table'], 1);
if (!$rt['code']) {
$this->_json(0, $rt['msg']);
}
$file+= (int)$rt['msg'];
$ct++;
// 创建统计字段
$fname = $t['table']."_total";
if (!\Phpcmf\Service::M()->is_field_exists($par, $fname)) {
\Phpcmf\Service::M('table')->add_field(
$par,
$fname,
'INT(10) UNSIGNED',
'NULL DEFAULT \'0\'',
'表单'.$t['name'].'统计'
);
}
}
\Phpcmf\Service::M('cache')->sync_cache(''); // 自动更新缓存
$this->_json(1, dr_lang('本站点共(%s)个表单,重建(%s)个文件', $ct, $file));
}
}
+588
View File
@@ -0,0 +1,588 @@
<?php namespace Phpcmf\Model\Mform;
// 模型类
class Mform extends \Phpcmf\Model
{
// 创建
public function create_module_form($data) {
$data['name'] = dr_safe_filename($data['name']);
// 为全部站点模块创建表单
foreach (\Phpcmf\Service::C()->site_info as $sid => $v) {
$par = $this->dbprefix(dr_module_table_prefix($data['module'], $sid)); // 父级表
$pre = $par.'_form_'.$data['table']; // 当前表
// 判断模块是否安装过
if (!$this->is_table_exists($par)) {
continue;
}
\Phpcmf\Service::M('table')->create_table(
$pre,
[
'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
'cid' => 'int(10) unsigned NOT NULL COMMENT \'内容id\'',
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者id\'',
'author' => 'varchar(50) NOT NULL COMMENT \'作者名称\'',
'inputip' => 'varchar(200) DEFAULT NULL COMMENT \'录入者ip\'',
'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'录入时间\'',
'title' => 'varchar(255) DEFAULT NULL COMMENT \'表单主题\'',
'status' => 'tinyint(1) DEFAULT NULL COMMENT \'状态值\'',
'tableid' => 'smallint(5) unsigned NOT NULL COMMENT \'附表id\'',
'displayorder' => 'int(10) DEFAULT NULL COMMENT \'排序值\'',
],
[
'PRIMARY KEY (`id`)',
'KEY `cid` (`cid`)',
'KEY `uid` (`uid`)',
'KEY `catid` (`catid`)',
'KEY `author` (`author`)',
'KEY `status` (`status`)',
'KEY `displayorder` (`displayorder`)',
'KEY `inputtime` (`inputtime`)',
],
'模块表单'.$data['name'].'表'
);
\Phpcmf\Service::M('table')->create_table(
$pre.'_data_0',
[
'id' => 'int(10) unsigned NOT NULL',
'cid' => 'int(10) unsigned NOT NULL COMMENT \'内容id\'',
'catid' => 'mediumint(8) unsigned NOT NULL COMMENT \'栏目id\'',
'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'作者id\'',
],
[
'UNIQUE KEY `id` (`id`)',
'KEY `cid` (`cid`)',
'KEY `catid` (`catid`)',
'KEY `uid` (`uid`)',
],
'模块表单'.$data['name'].'附表'
);
// 加上统计字段
if ($this->is_field_exists($par, $data['table']."_total")) {
continue;
}
\Phpcmf\Service::M('table')->add_field(
$par,
$data['table'].'_total',
'INT(10) UNSIGNED',
'NULL DEFAULT \'0\'',
'表单'.$data['name'].'统计'
);
}
// 删除原有的冗余字段
$this->db->table('field')->where('relatedid', $data['id'])->where('relatedname', 'mform-'.$data['module'])->delete();
// 默认字段
$this->db->table('field')->insert(array(
'name' => '主题',
'fieldname' => 'title',
'fieldtype' => 'Text',
'relatedid' => $data['id'],
'relatedname' => 'mform-'.$data['module'],
'isedit' => 1,
'ismain' => 1,
'ismember' => 1,
'issystem' => 1,
'issearch' => 1,
'disabled' => 0,
'setting' => dr_array2string(array(
'option' => array(
'width' => 300, // 表单宽度
'fieldtype' => 'VARCHAR', // 字段类型
'fieldlength' => '255' // 字段长度
),
'validate' => array(
'xss' => 1, // xss过滤
'required' => 1, // 表示必填
)
)),
'displayorder' => 0,
));
$this->db->table('field')->insert(array(
'name' => '作者',
'fieldname' => 'author',
'fieldtype' => 'Text',
'relatedid' => $data['id'],
'relatedname' => 'mform-'.$data['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' // 字段长度
),
'validate' => array(
'xss' => 1, // xss过滤
)
)),
'displayorder' => 0,
));
}
// 删除模块表单
public function delete_module_form($data) {
$id = intval($data['id']);
$table = $this->dbprefix(dr_module_table_prefix($data['module']).'_form_'.$data['table']);
// 判断模块是否存在表
if (!$this->is_table_exists($table)) {
return;
}
// 删除字段
$this->db->table('field')->where('relatedid', $id)->where('relatedname', 'mform-'.$data['module'])->delete();
// 删除表
\Phpcmf\Service::M('table')->drop_table($table, true);
// 删除附表
for ($i = 0; $i < 200; $i ++) {
if (!$this->is_table_exists($table.'_data_'.$i)) {
break;
}
\Phpcmf\Service::M('table')->drop_table($table.'_data_'.$i, true);
}
// 模块表统计字段删除
$par = $this->dbprefix(dr_module_table_prefix($data['module']));
// 判断模块是否存在表
if (!$this->is_table_exists($par)) {
return;
}
if ($this->is_field_exists($par, $data['table']."_total")) {
\Phpcmf\Service::M('table')->drop_field($par, $data['table'].'_total');
}
// 挂钩点
\Phpcmf\Hooks::trigger('module_form_uninstall_after', $data);
}
// 创建表单文件
public function create_form_file($dir, $table, $call = 0) {
$dir = ucfirst($dir);
$path = dr_get_app_dir($dir);
if (!is_dir($path)) {
return dr_return_data(1, 'ok');
}
$name = ucfirst($table);
$temp = dr_get_app_dir('mform').'Code/';
$files = [
$path.'Controllers/'.$name.'.php' => $temp.'$NAME$.php',
$path.'Controllers/Member/'.$name.'.php' => $temp.'Member$NAME$.php',
$path.'Controllers/Admin/'.$name.'.php' => $temp.'Admin$NAME$.php',
$path.'Controllers/Admin/'.$name.'_verify.php' => $temp.'Admin$NAME$_verify.php',
];
$ok = 0;
foreach ($files as $file => $form) {
if (!is_file($file)) {
$c = file_get_contents($form);
$size = file_put_contents($file, str_replace('$NAME$', $name, $c));
if (!$size && $call) {
unlink($file);
return dr_return_data(0, dr_lang('文件%s创建失败,无可写权限', str_replace(FCPATH, '', $file)));
}
$ok ++;
}
}
return dr_return_data(1, $ok);
}
// 创建模块表单
public function create_form($dir, $data) {
// 插入表单数据
$data['table'] = strtolower($data['table']);
$rt = $this->table('module_form')->insert([
'name' => $data['name'],
'table' => $data['table'],
'module' => $dir,
'setting' => '',
'disabled' => 0,
]);
if (!$rt['code']) {
return $rt;
}
$id = $data['id'] = $rt['code'];
$data['module'] = $dir;
// 创建文件
$rt = $this->create_form_file($dir, $data['table']);
if (!$rt['code']) {
$this->table('module_form')->delete($id);
return $rt;
}
// 创建表
$this->create_module_form($data);
return dr_return_data(1, 'ok');
}
// 删除模块表单
public function delete_form($ids) {
foreach ($ids as $id) {
$row = $this->table('module_form')->get(intval($id));
if (!$row) {
return dr_return_data(0, dr_lang('模块表单不存在(id:%s)', $id));
}
$rt = $this->table('module_form')->delete($id);
if (!$rt['code']) {
return dr_return_data(0, $rt['msg']);
}
$name = ucfirst($row['table']);
$path = dr_get_app_dir($row['module']);
unlink($path.'Controllers/'.$name.'.php');
unlink($path.'Controllers/Admin/'.$name.'.php');
unlink($path.'Controllers/Member/'.$name.'.php');
unlink($path.'Controllers/Admin/'.$name.'_verify.php');
// 删除表数据
$this->delete_module_form($row);
}
return dr_return_data(1, '');
}
public function link_menu($form, $table, $mdir, $config, $left) {
// 表单入库
if ($form) {
foreach ($form as $t) {
$mark = 'app-mform-verify-'.$mdir.'-'.$t['table'];
$menu = $this->db->table($table.'_menu')->where('mark', $mark)->get()->getRowArray();
$save = [
'uri' => $mdir.'/'.$t['table'].'_verify/index',
'mark' => $mark,
'name' => $menu && $menu['name'] ? $menu['name'] : dr_lang('%s%s', $config['name'], $t['name']),
'icon' => $menu && $menu['icon'] ? $menu['icon'] : dr_icon($t['setting']['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);
}
}
}
public function link_delete($module, $dir) {
$this->db->table('field')->where('relatedid', $module['id'])->where('relatedname', 'mform-'.$dir)->delete();
$this->db->table('admin_menu')->like('mark', 'app-mform-verify-'.$dir)->delete();
$this->db->table('module_form')->where('module', $dir)->delete();
}
public function link_uninstall($table, $dir) {
// 删除表单
$form = $this->db->table('module_form')->where('module', $dir)->get()->getResultArray();
if ($form) {
foreach ($form as $t) {
$mytable = $table.'_form_'.$t['table'];
// 主表
\Phpcmf\Service::M('table')->drop_table($mytable, true);
// 附表
for ($i = 0; $i < 200; $i ++) {
if (!$this->is_table_exists($mytable.'_data_'.$i)) {
break;
}
\Phpcmf\Service::M('table')->drop_table($mytable.'_data_'.$i, true);
}
}
}
}
private function _link_install($module, $mpath, $dir, $table) {
if (is_file($mpath.'Config/Form.php')) {
$form = require $mpath.'Config/Form.php';
if ($form) {
foreach ($form as $ftable => $t) {
// 插入表单数据
$rt = $this->table('module_form')->insert([
'name' => $t['form']['name'],
'table' => $ftable,
'module' => $dir,
'setting' => $t['form']['setting'],
'disabled' => 0,
]);
if ($rt['code']) {
// 建表(Schema → create_table;旧版 CREATE SQL → formatCreateSql
foreach ([1 => $table.'_form_'.$ftable, 0 => $table.'_form_'.$ftable.'_data_0'] as $ti => $tablename) {
$def = $t['table'][$ti] ?? '';
if (is_array($def) && isset($def['fields'])) {
\Phpcmf\Service::M('table')->create_table(
$tablename,
$def['fields'],
$def['indexes'] ?? [],
$def['comment'] ?? ''
);
} elseif ($def) {
$this->db->simpleQuery(str_replace('{tablename}', $tablename, dr_format_create_sql((string) $def)));
}
}
// 插入自定义字段
foreach ([1, 0] as $is_main) {
$f = $t['field'][$is_main];
if ($f) {
foreach ($f as $field) {
\Phpcmf\Service::M('module')->_add_field($field, $is_main, $rt['code'], 'mform-'.$dir);
}
}
}
}
}
}
}
}
public function link_install($module, $mpath, $dir, $table) {
// 创建表单
if (dr_count($module['site']) == 1) {
// 表示第一个站就创建表单
$this->_link_install($module, $mpath, $dir, $table);
} else {
// 创建模块已经存在的表单
$form = $this->db->table('module_form')->where('module', $dir)->get()->getResultArray();
if ($form) {
$this->db->resetDataCache();// 清除缓存,影响字段存在的重复
foreach ($form as $t) {
// 表示存在多个站
$sid = 0;
foreach ($module['site'] as $site => $tt) {
if ($this->is_table_exists($this->dbprefix($site.'_'.$dir).'_form_'.$t['table'])) {
// 表示已经在其他站创建过了,我们就复制它以前创建的表结构
$sid = $site;
break;
}
}
if ($sid) {
// 开始创建表单
$mytable = $table.'_form_'.$t['table'];
$cptable = $this->dbprefix($sid.'_'.$dir).'_form_'.$t['table'];
// 主表
list($sql) = \Phpcmf\Service::M('table')->create_table_sql($cptable);
$sql = str_replace($cptable, $mytable, $sql);
$this->db->simpleQuery(dr_format_create_sql($sql));
// 附表
list($sql) = \Phpcmf\Service::M('table')->create_table_sql($cptable.'_data_0');
$sql = str_replace($cptable.'_data_0', $mytable.'_data_0', $sql);
$this->db->simpleQuery(dr_format_create_sql($sql));
} else {
// 没有表就删除表单
//log_message('error', '没有表就删除表单');
$this->db->table('module_form')->where('id', $t['id'])->delete();
}
}
} else {
$this->_link_install($module, $mpath, $dir, $table);
}
}
}
// 缓存
public function link_cache($mdir, $cache) {
$form = $this->table('module_form')->where('module', $mdir)->where('disabled', 0)->order_by('id ASC')->getAll();
if ($form) {
foreach ($form as $t) {
$t['field'] = [];
// 模块表单的自定义字段
if (!$this->table('field')
->where('relatedname', 'mform-'.$mdir)
->where('relatedid', intval($t['id']))
->where('fieldname', 'author')->counts()) {
$this->db->table('field')->insert(array(
'name' => '作者',
'fieldname' => 'author',
'fieldtype' => 'Text',
'relatedid' => $t['id'],
'relatedname' => 'mform-'.$mdir,
'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' // 字段长度
),
'validate' => array(
'xss' => 1, // xss过滤
)
)),
'displayorder' => 0,
));
}
$field = $this->db->table('field')->where('disabled', 0)->where('relatedid', intval($t['id']))->where('relatedname', 'mform-'.$mdir)->orderBy('displayorder ASC, id ASC')->get()->getResultArray();
if ($field) {
foreach ($field as $f) {
$f['setting'] = dr_string2array($f['setting']);
$t['field'][$f['fieldname']] = $f;
}
}
$t['setting'] = dr_string2array($t['setting']);
// 排列table字段顺序
$t['setting']['list_field'] = dr_list_field_order($t['setting']['list_field']);
$cache['form'][$t['table']] = $t;
}
}
return $cache;
}
// 保存数据
public function save_content($mid, $tid, $index, $data, $data2 = []) {
$data['status'] = isset($data['status']) ? intval($data['status']) : 1;
$data['uid'] = isset($data['uid']) ? intval($data['uid']) : (int)$this->member['uid'];
$data['author'] = isset($data['author']) ? trim($data['author']) : $this->member['username'];
$data['inputip'] = isset($data['inputip']) ? $data['inputip'] : \Phpcmf\Service::L('input')->ip_info();
$data['inputtime'] = isset($data['inputtime']) ? $data['inputtime'] : SYS_TIME;
$data['tableid'] = 0;
$data['displayorder'] = isset($data['displayorder']) ? $data['displayorder'] : 0;
$data['cid'] = intval($index['id']); // 内容id
$data['catid'] = intval($index['catid']); // 栏目id
// 插入主表
$table = $mid.'_form_'.$tid;
$rt = $this->table_site($table)->insert($data);
if (!$rt['code']) {
return $rt;
}
$etable = dr_mform_ctable($mid, $tid, $data['cid'], 0);
if ($table != $etable) {
// 备用表
$this->table_site($etable)->replace($data);
}
$data['id'] = $rt['code'];
if ($data2) {
// 如果要使用附表分表就 按一定量进行分表设置 比如50000
$data['tableid'] = \Phpcmf\Service::M()->get_table_id($rt['code']);
if ($data['tableid'] > 0) {
// 判断附表是否存在,不存在则创建
$this->is_data_table(SITE_ID.'_'.$mid.'_form_'.$tid.'_data_', $data['tableid']);
// 更新tableid到主表
$this->table_site($mid.'_form_'.$tid)->update($data['id'], ['tableid' => $data['tableid']]);
if ($table != $etable) {
// 备用表
$this->table_site($etable)->update($data['id'], ['tableid' => $data['tableid']]);
}
}
$data2['id'] = $data['id'];
$data2['uid'] = $data['uid'];
$data2['cid'] = $data['cid']; // 内容id
$data2['catid'] = $data['catid']; // 栏目id
// 插入附表
$rt2 = $this->table_site($mid.'_form_'.$tid.'_data_'.$data['tableid'])->insert($data2);
if (!$rt2['code']) {
// 删除主表
$this->table_site($mid.'_form_'.$tid)->delete($data['id']);
if ($table != $etable) {
// 备用表
$this->table_site($etable)->delete($data['id']);
}
return $rt2;
}
}
if ($table != $etable) {
// 备用表
$total = $this->table_site($etable)->where('status', 1)->where('cid', $data['cid'])->counts();
} else {
$total = $this->table_site($mid.'_form_'.$tid)->where('status', 1)->where('cid', $data['cid'])->counts();
}
$this->table_site($mid)->update($data['cid'], [
$tid.'_total' => $total,
]);
return $rt;
}
// 模块表单内容地址
public function show_url($form, $id, $mid = '', $page = 0) {
// 模块目录识别
defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
$mid && $dir = $mid;
$module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dir);
return \Phpcmf\Service::L('router')->url_prefix('php', $module, [], SITE_FID) . 'c=' . $form . '&m=show&id=' . $id . ($page > 1 || strlen($page) > 1 ? '&page=' . $page : '');
}
// 模块表单提交地址
public function post_url($form, $cid, $mid = '') {
// 模块目录识别
defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
$mid && $dir = $mid;
$module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dir);
return \Phpcmf\Service::L('router')->url_prefix('php', $module, [], SITE_FID) . 'c=' . $form . '&m=post&cid=' . $cid;
}
// 模块表单列表地址
public function list_url($form, $cid, $mid = '', $page = 0) {
// 模块目录识别
defined('MOD_DIR') && MOD_DIR && $dir = MOD_DIR;
$mid && $dir = $mid;
$module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dir);
return \Phpcmf\Service::L('router')->url_prefix('php', $module, [], SITE_FID) . 'c=' . $form . '&m=index&cid=' . $cid . ($page > 1 || strlen($page) > 1 ? '&page=' . $page : '');
}
/**
* 删除模块内容时的联动
*/
public function delete_content($id, $siteid, $dirname) {
if (!$id) {
return;
}
$module = \Phpcmf\Service::L('cache')->get('module-' . SITE_ID . '-' . $dirname);
if ($module['form']) {
foreach ($module['form'] as $m) {
$table = $this->dbprefix(dr_module_table_prefix($dirname).'_form_'.$m['table']);
// 判断模块是否存在表
if ($this->is_table_exists($table)) {
$this->db->table($table)->where('cid', $id)->delete();
$this->db->table($table.'_data_0')->where('cid', $id)->delete();
}
}
}
}
// 更新统计字段
public function update_form_total($cid, $form) {
$total = $this->table(dr_mform_ctable(APP_DIR, $form, $cid))
->where('status', 1)
->where('cid', $cid)
->counts();
$this->table(dr_module_table_prefix(APP_DIR))->update($cid, [
$form.'_total' => $total,
]);
}
}
+52
View File
@@ -0,0 +1,52 @@
{template "header.html"}
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
<div class="table-scrollable">
<table class="table table-striped table-bordered table-hover table-checkable dataTable">
<thead>
<tr class="heading">
<th width="80"> </th>
<th width="300"> {dr_lang('名称')} / {dr_lang('表名')}</th>
<th> {dr_lang('操作')} </th>
</tr>
</thead>
<tbody>
{loop $module $i $t}
<tr class="odd gradeX">
<td> - </td>
<td><i class="{$t.icon}"></i> {$t.name} / {$t.dirname}</td>
<td>
<label><a href="javascript:dr_iframe('{dr_lang('创建表单')}', '{dr_url('mform/module/form_add', ['dir'=>$t.dirname])}');" class="btn btn-sm green"> <i class="fa fa-plus"></i> {dr_lang('创建表单')} </a></label>
</td>
</tr>
{php $form = \Phpcmf\Service::M()->table('module_form')->where('module', $t.dirname)->getAll();}
{loop $form $t}
<tr class="odd gradeX" id="dr_row_{$t.id}">
<td style="text-align:center">
<a href="javascript:;" onclick="dr_ajax_open_close(this, '{dr_url('mform/module/mhidden_edit', ['id'=>$t.id])}', 1);" class="badge badge-{if $t.disabled}no{else}yes{/if}"><i class="fa fa-{if $t.disabled}times{else}check{/if}"></i></a>
</td>
<td>&nbsp;&nbsp;&nbsp;{$t.name} / {$t.table}</td>
<td>
<label><a href="javascript:top.dr_iframe_show('{dr_lang('已审核内容')}','{dr_url($t['module'].'/'.$t['table'].'/index')}&is_menu=1', '80%', '90%');" class="btn btn-xs blue"> <i class="fa fa-table"></i> {dr_lang('已审核内容')} </a></label>
<label><a href="javascript:top.dr_iframe_show('{dr_lang('待审核内容')}','{dr_url($t['module'].'/'.$t['table'].'_verify/index')}&is_menu=1', '80%', '90%');" class="btn btn-xs red"> <i class="fa fa-edit"></i> {dr_lang('待审核内容')} </a></label>
{if $ci->_is_admin_auth('edit')}
<label><a href="{dr_url('mform/module/form_edit', ['dir'=>$t.module, 'id'=>$t.id])}" class="btn btn-xs green"> <i class="fa fa-edit"></i> {dr_lang('修改')} </a></label>
{/if}
{if $ci->_is_admin_auth()}
<label><a href="javascript:top.dr_iframe_show('{dr_lang('自定义字段')}','{dr_url('field/index', ['rname'=>'mform-'.$t['module'], 'rid'=>$t.id])}&is_menu=1', '80%', '90%');" class="btn btn-xs dark"> <i class="fa fa-code"></i> {dr_lang('自定义字段')} </a></label>
{/if}
{if $ci->_is_admin_auth('del')}
<label><a href="javascript:dr_load_ajax('{dr_lang('确定将此模块从当前站点中删除吗?')}', '{dr_url('mform/module/del', ['id'=>$t.id])}', 1);" class="btn btn-xs red"> <i class="fa fa-trash"></i> {dr_lang('删除')} </a></label>
{/if}
</td>
</tr>
{/loop}
{/loop}
</tbody>
</table>
</div>
</form>
{template "footer.html"}
+75
View File
@@ -0,0 +1,75 @@
{template "header.html"}
<div class="note note-danger">
<p>{dr_lang('模块表单是对模块内容的扩展,相当于模块的子内容')}</p>
</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 width="50" style="text-align:center"> {dr_lang('可用')} </th>
<th width="150"> {dr_lang('名称')} </th>
<th width="160"> {dr_lang('表单别名')} </th>
<th> </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">
<a href="javascript:;" onclick="dr_ajax_open_close(this, '{dr_url('module/mhidden_edit', ['id'=>$t.id])}', 1);" class="badge badge-{if $t.disabled}no{else}yes{/if}"><i class="fa fa-{if $t.disabled}times{else}check{/if}"></i></a>
</td>
<td>{$t.name}</td>
<td>{$t.table}</td>
<td>
{if $ci->_is_admin_auth('edit')}
<label><a href="{dr_url('module/form_edit', ['dir'=>$t.module, 'id'=>$t.id])}" class="btn btn-xs green"> <i class="fa fa-edit"></i> {dr_lang('修改')} </a></label>
{/if}
{if $ci->_is_admin_auth()}
<label><a href="{dr_url('field/index', ['rname'=>'mform-'.$t['module'], 'rid'=>$t.id])}" class="btn btn-xs dark"> <i class="fa fa-code"></i> {dr_lang('自定义字段')} </a></label>
{/if}
</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('module/form_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>
</div>
{template "footer.html"}
@@ -0,0 +1,31 @@
{template "header.html"}
<script type="text/javascript">
$(function() { //防止回车提交表单
document.onkeydown = function(e){
var ev = document.all ? window.event : e;
if (ev.keyCode==13) {
return false;
}
}
});
</script>
<form class="form-horizontal" role="form" id="myform">
{$form}
<div class="form-body">
<div class="form-group" id="dr_row_name">
<label class="col-xs-3 control-label ajax_name">{dr_lang('表单名称')}</label>
<div class="col-xs-8">
<input type="text" onblur="d_topinyin('table', 'name')" class="form-control" id="dr_name" name="data[name]" value="{$data.name}">
<span class="help-block"> {dr_lang('表单的描述名称')} </span>
</div>
</div>
<div class="form-group" id="dr_row_table">
<label class="col-xs-3 control-label ajax_name">{dr_lang('表单别名')}</label>
<div class="col-xs-8">
<input type="text" class="form-control" id="dr_table" name="data[table]" value="{$data.table}">
<span class="help-block"> {dr_lang('表单别名只能由字母或者字母+数字组成')} </span>
</div>
</div>
</div>
</form>
{template "footer.html"}
@@ -0,0 +1,294 @@
{template "header.html"}
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
{$form}
<div class="portlet bordered light myfbody">
<div class="portlet-title tabbable-line">
<ul class="nav nav-tabs" style="float:left;">
<li class="{if $page==0}active{/if}">
<a href="#tab_0" data-toggle="tab" onclick="$('#dr_page').val('0')"> <i class="fa fa-cog"></i> {dr_lang('基本设置')} </a>
</li>
{if $diy_tpl}
<li class=" {if $page==3}active{/if}">
<a href="#tab_3" data-toggle="tab" onclick="$('#dr_page').val('3')"> <i class="fa fa-cog"></i> {dr_lang('自定义设置')} </a>
</li>
{/if}
<li class="{if $page==1}active{/if}">
<a href="#tab_1" data-toggle="tab" onclick="$('#dr_page').val('1')"> <i class="fa fa-table"></i> {dr_lang('后台显示设置')} </a>
</li>
<li class="{if $page==2}active{/if}">
<a href="#tab_2" data-toggle="tab" onclick="$('#dr_page').val('2')"> <i class="fa fa-user"></i> {dr_lang('用户中心')} </a>
</li>
<li class="{if $page==5}active{/if}">
<a href="#tab_5" data-toggle="tab" onclick="$('#dr_page').val('5')"> <i class="fa fa-internet-explorer"></i> {dr_lang('前端SEO设置')} </a>
</li>
</ul>
</div>
<div class="portlet-body">
<div class="tab-content">
<div class="tab-pane {if $page==5}active{/if}" id="tab_5">
<div class="form-body">
<?php !$data['setting']['seo']['title'] && $data['setting']['seo']['title'] = '{title}{join}{formname}{join}{'.'SITE_NAME}';?>
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('内容SEO标题')}</label>
<div class="col-md-9">
<textarea class="form-control " style="height:90px" name="data[setting][seo][title]">{$data['setting']['seo']['title']}</textarea>
<span class="help-block">
<button class="btn btn-xs green" onclick="dr_seo_title_rule()" type="button"><i class="fa fa-code"></i> {dr_lang('可用通配符标签')}</button>
<script>
function dr_seo_title_rule() {
layer.alert('通用标签<br>'+
'{join} SEO连接符号,默认“_”<br>'+
'[{page}] 分页页码<br>'+
'{modulename} 模块名称<br>'+
'{formname} 表单名称<br>'+
'{catname} 当前栏目名称<br>'+
'{catpname} 当前栏目带层次的栏目名称<br>'+
'支持“网站表单表”任何字段,格式:{字段名},<br>如:{title}表示标题<br>'+
'支持网站系统常量,格式:{大写的常量名称},<br>如:{SITE_NAME}表示网站名称<br>'+
''+
'', {
shade: 0,
title: '',
btn: []
});
}
</script>
</span>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('内容SEO关键字')}</label>
<div class="col-md-9">
<textarea class="form-control " style="height:90px" name="data[setting][seo][keywords]">{$data['setting']['seo']['keywords']}</textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('内容SEO描述信息')}</label>
<div class="col-md-9">
<textarea class="form-control " style="height:90px" name="data[setting][seo][description]">{$data['setting']['seo']['description']}</textarea>
</div>
</div>
</div>
</div>
{if $diy_tpl}
<div class="tab-pane {if $page==3}active{/if}" id="tab_3">
<div class="form-body">
{load $diy_tpl}
</div>
</div>
{/if}
<div class="tab-pane {if $page==0}active{/if}" id="tab_0">
<div class="form-body">
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('表单别名')}</label>
<div class="col-md-9">
<div class="form-control-static"><label><span class="label label-success"> {$data.table} </span></label></div>
</div>
</div>
<div class="form-group" id="dr_row_name">
<label class="col-md-2 control-label ">{dr_lang('表单名称')}</label>
<div class="col-md-9">
<label><input type="text" class="form-control" id="dr_name" name="data[name]" value="{htmlspecialchars((string)$data.name)}"></label>
<span class="help-block"> {dr_lang('表单的描述名称')} </span>
</div>
</div>
<div class="form-group" id="dr_row_icon">
<label class="col-md-2 control-label ">{dr_lang('菜单图标')}</label>
<div class="col-md-9">
<div class="input-group" style="width:250px">
<input class="form-control" id="dr_icon" type="text" name="data[setting][icon]" value="{htmlspecialchars((string)$data['setting']['icon'])}" />
<span class="input-group-btn">
<a class="btn btn-success" href="{dr_url('api/icon')}" target="_blank"><i class="fa fa-arrow-right fa-fw" /></i> {dr_lang('查看')}</a>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('前端阅读权限')}</label>
<div class="col-md-9">
<div class="mt-radio-inline">
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_read]" value="0" {if !$data['setting']['is_read']}checked{/if} /> {dr_lang('全部开放')} <span></span></label>
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_read]" value="1" {if $data['setting']['is_read']}checked{/if} /> {dr_lang('仅自己和主题归属者')} <span></span></label>
</div>
<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">
<div class="mt-radio-inline">
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_close_post]" value="0" {if !$data['setting']['is_close_post']}checked{/if} /> {dr_lang('开启')} <span></span></label>
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_close_post]" value="1" {if $data['setting']['is_close_post']}checked{/if} /> {dr_lang('关闭')} <span></span></label>
</div>
<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">
<div class="mt-radio-inline">
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_post_code]" value="0" {if !$data['setting']['is_post_code']}checked{/if} /> {dr_lang('开启')} <span></span></label>
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_post_code]" value="1" {if $data['setting']['is_post_code']}checked{/if} /> {dr_lang('关闭')} <span></span></label>
</div>
<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">
<div class="mt-radio-inline">
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_verify]" value="0" {if !$data['setting']['is_verify']}checked{/if} /> {dr_lang('审核')} <span></span></label>
<label class="mt-radio mt-checkbox-outline"><input type="radio" name="data[setting][is_verify]" value="1" {if $data['setting']['is_verify']}checked{/if} /> {dr_lang('不审核')} <span></span></label>
</div>
<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="text" class="form-control input-xlarge" name="data[setting][rt_text]" value="{htmlspecialchars((string)$data['setting']['rt_text'])}" >
<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="text" class="form-control input-xlarge" name="data[setting][rt_text2]" value="{htmlspecialchars((string)$data['setting']['rt_text2'])}" >
<span class="help-block"> {dr_lang('当用户提交表单审核时显示的文字,默认为:操作成功,等待管理员审核')} </span>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('提交成功跳转URL')}</label>
<div class="col-md-9">
<input type="text" class="form-control input-xlarge" name="data[setting][rt_url]" value="{htmlspecialchars((string)$data['setting']['rt_url'])}" >
<span class="help-block"> {dr_lang('当用户提交表单成功之后跳转的链接,{cid}表示当前表单的归属内容的id号,{id}表示当前表单的id号')} </span>
</div>
</div>
</div>
</div>
<div class="tab-pane {if $page==1}active{/if}" id="tab_1">
<div class="form-body">
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('列表默认排序')}</label>
<div class="col-md-9">
<label><input class="form-control input-xlarge" type="text" name="data[setting][order]" value="{if $data['setting']['order']}{htmlspecialchars((string)$data['setting']['order'])}{else}inputtime DESC{/if}" ></label>
<span class="help-block">{dr_lang('排序格式符号MySQL的语法,例如:主表字段 desc')}</span>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('列表时间搜索')}</label>
<div class="col-md-9">
<label><input class="form-control" type="text" name="data[setting][search_time]" value="{if $data['setting']['search_time']}{htmlspecialchars((string)$data['setting']['search_time'])}{else}inputtime{/if}" ></label>
<span class="help-block">{dr_lang('设置后台时间范围搜索字段,默认为发布时间字段:inputtime')}</span>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('列表显示字段')}</label>
<div class="col-md-9">
<table class="table table-striped table-bordered table-hover table-checkable dataTable">
<thead>
<tr class="heading">
<th class="myselect">
{dr_lang('显示')}
</th>
<th width="180"> {dr_lang('字段')} </th>
<th width="100"> {dr_lang('类别')} </th>
<th width="150"> {dr_lang('名称')} </th>
<th width="100"> {dr_lang('宽度')} </th>
<th width="120"> {dr_lang('对其方式')} </th>
<th> {dr_lang('回调方法')} </th>
</tr>
</thead>
<tbody class="field-sort-items">
{loop $field $n $t}
<tr class="odd gradeX">
<td class="myselect">
<label class="mt-table mt-checkbox mt-checkbox-single mt-checkbox-outline">
<input type="checkbox" class="checkboxes" name="data[setting][list_field][{$t.fieldname}][use]" value="1" {if $data['setting']['list_field'][$t.fieldname]['use']} checked{/if} />
<span></span>
</label>
</td>
<td>{dr_lang($t.name)} ({$t.fieldname})</td>
<td>{$t.fieldtype}</td>
<td><input class="form-control" type="text" name="data[setting][list_field][{$t.fieldname}][name]" value="{php echo $data['setting']['list_field'][$t.fieldname]['name'] ? htmlspecialchars($data['setting']['list_field'][$t.fieldname]['name']) : $t.name}" /></td>
<td> <input class="form-control" type="text" name="data[setting][list_field][{$t.fieldname}][width]" value="{htmlspecialchars((string)$data['setting']['list_field'][$t.fieldname]['width'])}" /></td>
<td><input type="checkbox" name="data[setting][list_field][{$t.fieldname}][center]" {if $data['setting']['list_field'][$t.fieldname]['center']} checked{/if} 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">
</td>
<td> <div class="input-group" style="width:250px">
<span class="input-group-btn">
<a class="btn btn-success" href="javascript:dr_call_alert();">{dr_lang('回调')}</a>
</span>
<input class="form-control" type="text" name="data[setting][list_field][{$t.fieldname}][func]" value="{htmlspecialchars((string)$data['setting']['list_field'][$t.fieldname]['func'])}" />
</div></td>
</tr>
{/loop}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="tab-pane {if $page==2}active{/if}" id="tab_2">
<div class="form-body">
{if !IS_USE_MEMBER}
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('无法使用')}</label>
<div class="col-md-9">
<div class="form-control-static"><label><a class="label label-danger"> {dr_lang('本功能需要安装【用户系统】插件')} </a></label></div>
</div>
</div>
{else}
<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][is_member]" value="1" {if $data['setting']['is_member']}checked{/if} 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][is_member_user]" value="1" {if $data['setting']['is_member_user']}checked{/if} 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>
{/if}
</div>
</div>
</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()}&page='+$('#dr_page').val(), 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存')}</button>
</div>
</div>
</form>
<script type="text/javascript">
$(function () {
$(".field-sort-items").sortable();
});
</script>
{template "footer.html"}
@@ -0,0 +1,85 @@
{template "header.html"}
{template "api_list_date_search.html"}
{if $index}
<div class="finecms-top-name" style="padding-bottom: 20px">
<a href="{$index.url}" target="_blank"><code>{dr_strcut(dr_clearhtml($index.title), 50)}</code></a>
</div>
{/if}
<div class="note note-danger" {if !isset($get.submit) && !$is_show_search_bar}style="display: none"{/if} id="table-search-tool">
<div class="row table-search-tool">
<form action="{SELF}" method="get">
{dr_form_search_hidden($p)}
<div class="col-md-12 col-sm-12">
<label>
<select name="field" class="form-control">
<option value="id"> Id </option>
{loop $field $t}
{if dr_is_admin_search_field($t)}
<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">
<label>
<div class="input-group input-medium date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
<input type="text" class="form-control" value="{$param.date_form}" name="date_form">
<span class="input-group-addon"> {dr_lang('到')} </span>
<input type="text" class="form-control" value="{$param.date_to}" name="date_to">
</div>
</label>
</div>
<div class="col-md-12 col-sm-12">
<label><button id="table-search-tool-submit" type="button" class="btn blue btn-sm " name="submit" > <i class="fa fa-search"></i> {dr_lang('搜索')}</button></label>
<label><button id="table-search-tool-reset" type="reset" class="btn red btn-sm " name="reset" > <i class="fa fa-refresh"></i> {dr_lang('重置')}</button></label>
</div>
</form>
</div>
</div>
<div class="right-card-box">
<form class="form-horizontal" role="form" id="myform">
{dr_form_hidden()}
<div id="toolbar" class="toolbar">
{if $ci->_is_admin_auth('del')}
<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></label>
{/if}
{if $is_verify}
<label><button type="button" onclick="dr_ajax_option('{dr_url($uriprefix.'/status_index')}', '{dr_lang('你确定要审核通过它们吗?')}', 1)" class="btn blue btn-sm"> <i class="fa fa-check-square-o"></i> {dr_lang('通过')}</button></label>
<label><button type="button" onclick="dr_ajax_option('{dr_url($uriprefix.'/status_index', ['tid' => 1])}', '{dr_lang('你确定要拒绝它们吗?')}', 1)" class="btn yellow btn-sm"> <i class="fa fa-times-circle-o"></i> {dr_lang('拒绝')}</button></label>
{/if}
{if $cbottom}
<label>
<div class="btn-group dropup">
<a class="btn blue btn-sm dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true" aria-expanded="false" href="javascript:;"> {dr_lang('批量')}
<i class="fa fa-angle-up"></i>
</a>
<ul class="dropdown-menu">
{loop $cbottom $a}
<li>
<a href="{str_replace(['{mid}', '{fid}', '{cid}'], [APP_DIR, $form_table, $index.id], urldecode($a.url))}"> <i class="{$a.icon}"></i> {dr_lang($a.name)} </a>
</li>
{/loop}
</ul>
</div>
</label>
{/if}
<label class="table_select_all"></label>
</div>
{template "mytable.html"}
</form>
</div>
{template "footer.html"}
@@ -0,0 +1,99 @@
{template "header.html"}
<script>
{$auto_form_data_ajax}
</script>
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
{$form}
<div class="row myfbody {if $is_verify} fc-verify-post{/if}">
<div class="{if $is_mobile}col-md-12{else}col-md-9{/if}">
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption">
<span class="caption-subject font-green sbold ">{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">
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('关联')}</label>
<div class="col-md-9" style="padding-top: 7px;">
<code class="form-control-static"><a href="{$index.url}" target="_blank">{dr_clearhtml($index.title)}</a></code>
</div>
</div>
{$myfield}
</div>
</div>
</div>
{if $diyfield}
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption">
<span class="caption-subject font-green sbold ">{dr_lang('其他内容')}</span>
</div>
</div>
<div class="portlet-body">
<div class="form-body">
{$diyfield}
</div>
</div>
</div>
{/if}
</div>
<div class="{if $is_mobile}col-md-12{else}col-md-3{/if} my-sysfield">
<div class="portlet light bordered">
<div class="portlet-body">
<div class="form-body ">
{$sysfield}
</div>
</div>
</div>
</div>
</div>
<div class="portlet-body form myfooter">
<div class="form-actions text-center">
{if $is_verify}
<script>
function dr_verify() {
if ($("input[name='data[status]']:checked").val() == 0) {
layer.confirm('{dr_lang("您需要将它设置为通过状态吗?")}', {
icon: 3,
shade: 0,
title: '{dr_lang("审核提示")}',
btn: ['{dr_lang("设为通过")}','{dr_lang("保持现状")}']
}, function(){
$("input[name='data[status]'][value='1']").prop('checked',true);
dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$reply_url}');
}, function(){
dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$reply_url}');
});
} else {
dr_ajax_submit('{dr_now_url()}', 'myform', '2000', '{$reply_url}');
}
}
</script>
<label><button type="button" onclick="dr_verify()" class="btn green"> <i class="fa fa-save"></i> {dr_lang('提交审核')}</button></label>
{else}
<label><button type="button" onclick="dr_ajax_submit('{dr_now_url()}', 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存内容')}</button></label>
<label><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></label>
{if $is_form_cache}
<label><button type="button" onclick="auto_form_data_delete()" class="btn red"> <i class="fa fa-trash"></i> {dr_lang('删除历史缓存')}</button></label>
{/if}
{/if}
</div>
</div>
</form>
{template "footer.html"}
@@ -0,0 +1,69 @@
{template "header.html"}
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
{$form}
<div class="row myfbody {if $is_verify} fc-verify-post{/if}">
<div class="col-md-9">
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption">
<span class="caption-subject font-green sbold ">{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">
<div class="form-group">
<label class="col-md-2 control-label">{dr_lang('关联')}</label>
<div class="col-md-9">
<code class="form-control-static">{$index.title}</code>
</div>
</div>
{$myfield}
</div>
</div>
</div>
{if $diyfield}
<div class="portlet light bordered">
<div class="portlet-title">
<div class="caption">
<span class="caption-subject font-green sbold ">{dr_lang('其他内容')}</span>
</div>
</div>
<div class="portlet-body">
<div class="form-body">
{$diyfield}
</div>
</div>
</div>
{/if}
</div>
<div class="col-md-3 my-sysfield">
<div class="portlet light bordered">
<div class="portlet-body">
<div class="form-body">
{$sysfield}
</div>
</div>
</div>
</div>
</div>
<div class="portlet-body form myfooter">
<div class="form-actions text-center">
<a href="{$reply_url}" class="btn green"> <i class="fa fa-mail-reply"></i> {dr_lang('返回列表')}</a>
</div>
</div>
</form>
{template "footer.html"}