From 948f6b21e5ecb35f361b0a3a043314676f46889c Mon Sep 17 00:00:00 2001 From: phpnut Date: Wed, 25 Nov 2009 22:58:02 -0600 Subject: [PATCH] Refactored last commit changes are: To override plugin views with a themed version of the view you would create: /views/themed//plugins///*.ctp To override plugin views at the app view level you would create: /views/plugins///*.ctp --- cake/libs/view/theme.php | 5 +++-- cake/libs/view/view.php | 2 +- cake/tests/cases/libs/view/theme.test.php | 4 ++-- .../test_theme/{ => plugins}/test_plugin/layouts/default.ctp | 0 .../test_theme/{ => plugins}/test_plugin/tests/index.ctp | 0 5 files changed, 6 insertions(+), 5 deletions(-) rename cake/tests/test_app/views/themed/test_theme/{ => plugins}/test_plugin/layouts/default.ctp (100%) rename cake/tests/test_app/views/themed/test_theme/{ => plugins}/test_plugin/tests/index.ctp (100%) diff --git a/cake/libs/view/theme.php b/cake/libs/view/theme.php index c2531f442..57642f358 100644 --- a/cake/libs/view/theme.php +++ b/cake/libs/view/theme.php @@ -59,9 +59,10 @@ class ThemeView extends View { && strpos($paths[$i], DS . 'libs' . DS . 'view') === false && strpos($paths[$i], DS . $plugin . DS) === false) { if ($plugin) { - $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . $plugin . DS; + $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . 'plugins' . DS . $plugin . DS; + } else { + $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS; } - $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS; } } $paths = array_merge($themePaths, $paths); diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index f25c84838..854bcc1e5 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -939,7 +939,7 @@ class View extends Object { $count = count($viewPaths); for ($i = 0; $i < $count; $i++) { if (!isset($corePaths[$viewPaths[$i]])) { - $paths[] = $viewPaths[$i] . $plugin . DS; + $paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS; } } $paths[] = App::pluginPath($plugin) . 'views' . DS; diff --git a/cake/tests/cases/libs/view/theme.test.php b/cake/tests/cases/libs/view/theme.test.php index a40b2323b..5a9d09a70 100644 --- a/cake/tests/cases/libs/view/theme.test.php +++ b/cake/tests/cases/libs/view/theme.test.php @@ -207,11 +207,11 @@ class ThemeViewTest extends CakeTestCase { $this->Controller->theme = 'test_theme'; $ThemeView = new TestThemeView($this->Controller); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp'; + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp'; $result = $ThemeView->getViewFileName('index'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'test_plugin' . DS . 'layouts' . DS .'default.ctp'; + $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEqual($result, $expected); } diff --git a/cake/tests/test_app/views/themed/test_theme/test_plugin/layouts/default.ctp b/cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/layouts/default.ctp similarity index 100% rename from cake/tests/test_app/views/themed/test_theme/test_plugin/layouts/default.ctp rename to cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/layouts/default.ctp diff --git a/cake/tests/test_app/views/themed/test_theme/test_plugin/tests/index.ctp b/cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/tests/index.ctp similarity index 100% rename from cake/tests/test_app/views/themed/test_theme/test_plugin/tests/index.ctp rename to cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/tests/index.ctp