Browse Source

Making themes also CamelCased

Jose Lorenzo Rodriguez 15 years ago
parent
commit
6713bb154e

+ 2 - 2
lib/Cake/Core/App.php

@@ -387,11 +387,11 @@ class App {
  *
  * `App::themePath('MyTheme'); will return the full path to the 'MyTheme' theme`
  *
- * @param string $theme lower_cased theme name to find the path of.
+ * @param string $theme theme name to find the path of.
  * @return string full path to the theme.
  */
 	public static function themePath($theme) {
-		$themeDir = 'themed' . DS . Inflector::underscore($theme);
+		$themeDir = 'Themed' . DS . Inflector::camelize($theme);
 		foreach (self::$__packages['View'] as $path) {
 			if (is_dir($path . $themeDir)) {
 				return $path . $themeDir . DS ;

+ 2 - 2
lib/Cake/Test/Case/Core/AppTest.php

@@ -393,11 +393,11 @@ class AppImportTest extends CakeTestCase {
 			'View' => array(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS)
 		));
 		$path = App::themePath('test_theme');
-		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS;
+		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS;
 		$this->assertEqual($path, $expected);
 
 		$path = App::themePath('TestTheme');
-		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS;
+		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS;
 		$this->assertEqual($path, $expected);
 
 		App::build();

+ 3 - 3
lib/Cake/Test/Case/Routing/DispatcherTest.php

@@ -1227,21 +1227,21 @@ class DispatcherTest extends CakeTestCase {
 		$Dispatcher->dispatch(new CakeRequest('theme/test_theme/flash/theme_test.swf'));
 		$result = ob_get_clean();
 
-		$file = file_get_contents(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
+		$file = file_get_contents(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
 		$this->assertEqual($file, $result);
 		$this->assertEqual('this is just a test to load swf file from the theme.', $result);
 
 		ob_start();
 		$Dispatcher->dispatch(new CakeRequest('theme/test_theme/pdfs/theme_test.pdf'));
 		$result = ob_get_clean();
-		$file = file_get_contents(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
+		$file = file_get_contents(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
 		$this->assertEqual($file, $result);
 		$this->assertEqual('this is just a test to load pdf file from the theme.', $result);
 
 		ob_start();
 		$Dispatcher->dispatch(new CakeRequest('theme/test_theme/img/test.jpg'));
 		$result = ob_get_clean();
-		$file = file_get_contents(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
+		$file = file_get_contents(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
 		$this->assertEqual($file, $result);
 
 		ob_start();

+ 8 - 8
lib/Cake/Test/Case/View/ThemeViewTest.php

@@ -149,18 +149,18 @@ class ThemeViewTest extends CakeTestCase {
 		$this->Controller->name = 'TestPlugin';
 		$this->Controller->viewPath = 'Tests';
 		$this->Controller->action = 'index';
-		$this->Controller->theme = 'test_theme';
+		$this->Controller->theme = 'TestTheme';
 
 		$ThemeView = new TestThemeView($this->Controller);
-		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'Plugins' . DS . 'TestPlugin' . DS . 'Tests' . DS .'index.ctp';
+		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugins' . DS . 'TestPlugin' . DS . 'Tests' . DS .'index.ctp';
 		$result = $ThemeView->getViewFileName('index');
 		$this->assertEqual($result, $expected);
 
-		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'Plugins' . DS . 'TestPlugin' . DS . 'Layouts' . DS .'plugin_default.ctp';
+		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Plugins' . DS . 'TestPlugin' . DS . 'Layouts' . DS .'plugin_default.ctp';
 		$result = $ThemeView->getLayoutFileName('plugin_default');
 		$this->assertEqual($result, $expected);
 
-		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'Layouts' . DS .'default.ctp';
+		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
 		$result = $ThemeView->getLayoutFileName('default');
 		$this->assertEqual($result, $expected);
 	}
@@ -179,16 +179,16 @@ class ThemeViewTest extends CakeTestCase {
 		$this->Controller->params['pass'] = array('home');
 
 		$ThemeView = new TestThemeView($this->Controller);
-		$ThemeView->theme = 'test_theme';
+		$ThemeView->theme = 'TestTheme';
 		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
 		$result = $ThemeView->getViewFileName('home');
 		$this->assertEqual($result, $expected);
 
-		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'Posts' . DS .'index.ctp';
+		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Posts' . DS .'index.ctp';
 		$result = $ThemeView->getViewFileName('/Posts/index');
 		$this->assertEqual($result, $expected);
 
-		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'test_theme' . DS . 'Layouts' . DS .'default.ctp';
+		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS . 'Layouts' . DS .'default.ctp';
 		$result = $ThemeView->getLayoutFileName();
 		$this->assertEqual($result, $expected);
 
@@ -259,7 +259,7 @@ class ThemeViewTest extends CakeTestCase {
 		$this->Controller->name = 'Posts';
 		$this->Controller->viewPath = 'posts';
 		$this->Controller->layout = 'whatever';
-		$this->Controller->theme = 'test_theme';
+		$this->Controller->theme = 'TestTheme';
 
 		$View = new ThemeView($this->Controller);
 		$View->element('test_element');

+ 6 - 6
lib/Cake/Test/Case/View/ViewTest.php

@@ -753,14 +753,14 @@ class ViewTest extends CakeTestCase {
 		$result = $View->getViewFileName('index');
 		$this->assertPattern('/posts(\/|\\\)index.ctp/', $result);
 
-		$result = $View->getViewFileName('/pages/home');
-		$this->assertPattern('/pages(\/|\\\)home.ctp/', $result);
+		$result = $View->getViewFileName('/Pages/home');
+		$this->assertPattern('/Pages(\/|\\\)home.ctp/', $result);
 
-		$result = $View->getViewFileName('../elements/test_element');
-		$this->assertPattern('/elements(\/|\\\)test_element.ctp/', $result);
+		$result = $View->getViewFileName('../Elements/test_element');
+		$this->assertPattern('/Elements(\/|\\\)test_element.ctp/', $result);
 
-		$result = $View->getViewFileName('../themed/test_theme/posts/index');
-		$this->assertPattern('/themed(\/|\\\)test_theme(\/|\\\)posts(\/|\\\)index.ctp/', $result);
+		$result = $View->getViewFileName('../Themed/TestTheme/Posts/index');
+		$this->assertPattern('/Themed(\/|\\\)TestTheme(\/|\\\)Posts(\/|\\\)index.ctp/', $result);
 
 		$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
 		$result = $View->getViewFileName('../Posts/index');

lib/Cake/Test/test_app/View/Themed/test_theme/Elements/test_element.ctp → lib/Cake/Test/test_app/View/Themed/TestTheme/Elements/test_element.ctp


lib/Cake/Test/test_app/View/Themed/test_theme/Layouts/default.ctp → lib/Cake/Test/test_app/View/Themed/TestTheme/Layouts/default.ctp


lib/Cake/Test/test_app/View/Themed/test_theme/Posts/index.ctp → lib/Cake/Test/test_app/View/Themed/TestTheme/Posts/index.ctp


lib/Cake/Test/test_app/View/Themed/test_theme/Posts/scaffold.index.ctp → lib/Cake/Test/test_app/View/Themed/TestTheme/Posts/scaffold.index.ctp


lib/Cake/Test/test_app/View/Themed/test_theme/plugins/TestPlugin/Layouts/plugin_default.ctp → lib/Cake/Test/test_app/View/Themed/TestTheme/plugins/TestPlugin/Layouts/plugin_default.ctp


lib/Cake/Test/test_app/View/Themed/test_theme/plugins/TestPlugin/tests/index.ctp → lib/Cake/Test/test_app/View/Themed/TestTheme/plugins/TestPlugin/tests/index.ctp


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/css/test_asset.css → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/css/test_asset.css


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/css/theme_webroot.css → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/css/theme_webroot.css


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/flash/theme_test.swf → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/flash/theme_test.swf


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/img/cake.power.gif → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/img/cake.power.gif


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/img/test.jpg → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/img/test.jpg


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/js/one/theme_one.js → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/js/one/theme_one.js


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/js/theme.js → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/js/theme.js


lib/Cake/Test/test_app/View/Themed/test_theme/webroot/pdfs/theme_test.pdf → lib/Cake/Test/test_app/View/Themed/TestTheme/webroot/pdfs/theme_test.pdf


+ 4 - 9
lib/Cake/View/Helper.php

@@ -211,15 +211,10 @@ class Helper extends Object {
 			if (file_exists(Configure::read('App.www_root') . 'theme' . DS . $this->theme . DS  . $file)) {
 				$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
 			} else {
-				$viewPaths = App::path('views');
-
-				foreach ($viewPaths as $viewPath) {
-					$path = $viewPath . 'themed'. DS . $this->theme . DS  . 'webroot' . DS  . $file;
-
-					if (file_exists($path)) {
-						$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
-						break;
-					}
+				$themePath = App::themePath($this->theme);
+				$path = $themePath . 'webroot' . DS  . $file;
+				if (file_exists($path)) {
+					$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
 				}
 			}
 		}