Merge branch 'master' into 2.4

Conflicts:
	lib/Cake/Utility/CakeTime.php
	lib/Cake/VERSION.txt
This commit is contained in:
mark_story 2013-08-12 14:39:02 -04:00
commit 26769edd04
13 changed files with 101 additions and 50 deletions

View file

@ -58,7 +58,7 @@ class PagesController extends AppController {
$count = count($path); $count = count($path);
if (!$count) { if (!$count) {
$this->redirect('/'); return $this->redirect('/');
} }
$page = $subpage = $title_for_layout = null; $page = $subpage = $title_for_layout = null;

View file

@ -23,9 +23,9 @@
<?php echo $this->Html->charset(); ?> <?php echo $this->Html->charset(); ?>
<title><?php echo $page_title; ?></title> <title><?php echo $page_title; ?></title>
<?php if (Configure::read('debug') == 0) { ?> <?php if (Configure::read('debug') == 0): ?>
<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/> <meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/>
<?php } ?> <?php endif; ?>
<style><!-- <style><!--
P { text-align:center; font:bold 1.1em sans-serif } P { text-align:center; font:bold 1.1em sans-serif }
A { color:#444; text-decoration:none } A { color:#444; text-decoration:none }

View file

@ -1,10 +1,10 @@
<?php <?php
if (!isset($channel)) { if (!isset($channel)):
$channel = array(); $channel = array();
} endif;
if (!isset($channel['title'])) { if (!isset($channel['title'])):
$channel['title'] = $title_for_layout; $channel['title'] = $title_for_layout;
} endif;
echo $this->Rss->document( echo $this->Rss->document(
$this->Rss->channel( $this->Rss->channel(

View file

@ -101,12 +101,12 @@ if (isset($filePresent)):
} catch (Exception $connectionError) { } catch (Exception $connectionError) {
$connected = false; $connected = false;
$errorMsg = $connectionError->getMessage(); $errorMsg = $connectionError->getMessage();
if (method_exists($connectionError, 'getAttributes')) { if (method_exists($connectionError, 'getAttributes')):
$attributes = $connectionError->getAttributes(); $attributes = $connectionError->getAttributes();
if (isset($errorMsg['message'])) { if (isset($errorMsg['message'])):
$errorMsg .= '<br />' . $attributes['message']; $errorMsg .= '<br />' . $attributes['message'];
} endif;
} endif;
} }
?> ?>
<p> <p>
@ -127,13 +127,13 @@ if (isset($filePresent)):
<?php endif; ?> <?php endif; ?>
<?php <?php
App::uses('Validation', 'Utility'); App::uses('Validation', 'Utility');
if (!Validation::alphaNumeric('cakephp')) { if (!Validation::alphaNumeric('cakephp')):
echo '<p><span class="notice">'; echo '<p><span class="notice">';
echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.'); echo __d('cake_dev', 'PCRE has not been compiled with Unicode support.');
echo '<br/>'; echo '<br/>';
echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring'); echo __d('cake_dev', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>'; echo '</span></p>';
} endif;
?> ?>
<p> <p>

View file

@ -58,14 +58,13 @@
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved')); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
return $this->redirect(array('action' => 'index')); return $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index')); return $this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} else { }
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.')); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php endif; ?> <?php endif; ?>
} }
}
<?php <?php
foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc): foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc):
foreach ($modelObj->{$assoc} as $associationName => $relation): foreach ($modelObj->{$assoc} as $associationName => $relation):
@ -101,13 +100,12 @@
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved')); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
return $this->redirect(array('action' => 'index')); return $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index')); return $this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} else { }
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.')); $this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php endif; ?> <?php endif; ?>
}
} else { } else {
$options = array('conditions' => array('<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id)); $options = array('conditions' => array('<?php echo $currentModelName; ?>.' . $this-><?php echo $currentModelName; ?>->primaryKey => $id));
$this->request->data = $this-><?php echo $currentModelName; ?>->find('first', $options); $this->request->data = $this-><?php echo $currentModelName; ?>->find('first', $options);
@ -147,13 +145,13 @@
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted')); $this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
return $this->redirect(array('action' => 'index')); return $this->redirect(array('action' => 'index'));
<?php else: ?> <?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index')); return $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
} }
<?php if ($wannaUseSession): ?> <?php if ($wannaUseSession): ?>
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted')); $this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'));
<?php else: ?> <?php else: ?>
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index')); return $this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
<?php endif; ?> <?php endif; ?>
return $this->redirect(array('action' => 'index')); return $this->redirect(array('action' => 'index'));
} }

