\ No newline at end of file
diff --git a/admin/templates/default/sys_entry.php b/admin/templates/default/sys_entry.php
index 4a7a772..6ff3b00 100644
--- a/admin/templates/default/sys_entry.php
+++ b/admin/templates/default/sys_entry.php
@@ -1,62 +1,68 @@
-
-
-
-
-
+
+
+
diff --git a/application/config/database.php b/application/config/database.php
index 5b9c1a8..834aad9 100755
--- a/application/config/database.php
+++ b/application/config/database.php
@@ -58,7 +58,7 @@
$db['default']['password'] = 'root';
$db['default']['database'] = 'dilicms';
$db['default']['dbdriver'] = 'mysql';
-$db['default']['dbprefix'] = 'cd_';
+$db['default']['dbprefix'] = 'dili_';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
diff --git a/application/views/welcome_message.php b/application/views/welcome_message.php
index 5c819ae..3aead59 100644
--- a/application/views/welcome_message.php
+++ b/application/views/welcome_message.php
@@ -71,8 +71,18 @@
+
+ DiliCMS只有后台的基础部分,没有前台程序,请确认满足您的需求再进行安装使用。
+
+
安装
-
点此进行安装
+
+ 点此进行安装
+
+ - 请确环境检测中提到的文件夹有写入权限(windows也有权限问题)
+ - 安装程序采用HTML5,CSS3制作,请使用高端大气上档次的浏览器执行,^_^
+
+
QQ讨论群
185074106
diff --git a/install/config/database.php b/install/config/database.php
index edb3d8e..fb6ce20 100755
--- a/install/config/database.php
+++ b/install/config/database.php
@@ -58,7 +58,7 @@
$db['default']['password'] = 'root';
$db['default']['database'] = 'dilicms';
$db['default']['dbdriver'] = 'mysql';
-$db['default']['dbprefix'] = 'cd_';
+$db['default']['dbprefix'] = 'dili_';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
diff --git a/install/schema/backend_settings.sql b/install/schema/backend_settings.sql
index 4c6de37..caa1eb9 100644
--- a/install/schema/backend_settings.sql
+++ b/install/schema/backend_settings.sql
@@ -5,7 +5,8 @@ CREATE TABLE IF NOT EXISTS `{DB_PREFIX}backend_settings` (
`backend_root_access` tinyint(1) unsigned DEFAULT '1',
`backend_access_point` varchar(20) DEFAULT 'admin',
`backend_title` varchar(100) DEFAULT 'DiliCMS后台管理',
- `backend_logo` varchar(100) DEFAULT 'images/logo.gif'
+ `backend_logo` varchar(100) DEFAULT 'images/logo.gif',
+ `plugin_dev_mode` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8{SEPERATOR}
DELETE FROM `{DB_PREFIX}backend_settings`{SEPERATOR}
INSERT INTO `{DB_PREFIX}backend_settings` (`backend_theme`, `backend_lang`, `backend_root_access`, `backend_access_point`, `backend_title`, `backend_logo`) VALUES ('default', 'zh-cn', 1, '', 'DiliCMS', 'images/logo.gif')
\ No newline at end of file
diff --git a/install/schema/menus.sql b/install/schema/menus.sql
index 5d3d042..004de91 100644
--- a/install/schema/menus.sql
+++ b/install/schema/menus.sql
@@ -1,12 +1,12 @@
-DROP TABLE IF EXISTS `{DB_PREFIX}menus`{SEPERATOR}
-CREATE TABLE IF NOT EXISTS `{DB_PREFIX}menus` (
- `menu_id` tinyint(10) unsigned NOT NULL AUTO_INCREMENT,
- `class_name` varchar(20) NOT NULL,
- `method_name` varchar(30) NOT NULL,
- `menu_name` varchar(20) NOT NULL,
- `menu_level` tinyint(2) unsigned DEFAULT '0',
- `menu_parent` tinyint(10) unsigned DEFAULT '0',
- PRIMARY KEY (`menu_id`)
-) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=utf8{SEPERATOR}
-DELETE FROM `{DB_PREFIX}menus`{SEPERATOR}
-INSERT INTO `{DB_PREFIX}menus` (`menu_id`, `class_name`, `method_name`, `menu_name`, `menu_level`, `menu_parent`) VALUES (1, 'system', 'home', '系统', 0, 0), (2, 'system', 'home', '后台首页', 1, 1), (3, 'system', 'home', '后台首页', 2, 2), (4, 'setting', 'site', '系统设置', 1, 1), (5, 'setting', 'site', '站点设置', 2, 4), (6, 'setting', 'backend', '后台设置', 2, 4), (7, 'system', 'password', '修改密码', 2, 4), (8, 'system', 'cache', '更新缓存', 2, 4), (9, 'model', 'view', '模型管理', 1, 1), (10, 'model', 'view', '内容模型管理', 2, 9), (11, 'category', 'view', '分类模型管理', 2, 9), (12, 'plugin', 'view', '插件管理', 1, 1), (13, 'plugin', 'view', '插件管理', 2, 12), (14, 'role', 'view', '权限管理', 1, 1), (15, 'role', 'view', '用户组管理', 2, 14), (16, 'user', 'view', '用户管理', 2, 14), (17, 'content', 'view', '内容管理', 0, 0), (18, 'content', 'view', '内容管理', 1, 17), (19, 'category_content', 'view', '分类管理', 1, 17), (20, 'module', 'run', '工具', 0, 0), (21, 'database', 'index', '数据库管理', 1, 1), (22, 'database', 'index', '数据库备份', 2, 21), (23, 'database', 'recover', '数据库还原', 2, 21), (24, 'database', 'optimize', '数据库优化', 2, 21)
\ No newline at end of file
+DROP TABLE IF EXISTS `{DB_PREFIX}menus`{SEPERATOR}
+CREATE TABLE IF NOT EXISTS `{DB_PREFIX}menus` (
+ `menu_id` tinyint(10) unsigned NOT NULL AUTO_INCREMENT,
+ `class_name` varchar(20) NOT NULL,
+ `method_name` varchar(30) NOT NULL,
+ `menu_name` varchar(20) NOT NULL,
+ `menu_level` tinyint(2) unsigned DEFAULT '0',
+ `menu_parent` tinyint(10) unsigned DEFAULT '0',
+ PRIMARY KEY (`menu_id`)
+) ENGINE=MyISAM AUTO_INCREMENT=21 DEFAULT CHARSET=utf8{SEPERATOR}
+DELETE FROM `{DB_PREFIX}menus`{SEPERATOR}
+INSERT INTO `{DB_PREFIX}menus` (`menu_id`, `class_name`, `method_name`, `menu_name`, `menu_level`, `menu_parent`) VALUES (1, 'system', 'home', '系统', 0, 0), (2, 'system', 'home', '后台首页', 1, 1), (3, 'system', 'home', '后台首页', 2, 2), (4, 'setting', 'site', '系统设置', 1, 1), (5, 'setting', 'site', '站点设置', 2, 4), (6, 'setting', 'backend', '后台设置', 2, 4), (7, 'system', 'password', '修改密码', 2, 4), (8, 'system', 'cache', '更新缓存', 2, 4), (9, 'model', 'view', '模型管理', 1, 1), (10, 'model', 'view', '内容模型管理', 2, 9), (11, 'category', 'view', '分类模型管理', 2, 9), (12, 'plugin', 'view', '扩展管理', 1, 1), (13, 'plugin', 'view', '插件管理', 2, 12), (14, 'role', 'view', '权限管理', 1, 1), (15, 'role', 'view', '用户组管理', 2, 14), (16, 'user', 'view', '用户管理', 2, 14), (17, 'content', 'view', '内容管理', 0, 0), (18, 'content', 'view', '内容管理', 1, 17), (19, 'category_content', 'view', '分类管理', 1, 17), (20, 'module', 'run', '插件', 0, 0), (21, 'database', 'index', '数据库管理', 1, 1), (22, 'database', 'index', '数据库备份', 2, 21), (23, 'database', 'recover', '数据库还原', 2, 21), (24, 'database', 'optimize', '数据库优化', 2, 21)
\ No newline at end of file
diff --git a/shared/config/constant.php b/shared/config/constant.php
index 9bca037..4cd2b4a 100755
--- a/shared/config/constant.php
+++ b/shared/config/constant.php
@@ -11,7 +11,7 @@
define('IN_DILICMS', TRUE);
- define('DILICMS_VERSION', 'V2.1.3');
+ define('DILICMS_VERSION', 'V2.2.0-rc.1');
define('DILICMS_SHARE_PATH', BASEPATH . '../shared/');
diff --git a/shared/helpers/common_helper.php b/shared/helpers/common_helper.php
index 928e1f3..fb58047 100755
--- a/shared/helpers/common_helper.php
+++ b/shared/helpers/common_helper.php
@@ -1,112 +1,136 @@
-settings->item($key);
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * 更新缓存
- *
- * @access public
- * @param array
- * @param string
- * @return void
- */
-if ( ! function_exists('update_cache'))
-{
- function update_cache($array, $fix = '')
- {
- $ci = &get_instance();
- $ci->load->model('cache_mdl');
- $array = is_array($array) ? $array : array($array);
- foreach ($array as $v)
- {
- $method = 'update_' . $v . '_cache';
- $ci->cache_mdl->$method($fix);
- }
- }
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * 将array转换成缓存字符
- *
- * @access public
- * @param string
- * @param array
- * @return void
- */
-if ( ! function_exists('array_to_cache'))
-{
- function array_to_cache($name, $array)
- {
- return 'settings->item($key);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * 更新缓存
+ *
+ * @access public
+ * @param array
+ * @param string
+ * @return void
+ */
+if ( ! function_exists('update_cache'))
+{
+ function update_cache($array, $fix = '')
+ {
+ $ci = &get_instance();
+ $ci->load->model('cache_mdl');
+ $array = is_array($array) ? $array : array($array);
+ foreach ($array as $v)
+ {
+ $method = 'update_' . $v . '_cache';
+ $ci->cache_mdl->$method($fix);
+ }
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
+ * 将array转换成缓存字符
+ *
+ * @access public
+ * @param string
+ * @param array
+ * @return void
+ */
+if ( ! function_exists('array_to_cache'))
+{
+ function array_to_cache($name, $array)
+ {
+ return 'config->item('index_page') === '')
+ {
+ return backend_url("plugin/$name/$controller/$method", http_build_query($qs));
+ }
+ $qs['plugin'] = $plugin;
+ $qs['c'] = $controller;
+ $qs['m'] = $method;
+ return backend_url('module/run', http_build_query($qs));
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/* End of file common_helper.php */
/* Location: ./shared/heleprs/common_helper.php */
\ No newline at end of file
diff --git a/shared/libraries/Acl.php b/shared/libraries/Acl.php
index a198b41..16521eb 100755
--- a/shared/libraries/Acl.php
+++ b/shared/libraries/Acl.php
@@ -1,426 +1,432 @@
-ci = & get_instance();
- $this->ci->settings->load('menus');//加载菜单数据
- $this->top_menus = & setting('menus');
- if ($this->ci->_admin->role != 1)
- {
- $this->ci->settings->load('acl/role_' . $this->ci->_admin->role . '.php');//加载权限数据
- $this->top_menus = & setting('menus');
- $this->rights = & setting('current_role');
- }
- $this->_filter_menus();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 输出顶部菜单
- *
- * @access public
- * @return void
- */
- public function show_top_menus()
- {
- //检查是否显示顶部插件菜单.
- $is_show_module_menu = FALSE;
- if ($this->ci->plugin_manager->trigger_left_menu())
- {
- $is_show_module_menu = TRUE;
- }
- $last_menu_key = count($this->top_menus) - 1;
- foreach ($this->top_menus as $key => $v)
- {
- if ($key === 2 AND ! $is_show_module_menu)
- {
- continue;
- }
- echo '';
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 输出边栏菜单
- *
- * @access public
- * @return void
- */
- public function show_left_menus()
- {
- foreach ($this->left_menus as $v)
- {
- if ($v['sub_menus'])
- {
- echo '
' . $v['menu_name'] . '
- ';
- foreach ($v['sub_menus'] as $j)
- {
- $extra = '';
- $this->_current_menu == 1 AND $extra = 'model=' . $j['extra'] ;
- $this->_current_menu == 2 AND $extra = $j['extra'];
- echo '- ' . $j['menu_name'] . '
';
- }
- echo '
- ';
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 过滤菜单
- *
- * @access private
- * @return void
- */
- private function _filter_menus()
- {
- $class_name = $this->ci->uri->rsegment(1);
- $method_name = $this->ci->uri->rsegment(2);
- switch ($class_name)
- {
- case 'content' :
- case 'category_content' :
- $this->_filter_content_menus($class_name, $method_name);
- break;
- case 'module' :
- $this->_filter_module_menus($class_name, $method_name);
- break;
- case 'system' :
- case 'setting':
- case 'model' :
- case 'category' :
- case 'plugin' :
- case 'role' :
- case 'user' :
- case 'database' :
- $this->_filter_normal_menus($class_name, $method_name);
- break;
- default :
- //noting to do
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 过滤系统菜单
- *
- * @access private
- * @param string
- * @param string
- * @return void
- */
- private function _filter_normal_menus($class_name, $method_name, $default_uri = 'system/home', $current_menu = 0, $folder = '')
- {//0
- $this->_current_menu = $current_menu;
- $this->_default_link = backend_url($default_uri);
- $this->left_menus = & $this->top_menus[$this->_current_menu]['sub_menus'];
- foreach ($this->left_menus as $vkey => & $v)
- {
- foreach ($v['sub_menus'] as $jkey => & $j)
- {
- if ($j['class_name'] == $folder . $class_name AND $j['method_name'] == $method_name)
- {
- $j['current'] = TRUE;
- }
- if ($this->ci->_admin->role == 1)
- {
- continue;
- }
- $right = $j['class_name'] . '@' . $j['method_name'];
- if ( ! in_array($right, $this->rights['rights']) AND $right !='system@home')
- {
- unset($this->left_menus[$vkey]['sub_menus'][$jkey]);
- }
- }
- if ( ! $v['sub_menus'])
- {
- unset($this->left_menus[$vkey]);
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 过滤模型菜单
- *
- * @access private
- * @param string
- * @param string
- * @return void
- */
- private function _filter_content_menus($class_name, $method_name)
- {//1
- $this->_current_menu = 1;
- $this->left_menus = & $this->top_menus[$this->_current_menu]['sub_menus'];
- $extra = $this->ci->input->get('model');
- foreach ($this->left_menus as $vkey => & $v)
- {
- foreach ($v['sub_menus'] as $jkey => & $j)
- {
- if ($j['class_name'] == $class_name AND $j['method_name'] == $method_name AND
- ( ($j['extra'] == $extra AND $vkey == 0) || ($j['extra'] == $extra AND $vkey == 1) ) )
- {
- $j['current'] = TRUE;
- }
-
- if ($this->ci->_admin->role == 1)
- {
- continue;
- }
- $right = $j['class_name'] . '@' . $j['method_name'];
- if ( ! in_array($right, $this->rights['rights']) ||
- ( ! in_array($j['extra'], $this->rights['models']) AND $vkey == 0) ||
- ( ! in_array($j['extra'], $this->rights['category_models']) AND $vkey == 1)
- )
- {
- unset($this->left_menus[$vkey]['sub_menus'][$jkey]);
- }
- }
- if ( ! $v['sub_menus'])
- {
- unset($this->left_menus[$vkey]);
- }
- }
- //设定默认链接
- if ($_item = @ reset($this->left_menus[0]['sub_menus']))
- {
- if ( ! $this->_default_link)
- {
- $this->_default_link = backend_url($_item['class_name'] . '/view', 'model=' . $_item['extra']);
- }
- }
-
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 过滤插件菜单
- *
- * @access private
- * @param string
- * @param string
- * @return void
- */
- private function _filter_module_menus($class_name, $method_name)
- {//2
- $this->_current_menu = 2;
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 检测模块插件菜单
- *
- * @access public
- * @return void
- */
- public function detect_plugin_menus()
- {
- $this->top_menus[$this->_current_menu]['sub_menus'] = $this->ci->plugin_manager->trigger_left_menu();
- $this->left_menus = & $this->top_menus[$this->_current_menu]['sub_menus'];
- foreach ($this->left_menus as $key => & $v)
- {
- if (isset($v['sub_menus']) AND $v['sub_menus'])
- {
- foreach ($v['sub_menus'] as & $j)
- {
- $j['extra'] = 'plugin=' . $j['class_name'] . '&action=' . $j['method_name'];
- if ($j['class_name'] == $this->ci->input->get('plugin') AND $j['method_name'] == $this->ci->input->get('action'))
- {
- $j['current'] = TRUE;
- }
- $j['class_name'] = 'module';
- $j['method_name'] = 'run';
- if ( ! $this->_default_link)
- {
- $this->_default_link = backend_url('module/run', $j['extra']);
- }
- }
- }
- else
- {
- unset($this->left_menus[$key]);
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 检测插件
- *
- * @access public
- * @param string
- * @return void
- */
- public function permit($act = '', $folder = '')
- {
- if ($this->ci->_admin->role == 1)
- {
- return TRUE;
- }
- $class_method = $folder . $this->ci->uri->rsegment(1) . '@' . $this->ci->uri->rsegment(2) . ($act ? '@' . $act : '');
- if ( ! in_array($class_method,$this->rights['rights']))
- {
- return FALSE;
- }
- if ( $this->ci->uri->rsegment(1) == 'content' )
- {
- if ( ! in_array($this->ci->input->get('model'), $this->rights['models']))
- {
- return FALSE;
- }
- }
- else if ($this->ci->uri->rsegment(1) == 'category_content')
- {
- if ( ! in_array($this->ci->input->get('model'), $this->rights['category_models']))
- {
- return FALSE;
- }
- }
- else if ($this->ci->uri->rsegment(1) == 'module')
- {
- if ( ! in_array($this->ci->input->get('plugin'), $this->rights['plugins']))
- {
- return FALSE;
- }
- }
- return TRUE;
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 设置顶部选中菜单
- *
- * @access public
- * @param int
- * @return void
- */
- public function set_current_menu($key = 0)
- {
- $this->_current_menu = $key;
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 触发自定义菜单的检测
- *
- * @access public
- * @param int
- * @return void
- */
- public function filter_left_menus($default_uri = '', $current_menu = 0, $folder = '')
- {
- $current_menu AND $this->_current_menu = $current_menu;
- $class_name = $this->ci->uri->rsegment(1);
- $method_name = $this->ci->uri->rsegment(2);
- $this->_filter_normal_menus($class_name, $method_name, $default_uri, $this->_current_menu, $folder);
- }
-
- // ------------------------------------------------------------------------
-
-}
-
-/* End of file Acl.php */
+ci = & get_instance();
+ $this->ci->settings->load('menus');//加载菜单数据
+ $this->top_menus = & setting('menus');
+ if ($this->ci->_admin->role != 1)
+ {
+ $this->ci->settings->load('acl/role_' . $this->ci->_admin->role . '.php');//加载权限数据
+ $this->top_menus = & setting('menus');
+ $this->rights = & setting('current_role');
+ }
+ $this->_filter_menus();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 输出顶部菜单
+ *
+ * @access public
+ * @return void
+ */
+ public function show_top_menus()
+ {
+ //检查是否显示顶部插件菜单.
+ $is_show_module_menu = FALSE;
+ if ($this->ci->plugin_manager->get_menus())
+ {
+ $is_show_module_menu = TRUE;
+ }
+ $last_menu_key = count($this->top_menus) - 1;
+ foreach ($this->top_menus as $key => $v)
+ {
+ if ($key === 2 AND ! $is_show_module_menu)
+ {
+ continue;
+ }
+ echo '';
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 输出边栏菜单
+ *
+ * @access public
+ * @return void
+ */
+ public function show_left_menus()
+ {
+ foreach ($this->left_menus as $key => $v)
+ {
+ if ($v['sub_menus'])
+ {
+ echo '
' . $v['menu_name'] . '
+ ';
+ foreach ($v['sub_menus'] as $j)
+ {
+ $extra = '';
+ $this->_current_menu == 1 AND $extra = 'model=' . $j['extra'] ;
+ if ($this->_current_menu == 2) {
+ echo '- ' . $j['menu_name'] . '
';
+ continue;
+ }
+ echo '- ' . $j['menu_name'] . '
';
+ }
+ echo '
+ ';
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 过滤菜单
+ *
+ * @access private
+ * @return void
+ */
+ private function _filter_menus()
+ {
+ $class_name = $this->ci->uri->rsegment(1);
+ $method_name = $this->ci->uri->rsegment(2);
+ switch ($class_name)
+ {
+ case 'content' :
+ case 'category_content' :
+ $this->_filter_content_menus($class_name, $method_name);
+ break;
+ case 'module' :
+ $this->_filter_module_menus($class_name, $method_name);
+ break;
+ case 'system' :
+ case 'setting':
+ case 'model' :
+ case 'category' :
+ case 'plugin' :
+ case 'role' :
+ case 'user' :
+ case 'database' :
+ $this->_filter_normal_menus($class_name, $method_name);
+ break;
+ default :
+ //noting to do
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 过滤系统菜单
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return void
+ */
+ private function _filter_normal_menus($class_name, $method_name, $default_uri = 'system/home', $current_menu = 0, $folder = '')
+ {//0
+ $this->_current_menu = $current_menu;
+ $this->_default_link = backend_url($default_uri);
+ $this->left_menus = & $this->top_menus[$this->_current_menu]['sub_menus'];
+ foreach ($this->left_menus as $vkey => & $v)
+ {
+ foreach ($v['sub_menus'] as $jkey => & $j)
+ {
+ if ($j['class_name'] == $folder . $class_name AND $j['method_name'] == $method_name)
+ {
+ $j['current'] = TRUE;
+ }
+ if ($this->ci->_admin->role == 1)
+ {
+ continue;
+ }
+ $right = $j['class_name'] . '@' . $j['method_name'];
+ if ( ! in_array($right, $this->rights['rights']) AND $right !='system@home')
+ {
+ unset($this->left_menus[$vkey]['sub_menus'][$jkey]);
+ }
+ }
+ if ( ! $v['sub_menus'])
+ {
+ unset($this->left_menus[$vkey]);
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 过滤模型菜单
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return void
+ */
+ private function _filter_content_menus($class_name, $method_name)
+ {//1
+ $this->_current_menu = 1;
+ $this->left_menus = & $this->top_menus[$this->_current_menu]['sub_menus'];
+ $extra = $this->ci->input->get('model');
+ foreach ($this->left_menus as $vkey => & $v)
+ {
+ foreach ($v['sub_menus'] as $jkey => & $j)
+ {
+ if ($j['class_name'] == $class_name AND $j['method_name'] == $method_name AND
+ ( ($j['extra'] == $extra AND $vkey == 0) || ($j['extra'] == $extra AND $vkey == 1) ) )
+ {
+ $j['current'] = TRUE;
+ }
+
+ if ($this->ci->_admin->role == 1)
+ {
+ continue;
+ }
+ $right = $j['class_name'] . '@' . $j['method_name'];
+ if ( ! in_array($right, $this->rights['rights']) ||
+ ( ! in_array($j['extra'], $this->rights['models']) AND $vkey == 0) ||
+ ( ! in_array($j['extra'], $this->rights['category_models']) AND $vkey == 1)
+ )
+ {
+ unset($this->left_menus[$vkey]['sub_menus'][$jkey]);
+ }
+ }
+ if ( ! $v['sub_menus'])
+ {
+ unset($this->left_menus[$vkey]);
+ }
+ }
+ //设定默认链接
+ if ($_item = @ reset($this->left_menus[0]['sub_menus']))
+ {
+ if ( ! $this->_default_link)
+ {
+ $this->_default_link = backend_url($_item['class_name'] . '/view', 'model=' . $_item['extra']);
+ }
+ }
+
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 过滤插件菜单
+ *
+ * @access private
+ * @param string
+ * @param string
+ * @return void
+ */
+ private function _filter_module_menus($class_name, $method_name)
+ {//2
+ $this->_current_menu = 2;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 检测模块插件菜单
+ *
+ * @access public
+ * @return void
+ */
+ public function detect_plugin_menus()
+ {
+ $this->top_menus[$this->_current_menu]['sub_menus'] = $this->ci->plugin_manager->get_menus();
+ $this->left_menus = & $this->top_menus[$this->_current_menu]['sub_menus'];
+ foreach ($this->left_menus as $key => & $v)
+ {
+ if (isset($v['sub_menus']) AND $v['sub_menus'])
+ {
+ foreach ($v['sub_menus'] as & $j)
+ {
+ $j['extra'] = 'plugin=' . $key . '&action=' . $j['method_name'];
+ if ($key == $this->ci->input->get('plugin')
+ AND
+ $j['class_name'] == $this->ci->input->get('c')
+ AND
+ $j['method_name'] == $this->ci->input->get('m'))
+ {
+ $j['current'] = TRUE;
+ }
+ if ( ! $this->_default_link)
+ {
+ $this->_default_link = plugin_url($key, $j['class_name'], $j['method_name']);
+ }
+ }
+ }
+ else
+ {
+ unset($this->left_menus[$key]);
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 检测插件
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ public function permit($act = '', $folder = '')
+ {
+ if ($this->ci->_admin->role == 1)
+ {
+ return TRUE;
+ }
+ $class_method = $folder . $this->ci->uri->rsegment(1) . '@' . $this->ci->uri->rsegment(2) . ($act ? '@' . $act : '');
+ if ( ! in_array($class_method,$this->rights['rights']))
+ {
+ return FALSE;
+ }
+ if ( $this->ci->uri->rsegment(1) == 'content' )
+ {
+ if ( ! in_array($this->ci->input->get('model'), $this->rights['models']))
+ {
+ return FALSE;
+ }
+ }
+ else if ($this->ci->uri->rsegment(1) == 'category_content')
+ {
+ if ( ! in_array($this->ci->input->get('model'), $this->rights['category_models']))
+ {
+ return FALSE;
+ }
+ }
+ else if ($this->ci->uri->rsegment(1) == 'module')
+ {
+ if ( ! in_array($this->ci->input->get('plugin'), $this->rights['plugins']))
+ {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 设置顶部选中菜单
+ *
+ * @access public
+ * @param int
+ * @return void
+ */
+ public function set_current_menu($key = 0)
+ {
+ $this->_current_menu = $key;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 触发自定义菜单的检测
+ *
+ * @access public
+ * @param int
+ * @return void
+ */
+ public function filter_left_menus($default_uri = '', $current_menu = 0, $folder = '')
+ {
+ $current_menu AND $this->_current_menu = $current_menu;
+ $class_name = $this->ci->uri->rsegment(1);
+ $method_name = $this->ci->uri->rsegment(2);
+ $this->_filter_normal_menus($class_name, $method_name, $default_uri, $this->_current_menu, $folder);
+ }
+
+ // ------------------------------------------------------------------------
+
+}
+
+/* End of file Acl.php */
/* Location: ./shared/libraries/Acl.php */
\ No newline at end of file
diff --git a/shared/libraries/Plugin_manager.php b/shared/libraries/Plugin_manager.php
index f0380a9..ba1d72d 100755
--- a/shared/libraries/Plugin_manager.php
+++ b/shared/libraries/Plugin_manager.php
@@ -1,352 +1,276 @@
-ci = & get_instance();
- $this->_init();
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 初始化
- *
- * @access private
- * @return void
- */
- private function _init()
- {
- if ($this->ci->platform->cache_exists(DILICMS_SHARE_PATH . 'settings/plugins.php'))
- {
- eval('?>' . $this->ci->platform->cache_read(DILICMS_SHARE_PATH . 'settings/plugins.php'));
- if (isset($setting['active_plugins']))
- {
- $this->active_plugins = $setting['active_plugins']['plugins'];
- $this->active_model_plugins = $setting['active_plugins']['model_plugins'];
- $this->_load_plugins($this->active_plugins);
- unset($setting['active_plugins']);
- }
- }
- if ($this->ci->uri->rsegment(1) == 'category_content' || $this->ci->uri->rsegment(1) == 'content')
- {
- $this->_load_plugins($this->active_model_plugins, 'model_');
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 加载插件
- *
- * @access private
- * @param array
- * @param string
- * @return void
- */
- private function _load_plugins( & $plugins, $name_fix = '')
- {
- foreach ($plugins as $key => & $plugin)
- {
- if ($plugin['access'] == 1 && $this->ci->_admin->role != 1)
- {
- unset($plugins[$key]);
- continue;
- }
- if ($this->ci->_admin->role != 1 && ! in_array('module@run', $this->ci->acl->rights['rights']) )
- {
- unset($plugins[$key]);
- continue;
- }
- if ($this->ci->_admin->role != 1 && ! in_array($plugin['name'], $this->ci->acl->rights['plugins']))
- {
- unset($plugins[$key]);
- continue;
- }
- if ( ! file_exists(DILICMS_EXTENSION_PATH . 'plugins/' . $plugin['name'] . '/' . 'plugin_' . $name_fix . $plugin['name'] . '.php'))
- {
- unset($plugins[$key]);
- }
- else
- {
- $plugin_class = 'plugin_' . $name_fix . $plugin['name'];
- include DILICMS_EXTENSION_PATH . 'plugins/' . $plugin['name'] . '/' . 'plugin_' . $name_fix . $plugin['name'] . '.php';
- if (class_exists($plugin_class))
- {
- $plugin['instance'] = new $plugin_class($plugin['name']);
- }
- else
- {
- unset($plugins[$key]);
- }
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 导航触发钩子
- *
- * @access public
- * @return void
- */
- public function trigger_navigation()
- {
- foreach ($this->active_plugins as $plugin)
- {
- $plugin['instance']->register_navigation();
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 菜单触发钩子
- *
- * @access public
- * @return void
- */
- public function trigger_left_menu()
- {
- $left_menus = array();
- foreach ($this->active_plugins as $plugin)
- {
- $left_menu = $plugin['instance']->register_left_menu();
- if( $left_menu )
- {
- $left_menus[] = $left_menu;
- }
- }
- return $left_menus;
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 附件处理钩子触发
- *
- * @access public
- * @param string
- * @return void
- */
- public function trigger_attachment($file)
- {
- foreach ($this->active_plugins as $plugin)
- {
- $plugin['instance']->register_attachment($file);
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 模型插件系列钩子触发
- *
- * @access public
- * @param string
- * @return void/false
- */
- public function trigger_model_action($name = '' , & $arg1 = '' , & $arg2 = '')
- {
- if ( ! $name)
- {
- return FALSE;
- }
- foreach ($this->active_model_plugins as $plugin)
- {
- call_user_func_array(array(& $plugin['instance'], $name), array(& $arg1, & $arg2));
- }
- }
-
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * DiliCMS 插件基类
- *
- * @package DiliCMS
- * @subpackage Libraries
- * @category Libraries
- * @author Jeongee
- * @link http://www.dilicms.com
- */
-abstract class Dili_basic_plugin
-{
- protected $_name = '';
- protected $_ci = NULL;
- protected $_path = '';
-
- public function __construct($name)
- {
- $this->_name = $name;
- $this->_ci = & get_instance();
- $this->_path = DILICMS_EXTENSION_PATH . 'plugins/' . $this->_name . '/';
- }
-
- protected function _url($action, $qs = '')
- {
- return backend_url('module/run','plugin='.$this->_name.'&action='.$action).$qs;
- }
-
- protected function _check($type = '' , $model = '')
- {
- return $this->_ci->uri->rsegment(1) == $type && $model == $this->_ci->input->get('model');
- }
-
- protected function _template($view , $data = array() , $output = true)
- {
- extract($data);
- ob_start();
- eval('?>' . file_get_contents($this->_path . $view . '.php'));
- $content = ob_get_contents();
- ob_end_clean();
- if ($output == TRUE)
- {
- echo $content;
- }
- else
- {
- return $content;
- }
- }
-
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * DiliCMS 模型插件基类
- *
- * @package DiliCMS
- * @subpackage Libraries
- * @category Libraries
- * @author Jeongee
- * @link http://www.dilicms.com
- */
-abstract class Dili_model_plugin extends Dili_basic_plugin
-{
- public function __construct($name)
- {
- parent::__construct($name);
- }
- //注册操作栏
- public function register_operation(){}
- //注册模型信息插入前操作
- public function register_before_insert(){}//& $data
- //注册模型信息插入后操作
- public function register_after_insert(){}//& $data ,$id
- //注册模型信息修改前操作
- public function register_before_update(){}//& $data ,$id
- //注册模型信息修改后操作
- public function register_after_update(){}//& $data ,$id
- //注册模型信息删除前操作
- public function register_before_delete(){}//$ids
- //注册模型信息删除后操作
- public function register_after_delete(){}//$ids
- //注册模型信息添加修改页面视图
- public function register_view(){}//& $content
- //注册模型信息列表QUERY之前
- public function register_before_query(){}//&$where
- //注册模型信息列表数据二次处理
- public function register_before_list(){}//& $list
- //注册模型信息列表显示页面
- public function register_list_view(){}//& $list
- //注册模型信息列表操作栏
- public function register_list_operation_view(){}// &$data
- //注册模型信息进入列表信息动作
- public function register_on_reach_model_list(){}//
-}
-
-// ------------------------------------------------------------------------
-
-/**
- * DiliCMS 模块插件基类
- *
- * @package DiliCMS
- * @subpackage Libraries
- * @category Libraries
- * @author Jeongee
- * @link http://www.dilicms.com
- */
-abstract class Dili_plugin extends Dili_basic_plugin
-{
- public function __construct($name)
- {
- parent::__construct($name);
- }
- //注册快速导航栏按钮
- public function register_navigation(){}
- //注册左边栏菜单
- public function register_left_menu(){}
- /*return array( 'menu_name' => 'Hello World 插件',
- 'sub_menus' => array(
- 0=>array('class_name'=>$this->_name,'method_name'=>'welcome','menu_name'=>'测试左菜单')
- )
- );*/
- //注册快速导航栏按钮
- public function register_attachment(){}//参数为路径
-}
-
-/* End of file Plugin_manager.php */
+app = get_instance();
+
+ //如果插件开发模式开启了,将会每次自动更新插件缓存
+ if ($this->app->settings->item('plugin_dev_mode')) {
+
+ $this->app->load->model('cache_mdl');
+
+ $this->app->cache_mdl->update_plugin_cache();
+
+ }
+
+ $this->initialize();
+ }
+
+ private function initialize()
+ {
+ //加载插件
+ if ($this->app->platform->cache_exists(DILICMS_SHARE_PATH . 'settings/plugins.php'))
+ {
+ eval('?>' . $this->app->platform->cache_read(DILICMS_SHARE_PATH . 'settings/plugins.php'));
+ if (isset($setting['plugins']) and is_array($setting['plugins']))
+ {
+ $this->plugins = $setting['plugins'];
+ $this->watch();
+ unset($setting['plugins']);
+ }
+ }
+ if ($this->app->uri->rsegment(1) == 'category_content' || $this->app->uri->rsegment(1) == 'content')
+ {
+ $model = $this->app->input->get('model', true);
+ //重新分析classmap,加入autoloader
+ foreach ($this->plugins as $name => $plugin) {
+ foreach ($plugin['classmap'] as $filename => $hook) {
+ if ($model == $filename) {
+ $filename = ($name.'_hook_'.$model);
+ $this->classmap[$filename] = $hook;
+ }
+ }
+ }
+
+ }
+
+ //加载菜单
+ foreach ($this->plugins as $name => $plugin) {
+ $this->menus[$name] = $plugin['menus'];
+ }
+
+ }
+
+ private function watch()
+ {
+ foreach ($this->plugins as $key => $plugin)
+ {
+ if ($plugin['access'] == 1 and $this->app->_admin->role != 1)
+ {
+ unset($this->plugins[$key]);
+ continue;
+ }
+ if ($this->app->_admin->role != 1 and ! in_array('module@run', $this->app->acl->rights['rights']) )
+ {
+ unset($this->plugins[$key]);
+ continue;
+ }
+ if ($this->app->_admin->role != 1 && ! in_array($plugin['name'], $this->app->acl->rights['plugins']))
+ {
+ unset($this->plugins[$key]);
+ continue;
+ }
+ }
+ }
+
+ private function autoloader($class_name)
+ {
+ if (class_exists(ucfirst($class_name))) {
+ return true;
+ }
+ $path = DILICMS_EXTENSION_PATH . $this->classmap[$class_name];
+
+ if (isset($this->classmap[$class_name]) and file_exists($path))
+ {
+ include $path;
+ }
+ if (! class_exists(ucfirst($class_name))) {
+ throw new RuntimeException("Can't Find Class $class_name.");
+ }
+
+ }
+
+ public function trigger($method, & $data = null, $other = null)
+ {
+ $args = array(&$data, $other);
+ foreach ($this->classmap as $class => $path) {
+ if (! isset($this->instances[$class])) {
+ $this->autoloader($class);
+ $this->instances[$class] = new $class;
+ }
+
+ return call_user_func_array(array($this->instances[$class], $method), $args);
+ }
+ }
+
+ public function get_menus()
+ {
+ return $this->menus;
+ }
+
+}
+
+interface DiliCMS_Model_Hook_Interface
+{
+
+ /**
+ * 为操作工具栏新增按钮
+ */
+ public function buttons();
+
+ /**
+ * 模型数据新增入库前
+ */
+ public function inserting(&$data);
+
+ /**
+ * 模型数据新增入库后
+ */
+ public function inserted($data, $id);
+
+ /**
+ * 模型数据修改入库前
+ */
+ public function updating(&$data, $id);
+
+ /**
+ * 模型数据修改入库后
+ */
+ public function updated($data, $id);
+
+ /**
+ * 模型数据删除操作前
+ */
+ public function deleting(&$ids);
+
+ /**
+ * 模型数据删除操作后
+ */
+ public function deleted($ids);
+
+ /**
+ * 模型数据表单展示后
+ */
+ public function rendered($content);
+
+ /**
+ * 模型数据列表执行查询前
+ */
+ public function querying(&$where);
+
+ /**
+ * 模型数据列表展示前
+ */
+ public function listing(&$results);
+
+ /**
+ * 模型数据列表展示后
+ */
+ public function listed($results);
+
+ /**
+ * 模型数据列表各记录操作位置
+ */
+ public function row_buttons($data);
+
+ /**
+ * 模型数据进入列表页面开始处理前
+ *
+ * 可用于更细化的权限判断
+ */
+ //注册模型信息进入列表信息动作
+ public function reaching();
+}
+
+/**
+ * DiliCMS 插件基类
+ *
+ * @package DiliCMS
+ * @subpackage Libraries
+ * @category Libraries
+ * @author Jeongee
+ * @link http://www.dilicms.com
+ */
+abstract class DiliCMS_Plugin_Controller
+{
+ protected $name = '';
+
+ protected $app = null;
+
+ protected $path = '';
+
+ public function __construct($name)
+ {
+ $this->name = $name;
+
+ $this->app = & get_instance();
+
+ $this->path = DILICMS_EXTENSION_PATH . 'plugins/' . $this->name . '/';
+
+ $this->add_packages();
+ }
+
+ private function add_packages()
+ {
+ $this->load->add_package_path($this->path);
+ }
+
+ protected function plugin_url($controller, $method, $qs = array())
+ {
+ return plugin_url($this->name, $controller, $method, $qs);
+ }
+
+ public function get_path()
+ {
+ return $this->path;
+ }
+
+ public function __get($name)
+ {
+ if (property_exists($this->app, $name))
+ {
+ return $this->app->$name;
+ }
+ }
+
+}
+
+/* End of file Plugin_manager.php */
/* Location: ./shared/libraries/Plugin_manager.php */
\ No newline at end of file
diff --git a/shared/models/cache_mdl.php b/shared/models/cache_mdl.php
index f40075a..96c0c97 100755
--- a/shared/models/cache_mdl.php
+++ b/shared/models/cache_mdl.php
@@ -1,420 +1,439 @@
-platform->get_type() == 'default')
- {
- if ( ! file_exists(DILICMS_SHARE_PATH . 'settings/' . $folder))
- {
- mkdir(DILICMS_SHARE_PATH . 'settings/' . $folder);
- }
- }
-
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新内容模型缓存
- *
- * @access public
- * @param string
- * @return void
- */
- public function update_model_cache($target = '')
- {
- $data = array();
- if ($target)
- {
- $target = is_array($target) ? $target : array($target);
- $this->db->where_in('name', $target);
- }
- $models = $this->db->get($this->db->dbprefix('models'))->result_array();
- foreach ($models as $model)
- {
- $model['fields'] = array();
- $model['fields_org'] = $this->db->where('model', $model['id'])
- ->order_by('`order`', 'ASC')
- ->get($this->db->dbprefix('model_fields'))
- ->result_array();
- $model['listable'] = array();
- $model['searchable'] = array();
- foreach ($model['fields_org'] as $key=> & $v)
- {
- if ($v['listable'] == 1)
- {
- array_push($model['listable'], $v['id']);
- }
- if ($v['searchable'] == 1)
- {
- array_push($model['searchable'], $v['id']);
- }
- if (in_array($v['type'], array('select', 'checkbox', 'radio')))
- {
- if ($v['values'] == '')
- {
- $v['values'] = array();
- }
- else
- {
- $value = array();
- foreach (explode('|', $v['values']) as $vt)
- {
- if (strpos($vt, '=') > -1)
- {
- $vt = explode('=', $vt);
- $value[$vt[0]] = $vt[1];
- }
- else
- {
- $value[$vt] = $vt;
- }
- }
- $v['values'] = $value;
- }
- }
- $model['fields'][$v['id']] = $v;
- }
- unset($model['fields_org']);
- $this->_create_folder('model');
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/model/'.$model['name'].'.php',
- array_to_cache("setting['models']['" . $model['name'] . "']", $model)
- );
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新分类模型缓存
- *
- * @access public
- * @param string
- * @return void
- */
- public function update_category_cache($target = '')
- {
- $this->load->model('category_mdl');
- $data = array();
- if ($target)
- {
- $target = is_array($target) ? $target : array($target);
- $this->db->where_in('name', $target);
- }
- $models = $this->db->get($this->db->dbprefix('cate_models'))->result_array();
- foreach ($models as $model)
- {
- $model['fields'] = array();
- $model['fields_org'] = $this->db->where('model', $model['id'])
- ->order_by('`order`', 'ASC')
- ->get($this->db->dbprefix('cate_fields'))
- ->result_array();
- $model['listable'] = array();
- $model['searchable'] = array();
- foreach ($model['fields_org'] as $key=> & $v)
- {
- if ($v['listable'] == 1)
- {
- array_push($model['listable'], $v['id']);
- }
- if ($v['searchable'] == 1)
- {
- array_push($model['searchable'], $v['id']);
- }
- if (in_array($v['type'], array('select', 'checkbox', 'radio')))
- {
- if ($v['values'] == '')
- {
- $v['values'] = array();
- }
- else
- {
- $value = array();
- foreach (explode('|', $v['values']) as $vt)
- {
- if (strpos($vt,'=') > -1)
- {
- $vt = explode('=', $vt);
- $value[$vt[0]] = $vt[1];
- }
- else
- {
- $value[$vt] = $vt;
- }
- }
- $v['values'] = $value;
- }
- }
- $model['fields'][$v['id']] = $v;
- }
- unset($model['fields_org']);
- $this->_create_folder('category');
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/category/cate_' . $model['name'] . '.php',
- array_to_cache("setting['cate_models']['" . $model['name'] . "']", $model));
- $category = array();
- $categories = $this->category_mdl->get_category($model['name']);
- foreach($categories as $c)
- {
- $category[$c['classid']] = $c;
- }
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/category/data_' . $model['name'] . '.php',
- array_to_cache("setting['category']['" . $model['name'] . "']", $category));
- unset($categories,$category);
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新菜单缓存
- *
- * @access public
- * @return void
- */
- public function update_menu_cache()
- {
- $table_menu = $this->db->dbprefix('menus');
- $level_1_menus = $this->db->select('menu_id, class_name, method_name, menu_name')
- ->where('menu_level', 0)
- ->where('menu_parent', 0)
- ->get($table_menu)
- ->result_array();
- foreach ($level_1_menus as & $i)
- {
- $level_2_menus = $this->db->select('menu_id, class_name, method_name, menu_name')
- ->where('menu_level', 1)
- ->where('menu_parent', $i['menu_id'])
- ->get($table_menu)
- ->result_array();
- foreach ($level_2_menus as & $j)
- {
- if ($j['class_name'] == 'content')
- {
- $level_3_menus = $this->db
- ->select(" 'content' AS class_name, 'view' AS 'method_name', name AS extra, description AS menu_name", FALSE)
- ->get($this->db->dbprefix('models'))
- ->result_array();
- }
- else if ($j['class_name'] == 'category_content')
- {
- $level_3_menus = $this->db
- ->select(" 'category_content' AS class_name, 'view' AS 'method_name', name AS extra, description AS menu_name", FALSE)
- ->get($this->db->dbprefix('cate_models'))
- ->result_array();
- }
- else
- {
- $level_3_menus = $this->db->select('menu_id, class_name, method_name, menu_name')
- ->where('menu_level', 2)
- ->where('menu_parent', $j['menu_id'])
- ->get($table_menu)
- ->result_array();
- }
- $j['sub_menus'] = $level_3_menus;
- }
- $i['sub_menus'] = $level_2_menus;
- }
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/menus.php',
- array_to_cache("setting['menus']", $level_1_menus));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新用户组缓存
- *
- * @access public
- * @param string
- * @return void
- */
- public function update_role_cache($target = '')
- {
- if ($target)
- {
- $target = is_array($target) ? $target : array($target);
- $this->db->where_in('id', $target);
- }
- $roles = $this->db->get($this->db->dbprefix('roles'))->result_array();
- foreach ($roles as & $role)
- {
- $role['rights'] = explode(',', $role['rights']);
- $rights = $this->db->select('right_class, right_method, right_detail')
- ->where_in('right_id', $role['rights'])
- ->get($this->db->dbprefix('rights'))
- ->result();
- $role['rights'] = array();
- foreach ($rights as $right)
- {
- $role['rights'][] = $right->right_class . '@' . $right->right_method . ($right->right_detail ? '@' . $right->right_detail : '');
- }
- $role['models'] = explode(',', $role['models']);
- $role['category_models'] = explode(',', $role['category_models']);
- $role['plugins'] = explode(',', $role['plugins']);
- $this->_create_folder('acl');
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/acl/role_' . $role['id'] . '.php',
- array_to_cache("setting['current_role']",$role));
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新站点信息缓存
- *
- * @access public
- * @return void
- */
- public function update_site_cache()
- {
- $data = $this->db->get($this->db->dbprefix('site_settings'))->row_array();
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/site.php',
- array_to_cache("setting", $data));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新后台设置缓存
- *
- * @access public
- * @return void
- */
- public function update_backend_cache()
- {
- $data = $this->db->get($this->db->dbprefix('backend_settings'))->row_array();
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/backend.php',
- array_to_cache("setting", $data));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新插件信息缓存
- *
- * @access public
- * @return void
- */
- public function update_plugin_cache()
- {
- $cached_plugins = $model_plugins = $result_plugins = array();
- $plugins = $this->db->select('name, access')
- ->where('active', '1')
- ->get($this->db->dbprefix('plugins'))
- ->result_array();
- if ($plugins)
- {
- foreach ($plugins as $key => $plugin)
- {
- if (file_exists(DILICMS_EXTENSION_PATH . 'plugins/' . $plugin['name'] . '/' . 'plugin_' . $plugin['name'] . '.php'))
- {
- $result_plugins[$plugin['name']] = $plugin;
- }
- if (file_exists(DILICMS_EXTENSION_PATH . 'plugins/' . $plugin['name'] . '/' . 'plugin_model_' . $plugin['name'] . '.php'))
- {
- $model_plugins[$plugin['name']] = $plugin;
- }
- }
- }
- $cached_plugins['plugins'] = $result_plugins;
- $cached_plugins['model_plugins'] = $model_plugins;
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/plugins.php',
- array_to_cache("setting['active_plugins']", $cached_plugins));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * 更新字段类型缓存
- *
- * @access public
- * @return void
- */
- public function update_fieldtypes_cache()
- {
- $cached_fieldtypes = array();
- $cached_fieldtypes['fieldtypes'] = array();
- $cached_fieldtypes['extra_fieldtypes'] = array();
- $cached_fieldtypes['validation'] = array();
- $results = $this->db->get($this->db->dbprefix('fieldtypes'))->result_array();
- foreach ($results as $v)
- {
- $cached_fieldtypes['fieldtypes'][$v['k']] = $v['v'];
- }
- $results = $this->db->get($this->db->dbprefix('validations'))->result_array();
- foreach ($results as $v)
- {
- $cached_fieldtypes['validation'][$v['k']] = $v['v'];
- }
- $extra_path = DILICMS_EXTENSION_PATH . 'fields/';
- $this->load->helper('file');
- $extra_files = get_filenames($extra_path);
- foreach ($extra_files as $v)
- {
- if (preg_match("/^field_(.*?)\.php$/", $v))
- {
- include $extra_path . $v;
- if (class_exists($extra_class = str_replace('.php', '', $v)))
- {
- $tmp = new $extra_class();
- $cached_fieldtypes['extra_fieldtypes'][$tmp->k] = $tmp->v;
- }
- }
- }
- $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/fieldtypes.php',
- array_to_cache("setting",$cached_fieldtypes));
- }
-
- // ------------------------------------------------------------------------
-
-}
-
-/* End of file cache_mdl.php */
+platform->get_type() == 'default')
+ {
+ if ( ! file_exists(DILICMS_SHARE_PATH . 'settings/' . $folder))
+ {
+ mkdir(DILICMS_SHARE_PATH . 'settings/' . $folder);
+ }
+ }
+
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新内容模型缓存
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ public function update_model_cache($target = '')
+ {
+ $data = array();
+ if ($target)
+ {
+ $target = is_array($target) ? $target : array($target);
+ $this->db->where_in('name', $target);
+ }
+ $models = $this->db->get($this->db->dbprefix('models'))->result_array();
+ foreach ($models as $model)
+ {
+ $model['fields'] = array();
+ $model['fields_org'] = $this->db->where('model', $model['id'])
+ ->order_by('`order`', 'ASC')
+ ->get($this->db->dbprefix('model_fields'))
+ ->result_array();
+ $model['listable'] = array();
+ $model['searchable'] = array();
+ foreach ($model['fields_org'] as $key=> & $v)
+ {
+ if ($v['listable'] == 1)
+ {
+ array_push($model['listable'], $v['id']);
+ }
+ if ($v['searchable'] == 1)
+ {
+ array_push($model['searchable'], $v['id']);
+ }
+ if (in_array($v['type'], array('select', 'checkbox', 'radio')))
+ {
+ if ($v['values'] == '')
+ {
+ $v['values'] = array();
+ }
+ else
+ {
+ $value = array();
+ foreach (explode('|', $v['values']) as $vt)
+ {
+ if (strpos($vt, '=') > -1)
+ {
+ $vt = explode('=', $vt);
+ $value[$vt[0]] = $vt[1];
+ }
+ else
+ {
+ $value[$vt] = $vt;
+ }
+ }
+ $v['values'] = $value;
+ }
+ }
+ $model['fields'][$v['id']] = $v;
+ }
+ unset($model['fields_org']);
+ $this->_create_folder('model');
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/model/'.$model['name'].'.php',
+ array_to_cache("setting['models']['" . $model['name'] . "']", $model)
+ );
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新分类模型缓存
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ public function update_category_cache($target = '')
+ {
+ $this->load->model('category_mdl');
+ $data = array();
+ if ($target)
+ {
+ $target = is_array($target) ? $target : array($target);
+ $this->db->where_in('name', $target);
+ }
+ $models = $this->db->get($this->db->dbprefix('cate_models'))->result_array();
+ foreach ($models as $model)
+ {
+ $model['fields'] = array();
+ $model['fields_org'] = $this->db->where('model', $model['id'])
+ ->order_by('`order`', 'ASC')
+ ->get($this->db->dbprefix('cate_fields'))
+ ->result_array();
+ $model['listable'] = array();
+ $model['searchable'] = array();
+ foreach ($model['fields_org'] as $key=> & $v)
+ {
+ if ($v['listable'] == 1)
+ {
+ array_push($model['listable'], $v['id']);
+ }
+ if ($v['searchable'] == 1)
+ {
+ array_push($model['searchable'], $v['id']);
+ }
+ if (in_array($v['type'], array('select', 'checkbox', 'radio')))
+ {
+ if ($v['values'] == '')
+ {
+ $v['values'] = array();
+ }
+ else
+ {
+ $value = array();
+ foreach (explode('|', $v['values']) as $vt)
+ {
+ if (strpos($vt,'=') > -1)
+ {
+ $vt = explode('=', $vt);
+ $value[$vt[0]] = $vt[1];
+ }
+ else
+ {
+ $value[$vt] = $vt;
+ }
+ }
+ $v['values'] = $value;
+ }
+ }
+ $model['fields'][$v['id']] = $v;
+ }
+ unset($model['fields_org']);
+ $this->_create_folder('category');
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/category/cate_' . $model['name'] . '.php',
+ array_to_cache("setting['cate_models']['" . $model['name'] . "']", $model));
+ $category = array();
+ $categories = $this->category_mdl->get_category($model['name']);
+ foreach($categories as $c)
+ {
+ $category[$c['classid']] = $c;
+ }
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/category/data_' . $model['name'] . '.php',
+ array_to_cache("setting['category']['" . $model['name'] . "']", $category));
+ unset($categories,$category);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新菜单缓存
+ *
+ * @access public
+ * @return void
+ */
+ public function update_menu_cache()
+ {
+ $table_menu = $this->db->dbprefix('menus');
+ $level_1_menus = $this->db->select('menu_id, class_name, method_name, menu_name')
+ ->where('menu_level', 0)
+ ->where('menu_parent', 0)
+ ->get($table_menu)
+ ->result_array();
+ foreach ($level_1_menus as & $i)
+ {
+ $level_2_menus = $this->db->select('menu_id, class_name, method_name, menu_name')
+ ->where('menu_level', 1)
+ ->where('menu_parent', $i['menu_id'])
+ ->get($table_menu)
+ ->result_array();
+ foreach ($level_2_menus as & $j)
+ {
+ if ($j['class_name'] == 'content')
+ {
+ $level_3_menus = $this->db
+ ->select(" 'content' AS class_name, 'view' AS 'method_name', name AS extra, description AS menu_name", FALSE)
+ ->get($this->db->dbprefix('models'))
+ ->result_array();
+ }
+ else if ($j['class_name'] == 'category_content')
+ {
+ $level_3_menus = $this->db
+ ->select(" 'category_content' AS class_name, 'view' AS 'method_name', name AS extra, description AS menu_name", FALSE)
+ ->get($this->db->dbprefix('cate_models'))
+ ->result_array();
+ }
+ else
+ {
+ $level_3_menus = $this->db->select('menu_id, class_name, method_name, menu_name')
+ ->where('menu_level', 2)
+ ->where('menu_parent', $j['menu_id'])
+ ->get($table_menu)
+ ->result_array();
+ }
+ $j['sub_menus'] = $level_3_menus;
+ }
+ $i['sub_menus'] = $level_2_menus;
+ }
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/menus.php',
+ array_to_cache("setting['menus']", $level_1_menus));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新用户组缓存
+ *
+ * @access public
+ * @param string
+ * @return void
+ */
+ public function update_role_cache($target = '')
+ {
+ if ($target)
+ {
+ $target = is_array($target) ? $target : array($target);
+ $this->db->where_in('id', $target);
+ }
+ $roles = $this->db->get($this->db->dbprefix('roles'))->result_array();
+ foreach ($roles as & $role)
+ {
+ $role['rights'] = explode(',', $role['rights']);
+ $rights = $this->db->select('right_class, right_method, right_detail')
+ ->where_in('right_id', $role['rights'])
+ ->get($this->db->dbprefix('rights'))
+ ->result();
+ $role['rights'] = array();
+ foreach ($rights as $right)
+ {
+ $role['rights'][] = $right->right_class . '@' . $right->right_method . ($right->right_detail ? '@' . $right->right_detail : '');
+ }
+ $role['models'] = explode(',', $role['models']);
+ $role['category_models'] = explode(',', $role['category_models']);
+ $role['plugins'] = explode(',', $role['plugins']);
+ $this->_create_folder('acl');
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/acl/role_' . $role['id'] . '.php',
+ array_to_cache("setting['current_role']",$role));
+ }
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新站点信息缓存
+ *
+ * @access public
+ * @return void
+ */
+ public function update_site_cache()
+ {
+ $data = $this->db->get($this->db->dbprefix('site_settings'))->row_array();
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/site.php',
+ array_to_cache("setting", $data));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新后台设置缓存
+ *
+ * @access public
+ * @return void
+ */
+ public function update_backend_cache()
+ {
+ $data = $this->db->get($this->db->dbprefix('backend_settings'))->row_array();
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/backend.php',
+ array_to_cache("setting", $data));
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新插件信息缓存
+ *
+ * @access public
+ * @return void
+ */
+ public function update_plugin_cache()
+ {
+ $cached_plugins = array();
+ $plugins = $this->db->select('name, access')
+ ->where('active', '1')
+ ->get($this->db->dbprefix('plugins'))
+ ->result_array();
+ if ($plugins)
+ {
+ foreach ($plugins as $key => $plugin)
+ {
+ if (! isset($cached_plugins[$plugin['name']])) {
+ $cached_plugins[$plugin['name']] = array(
+ 'classmap' => array(),
+ 'menus' => array(),
+ 'access' => $plugin['access']
+ );
+ }
+
+ $this_plugin_path = DILICMS_EXTENSION_PATH.'plugins/'.$plugin['name'].'/';
+
+ $this_hook_path = 'plugins/'.$plugin['name'].'/hooks/';
+
+ if (file_exists($this_plugin_path.'hooks')) {
+ foreach (glob($this_plugin_path.'hooks/'.$plugin['name']."_hook_*.php") as $filename) {
+ $filename = basename($filename);
+ $model = str_replace(array('.php', $plugin['name']."_hook_"), array('', ''), $filename);
+ $cached_plugins[$plugin['name']]['classmap'][$model] = $this_hook_path.$filename;
+ }
+ }
+
+ if (file_exists($this_plugin_path.'menus.php')) {
+ $this_plugin_menus = include ($this_plugin_path.'menus.php');
+ $cached_plugins[$plugin['name']]['menus'] = $this_plugin_menus;
+ }
+
+
+ }
+ }
+
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/plugins.php',
+ array_to_cache("setting['plugins']", $cached_plugins));
+
+
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * 更新字段类型缓存
+ *
+ * @access public
+ * @return void
+ */
+ public function update_fieldtypes_cache()
+ {
+ $cached_fieldtypes = array();
+ $cached_fieldtypes['fieldtypes'] = array();
+ $cached_fieldtypes['extra_fieldtypes'] = array();
+ $cached_fieldtypes['validation'] = array();
+ $results = $this->db->get($this->db->dbprefix('fieldtypes'))->result_array();
+ foreach ($results as $v)
+ {
+ $cached_fieldtypes['fieldtypes'][$v['k']] = $v['v'];
+ }
+ $results = $this->db->get($this->db->dbprefix('validations'))->result_array();
+ foreach ($results as $v)
+ {
+ $cached_fieldtypes['validation'][$v['k']] = $v['v'];
+ }
+ $extra_path = DILICMS_EXTENSION_PATH . 'fields/';
+ $this->load->helper('file');
+ $extra_files = get_filenames($extra_path);
+ foreach ($extra_files as $v)
+ {
+ if (preg_match("/^field_(.*?)\.php$/", $v))
+ {
+ include $extra_path . $v;
+ if (class_exists($extra_class = str_replace('.php', '', $v)))
+ {
+ $tmp = new $extra_class();
+ $cached_fieldtypes['extra_fieldtypes'][$tmp->k] = $tmp->v;
+ }
+ }
+ }
+ $this->platform->cache_write(DILICMS_SHARE_PATH . 'settings/fieldtypes.php',
+ array_to_cache("setting",$cached_fieldtypes));
+ }
+
+ // ------------------------------------------------------------------------
+
+}
+
+/* End of file cache_mdl.php */
/* Location: ./shared/models/cache_mdl.php */
\ No newline at end of file