Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing whitespace and removig calls to Helper::output() introduced by…

… error
  • Loading branch information...
commit 09b466f8aab0b4a26a5f5f10eb5e183ffc5846b5 1 parent 0b3758d
@lorenzo lorenzo authored
View
16 cake/libs/i18n.php
@@ -524,21 +524,21 @@ function __loadLocaleDefinition($file, $domain = null) {
*/
function __parseLiteralValue($string) {
$string = $string[1];
- if (substr($string,0,2) === $this->__escape . 'x') {
+ if (substr($string, 0, 2) === $this->__escape . 'x') {
$delimiter = $this->__escape . 'x';
- return join('',array_map('chr',array_map('hexdec',array_filter(explode($delimiter,$string)))));
+ return join('',array_map('chr', array_map('hexdec',array_filter(explode($delimiter, $string)))));
}
- if (substr($string,0,2) === $this->__escape . 'd') {
+ if (substr($string, 0, 2) === $this->__escape . 'd') {
$delimiter = $this->__escape . 'd';
- return join('',array_map('chr',array_filter(explode($delimiter,$string))));
+ return join('',array_map('chr', array_filter(explode($delimiter, $string))));
}
if ($string[0] === $this->__escape && isset($string[1]) && is_numeric($string[1])) {
$delimiter = $this->__escape;
- return join('',array_map('chr',array_filter(explode($delimiter,$string))));
+ return join('', array_map('chr', array_filter(explode($delimiter, $string))));
}
- if (substr($string,0,3) === 'U00') {
+ if (substr($string, 0, 3) === 'U00') {
$delimiter = 'U00';
- return join('',array_map('chr',array_map('hexdec',array_filter(explode($delimiter,$string)))));
+ return join('', array_map('chr', array_map('hexdec', array_filter(explode($delimiter, $string)))));
}
return $string;
}
@@ -551,7 +551,7 @@ function __parseLiteralValue($string) {
* @return mixed translated format string if only value or array of translated strings for corresponding format.
* @access private
*/
- function __translateTime($format,$domain) {
+ function __translateTime($format, $domain) {
if (!empty($this->__domains['LC_TIME'][$this->__lang][$domain][$format])) {
if (($trans = $this->__domains[$this->category][$this->__lang][$domain][$format])) {
return $trans;
View
60 cake/libs/view/helpers/time.php
@@ -41,7 +41,7 @@ function convertSpecifiers($format, $time = null) {
$time = time();
}
$this->__time = $time;
- return preg_replace_callback('/\%(\w+)/',array($this,'__translateSpecifier'),$format);
+ return preg_replace_callback('/\%(\w+)/', array($this, '__translateSpecifier'), $format);
}
/**
@@ -54,21 +54,21 @@ function convertSpecifiers($format, $time = null) {
function __translateSpecifier($specifier) {
switch ($specifier[1]) {
case 'a':
- $abday = __c('abday',5,true);
+ $abday = __c('abday', 5, true);
if (is_array($abday)) {
- return $abday[date('w',$this->__time)];
+ return $abday[date('w', $this->__time)];
}
break;
case 'A':
$day = __c('day',5,true);
if (is_array($day)) {
- return $day[date('w',$this->__time)];
+ return $day[date('w', $this->__time)];
}
break;
case 'c':
$format = __c('d_t_fmt',5,true);
if ($format != 'd_t_fmt') {
- return $this->convertSpecifiers($format,$this->__time);
+ return $this->convertSpecifiers($format, $this->__time);
}
break;
case 'C':
@@ -76,18 +76,18 @@ function __translateSpecifier($specifier) {
case 'D':
return '%m/%d/%y';
case 'eS' :
- return date('jS',$this->__time);
+ return date('jS', $this->__time);
case 'b':
case 'h':
- $months = __c('abmon',5,true);
+ $months = __c('abmon', 5, true);
if (is_array($months)) {
- return $months[date('n',$this->__time) -1];
+ return $months[date('n', $this->__time) -1];
}
return '%b';
case 'B':
$months = __c('mon',5,true);
if (is_array($months)) {
- return $months[date('n',$this->__time) -1];
+ return $months[date('n', $this->__time) -1];
}
break;
case 'n':
@@ -96,16 +96,16 @@ function __translateSpecifier($specifier) {
case 'P':
$default = array('am' => 0, 'pm' => 1);
$meridiem = $default[date('a',$this->__time)];
- $format = __c('am_pm',5,true);
+ $format = __c('am_pm', 5, true);
if (is_array($format)) {
$meridiem = $format[$meridiem];
return ($specifier[1] == 'P') ? strtolower($meridiem) : strtoupper($meridiem);
}
break;
case 'r':
- $complete = __c('t_fmt_ampm',5,true);
+ $complete = __c('t_fmt_ampm', 5, true);
if ($complete != 't_fmt_ampm') {
- return str_replace('%p',$this->__translateSpecifier(array('%p','p')),$complete);
+ return str_replace('%p',$this->__translateSpecifier(array('%p', 'p')),$complete);
}
break;
case 'R':
@@ -117,15 +117,15 @@ function __translateSpecifier($specifier) {
case 'u':
return ($weekDay = date('w', $this->__time)) ? $weekDay : 7;
case 'x':
- $format = __c('d_fmt',5,true);
+ $format = __c('d_fmt', 5, true);
if ($format != 'd_fmt') {
- return $this->convertSpecifiers($format,$this->__time);
+ return $this->convertSpecifiers($format, $this->__time);
}
break;
case 'X':
$format = __c('t_fmt',5,true);
if ($format != 't_fmt') {
- return $this->convertSpecifiers($format,$this->__time);
+ return $this->convertSpecifiers($format, $this->__time);
}
break;
}
@@ -190,9 +190,8 @@ function nice($dateString = null, $userOffset = null) {
} else {
$date = time();
}
- $format = $this->convertSpecifiers('%a, %b %eS %Y, %H:%M',$date);
- $ret = strftime($format, $date);
- return $this->output($ret);
+ $format = $this->convertSpecifiers('%a, %b %eS %Y, %H:%M', $date);
+ return strftime($format, $date);
}
/**
@@ -217,11 +216,11 @@ function niceShort($dateString = null, $userOffset = null) {
} elseif ($this->wasYesterday($date)) {
$ret = sprintf(__('Yesterday, %s',true), strftime("%H:%M", $date));
} else {
- $format = $this->convertSpecifiers("%b %eS{$y}, %H:%M",$date);
+ $format = $this->convertSpecifiers("%b %eS{$y}, %H:%M", $date);
$ret = strftime($format, $date);
}
- return $this->output($ret);
+ return $ret;
}
/**
@@ -239,8 +238,7 @@ function daysAsSql($begin, $end, $fieldName, $userOffset = null) {
$begin = date('Y-m-d', $begin) . ' 00:00:00';
$end = date('Y-m-d', $end) . ' 23:59:59';
- $ret ="($fieldName >= '$begin') AND ($fieldName <= '$end')";
- return $this->output($ret);
+ return "($fieldName >= '$begin') AND ($fieldName <= '$end')";
}
/**
@@ -255,7 +253,7 @@ function daysAsSql($begin, $end, $fieldName, $userOffset = null) {
function dayAsSql($dateString, $fieldName, $userOffset = null) {
$date = $this->fromString($dateString, $userOffset);
$ret = $this->daysAsSql($dateString, $dateString, $fieldName);
- return $this->output($ret);
+ return $ret;
}
/**
@@ -359,7 +357,7 @@ function toQuarter($dateString, $range = false) {
break;
}
}
- return $this->output($date);
+ return $date;
}
/**
@@ -371,7 +369,7 @@ function toQuarter($dateString, $range = false) {
*/
function toUnix($dateString, $userOffset = null) {
$ret = $this->fromString($dateString, $userOffset);
- return $this->output($ret);
+ return $ret;
}
/**
@@ -384,7 +382,7 @@ function toUnix($dateString, $userOffset = null) {
function toAtom($dateString, $userOffset = null) {
$date = $this->fromString($dateString, $userOffset);
$ret = date('Y-m-d\TH:i:s\Z', $date);
- return $this->output($ret);
+ return $ret;
}
/**
@@ -397,7 +395,7 @@ function toAtom($dateString, $userOffset = null) {
function toRSS($dateString, $userOffset = null) {
$date = $this->fromString($dateString, $userOffset);
$ret = date("r", $date);
- return $this->output($ret);
+ return $ret;
}
/**
@@ -577,7 +575,7 @@ function timeAgoInWords($dateTime, $options = array()) {
$relativeDate = sprintf(__('%s ago', true), $relativeDate);
}
}
- return $this->output($relativeDate);
+ return $relativeDate;
}
/**
@@ -656,7 +654,7 @@ function format($format, $date = null, $invalid = false, $userOffset = null) {
if (is_numeric($_time) && $time === false) {
$format = $date;
- return $this->i18nFormat($_time,$format,$invalid,$userOffset);
+ return $this->i18nFormat($_time, $format, $invalid, $userOffset);
}
if ($time === false && $invalid !== false) {
return $invalid;
@@ -682,8 +680,8 @@ function i18nFormat($date, $format = null, $invalid = false, $userOffset = null)
if (empty($format)) {
$format = '%x';
}
- $format = $this->convertSpecifiers($format,$date);
- return strftime($format,$date);
+ $format = $this->convertSpecifiers($format, $date);
+ return strftime($format, $date);
}
}
?>
View
14 cake/tests/cases/libs/i18n.test.php
@@ -2593,15 +2593,15 @@ function testTimeDefinition() {
Configure::write('Config.language', 'po');
$result = __c('d_fmt', 5, true);
$expected = '%m/%d/%Y';
- $this->assertEqual($result,$expected);
+ $this->assertEqual($result, $expected);
- $result = __c('am_pm',5,true);
- $expected = array('AM','PM');
- $this->assertEqual($result,$expected);
+ $result = __c('am_pm', 5, true);
+ $expected = array('AM', 'PM');
+ $this->assertEqual($result, $expected);
- $result = __c('abmon',5,true);
- $expected = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
- $this->assertEqual($result,$expected);
+ $result = __c('abmon', 5, true);
+ $expected = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
+ $this->assertEqual($result, $expected);
}
/**
View
56 cake/tests/cases/libs/view/helpers/time.test.php
@@ -664,79 +664,79 @@ function testConvertSpecifiers() {
Configure::write('Config.language', 'time_test');
$time = 1263485619; // Thu Jan 14 11:43:39 2010
- $result = $this->Time->convertSpecifiers('%a',$time);
+ $result = $this->Time->convertSpecifiers('%a', $time);
$expected = 'jue';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%A',$time);
+ $result = $this->Time->convertSpecifiers('%A', $time);
$expected = 'jueves';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%c',$time);
+ $result = $this->Time->convertSpecifiers('%c', $time);
$expected = 'jue %d ene %Y %H:%M:%S %Z';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%C',$time);
+ $result = $this->Time->convertSpecifiers('%C', $time);
$expected = '20';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%D',$time);
+ $result = $this->Time->convertSpecifiers('%D', $time);
$expected = '%m/%d/%y';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%b',$time);
+ $result = $this->Time->convertSpecifiers('%b', $time);
$expected = 'ene';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%h',$time);
+ $result = $this->Time->convertSpecifiers('%h', $time);
$expected = 'ene';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%B',$time);
+ $result = $this->Time->convertSpecifiers('%B', $time);
$expected = 'enero';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%n',$time);
+ $result = $this->Time->convertSpecifiers('%n', $time);
$expected = "\n";
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%n',$time);
+ $result = $this->Time->convertSpecifiers('%n', $time);
$expected = "\n";
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%p',$time);
+ $result = $this->Time->convertSpecifiers('%p', $time);
$expected = 'AM';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%P',$time);
+ $result = $this->Time->convertSpecifiers('%P', $time);
$expected = 'am';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%r',$time);
+ $result = $this->Time->convertSpecifiers('%r', $time);
$expected = '%I:%M:%S AM';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%R',$time);
+ $result = $this->Time->convertSpecifiers('%R', $time);
$expected = '11:43';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%t',$time);
+ $result = $this->Time->convertSpecifiers('%t', $time);
$expected = "\t";
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%T',$time);
+ $result = $this->Time->convertSpecifiers('%T', $time);
$expected = '%H:%M:%S';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%u',$time);
+ $result = $this->Time->convertSpecifiers('%u', $time);
$expected = 4;
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%x',$time);
+ $result = $this->Time->convertSpecifiers('%x', $time);
$expected = '%d/%m/%y';
$this->assertEqual($result, $expected);
- $result = $this->Time->convertSpecifiers('%X',$time);
+ $result = $this->Time->convertSpecifiers('%X', $time);
$expected = '%H:%M:%S';
$this->assertEqual($result, $expected);
}
@@ -756,19 +756,19 @@ function testI18nFormat() {
$result = $this->Time->i18nFormat($time);
$expected = '14/01/10';
- $this->assertEqual($result,$expected);
+ $this->assertEqual($result, $expected);
- $result = $this->Time->i18nFormat($time,'%c');
+ $result = $this->Time->i18nFormat($time, '%c');
$expected = 'jue 14 ene 2010 13:59:28 VET';
- $this->assertEqual($result,$expected);
+ $this->assertEqual($result, $expected);
- $result = $this->Time->i18nFormat($time,'Time is %r, and date is %x');
+ $result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
$expected = 'Time is 01:59:28 PM, and date is 14/01/10';
- $this->assertEqual($result,$expected);
+ $this->assertEqual($result, $expected);
- $result = $this->Time->i18nFormat('invalid date','%x','Date invalid');
+ $result = $this->Time->i18nFormat('invalid date', '%x', 'Date invalid');
$expected = 'Date invalid';
- $this->assertEqual($result,$expected);
+ $this->assertEqual($result, $expected);
}
/**
@@ -779,8 +779,8 @@ function testI18nFormat() {
*/
function testFormatNewSyntax() {
$time = time();
- $this->assertEqual($this->Time->format($time),$this->Time->i18nFormat($time));
- $this->assertEqual($this->Time->format($time,'%c'),$this->Time->i18nFormat($time,'%c'));
+ $this->assertEqual($this->Time->format($time), $this->Time->i18nFormat($time));
+ $this->assertEqual($this->Time->format($time, '%c'), $this->Time->i18nFormat($time, '%c'));
}
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.