View file

@ -50,7 +50,7 @@ class PagesController extends AppController {
$count = count($path); $count = count($path);
if (!$count) { if (!$count) {
$this->redirect('/'); return $this->redirect('/');
} }
$page = $subpage = $title_for_layout = null; $page = $subpage = $title_for_layout = null;

View file

@ -329,10 +329,9 @@ class Scaffold {
protected function _sendMessage($message) { protected function _sendMessage($message) {
if ($this->_validSession) { if ($this->_validSession) {
$this->controller->Session->setFlash($message); $this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect); return $this->controller->redirect($this->redirect);
} else {
$this->controller->flash($message, $this->redirect);
} }
$this->controller->flash($message, $this->redirect);
} }
/** /**

View file

@ -313,7 +313,7 @@ class DboSource extends DataSource {
* Returns a quoted and escaped string of $data for use in an SQL statement. * Returns a quoted and escaped string of $data for use in an SQL statement.
* *
* @param string $data String to be prepared for use in an SQL statement * @param string $data String to be prepared for use in an SQL statement
* @param string $column The column into which this data will be inserted * @param string $column The column datatype into which this data will be inserted.
* @return string Quoted and escaped data * @return string Quoted and escaped data
*/ */
public function value($data, $column = null) { public function value($data, $column = null) {

View file

@ -248,6 +248,20 @@ class CakeTimeTest extends CakeTestCase {
); );
$expected = '1 year'; $expected = '1 year';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
$result = $this->Time->timeAgoInWords(
strtotime('+58 minutes'),
array('accuracy' => 'hour')
);
$expected = 'in about an hour';
$this->assertEquals($expected, $result);
$result = $this->Time->timeAgoInWords(
strtotime('+23 hours'),
array('accuracy' => 'day')
);
$expected = 'in about a day';
$this->assertEquals($expected, $result);
} }
/** /**
@ -335,6 +349,18 @@ class CakeTimeTest extends CakeTestCase {
array('end' => '2 years') array('end' => '2 years')
); );
$this->assertEquals('1 year, 1 month, 5 days ago', $result); $this->assertEquals('1 year, 1 month, 5 days ago', $result);
$result = $this->Time->timeAgoInWords(
strtotime('-58 minutes'),
array('accuracy' => 'hour')
);
$this->assertEquals('about an hour ago', $result);
$result = $this->Time->timeAgoInWords(
strtotime('-23 hours'),
array('accuracy' => 'day')
);
$this->assertEquals('about a day ago', $result);
} }
/** /**

View file

@ -59,7 +59,7 @@ class PagesController extends AppController {
$count = count($path); $count = count($path);
if (!$count) { if (!$count) {
$this->redirect('/'); return $this->redirect('/');
} }
$page = $subpage = $titleForLayout = null; $page = $subpage = $titleForLayout = null;

View file

@ -49,7 +49,7 @@ class TestsAppsController extends AppController {
} }
public function redirect_to() { public function redirect_to() {
$this->redirect('http://cakephp.org'); return $this->redirect('http://cakephp.org');
} }
} }

View file

@ -858,48 +858,76 @@ class CakeTime {
return sprintf($absoluteString, date($format, $inSeconds)); return sprintf($absoluteString, date($format, $inSeconds));
} }
$f = $accuracy['second']; $fWord = $accuracy['second'];
if ($years > 0) { if ($years > 0) {
$f = $accuracy['year']; $fWord = $accuracy['year'];
} elseif (abs($months) > 0) { } elseif (abs($months) > 0) {
$f = $accuracy['month']; $fWord = $accuracy['month'];
} elseif (abs($weeks) > 0) { } elseif (abs($weeks) > 0) {
$f = $accuracy['week']; $fWord = $accuracy['week'];
} elseif (abs($days) > 0) { } elseif (abs($days) > 0) {
$f = $accuracy['day']; $fWord = $accuracy['day'];
} elseif (abs($hours) > 0) { } elseif (abs($hours) > 0) {
$f = $accuracy['hour']; $fWord = $accuracy['hour'];
} elseif (abs($minutes) > 0) { } elseif (abs($minutes) > 0) {
$f = $accuracy['minute']; $fWord = $accuracy['minute'];
} }
$f = str_replace(array('year', 'month', 'week', 'day', 'hour', 'minute', 'second'), array(1, 2, 3, 4, 5, 6, 7), $f); $fNum = str_replace(array('year', 'month', 'week', 'day', 'hour', 'minute', 'second'), array(1, 2, 3, 4, 5, 6, 7), $fWord);
$relativeDate = ''; $relativeDate = '';
if ($f >= 1 && $years > 0) { if ($fNum >= 1 && $years > 0) {
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d year', '%d years', $years, $years); $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d year', '%d years', $years, $years);
} }
if ($f >= 2 && $months > 0) { if ($fNum >= 2 && $months > 0) {
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d month', '%d months', $months, $months); $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d month', '%d months', $months, $months);
} }
if ($f >= 3 && $weeks > 0) { if ($fNum >= 3 && $weeks > 0) {
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d week', '%d weeks', $weeks, $weeks); $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d week', '%d weeks', $weeks, $weeks);
} }
if ($f >= 4 && $days > 0) { if ($fNum >= 4 && $days > 0) {
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days); $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d day', '%d days', $days, $days);
} }
if ($f >= 5 && $hours > 0) { if ($fNum >= 5 && $hours > 0) {
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d hour', '%d hours', $hours, $hours); $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d hour', '%d hours', $hours, $hours);
} }
if ($f >= 6 && $minutes > 0) { if ($fNum >= 6 && $minutes > 0) {
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d minute', '%d minutes', $minutes, $minutes); $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d minute', '%d minutes', $minutes, $minutes);
} }
if ($f >= 7 && $seconds > 0) { if ($fNum >= 7 && $seconds > 0) {
$relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d second', '%d seconds', $seconds, $seconds); $relativeDate .= ($relativeDate ? ', ' : '') . __dn('cake', '%d second', '%d seconds', $seconds, $seconds);
} }
$aboutAgo = array(
'second' => __d('cake', 'about a second ago'),
'minute' => __d('cake', 'about a minute ago'),
'hour' => __d('cake', 'about an hour ago'),
'day' => __d('cake', 'about a day ago'),
'week' => __d('cake', 'about a week ago'),
'year' => __d('cake', 'about a year ago')
);
$aboutIn = array(
'second' => __d('cake', 'in about a second'),
'minute' => __d('cake', 'in about a minute'),
'hour' => __d('cake', 'in about an hour'),
'day' => __d('cake', 'in about a day'),
'week' => __d('cake', 'in about a week'),
'year' => __d('cake', 'in about a year')
);
// When time has passed
if (!$backwards) { if (!$backwards) {
return sprintf($relativeString, $relativeDate); if ($relativeDate) {
return __d('cake', '%s ago', $relativeDate);
}
return $aboutAgo[$fWord];
}
// When time is to come
if (!$relativeDate) {
return $aboutIn[$fWord];
} }
return $relativeDate; return $relativeDate;

View file

@ -99,7 +99,7 @@ class Security {
* *
* @param string $string String to hash * @param string $string String to hash
* @param string $type Method to use (sha1/sha256/md5/blowfish) * @param string $type Method to use (sha1/sha256/md5/blowfish)
* @param mixed $salt If true, automatically appends the application's salt * @param mixed $salt If true, automatically prepends the application's salt
* value to $string (Security.salt). If you are using blowfish the salt * value to $string (Security.salt). If you are using blowfish the salt
* must be false or a previously generated salt. * must be false or a previously generated salt.
* @return string Hash * @return string Hash