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);
if (!$count) {
$this->redirect('/');
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;

View file

@ -23,9 +23,9 @@
<?php echo $this->Html->charset(); ?>
<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; ?>"/>
<?php } ?>
<?php endif; ?>
<style><!--
P { text-align:center; font:bold 1.1em sans-serif }
A { color:#444; text-decoration:none }
@ -35,4 +35,4 @@ A:HOVER { text-decoration: underline; color:#44E }
<body>
<p><a href="<?php echo $url; ?>"><?php echo $message; ?></a></p>
</body>
</html>
</html>

View file

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

View file

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

View file

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

View file

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

View file

@ -329,10 +329,9 @@ class Scaffold {
protected function _sendMessage($message) {
if ($this->_validSession) {
$this->controller->Session->setFlash($message);
$this->controller->redirect($this->redirect);
} else {
$this->controller->flash($message, $this->redirect);
return $this->controller->redirect($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.
*
* @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
*/
public function value($data, $column = null) {

View file

@ -248,6 +248,20 @@ class CakeTimeTest extends CakeTestCase {
);
$expected = '1 year';
$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')
);
$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);
if (!$count) {
$this->redirect('/');
return $this->redirect('/');
}
$page = $subpage = $titleForLayout = null;

View file

@ -49,7 +49,7 @@ class TestsAppsController extends AppController {
}
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));
}
$f = $accuracy['second'];
$fWord = $accuracy['second'];
if ($years > 0) {
$f = $accuracy['year'];
$fWord = $accuracy['year'];
} elseif (abs($months) > 0) {
$f = $accuracy['month'];
$fWord = $accuracy['month'];
} elseif (abs($weeks) > 0) {
$f = $accuracy['week'];
$fWord = $accuracy['week'];
} elseif (abs($days) > 0) {
$f = $accuracy['day'];
$fWord = $accuracy['day'];
} elseif (abs($hours) > 0) {
$f = $accuracy['hour'];
$fWord = $accuracy['hour'];
} 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 = '';
if ($f >= 1 && $years > 0) {
if ($fNum >= 1 && $years > 0) {
$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);
}
if ($f >= 3 && $weeks > 0) {
if ($fNum >= 3 && $weeks > 0) {
$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);
}
if ($f >= 5 && $hours > 0) {
if ($fNum >= 5 && $hours > 0) {
$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);
}
if ($f >= 7 && $seconds > 0) {
if ($fNum >= 7 && $seconds > 0) {
$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) {
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;

View file

@ -99,7 +99,7 @@ class Security {
*
* @param string $string String to hash
* @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
* must be false or a previously generated salt.
* @return string Hash