Skip to content

Commit

Permalink
Merge branch 'master' into 2.4
Browse files Browse the repository at this point in the history
Conflicts:
	lib/Cake/Utility/CakeTime.php
	lib/Cake/VERSION.txt
  • Loading branch information
markstory committed Aug 12, 2013
2 parents 37cefe9 + 6ce10b2 commit 26769ed
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/Controller/PagesController.php
Expand Up @@ -58,7 +58,7 @@ public function display() {

$count = count($path);
if (!$count) {
$this->redirect('/');
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;

Expand Down
6 changes: 3 additions & 3 deletions app/View/Layouts/flash.ctp
Expand Up @@ -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 }
Expand All @@ -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>
8 changes: 4 additions & 4 deletions app/View/Layouts/rss/default.ctp
@@ -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(
Expand Down
12 changes: 6 additions & 6 deletions app/View/Pages/home.ctp
Expand Up @@ -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>
Expand All @@ -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>
Expand Down
18 changes: 8 additions & 10 deletions lib/Cake/Console/Templates/default/actions/controller_actions.ctp
Expand Up @@ -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'));
return $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.'));
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> could not be saved. Please, try again.'));
<?php endif; ?>
}
}
<?php
foreach (array('belongsTo', 'hasAndBelongsToMany') as $assoc):
Expand Down Expand Up @@ -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'));
return $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.'));
$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);
Expand Down Expand Up @@ -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'));
}
Expand Up @@ -50,7 +50,7 @@ public function display() {

$count = count($path);
if (!$count) {
$this->redirect('/');
return $this->redirect('/');
}
$page = $subpage = $title_for_layout = null;

Expand Down
5 changes: 2 additions & 3 deletions lib/Cake/Controller/Scaffold.php
Expand Up @@ -329,10 +329,9 @@ protected function _scaffoldDelete(CakeRequest $request) {
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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -313,7 +313,7 @@ public function getVersion() {
* 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) {
Expand Down
26 changes: 26 additions & 0 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -248,6 +248,20 @@ public function testTimeAgoInWordsAccuracy() {
);
$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);
}

/**
Expand Down Expand Up @@ -335,6 +349,18 @@ public function testTimeAgoInWordsNegativeValues() {
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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/test_app/Controller/PagesController.php
Expand Up @@ -59,7 +59,7 @@ public function display() {

$count = count($path);
if (!$count) {
$this->redirect('/');
return $this->redirect('/');
}
$page = $subpage = $titleForLayout = null;

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/test_app/Controller/TestsAppsController.php
Expand Up @@ -49,7 +49,7 @@ public function set_action() {
}

public function redirect_to() {
$this->redirect('http://cakephp.org');
return $this->redirect('http://cakephp.org');
}

}
60 changes: 44 additions & 16 deletions lib/Cake/Utility/CakeTime.php
Expand Up @@ -858,48 +858,76 @@ public static function timeAgoInWords($dateTime, $options = array()) {
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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Utility/Security.php
Expand Up @@ -99,7 +99,7 @@ public static function validateAuthKey($authKey) {
*
* @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
Expand Down

0 comments on commit 26769ed

Please sign in to comment.