mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Making themes also CamelCased
This commit is contained in:
parent
1930452da0
commit
6713bb154e
20 changed files with 25 additions and 30 deletions
|
@ -387,11 +387,11 @@ class App {
|
||||||
*
|
*
|
||||||
* `App::themePath('MyTheme'); will return the full path to the 'MyTheme' theme`
|
* `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.
|
* @return string full path to the theme.
|
||||||
*/
|
*/
|
||||||
public static function themePath($theme) {
|
public static function themePath($theme) {
|
||||||
$themeDir = 'themed' . DS . Inflector::underscore($theme);
|
$themeDir = 'Themed' . DS . Inflector::camelize($theme);
|
||||||
foreach (self::$__packages['View'] as $path) {
|
foreach (self::$__packages['View'] as $path) {
|
||||||
if (is_dir($path . $themeDir)) {
|
if (is_dir($path . $themeDir)) {
|
||||||
return $path . $themeDir . DS ;
|
return $path . $themeDir . DS ;
|
||||||
|
|
|
@ -393,11 +393,11 @@ class AppImportTest extends CakeTestCase {
|
||||||
'View' => array(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS)
|
'View' => array(LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS)
|
||||||
));
|
));
|
||||||
$path = App::themePath('test_theme');
|
$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);
|
$this->assertEqual($path, $expected);
|
||||||
|
|
||||||
$path = App::themePath('TestTheme');
|
$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);
|
$this->assertEqual($path, $expected);
|
||||||
|
|
||||||
App::build();
|
App::build();
|
||||||
|
|
|
@ -1227,21 +1227,21 @@ class DispatcherTest extends CakeTestCase {
|
||||||
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/flash/theme_test.swf'));
|
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/flash/theme_test.swf'));
|
||||||
$result = ob_get_clean();
|
$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($file, $result);
|
||||||
$this->assertEqual('this is just a test to load swf file from the theme.', $result);
|
$this->assertEqual('this is just a test to load swf file from the theme.', $result);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/pdfs/theme_test.pdf'));
|
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/pdfs/theme_test.pdf'));
|
||||||
$result = ob_get_clean();
|
$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($file, $result);
|
||||||
$this->assertEqual('this is just a test to load pdf file from the theme.', $result);
|
$this->assertEqual('this is just a test to load pdf file from the theme.', $result);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/img/test.jpg'));
|
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/img/test.jpg'));
|
||||||
$result = ob_get_clean();
|
$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);
|
$this->assertEqual($file, $result);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
|
@ -149,18 +149,18 @@ class ThemeViewTest extends CakeTestCase {
|
||||||
$this->Controller->name = 'TestPlugin';
|
$this->Controller->name = 'TestPlugin';
|
||||||
$this->Controller->viewPath = 'Tests';
|
$this->Controller->viewPath = 'Tests';
|
||||||
$this->Controller->action = 'index';
|
$this->Controller->action = 'index';
|
||||||
$this->Controller->theme = 'test_theme';
|
$this->Controller->theme = 'TestTheme';
|
||||||
|
|
||||||
$ThemeView = new TestThemeView($this->Controller);
|
$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');
|
$result = $ThemeView->getViewFileName('index');
|
||||||
$this->assertEqual($result, $expected);
|
$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');
|
$result = $ThemeView->getLayoutFileName('plugin_default');
|
||||||
$this->assertEqual($result, $expected);
|
$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');
|
$result = $ThemeView->getLayoutFileName('default');
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
@ -179,16 +179,16 @@ class ThemeViewTest extends CakeTestCase {
|
||||||
$this->Controller->params['pass'] = array('home');
|
$this->Controller->params['pass'] = array('home');
|
||||||
|
|
||||||
$ThemeView = new TestThemeView($this->Controller);
|
$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';
|
$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Pages' . DS .'home.ctp';
|
||||||
$result = $ThemeView->getViewFileName('home');
|
$result = $ThemeView->getViewFileName('home');
|
||||||
$this->assertEqual($result, $expected);
|
$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');
|
$result = $ThemeView->getViewFileName('/Posts/index');
|
||||||
$this->assertEqual($result, $expected);
|
$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();
|
$result = $ThemeView->getLayoutFileName();
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ class ThemeViewTest extends CakeTestCase {
|
||||||
$this->Controller->name = 'Posts';
|
$this->Controller->name = 'Posts';
|
||||||
$this->Controller->viewPath = 'posts';
|
$this->Controller->viewPath = 'posts';
|
||||||
$this->Controller->layout = 'whatever';
|
$this->Controller->layout = 'whatever';
|
||||||
$this->Controller->theme = 'test_theme';
|
$this->Controller->theme = 'TestTheme';
|
||||||
|
|
||||||
$View = new ThemeView($this->Controller);
|
$View = new ThemeView($this->Controller);
|
||||||
$View->element('test_element');
|
$View->element('test_element');
|
||||||
|
|
|
@ -753,14 +753,14 @@ class ViewTest extends CakeTestCase {
|
||||||
$result = $View->getViewFileName('index');
|
$result = $View->getViewFileName('index');
|
||||||
$this->assertPattern('/posts(\/|\\\)index.ctp/', $result);
|
$this->assertPattern('/posts(\/|\\\)index.ctp/', $result);
|
||||||
|
|
||||||
$result = $View->getViewFileName('/pages/home');
|
$result = $View->getViewFileName('/Pages/home');
|
||||||
$this->assertPattern('/pages(\/|\\\)home.ctp/', $result);
|
$this->assertPattern('/Pages(\/|\\\)home.ctp/', $result);
|
||||||
|
|
||||||
$result = $View->getViewFileName('../elements/test_element');
|
$result = $View->getViewFileName('../Elements/test_element');
|
||||||
$this->assertPattern('/elements(\/|\\\)test_element.ctp/', $result);
|
$this->assertPattern('/Elements(\/|\\\)test_element.ctp/', $result);
|
||||||
|
|
||||||
$result = $View->getViewFileName('../themed/test_theme/posts/index');
|
$result = $View->getViewFileName('../Themed/TestTheme/Posts/index');
|
||||||
$this->assertPattern('/themed(\/|\\\)test_theme(\/|\\\)posts(\/|\\\)index.ctp/', $result);
|
$this->assertPattern('/Themed(\/|\\\)TestTheme(\/|\\\)Posts(\/|\\\)index.ctp/', $result);
|
||||||
|
|
||||||
$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
|
$expected = LIBS . 'Test' . DS . 'test_app' . DS . 'View' . DS .'Posts' . DS .'index.ctp';
|
||||||
$result = $View->getViewFileName('../Posts/index');
|
$result = $View->getViewFileName('../Posts/index');
|
||||||
|
|
Before Width: | Height: | Size: 201 B After Width: | Height: | Size: 201 B |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
@ -211,15 +211,10 @@ class Helper extends Object {
|
||||||
if (file_exists(Configure::read('App.www_root') . 'theme' . DS . $this->theme . DS . $file)) {
|
if (file_exists(Configure::read('App.www_root') . 'theme' . DS . $this->theme . DS . $file)) {
|
||||||
$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
|
$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
|
||||||
} else {
|
} else {
|
||||||
$viewPaths = App::path('views');
|
$themePath = App::themePath($this->theme);
|
||||||
|
$path = $themePath . 'webroot' . DS . $file;
|
||||||
foreach ($viewPaths as $viewPath) {
|
|
||||||
$path = $viewPath . 'themed'. DS . $this->theme . DS . 'webroot' . DS . $file;
|
|
||||||
|
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
|
$webPath = "{$this->request->webroot}theme/" . $theme . $asset[0];
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue