From 7bc90a2eb19a2c59499796c6a5779c5bfa33c4cc Mon Sep 17 00:00:00 2001 From: phpnut Date: Sat, 27 Oct 2007 03:27:09 +0000 Subject: [PATCH] Fixes #3474, Plugin Models Not Loading for 1.2.0.5875 pre-beta release. Remove deprecated loadPluginController() from basics.php Fixed changed loadPluginController to loadController in CacheHelper git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5905 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/basics.php | 65 +++-------------------------- cake/libs/controller/controller.php | 5 +++ cake/libs/view/helpers/cache.php | 2 +- 3 files changed, 11 insertions(+), 61 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index 912b025a7..bda0a6f6c 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -108,9 +108,10 @@ if (!class_exists('AppModel')) { loadModel(); } - + $plugin = Inflector::underscore($plugin); $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($pluginAppModelFile); @@ -192,9 +193,10 @@ if (strpos($name, '.') !== false) { list($plugin, $name) = explode('.', $name); - + $plugin = Inflector::underscore($plugin); $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($pluginAppModelFile); @@ -357,12 +359,7 @@ } if (empty($name)) { - if (!class_exists(Inflector::camelize($plugin . 'Controller'))) { - if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) { - require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php'); - return true; - } - } + return false; } if (!class_exists($name . 'Controller')) { @@ -371,11 +368,6 @@ if (file_exists($file)) { require($file); return true; - } elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')) { - if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) { - require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php'); - return true; - } } return false; } @@ -419,53 +411,6 @@ } return false; } -/** - * Loads a plugin's controller. - * - * @param string $plugin Name of plugin - * @param string $controller Name of controller to load - * @return boolean Success - * @deprecated - */ - function loadPluginController($plugin, $controller) { - $pluginAppController = Inflector::camelize($plugin . '_app_controller'); - $plugin = Inflector::underscore($plugin); - $pluginAppControllerFile = APP . 'plugins' . DS . $plugin . DS . $plugin . '_app_controller.php'; - if (!class_exists($pluginAppController)) { - if (file_exists($pluginAppControllerFile)) { - require($pluginAppControllerFile); - } else { - return false; - } - } - - if (empty($controller)) { - if (!class_exists(Inflector::camelize($plugin . 'controller'))) { - if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) { - require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php'); - return true; - } - } - } - - if (!class_exists($controller . 'Controller')) { - $controller = Inflector::underscore($controller); - $file = APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $controller . '_controller.php'; - - if (file_exists($file)) { - require($file); - return true; - } elseif (!class_exists(Inflector::camelize($plugin) . 'Controller')) { - if (file_exists(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php')) { - require(APP . 'plugins' . DS . $plugin . DS . 'controllers' . DS . $plugin . '_controller.php'); - return true; - } else { - return false; - } - } - } - return true; - } /** * Loads a helper * diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 1a7f393cb..b5eadce7e 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -375,6 +375,11 @@ class Controller extends Object { $plugin = $this->plugin . '.'; } + if (strpos($modelClass, '.') !== false) { + list($plugin, $modelClass) = explode('.', $modelClass); + $plugin = $plugin . '.'; + } + $modelKey = Inflector::underscore($modelClass); if (!class_exists($modelClass)) { diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 815497bb7..fae916a1d 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -223,7 +223,7 @@ class CacheHelper extends AppHelper { require(\''.CAKE . 'app_controller.php\'); } } - loadPluginController(\''.$this->plugin.'\',\''.$this->controllerName.'\'); + loadController(\'' . $this->plugin . '.' . $this->controllerName . '\'); loadPluginModels(\''.$this->plugin.'\'); '; }