@@ -28,8 +28,9 @@ discard block |
||
| 28 | 28 | $this->detect_language_env(); |
| 29 | 29 | $the_one_language = current(array_intersect($this->detect_language_files(), $this->detect_language_env())); |
| 30 | 30 | |
| 31 | - if($the_one_language) |
|
| 32 | - $this->setForcedLang($the_one_language); |
|
| 31 | + if($the_one_language) { |
|
| 32 | + $this->setForcedLang($the_one_language); |
|
| 33 | + } |
|
| 33 | 34 | |
| 34 | 35 | return $the_one_language; |
| 35 | 36 | } |
@@ -37,13 +38,16 @@ discard block |
||
| 37 | 38 | public function detect_language_files() |
| 38 | 39 | { |
| 39 | 40 | $files = FileSystem::preg_scandir(dirname($this->filePath), '/.json$/'); |
| 40 | - if(empty($files)) |
|
| 41 | - return []; |
|
| 41 | + if(empty($files)) { |
|
| 42 | + return []; |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | $files = implode('',$files); |
| 44 | 46 | $res = preg_match_all('/([a-z]{3})\.json/', $files, $m); |
| 45 | - if($res) // false or 0 is none found |
|
| 47 | + if($res) { |
|
| 48 | + // false or 0 is none found |
|
| 46 | 49 | $this->detected_language_files = $m[1]; |
| 50 | + } |
|
| 47 | 51 | return $this->detected_language_files; |
| 48 | 52 | } |
| 49 | 53 | |
@@ -91,8 +95,9 @@ discard block |
||
| 91 | 95 | // remove illegal userLangs |
| 92 | 96 | foreach ($userLangs as $key => $value) { |
| 93 | 97 | // only allow a-z, A-Z and 0-9 and _ and - |
| 94 | - if (preg_match('/^[a-zA-Z0-9_-]*$/', $value) === 1) |
|
| 95 | - $this->detected_language_env[$key] = $value; |
|
| 98 | + if (preg_match('/^[a-zA-Z0-9_-]*$/', $value) === 1) { |
|
| 99 | + $this->detected_language_env[$key] = $value; |
|
| 100 | + } |
|
| 96 | 101 | } |
| 97 | 102 | |
| 98 | 103 | return $this->detected_language_env; |
@@ -119,12 +124,13 @@ discard block |
||
| 119 | 124 | return __FUNCTION__.': error'; |
| 120 | 125 | } |
| 121 | 126 | |
| 122 | - if($amount_of_days === -1) |
|
| 123 | - return L('DATETIME_RANGE_YESTERDAY'); |
|
| 124 | - elseif($amount_of_days === 0) |
|
| 125 | - return L('DATETIME_RANGE_TODAY'); |
|
| 126 | - elseif($amount_of_days === 1) |
|
| 127 | - return L('DATETIME_RANGE_TOMORROW'); |
|
| 127 | + if($amount_of_days === -1) { |
|
| 128 | + return L('DATETIME_RANGE_YESTERDAY'); |
|
| 129 | + } elseif($amount_of_days === 0) { |
|
| 130 | + return L('DATETIME_RANGE_TODAY'); |
|
| 131 | + } elseif($amount_of_days === 1) { |
|
| 132 | + return L('DATETIME_RANGE_TOMORROW'); |
|
| 133 | + } |
|
| 128 | 134 | |
| 129 | 135 | |
| 130 | 136 | $datetime_parts = [ |
@@ -141,18 +147,21 @@ discard block |
||
| 141 | 147 | $ordering = []; |
| 142 | 148 | foreach($datetime_parts as $unit => $label) |
| 143 | 149 | { |
| 144 | - if(!isset($date_diff[$unit])) |
|
| 145 | - continue; |
|
| 150 | + if(!isset($date_diff[$unit])) { |
|
| 151 | + continue; |
|
| 152 | + } |
|
| 146 | 153 | |
| 147 | 154 | $qty = (int)$date_diff[$unit]; |
| 148 | 155 | |
| 149 | - if($qty === 0) |
|
| 150 | - continue; |
|
| 156 | + if($qty === 0) { |
|
| 157 | + continue; |
|
| 158 | + } |
|
| 151 | 159 | |
| 152 | - if(isset($options['abbrev'])) |
|
| 153 | - $label.= '_ABBREV'; |
|
| 154 | - elseif($qty > 1) |
|
| 155 | - $label.= '_PLURAL'; |
|
| 160 | + if(isset($options['abbrev'])) { |
|
| 161 | + $label.= '_ABBREV'; |
|
| 162 | + } elseif($qty > 1) { |
|
| 163 | + $label.= '_PLURAL'; |
|
| 164 | + } |
|
| 156 | 165 | |
| 157 | 166 | $ordering[$unit] = $qty.' '.L($label).'.'; |
| 158 | 167 | } |
@@ -164,27 +173,31 @@ discard block |
||
| 164 | 173 | |
| 165 | 174 | public static function time($time_string, $short=true) |
| 166 | 175 | { |
| 167 | - if ($short === true) |
|
| 168 | - $time_string = substr($time_string, 0, 5); |
|
| 176 | + if ($short === true) { |
|
| 177 | + $time_string = substr($time_string, 0, 5); |
|
| 178 | + } |
|
| 169 | 179 | return $time_string; |
| 170 | 180 | } |
| 171 | 181 | |
| 172 | 182 | public static function human_date($date_string, $short=true) |
| 173 | 183 | { |
| 174 | - if($date_string === '0000-00-00' || empty($date_string)) |
|
| 175 | - return L('MODEL_common_VALUE_EMPTY'); |
|
| 184 | + if($date_string === '0000-00-00' || empty($date_string)) { |
|
| 185 | + return L('MODEL_common_VALUE_EMPTY'); |
|
| 186 | + } |
|
| 176 | 187 | |
| 177 | - if(preg_match('/^[0-9]{4}$/', $date_string) === 1) |
|
| 178 | - return intval($date_string); |
|
| 188 | + if(preg_match('/^[0-9]{4}$/', $date_string) === 1) { |
|
| 189 | + return intval($date_string); |
|
| 190 | + } |
|
| 179 | 191 | |
| 180 | 192 | list($year, $month, $day) = explode('-',$date_string); |
| 181 | 193 | |
| 182 | 194 | $ret = intval($day).' '.L("DATETIME_CALENDAR_MONTH_$month"); |
| 183 | 195 | |
| 184 | - if($short === true && Dato::format(null, 'Y') === $year) |
|
| 185 | - return $ret; |
|
| 186 | - else |
|
| 187 | - return "$ret $year"; |
|
| 196 | + if($short === true && Dato::format(null, 'Y') === $year) { |
|
| 197 | + return $ret; |
|
| 198 | + } else { |
|
| 199 | + return "$ret $year"; |
|
| 200 | + } |
|
| 188 | 201 | } |
| 189 | 202 | |
| 190 | 203 | public static function human_month($date_string) |