Merge remote branch 'markstory/2.0' into 2.0

This commit is contained in:
predominant 2010-05-03 10:40:03 +10:00
commit c2002dada7
32 changed files with 364 additions and 118 deletions

View file

@ -18,4 +18,5 @@
// @license MIT License (http://www.opensource.org/licenses/mit-license.php) // @license MIT License (http://www.opensource.org/licenses/mit-license.php)
// +--------------------------------------------------------------------------------------------+ // // +--------------------------------------------------------------------------------------------+ //
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
1.3.0-RC4 1.3.0

View file

@ -17,5 +17,5 @@
* @since CakePHP(tm) v 1.1.11.4062 * @since CakePHP(tm) v 1.1.11.4062
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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';
?> ?>

View file

@ -27,10 +27,10 @@
public function <?php echo $admin ?>view($id = null) { public function <?php echo $admin ?>view($id = null) {
if (!$id) { if (!$id) {
<?php if ($wannaUseSession): ?> <?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')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?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; ?> <?php endif; ?>
} }
$this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id)); $this->set('<?php echo $singularName; ?>', $this-><?php echo $currentModelName; ?>->read(null, $id));
@ -42,14 +42,14 @@
$this-><?php echo $currentModelName; ?>->create(); $this-><?php echo $currentModelName; ?>->create();
if ($this-><?php echo $currentModelName; ?>->save($this->data)) { if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
<?php if ($wannaUseSession): ?> <?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')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?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; ?> <?php endif; ?>
} else { } else {
<?php if ($wannaUseSession): ?> <?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; ?> <?php endif; ?>
} }
} }
@ -74,23 +74,23 @@
public function <?php echo $admin; ?>edit($id = null) { public function <?php echo $admin; ?>edit($id = null) {
if (!$id && empty($this->data)) { if (!$id && empty($this->data)) {
<?php if ($wannaUseSession): ?> <?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')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?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; ?> <?php endif; ?>
} }
if (!empty($this->data)) { if (!empty($this->data)) {
if ($this-><?php echo $currentModelName; ?>->save($this->data)) { if ($this-><?php echo $currentModelName; ?>->save($this->data)) {
<?php if ($wannaUseSession): ?> <?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')); $this->redirect(array('action' => 'index'));
<?php else: ?> <?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; ?> <?php endif; ?>
} else { } else {
<?php if ($wannaUseSession): ?> <?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; ?> <?php endif; ?>
} }
} }
@ -117,24 +117,24 @@
public function <?php echo $admin; ?>delete($id = null) { public function <?php echo $admin; ?>delete($id = null) {
if (!$id) { if (!$id) {
<?php if ($wannaUseSession): ?> <?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')); $this->redirect(array('action'=>'index'));
<?php else: ?> <?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; ?> <?php endif; ?>
} }
if ($this-><?php echo $currentModelName; ?>->delete($id)) { if ($this-><?php echo $currentModelName; ?>->delete($id)) {
<?php if ($wannaUseSession): ?> <?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')); $this->redirect(array('action'=>'index'));
<?php else: ?> <?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 endif; ?>
} }
<?php if ($wannaUseSession): ?> <?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: ?> <?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; ?> <?php endif; ?>
$this->redirect(array('action' => 'index')); $this->redirect(array('action' => 'index'));
} }

View file

@ -20,7 +20,7 @@
<div class="<?php echo $pluralVar;?> form"> <div class="<?php echo $pluralVar;?> form">
<?php echo "<?php echo \$this->Form->create('{$modelClass}');?>\n";?> <?php echo "<?php echo \$this->Form->create('{$modelClass}');?>\n";?>
<fieldset> <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 <?php
echo "\t<?php\n"; echo "\t<?php\n";
foreach ($fields as $field) { foreach ($fields as $field) {
@ -49,14 +49,14 @@
<?php if (strpos($action, 'add') === false): ?> <?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> <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;?> <?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 <?php
$done = array(); $done = array();
foreach ($associations as $type => $data) { foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) { foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?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(__('List " . 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(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller']; $done[] = $details['controller'];
} }
} }

View file

@ -71,22 +71,22 @@
</p> </p>
<div class="paging"> <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->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> </div>
<div class="actions"> <div class="actions">
<h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3> <h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3>
<ul> <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 <?php
$done = array(); $done = array();
foreach ($associations as $type => $data) { foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) { foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?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(__('List " . 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(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller']; $done[] = $details['controller'];
} }
} }

