Merge branch '1.3' into 1.3-misc

This commit is contained in:
Mark Story 2009-12-16 23:07:44 -05:00
commit 9230bb93af
19 changed files with 359 additions and 206 deletions

View file

@ -191,7 +191,7 @@
* CakePHP session IDs are also regenerated between requests if * CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high'. * 'Security.level' is set to 'high'.
*/ */
Configure::write('Security.level', 'high'); Configure::write('Security.level', 'medium');
/** /**
* A random string used in security hashing methods. * A random string used in security hashing methods.

View file

@ -603,9 +603,9 @@ class ModelTask extends Shell {
if (!empty($associations[$type])) { if (!empty($associations[$type])) {
$count = count($associations[$type]); $count = count($associations[$type]);
$response = 'y'; $response = 'y';
for ($i = 0; $i < $count; $i++) { foreach ($associations[$type] as $i => $assoc) {
$prompt = "{$model->name} {$type} {$associations[$type][$i]['alias']}"; $prompt = "{$model->name} {$type} {$assoc['alias']}?";
$response = $this->in("{$prompt}?", array('y','n'), 'y'); $response = $this->in($prompt, array('y','n'), 'y');
if ('n' == strtolower($response)) { if ('n' == strtolower($response)) {
unset($associations[$type][$i]); unset($associations[$type][$i]);

View file

@ -199,7 +199,7 @@
* CakePHP session IDs are also regenerated between requests if * CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high'. * 'Security.level' is set to 'high'.
*/ */
Configure::write('Security.level', 'high'); Configure::write('Security.level', 'medium');
/** /**
* A random string used in security hashing methods. * A random string used in security hashing methods.

View file

@ -20,7 +20,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<?php echo $html->charset(); ?> <?php echo $this->Html->charset(); ?>
<title><?php echo $page_title; ?></title> <title><?php echo $page_title; ?></title>
<?php if (Configure::read() == 0) { ?> <?php if (Configure::read() == 0) { ?>

View file

@ -61,14 +61,6 @@ class Dispatcher extends Object {
*/ */
var $here = false; var $here = false;
/**
* Plugin being served (if any)
*
* @var string
* @access public
*/
var $plugin = null;
/** /**
* the params for this request * the params for this request
* *
@ -117,7 +109,7 @@ class Dispatcher extends Object {
} }
$this->here = $this->base . '/' . $url; $this->here = $this->base . '/' . $url;
if ($this->cached($url)) { if ($this->asset($url) || $this->cached($url)) {
$this->_stop(); $this->_stop();
} }
$controller =& $this->__getController(); $controller =& $this->__getController();
@ -159,7 +151,7 @@ class Dispatcher extends Object {
$controller->base = $this->base; $controller->base = $this->base;
$controller->here = $this->here; $controller->here = $this->here;
$controller->webroot = $this->webroot; $controller->webroot = $this->webroot;
$controller->plugin = $this->plugin; $controller->plugin = isset($this->params['plugin']) ? $this->params['plugin'] : null;
$controller->params =& $this->params; $controller->params =& $this->params;
$controller->action =& $this->params['action']; $controller->action =& $this->params['action'];
$controller->passedArgs = array_merge($this->params['pass'], $this->params['named']); $controller->passedArgs = array_merge($this->params['pass'], $this->params['named']);
@ -399,16 +391,8 @@ class Dispatcher extends Object {
'pass' => array_merge($pass, $params['pass']), 'pass' => array_merge($pass, $params['pass']),
'named' => array_merge($named, $params['named']) 'named' => array_merge($named, $params['named'])
)); ));
$this->plugin = $params['plugin'];
} else { } else {
$params['plugin'] = $params['controller']; $params['plugin'] = $params['controller'];
$params['controller'] = $params['action'];
if (isset($params['pass'][0])) {
$params['action'] = $params['pass'][0];
array_shift($params['pass']);
} else {
$params['action'] = null;
}
} }
return $params; return $params;
} }
@ -420,19 +404,15 @@ class Dispatcher extends Object {
* @return mixed name of controller if not loaded, or object if loaded * @return mixed name of controller if not loaded, or object if loaded
* @access private * @access private
*/ */
function &__getController($params = null) { function &__getController() {
if (!is_array($params)) { $original = $params = $this->params;
$original = $params = $this->params;
}
$controller = false; $controller = false;
$ctrlClass = $this->__loadController($params); $ctrlClass = $this->__loadController($params);
if (!$ctrlClass) { if (!$ctrlClass) {
if (!isset($params['plugin'])) { if (!isset($params['plugin'])) {
$params = $this->_restructureParams($params); $params = $this->_restructureParams($params);
} else { } else {
if (empty($original['pass']) && $original['action'] == 'index') {
$params['action'] = null;
}
$params = $this->_restructureParams($params, true); $params = $this->_restructureParams($params, true);
} }
$ctrlClass = $this->__loadController($params); $ctrlClass = $this->__loadController($params);
@ -441,15 +421,13 @@ class Dispatcher extends Object {
return $controller; return $controller;
} }
} else { } else {
$params = $this->params; if (!isset($params['plugin'])) {
$params = $this->_restructureParams($params);
}
} }
$name = $ctrlClass; $name = $ctrlClass;
$ctrlClass = $ctrlClass . 'Controller'; $ctrlClass .= 'Controller';
if (class_exists($ctrlClass)) { if (class_exists($ctrlClass)) {
if (strtolower(get_parent_class($ctrlClass)) === strtolower($name . 'AppController') && empty($params['plugin'])) {
$params = $this->_restructureParams($params);
$params = $this->_restructureParams($params, true);
}
$this->params = $params; $this->params = $params;
$controller =& new $ctrlClass(); $controller =& new $ctrlClass();
} }
@ -466,10 +444,9 @@ class Dispatcher extends Object {
function __loadController($params) { function __loadController($params) {
$pluginName = $pluginPath = $controller = null; $pluginName = $pluginPath = $controller = null;
if (!empty($params['plugin'])) { if (!empty($params['plugin'])) {
$this->plugin = $params['plugin'];
$pluginName = Inflector::camelize($params['plugin']); $pluginName = Inflector::camelize($params['plugin']);
$pluginPath = $pluginName . '.'; $pluginPath = $pluginName . '.';
$this->params['controller'] = $this->plugin; $this->params['controller'] = $params['plugin'];
$controller = $pluginName; $controller = $pluginName;
} }
if (!empty($params['controller'])) { if (!empty($params['controller'])) {
@ -582,98 +559,12 @@ class Dispatcher extends Object {
} }
/** /**
* Outputs cached dispatch for js, css, img, view cache * Outputs cached dispatch view cache
* *
* @param string $url Requested URL * @param string $url Requested URL
* @access public * @access public
*/ */
function cached($url) { function cached($url) {
if (strpos($url, '..') === false && strpos($url, '.')) {
if (strpos($url, 'ccss/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.css');
$this->_stop();
} elseif (strpos($url, 'cjs/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.js');
$this->_stop();
}
App::import('View', 'Media', false);
$controller = null;
$Media = new MediaView($controller);
$ext = array_pop(explode('.', $url));
if (isset($Media->mimeType[$ext])) {
$pos = 0;
$parts = explode('/', $url);
if ($parts[0] === 'theme') {
$pos = strlen($parts[0] . $parts[1]) + 1;
} elseif (count($parts) > 2) {
$pos = strlen($parts[0]);
}
$ob = @ini_get("zlib.output_compression") !== '1' && extension_loaded("zlib") && (strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false);
if ($ob && Configure::read('Asset.compress')) {
ob_start();
ob_start('ob_gzhandler');
}
$assetFile = null;
$paths = array();
$matched = false;
if ($pos > 0) {
$plugin = substr($url, 0, $pos);
$url = preg_replace('/^' . preg_quote($plugin, '/') . '\//i', '', $url);
if (strpos($plugin, '/') !== false) {
list($plugin, $theme) = explode('/', $plugin);
$themePaths = App::path('views');
foreach ($themePaths as $viewPath) {
$path = $viewPath . 'themed' . DS . $theme . DS . 'webroot' . DS;
if ($plugin === 'theme' && (is_file($path . $url) && file_exists($path . $url))) {
$assetFile = $path . $url;
$matched = true;
break;
}
}
}
if ($matched === false) {
$paths[] = App::pluginPath($plugin) . 'webroot' . DS;
}
}
if ($matched === false) {
foreach ($paths as $path) {
if (is_file($path . $url) && file_exists($path . $url)) {
$assetFile = $path . $url;
break;
}
}
}
if ($assetFile !== null) {
$fileModified = filemtime($assetFile);
header("Date: " . date("D, j M Y G:i:s ", $fileModified) . 'GMT');
header('Content-type: ' . $Media->mimeType[$ext]);
header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
header("Cache-Control: cache");
header("Pragma: cache");
if ($ext === 'css' || $ext === 'js') {
include($assetFile);
} else {
readfile($assetFile);
}
if (Configure::read('Asset.compress')) {
ob_end_flush();
}
return true;
}
}
}
if (Configure::read('Cache.check') === true) { if (Configure::read('Cache.check') === true) {
$path = $this->here; $path = $this->here;
if ($this->here == '/') { if ($this->here == '/') {
@ -696,7 +587,124 @@ class Dispatcher extends Object {
return $view->renderCache($filename, getMicrotime()); return $view->renderCache($filename, getMicrotime());
} }
} }
return false; return false;
} }
/**
* Checks if a requested asset exists and sends it to the browser
*
* @param $url string $url Requested URL
* @return boolean True on success if the asset file was found and sent
* @access public
*/
function asset($url) {
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
return false;
}
if (strpos($url, 'ccss/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.css');
$this->_stop();
} elseif (strpos($url, 'cjs/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.js');
$this->_stop();
}
$controller = null;
$ext = array_pop(explode('.', $url));
$pos = 0;
$parts = explode('/', $url);
if ($parts[0] === 'theme') {
$pos = strlen($parts[0] . $parts[1]) + 1;
} elseif (count($parts) > 2) {
$pos = strlen($parts[0]);
}
$assetFile = null;
$paths = array();
$matched = false;
if ($pos > 0) {
$plugin = substr($url, 0, $pos);
$url = preg_replace('/^' . preg_quote($plugin, '/') . '\//i', '', $url);
if (strpos($plugin, '/') !== false) {
list($plugin, $theme) = explode('/', $plugin);
$themePaths = App::path('views');
foreach ($themePaths as $viewPath) {
$path = $viewPath . 'themed' . DS . $theme . DS . 'webroot' . DS;
if ($plugin === 'theme' && (is_file($path . $url) && file_exists($path . $url))) {
$assetFile = $path . $url;
break;
}
}
}
if ($matched === false) {
$paths[] = App::pluginPath($plugin) . 'webroot' . DS;
}
}
if ($matched === false) {
foreach ($paths as $path) {
if (is_file($path . $url) && file_exists($path . $url)) {
$assetFile = $path . $url;
break;
}
}
}
if ($assetFile !== null) {
$this->_deliverAsset($assetFile, $ext);
return true;
}
return false;
}
/**
* Sends an asset file to the client
*
* @param string $assetFile Path to the asset file in the file system
* @param string $ext The extension of the file to determine its mime type
* @return void
* @access protected
*/
function _deliverAsset($assetFile, $ext) {
$ob = @ini_get("zlib.output_compression") !== '1' && extension_loaded("zlib") && (strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false);
if ($ob && Configure::read('Asset.compress')) {
ob_start();
ob_start('ob_gzhandler');
}
App::import('View', 'Media', false);
$Media = new MediaView($controller);
if (isset($Media->mimeType[$ext])) {
$contentType = $Media->mimeType[$ext];
} else {
$contentType = 'application/octet-stream';
$agent = env('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
$contentType = 'application/octetstream';
}
}
header("Date: " . date("D, j M Y G:i:s ", filemtime($assetFile)) . 'GMT');
header('Content-type: ' . $contentType);
header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
header("Cache-Control: cache");
header("Pragma: cache");
if ($ext === 'css' || $ext === 'js') {
include($assetFile);
} else {
readfile($assetFile);
}
if (Configure::read('Asset.compress')) {
ob_end_flush();
}
}
} }
?> ?>

View file

@ -109,7 +109,7 @@ class Configure extends Object {
} }
} }
if (isset($config['debug'])) { if (isset($config['debug']) || isset($config['log'])) {
$reporting = 0; $reporting = 0;
if ($_this->debug) { if ($_this->debug) {
if (!class_exists('Debugger')) { if (!class_exists('Debugger')) {

View file

@ -272,7 +272,7 @@ class Router {
$self->__prefixes[] = $defaults['prefix']; $self->__prefixes[] = $defaults['prefix'];
$self->__prefixes = array_keys(array_flip($self->__prefixes)); $self->__prefixes = array_keys(array_flip($self->__prefixes));
} }
$defaults += array('action' => 'index', 'plugin' => null, 'controller' => null); $defaults += array('action' => 'index', 'plugin' => null);
$routeClass = 'CakeRoute'; $routeClass = 'CakeRoute';
if (isset($options['routeClass'])) { if (isset($options['routeClass'])) {
$routeClass = $options['routeClass']; $routeClass = $options['routeClass'];
@ -424,7 +424,11 @@ class Router {
if (!$self->__defaultsMapped && $self->__connectDefaults) { if (!$self->__defaultsMapped && $self->__connectDefaults) {
$self->__connectDefaultRoutes(); $self->__connectDefaultRoutes();
} }
$out = array('pass' => array(), 'named' => array()); $out = array(
'pass' => array(),
'named' => array(),
'controller' => null,
);
$r = $ext = null; $r = $ext = null;
if (ini_get('magic_quotes_gpc') === '1') { if (ini_get('magic_quotes_gpc') === '1') {
@ -1361,7 +1365,7 @@ class CakeRoute {
*/ */
function persistParams($url, $params) { function persistParams($url, $params) {
foreach ($this->options['persist'] as $persistKey) { foreach ($this->options['persist'] as $persistKey) {
if (array_key_exists($persistKey, $params)) { if (array_key_exists($persistKey, $params) && !isset($url[$persistKey])) {
$url[$persistKey] = $params[$persistKey]; $url[$persistKey] = $params[$persistKey];
} }
} }

View file

@ -33,15 +33,17 @@ class MediaView extends View {
'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh', 'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh',
'csv' => 'application/csv', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'csv' => 'application/csv', 'dcr' => 'application/x-director', 'dir' => 'application/x-director',
'dms' => 'application/octet-stream', 'doc' => 'application/msword', 'drw' => 'application/drafting', 'dms' => 'application/octet-stream', 'doc' => 'application/msword', 'drw' => 'application/drafting',
'dvi' => 'application/x-dvi', 'dwg' => 'application/acad', 'dxf' => 'application/dxf', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'dwg' => 'application/acad', 'dxf' => 'application/dxf',
'eps' => 'application/postscript', 'exe' => 'application/octet-stream', 'ez' => 'application/andrew-inset', 'dxr' => 'application/x-director', 'eot' => 'application/vnd.ms-fontobject', 'eps' => 'application/postscript',
'exe' => 'application/octet-stream', 'ez' => 'application/andrew-inset',
'flv' => 'video/x-flv', 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'flv' => 'video/x-flv', 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip',
'bz2' => 'application/x-bzip', '7z' => 'application/x-7z-compressed', 'hdf' => 'application/x-hdf', 'bz2' => 'application/x-bzip', '7z' => 'application/x-7z-compressed', 'hdf' => 'application/x-hdf',
'hqx' => 'application/mac-binhex40', 'ico' => 'image/vnd.microsoft.icon', 'ips' => 'application/x-ipscript', 'hqx' => 'application/mac-binhex40', 'ico' => 'image/vnd.microsoft.icon', 'ips' => 'application/x-ipscript',
'ipx' => 'application/x-ipix', 'js' => 'application/x-javascript', 'latex' => 'application/x-latex', 'ipx' => 'application/x-ipix', 'js' => 'application/x-javascript', 'latex' => 'application/x-latex',
'lha' => 'application/octet-stream', 'lsp' => 'application/x-lisp', 'lzh' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lsp' => 'application/x-lisp', 'lzh' => 'application/octet-stream',
'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'mif' => 'application/vnd.mif', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'mif' => 'application/vnd.mif',
'ms' => 'application/x-troff-ms', 'nc' => 'application/x-netcdf', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ms' => 'application/x-troff-ms', 'nc' => 'application/x-netcdf', 'oda' => 'application/oda',
'otf' => 'font/otf', 'pdf' => 'application/pdf',
'pgn' => 'application/x-chess-pgn', 'pot' => 'application/mspowerpoint', 'pps' => 'application/mspowerpoint', 'pgn' => 'application/x-chess-pgn', 'pot' => 'application/mspowerpoint', 'pps' => 'application/mspowerpoint',
'ppt' => 'application/mspowerpoint', 'ppz' => 'application/mspowerpoint', 'pre' => 'application/x-freelance', 'ppt' => 'application/mspowerpoint', 'ppz' => 'application/mspowerpoint', 'pre' => 'application/x-freelance',
'prt' => 'application/pro_eng', 'ps' => 'application/postscript', 'roff' => 'application/x-troff', 'prt' => 'application/pro_eng', 'ps' => 'application/postscript', 'roff' => 'application/x-troff',
@ -55,7 +57,8 @@ class MediaView extends View {
'swf' => 'application/x-shockwave-flash', 't' => 'application/x-troff', 'swf' => 'application/x-shockwave-flash', 't' => 'application/x-troff',
'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex',
'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'tr' => 'application/x-troff', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'tr' => 'application/x-troff',
'tsp' => 'application/dsptype', 'unv' => 'application/i-deas', 'ustar' => 'application/x-ustar', 'tsp' => 'application/dsptype', 'ttf' => 'font/ttf',
'unv' => 'application/i-deas', 'ustar' => 'application/x-ustar',
'vcd' => 'application/x-cdlink', 'vda' => 'application/vda', 'xlc' => 'application/vnd.ms-excel', 'vcd' => 'application/x-cdlink', 'vda' => 'application/vda', 'xlc' => 'application/vnd.ms-excel',
'xll' => 'application/vnd.ms-excel', 'xlm' => 'application/vnd.ms-excel', 'xls' => 'application/vnd.ms-excel', 'xll' => 'application/vnd.ms-excel', 'xlm' => 'application/vnd.ms-excel', 'xls' => 'application/vnd.ms-excel',
'xlw' => 'application/vnd.ms-excel', 'zip' => 'application/zip', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'xlw' => 'application/vnd.ms-excel', 'zip' => 'application/zip', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff',

View file

@ -19,24 +19,24 @@
?> ?>
<div class="<?php echo $pluralVar;?> form"> <div class="<?php echo $pluralVar;?> form">
<?php <?php
echo $form->create(); echo $this->Form->create();
echo $form->inputs($scaffoldFields, array('created', 'modified', 'updated')); echo $this->Form->inputs($scaffoldFields, array('created', 'modified', 'updated'));
echo $form->end(__('Submit', true)); echo $this->Form->end(__('Submit', true));
?> ?>
</div> </div>
<div class="actions"> <div class="actions">
<ul> <ul>
<?php if ($this->action != 'add'):?> <?php if ($this->action != 'add'):?>
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $form->value($modelClass.'.'.$primaryKey)); ?></li> <li><?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $this->Form->value($modelClass.'.'.$primaryKey)), null, __('Are you sure you want to delete', true).' #' . $this->Form->value($modelClass.'.'.$primaryKey)); ?></li>
<?php endif;?> <?php endif;?>
<li><?php echo $html->link(__('List', true).' '.$pluralHumanName, array('action' => 'index'));?></li> <li><?php echo $this->Html->link(__('List', true).' '.$pluralHumanName, array('action' => 'index'));?></li>
<?php <?php
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</li>\n";
echo "\t\t<li>" . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }

View file

@ -20,14 +20,14 @@
<div class="<?php echo $pluralVar;?> index"> <div class="<?php echo $pluralVar;?> index">
<h2><?php echo $pluralHumanName;?></h2> <h2><?php echo $pluralHumanName;?></h2>
<p><?php <p><?php
echo $paginator->counter(array( echo $this->Paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
)); ));
?></p> ?></p>
<table cellpadding="0" cellspacing="0"> <table cellpadding="0" cellspacing="0">
<tr> <tr>
<?php foreach ($scaffoldFields as $_field):?> <?php foreach ($scaffoldFields as $_field):?>
<th><?php echo $paginator->sort($_field);?></th> <th><?php echo $this->Paginator->sort($_field);?></th>
<?php endforeach;?> <?php endforeach;?>
<th><?php __('Actions');?></th> <th><?php __('Actions');?></th>
</tr> </tr>
@ -46,7 +46,7 @@ echo "\n";
foreach ($associations['belongsTo'] as $_alias => $_details) { foreach ($associations['belongsTo'] as $_alias => $_details) {
if ($_field === $_details['foreignKey']) { if ($_field === $_details['foreignKey']) {
$isKey = true; $isKey = true;
echo "\t\t<td>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t</td>\n"; echo "\t\t<td>\n\t\t\t" . $this->Html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t</td>\n";
break; break;
} }
} }
@ -57,9 +57,9 @@ echo "\n";
} }
echo "\t\t<td class=\"actions\">\n"; echo "\t\t<td class=\"actions\">\n";
echo "\t\t\t" . $html->link(__('View', true), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n"; echo "\t\t\t" . $this->Html->link(__('View', true), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
echo "\t\t\t" . $html->link(__('Edit', true), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])) . "\n"; echo "\t\t\t" . $this->Html->link(__('Edit', true), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
echo "\t\t\t" . $html->link(__('Delete', true), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey]) . "\n"; echo "\t\t\t" . $this->Html->link(__('Delete', true), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey]) . "\n";
echo "\t\t</td>\n"; echo "\t\t</td>\n";
echo "\t</tr>\n"; echo "\t</tr>\n";
@ -69,20 +69,20 @@ echo "\n";
</table> </table>
</div> </div>
<div class="paging"> <div class="paging">
<?php echo "\t" . $paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?> <?php echo "\t" . $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?>
| <?php echo $paginator->numbers() . "\n"?> | <?php echo $this->Paginator->numbers() . "\n"?>
<?php echo "\t ". $paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?> <?php echo "\t ". $this->Paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?>
</div> </div>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')); ?></li> <li><?php echo $this->Html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')); ?></li>
<?php <?php
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>" . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }

View file

@ -33,7 +33,7 @@ foreach ($scaffoldFields as $_field) {
if ($_field === $_details['foreignKey']) { if ($_field === $_details['foreignKey']) {
$isKey = true; $isKey = true;
echo "\t\t<dt{$class}>" . Inflector::humanize($_alias) . "</dt>\n"; echo "\t\t<dt{$class}>" . Inflector::humanize($_alias) . "</dt>\n";
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n"; echo "\t\t<dd{$class}>\n\t\t\t" . $this->Html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n";
break; break;
} }
} }
@ -49,17 +49,17 @@ foreach ($scaffoldFields as $_field) {
<div class="actions"> <div class="actions">
<ul> <ul>
<?php <?php
echo "\t\t<li>" .$html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n"; echo "\t\t<li>" .$this->Html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('Delete %s', true), $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n"; echo "\t\t<li>" .$this->Html->link(sprintf(__('Delete %s', true), $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('List %s', true), $pluralHumanName), array('action' => 'index')). " </li>\n"; echo "\t\t<li>" .$this->Html->link(sprintf(__('List %s', true), $pluralHumanName), array('action' => 'index')). " </li>\n";
echo "\t\t<li>" .$html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')). " </li>\n"; echo "\t\t<li>" .$this->Html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')). " </li>\n";
$done = array(); $done = array();
foreach ($associations as $_type => $_data) { foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) { foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
echo "\t\t<li>" . $html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>" . $html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n"; echo "\t\t<li>" . $this->Html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller']; $done[] = $_details['controller'];
} }
} }
@ -90,7 +90,7 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
<?php endif; ?> <?php endif; ?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?> <li><?php echo $this->Html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
</ul> </ul>
</div> </div>
</div> </div>
@ -136,9 +136,9 @@ $otherSingularVar = Inflector::variable($_alias);
} }
echo "\t\t\t<td class=\"actions\">\n"; echo "\t\t\t<td class=\"actions\">\n";
echo "\t\t\t\t" . $html->link(__('View', true), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n"; echo "\t\t\t\t" . $this->Html->link(__('View', true), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $html->link(__('Edit', true), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n"; echo "\t\t\t\t" . $this->Html->link(__('Edit', true), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $html->link(__('Delete', true), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n"; echo "\t\t\t\t" . $this->Html->link(__('Delete', true), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
echo "\t\t\t</td>\n"; echo "\t\t\t</td>\n";
echo "\t\t</tr>\n"; echo "\t\t</tr>\n";
endforeach; endforeach;
@ -147,7 +147,7 @@ $otherSingularVar = Inflector::variable($_alias);
<?php endif; ?> <?php endif; ?>
<div class="actions"> <div class="actions">
<ul> <ul>
<li><?php echo $html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li> <li><?php echo $this->Html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -1599,11 +1599,18 @@ class DispatcherTest extends CakeTestCase {
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
Router::reload(); Router::reload();
Router::connect('/my_plugin/:controller/:action/*', array('plugin'=>'my_plugin')); Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin'));
$Dispatcher =& new TestDispatcher(); $Dispatcher =& new TestDispatcher();
$Dispatcher->base = false; $Dispatcher->base = false;
$url = 'my_plugin/';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertEqual($controller->params['controller'], 'my_plugin');
$this->assertEqual($controller->params['plugin'], 'my_plugin');
$this->assertEqual($controller->params['action'], 'index');
$this->assertFalse(isset($controller->params['pass'][0]));
$url = 'my_plugin/my_plugin/add'; $url = 'my_plugin/my_plugin/add';
$controller = $Dispatcher->dispatch($url, array('return' => 1)); $controller = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertFalse(isset($controller->params['pass'][0])); $this->assertFalse(isset($controller->params['pass'][0]));
@ -1620,7 +1627,6 @@ class DispatcherTest extends CakeTestCase {
$url = 'my_plugin/add'; $url = 'my_plugin/add';
$controller = $Dispatcher->dispatch($url, array('return' => 1)); $controller = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertFalse(isset($controller->params['pass'][0])); $this->assertFalse(isset($controller->params['pass'][0]));
$Dispatcher =& new TestDispatcher(); $Dispatcher =& new TestDispatcher();
@ -1628,14 +1634,48 @@ class DispatcherTest extends CakeTestCase {
$url = 'my_plugin/add/0'; $url = 'my_plugin/add/0';
$controller = $Dispatcher->dispatch($url, array('return' => 1)); $controller = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertIdentical('0',$controller->params['pass'][0]); $this->assertEqual($controller->params['controller'], 'my_plugin');
$this->assertEqual($controller->params['plugin'], 'my_plugin');
$this->assertEqual($controller->params['action'], 'add');
$this->assertIdentical('0', $controller->params['pass'][0]);
$Dispatcher =& new TestDispatcher(); $Dispatcher =& new TestDispatcher();
$Dispatcher->base = false; $Dispatcher->base = false;
$url = 'my_plugin/add/1'; $url = 'my_plugin/add/1';
$controller = $Dispatcher->dispatch($url, array('return' => 1)); $controller = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertIdentical('1',$controller->params['pass'][0]);
$this->assertEqual($controller->params['controller'], 'my_plugin');
$this->assertEqual($controller->params['plugin'], 'my_plugin');
$this->assertEqual($controller->params['action'], 'add');
$this->assertIdentical('1', $controller->params['pass'][0]);
}
/**
* test plugin shortcut urls with controllers that need to be loaded,
* the above test uses a controller that has already been included.
*
* @return void
*/
function testPluginShortCutUrlsWithControllerThatNeedsToBeLoaded() {
$loaded = class_exists('TestPluginController', false);
if ($this->skipIf($loaded, 'TestPluginController already loaded, this test will always pass, skipping %s')) {
return true;
}
Router::reload();
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$Dispatcher =& new TestDispatcher();
$Dispatcher->base = false;
$url = 'test_plugin/';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertEqual($controller->params['controller'], 'test_plugin');
$this->assertEqual($controller->params['plugin'], 'test_plugin');
$this->assertEqual($controller->params['action'], 'index');
$this->assertFalse(isset($controller->params['pass'][0]));
App::build();
} }
/** /**
@ -1711,7 +1751,7 @@ class DispatcherTest extends CakeTestCase {
} }
/** /**
* undocumented function * Test dispatching into the TestPlugin in the test_app
* *
* @return void * @return void
* @access public * @access public
@ -1721,6 +1761,10 @@ class DispatcherTest extends CakeTestCase {
App::build(array( App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
)); ));
App::objects('plugin', null, false);
Router::reload();
Router::parse('/');
$url = '/test_plugin/tests/index'; $url = '/test_plugin/tests/index';
$result = $Dispatcher->dispatch($url, array('return' => 1)); $result = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertTrue(class_exists('TestsController')); $this->assertTrue(class_exists('TestsController'));
@ -1728,6 +1772,10 @@ class DispatcherTest extends CakeTestCase {
$this->assertTrue(class_exists('OtherComponentComponent')); $this->assertTrue(class_exists('OtherComponentComponent'));
$this->assertTrue(class_exists('PluginsComponentComponent')); $this->assertTrue(class_exists('PluginsComponentComponent'));
$this->assertEqual($result->params['controller'], 'tests');
$this->assertEqual($result->params['plugin'], 'test_plugin');
$this->assertEqual($result->params['action'], 'index');
App::build(); App::build();
} }
@ -1771,7 +1819,7 @@ class DispatcherTest extends CakeTestCase {
* @return void * @return void
* @access public * @access public
*/ */
function testStaticAssets() { function testAssets() {
Router::reload(); Router::reload();
$Configure = Configure::getInstance(); $Configure = Configure::getInstance();
$Configure->__objects = null; $Configure->__objects = null;
@ -1781,106 +1829,127 @@ class DispatcherTest extends CakeTestCase {
'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS), 'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
)); ));
$Dispatcher =& new TestDispatcher(); $Dispatcher =& new TestDispatcher();
$debug = Configure::read('debug'); $debug = Configure::read('debug');
Configure::write('debug', 0); Configure::write('debug', 0);
ob_start(); ob_start();
$Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css'); $Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual(null, $result); $this->assertFalse($result);
ob_start();
$Dispatcher->dispatch('theme/test_theme/pdfs');
$result = ob_get_clean();
$this->assertFalse($result);
ob_start(); ob_start();
$Dispatcher->dispatch('theme/test_theme/flash/theme_test.swf'); $Dispatcher->dispatch('theme/test_theme/flash/theme_test.swf');
$result = ob_get_clean(); $result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf'); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . 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('theme/test_theme/pdfs/theme_test.pdf'); $Dispatcher->dispatch('theme/test_theme/pdfs/theme_test.pdf');
$result = ob_get_clean(); $result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf'); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . 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('theme/test_theme/img/test.jpg'); $Dispatcher->dispatch('theme/test_theme/img/test.jpg');
$result = ob_get_clean(); $result = ob_get_clean();
$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'); $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); $this->assertEqual($file, $result);
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/css/test_asset.css'); $Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/css/test_asset.css');
ob_start(); ob_start();
$Dispatcher->cached('theme/test_theme/css/test_asset.css'); $Dispatcher->asset('theme/test_theme/css/test_asset.css');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('this is the test asset css file', $result); $this->assertEqual('this is the test asset css file', $result);
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/theme.js'); $Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/theme.js');
ob_start(); ob_start();
$Dispatcher->cached('theme/test_theme/js/theme.js'); $Dispatcher->asset('theme/test_theme/js/theme.js');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('root theme js file', $result); $this->assertEqual('root theme js file', $result);
$Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/one/theme_one.js'); $Dispatcher->params = $Dispatcher->parseParams('theme/test_theme/js/one/theme_one.js');
ob_start(); ob_start();
$Dispatcher->cached('theme/test_theme/js/one/theme_one.js'); $Dispatcher->asset('theme/test_theme/js/one/theme_one.js');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('nested theme js file', $result); $this->assertEqual('nested theme js file', $result);
ob_start(); ob_start();
$Dispatcher->dispatch('test_plugin/flash/plugin_test.swf'); $Dispatcher->dispatch('test_plugin/flash/plugin_test.swf');
$result = ob_get_clean(); $result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'flash' . DS . 'plugin_test.swf'); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'flash' . DS . 'plugin_test.swf');
$this->assertEqual($file, $result); $this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load swf file from the plugin.', $result); $this->assertEqual('this is just a test to load swf file from the plugin.', $result);
ob_start(); ob_start();
$Dispatcher->dispatch('test_plugin/pdfs/plugin_test.pdf'); $Dispatcher->dispatch('test_plugin/pdfs/plugin_test.pdf');
$result = ob_get_clean(); $result = ob_get_clean();
$file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'pdfs' . DS . 'plugin_test.pdf'); $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'pdfs' . DS . 'plugin_test.pdf');
$this->assertEqual($file, $result); $this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load pdf file from the plugin.', $result); $this->assertEqual('this is just a test to load pdf file from the plugin.', $result);
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/js/test_plugin/test.js'); $Dispatcher->asset('test_plugin/js/test_plugin/test.js');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('alert("Test App");', $result); $this->assertEqual('alert("Test App");', $result);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js');
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/js/test_plugin/test.js'); $Dispatcher->asset('test_plugin/js/test_plugin/test.js');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('alert("Test App");', $result); $this->assertEqual('alert("Test App");', $result);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css');
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/css/test_plugin_asset.css'); $Dispatcher->asset('test_plugin/css/test_plugin_asset.css');
$result = ob_get_clean(); $result = ob_get_clean();
$this->assertEqual('this is the test plugin asset css file', $result); $this->assertEqual('this is the test plugin asset css file', $result);
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif'); $Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif');
ob_start(); ob_start();
$Dispatcher->cached('test_plugin/img/cake.icon.gif'); $Dispatcher->asset('test_plugin/img/cake.icon.gif');
$result = ob_get_clean(); $result = ob_get_clean();
$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'); $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); $this->assertEqual($file, $result);
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js'); $Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js');
ob_start(); ob_start();
$Dispatcher->cached('plugin_js/js/plugin_js.js'); $Dispatcher->asset('plugin_js/js/plugin_js.js');
$result = ob_get_clean(); $result = ob_get_clean();
$expected = "alert('win sauce');"; $expected = "alert('win sauce');";
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/one/plugin_one.js'); $Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/one/plugin_one.js');
ob_start(); ob_start();
$Dispatcher->cached('plugin_js/js/one/plugin_one.js'); $Dispatcher->asset('plugin_js/js/one/plugin_one.js');
$result = ob_get_clean(); $result = ob_get_clean();
$expected = "alert('plugin one nested js file');"; $expected = "alert('plugin one nested js file');";
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
Configure::write('debug', $debug); Configure::write('debug', $debug);
//reset the header content-type without page can render as plain text. //reset the header content-type without page can render as plain text.
header('Content-type: text/html'); header('Content-type: text/html');
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/theme_one.htc');
ob_start();
$Dispatcher->asset('test_plugin/css/unknown.extension');
$result = ob_get_clean();
$this->assertEqual('Testing a file with unknown extension to mime mapping.', $result);
header('Content-type: text/html');
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/theme_one.htc');
ob_start();
$Dispatcher->asset('test_plugin/css/theme_one.htc');
$result = ob_get_clean();
$this->assertEqual('htc file', $result);
header('Content-type: text/html');
} }
/** /**

View file

@ -176,6 +176,11 @@ class ConfigureTest extends CakeTestCase {
Configure::write('debug', 2); Configure::write('debug', 2);
$this->assertEqual(ini_get('error_reporting'), E_ALL & ~E_DEPRECATED); $this->assertEqual(ini_get('error_reporting'), E_ALL & ~E_DEPRECATED);
$this->assertEqual(ini_get('display_errors'), 1); $this->assertEqual(ini_get('display_errors'), 1);
Configure::write('debug', 0);
Configure::write('log', false);
$this->assertEqual(ini_get('error_reporting'), 0);
$this->assertEqual(ini_get('display_errors'), 0);
} }
/** /**

View file

@ -508,6 +508,16 @@ class RouterTest extends CakeTestCase {
$result = Router::url(array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'year' => 2007, 'month' => 10, 'min-forestilling')); $result = Router::url(array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'year' => 2007, 'month' => 10, 'min-forestilling'));
$expected = '/kalender/10/2007/min-forestilling'; $expected = '/kalender/10/2007/min-forestilling';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
Router::reload();
Router::connect('/:controller/:action/*', array(), array(
'controller' => 'source|wiki|commits|tickets|comments|view',
'action' => 'branches|history|branch|logs|view|start|add|edit|modify'
));
Router::defaults(false);
$result = Router::parse('/foo/bar');
$expected = array('pass' => array(), 'named' => array(), 'controller' => null);
$this->assertEqual($result, $expected);
} }
/** /**
@ -1844,7 +1854,7 @@ class RouterTest extends CakeTestCase {
Router::connect('/government', $url); Router::connect('/government', $url);
Router::parse('/government'); Router::parse('/government');
$route =& Router::currentRoute(); $route =& Router::currentRoute();
$this->assertEqual(array_merge($url, array('plugin' => false)), $route->defaults); $this->assertEqual(array_merge($url, array('plugin' => null)), $route->defaults);
} }
/** /**
* testRequestRoute * testRequestRoute
@ -1857,21 +1867,21 @@ class RouterTest extends CakeTestCase {
Router::connect('/government', $url); Router::connect('/government', $url);
Router::parse('/government'); Router::parse('/government');
$route =& Router::requestRoute(); $route =& Router::requestRoute();
$this->assertEqual(array_merge($url, array('plugin' => false)), $route->defaults); $this->assertEqual(array_merge($url, array('plugin' => null)), $route->defaults);
// test that the first route is matched // test that the first route is matched
$newUrl = array('controller' => 'products', 'action' => 'display', 6); $newUrl = array('controller' => 'products', 'action' => 'display', 6);
Router::connect('/government', $url); Router::connect('/government', $url);
Router::parse('/government'); Router::parse('/government');
$route =& Router::requestRoute(); $route =& Router::requestRoute();
$this->assertEqual(array_merge($url, array('plugin' => false)), $route->defaults); $this->assertEqual(array_merge($url, array('plugin' => null)), $route->defaults);
// test that an unmatched route does not change the current route // test that an unmatched route does not change the current route
$newUrl = array('controller' => 'products', 'action' => 'display', 6); $newUrl = array('controller' => 'products', 'action' => 'display', 6);
Router::connect('/actor', $url); Router::connect('/actor', $url);
Router::parse('/government'); Router::parse('/government');
$route =& Router::requestRoute(); $route =& Router::requestRoute();
$this->assertEqual(array_merge($url, array('plugin' => false)), $route->defaults); $this->assertEqual(array_merge($url, array('plugin' => null)), $route->defaults);
} }
/** /**
* testGetParams * testGetParams
@ -1884,7 +1894,7 @@ class RouterTest extends CakeTestCase {
$params = array('param1' => '1', 'param2' => '2'); $params = array('param1' => '1', 'param2' => '2');
Router::setRequestInfo(array($params, $paths)); Router::setRequestInfo(array($params, $paths));
$expected = array( $expected = array(
'plugin' => false, 'controller' => false, 'action' => false, 'plugin' => null, 'controller' => false, 'action' => false,
'param1' => '1', 'param2' => '2' 'param1' => '1', 'param2' => '2'
); );
$this->assertEqual(Router::getparams(), $expected); $this->assertEqual(Router::getparams(), $expected);
@ -1896,7 +1906,7 @@ class RouterTest extends CakeTestCase {
$params = array('controller' => 'pages', 'action' => 'display'); $params = array('controller' => 'pages', 'action' => 'display');
Router::setRequestInfo(array($params, $paths)); Router::setRequestInfo(array($params, $paths));
$expected = array('plugin' => false, 'controller' => 'pages', 'action' => 'display'); $expected = array('plugin' => null, 'controller' => 'pages', 'action' => 'display');
$this->assertEqual(Router::getparams(), $expected); $this->assertEqual(Router::getparams(), $expected);
$this->assertEqual(Router::getparams(true), $expected); $this->assertEqual(Router::getparams(true), $expected);
} }
@ -2125,6 +2135,23 @@ class CakeRouteTestCase extends CakeTestCase {
'extra' => null, 'extra' => null,
); );
$this->assertEqual($route->defaults, $expected); $this->assertEqual($route->defaults, $expected);
$route =& new CakeRoute(
'/:controller/:action/*',
array('project' => false),
array(
'controller' => 'source|wiki|commits|tickets|comments|view',
'action' => 'branches|history|branch|logs|view|start|add|edit|modify'
)
);
$this->assertFalse($route->parse('/chaw_test/wiki'));
$result = $route->compile();
$this->assertNoPattern($result, '/some_project/source');
$this->assertPattern($result, '/source/view');
$this->assertPattern($result, '/source/view/other/params');
$this->assertNoPattern($result, '/chaw_test/wiki');
$this->assertNoPattern($result, '/source/wierd_action');
} }
/** /**
@ -2266,8 +2293,14 @@ class CakeRouteTestCase extends CakeTestCase {
$url = array('controller' => 'posts', 'action' => 'index'); $url = array('controller' => 'posts', 'action' => 'index');
$params = array('lang' => 'en', 'color' => 'blue'); $params = array('lang' => 'en', 'color' => 'blue');
$result = $route->persistParams($url, $params); $result = $route->persistParams($url, $params);
$this->assertEqual($result['lang'], $params['lang']); $this->assertEqual($result['lang'], 'en');
$this->assertEqual($result['color'], $params['color']); $this->assertEqual($result['color'], 'blue');
$url = array('controller' => 'posts', 'action' => 'index', 'color' => 'red');
$params = array('lang' => 'en', 'color' => 'blue');
$result = $route->persistParams($url, $params);
$this->assertEqual($result['lang'], 'en');
$this->assertEqual($result['color'], 'red');
} }
/** /**
@ -2286,5 +2319,4 @@ class CakeRouteTestCase extends CakeTestCase {
} }
} }
?> ?>

View file

@ -0,0 +1,30 @@
<?php
/**
* TestPluginController used by Dispatcher test to test plugin shortcut urls.
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake
* @subpackage cake.tests.test_app.plugins.test_plugin.views.helpers
* @since CakePHP(tm) v 1.3
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
class TestPluginController extends TestPluginAppController {
var $uses = array();
function index() {
$this->autoRender = false;
}
function add() {
$this->autoRender = false;
}
}

View file

@ -0,0 +1 @@
htc file

View file

@ -0,0 +1 @@
Testing a file with unknown extension to mime mapping.

View file

@ -20,7 +20,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<?php echo $html->charset();?> <?php echo $this->Html->charset();?>
<title> <title>
<?php __('CakePHP: the rapid development php framework:'); ?> <?php __('CakePHP: the rapid development php framework:'); ?>
<?php echo $title_for_layout;?> <?php echo $title_for_layout;?>
@ -28,13 +28,13 @@
<link rel="icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" /> <link rel="icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
<?php echo $html->css('cake.generic');?> <?php echo $this->Html->css('cake.generic');?>
<?php echo $scripts_for_layout;?> <?php echo $scripts_for_layout;?>
</head> </head>
<body> <body>
<div id="container"> <div id="container">
<div id="header"> <div id="header">
<h1><?php echo $html->link(__('CakePHP: the rapid development php framework', true), 'http://cakephp.org');?></h1> <h1><?php echo $this->Html->link(__('CakePHP: the rapid development php framework', true), 'http://cakephp.org');?></h1>
</div> </div>
<div id="content"> <div id="content">
@ -44,8 +44,8 @@
</div> </div>
<div id="footer"> <div id="footer">
<?php echo $html->link( <?php echo $this->Html->link(
$html->image('cake.power.gif', array('alt'=> __("CakePHP: the rapid development php framework", true), 'border'=>"0")), $this->Html->image('cake.power.gif', array('alt'=> __("CakePHP: the rapid development php framework", true), 'border'=>"0")),
'http://www.cakephp.org/', 'http://www.cakephp.org/',
array('target'=>'_blank'), null, false array('target'=>'_blank'), null, false
); );

View file

@ -21,7 +21,7 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title><?php echo $page_title?></title> <title><?php echo $page_title?></title>
<?php echo $html->charset(); ?> <?php echo $this->Html->charset(); ?>
<?php if (Configure::read() == 0) { ?> <?php if (Configure::read() == 0) { ?>
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/> <meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>