Browse Source

Themes are now plugins, this unifies the intallation experience and
loading syntax

Jose Lorenzo Rodriguez 12 years ago
parent
commit
5f6022557f

+ 11 - 10
src/View/View.php

@@ -1096,9 +1096,7 @@ class View {
 		if (!empty($plugin)) {
 			$count = count($viewPaths);
 			for ($i = 0; $i < $count; $i++) {
-				if (!in_array($viewPaths[$i], $corePaths)) {
-					$paths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS;
-				}
+				$paths[] = $viewPaths[$i] . 'Plugin' . DS . $plugin . DS;
 			}
 			$paths = array_merge($paths, App::path('Template', $plugin));
 		}
@@ -1106,21 +1104,24 @@ class View {
 		$paths = array_unique(array_merge($paths, $viewPaths));
 		if (!empty($this->theme)) {
 			$theme = Inflector::camelize($this->theme);
-			$themePaths = array();
-			foreach ($paths as $path) {
-				if (strpos($path, DS . 'Plugin' . DS) === false) {
-					if ($plugin) {
-						$themePaths[] = $path . 'Themed' . DS . $theme . DS . 'Plugin' . DS . $plugin . DS;
-					}
-					$themePaths[] = $path . 'Themed' . DS . $theme . DS;
+			$themePaths = App::path('Template', $theme);
+
+			if ($plugin) {
+				$count = count($viewPaths);
+				for ($i = 0; $i < $count; $i++) {
+					$themePaths[] = $themePaths[$i] . 'Plugin' . DS . $plugin . DS;
 				}
 			}
+
 			$paths = array_merge($themePaths, $paths);
 		}
+
 		$paths = array_merge($paths, $corePaths);
+
 		if ($plugin !== null) {
 			return $this->_pathsForPlugin[$plugin] = $paths;
 		}
+
 		return $this->_paths = $paths;
 	}
 

+ 4 - 7
tests/TestCase/View/ViewTest.php

@@ -272,7 +272,7 @@ class ViewTest extends TestCase {
 
 		App::objects('Plugin', null, false);
 
-		Plugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs'));
+		Plugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs', 'TestTheme'));
 		Configure::write('debug', true);
 	}
 
@@ -314,11 +314,11 @@ class ViewTest extends TestCase {
 		$result = $ThemeView->getViewFileName('home');
 		$this->assertPathEquals($expected, $result);
 
-		$expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS . 'index.ctp';
+		$expected = Plugin::path('TestTheme') . 'Template' . DS . 'Posts' . DS . 'index.ctp';
 		$result = $ThemeView->getViewFileName('/Posts/index');
 		$this->assertPathEquals($expected, $result);
 
-		$expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layout' . DS . 'default.ctp';
+		$expected =  Plugin::path('TestTheme') . 'Template' . DS . 'Layout' . DS . 'default.ctp';
 		$result = $ThemeView->getLayoutFileName();
 		$this->assertPathEquals($expected, $result);
 
@@ -370,7 +370,7 @@ class ViewTest extends TestCase {
 		];
 
 		$ThemeView = new TestThemeView(null, null, null, $viewOptions);
-		$themePath = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Themed' . DS . 'TestTheme' . DS;
+		$themePath =  Plugin::path('TestTheme') . 'Template' . DS;
 
 		$expected = $themePath . 'Plugin' . DS . 'TestPlugin' . DS . 'Tests' . DS . 'index.ctp';
 		$result = $ThemeView->getViewFileName('index');
@@ -1052,9 +1052,6 @@ class ViewTest extends TestCase {
 		$result = $View->getViewFileName('../Element/test_element');
 		$this->assertRegExp('/Element(\/|\\\)test_element.ctp/', $result);
 
-		$result = $View->getViewFileName('../Themed/TestTheme/Posts/index');
-		$this->assertRegExp('/Themed(\/|\\\)TestTheme(\/|\\\)Posts(\/|\\\)index.ctp/', $result);
-
 		$expected = TEST_APP . 'TestApp' . DS . 'Template' . DS . 'Posts' . DS . 'index.ctp';
 		$result = $View->getViewFileName('../Posts/index');
 		$this->assertPathEquals($expected, $result);

tests/test_app/TestApp/Template/Themed/TestTheme/Cell/Articles/display.ctp → tests/test_app/Plugin/TestTheme/Template/Cell/Articles/display.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Element/test_element.ctp → tests/test_app/Plugin/TestTheme/Template/Element/test_element.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Email/text/themed.ctp → tests/test_app/Plugin/TestTheme/Template/Email/text/themed.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Layout/default.ctp → tests/test_app/Plugin/TestTheme/Template/Layout/default.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Plugin/TestPlugin/Email/text/test_plugin_tpl.ctp → tests/test_app/Plugin/TestTheme/Template/Plugin/TestPlugin/Email/text/test_plugin_tpl.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Plugin/TestPlugin/Layout/plugin_default.ctp → tests/test_app/Plugin/TestTheme/Template/Plugin/TestPlugin/Layout/plugin_default.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Plugin/TestPlugin/Tests/index.ctp → tests/test_app/Plugin/TestTheme/Template/Plugin/TestPlugin/Tests/index.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Posts/index.ctp → tests/test_app/Plugin/TestTheme/Template/Posts/index.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/Posts/themed.ctp → tests/test_app/Plugin/TestTheme/Template/Posts/themed.ctp


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/css/test_asset.css → tests/test_app/Plugin/TestTheme/webroot/css/test_asset.css


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/css/theme_webroot.css → tests/test_app/Plugin/TestTheme/webroot/css/theme_webroot.css


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/flash/theme_test.swf → tests/test_app/Plugin/TestTheme/webroot/flash/theme_test.swf


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/img/cake.power.gif → tests/test_app/Plugin/TestTheme/webroot/img/cake.power.gif


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/img/test.jpg → tests/test_app/Plugin/TestTheme/webroot/img/test.jpg


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/js/one/theme_one.js → tests/test_app/Plugin/TestTheme/webroot/js/one/theme_one.js


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/js/theme.js → tests/test_app/Plugin/TestTheme/webroot/js/theme.js


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/pdfs/theme_test.pdf → tests/test_app/Plugin/TestTheme/webroot/pdfs/theme_test.pdf


tests/test_app/TestApp/Template/Themed/TestTheme/webroot/space image.text → tests/test_app/Plugin/TestTheme/webroot/space image.text