mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge remote branch 'markstory/2.0' into 2.0
This commit is contained in:
commit
c2002dada7
32 changed files with 364 additions and 118 deletions
|
@ -18,4 +18,5 @@
|
|||
// @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
// +--------------------------------------------------------------------------------------------+ //
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
1.3.0-RC4
|
||||
1.3.0
|
||||
|
||||
|
|
|
@ -17,5 +17,5 @@
|
|||
* @since CakePHP(tm) v 1.1.11.4062
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
return $config['Cake.version'] = '1.3.0-RC4';
|
||||
return $config['Cake.version'] = '1.3.0';
|
||||
?>
|
|
@ -27,10 +27,10 @@
|
|||
public function <?php echo $admin ?>view($id = null) {
|
||||
if (!$id) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('Invalid %s'), '<?php echo strtolower($singularHumanName) ?>'));
|
||||
$this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName) ?>'));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('Invalid %s'), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('Invalid <?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
|
||||
|
@ -42,14 +42,14 @@
|
|||
$this-><?php echo $currentModelName; ?>->create();
|
||||
if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s has been saved'), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('%s saved.'), '<?php echo ucfirst(strtolower($currentModelName)); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
} else {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.'), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
}
|
||||
|
@ -74,23 +74,23 @@
|
|||
public function <?php echo $admin; ?>edit($id = null) {
|
||||
if (!$id && empty($this->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('Invalid %s'), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('Invalid <?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('Invalid %s'), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>')), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s has been saved'), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
|
||||
$this->redirect(array('action' => 'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('The %s has been saved.'), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
} else {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('The %s could not be saved. Please, try again.'), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
}
|
||||
|
@ -117,24 +117,24 @@
|
|||
public function <?php echo $admin; ?>delete($id = null) {
|
||||
if (!$id) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('Invalid id for %s'), '<?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->Session->setFlash(__('Invalid id for <?php echo strtolower($singularHumanName); ?>'));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('Invalid %s'), '<?php echo strtolower($singularHumanName); ?>'), array('action' => 'index'));
|
||||
$this->flash(sprintf(__('Invalid <?php echo strtolower($singularHumanName); ?>')), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
if ($this-><?php echo $currentModelName; ?>->delete($id)) {
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('%s deleted'), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'));
|
||||
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('%s deleted'), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
}
|
||||
<?php if ($wannaUseSession): ?>
|
||||
$this->Session->setFlash(sprintf(__('%s was not deleted'), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'));
|
||||
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'));
|
||||
<?php else: ?>
|
||||
$this->flash(sprintf(__('%s was not deleted'), '<?php echo ucfirst(strtolower($singularHumanName)); ?>'), array('action' => 'index'));
|
||||
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
|
||||
<?php endif; ?>
|
||||
$this->redirect(array('action' => 'index'));
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
<div class="<?php echo $pluralVar;?> form">
|
||||
<?php echo "<?php echo \$this->Form->create('{$modelClass}');?>\n";?>
|
||||
<fieldset>
|
||||
<legend><?php echo "<?php printf(__('" . Inflector::humanize($action) . " %s'), __('{$singularHumanName}')); ?>";?></legend>
|
||||
<legend><?php printf("<?php __('%s %s', true); ?>", Inflector::humanize($action), $singularHumanName); ?></legend>
|
||||
<?php
|
||||
echo "\t<?php\n";
|
||||
foreach ($fields as $field) {
|
||||
|
@ -49,14 +49,14 @@
|
|||
<?php if (strpos($action, 'add') === false): ?>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, sprintf(__('Are you sure you want to delete # %s?'), \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>";?></li>
|
||||
<?php endif;?>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('List %s'), __('{$pluralHumanName}')), array('action' => 'index'));?>";?></li>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('List " . $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><?php echo \$this->Html->link(sprintf(__('List %s'), __('" . Inflector::humanize($details['controller']) . "')), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s'), __('" . Inflector::humanize(Inflector::underscore($alias)) . "')), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
$done[] = $details['controller'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,22 +71,22 @@
|
|||
</p>
|
||||
|
||||
<div class="paging">
|
||||
<?php echo "\t<?php echo \$this->Paginator->prev('<< '.__('previous'), array(), null, array('class'=>'disabled'));?>\n";?>
|
||||
<?php echo "\t<?php echo \$this->Paginator->prev('<< ' . __('previous'), array(), null, array('class'=>'disabled'));?>\n";?>
|
||||
| <?php echo "\t<?php echo \$this->Paginator->numbers();?>\n"?> |
|
||||
<?php echo "\t<?php echo \$this->Paginator->next(__('next').' >>', array(), null, array('class' => 'disabled'));?>\n";?>
|
||||
<?php echo "\t<?php echo \$this->Paginator->next(__('next') . ' >>', array(), null, array('class' => 'disabled'));?>\n";?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3>
|
||||
<ul>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('New %s'), __('{$singularHumanName}')), array('action' => 'add')); ?>";?></li>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('New " . $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><?php echo \$this->Html->link(sprintf(__('List %s'), __('" . Inflector::humanize($details['controller']) . "')), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s'), __('" . Inflector::humanize(Inflector::underscore($alias)) . "')), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
$done[] = $details['controller'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,17 +45,17 @@ foreach ($fields as $field) {
|
|||
<h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3>
|
||||
<ul>
|
||||
<?php
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('Edit %s'), __('{$singularHumanName}')), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('Delete %s'), __('{$singularHumanName}')), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('List %s'), __('{$pluralHumanName}')), array('action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s'), __('{$singularHumanName}')), array('action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . $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><?php echo \$this->Html->link(sprintf(__('List %s'), __('" . Inflector::humanize($details['controller']) . "')), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(sprintf(__('New %s'), __('" . Inflector::humanize(Inflector::underscore($alias)) . "')), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
|
||||
echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
|
||||
$done[] = $details['controller'];
|
||||
}
|
||||
}
|
||||
|
@ -67,12 +67,12 @@ foreach ($fields as $field) {
|
|||
if (!empty($associations['hasOne'])) :
|
||||
foreach ($associations['hasOne'] as $alias => $details): ?>
|
||||
<div class="related">
|
||||
<h3><?php echo "<?php printf(__('Related %s', true), __('" . Inflector::humanize($details['controller']) . "', true));?>";?></h3>
|
||||
<h3><?php echo "<?php echo __('Related " . Inflector::humanize($details['controller']) . "');?>";?></h3>
|
||||
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
|
||||
<dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
|
||||
<?php
|
||||
foreach ($details['fields'] as $field) {
|
||||
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "');?></dt>\n";
|
||||
echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php echo __('" . Inflector::humanize($field) . "');?></dt>\n";
|
||||
echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n </dd>\n";
|
||||
}
|
||||
?>
|
||||
|
@ -80,7 +80,7 @@ if (!empty($associations['hasOne'])) :
|
|||
<?php echo "<?php endif; ?>\n";?>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('Edit %s', true), __('" . Inflector::humanize(Inflector::underscore($alias)) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -100,16 +100,16 @@ foreach ($relations as $alias => $details):
|
|||
$otherPluralHumanName = Inflector::humanize($details['controller']);
|
||||
?>
|
||||
<div class="related">
|
||||
<h3><?php echo "<?php printf(__('Related %s', true), __('{$otherPluralHumanName}', true));?>";?></h3>
|
||||
<h3><?php echo "<?php echo __('Related " . $otherPluralHumanName . "');?>";?></h3>
|
||||
<?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
|
||||
<table cellpadding = "0" cellspacing = "0">
|
||||
<tr>
|
||||
<?php
|
||||
foreach ($details['fields'] as $field) {
|
||||
echo "\t\t<th><?php __('" . Inflector::humanize($field) . "'); ?></th>\n";
|
||||
echo "\t\t<th><?php echo __('" . Inflector::humanize($field) . "'); ?></th>\n";
|
||||
}
|
||||
?>
|
||||
<th class="actions"><?php echo "<?php __('Actions');?>";?></th>
|
||||
<th class="actions"><?php echo "<?php echo __('Actions');?>";?></th>
|
||||
</tr>
|
||||
<?php
|
||||
echo "\t<?php
|
||||
|
@ -127,9 +127,9 @@ echo "\t<?php
|
|||
}
|
||||
|
||||
echo "\t\t\t<td class=\"actions\">\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('View', true), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('Delete', true), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t\t<?php echo \$this->Html->link(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?'), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
|
||||
echo "\t\t\t</td>\n";
|
||||
echo "\t\t</tr>\n";
|
||||
|
||||
|
@ -139,7 +139,7 @@ echo "\t<?php endforeach; ?>\n";
|
|||
<?php echo "<?php endif; ?>\n\n";?>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo "<?php echo \$this->Html->link(sprintf(__('New %s', true), __('" . Inflector::humanize(Inflector::underscore($alias)) . "', true)), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
|
||||
<li><?php echo "<?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 233 B |
BIN
cake/console/templates/skel/webroot/img/cake.icon.png
Normal file
BIN
cake/console/templates/skel/webroot/img/cake.icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 943 B |
|
@ -546,8 +546,14 @@ class Dispatcher extends Object {
|
|||
return false;
|
||||
}
|
||||
$filters = Configure::read('Asset.filter');
|
||||
$isCss = strpos($url, 'ccss/') === 0;
|
||||
$isJs = strpos($url, 'cjs/') === 0;
|
||||
$isCss = (
|
||||
strpos($url, 'ccss/') === 0 ||
|
||||
preg_match('#^(theme/([^/]+)/ccss/)|(([^/]+)(?<!css)/ccss)/#i', $url)
|
||||
);
|
||||
$isJs = (
|
||||
strpos($url, 'cjs/') === 0 ||
|
||||
preg_match('#^/((theme/[^/]+)/cjs/)|(([^/]+)(?<!js)/cjs)/#i', $url)
|
||||
);
|
||||
|
||||
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
|
@ -609,6 +615,7 @@ class Dispatcher extends Object {
|
|||
}
|
||||
|
||||
App::import('View', 'Media', false);
|
||||
$controller = null;
|
||||
$Media = new MediaView($controller);
|
||||
if (isset($Media->mimeType[$ext])) {
|
||||
$contentType = $Media->mimeType[$ext];
|
||||
|
|
|
@ -550,13 +550,11 @@ class CakeSession extends Object {
|
|||
);
|
||||
break;
|
||||
default:
|
||||
if (empty($_SESSION)) {
|
||||
$config = CONFIGS . Configure::read('Session.save') . '.php';
|
||||
|
||||
if (is_file($config)) {
|
||||
require($config);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,6 +324,7 @@ class EmailComponent extends Object{
|
|||
* Send an email using the specified content, template and layout
|
||||
*
|
||||
* @param mixed $content Either an array of text lines, or a string with contents
|
||||
* If you are rendering a template this variable will be sent to the templates as `$content`
|
||||
* @param string $template Template to use when sending email
|
||||
* @param string $layout Layout to use to enclose email body
|
||||
* @return boolean Success
|
||||
|
|
|
@ -604,7 +604,8 @@ class Controller extends Object {
|
|||
*
|
||||
* @param string $modelClass Name of model class to load
|
||||
* @param mixed $id Initial ID the instanced model class should have
|
||||
* @return mixed true when single model found and instance created error returned if models not found.
|
||||
* @return mixed true when single model found and instance created, error returned if model not found.
|
||||
* @access public
|
||||
*/
|
||||
public function loadModel($modelClass = null, $id = null) {
|
||||
if ($modelClass === null) {
|
||||
|
@ -653,6 +654,8 @@ class Controller extends Object {
|
|||
$this->_persist($modelClass, true, $object);
|
||||
$this->modelNames[] = $modelClass;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -222,7 +222,8 @@ class Scaffold extends Object {
|
|||
function __scaffoldView($params) {
|
||||
if ($this->controller->_beforeScaffold('view')) {
|
||||
|
||||
$message = sprintf(__("No id set for %s::view()"), Inflector::humanize($this->modelKey));
|
||||
$message = __(sprintf("No id set for %s::view()", Inflector::humanize($this->modelKey)));
|
||||
|
||||
if (isset($params['pass'][0])) {
|
||||
$this->ScaffoldModel->id = $params['pass'][0];
|
||||
} elseif ($this->_validSession) {
|
||||
|
@ -302,7 +303,7 @@ class Scaffold extends Object {
|
|||
}
|
||||
|
||||
if (!$this->ScaffoldModel->exists()) {
|
||||
$message = sprintf(__("Invalid id for %s::edit()"), Inflector::humanize($this->modelKey));
|
||||
$message = __(sprintf("Invalid id for %s::edit()", Inflector::humanize($this->modelKey)));
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->redirect($this->redirect);
|
||||
|
@ -320,9 +321,8 @@ class Scaffold extends Object {
|
|||
|
||||
if ($this->ScaffoldModel->save($this->controller->data)) {
|
||||
if ($this->controller->_afterScaffoldSave($action)) {
|
||||
$message = sprintf(__('The %1$s has been %2$s'),
|
||||
Inflector::humanize($this->modelKey),
|
||||
$success
|
||||
$message = __(
|
||||
sprintf('The %1$s has been %2$s', Inflector::humanize($this->modelKey), $success)
|
||||
);
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
|
@ -336,8 +336,7 @@ class Scaffold extends Object {
|
|||
}
|
||||
} else {
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash(
|
||||
__('Please correct errors below.'));
|
||||
$this->controller->Session->setFlash(__('Please correct errors below.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +375,9 @@ class Scaffold extends Object {
|
|||
*/
|
||||
function __scaffoldDelete($params = array()) {
|
||||
if ($this->controller->_beforeScaffold('delete')) {
|
||||
$message = sprintf(__("No id set for %s::delete()"), Inflector::humanize($this->modelKey));
|
||||
$message = __(
|
||||
sprintf("No id set for %s::delete()", Inflector::humanize($this->modelKey))
|
||||
);
|
||||
if (isset($params['pass'][0])) {
|
||||
$id = $params['pass'][0];
|
||||
} elseif ($this->_validSession) {
|
||||
|
@ -388,9 +389,8 @@ class Scaffold extends Object {
|
|||
}
|
||||
|
||||
if ($this->ScaffoldModel->delete($id)) {
|
||||
$message = sprintf(
|
||||
__('The %1$s with id: %2$d has been deleted.'),
|
||||
Inflector::humanize($this->modelClass), $id
|
||||
$message = __(
|
||||
sprintf('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id),
|
||||
);
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
|
@ -400,10 +400,10 @@ class Scaffold extends Object {
|
|||
return $this->_output();
|
||||
}
|
||||
} else {
|
||||
$message = sprintf(
|
||||
__('There was an error deleting the %1$s with id: %2$d'),
|
||||
$message = __(sprintf(
|
||||
'There was an error deleting the %1$s with id: %2$d',
|
||||
Inflector::humanize($this->modelClass), $id
|
||||
);
|
||||
));
|
||||
if ($this->_validSession) {
|
||||
$this->controller->Session->setFlash($message);
|
||||
$this->controller->redirect($this->redirect);
|
||||
|
|
|
@ -133,7 +133,7 @@ class Inflector {
|
|||
'/(drive)s$/i' => '\1',
|
||||
'/([^fo])ves$/i' => '\1fe',
|
||||
'/(^analy)ses$/i' => '\1sis',
|
||||
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
|
||||
'/(analy|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
|
||||
'/([ti])a$/i' => '\1um',
|
||||
'/(p)eople$/i' => '\1\2erson',
|
||||
'/(m)en$/i' => '\1an',
|
||||
|
|
|
@ -244,10 +244,10 @@ class CakeSchema extends Object {
|
|||
|
||||
if (in_array($table, $currentTables)) {
|
||||
$key = array_search($table, $currentTables);
|
||||
if (empty($tables[$Object->table])) {
|
||||
$tables[$Object->table] = $this->__columns($Object);
|
||||
$tables[$Object->table]['indexes'] = $db->index($Object);
|
||||
$tables[$Object->table]['tableParameters'] = $db->readTableParameters($table);
|
||||
if (empty($tables[$table])) {
|
||||
$tables[$table] = $this->__columns($Object);
|
||||
$tables[$table]['indexes'] = $db->index($Object);
|
||||
$tables[$table]['tableParameters'] = $db->readTableParameters($table);
|
||||
unset($currentTables[$key]);
|
||||
}
|
||||
if (!empty($Object->hasAndBelongsToMany)) {
|
||||
|
@ -256,12 +256,12 @@ class CakeSchema extends Object {
|
|||
$class = $assocData['with'];
|
||||
}
|
||||
if (is_object($Object->$class)) {
|
||||
$table = $db->fullTableName($Object->$class, false);
|
||||
if (in_array($table, $currentTables)) {
|
||||
$withTable = $db->fullTableName($Object->$class, false);
|
||||
if (in_array($withTable, $currentTables)) {
|
||||
$key = array_search($table, $currentTables);
|
||||
$tables[$Object->$class->table] = $this->__columns($Object->$class);
|
||||
$tables[$Object->$class->table]['indexes'] = $db->index($Object->$class);
|
||||
$tables[$Object->$class->table]['tableParameters'] = $db->readTableParameters($table);
|
||||
$tables[$withTable] = $this->__columns($Object->$class);
|
||||
$tables[$withTable]['indexes'] = $db->index($Object->$class);
|
||||
$tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable);
|
||||
unset($currentTables[$key]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -500,14 +500,16 @@ class Model extends Object {
|
|||
/**
|
||||
* Bind model associations on the fly.
|
||||
*
|
||||
* If $reset is false, association will not be reset
|
||||
* If `$reset` is false, association will not be reset
|
||||
* to the originals defined in the model
|
||||
*
|
||||
* Example: Add a new hasOne binding to the Profile model not
|
||||
* defined in the model source code:
|
||||
* <code>
|
||||
* $this->User->bindModel( array('hasOne' => array('Profile')) );
|
||||
* </code>
|
||||
*
|
||||
* `$this->User->bindModel( array('hasOne' => array('Profile')) );`
|
||||
*
|
||||
* Bindings that are not made permanent will be reset by the next Model::find() call on this
|
||||
* model.
|
||||
*
|
||||
* @param array $params Set of bindings (indexed by binding type)
|
||||
* @param boolean $reset Set to false to make the binding permanent
|
||||
|
@ -544,9 +546,10 @@ class Model extends Object {
|
|||
*
|
||||
* Example: Turn off the associated Model Support request,
|
||||
* to temporarily lighten the User model:
|
||||
* <code>
|
||||
* $this->User->unbindModel( array('hasMany' => array('Supportrequest')) );
|
||||
* </code>
|
||||
*
|
||||
* `$this->User->unbindModel( array('hasMany' => array('Supportrequest')) );`
|
||||
*
|
||||
* unbound models that are not made permanent will reset with the next call to Model::find()
|
||||
*
|
||||
* @param array $params Set of bindings to unbind (indexed by binding type)
|
||||
* @param boolean $reset Set to false to make the unbinding permanent
|
||||
|
@ -1885,14 +1888,15 @@ class Model extends Object {
|
|||
if (!$cascade && !$callbacks) {
|
||||
return $db->delete($this, $conditions);
|
||||
} else {
|
||||
$ids = Set::extract(
|
||||
$this->find('all', array_merge(array(
|
||||
$ids = $this->find('all', array_merge(array(
|
||||
'fields' => "{$this->alias}.{$this->primaryKey}",
|
||||
'recursive' => 0), compact('conditions'))
|
||||
),
|
||||
"{n}.{$this->alias}.{$this->primaryKey}"
|
||||
);
|
||||
if ($ids === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ids = Set::extract($ids, "{n}.{$this->alias}.{$this->primaryKey}");
|
||||
if (empty($ids)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ class FormHelper extends AppHelper {
|
|||
if (is_array($validateProperties)) {
|
||||
|
||||
$dims = Set::countDim($validateProperties);
|
||||
if ($dims == 1) {
|
||||
if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
|
||||
$validateProperties = array($validateProperties);
|
||||
}
|
||||
|
||||
|
|
|
@ -311,10 +311,7 @@ class JsHelper extends AppHelper {
|
|||
$event = $this->event('click', $requestString, $options);
|
||||
}
|
||||
if (isset($options['buffer']) && $options['buffer'] == false) {
|
||||
$opts = array();
|
||||
if (isset($options['safe'])) {
|
||||
$opts['safe'] = $options['safe'];
|
||||
}
|
||||
$opts = array_intersect_key(array('safe' => null), $options);
|
||||
$out .= $this->Html->scriptBlock($event, $opts);
|
||||
}
|
||||
return $out;
|
||||
|
@ -387,7 +384,8 @@ class JsHelper extends AppHelper {
|
|||
$event = $this->event('click', $requestString, $options);
|
||||
}
|
||||
if (isset($options['buffer']) && $options['buffer'] == false) {
|
||||
$out .= $this->Html->scriptBlock($event, $options);
|
||||
$opts = array_intersect_key(array('safe' => null), $options);
|
||||
$out .= $this->Html->scriptBlock($event, $opts);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class MediaView extends View {
|
|||
*
|
||||
* @param object $controller
|
||||
*/
|
||||
function __construct(&$controller = null) {
|
||||
function __construct(&$controller) {
|
||||
parent::__construct($controller);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ if (Configure::read() == 0):
|
|||
$this->cakeError('error404');
|
||||
endif;
|
||||
?>
|
||||
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.'), Configure::version()); ?></h2>
|
||||
<a href="http://cakephp.lighthouseapp.com/projects/42648/changelog-1-3-0-RC4"><?php __('Read the changelog'); ?> </a>
|
||||
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.', true), Configure::version()); ?></h2>
|
||||
<a href="http://cakephp.lighthouseapp.com/projects/42648/changelog-1-3-0"><?php echo __('Read the changelog'); ?> </a>
|
||||
<?php
|
||||
if (Configure::read() > 0):
|
||||
Debugger::checkSecurityKeys();
|
||||
|
|
|
@ -69,6 +69,7 @@ class TestDispatcher extends Dispatcher {
|
|||
* @return void
|
||||
*/
|
||||
protected function _stop() {
|
||||
$this->stopped = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1325,6 +1326,11 @@ class DispatcherTest extends CakeTestCase {
|
|||
$url = 'test_dispatch_pages/camelCased';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertEqual('TestDispatchPages', $controller->name);
|
||||
|
||||
$url = 'test_dispatch_pages/camelCased/something. .';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertEqual($controller->params['pass'][0], 'something. .', 'Period was chopped off. %s');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1905,13 +1911,48 @@ class DispatcherTest extends CakeTestCase {
|
|||
));
|
||||
$this->assertNoErrors();
|
||||
|
||||
$Dispatcher->params = $Dispatcher->parseParams('ccss/cake.generic.css');
|
||||
ob_start();
|
||||
$Dispatcher->asset('ccss/cake.generic.css');
|
||||
$result = ob_get_clean();
|
||||
$this->assertTrue($Dispatcher->stopped);
|
||||
|
||||
header('HTTP/1.1 200 Ok');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that asset filters work for theme and plugin assets
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testAssetFilterForThemeAndPlugins() {
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
Configure::write('Asset.filter', array(
|
||||
'js' => '',
|
||||
'css' => ''
|
||||
));
|
||||
$Dispatcher->asset('theme/test_theme/ccss/cake.generic.css');
|
||||
$this->assertTrue($Dispatcher->stopped);
|
||||
|
||||
$Dispatcher->stopped = false;
|
||||
$Dispatcher->asset('theme/test_theme/cjs/debug_kit.js');
|
||||
$this->assertTrue($Dispatcher->stopped);
|
||||
|
||||
$Dispatcher->stopped = false;
|
||||
$Dispatcher->asset('test_plugin/ccss/cake.generic.css');
|
||||
$this->assertTrue($Dispatcher->stopped);
|
||||
|
||||
$Dispatcher->stopped = false;
|
||||
$Dispatcher->asset('test_plugin/cjs/debug_kit.js');
|
||||
$this->assertTrue($Dispatcher->stopped);
|
||||
|
||||
$Dispatcher->stopped = false;
|
||||
$Dispatcher->asset('css/ccss/debug_kit.css');
|
||||
$this->assertFalse($Dispatcher->stopped);
|
||||
|
||||
$Dispatcher->stopped = false;
|
||||
$Dispatcher->asset('js/cjs/debug_kit.js');
|
||||
$this->assertFalse($Dispatcher->stopped);
|
||||
}
|
||||
/**
|
||||
* testFullPageCachingDispatch method
|
||||
*
|
||||
|
|
|
@ -441,6 +441,26 @@ class ControllerTest extends CakeTestCase {
|
|||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* testLoadModel method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testLoadModel() {
|
||||
$Controller =& new Controller();
|
||||
|
||||
$this->assertFalse(isset($Controller->ControllerPost));
|
||||
|
||||
$result = $Controller->loadModel('ControllerPost');
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(is_a($Controller->ControllerPost, 'ControllerPost'));
|
||||
$this->assertTrue(in_array('ControllerPost', $Controller->modelNames));
|
||||
|
||||
ClassRegistry::flush();
|
||||
unset($Controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* testConstructClasses method
|
||||
*
|
||||
|
|
|
@ -116,6 +116,10 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEqual(Inflector::singularize('niches'), 'niche');
|
||||
$this->assertEqual(Inflector::singularize('waves'), 'wave');
|
||||
$this->assertEqual(Inflector::singularize('bureaus'), 'bureau');
|
||||
$this->assertEqual(Inflector::singularize('genetic_analyses'), 'genetic_analysis');
|
||||
$this->assertEqual(Inflector::singularize('doctor_diagnoses'), 'doctor_diagnosis');
|
||||
$this->assertEqual(Inflector::singularize('parantheses'), 'paranthesis');
|
||||
|
||||
$this->assertEqual(Inflector::singularize(''), '');
|
||||
}
|
||||
|
||||
|
|
|
@ -448,6 +448,33 @@ class SchemaCrossDatabaseFixture extends CakeTestFixture {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* SchemaPrefixAuthUser class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class SchemaPrefixAuthUser extends CakeTestModel {
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $name = 'SchemaPrefixAuthUser';
|
||||
/**
|
||||
* table prefix
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $tablePrefix = 'auth_';
|
||||
/**
|
||||
* useTable
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $useTable = 'users';
|
||||
}
|
||||
|
||||
/**
|
||||
* CakeSchemaTest
|
||||
*
|
||||
|
@ -523,7 +550,6 @@ class CakeSchemaTest extends CakeTestCase {
|
|||
|
||||
$expected = array('comments', 'datatypes', 'posts', 'posts_tags', 'tags');
|
||||
$this->assertEqual(array_keys($read['tables']), $expected);
|
||||
|
||||
foreach ($read['tables'] as $table => $fields) {
|
||||
$this->assertEqual(array_keys($fields), array_keys($this->Schema->tables[$table]));
|
||||
}
|
||||
|
@ -551,6 +577,25 @@ class CakeSchemaTest extends CakeTestCase {
|
|||
$this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* test read() with tablePrefix properties.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testSchemaReadWithTablePrefix() {
|
||||
$model =& new SchemaPrefixAuthUser();
|
||||
|
||||
$Schema =& new CakeSchema();
|
||||
$read = $Schema->read(array(
|
||||
'connection' => 'test_suite',
|
||||
'name' => 'TestApp',
|
||||
'models' => array('SchemaPrefixAuthUser')
|
||||
));
|
||||
unset($read['tables']['missing']);
|
||||
$this->assertTrue(isset($read['tables']['auth_users']), 'auth_users key missing %s');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* test reading schema from plugins.
|
||||
*
|
||||
|
|
|
@ -423,6 +423,12 @@ class ModelDeleteTest extends BaseModelTest {
|
|||
|
||||
$result = $TestModel->deleteAll(array('Article.user_id' => 999));
|
||||
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s');
|
||||
|
||||
$this->expectError();
|
||||
ob_start();
|
||||
$result = $TestModel->deleteAll(array('Article.non_existent_field' => 999));
|
||||
ob_get_clean();
|
||||
$this->assertFalse($result, 'deleteAll returned true when find query generated sql error. %s');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1558,6 +1558,36 @@ class RouterTest extends CakeTestCase {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that requests with a trailing dot don't loose the do.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testParsingWithTrailingPeriod() {
|
||||
Router::reload();
|
||||
$result = Router::parse('/posts/view/something.');
|
||||
$this->assertEqual($result['pass'][0], 'something.', 'Period was chopped off %s');
|
||||
|
||||
$result = Router::parse('/posts/view/something. . .');
|
||||
$this->assertEqual($result['pass'][0], 'something. . .', 'Period was chopped off %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that requests with a trailing dot don't loose the do.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testParsingWithTrailingPeriodAndParseExtensions() {
|
||||
Router::reload();
|
||||
Router::parseExtensions('json');
|
||||
|
||||
$result = Router::parse('/posts/view/something.');
|
||||
$this->assertEqual($result['pass'][0], 'something.', 'Period was chopped off %s');
|
||||
|
||||
$result = Router::parse('/posts/view/something. . .');
|
||||
$this->assertEqual($result['pass'][0], 'something. . .', 'Period was chopped off %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* testParsingWithPrefixes method
|
||||
*
|
||||
|
|
|
@ -109,8 +109,12 @@ class Contact extends CakeTestModel {
|
|||
'imrequiredtoo' => array('rule' => 'notEmpty'),
|
||||
'required_one' => array('required' => array('rule' => array('notEmpty'))),
|
||||
'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true),
|
||||
'imalsonotrequired' => array('alpha' => array('rule' => 'alphaNumeric','allowEmpty' => true),
|
||||
'between' => array('rule' => array('between', 5, 30))));
|
||||
'imalsonotrequired' => array(
|
||||
'alpha' => array('rule' => 'alphaNumeric','allowEmpty' => true),
|
||||
'between' => array('rule' => array('between', 5, 30)),
|
||||
),
|
||||
'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true),
|
||||
);
|
||||
|
||||
/**
|
||||
* schema method
|
||||
|
@ -5593,6 +5597,20 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.imnotrequiredeither');
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
'label' => array('for' => 'ContactImnotrequiredeither'),
|
||||
'Imnotrequiredeither',
|
||||
'/label',
|
||||
'input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][imnotrequiredeither]',
|
||||
'id' => 'ContactImnotrequiredeither'
|
||||
),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
extract($this->dateRegex);
|
||||
$now = strtotime('now');
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
App::import('Core', array('Helper', 'AppHelper', 'ClassRegistry', 'Controller', 'Model'));
|
||||
App::import('Helper', array('Html', 'Form'));
|
||||
|
||||
if (!defined('FULL_BASE_URL')) {
|
||||
define('FULL_BASE_URL', 'http://cakephp.org');
|
||||
}
|
||||
|
||||
/**
|
||||
* TheHtmlTestController class
|
||||
*
|
||||
|
@ -157,6 +161,10 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$expected = array('a' => array('href' => '/home'), 'preg:/\/home/', '/a');
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->link('Posts', array('controller' => 'posts', 'action' => 'index', 'full_base' => true));
|
||||
$expected = array('a' => array('href' => FULL_BASE_URL . '/posts'), 'Posts', '/a');
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?'));
|
||||
$expected = array(
|
||||
'a' => array('href' => '/home', 'onclick' => 'return confirm('Are you sure you want to do this?');'),
|
||||
|
|
|
@ -456,6 +456,43 @@ CODE;
|
|||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that no buffer works with submit() and that parameters are leaking into the script tag.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testSubmitWithNoBuffer() {
|
||||
$this->_useMock();
|
||||
$options = array('update' => '#content', 'id' => 'test-submit', 'buffer' => false, 'safe' => false);
|
||||
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'serialize-code', array('serializeform', '*'));
|
||||
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'serialize-code', array('serializeForm', '*'));
|
||||
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'ajax-code', array('request', '*'));
|
||||
$this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'event-handler', array('event', '*'));
|
||||
|
||||
$this->Js->TestJsEngine->expectAt(0, 'dispatchMethod', array('get', '*'));
|
||||
$this->Js->TestJsEngine->expectAt(1, 'dispatchMethod', array(new PatternExpectation('/serializeForm/i'), '*'));
|
||||
$this->Js->TestJsEngine->expectAt(2, 'dispatchMethod', array('request', '*'));
|
||||
|
||||
$params = array(
|
||||
'update' => $options['update'], 'buffer' => false, 'safe' => false, 'data' => 'serialize-code',
|
||||
'method' => 'post', 'dataExpression' => true
|
||||
);
|
||||
$this->Js->TestJsEngine->expectAt(3, 'dispatchMethod', array(
|
||||
'event', array('click', "ajax-code", $params)
|
||||
));
|
||||
|
||||
$result = $this->Js->submit('Save', $options);
|
||||
$expected = array(
|
||||
'div' => array('class' => 'submit'),
|
||||
'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'),
|
||||
'/div',
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
'event-handler',
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that Object::Object() is not breaking json output in JsHelper
|
||||
*
|
||||
|
|
|
@ -45,12 +45,12 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'nextPage' => true,
|
||||
'pageCount' => 7,
|
||||
'defaults' => array(
|
||||
'order' => 'Article.date ASC',
|
||||
'order' => array('Article.date' => 'asc'),
|
||||
'limit' => 9,
|
||||
'conditions' => array()
|
||||
),
|
||||
'options' => array(
|
||||
'order' => 'Article.date ASC',
|
||||
'order' => array('Article.date' => 'asc'),
|
||||
'limit' => 9,
|
||||
'page' => 1,
|
||||
'conditions' => array()
|
||||
|
@ -298,6 +298,12 @@ class PaginatorHelperTest extends CakeTestCase {
|
|||
'order' => array('Article.title' => 'desc'
|
||||
)));
|
||||
$this->assertEqual('Article.title', $result);
|
||||
|
||||
$result = $this->Paginator->sortKey('Article', array('sort' => 'Article.title'));
|
||||
$this->assertEqual($result, 'Article.title');
|
||||
|
||||
$result = $this->Paginator->sortKey('Article', array('sort' => 'Article'));
|
||||
$this->assertEqual($result, 'Article');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,17 @@ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php';
|
|||
* @subpackage cake.tests.lib
|
||||
*/
|
||||
class CakeHtmlReporter extends CakeBaseReporter {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $charset
|
||||
* @param string $params
|
||||
* @return void
|
||||
*/
|
||||
function __construct($charset = 'utf-8', $params = array()) {
|
||||
$params = array_map(array($this, '_htmlEntities'), $params);
|
||||
parent::__construct($charset, $params);
|
||||
}
|
||||
/**
|
||||
* Paints the top of the web page setting the
|
||||
* title to the name of the starting test.
|
||||
|
@ -39,7 +49,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
$this->sendNoCacheHeaders();
|
||||
$this->paintDocumentStart();
|
||||
$this->paintTestMenu();
|
||||
echo "<h2>$testName</h2>\n";
|
||||
printf("<h2>%s</h2>\n", $this->_htmlEntities($testName));
|
||||
echo "<ul class='tests'>\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class TestManager {
|
|||
$this->appTest = true;
|
||||
}
|
||||
if (isset($_GET['plugin'])) {
|
||||
$this->pluginTest = $_GET['plugin'];
|
||||
$this->pluginTest = htmlentities($_GET['plugin']);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,8 +127,11 @@ class TestManager {
|
|||
public function runTestCase($testCaseFile, &$reporter, $testing = false) {
|
||||
$testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile;
|
||||
|
||||
if (!file_exists($testCaseFileWithPath)) {
|
||||
trigger_error(sprintf(__('Test case %s cannot be found', true), $testCaseFile), E_USER_ERROR);
|
||||
if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) {
|
||||
trigger_error(
|
||||
sprintf(__("Test case %s cannot be found", true), htmlentities($testCaseFile)),
|
||||
E_USER_ERROR
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -151,8 +154,14 @@ class TestManager {
|
|||
public function runGroupTest($groupTestName, &$reporter) {
|
||||
$filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension;
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
trigger_error(sprintf(__('Group test %s cannot be found at %s', true), $groupTestName, $filePath), E_USER_ERROR);
|
||||
if (!file_exists($filePath) || strpos($filePath, '..')) {
|
||||
trigger_error(sprintf(
|
||||
__("Group test %s cannot be found at %s", true),
|
||||
htmlentities($groupTestName),
|
||||
htmlentities($filePath)
|
||||
),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
require_once $filePath;
|
||||
|
|
Loading…
Add table
Reference in a new issue