From d09a48d88244467618cd60a19b8988687aee558f Mon Sep 17 00:00:00 2001 From: phpnut Date: Fri, 3 Feb 2006 03:46:27 +0000 Subject: [PATCH] Merging fixes and enhancements into trunk Revision: [1912] Adding more work arounds for using plugins. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1913 3807eeeb-6ff5-0310-8944-8be069107fe0 --- VERSION.txt | 2 +- cake/basics.php | 38 +++++++++++++++++++++++++++++--------- cake/dispatcher.php | 5 +++-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 7c9256ed3..607b2bde5 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -6,4 +6,4 @@ // +---------------------------------------------------------------------------------------------------+ // /////////////////////////////////////////////////////////////////////////////////////////////////////////// -0.10.8.1911 RC 4 \ No newline at end of file +0.10.8.1913 RC 4 \ No newline at end of file diff --git a/cake/basics.php b/cake/basics.php index 54387f6dd..7ba9b4d6e 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -97,7 +97,27 @@ function loadModels() */ function loadPluginModels ($plugin) { - $pluginModelDir = APP.'plugins'.DS.$plugin.'models'.DS; + $pluginAppModel = Inflector::camelize($plugin.'_app_model'); + $pluginAppModelFile = APP.'plugins'.DS.$plugin.DS.$plugin.'_app_model.php'; + + if(!class_exists($pluginAppModel)) + { + if(file_exists($pluginAppModelFile)) + { + require_once($pluginAppModelFile); + } + else + { + die('Plugins must have a class named '. $pluginAppModel); + } + } + + if (phpversion() < 5 && function_exists("overload")) + { + overload($pluginAppModel); + } + + $pluginModelDir = APP.'plugins'.DS.$plugin.DS.'models'.DS; foreach (listClasses($pluginModelDir) as $modelFileName) { @@ -252,19 +272,19 @@ function loadController ($name) */ function loadPluginController ($plugin, $controller) { - if(!class_exists('AppController')) + + $pluginAppController = Inflector::camelize($plugin.'_app_controller'); + $pluginAppControllerFile = APP.'plugins'.DS.$plugin.DS.$plugin.'_app_controller.php'; + + if(!class_exists($pluginAppController)) { - if(file_exists(APP.'plugins'.DS.$plugin.DS.'app_controller.php')) + if(file_exists($pluginAppControllerFile)) { - require_once(APP.'plugins'.DS.$plugin.DS.'app_controller.php'); - } - elseif(file_exists(APP.'app_controller.php')) - { - require_once(APP.'app_controller.php'); + require_once($pluginAppControllerFile); } else { - require_once(CAKE.'app_controller.php'); + die('Plugins must have a class named '. $pluginAppController); } } diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 86cc89d33..dc3e7153a 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -126,8 +126,9 @@ class Dispatcher extends Object { $ctrlClass = $pluginClass; $params = $this->_restructureParams($params); - $this->plugin = Inflector::underscore($ctrlName).DS; - loadPluginModels($this->plugin); + $plugin = Inflector::underscore($ctrlName); + $this->plugin = $plugin.DS; + loadPluginModels($plugin); $this->base = $this->base.'/'.Inflector::underscore($ctrlName); } }