mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '1.3' into 1.3-misc
This commit is contained in:
commit
9230bb93af
19 changed files with 359 additions and 206 deletions
|
@ -191,7 +191,7 @@
|
|||
* CakePHP session IDs are also regenerated between requests if
|
||||
* 'Security.level' is set to 'high'.
|
||||
*/
|
||||
Configure::write('Security.level', 'high');
|
||||
Configure::write('Security.level', 'medium');
|
||||
|
||||
/**
|
||||
* A random string used in security hashing methods.
|
||||
|
|
|
@ -603,9 +603,9 @@ class ModelTask extends Shell {
|
|||
if (!empty($associations[$type])) {
|
||||
$count = count($associations[$type]);
|
||||
$response = 'y';
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$prompt = "{$model->name} {$type} {$associations[$type][$i]['alias']}";
|
||||
$response = $this->in("{$prompt}?", array('y','n'), 'y');
|
||||
foreach ($associations[$type] as $i => $assoc) {
|
||||
$prompt = "{$model->name} {$type} {$assoc['alias']}?";
|
||||
$response = $this->in($prompt, array('y','n'), 'y');
|
||||
|
||||
if ('n' == strtolower($response)) {
|
||||
unset($associations[$type][$i]);
|
||||
|
|
|
@ -199,7 +199,7 @@
|
|||
* CakePHP session IDs are also regenerated between requests if
|
||||
* 'Security.level' is set to 'high'.
|
||||
*/
|
||||
Configure::write('Security.level', 'high');
|
||||
Configure::write('Security.level', 'medium');
|
||||
|
||||
/**
|
||||
* A random string used in security hashing methods.
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<!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">
|
||||
<head>
|
||||
<?php echo $html->charset(); ?>
|
||||
<?php echo $this->Html->charset(); ?>
|
||||
<title><?php echo $page_title; ?></title>
|
||||
|
||||
<?php if (Configure::read() == 0) { ?>
|
||||
|
|
|
@ -61,14 +61,6 @@ class Dispatcher extends Object {
|
|||
*/
|
||||
var $here = false;
|
||||
|
||||
/**
|
||||
* Plugin being served (if any)
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $plugin = null;
|
||||
|
||||
/**
|
||||
* the params for this request
|
||||
*
|
||||
|
@ -117,7 +109,7 @@ class Dispatcher extends Object {
|
|||
}
|
||||
$this->here = $this->base . '/' . $url;
|
||||
|
||||
if ($this->cached($url)) {
|
||||
if ($this->asset($url) || $this->cached($url)) {
|
||||
$this->_stop();
|
||||
}
|
||||
$controller =& $this->__getController();
|
||||
|
@ -159,7 +151,7 @@ class Dispatcher extends Object {
|
|||
$controller->base = $this->base;
|
||||
$controller->here = $this->here;
|
||||
$controller->webroot = $this->webroot;
|
||||
$controller->plugin = $this->plugin;
|
||||
$controller->plugin = isset($this->params['plugin']) ? $this->params['plugin'] : null;
|
||||
$controller->params =& $this->params;
|
||||
$controller->action =& $this->params['action'];
|
||||
$controller->passedArgs = array_merge($this->params['pass'], $this->params['named']);
|
||||
|
@ -399,16 +391,8 @@ class Dispatcher extends Object {
|
|||
'pass' => array_merge($pass, $params['pass']),
|
||||
'named' => array_merge($named, $params['named'])
|
||||
));
|
||||
$this->plugin = $params['plugin'];
|
||||
} else {
|
||||
$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;
|
||||
}
|
||||
|
@ -420,19 +404,15 @@ class Dispatcher extends Object {
|
|||
* @return mixed name of controller if not loaded, or object if loaded
|
||||
* @access private
|
||||
*/
|
||||
function &__getController($params = null) {
|
||||
if (!is_array($params)) {
|
||||
$original = $params = $this->params;
|
||||
}
|
||||
function &__getController() {
|
||||
$original = $params = $this->params;
|
||||
|
||||
$controller = false;
|
||||
$ctrlClass = $this->__loadController($params);
|
||||
if (!$ctrlClass) {
|
||||
if (!isset($params['plugin'])) {
|
||||
$params = $this->_restructureParams($params);
|
||||
} else {
|
||||
if (empty($original['pass']) && $original['action'] == 'index') {
|
||||
$params['action'] = null;
|
||||
}
|
||||
$params = $this->_restructureParams($params, true);
|
||||
}
|
||||
$ctrlClass = $this->__loadController($params);
|
||||
|
@ -441,15 +421,13 @@ class Dispatcher extends Object {
|
|||
return $controller;
|
||||
}
|
||||
} else {
|
||||
$params = $this->params;
|
||||
if (!isset($params['plugin'])) {
|
||||
$params = $this->_restructureParams($params);
|
||||
}
|
||||
}
|
||||
$name = $ctrlClass;
|
||||
$ctrlClass = $ctrlClass . 'Controller';
|
||||
$ctrlClass .= 'Controller';
|
||||
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;
|
||||
$controller =& new $ctrlClass();
|
||||
}
|
||||
|
@ -466,10 +444,9 @@ class Dispatcher extends Object {
|
|||
function __loadController($params) {
|
||||
$pluginName = $pluginPath = $controller = null;
|
||||
if (!empty($params['plugin'])) {
|
||||
$this->plugin = $params['plugin'];
|
||||
$pluginName = Inflector::camelize($params['plugin']);
|
||||
$pluginPath = $pluginName . '.';
|
||||
$this->params['controller'] = $this->plugin;
|
||||
$this->params['controller'] = $params['plugin'];
|
||||
$controller = $pluginName;
|
||||
}
|
||||
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
|
||||
* @access public
|
||||
*/
|
||||
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) {
|
||||
$path = $this->here;
|
||||
if ($this->here == '/') {
|
||||
|
@ -696,7 +587,124 @@ class Dispatcher extends Object {
|
|||
return $view->renderCache($filename, getMicrotime());
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -109,7 +109,7 @@ class Configure extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($config['debug'])) {
|
||||
if (isset($config['debug']) || isset($config['log'])) {
|
||||
$reporting = 0;
|
||||
if ($_this->debug) {
|
||||
if (!class_exists('Debugger')) {
|
||||
|
|
|
@ -272,7 +272,7 @@ class Router {
|
|||
$self->__prefixes[] = $defaults['prefix'];
|
||||
$self->__prefixes = array_keys(array_flip($self->__prefixes));
|
||||
}
|
||||
$defaults += array('action' => 'index', 'plugin' => null, 'controller' => null);
|
||||
$defaults += array('action' => 'index', 'plugin' => null);
|
||||
$routeClass = 'CakeRoute';
|
||||
if (isset($options['routeClass'])) {
|
||||
$routeClass = $options['routeClass'];
|
||||
|
@ -424,7 +424,11 @@ class Router {
|
|||
if (!$self->__defaultsMapped && $self->__connectDefaults) {
|
||||
$self->__connectDefaultRoutes();
|
||||
}
|
||||
$out = array('pass' => array(), 'named' => array());
|
||||
$out = array(
|
||||
'pass' => array(),
|
||||
'named' => array(),
|
||||
'controller' => null,
|
||||
);
|
||||
$r = $ext = null;
|
||||
|
||||
if (ini_get('magic_quotes_gpc') === '1') {
|
||||
|
@ -1361,7 +1365,7 @@ class CakeRoute {
|
|||
*/
|
||||
function persistParams($url, $params) {
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,15 +33,17 @@ class MediaView extends View {
|
|||
'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh',
|
||||
'csv' => 'application/csv', 'dcr' => 'application/x-director', 'dir' => 'application/x-director',
|
||||
'dms' => 'application/octet-stream', 'doc' => 'application/msword', 'drw' => 'application/drafting',
|
||||
'dvi' => 'application/x-dvi', 'dwg' => 'application/acad', 'dxf' => 'application/dxf', 'dxr' => 'application/x-director',
|
||||
'eps' => 'application/postscript', 'exe' => 'application/octet-stream', 'ez' => 'application/andrew-inset',
|
||||
'dvi' => 'application/x-dvi', 'dwg' => 'application/acad', 'dxf' => 'application/dxf',
|
||||
'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',
|
||||
'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',
|
||||
'ipx' => 'application/x-ipix', 'js' => 'application/x-javascript', 'latex' => 'application/x-latex',
|
||||
'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',
|
||||
'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',
|
||||
'ppt' => 'application/mspowerpoint', 'ppz' => 'application/mspowerpoint', 'pre' => 'application/x-freelance',
|
||||
'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',
|
||||
'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex',
|
||||
'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',
|
||||
'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',
|
||||
|
|
|
@ -19,24 +19,24 @@
|
|||
?>
|
||||
<div class="<?php echo $pluralVar;?> form">
|
||||
<?php
|
||||
echo $form->create();
|
||||
echo $form->inputs($scaffoldFields, array('created', 'modified', 'updated'));
|
||||
echo $form->end(__('Submit', true));
|
||||
echo $this->Form->create();
|
||||
echo $this->Form->inputs($scaffoldFields, array('created', 'modified', 'updated'));
|
||||
echo $this->Form->end(__('Submit', true));
|
||||
?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<?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;?>
|
||||
<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
|
||||
$done = array();
|
||||
foreach ($associations as $_type => $_data) {
|
||||
foreach ($_data as $_alias => $_details) {
|
||||
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>" . $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(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "</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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@
|
|||
<div class="<?php echo $pluralVar;?> index">
|
||||
<h2><?php echo $pluralHumanName;?></h2>
|
||||
<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)
|
||||
));
|
||||
?></p>
|
||||
<table cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<?php foreach ($scaffoldFields as $_field):?>
|
||||
<th><?php echo $paginator->sort($_field);?></th>
|
||||
<th><?php echo $this->Paginator->sort($_field);?></th>
|
||||
<?php endforeach;?>
|
||||
<th><?php __('Actions');?></th>
|
||||
</tr>
|
||||
|
@ -46,7 +46,7 @@ echo "\n";
|
|||
foreach ($associations['belongsTo'] as $_alias => $_details) {
|
||||
if ($_field === $_details['foreignKey']) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ echo "\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" . $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(__('View', true), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])) . "\n";
|
||||
echo "\t\t\t" . $this->Html->link(__('Edit', true), array('action' => 'edit', ${$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</tr>\n";
|
||||
|
||||
|
@ -69,20 +69,20 @@ echo "\n";
|
|||
</table>
|
||||
</div>
|
||||
<div class="paging">
|
||||
<?php echo "\t" . $paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?>
|
||||
| <?php echo $paginator->numbers() . "\n"?>
|
||||
<?php echo "\t ". $paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?>
|
||||
<?php echo "\t" . $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class' => 'disabled')) . "\n";?>
|
||||
| <?php echo $this->Paginator->numbers() . "\n"?>
|
||||
<?php echo "\t ". $this->Paginator->next(__('next', true) .' >>', array(), null, array('class' => 'disabled')) . "\n";?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<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
|
||||
$done = array();
|
||||
foreach ($associations as $_type => $_data) {
|
||||
foreach ($_data as $_alias => $_details) {
|
||||
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>" . $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(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</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'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ foreach ($scaffoldFields as $_field) {
|
|||
if ($_field === $_details['foreignKey']) {
|
||||
$isKey = true;
|
||||
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 </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 </dd>\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -49,17 +49,17 @@ foreach ($scaffoldFields as $_field) {
|
|||
<div class="actions">
|
||||
<ul>
|
||||
<?php
|
||||
echo "\t\t<li>" .$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>" .$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(__('Edit %s', true), $singularHumanName), array('action' => 'edit', ${$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>" .$this->Html->link(sprintf(__('List %s', true), $pluralHumanName), array('action' => 'index')). " </li>\n";
|
||||
echo "\t\t<li>" .$this->Html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')). " </li>\n";
|
||||
|
||||
$done = array();
|
||||
foreach ($associations as $_type => $_data) {
|
||||
foreach ($_data as $_alias => $_details) {
|
||||
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>" . $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(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</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'];
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ foreach ($associations['hasOne'] as $_alias => $_details): ?>
|
|||
<?php endif; ?>
|
||||
<div class="actions">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -136,9 +136,9 @@ $otherSingularVar = Inflector::variable($_alias);
|
|||
}
|
||||
|
||||
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" . $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(__('View', true), array('controller' => $_details['controller'], 'action' => 'view', ${$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" . $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</tr>\n";
|
||||
endforeach;
|
||||
|
@ -147,7 +147,7 @@ $otherSingularVar = Inflector::variable($_alias);
|
|||
<?php endif; ?>
|
||||
<div class="actions">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1599,11 +1599,18 @@ class DispatcherTest extends CakeTestCase {
|
|||
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
|
||||
|
||||
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->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';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertFalse(isset($controller->params['pass'][0]));
|
||||
|
@ -1620,7 +1627,6 @@ class DispatcherTest extends CakeTestCase {
|
|||
|
||||
$url = 'my_plugin/add';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$this->assertFalse(isset($controller->params['pass'][0]));
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
|
@ -1628,14 +1634,48 @@ class DispatcherTest extends CakeTestCase {
|
|||
|
||||
$url = 'my_plugin/add/0';
|
||||
$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->base = false;
|
||||
|
||||
$url = 'my_plugin/add/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
|
||||
* @access public
|
||||
|
@ -1721,6 +1761,10 @@ class DispatcherTest extends CakeTestCase {
|
|||
App::build(array(
|
||||
'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';
|
||||
$result = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertTrue(class_exists('TestsController'));
|
||||
|
@ -1728,6 +1772,10 @@ class DispatcherTest extends CakeTestCase {
|
|||
$this->assertTrue(class_exists('OtherComponentComponent'));
|
||||
$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();
|
||||
}
|
||||
|
||||
|
@ -1771,7 +1819,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testStaticAssets() {
|
||||
function testAssets() {
|
||||
Router::reload();
|
||||
$Configure = Configure::getInstance();
|
||||
$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),
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$debug = Configure::read('debug');
|
||||
Configure::write('debug', 0);
|
||||
|
||||
ob_start();
|
||||
$Dispatcher->dispatch('theme/test_theme/../webroot/css/test_asset.css');
|
||||
$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();
|
||||
$Dispatcher->dispatch('theme/test_theme/flash/theme_test.swf');
|
||||
$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');
|
||||
$this->assertEqual($file, $result);
|
||||
$this->assertEqual('this is just a test to load swf file from the theme.', $result);
|
||||
|
||||
|
||||
ob_start();
|
||||
$Dispatcher->dispatch('theme/test_theme/pdfs/theme_test.pdf');
|
||||
$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');
|
||||
$this->assertEqual($file, $result);
|
||||
$this->assertEqual('this is just a test to load pdf file from the theme.', $result);
|
||||
|
||||
|
||||
ob_start();
|
||||
$Dispatcher->dispatch('theme/test_theme/img/test.jpg');
|
||||
$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');
|
||||
$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');
|
||||
$Dispatcher->asset('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');
|
||||
$Dispatcher->asset('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');
|
||||
$Dispatcher->asset('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();
|
||||
$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('this is just a test to load swf file from the plugin.', $result);
|
||||
|
||||
|
||||
ob_start();
|
||||
$Dispatcher->dispatch('test_plugin/pdfs/plugin_test.pdf');
|
||||
$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');
|
||||
$this->assertEqual($file, $result);
|
||||
$this->assertEqual('this is just a test to load pdf file from the plugin.', $result);
|
||||
|
||||
|
||||
ob_start();
|
||||
$Dispatcher->cached('test_plugin/js/test_plugin/test.js');
|
||||
$Dispatcher->asset('test_plugin/js/test_plugin/test.js');
|
||||
$result = ob_get_clean();
|
||||
$this->assertEqual('alert("Test App");', $result);
|
||||
|
||||
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/js/test_plugin/test.js');
|
||||
ob_start();
|
||||
$Dispatcher->cached('test_plugin/js/test_plugin/test.js');
|
||||
$Dispatcher->asset('test_plugin/js/test_plugin/test.js');
|
||||
$result = ob_get_clean();
|
||||
$this->assertEqual('alert("Test App");', $result);
|
||||
|
||||
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/css/test_plugin_asset.css');
|
||||
ob_start();
|
||||
$Dispatcher->cached('test_plugin/css/test_plugin_asset.css');
|
||||
$Dispatcher->asset('test_plugin/css/test_plugin_asset.css');
|
||||
$result = ob_get_clean();
|
||||
$this->assertEqual('this is the test plugin asset css file', $result);
|
||||
|
||||
$Dispatcher->params = $Dispatcher->parseParams('test_plugin/img/cake.icon.gif');
|
||||
ob_start();
|
||||
$Dispatcher->cached('test_plugin/img/cake.icon.gif');
|
||||
$Dispatcher->asset('test_plugin/img/cake.icon.gif');
|
||||
$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');
|
||||
$this->assertEqual($file, $result);
|
||||
|
||||
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/plugin_js.js');
|
||||
ob_start();
|
||||
$Dispatcher->cached('plugin_js/js/plugin_js.js');
|
||||
$Dispatcher->asset('plugin_js/js/plugin_js.js');
|
||||
$result = ob_get_clean();
|
||||
$expected = "alert('win sauce');";
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
|
||||
$Dispatcher->params = $Dispatcher->parseParams('plugin_js/js/one/plugin_one.js');
|
||||
ob_start();
|
||||
$Dispatcher->cached('plugin_js/js/one/plugin_one.js');
|
||||
$Dispatcher->asset('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');
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -176,6 +176,11 @@ class ConfigureTest extends CakeTestCase {
|
|||
Configure::write('debug', 2);
|
||||
$this->assertEqual(ini_get('error_reporting'), E_ALL & ~E_DEPRECATED);
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -508,6 +508,16 @@ class RouterTest extends CakeTestCase {
|
|||
$result = Router::url(array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'year' => 2007, 'month' => 10, 'min-forestilling'));
|
||||
$expected = '/kalender/10/2007/min-forestilling';
|
||||
$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::parse('/government');
|
||||
$route =& Router::currentRoute();
|
||||
$this->assertEqual(array_merge($url, array('plugin' => false)), $route->defaults);
|
||||
$this->assertEqual(array_merge($url, array('plugin' => null)), $route->defaults);
|
||||
}
|
||||
/**
|
||||
* testRequestRoute
|
||||
|
@ -1857,21 +1867,21 @@ class RouterTest extends CakeTestCase {
|
|||
Router::connect('/government', $url);
|
||||
Router::parse('/government');
|
||||
$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
|
||||
$newUrl = array('controller' => 'products', 'action' => 'display', 6);
|
||||
Router::connect('/government', $url);
|
||||
Router::parse('/government');
|
||||
$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
|
||||
$newUrl = array('controller' => 'products', 'action' => 'display', 6);
|
||||
Router::connect('/actor', $url);
|
||||
Router::parse('/government');
|
||||
$route =& Router::requestRoute();
|
||||
$this->assertEqual(array_merge($url, array('plugin' => false)), $route->defaults);
|
||||
$this->assertEqual(array_merge($url, array('plugin' => null)), $route->defaults);
|
||||
}
|
||||
/**
|
||||
* testGetParams
|
||||
|
@ -1884,7 +1894,7 @@ class RouterTest extends CakeTestCase {
|
|||
$params = array('param1' => '1', 'param2' => '2');
|
||||
Router::setRequestInfo(array($params, $paths));
|
||||
$expected = array(
|
||||
'plugin' => false, 'controller' => false, 'action' => false,
|
||||
'plugin' => null, 'controller' => false, 'action' => false,
|
||||
'param1' => '1', 'param2' => '2'
|
||||
);
|
||||
$this->assertEqual(Router::getparams(), $expected);
|
||||
|
@ -1896,7 +1906,7 @@ class RouterTest extends CakeTestCase {
|
|||
|
||||
$params = array('controller' => 'pages', 'action' => 'display');
|
||||
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(true), $expected);
|
||||
}
|
||||
|
@ -2125,6 +2135,23 @@ class CakeRouteTestCase extends CakeTestCase {
|
|||
'extra' => null,
|
||||
);
|
||||
$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');
|
||||
$params = array('lang' => 'en', 'color' => 'blue');
|
||||
$result = $route->persistParams($url, $params);
|
||||
$this->assertEqual($result['lang'], $params['lang']);
|
||||
$this->assertEqual($result['color'], $params['color']);
|
||||
$this->assertEqual($result['lang'], 'en');
|
||||
$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 {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
htc file
|
|
@ -0,0 +1 @@
|
|||
Testing a file with unknown extension to mime mapping.
|
|
@ -20,7 +20,7 @@
|
|||
<!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">
|
||||
<head>
|
||||
<?php echo $html->charset();?>
|
||||
<?php echo $this->Html->charset();?>
|
||||
<title>
|
||||
<?php __('CakePHP: the rapid development php framework:'); ?>
|
||||
<?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="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;?>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<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 id="content">
|
||||
|
||||
|
@ -44,8 +44,8 @@
|
|||
|
||||
</div>
|
||||
<div id="footer">
|
||||
<?php echo $html->link(
|
||||
$html->image('cake.power.gif', array('alt'=> __("CakePHP: the rapid development php framework", true), 'border'=>"0")),
|
||||
<?php echo $this->Html->link(
|
||||
$this->Html->image('cake.power.gif', array('alt'=> __("CakePHP: the rapid development php framework", true), 'border'=>"0")),
|
||||
'http://www.cakephp.org/',
|
||||
array('target'=>'_blank'), null, false
|
||||
);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title><?php echo $page_title?></title>
|
||||
<?php echo $html->charset(); ?>
|
||||
<?php echo $this->Html->charset(); ?>
|
||||
|
||||
<?php if (Configure::read() == 0) { ?>
|
||||
<meta http-equiv="Refresh" content="<?php echo $pause?>;url=<?php echo $url?>"/>
|
||||
|
|
Loading…
Reference in a new issue