View file

@ -45,17 +45,17 @@ foreach ($fields as $field) {
<h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3> <h3><?php echo "<?php echo __('Actions'); ?>"; ?></h3>
<ul> <ul>
<?php <?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(__('Edit " . $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(__('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(sprintf(__('List %s'), __('{$pluralHumanName}')), array('action' => 'index')); ?> </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(sprintf(__('New %s'), __('{$singularHumanName}')), array('action' => 'add')); ?> </li>\n"; echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?> </li>\n";
$done = array(); $done = array();
foreach ($associations as $type => $data) { foreach ($associations as $type => $data) {
foreach ($data as $alias => $details) { foreach ($data as $alias => $details) {
if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
echo "\t\t<li><?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(__('List " . 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(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
$done[] = $details['controller']; $done[] = $details['controller'];
} }
} }
@ -67,12 +67,12 @@ foreach ($fields as $field) {
if (!empty($associations['hasOne'])) : if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $alias => $details): ?> foreach ($associations['hasOne'] as $alias => $details): ?>
<div class="related"> <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";?> <?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
<dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?> <dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
<?php <?php
foreach ($details['fields'] as $field) { 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&nbsp;</dd>\n"; echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n";
} }
?> ?>
@ -80,7 +80,7 @@ if (!empty($associations['hasOne'])) :
<?php echo "<?php endif; ?>\n";?> <?php echo "<?php endif; ?>\n";?>
<div class="actions"> <div class="actions">
<ul> <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> </ul>
</div> </div>
</div> </div>
@ -100,16 +100,16 @@ foreach ($relations as $alias => $details):
$otherPluralHumanName = Inflector::humanize($details['controller']); $otherPluralHumanName = Inflector::humanize($details['controller']);
?> ?>
<div class="related"> <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";?> <?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
<table cellpadding = "0" cellspacing = "0"> <table cellpadding = "0" cellspacing = "0">
<tr> <tr>
<?php <?php
foreach ($details['fields'] as $field) { 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> </tr>
<?php <?php
echo "\t<?php echo "\t<?php
@ -127,9 +127,9 @@ echo "\t<?php
} }
echo "\t\t\t<td class=\"actions\">\n"; 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(__('View'), 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(__('Edit'), 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(__('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\t</td>\n";
echo "\t\t</tr>\n"; echo "\t\t</tr>\n";
@ -139,7 +139,7 @@ echo "\t<?php endforeach; ?>\n";
<?php echo "<?php endif; ?>\n\n";?> <?php echo "<?php endif; ?>\n\n";?>
<div class="actions"> <div class="actions">
<ul> <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> </ul>
</div> </div>
</div> </div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

View file

@ -546,8 +546,14 @@ class Dispatcher extends Object {
return false; return false;
} }
$filters = Configure::read('Asset.filter'); $filters = Configure::read('Asset.filter');
$isCss = strpos($url, 'ccss/') === 0; $isCss = (
$isJs = strpos($url, 'cjs/') === 0; 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']))) { if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
header('HTTP/1.1 404 Not Found'); header('HTTP/1.1 404 Not Found');
@ -609,6 +615,7 @@ class Dispatcher extends Object {
} }
App::import('View', 'Media', false); App::import('View', 'Media', false);
$controller = null;
$Media = new MediaView($controller); $Media = new MediaView($controller);
if (isset($Media->mimeType[$ext])) { if (isset($Media->mimeType[$ext])) {
$contentType = $Media->mimeType[$ext]; $contentType = $Media->mimeType[$ext];

View file

@ -550,12 +550,10 @@ class CakeSession extends Object {
); );
break; break;
default: default:
if (empty($_SESSION)) { $config = CONFIGS . Configure::read('Session.save') . '.php';
$config = CONFIGS . Configure::read('Session.save') . '.php';
if (is_file($config)) { if (is_file($config)) {
require($config); require($config);
}
} }
break; break;
} }

View file

@ -324,6 +324,7 @@ class EmailComponent extends Object{
* Send an email using the specified content, template and layout * Send an email using the specified content, template and layout
* *
* @param mixed $content Either an array of text lines, or a string with contents * @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 $template Template to use when sending email
* @param string $layout Layout to use to enclose email body * @param string $layout Layout to use to enclose email body
* @return boolean Success * @return boolean Success

View file

@ -604,7 +604,8 @@ class Controller extends Object {
* *
* @param string $modelClass Name of model class to load * @param string $modelClass Name of model class to load
* @param mixed $id Initial ID the instanced model class should have * @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) { public function loadModel($modelClass = null, $id = null) {
if ($modelClass === null) { if ($modelClass === null) {
@ -653,6 +654,8 @@ class Controller extends Object {
$this->_persist($modelClass, true, $object); $this->_persist($modelClass, true, $object);
$this->modelNames[] = $modelClass; $this->modelNames[] = $modelClass;
} }
return true;
} }
/** /**
@ -729,7 +732,7 @@ class Controller extends Object {
} }
/** /**
* Convenience and object wrapper method for header(). Useful when doing tests and * Convenience and object wrapper method for header(). Useful when doing tests and
* asserting that particular headers have been set. * asserting that particular headers have been set.
* *
* @param string $status The header message that is being set. * @param string $status The header message that is being set.

View file

@ -222,7 +222,8 @@ class Scaffold extends Object {
function __scaffoldView($params) { function __scaffoldView($params) {
if ($this->controller->_beforeScaffold('view')) { 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])) { if (isset($params['pass'][0])) {
$this->ScaffoldModel->id = $params['pass'][0]; $this->ScaffoldModel->id = $params['pass'][0];
} elseif ($this->_validSession) { } elseif ($this->_validSession) {
@ -302,7 +303,7 @@ class Scaffold extends Object {
} }
if (!$this->ScaffoldModel->exists()) { 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) { if ($this->_validSession) {
$this->controller->Session->setFlash($message); $this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect); $this->controller->redirect($this->redirect);
@ -320,9 +321,8 @@ class Scaffold extends Object {
if ($this->ScaffoldModel->save($this->controller->data)) { if ($this->ScaffoldModel->save($this->controller->data)) {
if ($this->controller->_afterScaffoldSave($action)) { if ($this->controller->_afterScaffoldSave($action)) {
$message = sprintf(__('The %1$s has been %2$s'), $message = __(
Inflector::humanize($this->modelKey), sprintf('The %1$s has been %2$s', Inflector::humanize($this->modelKey), $success)
$success
); );
if ($this->_validSession) { if ($this->_validSession) {
$this->controller->Session->setFlash($message); $this->controller->Session->setFlash($message);
@ -336,8 +336,7 @@ class Scaffold extends Object {
} }
} else { } else {
if ($this->_validSession) { if ($this->_validSession) {
$this->controller->Session->setFlash( $this->controller->Session->setFlash(__('Please correct errors below.'));
__('Please correct errors below.'));
} }
} }
} }
@ -376,7 +375,9 @@ class Scaffold extends Object {
*/ */
function __scaffoldDelete($params = array()) { function __scaffoldDelete($params = array()) {
if ($this->controller->_beforeScaffold('delete')) { 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])) { if (isset($params['pass'][0])) {
$id = $params['pass'][0]; $id = $params['pass'][0];
} elseif ($this->_validSession) { } elseif ($this->_validSession) {
@ -388,9 +389,8 @@ class Scaffold extends Object {
} }
if ($this->ScaffoldModel->delete($id)) { if ($this->ScaffoldModel->delete($id)) {
$message = sprintf( $message = __(
__('The %1$s with id: %2$d has been deleted.'), sprintf('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id),
Inflector::humanize($this->modelClass), $id
); );
if ($this->_validSession) { if ($this->_validSession) {
$this->controller->Session->setFlash($message); $this->controller->Session->setFlash($message);
@ -400,10 +400,10 @@ class Scaffold extends Object {
return $this->_output(); return $this->_output();
} }
} else { } else {
$message = sprintf( $message = __(sprintf(
__('There was an error deleting the %1$s with id: %2$d'), 'There was an error deleting the %1$s with id: %2$d',
Inflector::humanize($this->modelClass), $id Inflector::humanize($this->modelClass), $id
); ));
if ($this->_validSession) { if ($this->_validSession) {
$this->controller->Session->setFlash($message); $this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect); $this->controller->redirect($this->redirect);

View file

@ -133,7 +133,7 @@ class Inflector {
'/(drive)s$/i' => '\1', '/(drive)s$/i' => '\1',
'/([^fo])ves$/i' => '\1fe', '/([^fo])ves$/i' => '\1fe',
'/(^analy)ses$/i' => '\1sis', '/(^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', '/([ti])a$/i' => '\1um',
'/(p)eople$/i' => '\1\2erson', '/(p)eople$/i' => '\1\2erson',
'/(m)en$/i' => '\1an', '/(m)en$/i' => '\1an',

View file

@ -244,10 +244,10 @@ class CakeSchema extends Object {
if (in_array($table, $currentTables)) { if (in_array($table, $currentTables)) {
$key = array_search($table, $currentTables); $key = array_search($table, $currentTables);
if (empty($tables[$Object->table])) { if (empty($tables[$table])) {
$tables[$Object->table] = $this->__columns($Object); $tables[$table] = $this->__columns($Object);
$tables[$Object->table]['indexes'] = $db->index($Object); $tables[$table]['indexes'] = $db->index($Object);
$tables[$Object->table]['tableParameters'] = $db->readTableParameters($table); $tables[$table]['tableParameters'] = $db->readTableParameters($table);
unset($currentTables[$key]); unset($currentTables[$key]);
} }
if (!empty($Object->hasAndBelongsToMany)) { if (!empty($Object->hasAndBelongsToMany)) {
@ -256,12 +256,12 @@ class CakeSchema extends Object {
$class = $assocData['with']; $class = $assocData['with'];
} }
if (is_object($Object->$class)) { if (is_object($Object->$class)) {
$table = $db->fullTableName($Object->$class, false); $withTable = $db->fullTableName($Object->$class, false);
if (in_array($table, $currentTables)) { if (in_array($withTable, $currentTables)) {
$key = array_search($table, $currentTables); $key = array_search($table, $currentTables);
$tables[$Object->$class->table] = $this->__columns($Object->$class); $tables[$withTable] = $this->__columns($Object->$class);
$tables[$Object->$class->table]['indexes'] = $db->index($Object->$class); $tables[$withTable]['indexes'] = $db->index($Object->$class);
$tables[$Object->$class->table]['tableParameters'] = $db->readTableParameters($table); $tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable);
unset($currentTables[$key]); unset($currentTables[$key]);
} }
} }

View file

@ -500,14 +500,16 @@ class Model extends Object {
/** /**
* Bind model associations on the fly. * 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 * to the originals defined in the model
* *
* Example: Add a new hasOne binding to the Profile model not * Example: Add a new hasOne binding to the Profile model not
* defined in the model source code: * defined in the model source code:
* <code> *
* $this->User->bindModel( array('hasOne' => array('Profile')) ); * `$this->User->bindModel( array('hasOne' => array('Profile')) );`
* </code> *
* 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 array $params Set of bindings (indexed by binding type)
* @param boolean $reset Set to false to make the binding permanent * @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, * Example: Turn off the associated Model Support request,
* to temporarily lighten the User model: * to temporarily lighten the User model:
* <code> *
* $this->User->unbindModel( array('hasMany' => array('Supportrequest')) ); * `$this->User->unbindModel( array('hasMany' => array('Supportrequest')) );`
* </code> *
* 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 array $params Set of bindings to unbind (indexed by binding type)
* @param boolean $reset Set to false to make the unbinding permanent * @param boolean $reset Set to false to make the unbinding permanent
@ -1885,14 +1888,15 @@ class Model extends Object {
if (!$cascade && !$callbacks) { if (!$cascade && !$callbacks) {
return $db->delete($this, $conditions); return $db->delete($this, $conditions);
} else { } else {
$ids = Set::extract( $ids = $this->find('all', array_merge(array(
$this->find('all', array_merge(array( 'fields' => "{$this->alias}.{$this->primaryKey}",
'fields' => "{$this->alias}.{$this->primaryKey}", 'recursive' => 0), compact('conditions'))
'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)) { if (empty($ids)) {
return true; return true;
} }

View file

@ -146,7 +146,7 @@ class FormHelper extends AppHelper {
if (is_array($validateProperties)) { if (is_array($validateProperties)) {
$dims = Set::countDim($validateProperties); $dims = Set::countDim($validateProperties);
if ($dims == 1) { if ($dims == 1 || ($dims == 2 && isset($validateProperties['rule']))) {
$validateProperties = array($validateProperties); $validateProperties = array($validateProperties);
} }

View file

@ -311,10 +311,7 @@ class JsHelper extends AppHelper {
$event = $this->event('click', $requestString, $options); $event = $this->event('click', $requestString, $options);
} }
if (isset($options['buffer']) && $options['buffer'] == false) { if (isset($options['buffer']) && $options['buffer'] == false) {
$opts = array(); $opts = array_intersect_key(array('safe' => null), $options);
if (isset($options['safe'])) {
$opts['safe'] = $options['safe'];
}
$out .= $this->Html->scriptBlock($event, $opts); $out .= $this->Html->scriptBlock($event, $opts);
} }
return $out; return $out;
@ -387,7 +384,8 @@ class JsHelper extends AppHelper {
$event = $this->event('click', $requestString, $options); $event = $this->event('click', $requestString, $options);
} }
if (isset($options['buffer']) && $options['buffer'] == false) { 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; return $out;
} }

View file

@ -95,7 +95,7 @@ class MediaView extends View {
* *
* @param object $controller * @param object $controller
*/ */
function __construct(&$controller = null) { function __construct(&$controller) {
parent::__construct($controller); parent::__construct($controller);
} }

View file

@ -20,8 +20,8 @@ if (Configure::read() == 0):
$this->cakeError('error404'); $this->cakeError('error404');
endif; endif;
?> ?>
<h2><?php echo sprintf(__('Release Notes for CakePHP %s.'), Configure::version()); ?></h2> <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-RC4"><?php __('Read the changelog'); ?> </a> <a href="http://cakephp.lighthouseapp.com/projects/42648/changelog-1-3-0"><?php echo __('Read the changelog'); ?> </a>
<?php <?php
if (Configure::read() > 0): if (Configure::read() > 0):
Debugger::checkSecurityKeys(); Debugger::checkSecurityKeys();

View file

@ -69,6 +69,7 @@ class TestDispatcher extends Dispatcher {
* @return void * @return void
*/ */
protected function _stop() { protected function _stop() {
$this->stopped = true;
return true; return true;
} }
} }
@ -1325,6 +1326,11 @@ class DispatcherTest extends CakeTestCase {
$url = 'test_dispatch_pages/camelCased'; $url = 'test_dispatch_pages/camelCased';
$controller = $Dispatcher->dispatch($url, array('return' => 1)); $controller = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertEqual('TestDispatchPages', $controller->name); $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(); $this->assertNoErrors();
$Dispatcher->params = $Dispatcher->parseParams('ccss/cake.generic.css');
ob_start(); ob_start();
$Dispatcher->asset('ccss/cake.generic.css'); $Dispatcher->asset('ccss/cake.generic.css');
$result = ob_get_clean();
$this->assertTrue($Dispatcher->stopped);
header('HTTP/1.1 200 Ok'); 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 * testFullPageCachingDispatch method
* *

View file

@ -441,6 +441,26 @@ class ControllerTest extends CakeTestCase {
App::build(); 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 * testConstructClasses method
* *

View file

@ -116,6 +116,10 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::singularize('niches'), 'niche'); $this->assertEqual(Inflector::singularize('niches'), 'niche');
$this->assertEqual(Inflector::singularize('waves'), 'wave'); $this->assertEqual(Inflector::singularize('waves'), 'wave');
$this->assertEqual(Inflector::singularize('bureaus'), 'bureau'); $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(''), ''); $this->assertEqual(Inflector::singularize(''), '');
} }

View file

@ -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 * CakeSchemaTest
* *
@ -523,7 +550,6 @@ class CakeSchemaTest extends CakeTestCase {
$expected = array('comments', 'datatypes', 'posts', 'posts_tags', 'tags'); $expected = array('comments', 'datatypes', 'posts', 'posts_tags', 'tags');
$this->assertEqual(array_keys($read['tables']), $expected); $this->assertEqual(array_keys($read['tables']), $expected);
foreach ($read['tables'] as $table => $fields) { foreach ($read['tables'] as $table => $fields) {
$this->assertEqual(array_keys($fields), array_keys($this->Schema->tables[$table])); $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'); $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. * test reading schema from plugins.
* *
@ -575,7 +620,7 @@ class CakeSchemaTest extends CakeTestCase {
$this->assertTrue(isset($read['tables']['test_plugin_comments'])); $this->assertTrue(isset($read['tables']['test_plugin_comments']));
$this->assertTrue(isset($read['tables']['posts'])); $this->assertTrue(isset($read['tables']['posts']));
$this->assertEqual(count($read['tables']), 4); $this->assertEqual(count($read['tables']), 4);
App::build(); App::build();
} }

View file

@ -423,6 +423,12 @@ class ModelDeleteTest extends BaseModelTest {
$result = $TestModel->deleteAll(array('Article.user_id' => 999)); $result = $TestModel->deleteAll(array('Article.user_id' => 999));
$this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s'); $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');
} }
/** /**

View file

@ -1558,6 +1558,36 @@ class RouterTest extends CakeTestCase {
$this->assertEqual($result, $expected); $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 * testParsingWithPrefixes method
* *

View file

@ -109,8 +109,12 @@ class Contact extends CakeTestModel {
'imrequiredtoo' => array('rule' => 'notEmpty'), 'imrequiredtoo' => array('rule' => 'notEmpty'),
'required_one' => array('required' => array('rule' => array('notEmpty'))), 'required_one' => array('required' => array('rule' => array('notEmpty'))),
'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true), 'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true),
'imalsonotrequired' => array('alpha' => array('rule' => 'alphaNumeric','allowEmpty' => true), 'imalsonotrequired' => array(
'between' => array('rule' => array('between', 5, 30)))); '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 * schema method
@ -5593,6 +5597,20 @@ class FormHelperTest extends CakeTestCase {
); );
$this->assertTags($result, $expected); $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); extract($this->dateRegex);
$now = strtotime('now'); $now = strtotime('now');

View file

@ -20,6 +20,10 @@
App::import('Core', array('Helper', 'AppHelper', 'ClassRegistry', 'Controller', 'Model')); App::import('Core', array('Helper', 'AppHelper', 'ClassRegistry', 'Controller', 'Model'));
App::import('Helper', array('Html', 'Form')); App::import('Helper', array('Html', 'Form'));
if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL', 'http://cakephp.org');
}
/** /**
* TheHtmlTestController class * TheHtmlTestController class
* *
@ -157,6 +161,10 @@ class HtmlHelperTest extends CakeTestCase {
$expected = array('a' => array('href' => '/home'), 'preg:/\/home/', '/a'); $expected = array('a' => array('href' => '/home'), 'preg:/\/home/', '/a');
$this->assertTags($result, $expected); $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?')); $result = $this->Html->link('Home', '/home', array('confirm' => 'Are you sure you want to do this?'));
$expected = array( $expected = array(
'a' => array('href' => '/home', 'onclick' => 'return confirm(&#039;Are you sure you want to do this?&#039;);'), 'a' => array('href' => '/home', 'onclick' => 'return confirm(&#039;Are you sure you want to do this?&#039;);'),
@ -358,18 +366,18 @@ class HtmlHelperTest extends CakeTestCase {
$webroot = $this->Html->webroot; $webroot = $this->Html->webroot;
$this->Html->webroot = '/testing/'; $this->Html->webroot = '/testing/';
$result = $this->Html->image('__cake_test_image.gif'); $result = $this->Html->image('__cake_test_image.gif');
$this->assertTags($result, array( $this->assertTags($result, array(
'img' => array( 'img' => array(
'src' => 'preg:/\/testing\/theme\/test_theme\/img\/__cake_test_image\.gif\?\d+/', 'src' => 'preg:/\/testing\/theme\/test_theme\/img\/__cake_test_image\.gif\?\d+/',
'alt' => '' 'alt' => ''
))); )));
$this->Html->webroot = $webroot; $this->Html->webroot = $webroot;
$dir =& new Folder(WWW_ROOT . 'theme' . DS . 'test_theme'); $dir =& new Folder(WWW_ROOT . 'theme' . DS . 'test_theme');
$dir->delete(); $dir->delete();
} }
/** /**
* test theme assets in main webroot path * test theme assets in main webroot path
* *
@ -383,7 +391,7 @@ class HtmlHelperTest extends CakeTestCase {
)); ));
$webRoot = Configure::read('App.www_root'); $webRoot = Configure::read('App.www_root');
Configure::write('App.www_root', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'webroot' . DS); Configure::write('App.www_root', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'webroot' . DS);
$webroot = $this->Html->webroot; $webroot = $this->Html->webroot;
$this->Html->theme = 'test_theme'; $this->Html->theme = 'test_theme';
$result = $this->Html->css('webroot_test'); $result = $this->Html->css('webroot_test');
@ -399,7 +407,7 @@ class HtmlHelperTest extends CakeTestCase {
'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/theme_webroot\.css/') 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/theme_webroot\.css/')
); );
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
Configure::write('App.www_root', $webRoot); Configure::write('App.www_root', $webRoot);
} }

View file

@ -456,6 +456,43 @@ CODE;
$this->assertTags($result, $expected); $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 * Test that Object::Object() is not breaking json output in JsHelper
* *

View file

@ -45,12 +45,12 @@ class PaginatorHelperTest extends CakeTestCase {
'nextPage' => true, 'nextPage' => true,
'pageCount' => 7, 'pageCount' => 7,
'defaults' => array( 'defaults' => array(
'order' => 'Article.date ASC', 'order' => array('Article.date' => 'asc'),
'limit' => 9, 'limit' => 9,
'conditions' => array() 'conditions' => array()
), ),
'options' => array( 'options' => array(
'order' => 'Article.date ASC', 'order' => array('Article.date' => 'asc'),
'limit' => 9, 'limit' => 9,
'page' => 1, 'page' => 1,
'conditions' => array() 'conditions' => array()
@ -295,9 +295,15 @@ class PaginatorHelperTest extends CakeTestCase {
*/ */
function testSortKey() { function testSortKey() {
$result = $this->Paginator->sortKey(null, array( $result = $this->Paginator->sortKey(null, array(
'order' => array('Article.title' => 'desc' 'order' => array('Article.title' => 'desc'
))); )));
$this->assertEqual('Article.title', $result); $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');
} }
/** /**

View file

@ -27,7 +27,17 @@ include_once dirname(__FILE__) . DS . 'cake_base_reporter.php';
* @subpackage cake.tests.lib * @subpackage cake.tests.lib
*/ */
class CakeHtmlReporter extends CakeBaseReporter { 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 * Paints the top of the web page setting the
* title to the name of the starting test. * title to the name of the starting test.
@ -39,7 +49,7 @@ class CakeHtmlReporter extends CakeBaseReporter {
$this->sendNoCacheHeaders(); $this->sendNoCacheHeaders();
$this->paintDocumentStart(); $this->paintDocumentStart();
$this->paintTestMenu(); $this->paintTestMenu();
echo "<h2>$testName</h2>\n"; printf("<h2>%s</h2>\n", $this->_htmlEntities($testName));
echo "<ul class='tests'>\n"; echo "<ul class='tests'>\n";
} }

View file

@ -69,7 +69,7 @@ class TestManager {
$this->appTest = true; $this->appTest = true;
} }
if (isset($_GET['plugin'])) { 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) { public function runTestCase($testCaseFile, &$reporter, $testing = false) {
$testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile; $testCaseFileWithPath = $this->_getTestsPath() . DS . $testCaseFile;
if (!file_exists($testCaseFileWithPath)) { if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) {
trigger_error(sprintf(__('Test case %s cannot be found', true), $testCaseFile), E_USER_ERROR); trigger_error(
sprintf(__("Test case %s cannot be found", true), htmlentities($testCaseFile)),
E_USER_ERROR
);
return false; return false;
} }
@ -151,8 +154,14 @@ class TestManager {
public function runGroupTest($groupTestName, &$reporter) { public function runGroupTest($groupTestName, &$reporter) {
$filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension; $filePath = $this->_getTestsPath('groups') . DS . strtolower($groupTestName) . $this->_groupExtension;
if (!file_exists($filePath)) { if (!file_exists($filePath) || strpos($filePath, '..')) {
trigger_error(sprintf(__('Group test %s cannot be found at %s', true), $groupTestName, $filePath), E_USER_ERROR); trigger_error(sprintf(
__("Group test %s cannot be found at %s", true),
htmlentities($groupTestName),
htmlentities($filePath)
),
E_USER_ERROR
);
} }
require_once $filePath; require_once $filePath;