From 09b466f8aab0b4a26a5f5f10eb5e183ffc5846b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 14 Jan 2010 15:38:48 -0430 Subject: [PATCH] Fixing whitespace and removig calls to Helper::output() introduced by error --- cake/libs/i18n.php | 16 ++--- cake/libs/view/helpers/time.php | 60 +++++++++---------- cake/tests/cases/libs/i18n.test.php | 14 ++--- .../cases/libs/view/helpers/time.test.php | 56 ++++++++--------- 4 files changed, 72 insertions(+), 74 deletions(-) diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index a98227527..358989fc7 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -524,21 +524,21 @@ class I18n extends Object { */ 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 @@ class I18n extends Object { * @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; diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 9c62ca8fd..0f54facb6 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -41,7 +41,7 @@ class TimeHelper extends AppHelper { $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 @@ class TimeHelper extends AppHelper { 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 @@ class TimeHelper extends AppHelper { 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 @@ class TimeHelper extends AppHelper { 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 @@ class TimeHelper extends AppHelper { 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 @@ class TimeHelper extends AppHelper { } 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 @@ class TimeHelper extends AppHelper { } 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 @@ class TimeHelper extends AppHelper { $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 @@ class TimeHelper extends AppHelper { 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 @@ class TimeHelper extends AppHelper { break; } } - return $this->output($date); + return $date; } /** @@ -371,7 +369,7 @@ class TimeHelper extends AppHelper { */ function toUnix($dateString, $userOffset = null) { $ret = $this->fromString($dateString, $userOffset); - return $this->output($ret); + return $ret; } /** @@ -384,7 +382,7 @@ class TimeHelper extends AppHelper { 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 @@ class TimeHelper extends AppHelper { function toRSS($dateString, $userOffset = null) { $date = $this->fromString($dateString, $userOffset); $ret = date("r", $date); - return $this->output($ret); + return $ret; } /** @@ -577,7 +575,7 @@ class TimeHelper extends AppHelper { $relativeDate = sprintf(__('%s ago', true), $relativeDate); } } - return $this->output($relativeDate); + return $relativeDate; } /** @@ -656,7 +654,7 @@ class TimeHelper extends AppHelper { 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 @@ class TimeHelper extends AppHelper { if (empty($format)) { $format = '%x'; } - $format = $this->convertSpecifiers($format,$date); - return strftime($format,$date); + $format = $this->convertSpecifiers($format, $date); + return strftime($format, $date); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/i18n.test.php b/cake/tests/cases/libs/i18n.test.php index 53ba2f8a0..69b26fceb 100644 --- a/cake/tests/cases/libs/i18n.test.php +++ b/cake/tests/cases/libs/i18n.test.php @@ -2593,15 +2593,15 @@ class I18nTest extends CakeTestCase { 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); } /** diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index cee35196e..7b70d4ed7 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -664,79 +664,79 @@ class TimeHelperTest extends CakeTestCase { 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 @@ class TimeHelperTest extends CakeTestCase { $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 @@ class TimeHelperTest extends CakeTestCase { */ 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')); } } ?> \ No newline at end of file