Removing unneeded code in Dispatcher::cached();

Fixing path search for themes
This commit is contained in:
phpnut 2009-11-27 00:49:20 -06:00
parent 21d2226f75
commit 43fdde2dad
6 changed files with 42 additions and 28 deletions

View file

@ -123,13 +123,11 @@ class Dispatcher extends Object {
$url = $this->getUrl();
$this->params = array_merge($this->parseParams($url), $additionalParams);
}
$this->here = $this->base . '/' . $url;
if ($this->cached($url)) {
$this->_stop();
}
$controller =& $this->__getController();
if (!is_object($controller)) {
@ -141,7 +139,6 @@ class Dispatcher extends Object {
'base' => $this->base
)));
}
$privateAction = $this->params['action'][0] === '_';
$prefixes = Router::prefixes();
@ -167,7 +164,6 @@ class Dispatcher extends Object {
'base' => $this->base
)));
}
$controller->base = $this->base;
$controller->here = $this->here;
$controller->webroot = $this->webroot;
@ -615,9 +611,8 @@ class Dispatcher extends Object {
if (isset($Media->mimeType[$ext])) {
$pos = 0;
$parts = explode('/', $url);
if ($parts[0] === 'css' || $parts[0] === 'js' || $parts[0] === 'img') {
$pos = 0;
} elseif ($parts[0] === 'theme') {
if ($parts[0] === 'theme') {
$pos = strlen($parts[0] . $parts[1]) + 1;
} elseif (count($parts) > 2) {
$pos = strlen($parts[0]);

View file

@ -56,8 +56,7 @@ class ThemeView extends View {
$count = count($paths);
for ($i = 0; $i < $count; $i++) {
if (strpos($paths[$i], DS . 'plugins' . DS) === false
&& strpos($paths[$i], DS . 'libs' . DS . 'view') === false
&& strpos($paths[$i], DS . $plugin . DS) === false) {
&& strpos($paths[$i], DS . 'libs' . DS . 'view') === false) {
if ($plugin) {
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . 'plugins' . DS . $plugin . DS;
}

View file

@ -1811,13 +1811,24 @@ class DispatcherTest extends CakeTestCase {
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
$this->assertEqual($file, $result);
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/css/test_asset.css');
ob_start();
$Dispatcher->cached('theme/test_theme/css/test_asset.css');
$result = ob_get_clean();
$this->assertEqual('this is the test asset css file', $result);
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/theme.js');
ob_start();
$Dispatcher->cached('theme/test_theme/js/theme.js');
$result = ob_get_clean();
$this->assertEqual('root theme js file', $result);
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/one/theme_one.js');
ob_start();
$Dispatcher->cached('theme/test_theme/js/one/theme_one.js');
$result = ob_get_clean();
$this->assertEqual('nested theme js file', $result);
ob_start();
$Dispatcher->dispatch('test_plugin/flash/plugin_test.swf');
$result = ob_get_clean();
@ -1856,8 +1867,6 @@ class DispatcherTest extends CakeTestCase {
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'webroot' . DS . 'img' . DS . 'cake.icon.gif');
$this->assertEqual($file, $result);
Configure::write('debug', $debug);
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js');
ob_start();
$Dispatcher->cached('plugin_js/js/plugin_js.js');
@ -1865,7 +1874,15 @@ class DispatcherTest extends CakeTestCase {
$expected = "alert('win sauce');";
$this->assertEqual($result, $expected);
header('Content-type: text/html');//reset the header content-type without page can render as plain text.
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/one/plugin_one.js');
ob_start();
$Dispatcher->cached('plugin_js/js/one/plugin_one.js');
$result = ob_get_clean();
$expected = "alert('plugin one nested js file');";
$this->assertEqual($result, $expected);
Configure::write('debug', $debug);
//reset the header content-type without page can render as plain text.
header('Content-type: text/html');
}
/**

View file

@ -0,0 +1 @@
alert('plugin one nested js file');

View file

@ -0,0 +1 @@
nested theme js file

View file

@ -0,0 +1 @@
root theme js file