Making themes also CamelCased

This commit is contained in:
Jose Lorenzo Rodriguez 2011-05-15 00:08:01 -04:30
parent 1930452da0
commit 6713bb154e
20 changed files with 25 additions and 30 deletions

View file

@ -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 ;

View file

@ -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();

View file

@ -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();

View file

@ -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');

View file

@ -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');

View file

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

@ -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];
}
}
}