@@ -74,38 +74,38 @@ discard block |
||
| 74 | 74 | $charset = NULL; |
| 75 | 75 | $modifier = NULL; |
| 76 | 76 | if ($locale) { |
| 77 | - if (preg_match("/^(?P<lang>[a-z]{2,3})" // language code |
|
| 78 | - ."(?:_(?P<country>[A-Z]{2}))?" // country code |
|
| 79 | - ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?" // charset |
|
| 80 | - ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
|
| 81 | - $locale, $matches)) { |
|
| 82 | - |
|
| 83 | - if (isset($matches["lang"])) $lang = $matches["lang"]; |
|
| 84 | - if (isset($matches["country"])) $country = $matches["country"]; |
|
| 85 | - if (isset($matches["charset"])) $charset = $matches["charset"]; |
|
| 86 | - if (isset($matches["modifier"])) $modifier = $matches["modifier"]; |
|
| 87 | - |
|
| 88 | - if ($modifier) { |
|
| 89 | - if ($country) { |
|
| 90 | - if ($charset) |
|
| 91 | - array_push($locale_names, "${lang}_$country.$charset@$modifier"); |
|
| 92 | - array_push($locale_names, "${lang}_$country@$modifier"); |
|
| 93 | - } elseif ($charset) |
|
| 94 | - array_push($locale_names, "${lang}.$charset@$modifier"); |
|
| 95 | - array_push($locale_names, "$lang@$modifier"); |
|
| 96 | - } |
|
| 97 | - if ($country) { |
|
| 98 | - if ($charset) |
|
| 99 | - array_push($locale_names, "${lang}_$country.$charset"); |
|
| 100 | - array_push($locale_names, "${lang}_$country"); |
|
| 101 | - } elseif ($charset) |
|
| 102 | - array_push($locale_names, "${lang}.$charset"); |
|
| 103 | - array_push($locale_names, $lang); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - // If the locale name doesn't match POSIX style, just include it as-is. |
|
| 107 | - if (!in_array($locale, $locale_names)) |
|
| 108 | - array_push($locale_names, $locale); |
|
| 77 | + if (preg_match("/^(?P<lang>[a-z]{2,3})" // language code |
|
| 78 | + ."(?:_(?P<country>[A-Z]{2}))?" // country code |
|
| 79 | + ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?" // charset |
|
| 80 | + ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
|
| 81 | + $locale, $matches)) { |
|
| 82 | + |
|
| 83 | + if (isset($matches["lang"])) $lang = $matches["lang"]; |
|
| 84 | + if (isset($matches["country"])) $country = $matches["country"]; |
|
| 85 | + if (isset($matches["charset"])) $charset = $matches["charset"]; |
|
| 86 | + if (isset($matches["modifier"])) $modifier = $matches["modifier"]; |
|
| 87 | + |
|
| 88 | + if ($modifier) { |
|
| 89 | + if ($country) { |
|
| 90 | + if ($charset) |
|
| 91 | + array_push($locale_names, "${lang}_$country.$charset@$modifier"); |
|
| 92 | + array_push($locale_names, "${lang}_$country@$modifier"); |
|
| 93 | + } elseif ($charset) |
|
| 94 | + array_push($locale_names, "${lang}.$charset@$modifier"); |
|
| 95 | + array_push($locale_names, "$lang@$modifier"); |
|
| 96 | + } |
|
| 97 | + if ($country) { |
|
| 98 | + if ($charset) |
|
| 99 | + array_push($locale_names, "${lang}_$country.$charset"); |
|
| 100 | + array_push($locale_names, "${lang}_$country"); |
|
| 101 | + } elseif ($charset) |
|
| 102 | + array_push($locale_names, "${lang}.$charset"); |
|
| 103 | + array_push($locale_names, $lang); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + // If the locale name doesn't match POSIX style, just include it as-is. |
|
| 107 | + if (!in_array($locale, $locale_names)) |
|
| 108 | + array_push($locale_names, $locale); |
|
| 109 | 109 | } |
| 110 | 110 | return $locale_names; |
| 111 | 111 | } |
@@ -114,60 +114,60 @@ discard block |
||
| 114 | 114 | * Utility function to get a StreamReader for the given text domain. |
| 115 | 115 | */ |
| 116 | 116 | function _get_reader($domain=null, $category=5, $enable_cache=true) { |
| 117 | - global $text_domains, $default_domain, $LC_CATEGORIES; |
|
| 118 | - if (!isset($domain)) $domain = $default_domain; |
|
| 119 | - if (!isset($text_domains[$domain]->l10n)) { |
|
| 120 | - // get the current locale |
|
| 121 | - $locale = _setlocale(LC_MESSAGES, 0); |
|
| 122 | - $bound_path = isset($text_domains[$domain]->path) ? |
|
| 123 | - $text_domains[$domain]->path : './'; |
|
| 124 | - $subpath = $LC_CATEGORIES[$category] ."/$domain.mo"; |
|
| 125 | - |
|
| 126 | - $locale_names = get_list_of_locales($locale); |
|
| 127 | - $input = null; |
|
| 128 | - foreach ($locale_names as $locale) { |
|
| 129 | - $full_path = $bound_path . $locale . "/" . $subpath; |
|
| 130 | - if (file_exists($full_path)) { |
|
| 131 | - $input = new FileReader($full_path); |
|
| 132 | - break; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if (!array_key_exists($domain, $text_domains)) { |
|
| 137 | - // Initialize an empty domain object. |
|
| 138 | - $text_domains[$domain] = new domain(); |
|
| 139 | - } |
|
| 140 | - $text_domains[$domain]->l10n = new gettext_reader($input, |
|
| 141 | - $enable_cache); |
|
| 142 | - } |
|
| 143 | - return $text_domains[$domain]->l10n; |
|
| 117 | + global $text_domains, $default_domain, $LC_CATEGORIES; |
|
| 118 | + if (!isset($domain)) $domain = $default_domain; |
|
| 119 | + if (!isset($text_domains[$domain]->l10n)) { |
|
| 120 | + // get the current locale |
|
| 121 | + $locale = _setlocale(LC_MESSAGES, 0); |
|
| 122 | + $bound_path = isset($text_domains[$domain]->path) ? |
|
| 123 | + $text_domains[$domain]->path : './'; |
|
| 124 | + $subpath = $LC_CATEGORIES[$category] ."/$domain.mo"; |
|
| 125 | + |
|
| 126 | + $locale_names = get_list_of_locales($locale); |
|
| 127 | + $input = null; |
|
| 128 | + foreach ($locale_names as $locale) { |
|
| 129 | + $full_path = $bound_path . $locale . "/" . $subpath; |
|
| 130 | + if (file_exists($full_path)) { |
|
| 131 | + $input = new FileReader($full_path); |
|
| 132 | + break; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if (!array_key_exists($domain, $text_domains)) { |
|
| 137 | + // Initialize an empty domain object. |
|
| 138 | + $text_domains[$domain] = new domain(); |
|
| 139 | + } |
|
| 140 | + $text_domains[$domain]->l10n = new gettext_reader($input, |
|
| 141 | + $enable_cache); |
|
| 142 | + } |
|
| 143 | + return $text_domains[$domain]->l10n; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
| 147 | 147 | * Returns whether we are using our emulated gettext API or PHP built-in one. |
| 148 | 148 | */ |
| 149 | 149 | function locale_emulation() { |
| 150 | - global $EMULATEGETTEXT; |
|
| 151 | - return $EMULATEGETTEXT; |
|
| 150 | + global $EMULATEGETTEXT; |
|
| 151 | + return $EMULATEGETTEXT; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | 155 | * Checks if the current locale is supported on this system. |
| 156 | 156 | */ |
| 157 | 157 | function _check_locale_and_function($function=false) { |
| 158 | - global $EMULATEGETTEXT; |
|
| 159 | - if ($function and !function_exists($function)) |
|
| 160 | - return false; |
|
| 161 | - return !$EMULATEGETTEXT; |
|
| 158 | + global $EMULATEGETTEXT; |
|
| 159 | + if ($function and !function_exists($function)) |
|
| 160 | + return false; |
|
| 161 | + return !$EMULATEGETTEXT; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
| 165 | 165 | * Get the codeset for the given domain. |
| 166 | 166 | */ |
| 167 | 167 | function _get_codeset($domain=null) { |
| 168 | - global $text_domains, $default_domain, $LC_CATEGORIES; |
|
| 169 | - if (!isset($domain)) $domain = $default_domain; |
|
| 170 | - return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
|
| 168 | + global $text_domains, $default_domain, $LC_CATEGORIES; |
|
| 169 | + if (!isset($domain)) $domain = $default_domain; |
|
| 170 | + return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -176,9 +176,9 @@ discard block |
||
| 176 | 176 | function _encode($text) { |
| 177 | 177 | $target_encoding = _get_codeset(); |
| 178 | 178 | if (function_exists("mb_detect_encoding")) { |
| 179 | - $source_encoding = mb_detect_encoding($text); |
|
| 180 | - if ($source_encoding != $target_encoding) |
|
| 181 | - $text = mb_convert_encoding($text, $target_encoding, $source_encoding); |
|
| 179 | + $source_encoding = mb_detect_encoding($text); |
|
| 180 | + if ($source_encoding != $target_encoding) |
|
| 181 | + $text = mb_convert_encoding($text, $target_encoding, $source_encoding); |
|
| 182 | 182 | } |
| 183 | 183 | return $text; |
| 184 | 184 | } |
@@ -191,185 +191,185 @@ discard block |
||
| 191 | 191 | */ |
| 192 | 192 | function _get_default_locale($locale) { |
| 193 | 193 | if ($locale == '') // emulate variable support |
| 194 | - return getenv('LANG'); |
|
| 194 | + return getenv('LANG'); |
|
| 195 | 195 | else |
| 196 | - return $locale; |
|
| 196 | + return $locale; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | 200 | * Sets a requested locale, if needed emulates it. |
| 201 | 201 | */ |
| 202 | 202 | function _setlocale($category, $locale) { |
| 203 | - global $CURRENTLOCALE, $EMULATEGETTEXT; |
|
| 204 | - if ($locale === 0) { // use === to differentiate between string "0" |
|
| 205 | - if ($CURRENTLOCALE != '') |
|
| 206 | - return $CURRENTLOCALE; |
|
| 207 | - else |
|
| 208 | - // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 209 | - // even if we tried to read locale without setting it first |
|
| 210 | - return _setlocale($category, $CURRENTLOCALE); |
|
| 211 | - } else { |
|
| 212 | - if (function_exists('setlocale')) { |
|
| 213 | - $ret = setlocale($category, $locale); |
|
| 214 | - if (($locale == '' and !$ret) or // failed setting it by env |
|
| 215 | - ($locale != '' and $ret != $locale)) { // failed setting it |
|
| 216 | - // Failed setting it according to environment. |
|
| 217 | - $CURRENTLOCALE = _get_default_locale($locale); |
|
| 218 | - $EMULATEGETTEXT = 1; |
|
| 219 | - } else { |
|
| 220 | - $CURRENTLOCALE = $ret; |
|
| 221 | - $EMULATEGETTEXT = 0; |
|
| 222 | - } |
|
| 223 | - } else { |
|
| 224 | - // No function setlocale(), emulate it all. |
|
| 225 | - $CURRENTLOCALE = _get_default_locale($locale); |
|
| 226 | - $EMULATEGETTEXT = 1; |
|
| 227 | - } |
|
| 228 | - // Allow locale to be changed on the go for one translation domain. |
|
| 229 | - global $text_domains, $default_domain; |
|
| 230 | - if (array_key_exists($default_domain, $text_domains)) { |
|
| 231 | - unset($text_domains[$default_domain]->l10n); |
|
| 232 | - } |
|
| 233 | - return $CURRENTLOCALE; |
|
| 234 | - } |
|
| 203 | + global $CURRENTLOCALE, $EMULATEGETTEXT; |
|
| 204 | + if ($locale === 0) { // use === to differentiate between string "0" |
|
| 205 | + if ($CURRENTLOCALE != '') |
|
| 206 | + return $CURRENTLOCALE; |
|
| 207 | + else |
|
| 208 | + // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 209 | + // even if we tried to read locale without setting it first |
|
| 210 | + return _setlocale($category, $CURRENTLOCALE); |
|
| 211 | + } else { |
|
| 212 | + if (function_exists('setlocale')) { |
|
| 213 | + $ret = setlocale($category, $locale); |
|
| 214 | + if (($locale == '' and !$ret) or // failed setting it by env |
|
| 215 | + ($locale != '' and $ret != $locale)) { // failed setting it |
|
| 216 | + // Failed setting it according to environment. |
|
| 217 | + $CURRENTLOCALE = _get_default_locale($locale); |
|
| 218 | + $EMULATEGETTEXT = 1; |
|
| 219 | + } else { |
|
| 220 | + $CURRENTLOCALE = $ret; |
|
| 221 | + $EMULATEGETTEXT = 0; |
|
| 222 | + } |
|
| 223 | + } else { |
|
| 224 | + // No function setlocale(), emulate it all. |
|
| 225 | + $CURRENTLOCALE = _get_default_locale($locale); |
|
| 226 | + $EMULATEGETTEXT = 1; |
|
| 227 | + } |
|
| 228 | + // Allow locale to be changed on the go for one translation domain. |
|
| 229 | + global $text_domains, $default_domain; |
|
| 230 | + if (array_key_exists($default_domain, $text_domains)) { |
|
| 231 | + unset($text_domains[$default_domain]->l10n); |
|
| 232 | + } |
|
| 233 | + return $CURRENTLOCALE; |
|
| 234 | + } |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | 238 | * Sets the path for a domain. |
| 239 | 239 | */ |
| 240 | 240 | function _bindtextdomain($domain, $path) { |
| 241 | - global $text_domains; |
|
| 242 | - // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
|
| 243 | - if (substr(php_uname(), 0, 7) == "Windows") { |
|
| 244 | - if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
| 245 | - $path .= '\\'; |
|
| 246 | - } else { |
|
| 247 | - if ($path[strlen($path)-1] != '/') |
|
| 248 | - $path .= '/'; |
|
| 249 | - } |
|
| 250 | - if (!array_key_exists($domain, $text_domains)) { |
|
| 251 | - // Initialize an empty domain object. |
|
| 252 | - $text_domains[$domain] = new domain(); |
|
| 253 | - } |
|
| 254 | - $text_domains[$domain]->path = $path; |
|
| 241 | + global $text_domains; |
|
| 242 | + // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
|
| 243 | + if (substr(php_uname(), 0, 7) == "Windows") { |
|
| 244 | + if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
| 245 | + $path .= '\\'; |
|
| 246 | + } else { |
|
| 247 | + if ($path[strlen($path)-1] != '/') |
|
| 248 | + $path .= '/'; |
|
| 249 | + } |
|
| 250 | + if (!array_key_exists($domain, $text_domains)) { |
|
| 251 | + // Initialize an empty domain object. |
|
| 252 | + $text_domains[$domain] = new domain(); |
|
| 253 | + } |
|
| 254 | + $text_domains[$domain]->path = $path; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * Specify the character encoding in which the messages from the DOMAIN message catalog will be returned. |
| 259 | 259 | */ |
| 260 | 260 | function _bind_textdomain_codeset($domain, $codeset) { |
| 261 | - global $text_domains; |
|
| 262 | - $text_domains[$domain]->codeset = $codeset; |
|
| 261 | + global $text_domains; |
|
| 262 | + $text_domains[$domain]->codeset = $codeset; |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Sets the default domain. |
| 267 | 267 | */ |
| 268 | 268 | function _textdomain($domain) { |
| 269 | - global $default_domain; |
|
| 270 | - $default_domain = $domain; |
|
| 269 | + global $default_domain; |
|
| 270 | + $default_domain = $domain; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * Lookup a message in the current domain. |
| 275 | 275 | */ |
| 276 | 276 | function _gettext($msgid) { |
| 277 | - $l10n = _get_reader(); |
|
| 278 | - return _encode($l10n->translate($msgid)); |
|
| 277 | + $l10n = _get_reader(); |
|
| 278 | + return _encode($l10n->translate($msgid)); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | 282 | * Alias for gettext. |
| 283 | 283 | */ |
| 284 | 284 | function __($msgid) { |
| 285 | - return _gettext($msgid); |
|
| 285 | + return _gettext($msgid); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
| 289 | 289 | * Plural version of gettext. |
| 290 | 290 | */ |
| 291 | 291 | function _ngettext($singular, $plural, $number) { |
| 292 | - $l10n = _get_reader(); |
|
| 293 | - return _encode($l10n->ngettext($singular, $plural, $number)); |
|
| 292 | + $l10n = _get_reader(); |
|
| 293 | + return _encode($l10n->ngettext($singular, $plural, $number)); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
| 297 | 297 | * Override the current domain. |
| 298 | 298 | */ |
| 299 | 299 | function _dgettext($domain, $msgid) { |
| 300 | - $l10n = _get_reader($domain); |
|
| 301 | - return _encode($l10n->translate($msgid)); |
|
| 300 | + $l10n = _get_reader($domain); |
|
| 301 | + return _encode($l10n->translate($msgid)); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * Plural version of dgettext. |
| 306 | 306 | */ |
| 307 | 307 | function _dngettext($domain, $singular, $plural, $number) { |
| 308 | - $l10n = _get_reader($domain); |
|
| 309 | - return _encode($l10n->ngettext($singular, $plural, $number)); |
|
| 308 | + $l10n = _get_reader($domain); |
|
| 309 | + return _encode($l10n->ngettext($singular, $plural, $number)); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
| 313 | 313 | * Overrides the domain and category for a single lookup. |
| 314 | 314 | */ |
| 315 | 315 | function _dcgettext($domain, $msgid, $category) { |
| 316 | - $l10n = _get_reader($domain, $category); |
|
| 317 | - return _encode($l10n->translate($msgid)); |
|
| 316 | + $l10n = _get_reader($domain, $category); |
|
| 317 | + return _encode($l10n->translate($msgid)); |
|
| 318 | 318 | } |
| 319 | 319 | /** |
| 320 | 320 | * Plural version of dcgettext. |
| 321 | 321 | */ |
| 322 | 322 | function _dcngettext($domain, $singular, $plural, $number, $category) { |
| 323 | - $l10n = _get_reader($domain, $category); |
|
| 324 | - return _encode($l10n->ngettext($singular, $plural, $number)); |
|
| 323 | + $l10n = _get_reader($domain, $category); |
|
| 324 | + return _encode($l10n->ngettext($singular, $plural, $number)); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Context version of gettext. |
| 329 | 329 | */ |
| 330 | 330 | function _pgettext($context, $msgid) { |
| 331 | - $l10n = _get_reader(); |
|
| 332 | - return _encode($l10n->pgettext($context, $msgid)); |
|
| 331 | + $l10n = _get_reader(); |
|
| 332 | + return _encode($l10n->pgettext($context, $msgid)); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | 336 | * Override the current domain in a context gettext call. |
| 337 | 337 | */ |
| 338 | 338 | function _dpgettext($domain, $context, $msgid) { |
| 339 | - $l10n = _get_reader($domain); |
|
| 340 | - return _encode($l10n->pgettext($context, $msgid)); |
|
| 339 | + $l10n = _get_reader($domain); |
|
| 340 | + return _encode($l10n->pgettext($context, $msgid)); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
| 344 | 344 | * Overrides the domain and category for a single context-based lookup. |
| 345 | 345 | */ |
| 346 | 346 | function _dcpgettext($domain, $context, $msgid, $category) { |
| 347 | - $l10n = _get_reader($domain, $category); |
|
| 348 | - return _encode($l10n->pgettext($context, $msgid)); |
|
| 347 | + $l10n = _get_reader($domain, $category); |
|
| 348 | + return _encode($l10n->pgettext($context, $msgid)); |
|
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /** |
| 352 | 352 | * Context version of ngettext. |
| 353 | 353 | */ |
| 354 | 354 | function _npgettext($context, $singular, $plural) { |
| 355 | - $l10n = _get_reader(); |
|
| 356 | - return _encode($l10n->npgettext($context, $singular, $plural)); |
|
| 355 | + $l10n = _get_reader(); |
|
| 356 | + return _encode($l10n->npgettext($context, $singular, $plural)); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * Override the current domain in a context ngettext call. |
| 361 | 361 | */ |
| 362 | 362 | function _dnpgettext($domain, $context, $singular, $plural) { |
| 363 | - $l10n = _get_reader($domain); |
|
| 364 | - return _encode($l10n->npgettext($context, $singular, $plural)); |
|
| 363 | + $l10n = _get_reader($domain); |
|
| 364 | + return _encode($l10n->npgettext($context, $singular, $plural)); |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | /** |
| 368 | 368 | * Overrides the domain and category for a plural context-based lookup. |
| 369 | 369 | */ |
| 370 | 370 | function _dcnpgettext($domain, $context, $singular, $plural, $category) { |
| 371 | - $l10n = _get_reader($domain, $category); |
|
| 372 | - return _encode($l10n->npgettext($context, $singular, $plural)); |
|
| 371 | + $l10n = _get_reader($domain, $category); |
|
| 372 | + return _encode($l10n->npgettext($context, $singular, $plural)); |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
@@ -380,99 +380,99 @@ discard block |
||
| 380 | 380 | // custom impl otherwise. |
| 381 | 381 | |
| 382 | 382 | function T_setlocale($category, $locale) { |
| 383 | - return _setlocale($category, $locale); |
|
| 383 | + return _setlocale($category, $locale); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | function T_bindtextdomain($domain, $path) { |
| 387 | - if (_check_locale_and_function()) return bindtextdomain($domain, $path); |
|
| 388 | - else return _bindtextdomain($domain, $path); |
|
| 387 | + if (_check_locale_and_function()) return bindtextdomain($domain, $path); |
|
| 388 | + else return _bindtextdomain($domain, $path); |
|
| 389 | 389 | } |
| 390 | 390 | function T_bind_textdomain_codeset($domain, $codeset) { |
| 391 | - // bind_textdomain_codeset is available only in PHP 4.2.0+ |
|
| 392 | - if (_check_locale_and_function('bind_textdomain_codeset')) |
|
| 393 | - return bind_textdomain_codeset($domain, $codeset); |
|
| 394 | - else return _bind_textdomain_codeset($domain, $codeset); |
|
| 391 | + // bind_textdomain_codeset is available only in PHP 4.2.0+ |
|
| 392 | + if (_check_locale_and_function('bind_textdomain_codeset')) |
|
| 393 | + return bind_textdomain_codeset($domain, $codeset); |
|
| 394 | + else return _bind_textdomain_codeset($domain, $codeset); |
|
| 395 | 395 | } |
| 396 | 396 | function T_textdomain($domain) { |
| 397 | - if (_check_locale_and_function()) return textdomain($domain); |
|
| 398 | - else return _textdomain($domain); |
|
| 397 | + if (_check_locale_and_function()) return textdomain($domain); |
|
| 398 | + else return _textdomain($domain); |
|
| 399 | 399 | } |
| 400 | 400 | function T_gettext($msgid) { |
| 401 | - if (_check_locale_and_function()) return gettext($msgid); |
|
| 402 | - else return _gettext($msgid); |
|
| 401 | + if (_check_locale_and_function()) return gettext($msgid); |
|
| 402 | + else return _gettext($msgid); |
|
| 403 | 403 | } |
| 404 | 404 | function T_($msgid) { |
| 405 | - if (_check_locale_and_function()) return _($msgid); |
|
| 406 | - return __($msgid); |
|
| 405 | + if (_check_locale_and_function()) return _($msgid); |
|
| 406 | + return __($msgid); |
|
| 407 | 407 | } |
| 408 | 408 | function T_ngettext($singular, $plural, $number) { |
| 409 | - if (_check_locale_and_function()) |
|
| 410 | - return ngettext($singular, $plural, $number); |
|
| 411 | - else return _ngettext($singular, $plural, $number); |
|
| 409 | + if (_check_locale_and_function()) |
|
| 410 | + return ngettext($singular, $plural, $number); |
|
| 411 | + else return _ngettext($singular, $plural, $number); |
|
| 412 | 412 | } |
| 413 | 413 | function T_dgettext($domain, $msgid) { |
| 414 | - if (_check_locale_and_function()) return dgettext($domain, $msgid); |
|
| 415 | - else return _dgettext($domain, $msgid); |
|
| 414 | + if (_check_locale_and_function()) return dgettext($domain, $msgid); |
|
| 415 | + else return _dgettext($domain, $msgid); |
|
| 416 | 416 | } |
| 417 | 417 | function T_dngettext($domain, $singular, $plural, $number) { |
| 418 | - if (_check_locale_and_function()) |
|
| 419 | - return dngettext($domain, $singular, $plural, $number); |
|
| 420 | - else return _dngettext($domain, $singular, $plural, $number); |
|
| 418 | + if (_check_locale_and_function()) |
|
| 419 | + return dngettext($domain, $singular, $plural, $number); |
|
| 420 | + else return _dngettext($domain, $singular, $plural, $number); |
|
| 421 | 421 | } |
| 422 | 422 | function T_dcgettext($domain, $msgid, $category) { |
| 423 | - if (_check_locale_and_function()) |
|
| 424 | - return dcgettext($domain, $msgid, $category); |
|
| 425 | - else return _dcgettext($domain, $msgid, $category); |
|
| 423 | + if (_check_locale_and_function()) |
|
| 424 | + return dcgettext($domain, $msgid, $category); |
|
| 425 | + else return _dcgettext($domain, $msgid, $category); |
|
| 426 | 426 | } |
| 427 | 427 | function T_dcngettext($domain, $singular, $plural, $number, $category) { |
| 428 | - if (_check_locale_and_function()) |
|
| 429 | - return dcngettext($domain, $singular, $plural, $number, $category); |
|
| 430 | - else return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 428 | + if (_check_locale_and_function()) |
|
| 429 | + return dcngettext($domain, $singular, $plural, $number, $category); |
|
| 430 | + else return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | function T_pgettext($context, $msgid) { |
| 434 | 434 | if (_check_locale_and_function('pgettext')) |
| 435 | - return pgettext($context, $msgid); |
|
| 435 | + return pgettext($context, $msgid); |
|
| 436 | 436 | else |
| 437 | - return _pgettext($context, $msgid); |
|
| 437 | + return _pgettext($context, $msgid); |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | function T_dpgettext($domain, $context, $msgid) { |
| 441 | 441 | if (_check_locale_and_function('dpgettext')) |
| 442 | - return dpgettext($domain, $context, $msgid); |
|
| 442 | + return dpgettext($domain, $context, $msgid); |
|
| 443 | 443 | else |
| 444 | - return _dpgettext($domain, $context, $msgid); |
|
| 444 | + return _dpgettext($domain, $context, $msgid); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | function T_dcpgettext($domain, $context, $msgid, $category) { |
| 448 | 448 | if (_check_locale_and_function('dcpgettext')) |
| 449 | - return dcpgettext($domain, $context, $msgid, $category); |
|
| 449 | + return dcpgettext($domain, $context, $msgid, $category); |
|
| 450 | 450 | else |
| 451 | - return _dcpgettext($domain, $context, $msgid, $category); |
|
| 451 | + return _dcpgettext($domain, $context, $msgid, $category); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | function T_npgettext($context, $singular, $plural, $number) { |
| 455 | - if (_check_locale_and_function('npgettext')) |
|
| 456 | - return npgettext($context, $singular, $plural, $number); |
|
| 457 | - else |
|
| 458 | - return _npgettext($context, $singular, $plural, $number); |
|
| 455 | + if (_check_locale_and_function('npgettext')) |
|
| 456 | + return npgettext($context, $singular, $plural, $number); |
|
| 457 | + else |
|
| 458 | + return _npgettext($context, $singular, $plural, $number); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | function T_dnpgettext($domain, $context, $singular, $plural, $number) { |
| 462 | 462 | if (_check_locale_and_function('dnpgettext')) |
| 463 | - return dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 463 | + return dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 464 | 464 | else |
| 465 | - return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 465 | + return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | function T_dcnpgettext($domain, $context, $singular, $plural, |
| 469 | - $number, $category) { |
|
| 470 | - if (_check_locale_and_function('dcnpgettext')) |
|
| 471 | - return dcnpgettext($domain, $context, $singular, |
|
| 472 | - $plural, $number, $category); |
|
| 473 | - else |
|
| 474 | - return _dcnpgettext($domain, $context, $singular, |
|
| 475 | - $plural, $number, $category); |
|
| 469 | + $number, $category) { |
|
| 470 | + if (_check_locale_and_function('dcnpgettext')) |
|
| 471 | + return dcnpgettext($domain, $context, $singular, |
|
| 472 | + $plural, $number, $category); |
|
| 473 | + else |
|
| 474 | + return _dcnpgettext($domain, $context, $singular, |
|
| 475 | + $plural, $number, $category); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -480,56 +480,56 @@ discard block |
||
| 480 | 480 | // Wrappers used as a drop in replacement for the standard gettext functions |
| 481 | 481 | |
| 482 | 482 | if (!function_exists('gettext')) { |
| 483 | - function bindtextdomain($domain, $path) { |
|
| 484 | - return _bindtextdomain($domain, $path); |
|
| 485 | - } |
|
| 486 | - function bind_textdomain_codeset($domain, $codeset) { |
|
| 487 | - return _bind_textdomain_codeset($domain, $codeset); |
|
| 488 | - } |
|
| 489 | - function textdomain($domain) { |
|
| 490 | - return _textdomain($domain); |
|
| 491 | - } |
|
| 492 | - function gettext($msgid) { |
|
| 493 | - return _gettext($msgid); |
|
| 494 | - } |
|
| 495 | - function _($msgid) { |
|
| 496 | - return __($msgid); |
|
| 497 | - } |
|
| 498 | - function ngettext($singular, $plural, $number) { |
|
| 499 | - return _ngettext($singular, $plural, $number); |
|
| 500 | - } |
|
| 501 | - function dgettext($domain, $msgid) { |
|
| 502 | - return _dgettext($domain, $msgid); |
|
| 503 | - } |
|
| 504 | - function dngettext($domain, $singular, $plural, $number) { |
|
| 505 | - return _dngettext($domain, $singular, $plural, $number); |
|
| 506 | - } |
|
| 507 | - function dcgettext($domain, $msgid, $category) { |
|
| 508 | - return _dcgettext($domain, $msgid, $category); |
|
| 509 | - } |
|
| 510 | - function dcngettext($domain, $singular, $plural, $number, $category) { |
|
| 511 | - return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 512 | - } |
|
| 513 | - function pgettext($context, $msgid) { |
|
| 514 | - return _pgettext($context, $msgid); |
|
| 515 | - } |
|
| 516 | - function npgettext($context, $singular, $plural, $number) { |
|
| 517 | - return _npgettext($context, $singular, $plural, $number); |
|
| 518 | - } |
|
| 519 | - function dpgettext($domain, $context, $msgid) { |
|
| 520 | - return _dpgettext($domain, $context, $msgid); |
|
| 521 | - } |
|
| 522 | - function dnpgettext($domain, $context, $singular, $plural, $number) { |
|
| 523 | - return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 524 | - } |
|
| 525 | - function dcpgettext($domain, $context, $msgid, $category) { |
|
| 526 | - return _dcpgettext($domain, $context, $msgid, $category); |
|
| 527 | - } |
|
| 528 | - function dcnpgettext($domain, $context, $singular, $plural, |
|
| 529 | - $number, $category) { |
|
| 530 | - return _dcnpgettext($domain, $context, $singular, $plural, |
|
| 531 | - $number, $category); |
|
| 532 | - } |
|
| 483 | + function bindtextdomain($domain, $path) { |
|
| 484 | + return _bindtextdomain($domain, $path); |
|
| 485 | + } |
|
| 486 | + function bind_textdomain_codeset($domain, $codeset) { |
|
| 487 | + return _bind_textdomain_codeset($domain, $codeset); |
|
| 488 | + } |
|
| 489 | + function textdomain($domain) { |
|
| 490 | + return _textdomain($domain); |
|
| 491 | + } |
|
| 492 | + function gettext($msgid) { |
|
| 493 | + return _gettext($msgid); |
|
| 494 | + } |
|
| 495 | + function _($msgid) { |
|
| 496 | + return __($msgid); |
|
| 497 | + } |
|
| 498 | + function ngettext($singular, $plural, $number) { |
|
| 499 | + return _ngettext($singular, $plural, $number); |
|
| 500 | + } |
|
| 501 | + function dgettext($domain, $msgid) { |
|
| 502 | + return _dgettext($domain, $msgid); |
|
| 503 | + } |
|
| 504 | + function dngettext($domain, $singular, $plural, $number) { |
|
| 505 | + return _dngettext($domain, $singular, $plural, $number); |
|
| 506 | + } |
|
| 507 | + function dcgettext($domain, $msgid, $category) { |
|
| 508 | + return _dcgettext($domain, $msgid, $category); |
|
| 509 | + } |
|
| 510 | + function dcngettext($domain, $singular, $plural, $number, $category) { |
|
| 511 | + return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 512 | + } |
|
| 513 | + function pgettext($context, $msgid) { |
|
| 514 | + return _pgettext($context, $msgid); |
|
| 515 | + } |
|
| 516 | + function npgettext($context, $singular, $plural, $number) { |
|
| 517 | + return _npgettext($context, $singular, $plural, $number); |
|
| 518 | + } |
|
| 519 | + function dpgettext($domain, $context, $msgid) { |
|
| 520 | + return _dpgettext($domain, $context, $msgid); |
|
| 521 | + } |
|
| 522 | + function dnpgettext($domain, $context, $singular, $plural, $number) { |
|
| 523 | + return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 524 | + } |
|
| 525 | + function dcpgettext($domain, $context, $msgid, $category) { |
|
| 526 | + return _dcpgettext($domain, $context, $msgid, $category); |
|
| 527 | + } |
|
| 528 | + function dcnpgettext($domain, $context, $singular, $plural, |
|
| 529 | + $number, $category) { |
|
| 530 | + return _dcnpgettext($domain, $context, $singular, $plural, |
|
| 531 | + $number, $category); |
|
| 532 | + } |
|
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | ?> |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | // LC_MESSAGES is not available if php-gettext is not loaded |
| 36 | 36 | // while the other constants are already available from session extension. |
| 37 | 37 | if (!defined('LC_MESSAGES')) { |
| 38 | - define('LC_MESSAGES', 5); |
|
| 38 | + define('LC_MESSAGES', 5); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | require('streams.php'); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | if (preg_match("/^(?P<lang>[a-z]{2,3})" // language code |
| 78 | 78 | ."(?:_(?P<country>[A-Z]{2}))?" // country code |
| 79 | 79 | ."(?:\.(?P<charset>[-A-Za-z0-9_]+))?" // charset |
| 80 | - ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
|
| 80 | + ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
|
| 81 | 81 | $locale, $matches)) { |
| 82 | 82 | |
| 83 | 83 | if (isset($matches["lang"])) $lang = $matches["lang"]; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | /** |
| 114 | 114 | * Utility function to get a StreamReader for the given text domain. |
| 115 | 115 | */ |
| 116 | -function _get_reader($domain=null, $category=5, $enable_cache=true) { |
|
| 116 | +function _get_reader($domain = null, $category = 5, $enable_cache = true) { |
|
| 117 | 117 | global $text_domains, $default_domain, $LC_CATEGORIES; |
| 118 | 118 | if (!isset($domain)) $domain = $default_domain; |
| 119 | 119 | if (!isset($text_domains[$domain]->l10n)) { |
@@ -121,12 +121,12 @@ discard block |
||
| 121 | 121 | $locale = _setlocale(LC_MESSAGES, 0); |
| 122 | 122 | $bound_path = isset($text_domains[$domain]->path) ? |
| 123 | 123 | $text_domains[$domain]->path : './'; |
| 124 | - $subpath = $LC_CATEGORIES[$category] ."/$domain.mo"; |
|
| 124 | + $subpath = $LC_CATEGORIES[$category]."/$domain.mo"; |
|
| 125 | 125 | |
| 126 | 126 | $locale_names = get_list_of_locales($locale); |
| 127 | 127 | $input = null; |
| 128 | 128 | foreach ($locale_names as $locale) { |
| 129 | - $full_path = $bound_path . $locale . "/" . $subpath; |
|
| 129 | + $full_path = $bound_path.$locale."/".$subpath; |
|
| 130 | 130 | if (file_exists($full_path)) { |
| 131 | 131 | $input = new FileReader($full_path); |
| 132 | 132 | break; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | /** |
| 155 | 155 | * Checks if the current locale is supported on this system. |
| 156 | 156 | */ |
| 157 | -function _check_locale_and_function($function=false) { |
|
| 157 | +function _check_locale_and_function($function = false) { |
|
| 158 | 158 | global $EMULATEGETTEXT; |
| 159 | 159 | if ($function and !function_exists($function)) |
| 160 | 160 | return false; |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | /** |
| 165 | 165 | * Get the codeset for the given domain. |
| 166 | 166 | */ |
| 167 | -function _get_codeset($domain=null) { |
|
| 167 | +function _get_codeset($domain = null) { |
|
| 168 | 168 | global $text_domains, $default_domain, $LC_CATEGORIES; |
| 169 | 169 | if (!isset($domain)) $domain = $default_domain; |
| 170 | - return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
|
| 170 | + return (isset($text_domains[$domain]->codeset)) ? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | global $text_domains; |
| 242 | 242 | // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
| 243 | 243 | if (substr(php_uname(), 0, 7) == "Windows") { |
| 244 | - if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
| 244 | + if ($path[strlen($path) - 1] != '\\' and $path[strlen($path) - 1] != '/') |
|
| 245 | 245 | $path .= '\\'; |
| 246 | 246 | } else { |
| 247 | - if ($path[strlen($path)-1] != '/') |
|
| 247 | + if ($path[strlen($path) - 1] != '/') |
|
| 248 | 248 | $path .= '/'; |
| 249 | 249 | } |
| 250 | 250 | if (!array_key_exists($domain, $text_domains)) { |
@@ -80,32 +80,45 @@ discard block |
||
| 80 | 80 | ."(?:@(?P<modifier>[-A-Za-z0-9_]+))?$/", // @ modifier |
| 81 | 81 | $locale, $matches)) { |
| 82 | 82 | |
| 83 | - if (isset($matches["lang"])) $lang = $matches["lang"]; |
|
| 84 | - if (isset($matches["country"])) $country = $matches["country"]; |
|
| 85 | - if (isset($matches["charset"])) $charset = $matches["charset"]; |
|
| 86 | - if (isset($matches["modifier"])) $modifier = $matches["modifier"]; |
|
| 83 | + if (isset($matches["lang"])) { |
|
| 84 | + $lang = $matches["lang"]; |
|
| 85 | + } |
|
| 86 | + if (isset($matches["country"])) { |
|
| 87 | + $country = $matches["country"]; |
|
| 88 | + } |
|
| 89 | + if (isset($matches["charset"])) { |
|
| 90 | + $charset = $matches["charset"]; |
|
| 91 | + } |
|
| 92 | + if (isset($matches["modifier"])) { |
|
| 93 | + $modifier = $matches["modifier"]; |
|
| 94 | + } |
|
| 87 | 95 | |
| 88 | 96 | if ($modifier) { |
| 89 | 97 | if ($country) { |
| 90 | - if ($charset) |
|
| 91 | - array_push($locale_names, "${lang}_$country.$charset@$modifier"); |
|
| 98 | + if ($charset) { |
|
| 99 | + array_push($locale_names, "${lang}_$country.$charset@$modifier"); |
|
| 100 | + } |
|
| 92 | 101 | array_push($locale_names, "${lang}_$country@$modifier"); |
| 93 | - } elseif ($charset) |
|
| 94 | - array_push($locale_names, "${lang}.$charset@$modifier"); |
|
| 102 | + } elseif ($charset) { |
|
| 103 | + array_push($locale_names, "${lang}.$charset@$modifier"); |
|
| 104 | + } |
|
| 95 | 105 | array_push($locale_names, "$lang@$modifier"); |
| 96 | 106 | } |
| 97 | 107 | if ($country) { |
| 98 | - if ($charset) |
|
| 99 | - array_push($locale_names, "${lang}_$country.$charset"); |
|
| 108 | + if ($charset) { |
|
| 109 | + array_push($locale_names, "${lang}_$country.$charset"); |
|
| 110 | + } |
|
| 100 | 111 | array_push($locale_names, "${lang}_$country"); |
| 101 | - } elseif ($charset) |
|
| 102 | - array_push($locale_names, "${lang}.$charset"); |
|
| 112 | + } elseif ($charset) { |
|
| 113 | + array_push($locale_names, "${lang}.$charset"); |
|
| 114 | + } |
|
| 103 | 115 | array_push($locale_names, $lang); |
| 104 | 116 | } |
| 105 | 117 | |
| 106 | 118 | // If the locale name doesn't match POSIX style, just include it as-is. |
| 107 | - if (!in_array($locale, $locale_names)) |
|
| 108 | - array_push($locale_names, $locale); |
|
| 119 | + if (!in_array($locale, $locale_names)) { |
|
| 120 | + array_push($locale_names, $locale); |
|
| 121 | + } |
|
| 109 | 122 | } |
| 110 | 123 | return $locale_names; |
| 111 | 124 | } |
@@ -115,7 +128,9 @@ discard block |
||
| 115 | 128 | */ |
| 116 | 129 | function _get_reader($domain=null, $category=5, $enable_cache=true) { |
| 117 | 130 | global $text_domains, $default_domain, $LC_CATEGORIES; |
| 118 | - if (!isset($domain)) $domain = $default_domain; |
|
| 131 | + if (!isset($domain)) { |
|
| 132 | + $domain = $default_domain; |
|
| 133 | + } |
|
| 119 | 134 | if (!isset($text_domains[$domain]->l10n)) { |
| 120 | 135 | // get the current locale |
| 121 | 136 | $locale = _setlocale(LC_MESSAGES, 0); |
@@ -156,8 +171,9 @@ discard block |
||
| 156 | 171 | */ |
| 157 | 172 | function _check_locale_and_function($function=false) { |
| 158 | 173 | global $EMULATEGETTEXT; |
| 159 | - if ($function and !function_exists($function)) |
|
| 160 | - return false; |
|
| 174 | + if ($function and !function_exists($function)) { |
|
| 175 | + return false; |
|
| 176 | + } |
|
| 161 | 177 | return !$EMULATEGETTEXT; |
| 162 | 178 | } |
| 163 | 179 | |
@@ -166,7 +182,9 @@ discard block |
||
| 166 | 182 | */ |
| 167 | 183 | function _get_codeset($domain=null) { |
| 168 | 184 | global $text_domains, $default_domain, $LC_CATEGORIES; |
| 169 | - if (!isset($domain)) $domain = $default_domain; |
|
| 185 | + if (!isset($domain)) { |
|
| 186 | + $domain = $default_domain; |
|
| 187 | + } |
|
| 170 | 188 | return (isset($text_domains[$domain]->codeset))? $text_domains[$domain]->codeset : ini_get('mbstring.internal_encoding'); |
| 171 | 189 | } |
| 172 | 190 | |
@@ -177,8 +195,9 @@ discard block |
||
| 177 | 195 | $target_encoding = _get_codeset(); |
| 178 | 196 | if (function_exists("mb_detect_encoding")) { |
| 179 | 197 | $source_encoding = mb_detect_encoding($text); |
| 180 | - if ($source_encoding != $target_encoding) |
|
| 181 | - $text = mb_convert_encoding($text, $target_encoding, $source_encoding); |
|
| 198 | + if ($source_encoding != $target_encoding) { |
|
| 199 | + $text = mb_convert_encoding($text, $target_encoding, $source_encoding); |
|
| 200 | + } |
|
| 182 | 201 | } |
| 183 | 202 | return $text; |
| 184 | 203 | } |
@@ -190,11 +209,13 @@ discard block |
||
| 190 | 209 | * Returns passed in $locale, or environment variable $LANG if $locale == ''. |
| 191 | 210 | */ |
| 192 | 211 | function _get_default_locale($locale) { |
| 193 | - if ($locale == '') // emulate variable support |
|
| 212 | + if ($locale == '') { |
|
| 213 | + // emulate variable support |
|
| 194 | 214 | return getenv('LANG'); |
| 195 | - else |
|
| 196 | - return $locale; |
|
| 197 | -} |
|
| 215 | + } else { |
|
| 216 | + return $locale; |
|
| 217 | + } |
|
| 218 | + } |
|
| 198 | 219 | |
| 199 | 220 | /** |
| 200 | 221 | * Sets a requested locale, if needed emulates it. |
@@ -202,12 +223,13 @@ discard block |
||
| 202 | 223 | function _setlocale($category, $locale) { |
| 203 | 224 | global $CURRENTLOCALE, $EMULATEGETTEXT; |
| 204 | 225 | if ($locale === 0) { // use === to differentiate between string "0" |
| 205 | - if ($CURRENTLOCALE != '') |
|
| 206 | - return $CURRENTLOCALE; |
|
| 207 | - else |
|
| 208 | - // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 226 | + if ($CURRENTLOCALE != '') { |
|
| 227 | + return $CURRENTLOCALE; |
|
| 228 | + } else { |
|
| 229 | + // obey LANG variable, maybe extend to support all of LC_* vars |
|
| 209 | 230 | // even if we tried to read locale without setting it first |
| 210 | 231 | return _setlocale($category, $CURRENTLOCALE); |
| 232 | + } |
|
| 211 | 233 | } else { |
| 212 | 234 | if (function_exists('setlocale')) { |
| 213 | 235 | $ret = setlocale($category, $locale); |
@@ -241,11 +263,13 @@ discard block |
||
| 241 | 263 | global $text_domains; |
| 242 | 264 | // ensure $path ends with a slash ('/' should work for both, but lets still play nice) |
| 243 | 265 | if (substr(php_uname(), 0, 7) == "Windows") { |
| 244 | - if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') |
|
| 245 | - $path .= '\\'; |
|
| 266 | + if ($path[strlen($path)-1] != '\\' and $path[strlen($path)-1] != '/') { |
|
| 267 | + $path .= '\\'; |
|
| 268 | + } |
|
| 246 | 269 | } else { |
| 247 | - if ($path[strlen($path)-1] != '/') |
|
| 248 | - $path .= '/'; |
|
| 270 | + if ($path[strlen($path)-1] != '/') { |
|
| 271 | + $path .= '/'; |
|
| 272 | + } |
|
| 249 | 273 | } |
| 250 | 274 | if (!array_key_exists($domain, $text_domains)) { |
| 251 | 275 | // Initialize an empty domain object. |
@@ -384,96 +408,126 @@ discard block |
||
| 384 | 408 | } |
| 385 | 409 | |
| 386 | 410 | function T_bindtextdomain($domain, $path) { |
| 387 | - if (_check_locale_and_function()) return bindtextdomain($domain, $path); |
|
| 388 | - else return _bindtextdomain($domain, $path); |
|
| 389 | -} |
|
| 411 | + if (_check_locale_and_function()) { |
|
| 412 | + return bindtextdomain($domain, $path); |
|
| 413 | + } else { |
|
| 414 | + return _bindtextdomain($domain, $path); |
|
| 415 | + } |
|
| 416 | + } |
|
| 390 | 417 | function T_bind_textdomain_codeset($domain, $codeset) { |
| 391 | 418 | // bind_textdomain_codeset is available only in PHP 4.2.0+ |
| 392 | - if (_check_locale_and_function('bind_textdomain_codeset')) |
|
| 393 | - return bind_textdomain_codeset($domain, $codeset); |
|
| 394 | - else return _bind_textdomain_codeset($domain, $codeset); |
|
| 395 | -} |
|
| 419 | + if (_check_locale_and_function('bind_textdomain_codeset')) { |
|
| 420 | + return bind_textdomain_codeset($domain, $codeset); |
|
| 421 | + } else { |
|
| 422 | + return _bind_textdomain_codeset($domain, $codeset); |
|
| 423 | + } |
|
| 424 | + } |
|
| 396 | 425 | function T_textdomain($domain) { |
| 397 | - if (_check_locale_and_function()) return textdomain($domain); |
|
| 398 | - else return _textdomain($domain); |
|
| 399 | -} |
|
| 426 | + if (_check_locale_and_function()) { |
|
| 427 | + return textdomain($domain); |
|
| 428 | + } else { |
|
| 429 | + return _textdomain($domain); |
|
| 430 | + } |
|
| 431 | + } |
|
| 400 | 432 | function T_gettext($msgid) { |
| 401 | - if (_check_locale_and_function()) return gettext($msgid); |
|
| 402 | - else return _gettext($msgid); |
|
| 403 | -} |
|
| 433 | + if (_check_locale_and_function()) { |
|
| 434 | + return gettext($msgid); |
|
| 435 | + } else { |
|
| 436 | + return _gettext($msgid); |
|
| 437 | + } |
|
| 438 | + } |
|
| 404 | 439 | function T_($msgid) { |
| 405 | - if (_check_locale_and_function()) return _($msgid); |
|
| 440 | + if (_check_locale_and_function()) { |
|
| 441 | + return _($msgid); |
|
| 442 | + } |
|
| 406 | 443 | return __($msgid); |
| 407 | 444 | } |
| 408 | 445 | function T_ngettext($singular, $plural, $number) { |
| 409 | - if (_check_locale_and_function()) |
|
| 410 | - return ngettext($singular, $plural, $number); |
|
| 411 | - else return _ngettext($singular, $plural, $number); |
|
| 412 | -} |
|
| 446 | + if (_check_locale_and_function()) { |
|
| 447 | + return ngettext($singular, $plural, $number); |
|
| 448 | + } else { |
|
| 449 | + return _ngettext($singular, $plural, $number); |
|
| 450 | + } |
|
| 451 | + } |
|
| 413 | 452 | function T_dgettext($domain, $msgid) { |
| 414 | - if (_check_locale_and_function()) return dgettext($domain, $msgid); |
|
| 415 | - else return _dgettext($domain, $msgid); |
|
| 416 | -} |
|
| 453 | + if (_check_locale_and_function()) { |
|
| 454 | + return dgettext($domain, $msgid); |
|
| 455 | + } else { |
|
| 456 | + return _dgettext($domain, $msgid); |
|
| 457 | + } |
|
| 458 | + } |
|
| 417 | 459 | function T_dngettext($domain, $singular, $plural, $number) { |
| 418 | - if (_check_locale_and_function()) |
|
| 419 | - return dngettext($domain, $singular, $plural, $number); |
|
| 420 | - else return _dngettext($domain, $singular, $plural, $number); |
|
| 421 | -} |
|
| 460 | + if (_check_locale_and_function()) { |
|
| 461 | + return dngettext($domain, $singular, $plural, $number); |
|
| 462 | + } else { |
|
| 463 | + return _dngettext($domain, $singular, $plural, $number); |
|
| 464 | + } |
|
| 465 | + } |
|
| 422 | 466 | function T_dcgettext($domain, $msgid, $category) { |
| 423 | - if (_check_locale_and_function()) |
|
| 424 | - return dcgettext($domain, $msgid, $category); |
|
| 425 | - else return _dcgettext($domain, $msgid, $category); |
|
| 426 | -} |
|
| 467 | + if (_check_locale_and_function()) { |
|
| 468 | + return dcgettext($domain, $msgid, $category); |
|
| 469 | + } else { |
|
| 470 | + return _dcgettext($domain, $msgid, $category); |
|
| 471 | + } |
|
| 472 | + } |
|
| 427 | 473 | function T_dcngettext($domain, $singular, $plural, $number, $category) { |
| 428 | - if (_check_locale_and_function()) |
|
| 429 | - return dcngettext($domain, $singular, $plural, $number, $category); |
|
| 430 | - else return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 431 | -} |
|
| 474 | + if (_check_locale_and_function()) { |
|
| 475 | + return dcngettext($domain, $singular, $plural, $number, $category); |
|
| 476 | + } else { |
|
| 477 | + return _dcngettext($domain, $singular, $plural, $number, $category); |
|
| 478 | + } |
|
| 479 | + } |
|
| 432 | 480 | |
| 433 | 481 | function T_pgettext($context, $msgid) { |
| 434 | - if (_check_locale_and_function('pgettext')) |
|
| 435 | - return pgettext($context, $msgid); |
|
| 436 | - else |
|
| 437 | - return _pgettext($context, $msgid); |
|
| 438 | -} |
|
| 482 | + if (_check_locale_and_function('pgettext')) { |
|
| 483 | + return pgettext($context, $msgid); |
|
| 484 | + } else { |
|
| 485 | + return _pgettext($context, $msgid); |
|
| 486 | + } |
|
| 487 | + } |
|
| 439 | 488 | |
| 440 | 489 | function T_dpgettext($domain, $context, $msgid) { |
| 441 | - if (_check_locale_and_function('dpgettext')) |
|
| 442 | - return dpgettext($domain, $context, $msgid); |
|
| 443 | - else |
|
| 444 | - return _dpgettext($domain, $context, $msgid); |
|
| 445 | -} |
|
| 490 | + if (_check_locale_and_function('dpgettext')) { |
|
| 491 | + return dpgettext($domain, $context, $msgid); |
|
| 492 | + } else { |
|
| 493 | + return _dpgettext($domain, $context, $msgid); |
|
| 494 | + } |
|
| 495 | + } |
|
| 446 | 496 | |
| 447 | 497 | function T_dcpgettext($domain, $context, $msgid, $category) { |
| 448 | - if (_check_locale_and_function('dcpgettext')) |
|
| 449 | - return dcpgettext($domain, $context, $msgid, $category); |
|
| 450 | - else |
|
| 451 | - return _dcpgettext($domain, $context, $msgid, $category); |
|
| 452 | -} |
|
| 498 | + if (_check_locale_and_function('dcpgettext')) { |
|
| 499 | + return dcpgettext($domain, $context, $msgid, $category); |
|
| 500 | + } else { |
|
| 501 | + return _dcpgettext($domain, $context, $msgid, $category); |
|
| 502 | + } |
|
| 503 | + } |
|
| 453 | 504 | |
| 454 | 505 | function T_npgettext($context, $singular, $plural, $number) { |
| 455 | - if (_check_locale_and_function('npgettext')) |
|
| 456 | - return npgettext($context, $singular, $plural, $number); |
|
| 457 | - else |
|
| 458 | - return _npgettext($context, $singular, $plural, $number); |
|
| 459 | -} |
|
| 506 | + if (_check_locale_and_function('npgettext')) { |
|
| 507 | + return npgettext($context, $singular, $plural, $number); |
|
| 508 | + } else { |
|
| 509 | + return _npgettext($context, $singular, $plural, $number); |
|
| 510 | + } |
|
| 511 | + } |
|
| 460 | 512 | |
| 461 | 513 | function T_dnpgettext($domain, $context, $singular, $plural, $number) { |
| 462 | - if (_check_locale_and_function('dnpgettext')) |
|
| 463 | - return dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 464 | - else |
|
| 465 | - return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 466 | -} |
|
| 514 | + if (_check_locale_and_function('dnpgettext')) { |
|
| 515 | + return dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 516 | + } else { |
|
| 517 | + return _dnpgettext($domain, $context, $singular, $plural, $number); |
|
| 518 | + } |
|
| 519 | + } |
|
| 467 | 520 | |
| 468 | 521 | function T_dcnpgettext($domain, $context, $singular, $plural, |
| 469 | 522 | $number, $category) { |
| 470 | - if (_check_locale_and_function('dcnpgettext')) |
|
| 471 | - return dcnpgettext($domain, $context, $singular, |
|
| 523 | + if (_check_locale_and_function('dcnpgettext')) { |
|
| 524 | + return dcnpgettext($domain, $context, $singular, |
|
| 472 | 525 | $plural, $number, $category); |
| 473 | - else |
|
| 474 | - return _dcnpgettext($domain, $context, $singular, |
|
| 526 | + } else { |
|
| 527 | + return _dcnpgettext($domain, $context, $singular, |
|
| 475 | 528 | $plural, $number, $category); |
| 476 | -} |
|
| 529 | + } |
|
| 530 | + } |
|
| 477 | 531 | |
| 478 | 532 | |
| 479 | 533 | |
@@ -26,22 +26,22 @@ discard block |
||
| 26 | 26 | class StreamReader { |
| 27 | 27 | // should return a string [FIXME: perhaps return array of bytes?] |
| 28 | 28 | function read($bytes) { |
| 29 | - return false; |
|
| 29 | + return false; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | // should return new position |
| 33 | 33 | function seekto($position) { |
| 34 | - return false; |
|
| 34 | + return false; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // returns current position |
| 38 | 38 | function currentpos() { |
| 39 | - return false; |
|
| 39 | + return false; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // returns length of entire stream (limit for seekto()s) |
| 43 | 43 | function length() { |
| 44 | - return false; |
|
| 44 | + return false; |
|
| 45 | 45 | } |
| 46 | 46 | }; |
| 47 | 47 | |
@@ -50,32 +50,32 @@ discard block |
||
| 50 | 50 | var $_str; |
| 51 | 51 | |
| 52 | 52 | function StringReader($str='') { |
| 53 | - $this->_str = $str; |
|
| 54 | - $this->_pos = 0; |
|
| 53 | + $this->_str = $str; |
|
| 54 | + $this->_pos = 0; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | function read($bytes) { |
| 58 | - $data = substr($this->_str, $this->_pos, $bytes); |
|
| 59 | - $this->_pos += $bytes; |
|
| 60 | - if (strlen($this->_str)<$this->_pos) |
|
| 61 | - $this->_pos = strlen($this->_str); |
|
| 58 | + $data = substr($this->_str, $this->_pos, $bytes); |
|
| 59 | + $this->_pos += $bytes; |
|
| 60 | + if (strlen($this->_str)<$this->_pos) |
|
| 61 | + $this->_pos = strlen($this->_str); |
|
| 62 | 62 | |
| 63 | - return $data; |
|
| 63 | + return $data; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | function seekto($pos) { |
| 67 | - $this->_pos = $pos; |
|
| 68 | - if (strlen($this->_str)<$this->_pos) |
|
| 69 | - $this->_pos = strlen($this->_str); |
|
| 70 | - return $this->_pos; |
|
| 67 | + $this->_pos = $pos; |
|
| 68 | + if (strlen($this->_str)<$this->_pos) |
|
| 69 | + $this->_pos = strlen($this->_str); |
|
| 70 | + return $this->_pos; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | function currentpos() { |
| 74 | - return $this->_pos; |
|
| 74 | + return $this->_pos; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | function length() { |
| 78 | - return strlen($this->_str); |
|
| 78 | + return strlen($this->_str); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | }; |
@@ -87,55 +87,55 @@ discard block |
||
| 87 | 87 | var $_length; |
| 88 | 88 | |
| 89 | 89 | function FileReader($filename) { |
| 90 | - if (file_exists($filename)) { |
|
| 90 | + if (file_exists($filename)) { |
|
| 91 | 91 | |
| 92 | - $this->_length=filesize($filename); |
|
| 93 | - $this->_pos = 0; |
|
| 94 | - $this->_fd = fopen($filename,'rb'); |
|
| 95 | - if (!$this->_fd) { |
|
| 96 | - $this->error = 3; // Cannot read file, probably permissions |
|
| 97 | - return false; |
|
| 98 | - } |
|
| 99 | - } else { |
|
| 100 | - $this->error = 2; // File doesn't exist |
|
| 101 | - return false; |
|
| 102 | - } |
|
| 92 | + $this->_length=filesize($filename); |
|
| 93 | + $this->_pos = 0; |
|
| 94 | + $this->_fd = fopen($filename,'rb'); |
|
| 95 | + if (!$this->_fd) { |
|
| 96 | + $this->error = 3; // Cannot read file, probably permissions |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 99 | + } else { |
|
| 100 | + $this->error = 2; // File doesn't exist |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | function read($bytes) { |
| 106 | - if ($bytes) { |
|
| 107 | - fseek($this->_fd, $this->_pos); |
|
| 106 | + if ($bytes) { |
|
| 107 | + fseek($this->_fd, $this->_pos); |
|
| 108 | 108 | |
| 109 | - // PHP 5.1.1 does not read more than 8192 bytes in one fread() |
|
| 110 | - // the discussions at PHP Bugs suggest it's the intended behaviour |
|
| 111 | - $data = ''; |
|
| 112 | - while ($bytes > 0) { |
|
| 113 | - $chunk = fread($this->_fd, $bytes); |
|
| 114 | - $data .= $chunk; |
|
| 115 | - $bytes -= strlen($chunk); |
|
| 116 | - } |
|
| 117 | - $this->_pos = ftell($this->_fd); |
|
| 109 | + // PHP 5.1.1 does not read more than 8192 bytes in one fread() |
|
| 110 | + // the discussions at PHP Bugs suggest it's the intended behaviour |
|
| 111 | + $data = ''; |
|
| 112 | + while ($bytes > 0) { |
|
| 113 | + $chunk = fread($this->_fd, $bytes); |
|
| 114 | + $data .= $chunk; |
|
| 115 | + $bytes -= strlen($chunk); |
|
| 116 | + } |
|
| 117 | + $this->_pos = ftell($this->_fd); |
|
| 118 | 118 | |
| 119 | - return $data; |
|
| 120 | - } else return ''; |
|
| 119 | + return $data; |
|
| 120 | + } else return ''; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | function seekto($pos) { |
| 124 | - fseek($this->_fd, $pos); |
|
| 125 | - $this->_pos = ftell($this->_fd); |
|
| 126 | - return $this->_pos; |
|
| 124 | + fseek($this->_fd, $pos); |
|
| 125 | + $this->_pos = ftell($this->_fd); |
|
| 126 | + return $this->_pos; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | function currentpos() { |
| 130 | - return $this->_pos; |
|
| 130 | + return $this->_pos; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | function length() { |
| 134 | - return $this->_length; |
|
| 134 | + return $this->_length; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | function close() { |
| 138 | - fclose($this->_fd); |
|
| 138 | + fclose($this->_fd); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | }; |
@@ -144,22 +144,22 @@ discard block |
||
| 144 | 144 | // over it (it assumes knowledge of StringReader internals) |
| 145 | 145 | class CachedFileReader extends StringReader { |
| 146 | 146 | function CachedFileReader($filename) { |
| 147 | - if (file_exists($filename)) { |
|
| 148 | - |
|
| 149 | - $length=filesize($filename); |
|
| 150 | - $fd = fopen($filename,'rb'); |
|
| 151 | - |
|
| 152 | - if (!$fd) { |
|
| 153 | - $this->error = 3; // Cannot read file, probably permissions |
|
| 154 | - return false; |
|
| 155 | - } |
|
| 156 | - $this->_str = fread($fd, $length); |
|
| 157 | - fclose($fd); |
|
| 158 | - |
|
| 159 | - } else { |
|
| 160 | - $this->error = 2; // File doesn't exist |
|
| 161 | - return false; |
|
| 162 | - } |
|
| 147 | + if (file_exists($filename)) { |
|
| 148 | + |
|
| 149 | + $length=filesize($filename); |
|
| 150 | + $fd = fopen($filename,'rb'); |
|
| 151 | + |
|
| 152 | + if (!$fd) { |
|
| 153 | + $this->error = 3; // Cannot read file, probably permissions |
|
| 154 | + return false; |
|
| 155 | + } |
|
| 156 | + $this->_str = fread($fd, $length); |
|
| 157 | + fclose($fd); |
|
| 158 | + |
|
| 159 | + } else { |
|
| 160 | + $this->error = 2; // File doesn't exist |
|
| 161 | + return false; |
|
| 162 | + } |
|
| 163 | 163 | } |
| 164 | 164 | }; |
| 165 | 165 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | var $_pos; |
| 50 | 50 | var $_str; |
| 51 | 51 | |
| 52 | - function StringReader($str='') { |
|
| 52 | + function StringReader($str = '') { |
|
| 53 | 53 | $this->_str = $str; |
| 54 | 54 | $this->_pos = 0; |
| 55 | 55 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | function read($bytes) { |
| 58 | 58 | $data = substr($this->_str, $this->_pos, $bytes); |
| 59 | 59 | $this->_pos += $bytes; |
| 60 | - if (strlen($this->_str)<$this->_pos) |
|
| 60 | + if (strlen($this->_str) < $this->_pos) |
|
| 61 | 61 | $this->_pos = strlen($this->_str); |
| 62 | 62 | |
| 63 | 63 | return $data; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | function seekto($pos) { |
| 67 | 67 | $this->_pos = $pos; |
| 68 | - if (strlen($this->_str)<$this->_pos) |
|
| 68 | + if (strlen($this->_str) < $this->_pos) |
|
| 69 | 69 | $this->_pos = strlen($this->_str); |
| 70 | 70 | return $this->_pos; |
| 71 | 71 | } |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | function FileReader($filename) { |
| 90 | 90 | if (file_exists($filename)) { |
| 91 | 91 | |
| 92 | - $this->_length=filesize($filename); |
|
| 92 | + $this->_length = filesize($filename); |
|
| 93 | 93 | $this->_pos = 0; |
| 94 | - $this->_fd = fopen($filename,'rb'); |
|
| 94 | + $this->_fd = fopen($filename, 'rb'); |
|
| 95 | 95 | if (!$this->_fd) { |
| 96 | 96 | $this->error = 3; // Cannot read file, probably permissions |
| 97 | 97 | return false; |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | function CachedFileReader($filename) { |
| 147 | 147 | if (file_exists($filename)) { |
| 148 | 148 | |
| 149 | - $length=filesize($filename); |
|
| 150 | - $fd = fopen($filename,'rb'); |
|
| 149 | + $length = filesize($filename); |
|
| 150 | + $fd = fopen($filename, 'rb'); |
|
| 151 | 151 | |
| 152 | 152 | if (!$fd) { |
| 153 | 153 | $this->error = 3; // Cannot read file, probably permissions |
@@ -57,16 +57,18 @@ discard block |
||
| 57 | 57 | function read($bytes) { |
| 58 | 58 | $data = substr($this->_str, $this->_pos, $bytes); |
| 59 | 59 | $this->_pos += $bytes; |
| 60 | - if (strlen($this->_str)<$this->_pos) |
|
| 61 | - $this->_pos = strlen($this->_str); |
|
| 60 | + if (strlen($this->_str)<$this->_pos) { |
|
| 61 | + $this->_pos = strlen($this->_str); |
|
| 62 | + } |
|
| 62 | 63 | |
| 63 | 64 | return $data; |
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 67 | function seekto($pos) { |
| 67 | 68 | $this->_pos = $pos; |
| 68 | - if (strlen($this->_str)<$this->_pos) |
|
| 69 | - $this->_pos = strlen($this->_str); |
|
| 69 | + if (strlen($this->_str)<$this->_pos) { |
|
| 70 | + $this->_pos = strlen($this->_str); |
|
| 71 | + } |
|
| 70 | 72 | return $this->_pos; |
| 71 | 73 | } |
| 72 | 74 | |
@@ -117,7 +119,9 @@ discard block |
||
| 117 | 119 | $this->_pos = ftell($this->_fd); |
| 118 | 120 | |
| 119 | 121 | return $data; |
| 120 | - } else return ''; |
|
| 122 | + } else { |
|
| 123 | + return ''; |
|
| 124 | + } |
|
| 121 | 125 | } |
| 122 | 126 | |
| 123 | 127 | function seekto($pos) { |
@@ -61,19 +61,19 @@ discard block |
||
| 61 | 61 | * @return Integer from the Stream |
| 62 | 62 | */ |
| 63 | 63 | function readint() { |
| 64 | - if ($this->BYTEORDER == 0) { |
|
| 65 | - // low endian |
|
| 66 | - $input=unpack('V', $this->STREAM->read(4)); |
|
| 67 | - return array_shift($input); |
|
| 68 | - } else { |
|
| 69 | - // big endian |
|
| 70 | - $input=unpack('N', $this->STREAM->read(4)); |
|
| 71 | - return array_shift($input); |
|
| 72 | - } |
|
| 73 | - } |
|
| 64 | + if ($this->BYTEORDER == 0) { |
|
| 65 | + // low endian |
|
| 66 | + $input=unpack('V', $this->STREAM->read(4)); |
|
| 67 | + return array_shift($input); |
|
| 68 | + } else { |
|
| 69 | + // big endian |
|
| 70 | + $input=unpack('N', $this->STREAM->read(4)); |
|
| 71 | + return array_shift($input); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | function read($bytes) { |
| 76 | - return $this->STREAM->read($bytes); |
|
| 76 | + return $this->STREAM->read($bytes); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | * @return Array of Integers |
| 84 | 84 | */ |
| 85 | 85 | function readintarray($count) { |
| 86 | - if ($this->BYTEORDER == 0) { |
|
| 87 | - // low endian |
|
| 88 | - return unpack('V'.$count, $this->STREAM->read(4 * $count)); |
|
| 89 | - } else { |
|
| 90 | - // big endian |
|
| 91 | - return unpack('N'.$count, $this->STREAM->read(4 * $count)); |
|
| 92 | - } |
|
| 86 | + if ($this->BYTEORDER == 0) { |
|
| 87 | + // low endian |
|
| 88 | + return unpack('V'.$count, $this->STREAM->read(4 * $count)); |
|
| 89 | + } else { |
|
| 90 | + // big endian |
|
| 91 | + return unpack('N'.$count, $this->STREAM->read(4 * $count)); |
|
| 92 | + } |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -99,35 +99,35 @@ discard block |
||
| 99 | 99 | * @param boolean enable_cache Enable or disable caching of strings (default on) |
| 100 | 100 | */ |
| 101 | 101 | function __construct($Reader, $enable_cache = true) { |
| 102 | - // If there isn't a StreamReader, turn on short circuit mode. |
|
| 103 | - if (! $Reader || isset($Reader->error) ) { |
|
| 104 | - $this->short_circuit = true; |
|
| 105 | - return; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // Caching can be turned off |
|
| 109 | - $this->enable_cache = $enable_cache; |
|
| 110 | - |
|
| 111 | - $MAGIC1 = "\x95\x04\x12\xde"; |
|
| 112 | - $MAGIC2 = "\xde\x12\x04\x95"; |
|
| 113 | - |
|
| 114 | - $this->STREAM = $Reader; |
|
| 115 | - $magic = $this->read(4); |
|
| 116 | - if ($magic == $MAGIC1) { |
|
| 117 | - $this->BYTEORDER = 1; |
|
| 118 | - } elseif ($magic == $MAGIC2) { |
|
| 119 | - $this->BYTEORDER = 0; |
|
| 120 | - } else { |
|
| 121 | - $this->error = 1; // not MO file |
|
| 122 | - return false; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - // FIXME: Do we care about revision? We should. |
|
| 126 | - $revision = $this->readint(); |
|
| 127 | - |
|
| 128 | - $this->total = $this->readint(); |
|
| 129 | - $this->originals = $this->readint(); |
|
| 130 | - $this->translations = $this->readint(); |
|
| 102 | + // If there isn't a StreamReader, turn on short circuit mode. |
|
| 103 | + if (! $Reader || isset($Reader->error) ) { |
|
| 104 | + $this->short_circuit = true; |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // Caching can be turned off |
|
| 109 | + $this->enable_cache = $enable_cache; |
|
| 110 | + |
|
| 111 | + $MAGIC1 = "\x95\x04\x12\xde"; |
|
| 112 | + $MAGIC2 = "\xde\x12\x04\x95"; |
|
| 113 | + |
|
| 114 | + $this->STREAM = $Reader; |
|
| 115 | + $magic = $this->read(4); |
|
| 116 | + if ($magic == $MAGIC1) { |
|
| 117 | + $this->BYTEORDER = 1; |
|
| 118 | + } elseif ($magic == $MAGIC2) { |
|
| 119 | + $this->BYTEORDER = 0; |
|
| 120 | + } else { |
|
| 121 | + $this->error = 1; // not MO file |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // FIXME: Do we care about revision? We should. |
|
| 126 | + $revision = $this->readint(); |
|
| 127 | + |
|
| 128 | + $this->total = $this->readint(); |
|
| 129 | + $this->originals = $this->readint(); |
|
| 130 | + $this->translations = $this->readint(); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -138,32 +138,32 @@ discard block |
||
| 138 | 138 | * @access private |
| 139 | 139 | */ |
| 140 | 140 | function load_tables() { |
| 141 | - if (is_array($this->cache_translations) && |
|
| 142 | - is_array($this->table_originals) && |
|
| 143 | - is_array($this->table_translations)) |
|
| 144 | - return; |
|
| 145 | - |
|
| 146 | - /* get original and translations tables */ |
|
| 147 | - if (!is_array($this->table_originals)) { |
|
| 148 | - $this->STREAM->seekto($this->originals); |
|
| 149 | - $this->table_originals = $this->readintarray($this->total * 2); |
|
| 150 | - } |
|
| 151 | - if (!is_array($this->table_translations)) { |
|
| 152 | - $this->STREAM->seekto($this->translations); |
|
| 153 | - $this->table_translations = $this->readintarray($this->total * 2); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - if ($this->enable_cache) { |
|
| 157 | - $this->cache_translations = array (); |
|
| 158 | - /* read all strings in the cache */ |
|
| 159 | - for ($i = 0; $i < $this->total; $i++) { |
|
| 160 | - $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); |
|
| 161 | - $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]); |
|
| 162 | - $this->STREAM->seekto($this->table_translations[$i * 2 + 2]); |
|
| 163 | - $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]); |
|
| 164 | - $this->cache_translations[$original] = $translation; |
|
| 165 | - } |
|
| 166 | - } |
|
| 141 | + if (is_array($this->cache_translations) && |
|
| 142 | + is_array($this->table_originals) && |
|
| 143 | + is_array($this->table_translations)) |
|
| 144 | + return; |
|
| 145 | + |
|
| 146 | + /* get original and translations tables */ |
|
| 147 | + if (!is_array($this->table_originals)) { |
|
| 148 | + $this->STREAM->seekto($this->originals); |
|
| 149 | + $this->table_originals = $this->readintarray($this->total * 2); |
|
| 150 | + } |
|
| 151 | + if (!is_array($this->table_translations)) { |
|
| 152 | + $this->STREAM->seekto($this->translations); |
|
| 153 | + $this->table_translations = $this->readintarray($this->total * 2); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + if ($this->enable_cache) { |
|
| 157 | + $this->cache_translations = array (); |
|
| 158 | + /* read all strings in the cache */ |
|
| 159 | + for ($i = 0; $i < $this->total; $i++) { |
|
| 160 | + $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); |
|
| 161 | + $original = $this->STREAM->read($this->table_originals[$i * 2 + 1]); |
|
| 162 | + $this->STREAM->seekto($this->table_translations[$i * 2 + 2]); |
|
| 163 | + $translation = $this->STREAM->read($this->table_translations[$i * 2 + 1]); |
|
| 164 | + $this->cache_translations[$original] = $translation; |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | * @return string Requested string if found, otherwise '' |
| 175 | 175 | */ |
| 176 | 176 | function get_original_string($num) { |
| 177 | - $length = $this->table_originals[$num * 2 + 1]; |
|
| 178 | - $offset = $this->table_originals[$num * 2 + 2]; |
|
| 179 | - if (! $length) |
|
| 180 | - return ''; |
|
| 181 | - $this->STREAM->seekto($offset); |
|
| 182 | - $data = $this->STREAM->read($length); |
|
| 183 | - return (string)$data; |
|
| 177 | + $length = $this->table_originals[$num * 2 + 1]; |
|
| 178 | + $offset = $this->table_originals[$num * 2 + 2]; |
|
| 179 | + if (! $length) |
|
| 180 | + return ''; |
|
| 181 | + $this->STREAM->seekto($offset); |
|
| 182 | + $data = $this->STREAM->read($length); |
|
| 183 | + return (string)$data; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -191,13 +191,13 @@ discard block |
||
| 191 | 191 | * @return string Requested string if found, otherwise '' |
| 192 | 192 | */ |
| 193 | 193 | function get_translation_string($num) { |
| 194 | - $length = $this->table_translations[$num * 2 + 1]; |
|
| 195 | - $offset = $this->table_translations[$num * 2 + 2]; |
|
| 196 | - if (! $length) |
|
| 197 | - return ''; |
|
| 198 | - $this->STREAM->seekto($offset); |
|
| 199 | - $data = $this->STREAM->read($length); |
|
| 200 | - return (string)$data; |
|
| 194 | + $length = $this->table_translations[$num * 2 + 1]; |
|
| 195 | + $offset = $this->table_translations[$num * 2 + 2]; |
|
| 196 | + if (! $length) |
|
| 197 | + return ''; |
|
| 198 | + $this->STREAM->seekto($offset); |
|
| 199 | + $data = $this->STREAM->read($length); |
|
| 200 | + return (string)$data; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -210,35 +210,35 @@ discard block |
||
| 210 | 210 | * @return int string number (offset in originals table) |
| 211 | 211 | */ |
| 212 | 212 | function find_string($string, $start = -1, $end = -1) { |
| 213 | - if (($start == -1) or ($end == -1)) { |
|
| 214 | - // find_string is called with only one parameter, set start end end |
|
| 215 | - $start = 0; |
|
| 216 | - $end = $this->total; |
|
| 217 | - } |
|
| 218 | - if (abs($start - $end) <= 1) { |
|
| 219 | - // We're done, now we either found the string, or it doesn't exist |
|
| 220 | - $txt = $this->get_original_string($start); |
|
| 221 | - if ($string == $txt) |
|
| 222 | - return $start; |
|
| 223 | - else |
|
| 224 | - return -1; |
|
| 225 | - } else if ($start > $end) { |
|
| 226 | - // start > end -> turn around and start over |
|
| 227 | - return $this->find_string($string, $end, $start); |
|
| 228 | - } else { |
|
| 229 | - // Divide table in two parts |
|
| 230 | - $half = (int)(($start + $end) / 2); |
|
| 231 | - $cmp = strcmp($string, $this->get_original_string($half)); |
|
| 232 | - if ($cmp == 0) |
|
| 233 | - // string is exactly in the middle => return it |
|
| 234 | - return $half; |
|
| 235 | - else if ($cmp < 0) |
|
| 236 | - // The string is in the upper half |
|
| 237 | - return $this->find_string($string, $start, $half); |
|
| 238 | - else |
|
| 239 | - // The string is in the lower half |
|
| 240 | - return $this->find_string($string, $half, $end); |
|
| 241 | - } |
|
| 213 | + if (($start == -1) or ($end == -1)) { |
|
| 214 | + // find_string is called with only one parameter, set start end end |
|
| 215 | + $start = 0; |
|
| 216 | + $end = $this->total; |
|
| 217 | + } |
|
| 218 | + if (abs($start - $end) <= 1) { |
|
| 219 | + // We're done, now we either found the string, or it doesn't exist |
|
| 220 | + $txt = $this->get_original_string($start); |
|
| 221 | + if ($string == $txt) |
|
| 222 | + return $start; |
|
| 223 | + else |
|
| 224 | + return -1; |
|
| 225 | + } else if ($start > $end) { |
|
| 226 | + // start > end -> turn around and start over |
|
| 227 | + return $this->find_string($string, $end, $start); |
|
| 228 | + } else { |
|
| 229 | + // Divide table in two parts |
|
| 230 | + $half = (int)(($start + $end) / 2); |
|
| 231 | + $cmp = strcmp($string, $this->get_original_string($half)); |
|
| 232 | + if ($cmp == 0) |
|
| 233 | + // string is exactly in the middle => return it |
|
| 234 | + return $half; |
|
| 235 | + else if ($cmp < 0) |
|
| 236 | + // The string is in the upper half |
|
| 237 | + return $this->find_string($string, $start, $half); |
|
| 238 | + else |
|
| 239 | + // The string is in the lower half |
|
| 240 | + return $this->find_string($string, $half, $end); |
|
| 241 | + } |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -249,24 +249,24 @@ discard block |
||
| 249 | 249 | * @return string translated string (or original, if not found) |
| 250 | 250 | */ |
| 251 | 251 | function translate($string) { |
| 252 | - if ($this->short_circuit) |
|
| 253 | - return $string; |
|
| 254 | - $this->load_tables(); |
|
| 255 | - |
|
| 256 | - if ($this->enable_cache) { |
|
| 257 | - // Caching enabled, get translated string from cache |
|
| 258 | - if (array_key_exists($string, $this->cache_translations)) |
|
| 259 | - return $this->cache_translations[$string]; |
|
| 260 | - else |
|
| 261 | - return $string; |
|
| 262 | - } else { |
|
| 263 | - // Caching not enabled, try to find string |
|
| 264 | - $num = $this->find_string($string); |
|
| 265 | - if ($num == -1) |
|
| 266 | - return $string; |
|
| 267 | - else |
|
| 268 | - return $this->get_translation_string($num); |
|
| 269 | - } |
|
| 252 | + if ($this->short_circuit) |
|
| 253 | + return $string; |
|
| 254 | + $this->load_tables(); |
|
| 255 | + |
|
| 256 | + if ($this->enable_cache) { |
|
| 257 | + // Caching enabled, get translated string from cache |
|
| 258 | + if (array_key_exists($string, $this->cache_translations)) |
|
| 259 | + return $this->cache_translations[$string]; |
|
| 260 | + else |
|
| 261 | + return $string; |
|
| 262 | + } else { |
|
| 263 | + // Caching not enabled, try to find string |
|
| 264 | + $num = $this->find_string($string); |
|
| 265 | + if ($num == -1) |
|
| 266 | + return $string; |
|
| 267 | + else |
|
| 268 | + return $this->get_translation_string($num); |
|
| 269 | + } |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | /** |
@@ -276,32 +276,32 @@ discard block |
||
| 276 | 276 | * @return string sanitized plural form expression |
| 277 | 277 | */ |
| 278 | 278 | function sanitize_plural_expression($expr) { |
| 279 | - // Get rid of disallowed characters. |
|
| 280 | - $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr); |
|
| 281 | - |
|
| 282 | - // Add parenthesis for tertiary '?' operator. |
|
| 283 | - $expr .= ';'; |
|
| 284 | - $res = ''; |
|
| 285 | - $p = 0; |
|
| 286 | - for ($i = 0; $i < strlen($expr); $i++) { |
|
| 287 | - $ch = $expr[$i]; |
|
| 288 | - switch ($ch) { |
|
| 289 | - case '?': |
|
| 290 | - $res .= ' ? ('; |
|
| 291 | - $p++; |
|
| 292 | - break; |
|
| 293 | - case ':': |
|
| 294 | - $res .= ') : ('; |
|
| 295 | - break; |
|
| 296 | - case ';': |
|
| 297 | - $res .= str_repeat( ')', $p) . ';'; |
|
| 298 | - $p = 0; |
|
| 299 | - break; |
|
| 300 | - default: |
|
| 301 | - $res .= $ch; |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - return $res; |
|
| 279 | + // Get rid of disallowed characters. |
|
| 280 | + $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr); |
|
| 281 | + |
|
| 282 | + // Add parenthesis for tertiary '?' operator. |
|
| 283 | + $expr .= ';'; |
|
| 284 | + $res = ''; |
|
| 285 | + $p = 0; |
|
| 286 | + for ($i = 0; $i < strlen($expr); $i++) { |
|
| 287 | + $ch = $expr[$i]; |
|
| 288 | + switch ($ch) { |
|
| 289 | + case '?': |
|
| 290 | + $res .= ' ? ('; |
|
| 291 | + $p++; |
|
| 292 | + break; |
|
| 293 | + case ':': |
|
| 294 | + $res .= ') : ('; |
|
| 295 | + break; |
|
| 296 | + case ';': |
|
| 297 | + $res .= str_repeat( ')', $p) . ';'; |
|
| 298 | + $p = 0; |
|
| 299 | + break; |
|
| 300 | + default: |
|
| 301 | + $res .= $ch; |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + return $res; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | /** |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | * @return string verbatim plural form header field |
| 312 | 312 | */ |
| 313 | 313 | function extract_plural_forms_header_from_po_header($header) { |
| 314 | - if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) |
|
| 315 | - $expr = $regs[2]; |
|
| 316 | - else |
|
| 317 | - $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 318 | - return $expr; |
|
| 314 | + if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) |
|
| 315 | + $expr = $regs[2]; |
|
| 316 | + else |
|
| 317 | + $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 318 | + return $expr; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | /** |
@@ -325,21 +325,21 @@ discard block |
||
| 325 | 325 | * @return string plural form header |
| 326 | 326 | */ |
| 327 | 327 | function get_plural_forms() { |
| 328 | - // lets assume message number 0 is header |
|
| 329 | - // this is true, right? |
|
| 330 | - $this->load_tables(); |
|
| 331 | - |
|
| 332 | - // cache header field for plural forms |
|
| 333 | - if (! is_string($this->pluralheader)) { |
|
| 334 | - if ($this->enable_cache) { |
|
| 335 | - $header = $this->cache_translations[""]; |
|
| 336 | - } else { |
|
| 337 | - $header = $this->get_translation_string(0); |
|
| 338 | - } |
|
| 339 | - $expr = $this->extract_plural_forms_header_from_po_header($header); |
|
| 340 | - $this->pluralheader = $this->sanitize_plural_expression($expr); |
|
| 341 | - } |
|
| 342 | - return $this->pluralheader; |
|
| 328 | + // lets assume message number 0 is header |
|
| 329 | + // this is true, right? |
|
| 330 | + $this->load_tables(); |
|
| 331 | + |
|
| 332 | + // cache header field for plural forms |
|
| 333 | + if (! is_string($this->pluralheader)) { |
|
| 334 | + if ($this->enable_cache) { |
|
| 335 | + $header = $this->cache_translations[""]; |
|
| 336 | + } else { |
|
| 337 | + $header = $this->get_translation_string(0); |
|
| 338 | + } |
|
| 339 | + $expr = $this->extract_plural_forms_header_from_po_header($header); |
|
| 340 | + $this->pluralheader = $this->sanitize_plural_expression($expr); |
|
| 341 | + } |
|
| 342 | + return $this->pluralheader; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -350,21 +350,21 @@ discard block |
||
| 350 | 350 | * @return int array index of the right plural form |
| 351 | 351 | */ |
| 352 | 352 | function select_string($n) { |
| 353 | - if (!is_int($n)) { |
|
| 354 | - throw new InvalidArgumentException( |
|
| 355 | - "Select_string only accepts integers: " . $n); |
|
| 356 | - } |
|
| 357 | - $string = $this->get_plural_forms(); |
|
| 358 | - $string = str_replace('nplurals',"\$total",$string); |
|
| 359 | - $string = str_replace("n",$n,$string); |
|
| 360 | - $string = str_replace('plural',"\$plural",$string); |
|
| 361 | - |
|
| 362 | - $total = 0; |
|
| 363 | - $plural = 0; |
|
| 364 | - |
|
| 365 | - eval("$string"); |
|
| 366 | - if ($plural >= $total) $plural = $total - 1; |
|
| 367 | - return $plural; |
|
| 353 | + if (!is_int($n)) { |
|
| 354 | + throw new InvalidArgumentException( |
|
| 355 | + "Select_string only accepts integers: " . $n); |
|
| 356 | + } |
|
| 357 | + $string = $this->get_plural_forms(); |
|
| 358 | + $string = str_replace('nplurals',"\$total",$string); |
|
| 359 | + $string = str_replace("n",$n,$string); |
|
| 360 | + $string = str_replace('plural',"\$plural",$string); |
|
| 361 | + |
|
| 362 | + $total = 0; |
|
| 363 | + $plural = 0; |
|
| 364 | + |
|
| 365 | + eval("$string"); |
|
| 366 | + if ($plural >= $total) $plural = $total - 1; |
|
| 367 | + return $plural; |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
@@ -377,58 +377,58 @@ discard block |
||
| 377 | 377 | * @return translated plural form |
| 378 | 378 | */ |
| 379 | 379 | function ngettext($single, $plural, $number) { |
| 380 | - if ($this->short_circuit) { |
|
| 381 | - if ($number != 1) |
|
| 382 | - return $plural; |
|
| 383 | - else |
|
| 384 | - return $single; |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - // find out the appropriate form |
|
| 388 | - $select = $this->select_string($number); |
|
| 389 | - |
|
| 390 | - // this should contains all strings separated by NULLs |
|
| 391 | - $key = $single . chr(0) . $plural; |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - if ($this->enable_cache) { |
|
| 395 | - if (! array_key_exists($key, $this->cache_translations)) { |
|
| 396 | - return ($number != 1) ? $plural : $single; |
|
| 397 | - } else { |
|
| 398 | - $result = $this->cache_translations[$key]; |
|
| 399 | - $list = explode(chr(0), $result); |
|
| 400 | - return $list[$select]; |
|
| 401 | - } |
|
| 402 | - } else { |
|
| 403 | - $num = $this->find_string($key); |
|
| 404 | - if ($num == -1) { |
|
| 405 | - return ($number != 1) ? $plural : $single; |
|
| 406 | - } else { |
|
| 407 | - $result = $this->get_translation_string($num); |
|
| 408 | - $list = explode(chr(0), $result); |
|
| 409 | - return $list[$select]; |
|
| 410 | - } |
|
| 411 | - } |
|
| 380 | + if ($this->short_circuit) { |
|
| 381 | + if ($number != 1) |
|
| 382 | + return $plural; |
|
| 383 | + else |
|
| 384 | + return $single; |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + // find out the appropriate form |
|
| 388 | + $select = $this->select_string($number); |
|
| 389 | + |
|
| 390 | + // this should contains all strings separated by NULLs |
|
| 391 | + $key = $single . chr(0) . $plural; |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + if ($this->enable_cache) { |
|
| 395 | + if (! array_key_exists($key, $this->cache_translations)) { |
|
| 396 | + return ($number != 1) ? $plural : $single; |
|
| 397 | + } else { |
|
| 398 | + $result = $this->cache_translations[$key]; |
|
| 399 | + $list = explode(chr(0), $result); |
|
| 400 | + return $list[$select]; |
|
| 401 | + } |
|
| 402 | + } else { |
|
| 403 | + $num = $this->find_string($key); |
|
| 404 | + if ($num == -1) { |
|
| 405 | + return ($number != 1) ? $plural : $single; |
|
| 406 | + } else { |
|
| 407 | + $result = $this->get_translation_string($num); |
|
| 408 | + $list = explode(chr(0), $result); |
|
| 409 | + return $list[$select]; |
|
| 410 | + } |
|
| 411 | + } |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | function pgettext($context, $msgid) { |
| 415 | - $key = $context . chr(4) . $msgid; |
|
| 416 | - $ret = $this->translate($key); |
|
| 417 | - if (strpos($ret, "\004") !== FALSE) { |
|
| 418 | - return $msgid; |
|
| 419 | - } else { |
|
| 420 | - return $ret; |
|
| 421 | - } |
|
| 415 | + $key = $context . chr(4) . $msgid; |
|
| 416 | + $ret = $this->translate($key); |
|
| 417 | + if (strpos($ret, "\004") !== FALSE) { |
|
| 418 | + return $msgid; |
|
| 419 | + } else { |
|
| 420 | + return $ret; |
|
| 421 | + } |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | function npgettext($context, $singular, $plural, $number) { |
| 425 | - $key = $context . chr(4) . $singular; |
|
| 426 | - $ret = $this->ngettext($key, $plural, $number); |
|
| 427 | - if (strpos($ret, "\004") !== FALSE) { |
|
| 428 | - return $singular; |
|
| 429 | - } else { |
|
| 430 | - return $ret; |
|
| 431 | - } |
|
| 425 | + $key = $context . chr(4) . $singular; |
|
| 426 | + $ret = $this->ngettext($key, $plural, $number); |
|
| 427 | + if (strpos($ret, "\004") !== FALSE) { |
|
| 428 | + return $singular; |
|
| 429 | + } else { |
|
| 430 | + return $ret; |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | 433 | } |
| 434 | 434 | } |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | var $error = 0; // public variable that holds error code (0 if no error) |
| 39 | 39 | |
| 40 | 40 | //private: |
| 41 | - var $BYTEORDER = 0; // 0: low endian, 1: big endian |
|
| 41 | + var $BYTEORDER = 0; // 0: low endian, 1: big endian |
|
| 42 | 42 | var $STREAM = NULL; |
| 43 | 43 | var $short_circuit = false; |
| 44 | 44 | var $enable_cache = false; |
| 45 | - var $originals = NULL; // offset of original table |
|
| 46 | - var $translations = NULL; // offset of translation table |
|
| 47 | - var $pluralheader = NULL; // cache header field for plural forms |
|
| 48 | - var $total = 0; // total string count |
|
| 49 | - var $table_originals = NULL; // table for original strings (offsets) |
|
| 50 | - var $table_translations = NULL; // table for translated strings (offsets) |
|
| 51 | - var $cache_translations = NULL; // original -> translation mapping |
|
| 45 | + var $originals = NULL; // offset of original table |
|
| 46 | + var $translations = NULL; // offset of translation table |
|
| 47 | + var $pluralheader = NULL; // cache header field for plural forms |
|
| 48 | + var $total = 0; // total string count |
|
| 49 | + var $table_originals = NULL; // table for original strings (offsets) |
|
| 50 | + var $table_translations = NULL; // table for translated strings (offsets) |
|
| 51 | + var $cache_translations = NULL; // original -> translation mapping |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | /* Methods */ |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | function readint() { |
| 64 | 64 | if ($this->BYTEORDER == 0) { |
| 65 | 65 | // low endian |
| 66 | - $input=unpack('V', $this->STREAM->read(4)); |
|
| 66 | + $input = unpack('V', $this->STREAM->read(4)); |
|
| 67 | 67 | return array_shift($input); |
| 68 | 68 | } else { |
| 69 | 69 | // big endian |
| 70 | - $input=unpack('N', $this->STREAM->read(4)); |
|
| 70 | + $input = unpack('N', $this->STREAM->read(4)); |
|
| 71 | 71 | return array_shift($input); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | function __construct($Reader, $enable_cache = true) { |
| 102 | 102 | // If there isn't a StreamReader, turn on short circuit mode. |
| 103 | - if (! $Reader || isset($Reader->error) ) { |
|
| 103 | + if (!$Reader || isset($Reader->error)) { |
|
| 104 | 104 | $this->short_circuit = true; |
| 105 | 105 | return; |
| 106 | 106 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | if ($this->enable_cache) { |
| 157 | - $this->cache_translations = array (); |
|
| 157 | + $this->cache_translations = array(); |
|
| 158 | 158 | /* read all strings in the cache */ |
| 159 | 159 | for ($i = 0; $i < $this->total; $i++) { |
| 160 | 160 | $this->STREAM->seekto($this->table_originals[$i * 2 + 2]); |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | function get_original_string($num) { |
| 177 | 177 | $length = $this->table_originals[$num * 2 + 1]; |
| 178 | 178 | $offset = $this->table_originals[$num * 2 + 2]; |
| 179 | - if (! $length) |
|
| 179 | + if (!$length) |
|
| 180 | 180 | return ''; |
| 181 | 181 | $this->STREAM->seekto($offset); |
| 182 | 182 | $data = $this->STREAM->read($length); |
| 183 | - return (string)$data; |
|
| 183 | + return (string) $data; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | function get_translation_string($num) { |
| 194 | 194 | $length = $this->table_translations[$num * 2 + 1]; |
| 195 | 195 | $offset = $this->table_translations[$num * 2 + 2]; |
| 196 | - if (! $length) |
|
| 196 | + if (!$length) |
|
| 197 | 197 | return ''; |
| 198 | 198 | $this->STREAM->seekto($offset); |
| 199 | 199 | $data = $this->STREAM->read($length); |
| 200 | - return (string)$data; |
|
| 200 | + return (string) $data; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | return $this->find_string($string, $end, $start); |
| 228 | 228 | } else { |
| 229 | 229 | // Divide table in two parts |
| 230 | - $half = (int)(($start + $end) / 2); |
|
| 230 | + $half = (int) (($start + $end) / 2); |
|
| 231 | 231 | $cmp = strcmp($string, $this->get_original_string($half)); |
| 232 | 232 | if ($cmp == 0) |
| 233 | 233 | // string is exactly in the middle => return it |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | $res .= ') : ('; |
| 295 | 295 | break; |
| 296 | 296 | case ';': |
| 297 | - $res .= str_repeat( ')', $p) . ';'; |
|
| 297 | + $res .= str_repeat(')', $p).';'; |
|
| 298 | 298 | $p = 0; |
| 299 | 299 | break; |
| 300 | 300 | default: |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $this->load_tables(); |
| 331 | 331 | |
| 332 | 332 | // cache header field for plural forms |
| 333 | - if (! is_string($this->pluralheader)) { |
|
| 333 | + if (!is_string($this->pluralheader)) { |
|
| 334 | 334 | if ($this->enable_cache) { |
| 335 | 335 | $header = $this->cache_translations[""]; |
| 336 | 336 | } else { |
@@ -352,12 +352,12 @@ discard block |
||
| 352 | 352 | function select_string($n) { |
| 353 | 353 | if (!is_int($n)) { |
| 354 | 354 | throw new InvalidArgumentException( |
| 355 | - "Select_string only accepts integers: " . $n); |
|
| 355 | + "Select_string only accepts integers: ".$n); |
|
| 356 | 356 | } |
| 357 | 357 | $string = $this->get_plural_forms(); |
| 358 | - $string = str_replace('nplurals',"\$total",$string); |
|
| 359 | - $string = str_replace("n",$n,$string); |
|
| 360 | - $string = str_replace('plural',"\$plural",$string); |
|
| 358 | + $string = str_replace('nplurals', "\$total", $string); |
|
| 359 | + $string = str_replace("n", $n, $string); |
|
| 360 | + $string = str_replace('plural', "\$plural", $string); |
|
| 361 | 361 | |
| 362 | 362 | $total = 0; |
| 363 | 363 | $plural = 0; |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | $select = $this->select_string($number); |
| 389 | 389 | |
| 390 | 390 | // this should contains all strings separated by NULLs |
| 391 | - $key = $single . chr(0) . $plural; |
|
| 391 | + $key = $single.chr(0).$plural; |
|
| 392 | 392 | |
| 393 | 393 | |
| 394 | 394 | if ($this->enable_cache) { |
| 395 | - if (! array_key_exists($key, $this->cache_translations)) { |
|
| 395 | + if (!array_key_exists($key, $this->cache_translations)) { |
|
| 396 | 396 | return ($number != 1) ? $plural : $single; |
| 397 | 397 | } else { |
| 398 | 398 | $result = $this->cache_translations[$key]; |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | function pgettext($context, $msgid) { |
| 415 | - $key = $context . chr(4) . $msgid; |
|
| 415 | + $key = $context.chr(4).$msgid; |
|
| 416 | 416 | $ret = $this->translate($key); |
| 417 | 417 | if (strpos($ret, "\004") !== FALSE) { |
| 418 | 418 | return $msgid; |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | function npgettext($context, $singular, $plural, $number) { |
| 425 | - $key = $context . chr(4) . $singular; |
|
| 425 | + $key = $context.chr(4).$singular; |
|
| 426 | 426 | $ret = $this->ngettext($key, $plural, $number); |
| 427 | 427 | if (strpos($ret, "\004") !== FALSE) { |
| 428 | 428 | return $singular; |
@@ -140,8 +140,9 @@ discard block |
||
| 140 | 140 | function load_tables() { |
| 141 | 141 | if (is_array($this->cache_translations) && |
| 142 | 142 | is_array($this->table_originals) && |
| 143 | - is_array($this->table_translations)) |
|
| 144 | - return; |
|
| 143 | + is_array($this->table_translations)) { |
|
| 144 | + return; |
|
| 145 | + } |
|
| 145 | 146 | |
| 146 | 147 | /* get original and translations tables */ |
| 147 | 148 | if (!is_array($this->table_originals)) { |
@@ -176,8 +177,9 @@ discard block |
||
| 176 | 177 | function get_original_string($num) { |
| 177 | 178 | $length = $this->table_originals[$num * 2 + 1]; |
| 178 | 179 | $offset = $this->table_originals[$num * 2 + 2]; |
| 179 | - if (! $length) |
|
| 180 | - return ''; |
|
| 180 | + if (! $length) { |
|
| 181 | + return ''; |
|
| 182 | + } |
|
| 181 | 183 | $this->STREAM->seekto($offset); |
| 182 | 184 | $data = $this->STREAM->read($length); |
| 183 | 185 | return (string)$data; |
@@ -193,8 +195,9 @@ discard block |
||
| 193 | 195 | function get_translation_string($num) { |
| 194 | 196 | $length = $this->table_translations[$num * 2 + 1]; |
| 195 | 197 | $offset = $this->table_translations[$num * 2 + 2]; |
| 196 | - if (! $length) |
|
| 197 | - return ''; |
|
| 198 | + if (! $length) { |
|
| 199 | + return ''; |
|
| 200 | + } |
|
| 198 | 201 | $this->STREAM->seekto($offset); |
| 199 | 202 | $data = $this->STREAM->read($length); |
| 200 | 203 | return (string)$data; |
@@ -218,10 +221,11 @@ discard block |
||
| 218 | 221 | if (abs($start - $end) <= 1) { |
| 219 | 222 | // We're done, now we either found the string, or it doesn't exist |
| 220 | 223 | $txt = $this->get_original_string($start); |
| 221 | - if ($string == $txt) |
|
| 222 | - return $start; |
|
| 223 | - else |
|
| 224 | - return -1; |
|
| 224 | + if ($string == $txt) { |
|
| 225 | + return $start; |
|
| 226 | + } else { |
|
| 227 | + return -1; |
|
| 228 | + } |
|
| 225 | 229 | } else if ($start > $end) { |
| 226 | 230 | // start > end -> turn around and start over |
| 227 | 231 | return $this->find_string($string, $end, $start); |
@@ -229,15 +233,16 @@ discard block |
||
| 229 | 233 | // Divide table in two parts |
| 230 | 234 | $half = (int)(($start + $end) / 2); |
| 231 | 235 | $cmp = strcmp($string, $this->get_original_string($half)); |
| 232 | - if ($cmp == 0) |
|
| 233 | - // string is exactly in the middle => return it |
|
| 236 | + if ($cmp == 0) { |
|
| 237 | + // string is exactly in the middle => return it |
|
| 234 | 238 | return $half; |
| 235 | - else if ($cmp < 0) |
|
| 236 | - // The string is in the upper half |
|
| 239 | + } else if ($cmp < 0) { |
|
| 240 | + // The string is in the upper half |
|
| 237 | 241 | return $this->find_string($string, $start, $half); |
| 238 | - else |
|
| 239 | - // The string is in the lower half |
|
| 242 | + } else { |
|
| 243 | + // The string is in the lower half |
|
| 240 | 244 | return $this->find_string($string, $half, $end); |
| 245 | + } |
|
| 241 | 246 | } |
| 242 | 247 | } |
| 243 | 248 | |
@@ -249,23 +254,26 @@ discard block |
||
| 249 | 254 | * @return string translated string (or original, if not found) |
| 250 | 255 | */ |
| 251 | 256 | function translate($string) { |
| 252 | - if ($this->short_circuit) |
|
| 253 | - return $string; |
|
| 257 | + if ($this->short_circuit) { |
|
| 258 | + return $string; |
|
| 259 | + } |
|
| 254 | 260 | $this->load_tables(); |
| 255 | 261 | |
| 256 | 262 | if ($this->enable_cache) { |
| 257 | 263 | // Caching enabled, get translated string from cache |
| 258 | - if (array_key_exists($string, $this->cache_translations)) |
|
| 259 | - return $this->cache_translations[$string]; |
|
| 260 | - else |
|
| 261 | - return $string; |
|
| 264 | + if (array_key_exists($string, $this->cache_translations)) { |
|
| 265 | + return $this->cache_translations[$string]; |
|
| 266 | + } else { |
|
| 267 | + return $string; |
|
| 268 | + } |
|
| 262 | 269 | } else { |
| 263 | 270 | // Caching not enabled, try to find string |
| 264 | 271 | $num = $this->find_string($string); |
| 265 | - if ($num == -1) |
|
| 266 | - return $string; |
|
| 267 | - else |
|
| 268 | - return $this->get_translation_string($num); |
|
| 272 | + if ($num == -1) { |
|
| 273 | + return $string; |
|
| 274 | + } else { |
|
| 275 | + return $this->get_translation_string($num); |
|
| 276 | + } |
|
| 269 | 277 | } |
| 270 | 278 | } |
| 271 | 279 | |
@@ -311,10 +319,11 @@ discard block |
||
| 311 | 319 | * @return string verbatim plural form header field |
| 312 | 320 | */ |
| 313 | 321 | function extract_plural_forms_header_from_po_header($header) { |
| 314 | - if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) |
|
| 315 | - $expr = $regs[2]; |
|
| 316 | - else |
|
| 317 | - $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 322 | + if (preg_match("/(^|\n)plural-forms: ([^\n]*)\n/i", $header, $regs)) { |
|
| 323 | + $expr = $regs[2]; |
|
| 324 | + } else { |
|
| 325 | + $expr = "nplurals=2; plural=n == 1 ? 0 : 1;"; |
|
| 326 | + } |
|
| 318 | 327 | return $expr; |
| 319 | 328 | } |
| 320 | 329 | |
@@ -363,7 +372,9 @@ discard block |
||
| 363 | 372 | $plural = 0; |
| 364 | 373 | |
| 365 | 374 | eval("$string"); |
| 366 | - if ($plural >= $total) $plural = $total - 1; |
|
| 375 | + if ($plural >= $total) { |
|
| 376 | + $plural = $total - 1; |
|
| 377 | + } |
|
| 367 | 378 | return $plural; |
| 368 | 379 | } |
| 369 | 380 | |
@@ -378,10 +389,11 @@ discard block |
||
| 378 | 389 | */ |
| 379 | 390 | function ngettext($single, $plural, $number) { |
| 380 | 391 | if ($this->short_circuit) { |
| 381 | - if ($number != 1) |
|
| 382 | - return $plural; |
|
| 383 | - else |
|
| 384 | - return $single; |
|
| 392 | + if ($number != 1) { |
|
| 393 | + return $plural; |
|
| 394 | + } else { |
|
| 395 | + return $single; |
|
| 396 | + } |
|
| 385 | 397 | } |
| 386 | 398 | |
| 387 | 399 | // find out the appropriate form |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | <?php |
| 94 | 94 | foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { |
| 95 | 95 | if (method_exists($p, "get_js")) { |
| 96 | - $script = $p->get_js(); |
|
| 96 | + $script = $p->get_js(); |
|
| 97 | 97 | |
| 98 | - if ($script) { |
|
| 98 | + if ($script) { |
|
| 99 | 99 | echo "try { |
| 100 | 100 | $script |
| 101 | 101 | } catch (e) { |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | <img src='images/indicator_tiny.gif'/> |
| 147 | 147 | <?php echo __("Loading, please wait..."); ?></div> |
| 148 | 148 | <?php |
| 149 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_TREE) as $p) { |
|
| 150 | - echo $p->hook_feed_tree(); |
|
| 151 | - } |
|
| 152 | - ?> |
|
| 149 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FEED_TREE) as $p) { |
|
| 150 | + echo $p->hook_feed_tree(); |
|
| 151 | + } |
|
| 152 | + ?> |
|
| 153 | 153 | <div id="feedTree"></div> |
| 154 | 154 | </div> |
| 155 | 155 | |
@@ -167,10 +167,10 @@ discard block |
||
| 167 | 167 | title="<?php echo __('Updates are available from Git.') ?>">new_releases</i> |
| 168 | 168 | |
| 169 | 169 | <?php |
| 170 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_MAIN_TOOLBAR_BUTTON) as $p) { |
|
| 171 | - echo $p->hook_main_toolbar_button(); |
|
| 172 | - } |
|
| 173 | - ?> |
|
| 170 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_MAIN_TOOLBAR_BUTTON) as $p) { |
|
| 171 | + echo $p->hook_main_toolbar_button(); |
|
| 172 | + } |
|
| 173 | + ?> |
|
| 174 | 174 | |
| 175 | 175 | <form id="toolbar-headlines" action="" style="order : 10" onsubmit='return false'> |
| 176 | 176 | |
@@ -220,10 +220,10 @@ discard block |
||
| 220 | 220 | <div class="action-chooser" style="order : 30"> |
| 221 | 221 | |
| 222 | 222 | <?php |
| 223 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) { |
|
| 224 | - echo $p->hook_toolbar_button(); |
|
| 225 | - } |
|
| 226 | - ?> |
|
| 223 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) { |
|
| 224 | + echo $p->hook_toolbar_button(); |
|
| 225 | + } |
|
| 226 | + ?> |
|
| 227 | 227 | |
| 228 | 228 | <div dojoType="fox.form.DropDownButton" class="action-button" title="<?php echo __('Actions...') ?>"> |
| 229 | 229 | <span><i class="material-icons">menu</i></span> |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div> |
| 243 | 243 | |
| 244 | 244 | <?php |
| 245 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) { |
|
| 246 | - echo $p->hook_action_item(); |
|
| 247 | - } |
|
| 248 | - ?> |
|
| 245 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) { |
|
| 246 | + echo $p->hook_action_item(); |
|
| 247 | + } |
|
| 248 | + ?> |
|
| 249 | 249 | |
| 250 | 250 | <?php if (!$_SESSION["hide_logout"]) { ?> |
| 251 | 251 | <div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcLogout')"><?php echo __('Logout') ?></div> |
@@ -12,11 +12,11 @@ |
||
| 12 | 12 | // we need a separate check here because functions.php might get parsed |
| 13 | 13 | // incorrectly before 5.3 because of :: syntax. |
| 14 | 14 | if (version_compare(PHP_VERSION, '5.6.0', '<')) { |
| 15 | - print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using " . PHP_VERSION . ".\n"; |
|
| 15 | + print "<b>Fatal Error</b>: PHP version 5.6.0 or newer required. You're using ".PHP_VERSION.".\n"; |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR . |
|
| 19 | + set_include_path(dirname(__FILE__)."/include".PATH_SEPARATOR. |
|
| 20 | 20 | get_include_path()); |
| 21 | 21 | |
| 22 | 22 | require_once "autoload.php"; |
@@ -19,7 +19,9 @@ |
||
| 19 | 19 | require_once "config.php"; |
| 20 | 20 | require_once "db-prefs.php"; |
| 21 | 21 | |
| 22 | - if (!init_plugins()) return; |
|
| 22 | + if (!init_plugins()) { |
|
| 23 | + return; |
|
| 24 | + } |
|
| 23 | 25 | |
| 24 | 26 | login_sequence(); |
| 25 | 27 | |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | $ERRORS[0] = ""; |
| 8 | 8 | |
| 9 | 9 | $ERRORS[1] = __("This program requires XmlHttpRequest " . |
| 10 | - "to function properly. Your browser doesn't seem to support it."); |
|
| 10 | + "to function properly. Your browser doesn't seem to support it."); |
|
| 11 | 11 | |
| 12 | 12 | $ERRORS[2] = __("This program requires cookies " . |
| 13 | - "to function properly. Your browser doesn't seem to support them."); |
|
| 13 | + "to function properly. Your browser doesn't seem to support them."); |
|
| 14 | 14 | |
| 15 | 15 | $ERRORS[3] = __("Backend sanity check failed."); |
| 16 | 16 | |
@@ -41,15 +41,15 @@ discard block |
||
| 41 | 41 | $ERRORS[15] = __("Encoding data as JSON failed"); |
| 42 | 42 | |
| 43 | 43 | if ($_REQUEST['mode'] == 'js') { |
| 44 | - header("Content-Type: text/javascript; charset=UTF-8"); |
|
| 44 | + header("Content-Type: text/javascript; charset=UTF-8"); |
|
| 45 | 45 | |
| 46 | - print "var ERRORS = [];\n"; |
|
| 46 | + print "var ERRORS = [];\n"; |
|
| 47 | 47 | |
| 48 | - foreach ($ERRORS as $id => $error) { |
|
| 48 | + foreach ($ERRORS as $id => $error) { |
|
| 49 | 49 | |
| 50 | - $error = preg_replace("/\n/", "", $error); |
|
| 51 | - $error = preg_replace("/\"/", "\\\"", $error); |
|
| 50 | + $error = preg_replace("/\n/", "", $error); |
|
| 51 | + $error = preg_replace("/\"/", "\\\"", $error); |
|
| 52 | 52 | |
| 53 | - print "ERRORS[$id] = \"$error\";\n"; |
|
| 54 | - } |
|
| 53 | + print "ERRORS[$id] = \"$error\";\n"; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -6,10 +6,10 @@ |
||
| 6 | 6 | |
| 7 | 7 | $ERRORS[0] = ""; |
| 8 | 8 | |
| 9 | -$ERRORS[1] = __("This program requires XmlHttpRequest " . |
|
| 9 | +$ERRORS[1] = __("This program requires XmlHttpRequest ". |
|
| 10 | 10 | "to function properly. Your browser doesn't seem to support it."); |
| 11 | 11 | |
| 12 | -$ERRORS[2] = __("This program requires cookies " . |
|
| 12 | +$ERRORS[2] = __("This program requires cookies ". |
|
| 13 | 13 | "to function properly. Your browser doesn't seem to support them."); |
| 14 | 14 | |
| 15 | 15 | $ERRORS[3] = __("Backend sanity check failed."); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | $new_feed_id = $row['id']; |
| 238 | 238 | } else { |
| 239 | 239 | $row = $this->pdo->query("SELECT MAX(id) AS id FROM ttrss_archived_feeds")->fetch(); |
| 240 | - $new_feed_id = (int)$row['id'] + 1; |
|
| 240 | + $new_feed_id = (int) $row['id'] + 1; |
|
| 241 | 241 | |
| 242 | 242 | $sth = $this->pdo->prepare("INSERT INTO ttrss_archived_feeds |
| 243 | 243 | (id, owner_uid, title, feed_url, site_url, created) |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | /* GET["cmode"] = 0 - mark as read, 1 - as unread, 2 - toggle */ |
| 288 | 288 | public function catchupSelected() { |
| 289 | 289 | $ids = explode(",", clean($_REQUEST["ids"])); |
| 290 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
| 290 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
| 291 | 291 | |
| 292 | 292 | Article::catchupArticlesById($ids, $cmode); |
| 293 | 293 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | public function markSelected() { |
| 298 | 298 | $ids = explode(",", clean($_REQUEST["ids"])); |
| 299 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
| 299 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
| 300 | 300 | |
| 301 | 301 | $this->markArticlesById($ids, $cmode); |
| 302 | 302 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | public function publishSelected() { |
| 307 | 307 | $ids = explode(",", clean($_REQUEST["ids"])); |
| 308 | - $cmode = (int)clean($_REQUEST["cmode"]); |
|
| 308 | + $cmode = (int) clean($_REQUEST["cmode"]); |
|
| 309 | 309 | |
| 310 | 310 | $this->publishArticlesById($ids, $cmode); |
| 311 | 311 | |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | |
| 343 | 343 | print "<ul>"; |
| 344 | 344 | while ($line = $sth->fetch()) { |
| 345 | - print "<li>" . $line["caption"] . "</li>"; |
|
| 345 | + print "<li>".$line["caption"]."</li>"; |
|
| 346 | 346 | } |
| 347 | 347 | print "</ul>"; |
| 348 | 348 | } |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | |
| 579 | 579 | if ($msg) { |
| 580 | 580 | Logger::get()->log_error(E_USER_WARNING, |
| 581 | - $msg, 'client-js:' . $file, $line, $context); |
|
| 581 | + $msg, 'client-js:'.$file, $line, $context); |
|
| 582 | 582 | |
| 583 | 583 | echo json_encode(array("message" => "HOST_ERROR_LOGGED")); |
| 584 | 584 | } else { |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | $content = json_decode($content, true); |
| 603 | 603 | |
| 604 | 604 | if ($content && isset($content["changeset"])) { |
| 605 | - if ($git_timestamp < (int)$content["changeset"]["timestamp"] && |
|
| 605 | + if ($git_timestamp < (int) $content["changeset"]["timestamp"] && |
|
| 606 | 606 | $git_commit != $content["changeset"]["id"]) { |
| 607 | 607 | |
| 608 | 608 | $rv = $content["changeset"]; |
@@ -11,7 +11,9 @@ discard block |
||
| 11 | 11 | $_SESSION["profile"] = (int) clean($_REQUEST["id"]); |
| 12 | 12 | |
| 13 | 13 | // default value |
| 14 | - if (!$_SESSION["profile"]) $_SESSION["profile"] = null; |
|
| 14 | + if (!$_SESSION["profile"]) { |
|
| 15 | + $_SESSION["profile"] = null; |
|
| 16 | + } |
|
| 15 | 17 | } |
| 16 | 18 | |
| 17 | 19 | public function remprofiles() { |
@@ -173,7 +175,9 @@ discard block |
||
| 173 | 175 | if ($row = $sth->fetch()) { |
| 174 | 176 | $feed_id = $row["id"]; |
| 175 | 177 | } else { |
| 176 | - if (!$title) $title = '[Unknown]'; |
|
| 178 | + if (!$title) { |
|
| 179 | + $title = '[Unknown]'; |
|
| 180 | + } |
|
| 177 | 181 | |
| 178 | 182 | $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds |
| 179 | 183 | (owner_uid,feed_url,site_url,title,cat_id,auth_login,auth_pass,update_method) |
@@ -216,7 +220,9 @@ discard block |
||
| 216 | 220 | private function archive_article($id, $owner_uid) { |
| 217 | 221 | $this->pdo->beginTransaction(); |
| 218 | 222 | |
| 219 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
| 223 | + if (!$owner_uid) { |
|
| 224 | + $owner_uid = $_SESSION['uid']; |
|
| 225 | + } |
|
| 220 | 226 | |
| 221 | 227 | $sth = $this->pdo->prepare("SELECT feed_id FROM ttrss_user_entries |
| 222 | 228 | WHERE ref_id = ? AND owner_uid = ?"); |
@@ -278,8 +284,9 @@ discard block |
||
| 278 | 284 | 'seq' => $seq |
| 279 | 285 | ]; |
| 280 | 286 | |
| 281 | - if ($seq % 2 == 0) |
|
| 282 | - $reply['runtime-info'] = make_runtime_info(); |
|
| 287 | + if ($seq % 2 == 0) { |
|
| 288 | + $reply['runtime-info'] = make_runtime_info(); |
|
| 289 | + } |
|
| 283 | 290 | |
| 284 | 291 | print json_encode($reply); |
| 285 | 292 | } |
@@ -353,7 +360,9 @@ discard block |
||
| 353 | 360 | $payload = json_decode(clean($_REQUEST["payload"]), false); |
| 354 | 361 | $mode = clean($_REQUEST["mode"]); |
| 355 | 362 | |
| 356 | - if (!$payload || !is_array($payload)) return; |
|
| 363 | + if (!$payload || !is_array($payload)) { |
|
| 364 | + return; |
|
| 365 | + } |
|
| 357 | 366 | |
| 358 | 367 | if ($mode == 1) { |
| 359 | 368 | foreach ($payload as $feed) { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $sth = $this->pdo->prepare("SELECT link FROM ttrss_entries, ttrss_user_entries |
| 14 | 14 | WHERE id = ? AND id = ref_id AND owner_uid = ? |
| 15 | 15 | LIMIT 1"); |
| 16 | - $sth->execute([$id, $_SESSION['uid']]); |
|
| 16 | + $sth->execute([$id, $_SESSION['uid']]); |
|
| 17 | 17 | |
| 18 | 18 | if ($row = $sth->fetch()) { |
| 19 | 19 | $article_url = $row['link']; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $sth = $pdo->prepare("SELECT int_id FROM ttrss_user_entries WHERE |
| 78 | 78 | ref_id = ? AND owner_uid = ? LIMIT 1"); |
| 79 | - $sth->execute([$ref_id, $owner_uid]); |
|
| 79 | + $sth->execute([$ref_id, $owner_uid]); |
|
| 80 | 80 | |
| 81 | 81 | if ($row = $sth->fetch()) { |
| 82 | 82 | $int_id = $row['int_id']; |
@@ -616,22 +616,22 @@ discard block |
||
| 616 | 616 | |
| 617 | 617 | public static function purge_orphans() { |
| 618 | 618 | |
| 619 | - // purge orphaned posts in main content table |
|
| 619 | + // purge orphaned posts in main content table |
|
| 620 | 620 | |
| 621 | - if (DB_TYPE == "mysql") |
|
| 622 | - $limit_qpart = "LIMIT 5000"; |
|
| 623 | - else |
|
| 624 | - $limit_qpart = ""; |
|
| 621 | + if (DB_TYPE == "mysql") |
|
| 622 | + $limit_qpart = "LIMIT 5000"; |
|
| 623 | + else |
|
| 624 | + $limit_qpart = ""; |
|
| 625 | 625 | |
| 626 | - $pdo = Db::pdo(); |
|
| 627 | - $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
|
| 626 | + $pdo = Db::pdo(); |
|
| 627 | + $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
|
| 628 | 628 | NOT EXISTS (SELECT ref_id FROM ttrss_user_entries WHERE ref_id = id) $limit_qpart"); |
| 629 | 629 | |
| 630 | - if (Debug::enabled()) { |
|
| 631 | - $rows = $res->rowCount(); |
|
| 632 | - Debug::log("Purged $rows orphaned posts."); |
|
| 633 | - } |
|
| 634 | - } |
|
| 630 | + if (Debug::enabled()) { |
|
| 631 | + $rows = $res->rowCount(); |
|
| 632 | + Debug::log("Purged $rows orphaned posts."); |
|
| 633 | + } |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | public static function catchupArticlesById($ids, $cmode, $owner_uid = false) { |
| 637 | 637 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | public static function create_published_article($title, $url, $content, $labels_str, |
| 31 | 31 | $owner_uid) { |
| 32 | 32 | |
| 33 | - $guid = 'SHA1:' . sha1("ttshared:" . $url . $owner_uid); // include owner_uid to prevent global GUID clash |
|
| 33 | + $guid = 'SHA1:'.sha1("ttshared:".$url.$owner_uid); // include owner_uid to prevent global GUID clash |
|
| 34 | 34 | |
| 35 | 35 | if (!$content) { |
| 36 | 36 | $pluginhost = new PluginHost(); |
@@ -85,12 +85,12 @@ discard block |
||
| 85 | 85 | content = ?, content_hash = ? WHERE id = ?"); |
| 86 | 86 | $sth->execute([$content, $content_hash, $ref_id]); |
| 87 | 87 | |
| 88 | - if (DB_TYPE == "pgsql"){ |
|
| 88 | + if (DB_TYPE == "pgsql") { |
|
| 89 | 89 | $sth = $pdo->prepare("UPDATE ttrss_entries |
| 90 | 90 | SET tsvector_combined = to_tsvector( :ts_content) |
| 91 | 91 | WHERE id = :id"); |
| 92 | 92 | $params = [ |
| 93 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
| 93 | + ":ts_content" => mb_substr(strip_tags($content), 0, 900000), |
|
| 94 | 94 | ":id" => $ref_id]; |
| 95 | 95 | $sth->execute($params); |
| 96 | 96 | } |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | if ($row = $sth->fetch()) { |
| 132 | 132 | $ref_id = $row["id"]; |
| 133 | - if (DB_TYPE == "pgsql"){ |
|
| 133 | + if (DB_TYPE == "pgsql") { |
|
| 134 | 134 | $sth = $pdo->prepare("UPDATE ttrss_entries |
| 135 | 135 | SET tsvector_combined = to_tsvector( :ts_content) |
| 136 | 136 | WHERE id = :id"); |
| 137 | 137 | $params = [ |
| 138 | - ":ts_content" => mb_substr(strip_tags($content ), 0, 900000), |
|
| 138 | + ":ts_content" => mb_substr(strip_tags($content), 0, 900000), |
|
| 139 | 139 | ":id" => $ref_id]; |
| 140 | 140 | $sth->execute($params); |
| 141 | 141 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | print_hidden("op", "article"); |
| 174 | 174 | print_hidden("method", "setArticleTags"); |
| 175 | 175 | |
| 176 | - print "<header class='horizontal'>" . __("Tags for this article (separated by commas):")."</header>"; |
|
| 176 | + print "<header class='horizontal'>".__("Tags for this article (separated by commas):")."</header>"; |
|
| 177 | 177 | |
| 178 | 178 | print "<section>"; |
| 179 | 179 | print "<textarea dojoType='dijit.form.SimpleTextarea' rows='4' |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | public function setScore() { |
| 196 | 196 | $ids = explode(",", clean($_REQUEST['id'])); |
| 197 | - $score = (int)clean($_REQUEST['score']); |
|
| 197 | + $score = (int) clean($_REQUEST['score']); |
|
| 198 | 198 | |
| 199 | 199 | $ids_qmarks = arr_qmarks($ids); |
| 200 | 200 | |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $sth->execute(array_merge([$score], $ids, [$_SESSION['uid']])); |
| 205 | 205 | |
| 206 | - print json_encode(["id" => $ids, "score" => (int)$score]); |
|
| 206 | + print json_encode(["id" => $ids, "score" => (int) $score]); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | public function getScore() { |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $score = $row['score']; |
| 217 | 217 | |
| 218 | - print json_encode(["id" => $id, "score" => (int)$score]); |
|
| 218 | + print json_encode(["id" => $id, "score" => (int) $score]); |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | |
| 294 | 294 | print "<ul>"; |
| 295 | 295 | while ($line = $sth->fetch()) { |
| 296 | - print "<li>" . $line["tag_name"] . "</li>"; |
|
| 296 | + print "<li>".$line["tag_name"]."</li>"; |
|
| 297 | 297 | } |
| 298 | 298 | print "</ul>"; |
| 299 | 299 | } |
@@ -432,21 +432,21 @@ discard block |
||
| 432 | 432 | if (!$hide_images) { |
| 433 | 433 | $encsize = ''; |
| 434 | 434 | if ($entry['height'] > 0) |
| 435 | - $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
| 435 | + $encsize .= ' height="'.intval($entry['height']).'"'; |
|
| 436 | 436 | if ($entry['width'] > 0) |
| 437 | - $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
| 437 | + $encsize .= ' width="'.intval($entry['width']).'"'; |
|
| 438 | 438 | $rv .= "<p><img |
| 439 | 439 | alt=\"".htmlspecialchars($entry["filename"])."\" |
| 440 | - src=\"" .htmlspecialchars($entry["url"]) . "\" |
|
| 441 | - " . $encsize . " /></p>"; |
|
| 440 | + src=\"" .htmlspecialchars($entry["url"])."\" |
|
| 441 | + " . $encsize." /></p>"; |
|
| 442 | 442 | } else { |
| 443 | 443 | $rv .= "<p><a target=\"_blank\" rel=\"noopener noreferrer\" |
| 444 | 444 | href=\"".htmlspecialchars($entry["url"])."\" |
| 445 | - >" .htmlspecialchars($entry["url"]) . "</a></p>"; |
|
| 445 | + >" .htmlspecialchars($entry["url"])."</a></p>"; |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | if ($entry['title']) { |
| 449 | - $rv.= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
| 449 | + $rv .= "<div class=\"enclosure_title\">${entry['title']}</div>"; |
|
| 450 | 450 | } |
| 451 | 451 | } |
| 452 | 452 | } |
@@ -461,13 +461,13 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | $rv .= "<div class=\"attachments\" dojoType=\"fox.form.DropDownButton\">". |
| 464 | - "<span>" . __('Attachments')."</span>"; |
|
| 464 | + "<span>".__('Attachments')."</span>"; |
|
| 465 | 465 | |
| 466 | 466 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
| 467 | 467 | |
| 468 | 468 | foreach ($entries as $entry) { |
| 469 | 469 | if ($entry["title"]) |
| 470 | - $title = " — " . truncate_string($entry["title"], 30); |
|
| 470 | + $title = " — ".truncate_string($entry["title"], 30); |
|
| 471 | 471 | else |
| 472 | 472 | $title = ""; |
| 473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | $filename = ""; |
| 478 | 478 | |
| 479 | 479 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
| 480 | - dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; |
|
| 480 | + dojoType=\"dijit.MenuItem\">".$filename.$title."</div>"; |
|
| 481 | 481 | |
| 482 | 482 | }; |
| 483 | 483 | |
@@ -546,10 +546,10 @@ discard block |
||
| 546 | 546 | $tags_str = ""; |
| 547 | 547 | |
| 548 | 548 | for ($i = 0; $i < $maxtags; $i++) { |
| 549 | - $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">" . $tags[$i] . "</a>, "; |
|
| 549 | + $tags_str .= "<a class=\"tag\" href=\"#\" onclick=\"Feeds.open({feed:'".$tags[$i]."'})\">".$tags[$i]."</a>, "; |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | - $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
|
| 552 | + $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str) - 2); |
|
| 553 | 553 | |
| 554 | 554 | if (count($tags) > $maxtags) |
| 555 | 555 | $tags_str .= ", …"; |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | if (!$article_image && !$article_stream) { |
| 742 | 742 | $tmpdoc = new DOMDocument(); |
| 743 | 743 | |
| 744 | - if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">' . mb_substr($content, 0, 131070))) { |
|
| 744 | + if (@$tmpdoc->loadHTML('<?xml encoding="UTF-8">'.mb_substr($content, 0, 131070))) { |
|
| 745 | 745 | $tmpxpath = new DOMXPath($tmpdoc); |
| 746 | 746 | $elems = $tmpxpath->query('(//img[@src]|//video[@poster]|//iframe[contains(@src , "youtube.com/embed/")])'); |
| 747 | 747 | |
@@ -749,8 +749,8 @@ discard block |
||
| 749 | 749 | if ($e->nodeName == "iframe") { |
| 750 | 750 | $matches = []; |
| 751 | 751 | if (preg_match("/\/embed\/([\w-]+)/", $e->getAttribute("src"), $matches)) { |
| 752 | - $article_image = "https://img.youtube.com/vi/" . $matches[1] . "/hqdefault.jpg"; |
|
| 753 | - $article_stream = "https://youtu.be/" . $matches[1]; |
|
| 752 | + $article_image = "https://img.youtube.com/vi/".$matches[1]."/hqdefault.jpg"; |
|
| 753 | + $article_stream = "https://youtu.be/".$matches[1]; |
|
| 754 | 754 | break; |
| 755 | 755 | } |
| 756 | 756 | } else if ($e->nodeName == "video") { |
@@ -57,10 +57,16 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | $rc = false; |
| 59 | 59 | |
| 60 | - if (!$title) $title = $url; |
|
| 61 | - if (!$title && !$url) return false; |
|
| 60 | + if (!$title) { |
|
| 61 | + $title = $url; |
|
| 62 | + } |
|
| 63 | + if (!$title && !$url) { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 62 | 66 | |
| 63 | - if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; |
|
| 67 | + if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 64 | 70 | |
| 65 | 71 | $pdo = Db::pdo(); |
| 66 | 72 | |
@@ -271,7 +277,9 @@ discard block |
||
| 271 | 277 | $tags_str = $this->format_tags_string($tags); |
| 272 | 278 | $tags_str_full = join(", ", $tags); |
| 273 | 279 | |
| 274 | - if (!$tags_str_full) $tags_str_full = __("no tags"); |
|
| 280 | + if (!$tags_str_full) { |
|
| 281 | + $tags_str_full = __("no tags"); |
|
| 282 | + } |
|
| 275 | 283 | |
| 276 | 284 | print json_encode([ |
| 277 | 285 | "id" => (int) $id, |
@@ -320,10 +328,11 @@ discard block |
||
| 320 | 328 | |
| 321 | 329 | foreach ($ids as $id) { |
| 322 | 330 | |
| 323 | - if ($assign) |
|
| 324 | - Labels::add_article($id, $label, $_SESSION["uid"]); |
|
| 325 | - else |
|
| 326 | - Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
| 331 | + if ($assign) { |
|
| 332 | + Labels::add_article($id, $label, $_SESSION["uid"]); |
|
| 333 | + } else { |
|
| 334 | + Labels::remove_article($id, $label, $_SESSION["uid"]); |
|
| 335 | + } |
|
| 327 | 336 | |
| 328 | 337 | $labels = $this->get_article_labels($id, $_SESSION["uid"]); |
| 329 | 338 | |
@@ -384,14 +393,18 @@ discard block |
||
| 384 | 393 | $width = $line["width"]; |
| 385 | 394 | $height = $line["height"]; |
| 386 | 395 | |
| 387 | - if (!$ctype) $ctype = __("unknown type"); |
|
| 396 | + if (!$ctype) { |
|
| 397 | + $ctype = __("unknown type"); |
|
| 398 | + } |
|
| 388 | 399 | |
| 389 | 400 | //$filename = substr($url, strrpos($url, "/")+1); |
| 390 | 401 | $filename = basename($url); |
| 391 | 402 | |
| 392 | 403 | $player = format_inline_player($url, $ctype); |
| 393 | 404 | |
| 394 | - if ($player) array_push($entries_inline, $player); |
|
| 405 | + if ($player) { |
|
| 406 | + array_push($entries_inline, $player); |
|
| 407 | + } |
|
| 395 | 408 | |
| 396 | 409 | # $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" . |
| 397 | 410 | # $filename . " (" . $ctype . ")" . "</a>"; |
@@ -419,8 +432,9 @@ discard block |
||
| 419 | 432 | |
| 420 | 433 | foreach ($entries as $entry) { |
| 421 | 434 | |
| 422 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) |
|
| 423 | - $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
| 435 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ENCLOSURE) as $plugin) { |
|
| 436 | + $retval = $plugin->hook_render_enclosure($entry, $hide_images); |
|
| 437 | + } |
|
| 424 | 438 | |
| 425 | 439 | |
| 426 | 440 | if ($retval) { |
@@ -431,10 +445,12 @@ discard block |
||
| 431 | 445 | |
| 432 | 446 | if (!$hide_images) { |
| 433 | 447 | $encsize = ''; |
| 434 | - if ($entry['height'] > 0) |
|
| 435 | - $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
| 436 | - if ($entry['width'] > 0) |
|
| 437 | - $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
| 448 | + if ($entry['height'] > 0) { |
|
| 449 | + $encsize .= ' height="' . intval($entry['height']) . '"'; |
|
| 450 | + } |
|
| 451 | + if ($entry['width'] > 0) { |
|
| 452 | + $encsize .= ' width="' . intval($entry['width']) . '"'; |
|
| 453 | + } |
|
| 438 | 454 | $rv .= "<p><img |
| 439 | 455 | alt=\"".htmlspecialchars($entry["filename"])."\" |
| 440 | 456 | src=\"" .htmlspecialchars($entry["url"]) . "\" |
@@ -466,15 +482,17 @@ discard block |
||
| 466 | 482 | $rv .= "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; |
| 467 | 483 | |
| 468 | 484 | foreach ($entries as $entry) { |
| 469 | - if ($entry["title"]) |
|
| 470 | - $title = " — " . truncate_string($entry["title"], 30); |
|
| 471 | - else |
|
| 472 | - $title = ""; |
|
| 485 | + if ($entry["title"]) { |
|
| 486 | + $title = " — " . truncate_string($entry["title"], 30); |
|
| 487 | + } else { |
|
| 488 | + $title = ""; |
|
| 489 | + } |
|
| 473 | 490 | |
| 474 | - if ($entry["filename"]) |
|
| 475 | - $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
| 476 | - else |
|
| 477 | - $filename = ""; |
|
| 491 | + if ($entry["filename"]) { |
|
| 492 | + $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60); |
|
| 493 | + } else { |
|
| 494 | + $filename = ""; |
|
| 495 | + } |
|
| 478 | 496 | |
| 479 | 497 | $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' |
| 480 | 498 | dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; |
@@ -492,7 +510,9 @@ discard block |
||
| 492 | 510 | |
| 493 | 511 | $a_id = $id; |
| 494 | 512 | |
| 495 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 513 | + if (!$owner_uid) { |
|
| 514 | + $owner_uid = $_SESSION["uid"]; |
|
| 515 | + } |
|
| 496 | 516 | |
| 497 | 517 | $pdo = Db::pdo(); |
| 498 | 518 | |
@@ -510,7 +530,9 @@ discard block |
||
| 510 | 530 | WHERE ref_id = ? AND owner_uid = ?"); |
| 511 | 531 | $csth->execute([$id, $owner_uid]); |
| 512 | 532 | |
| 513 | - if ($row = $csth->fetch()) $tag_cache = $row["tag_cache"]; |
|
| 533 | + if ($row = $csth->fetch()) { |
|
| 534 | + $tag_cache = $row["tag_cache"]; |
|
| 535 | + } |
|
| 514 | 536 | } |
| 515 | 537 | |
| 516 | 538 | if ($tag_cache) { |
@@ -551,8 +573,9 @@ discard block |
||
| 551 | 573 | |
| 552 | 574 | $tags_str = mb_substr($tags_str, 0, mb_strlen($tags_str)-2); |
| 553 | 575 | |
| 554 | - if (count($tags) > $maxtags) |
|
| 555 | - $tags_str .= ", …"; |
|
| 576 | + if (count($tags) > $maxtags) { |
|
| 577 | + $tags_str .= ", …"; |
|
| 578 | + } |
|
| 556 | 579 | |
| 557 | 580 | return $tags_str; |
| 558 | 581 | } |
@@ -560,7 +583,9 @@ discard block |
||
| 560 | 583 | |
| 561 | 584 | public static function format_article_labels($labels) { |
| 562 | 585 | |
| 563 | - if (!is_array($labels)) return ''; |
|
| 586 | + if (!is_array($labels)) { |
|
| 587 | + return ''; |
|
| 588 | + } |
|
| 564 | 589 | |
| 565 | 590 | $labels_str = ""; |
| 566 | 591 | |
@@ -618,10 +643,11 @@ discard block |
||
| 618 | 643 | |
| 619 | 644 | // purge orphaned posts in main content table |
| 620 | 645 | |
| 621 | - if (DB_TYPE == "mysql") |
|
| 622 | - $limit_qpart = "LIMIT 5000"; |
|
| 623 | - else |
|
| 624 | - $limit_qpart = ""; |
|
| 646 | + if (DB_TYPE == "mysql") { |
|
| 647 | + $limit_qpart = "LIMIT 5000"; |
|
| 648 | + } else { |
|
| 649 | + $limit_qpart = ""; |
|
| 650 | + } |
|
| 625 | 651 | |
| 626 | 652 | $pdo = Db::pdo(); |
| 627 | 653 | $res = $pdo->query("DELETE FROM ttrss_entries WHERE |
@@ -635,7 +661,9 @@ discard block |
||
| 635 | 661 | |
| 636 | 662 | public static function catchupArticlesById($ids, $cmode, $owner_uid = false) { |
| 637 | 663 | |
| 638 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 664 | + if (!$owner_uid) { |
|
| 665 | + $owner_uid = $_SESSION["uid"]; |
|
| 666 | + } |
|
| 639 | 667 | |
| 640 | 668 | $pdo = Db::pdo(); |
| 641 | 669 | |
@@ -685,7 +713,9 @@ discard block |
||
| 685 | 713 | public static function get_article_labels($id, $owner_uid = false) { |
| 686 | 714 | $rv = array(); |
| 687 | 715 | |
| 688 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 716 | + if (!$owner_uid) { |
|
| 717 | + $owner_uid = $_SESSION["uid"]; |
|
| 718 | + } |
|
| 689 | 719 | |
| 690 | 720 | $pdo = Db::pdo(); |
| 691 | 721 | |
@@ -699,10 +729,11 @@ discard block |
||
| 699 | 729 | if ($label_cache) { |
| 700 | 730 | $tmp = json_decode($label_cache, true); |
| 701 | 731 | |
| 702 | - if (!$tmp || $tmp["no-labels"] == 1) |
|
| 703 | - return $rv; |
|
| 704 | - else |
|
| 705 | - return $tmp; |
|
| 732 | + if (!$tmp || $tmp["no-labels"] == 1) { |
|
| 733 | + return $rv; |
|
| 734 | + } else { |
|
| 735 | + return $tmp; |
|
| 736 | + } |
|
| 706 | 737 | } |
| 707 | 738 | } |
| 708 | 739 | |
@@ -721,10 +752,11 @@ discard block |
||
| 721 | 752 | array_push($rv, $rk); |
| 722 | 753 | } |
| 723 | 754 | |
| 724 | - if (count($rv) > 0) |
|
| 725 | - Labels::update_cache($owner_uid, $id, $rv); |
|
| 726 | - else |
|
| 727 | - Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
| 755 | + if (count($rv) > 0) { |
|
| 756 | + Labels::update_cache($owner_uid, $id, $rv); |
|
| 757 | + } else { |
|
| 758 | + Labels::update_cache($owner_uid, $id, array("no-labels" => 1)); |
|
| 759 | + } |
|
| 728 | 760 | |
| 729 | 761 | return $rv; |
| 730 | 762 | } |
@@ -772,28 +804,33 @@ discard block |
||
| 772 | 804 | } |
| 773 | 805 | } |
| 774 | 806 | |
| 775 | - if (!$article_image) |
|
| 776 | - foreach ($enclosures as $enc) { |
|
| 807 | + if (!$article_image) { |
|
| 808 | + foreach ($enclosures as $enc) { |
|
| 777 | 809 | if (strpos($enc["content_type"], "image/") !== FALSE) { |
| 778 | 810 | $article_image = $enc["content_url"]; |
| 811 | + } |
|
| 779 | 812 | break; |
| 780 | 813 | } |
| 781 | 814 | } |
| 782 | 815 | |
| 783 | - if ($article_image) |
|
| 784 | - $article_image = rewrite_relative_url($site_url, $article_image); |
|
| 816 | + if ($article_image) { |
|
| 817 | + $article_image = rewrite_relative_url($site_url, $article_image); |
|
| 818 | + } |
|
| 785 | 819 | |
| 786 | - if ($article_stream) |
|
| 787 | - $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
| 820 | + if ($article_stream) { |
|
| 821 | + $article_stream = rewrite_relative_url($site_url, $article_stream); |
|
| 822 | + } |
|
| 788 | 823 | } |
| 789 | 824 | |
| 790 | 825 | $cache = new DiskCache("images"); |
| 791 | 826 | |
| 792 | - if ($article_image && $cache->exists(sha1($article_image))) |
|
| 793 | - $article_image = $cache->getUrl(sha1($article_image)); |
|
| 827 | + if ($article_image && $cache->exists(sha1($article_image))) { |
|
| 828 | + $article_image = $cache->getUrl(sha1($article_image)); |
|
| 829 | + } |
|
| 794 | 830 | |
| 795 | - if ($article_stream && $cache->exists(sha1($article_stream))) |
|
| 796 | - $article_stream = $cache->getUrl(sha1($article_stream)); |
|
| 831 | + if ($article_stream && $cache->exists(sha1($article_stream))) { |
|
| 832 | + $article_stream = $cache->getUrl(sha1($article_stream)); |
|
| 833 | + } |
|
| 797 | 834 | |
| 798 | 835 | return [$article_image, $article_stream]; |
| 799 | 836 | } |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | const NEVER_GROUP_FEEDS = [ -6, 0 ]; |
| 6 | 6 | const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ]; |
| 7 | 7 | |
| 8 | - private $params; |
|
| 8 | + private $params; |
|
| 9 | 9 | |
| 10 | - function csrf_ignore($method) { |
|
| 10 | + function csrf_ignore($method) { |
|
| 11 | 11 | $csrf_ignored = array("index", "quickaddfeed", "search"); |
| 12 | 12 | |
| 13 | 13 | return array_search($method, $csrf_ignored) !== false; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | //$reply .= "<option value=\"catchupPage()\">".__('Mark as read')."</option>"; |
| 102 | 102 | |
| 103 | 103 | $reply .= "<option value=\"App.displayDlg('".__("Show as feed")."','generatedFeed', '$feed_id:$is_cat:$rss_link')\">". |
| 104 | - __('Show as feed')."</option>"; |
|
| 104 | + __('Show as feed')."</option>"; |
|
| 105 | 105 | |
| 106 | 106 | $reply .= "</select>"; |
| 107 | 107 | |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | $method_split = explode(":", $method); |
| 134 | 134 | |
| 135 | 135 | if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) { |
| 136 | - $sth = $this->pdo->prepare("UPDATE ttrss_feeds |
|
| 136 | + $sth = $this->pdo->prepare("UPDATE ttrss_feeds |
|
| 137 | 137 | SET last_updated = '1970-01-01', last_update_started = '1970-01-01' |
| 138 | 138 | WHERE id = ?"); |
| 139 | - $sth->execute([$feed]); |
|
| 139 | + $sth->execute([$feed]); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | if ($method_split[0] == "MarkAllReadGR") { |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | "include_children" => $include_children, |
| 198 | 198 | "check_first_id" => $check_first_id, |
| 199 | 199 | "skip_first_id_check" => $skip_first_id_check, |
| 200 | - "order_by" => $order_by |
|
| 200 | + "order_by" => $order_by |
|
| 201 | 201 | ); |
| 202 | 202 | |
| 203 | 203 | $qfh_ret = $this->queryFeedHeadlines($params); |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | $headlines_count = 0; |
| 237 | 237 | |
| 238 | - if (is_object($result)) { |
|
| 238 | + if (is_object($result)) { |
|
| 239 | 239 | while ($line = $result->fetch(PDO::FETCH_ASSOC)) { |
| 240 | 240 | |
| 241 | 241 | ++$headlines_count; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
| 249 | 249 | $line = $p->hook_query_headlines($line, 250, false); |
| 250 | 250 | } |
| 251 | - } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | $id = $line["id"]; |
| 254 | 254 | |
@@ -295,53 +295,53 @@ discard block |
||
| 295 | 295 | |
| 296 | 296 | if (!$line["feed_title"]) $line["feed_title"] = ""; |
| 297 | 297 | |
| 298 | - $line["buttons_left"] = ""; |
|
| 299 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
|
| 300 | - $line["buttons_left"] .= $p->hook_article_left_button($line); |
|
| 301 | - } |
|
| 298 | + $line["buttons_left"] = ""; |
|
| 299 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
|
| 300 | + $line["buttons_left"] .= $p->hook_article_left_button($line); |
|
| 301 | + } |
|
| 302 | 302 | |
| 303 | - $line["buttons"] = ""; |
|
| 304 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { |
|
| 305 | - $line["buttons"] .= $p->hook_article_button($line); |
|
| 306 | - } |
|
| 303 | + $line["buttons"] = ""; |
|
| 304 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_BUTTON) as $p) { |
|
| 305 | + $line["buttons"] .= $p->hook_article_button($line); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - $line["content"] = sanitize($line["content"], |
|
| 309 | - $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); |
|
| 308 | + $line["content"] = sanitize($line["content"], |
|
| 309 | + $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); |
|
| 310 | 310 | |
| 311 | - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { |
|
| 312 | - $line = $p->hook_render_article_cdm($line); |
|
| 313 | - } |
|
| 311 | + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { |
|
| 312 | + $line = $p->hook_render_article_cdm($line); |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $line['content'] = DiskCache::rewriteUrls($line['content']); |
|
| 315 | + $line['content'] = DiskCache::rewriteUrls($line['content']); |
|
| 316 | 316 | |
| 317 | - if ($line['note']) |
|
| 318 | - $line['note'] = Article::format_article_note($id, $line['note']); |
|
| 319 | - else |
|
| 320 | - $line['note'] = ""; |
|
| 317 | + if ($line['note']) |
|
| 318 | + $line['note'] = Article::format_article_note($id, $line['note']); |
|
| 319 | + else |
|
| 320 | + $line['note'] = ""; |
|
| 321 | 321 | |
| 322 | - if (!get_pref("CDM_EXPANDED")) { |
|
| 323 | - $line["cdm_excerpt"] = "<span class='collapse'> |
|
| 322 | + if (!get_pref("CDM_EXPANDED")) { |
|
| 323 | + $line["cdm_excerpt"] = "<span class='collapse'> |
|
| 324 | 324 | <i class='material-icons' onclick='return Article.cdmUnsetActive(event)' |
| 325 | 325 | title=\"" . __("Collapse article") . "\">remove_circle</i></span>"; |
| 326 | 326 | |
| 327 | - if (get_pref('SHOW_CONTENT_PREVIEW')) { |
|
| 328 | - $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; |
|
| 329 | - } |
|
| 330 | - } |
|
| 327 | + if (get_pref('SHOW_CONTENT_PREVIEW')) { |
|
| 328 | + $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | 331 | |
| 332 | - $line["enclosures"] = Article::format_article_enclosures($id, $line["always_display_enclosures"], |
|
| 333 | - $line["content"], $line["hide_images"]); |
|
| 332 | + $line["enclosures"] = Article::format_article_enclosures($id, $line["always_display_enclosures"], |
|
| 333 | + $line["content"], $line["hide_images"]); |
|
| 334 | 334 | |
| 335 | - if ($line["orig_feed_id"]) { |
|
| 335 | + if ($line["orig_feed_id"]) { |
|
| 336 | 336 | |
| 337 | - $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds |
|
| 337 | + $ofgh = $this->pdo->prepare("SELECT * FROM ttrss_archived_feeds |
|
| 338 | 338 | WHERE id = ? AND owner_uid = ?"); |
| 339 | - $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); |
|
| 339 | + $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); |
|
| 340 | 340 | |
| 341 | - if ($tmp_line = $ofgh->fetch()) { |
|
| 342 | - $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; |
|
| 343 | - } |
|
| 344 | - } |
|
| 341 | + if ($tmp_line = $ofgh->fetch()) { |
|
| 342 | + $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; |
|
| 343 | + } |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | 346 | $line["updated_long"] = make_local_datetime($line["updated"],true); |
| 347 | 347 | $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | $line['feed_icon'] = "<i class='icon-no-feed material-icons'>rss_feed</i>"; |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - //setting feed headline background color, needs to change text color based on dark/light |
|
| 366 | + //setting feed headline background color, needs to change text color based on dark/light |
|
| 367 | 367 | $fav_color = $line['favicon_avg_color']; |
| 368 | 368 | |
| 369 | 369 | require_once "colors.php"; |
@@ -377,18 +377,18 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | if (isset($rgba_cache[$feed_id])) { |
| 380 | - $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
| 381 | - } |
|
| 380 | + $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | 383 | /* we don't need those */ |
| 384 | 384 | |
| 385 | - foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
|
| 386 | - "uuid", "label_cache", "yyiw"] as $k) |
|
| 387 | - unset($line[$k]); |
|
| 385 | + foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
|
| 386 | + "uuid", "label_cache", "yyiw"] as $k) |
|
| 387 | + unset($line[$k]); |
|
| 388 | 388 | |
| 389 | 389 | array_push($reply['content'], $line); |
| 390 | 390 | } |
| 391 | - } |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | 393 | if (!$headlines_count) { |
| 394 | 394 | |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | $reply['headlines']['is_cat'] = (bool) $cat_view; |
| 571 | 571 | |
| 572 | 572 | $reply['headlines-info'] = ["count" => (int) $headlines_count, |
| 573 | - "disable_cache" => (bool) $disable_cache]; |
|
| 573 | + "disable_cache" => (bool) $disable_cache]; |
|
| 574 | 574 | |
| 575 | 575 | // this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc |
| 576 | 576 | $reply['runtime-info'] = make_runtime_info(); |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | $reply_json = json_encode($reply); |
| 579 | 579 | |
| 580 | 580 | if (!$reply_json) { |
| 581 | - $reply_json = json_encode(["error" => ["code" => 15, |
|
| 582 | - "message" => json_last_error_msg()]]); |
|
| 583 | - } |
|
| 581 | + $reply_json = json_encode(["error" => ["code" => 15, |
|
| 582 | + "message" => json_last_error_msg()]]); |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | 585 | print $reply_json; |
| 586 | 586 | |
@@ -780,9 +780,9 @@ discard block |
||
| 780 | 780 | $sth->execute([$feed_id, $_SESSION['uid']]); |
| 781 | 781 | |
| 782 | 782 | if (!$sth->fetch()) { |
| 783 | - print "Access denied."; |
|
| 784 | - return; |
|
| 785 | - } |
|
| 783 | + print "Access denied."; |
|
| 784 | + return; |
|
| 785 | + } |
|
| 786 | 786 | |
| 787 | 787 | $refetch_checked = isset($_REQUEST["force_refetch"]) ? "checked" : ""; |
| 788 | 788 | $rehash_checked = isset($_REQUEST["force_rehash"]) ? "checked" : ""; |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | } else { |
| 1231 | 1231 | $icon = self::getIconFile($id); |
| 1232 | 1232 | |
| 1233 | - if ($icon && file_exists($icon)) { |
|
| 1233 | + if ($icon && file_exists($icon)) { |
|
| 1234 | 1234 | return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
| 1235 | 1235 | } |
| 1236 | 1236 | } |
@@ -1240,7 +1240,7 @@ discard block |
||
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | 1242 | public static function getFeedTitle($id, $cat = false) { |
| 1243 | - $pdo = Db::pdo(); |
|
| 1243 | + $pdo = Db::pdo(); |
|
| 1244 | 1244 | |
| 1245 | 1245 | if ($cat) { |
| 1246 | 1246 | return Feeds::getCategoryTitle($id); |
@@ -1271,10 +1271,10 @@ discard block |
||
| 1271 | 1271 | |
| 1272 | 1272 | } else if (is_numeric($id) && $id > 0) { |
| 1273 | 1273 | |
| 1274 | - $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?"); |
|
| 1275 | - $sth->execute([$id]); |
|
| 1274 | + $sth = $pdo->prepare("SELECT title FROM ttrss_feeds WHERE id = ?"); |
|
| 1275 | + $sth->execute([$id]); |
|
| 1276 | 1276 | |
| 1277 | - if ($row = $sth->fetch()) { |
|
| 1277 | + if ($row = $sth->fetch()) { |
|
| 1278 | 1278 | return $row["title"]; |
| 1279 | 1279 | } else { |
| 1280 | 1280 | return "Unknown feed ($id)"; |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | |
| 1294 | 1294 | if ($cat >= 0) { |
| 1295 | 1295 | |
| 1296 | - if (!$cat) $cat = null; |
|
| 1296 | + if (!$cat) $cat = null; |
|
| 1297 | 1297 | |
| 1298 | 1298 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
| 1299 | 1299 | WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) |
@@ -1333,7 +1333,7 @@ discard block |
||
| 1333 | 1333 | WHERE article_id = ref_id AND unread = true |
| 1334 | 1334 | AND ttrss_user_entries.owner_uid = ?"); |
| 1335 | 1335 | $sth->execute([$owner_uid]); |
| 1336 | - $row = $sth->fetch(); |
|
| 1336 | + $row = $sth->fetch(); |
|
| 1337 | 1337 | |
| 1338 | 1338 | return $row["unread"]; |
| 1339 | 1339 | } |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | return __("Labels"); |
| 1382 | 1382 | } else { |
| 1383 | 1383 | |
| 1384 | - $pdo = Db::pdo(); |
|
| 1384 | + $pdo = Db::pdo(); |
|
| 1385 | 1385 | |
| 1386 | 1386 | $sth = $pdo->prepare("SELECT title FROM ttrss_feed_categories WHERE |
| 1387 | 1387 | id = ?"); |
@@ -1417,7 +1417,7 @@ discard block |
||
| 1417 | 1417 | $pdo = Db::pdo(); |
| 1418 | 1418 | |
| 1419 | 1419 | // WARNING: due to highly dynamic nature of this query its going to quote parameters |
| 1420 | - // right before adding them to SQL part |
|
| 1420 | + // right before adding them to SQL part |
|
| 1421 | 1421 | |
| 1422 | 1422 | $feed = $params["feed"]; |
| 1423 | 1423 | $limit = isset($params["limit"]) ? $params["limit"] : 30; |
@@ -1661,7 +1661,7 @@ discard block |
||
| 1661 | 1661 | $ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated |
| 1662 | 1662 | FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); |
| 1663 | 1663 | $ssth->execute([$feed, $owner_uid]); |
| 1664 | - $row = $ssth->fetch(); |
|
| 1664 | + $row = $ssth->fetch(); |
|
| 1665 | 1665 | |
| 1666 | 1666 | $feed_title = $row["title"]; |
| 1667 | 1667 | $feed_site_url = $row["site_url"]; |
@@ -1899,9 +1899,9 @@ discard block |
||
| 1899 | 1899 | public static function getFeedCategory($feed) { |
| 1900 | 1900 | $pdo = Db::pdo(); |
| 1901 | 1901 | |
| 1902 | - $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds |
|
| 1902 | + $sth = $pdo->prepare("SELECT cat_id FROM ttrss_feeds |
|
| 1903 | 1903 | WHERE id = ?"); |
| 1904 | - $sth->execute([$feed]); |
|
| 1904 | + $sth->execute([$feed]); |
|
| 1905 | 1905 | |
| 1906 | 1906 | if ($row = $sth->fetch()) { |
| 1907 | 1907 | return $row["cat_id"]; |
@@ -1911,20 +1911,20 @@ discard block |
||
| 1911 | 1911 | |
| 1912 | 1912 | } |
| 1913 | 1913 | |
| 1914 | - function color_of($name) { |
|
| 1915 | - $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
|
| 1916 | - "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", |
|
| 1917 | - "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; |
|
| 1914 | + function color_of($name) { |
|
| 1915 | + $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
|
| 1916 | + "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", |
|
| 1917 | + "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; |
|
| 1918 | 1918 | |
| 1919 | - $sum = 0; |
|
| 1919 | + $sum = 0; |
|
| 1920 | 1920 | |
| 1921 | - for ($i = 0; $i < strlen($name); $i++) { |
|
| 1922 | - $sum += ord($name[$i]); |
|
| 1923 | - } |
|
| 1921 | + for ($i = 0; $i < strlen($name); $i++) { |
|
| 1922 | + $sum += ord($name[$i]); |
|
| 1923 | + } |
|
| 1924 | 1924 | |
| 1925 | - $sum %= count($colormap); |
|
| 1925 | + $sum %= count($colormap); |
|
| 1926 | 1926 | |
| 1927 | - return $colormap[$sum]; |
|
| 1927 | + return $colormap[$sum]; |
|
| 1928 | 1928 | } |
| 1929 | 1929 | |
| 1930 | 1930 | public static function get_feeds_from_html($url, $content) { |
@@ -398,21 +398,21 @@ discard block |
||
| 398 | 398 | $message = $query_error_override; |
| 399 | 399 | } else { |
| 400 | 400 | switch ($view_mode) { |
| 401 | - case "unread": |
|
| 402 | - $message = __("No unread articles found to display."); |
|
| 403 | - break; |
|
| 404 | - case "updated": |
|
| 405 | - $message = __("No updated articles found to display."); |
|
| 406 | - break; |
|
| 407 | - case "marked": |
|
| 408 | - $message = __("No starred articles found to display."); |
|
| 409 | - break; |
|
| 410 | - default: |
|
| 411 | - if ($feed < LABEL_BASE_INDEX) { |
|
| 412 | - $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter."); |
|
| 413 | - } else { |
|
| 414 | - $message = __("No articles found to display."); |
|
| 415 | - } |
|
| 401 | + case "unread": |
|
| 402 | + $message = __("No unread articles found to display."); |
|
| 403 | + break; |
|
| 404 | + case "updated": |
|
| 405 | + $message = __("No updated articles found to display."); |
|
| 406 | + break; |
|
| 407 | + case "marked": |
|
| 408 | + $message = __("No starred articles found to display."); |
|
| 409 | + break; |
|
| 410 | + default: |
|
| 411 | + if ($feed < LABEL_BASE_INDEX) { |
|
| 412 | + $message = __("No articles found to display. You can assign articles to labels manually from article header context menu (applies to all selected articles) or use a filter."); |
|
| 413 | + } else { |
|
| 414 | + $message = __("No articles found to display."); |
|
| 415 | + } |
|
| 416 | 416 | } |
| 417 | 417 | } |
| 418 | 418 | |
@@ -874,29 +874,29 @@ discard block |
||
| 874 | 874 | // TODO: all this interval stuff needs some generic generator function |
| 875 | 875 | |
| 876 | 876 | switch ($mode) { |
| 877 | - case "1day": |
|
| 878 | - if (DB_TYPE == "pgsql") { |
|
| 879 | - $date_qpart = "date_entered < NOW() - INTERVAL '1 day' "; |
|
| 880 | - } else { |
|
| 881 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
| 882 | - } |
|
| 883 | - break; |
|
| 884 | - case "1week": |
|
| 885 | - if (DB_TYPE == "pgsql") { |
|
| 886 | - $date_qpart = "date_entered < NOW() - INTERVAL '1 week' "; |
|
| 887 | - } else { |
|
| 888 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) "; |
|
| 889 | - } |
|
| 890 | - break; |
|
| 891 | - case "2week": |
|
| 892 | - if (DB_TYPE == "pgsql") { |
|
| 893 | - $date_qpart = "date_entered < NOW() - INTERVAL '2 week' "; |
|
| 894 | - } else { |
|
| 895 | - $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) "; |
|
| 896 | - } |
|
| 897 | - break; |
|
| 898 | - default: |
|
| 899 | - $date_qpart = "true"; |
|
| 877 | + case "1day": |
|
| 878 | + if (DB_TYPE == "pgsql") { |
|
| 879 | + $date_qpart = "date_entered < NOW() - INTERVAL '1 day' "; |
|
| 880 | + } else { |
|
| 881 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 DAY) "; |
|
| 882 | + } |
|
| 883 | + break; |
|
| 884 | + case "1week": |
|
| 885 | + if (DB_TYPE == "pgsql") { |
|
| 886 | + $date_qpart = "date_entered < NOW() - INTERVAL '1 week' "; |
|
| 887 | + } else { |
|
| 888 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 1 WEEK) "; |
|
| 889 | + } |
|
| 890 | + break; |
|
| 891 | + case "2week": |
|
| 892 | + if (DB_TYPE == "pgsql") { |
|
| 893 | + $date_qpart = "date_entered < NOW() - INTERVAL '2 week' "; |
|
| 894 | + } else { |
|
| 895 | + $date_qpart = "date_entered < DATE_SUB(NOW(), INTERVAL 2 WEEK) "; |
|
| 896 | + } |
|
| 897 | + break; |
|
| 898 | + default: |
|
| 899 | + $date_qpart = "true"; |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | if (is_numeric($feed)) { |
@@ -1212,28 +1212,28 @@ discard block |
||
| 1212 | 1212 | |
| 1213 | 1213 | public static function getFeedIcon($id) { |
| 1214 | 1214 | switch ($id) { |
| 1215 | - case 0: |
|
| 1216 | - return "archive"; |
|
| 1217 | - case -1: |
|
| 1218 | - return "star"; |
|
| 1219 | - case -2: |
|
| 1220 | - return "rss_feed"; |
|
| 1221 | - case -3: |
|
| 1222 | - return "whatshot"; |
|
| 1223 | - case -4: |
|
| 1224 | - return "inbox"; |
|
| 1225 | - case -6: |
|
| 1226 | - return "restore"; |
|
| 1227 | - default: |
|
| 1228 | - if ($id < LABEL_BASE_INDEX) { |
|
| 1229 | - return "label"; |
|
| 1230 | - } else { |
|
| 1231 | - $icon = self::getIconFile($id); |
|
| 1215 | + case 0: |
|
| 1216 | + return "archive"; |
|
| 1217 | + case -1: |
|
| 1218 | + return "star"; |
|
| 1219 | + case -2: |
|
| 1220 | + return "rss_feed"; |
|
| 1221 | + case -3: |
|
| 1222 | + return "whatshot"; |
|
| 1223 | + case -4: |
|
| 1224 | + return "inbox"; |
|
| 1225 | + case -6: |
|
| 1226 | + return "restore"; |
|
| 1227 | + default: |
|
| 1228 | + if ($id < LABEL_BASE_INDEX) { |
|
| 1229 | + return "label"; |
|
| 1230 | + } else { |
|
| 1231 | + $icon = self::getIconFile($id); |
|
| 1232 | 1232 | |
| 1233 | 1233 | if ($icon && file_exists($icon)) { |
| 1234 | - return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
| 1235 | - } |
|
| 1234 | + return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
| 1236 | 1235 | } |
| 1236 | + } |
|
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | return false; |
@@ -2201,102 +2201,102 @@ discard block |
||
| 2201 | 2201 | $commandpair = explode(":", mb_strtolower($k), 2); |
| 2202 | 2202 | |
| 2203 | 2203 | switch ($commandpair[0]) { |
| 2204 | - case "title": |
|
| 2205 | - if ($commandpair[1]) { |
|
| 2206 | - array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
|
| 2207 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
| 2208 | - } else { |
|
| 2209 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
| 2204 | + case "title": |
|
| 2205 | + if ($commandpair[1]) { |
|
| 2206 | + array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
|
| 2207 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
| 2208 | + } else { |
|
| 2209 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
| 2210 | 2210 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2211 | - array_push($search_words, $k); |
|
| 2212 | - } |
|
| 2213 | - break; |
|
| 2214 | - case "author": |
|
| 2215 | - if ($commandpair[1]) { |
|
| 2216 | - array_push($query_keywords, "($not (LOWER(author) LIKE ". |
|
| 2217 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2218 | - } else { |
|
| 2219 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
| 2211 | + array_push($search_words, $k); |
|
| 2212 | + } |
|
| 2213 | + break; |
|
| 2214 | + case "author": |
|
| 2215 | + if ($commandpair[1]) { |
|
| 2216 | + array_push($query_keywords, "($not (LOWER(author) LIKE ". |
|
| 2217 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2218 | + } else { |
|
| 2219 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
| 2220 | 2220 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2221 | - array_push($search_words, $k); |
|
| 2222 | - } |
|
| 2223 | - break; |
|
| 2224 | - case "note": |
|
| 2225 | - if ($commandpair[1]) { |
|
| 2226 | - if ($commandpair[1] == "true") |
|
| 2227 | - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
| 2228 | - else if ($commandpair[1] == "false") |
|
| 2229 | - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
| 2230 | - else |
|
| 2231 | - array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
| 2232 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2233 | - } else { |
|
| 2234 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2221 | + array_push($search_words, $k); |
|
| 2222 | + } |
|
| 2223 | + break; |
|
| 2224 | + case "note": |
|
| 2225 | + if ($commandpair[1]) { |
|
| 2226 | + if ($commandpair[1] == "true") |
|
| 2227 | + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
| 2228 | + else if ($commandpair[1] == "false") |
|
| 2229 | + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
| 2230 | + else |
|
| 2231 | + array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
| 2232 | + $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2233 | + } else { |
|
| 2234 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2235 | 2235 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2236 | - if (!$not) array_push($search_words, $k); |
|
| 2237 | - } |
|
| 2238 | - break; |
|
| 2239 | - case "star": |
|
| 2236 | + if (!$not) array_push($search_words, $k); |
|
| 2237 | + } |
|
| 2238 | + break; |
|
| 2239 | + case "star": |
|
| 2240 | 2240 | |
| 2241 | - if ($commandpair[1]) { |
|
| 2242 | - if ($commandpair[1] == "true") |
|
| 2243 | - array_push($query_keywords, "($not (marked = true))"); |
|
| 2244 | - else |
|
| 2245 | - array_push($query_keywords, "($not (marked = false))"); |
|
| 2246 | - } else { |
|
| 2247 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2241 | + if ($commandpair[1]) { |
|
| 2242 | + if ($commandpair[1] == "true") |
|
| 2243 | + array_push($query_keywords, "($not (marked = true))"); |
|
| 2244 | + else |
|
| 2245 | + array_push($query_keywords, "($not (marked = false))"); |
|
| 2246 | + } else { |
|
| 2247 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2248 | 2248 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2249 | - if (!$not) array_push($search_words, $k); |
|
| 2250 | - } |
|
| 2251 | - break; |
|
| 2252 | - case "pub": |
|
| 2253 | - if ($commandpair[1]) { |
|
| 2254 | - if ($commandpair[1] == "true") |
|
| 2255 | - array_push($query_keywords, "($not (published = true))"); |
|
| 2256 | - else |
|
| 2257 | - array_push($query_keywords, "($not (published = false))"); |
|
| 2249 | + if (!$not) array_push($search_words, $k); |
|
| 2250 | + } |
|
| 2251 | + break; |
|
| 2252 | + case "pub": |
|
| 2253 | + if ($commandpair[1]) { |
|
| 2254 | + if ($commandpair[1] == "true") |
|
| 2255 | + array_push($query_keywords, "($not (published = true))"); |
|
| 2256 | + else |
|
| 2257 | + array_push($query_keywords, "($not (published = false))"); |
|
| 2258 | 2258 | |
| 2259 | - } else { |
|
| 2260 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
| 2259 | + } else { |
|
| 2260 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
|
| 2261 | 2261 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2262 | - if (!$not) array_push($search_words, $k); |
|
| 2263 | - } |
|
| 2264 | - break; |
|
| 2265 | - case "unread": |
|
| 2266 | - if ($commandpair[1]) { |
|
| 2267 | - if ($commandpair[1] == "true") |
|
| 2268 | - array_push($query_keywords, "($not (unread = true))"); |
|
| 2269 | - else |
|
| 2270 | - array_push($query_keywords, "($not (unread = false))"); |
|
| 2262 | + if (!$not) array_push($search_words, $k); |
|
| 2263 | + } |
|
| 2264 | + break; |
|
| 2265 | + case "unread": |
|
| 2266 | + if ($commandpair[1]) { |
|
| 2267 | + if ($commandpair[1] == "true") |
|
| 2268 | + array_push($query_keywords, "($not (unread = true))"); |
|
| 2269 | + else |
|
| 2270 | + array_push($query_keywords, "($not (unread = false))"); |
|
| 2271 | 2271 | |
| 2272 | - } else { |
|
| 2273 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2272 | + } else { |
|
| 2273 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2274 | 2274 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2275 | - if (!$not) array_push($search_words, $k); |
|
| 2276 | - } |
|
| 2277 | - break; |
|
| 2278 | - default: |
|
| 2279 | - if (strpos($k, "@") === 0) { |
|
| 2275 | + if (!$not) array_push($search_words, $k); |
|
| 2276 | + } |
|
| 2277 | + break; |
|
| 2278 | + default: |
|
| 2279 | + if (strpos($k, "@") === 0) { |
|
| 2280 | 2280 | |
| 2281 | - $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); |
|
| 2282 | - $orig_ts = strtotime(substr($k, 1)); |
|
| 2283 | - $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); |
|
| 2281 | + $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); |
|
| 2282 | + $orig_ts = strtotime(substr($k, 1)); |
|
| 2283 | + $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); |
|
| 2284 | 2284 | |
| 2285 | - //$k = date("Y-m-d", strtotime(substr($k, 1))); |
|
| 2285 | + //$k = date("Y-m-d", strtotime(substr($k, 1))); |
|
| 2286 | 2286 | |
| 2287 | - array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); |
|
| 2288 | - } else { |
|
| 2287 | + array_push($query_keywords, "(".SUBSTRING_FOR_DATE."(updated,1,LENGTH('$k')) $not = '$k')"); |
|
| 2288 | + } else { |
|
| 2289 | 2289 | |
| 2290 | - if (DB_TYPE == "pgsql") { |
|
| 2291 | - $k = mb_strtolower($k); |
|
| 2292 | - array_push($search_query_leftover, $not ? "!$k" : $k); |
|
| 2293 | - } else { |
|
| 2294 | - array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2290 | + if (DB_TYPE == "pgsql") { |
|
| 2291 | + $k = mb_strtolower($k); |
|
| 2292 | + array_push($search_query_leftover, $not ? "!$k" : $k); |
|
| 2293 | + } else { |
|
| 2294 | + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
|
| 2295 | 2295 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2296 | - } |
|
| 2297 | - |
|
| 2298 | - if (!$not) array_push($search_words, $k); |
|
| 2299 | 2296 | } |
| 2297 | + |
|
| 2298 | + if (!$not) array_push($search_words, $k); |
|
| 2299 | + } |
|
| 2300 | 2300 | } |
| 2301 | 2301 | } |
| 2302 | 2302 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | require_once "colors.php"; |
| 3 | 3 | |
| 4 | 4 | class Feeds extends Handler_Protected { |
| 5 | - const NEVER_GROUP_FEEDS = [ -6, 0 ]; |
|
| 6 | - const NEVER_GROUP_BY_DATE = [ -2, -1, -3 ]; |
|
| 5 | + const NEVER_GROUP_FEEDS = [ -6, 0]; |
|
| 6 | + const NEVER_GROUP_BY_DATE = [ -2, -1, -3]; |
|
| 7 | 7 | |
| 8 | 8 | private $params; |
| 9 | 9 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $reply = ""; |
| 29 | 29 | |
| 30 | - $rss_link = htmlspecialchars(get_self_url_prefix() . |
|
| 30 | + $rss_link = htmlspecialchars(get_self_url_prefix(). |
|
| 31 | 31 | "/public.php?op=rss&id=$feed_id$cat_q$search_q"); |
| 32 | 32 | |
| 33 | 33 | $reply .= "<span class='left'>"; |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | if ($error) |
| 52 | - $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
| 52 | + $reply .= " <i title=\"".htmlspecialchars($error)."\" class='material-icons icon-error'>error</i>"; |
|
| 53 | 53 | |
| 54 | 54 | $reply .= "</span>"; |
| 55 | 55 | $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $sth->execute([$feed]); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ($method_split[0] == "MarkAllReadGR") { |
|
| 142 | + if ($method_split[0] == "MarkAllReadGR") { |
|
| 143 | 143 | $this->catchup_feed($method_split[1], false); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | if (!get_pref('SHOW_CONTENT_PREVIEW')) { |
| 244 | 244 | $line["content_preview"] = ""; |
| 245 | 245 | } else { |
| 246 | - $line["content_preview"] = "— " . truncate_string(strip_tags($line["content"]), 250); |
|
| 246 | + $line["content_preview"] = "— ".truncate_string(strip_tags($line["content"]), 250); |
|
| 247 | 247 | |
| 248 | 248 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { |
| 249 | 249 | $line = $p->hook_query_headlines($line, 250, false); |
@@ -322,10 +322,10 @@ discard block |
||
| 322 | 322 | if (!get_pref("CDM_EXPANDED")) { |
| 323 | 323 | $line["cdm_excerpt"] = "<span class='collapse'> |
| 324 | 324 | <i class='material-icons' onclick='return Article.cdmUnsetActive(event)' |
| 325 | - title=\"" . __("Collapse article") . "\">remove_circle</i></span>"; |
|
| 325 | + title=\"" . __("Collapse article")."\">remove_circle</i></span>"; |
|
| 326 | 326 | |
| 327 | 327 | if (get_pref('SHOW_CONTENT_PREVIEW')) { |
| 328 | - $line["cdm_excerpt"] .= "<span class='excerpt'>" . $line["content_preview"] . "</span>"; |
|
| 328 | + $line["cdm_excerpt"] .= "<span class='excerpt'>".$line["content_preview"]."</span>"; |
|
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | $ofgh->execute([$line["orig_feed_id"], $_SESSION['uid']]); |
| 340 | 340 | |
| 341 | 341 | if ($tmp_line = $ofgh->fetch()) { |
| 342 | - $line["orig_feed"] = [ $tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"] ]; |
|
| 342 | + $line["orig_feed"] = [$tmp_line["title"], $tmp_line["site_url"], $tmp_line["feed_url"]]; |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | - $line["updated_long"] = make_local_datetime($line["updated"],true); |
|
| 346 | + $line["updated_long"] = make_local_datetime($line["updated"], true); |
|
| 347 | 347 | $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); |
| 348 | 348 | |
| 349 | 349 | |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | if (isset($rgba_cache[$feed_id])) { |
| 380 | - $line['feed_bg_color'] = 'rgba(' . implode(",", $rgba_cache[$feed_id]) . ',0.3)'; |
|
| 380 | + $line['feed_bg_color'] = 'rgba('.implode(",", $rgba_cache[$feed_id]).',0.3)'; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /* we don't need those */ |
@@ -421,7 +421,7 @@ discard block |
||
| 421 | 421 | |
| 422 | 422 | $reply['content'] .= "<p><span class=\"text-muted\">"; |
| 423 | 423 | |
| 424 | - $sth = $this->pdo->prepare("SELECT " . SUBSTRING_FOR_DATE . "(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
| 424 | + $sth = $this->pdo->prepare("SELECT ".SUBSTRING_FOR_DATE."(MAX(last_updated), 1, 19) AS last_updated FROM ttrss_feeds |
|
| 425 | 425 | WHERE owner_uid = ?"); |
| 426 | 426 | $sth->execute([$_SESSION['uid']]); |
| 427 | 427 | $row = $sth->fetch(); |
@@ -439,8 +439,8 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | if ($num_errors > 0) { |
| 441 | 441 | $reply['content'] .= "<br/>"; |
| 442 | - $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">" . |
|
| 443 | - __('Some feeds have update errors (click for details)') . "</a>"; |
|
| 442 | + $reply['content'] .= "<a class=\"text-muted\" href=\"#\" onclick=\"CommonDialogs.showFeedsWithErrors()\">". |
|
| 443 | + __('Some feeds have update errors (click for details)')."</a>"; |
|
| 444 | 444 | } |
| 445 | 445 | $reply['content'] .= "</span></p></div>"; |
| 446 | 446 | |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | $reply['headlines']['is_cat'] = false; |
| 636 | 636 | |
| 637 | 637 | $reply['headlines']['toolbar'] = ''; |
| 638 | - $reply['headlines']['content'] = "<div class='whiteBox'>". $error . "</div>"; |
|
| 638 | + $reply['headlines']['content'] = "<div class='whiteBox'>".$error."</div>"; |
|
| 639 | 639 | |
| 640 | 640 | $reply['headlines-info'] = array("count" => 0, |
| 641 | 641 | "unread" => 0, |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | print "<fieldset>"; |
| 670 | 670 | |
| 671 | 671 | if (get_pref('ENABLE_FEED_CATS')) { |
| 672 | - print "<label class='inline'>" . __('Place in category:') . "</label> "; |
|
| 672 | + print "<label class='inline'>".__('Place in category:')."</label> "; |
|
| 673 | 673 | print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"'); |
| 674 | 674 | } |
| 675 | 675 | |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | print "</section>"; |
| 679 | 679 | |
| 680 | 680 | print '<div id="feedDlg_feedsContainer" style="display : none"> |
| 681 | - <header>' . __('Available feeds') . '</header> |
|
| 681 | + <header>' . __('Available feeds').'</header> |
|
| 682 | 682 | <section> |
| 683 | 683 | <fieldset> |
| 684 | 684 | <select id="feedDlg_feedContainerSelect" |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | |
| 744 | 744 | if (DB_TYPE == "pgsql") { |
| 745 | 745 | print "<fieldset>"; |
| 746 | - print "<label class='inline'>" . __("Language:") . "</label>"; |
|
| 746 | + print "<label class='inline'>".__("Language:")."</label>"; |
|
| 747 | 747 | print_select("search_language", get_pref('DEFAULT_SEARCH_LANGUAGE'), Pref_Feeds::get_ts_languages(), |
| 748 | 748 | "dojoType='fox.form.Select' title=\"".__('Used for word stemming')."\""); |
| 749 | 749 | print "</fieldset>"; |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | Debug::set_enabled(true); |
| 773 | 773 | Debug::set_loglevel($_REQUEST["xdebug"]); |
| 774 | 774 | |
| 775 | - $feed_id = (int)$_REQUEST["feed_id"]; |
|
| 775 | + $feed_id = (int) $_REQUEST["feed_id"]; |
|
| 776 | 776 | @$do_update = $_REQUEST["action"] == "do_update"; |
| 777 | 777 | $csrf_token = $_REQUEST["csrf_token"]; |
| 778 | 778 | |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | </script> |
| 812 | 812 | |
| 813 | 813 | <div class="container"> |
| 814 | - <h1>Feed Debugger: <?php echo "$feed_id: " . $this->getFeedTitle($feed_id) ?></h1> |
|
| 814 | + <h1>Feed Debugger: <?php echo "$feed_id: ".$this->getFeedTitle($feed_id) ?></h1> |
|
| 815 | 815 | <div class="content"> |
| 816 | 816 | <form method="GET" action=""> |
| 817 | 817 | <input type="hidden" name="op" value="feeds"> |
@@ -1074,7 +1074,7 @@ discard block |
||
| 1074 | 1074 | } else if ($n_feed >= 0) { |
| 1075 | 1075 | |
| 1076 | 1076 | if ($n_feed != 0) { |
| 1077 | - $match_part = "feed_id = " . (int)$n_feed; |
|
| 1077 | + $match_part = "feed_id = ".(int) $n_feed; |
|
| 1078 | 1078 | } else { |
| 1079 | 1079 | $match_part = "feed_id IS NULL"; |
| 1080 | 1080 | } |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | (owner_uid,feed_url,title,cat_id, auth_login,auth_pass,update_method,auth_pass_encrypted) |
| 1185 | 1185 | VALUES (?, ?, ?, ?, ?, ?, 0, false)"); |
| 1186 | 1186 | |
| 1187 | - $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string)$auth_login, (string)$auth_pass]); |
|
| 1187 | + $sth->execute([$_SESSION['uid'], $url, "[Unknown]", $cat_id, (string) $auth_login, (string) $auth_pass]); |
|
| 1188 | 1188 | |
| 1189 | 1189 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE feed_url = ? |
| 1190 | 1190 | AND owner_uid = ?"); |
@@ -1203,11 +1203,11 @@ discard block |
||
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | public static function getIconFile($feed_id) { |
| 1206 | - return ICONS_DIR . "/$feed_id.ico"; |
|
| 1206 | + return ICONS_DIR."/$feed_id.ico"; |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | public static function feedHasIcon($id) { |
| 1210 | - return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0; |
|
| 1210 | + return is_file(ICONS_DIR."/$id.ico") && filesize(ICONS_DIR."/$id.ico") > 0; |
|
| 1211 | 1211 | } |
| 1212 | 1212 | |
| 1213 | 1213 | public static function getFeedIcon($id) { |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | $icon = self::getIconFile($id); |
| 1232 | 1232 | |
| 1233 | 1233 | if ($icon && file_exists($icon)) { |
| 1234 | - return ICONS_URL . "/" . basename($icon) . "?" . filemtime($icon); |
|
| 1234 | + return ICONS_URL."/".basename($icon)."?".filemtime($icon); |
|
| 1235 | 1235 | } |
| 1236 | 1236 | } |
| 1237 | 1237 | } |
@@ -1303,7 +1303,7 @@ discard block |
||
| 1303 | 1303 | |
| 1304 | 1304 | $cat_feeds = array(); |
| 1305 | 1305 | while ($line = $sth->fetch()) { |
| 1306 | - array_push($cat_feeds, "feed_id = " . (int)$line["id"]); |
|
| 1306 | + array_push($cat_feeds, "feed_id = ".(int) $line["id"]); |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | if (count($cat_feeds) == 0) return 0; |
@@ -1517,7 +1517,7 @@ discard block |
||
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | if ($limit > 0) { |
| 1520 | - $limit_query_part = "LIMIT " . (int)$limit; |
|
| 1520 | + $limit_query_part = "LIMIT ".(int) $limit; |
|
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | $allow_archived = false; |
@@ -1544,7 +1544,7 @@ discard block |
||
| 1544 | 1544 | implode(",", $subcats).")"; |
| 1545 | 1545 | |
| 1546 | 1546 | } else { |
| 1547 | - $query_strategy_part = "cat_id = " . $pdo->quote($feed); |
|
| 1547 | + $query_strategy_part = "cat_id = ".$pdo->quote($feed); |
|
| 1548 | 1548 | } |
| 1549 | 1549 | |
| 1550 | 1550 | } else { |
@@ -1554,7 +1554,7 @@ discard block |
||
| 1554 | 1554 | $vfeed_query_part = "ttrss_feeds.title AS feed_title,"; |
| 1555 | 1555 | |
| 1556 | 1556 | } else { |
| 1557 | - $query_strategy_part = "feed_id = " . $pdo->quote($feed); |
|
| 1557 | + $query_strategy_part = "feed_id = ".$pdo->quote($feed); |
|
| 1558 | 1558 | } |
| 1559 | 1559 | } else if ($feed == 0 && !$cat_view) { // archive virtual feed |
| 1560 | 1560 | $query_strategy_part = "feed_id IS NULL"; |
@@ -1676,7 +1676,7 @@ discard block |
||
| 1676 | 1676 | $content_query_part = "content, "; |
| 1677 | 1677 | |
| 1678 | 1678 | if ($limit_query_part) { |
| 1679 | - $offset_query_part = "OFFSET " . (int)$offset; |
|
| 1679 | + $offset_query_part = "OFFSET ".(int) $offset; |
|
| 1680 | 1680 | } else { |
| 1681 | 1681 | $offset_query_part = ""; |
| 1682 | 1682 | } |
@@ -1765,7 +1765,7 @@ discard block |
||
| 1765 | 1765 | $res = $pdo->query($query); |
| 1766 | 1766 | |
| 1767 | 1767 | if ($row = $res->fetch()) { |
| 1768 | - $first_id = (int)$row["id"]; |
|
| 1768 | + $first_id = (int) $row["id"]; |
|
| 1769 | 1769 | |
| 1770 | 1770 | if ($offset > 0 && $first_id && $check_first_id && $first_id != $check_first_id) { |
| 1771 | 1771 | return array(-1, $feed_title, $feed_site_url, $last_error, $last_updated, $search_words, $first_id, $vfeed_query_part != "", $query_error_override); |
@@ -1912,9 +1912,9 @@ discard block |
||
| 1912 | 1912 | } |
| 1913 | 1913 | |
| 1914 | 1914 | function color_of($name) { |
| 1915 | - $colormap = [ "#1cd7d7","#d91111","#1212d7","#8e16e5","#7b7b7b", |
|
| 1916 | - "#39f110","#0bbea6","#ec0e0e","#1534f2","#b9e416", |
|
| 1917 | - "#479af2","#f36b14","#10c7e9","#1e8fe7","#e22727" ]; |
|
| 1915 | + $colormap = ["#1cd7d7", "#d91111", "#1212d7", "#8e16e5", "#7b7b7b", |
|
| 1916 | + "#39f110", "#0bbea6", "#ec0e0e", "#1534f2", "#b9e416", |
|
| 1917 | + "#479af2", "#f36b14", "#10c7e9", "#1e8fe7", "#e22727"]; |
|
| 1918 | 1918 | |
| 1919 | 1919 | $sum = 0; |
| 1920 | 1920 | |
@@ -1978,13 +1978,13 @@ discard block |
||
| 1978 | 1978 | |
| 1979 | 1979 | // support schema-less urls |
| 1980 | 1980 | if (strpos($url, '//') === 0) { |
| 1981 | - $url = 'https:' . $url; |
|
| 1981 | + $url = 'https:'.$url; |
|
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | 1984 | if (strpos($url, '://') === false) { |
| 1985 | - $url = 'http://' . $url; |
|
| 1985 | + $url = 'http://'.$url; |
|
| 1986 | 1986 | } else if (substr($url, 0, 5) == 'feed:') { |
| 1987 | - $url = 'http:' . substr($url, 5); |
|
| 1987 | + $url = 'http:'.substr($url, 5); |
|
| 1988 | 1988 | } |
| 1989 | 1989 | |
| 1990 | 1990 | //prepend slash if the URL has no slash in it |
@@ -2034,7 +2034,7 @@ discard block |
||
| 2034 | 2034 | |
| 2035 | 2035 | $sth = $pdo->prepare("INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat,order_id) |
| 2036 | 2036 | VALUES (?, ?, ?, ?)"); |
| 2037 | - $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int)$order_id]); |
|
| 2037 | + $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int) $order_id]); |
|
| 2038 | 2038 | |
| 2039 | 2039 | if (!$tr_in_progress) $pdo->commit(); |
| 2040 | 2040 | |
@@ -2134,7 +2134,7 @@ discard block |
||
| 2134 | 2134 | $sth->execute([$feed_id]); |
| 2135 | 2135 | |
| 2136 | 2136 | } else { |
| 2137 | - $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
| 2137 | + $sth = $pdo->prepare("DELETE FROM ttrss_user_entries |
|
| 2138 | 2138 | USING ttrss_user_entries, ttrss_entries |
| 2139 | 2139 | WHERE ttrss_entries.id = ref_id AND |
| 2140 | 2140 | marked = false AND |
@@ -2204,7 +2204,7 @@ discard block |
||
| 2204 | 2204 | case "title": |
| 2205 | 2205 | if ($commandpair[1]) { |
| 2206 | 2206 | array_push($query_keywords, "($not (LOWER(ttrss_entries.title) LIKE ". |
| 2207 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%') ."))"); |
|
| 2207 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
| 2208 | 2208 | } else { |
| 2209 | 2209 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
| 2210 | 2210 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2214,7 +2214,7 @@ discard block |
||
| 2214 | 2214 | case "author": |
| 2215 | 2215 | if ($commandpair[1]) { |
| 2216 | 2216 | array_push($query_keywords, "($not (LOWER(author) LIKE ". |
| 2217 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2217 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
| 2218 | 2218 | } else { |
| 2219 | 2219 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
| 2220 | 2220 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2229,7 +2229,7 @@ discard block |
||
| 2229 | 2229 | array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
| 2230 | 2230 | else |
| 2231 | 2231 | array_push($query_keywords, "($not (LOWER(note) LIKE ". |
| 2232 | - $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
|
| 2232 | + $pdo->quote('%'.mb_strtolower($commandpair[1]).'%')."))"); |
|
| 2233 | 2233 | } else { |
| 2234 | 2234 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2235 | 2235 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
@@ -2306,7 +2306,7 @@ discard block |
||
| 2306 | 2306 | |
| 2307 | 2307 | // if there's no joiners consider this a "simple" search and |
| 2308 | 2308 | // concatenate everything with &, otherwise don't try to mess with tsquery syntax |
| 2309 | - if (preg_match("/[&|]/", implode(" " , $search_query_leftover))) { |
|
| 2309 | + if (preg_match("/[&|]/", implode(" ", $search_query_leftover))) { |
|
| 2310 | 2310 | $tsquery = $pdo->quote(implode(" ", $search_query_leftover)); |
| 2311 | 2311 | } else { |
| 2312 | 2312 | $tsquery = $pdo->quote(implode(" & ", $search_query_leftover)); |
@@ -17,7 +17,9 @@ discard block |
||
| 17 | 17 | $feed_id, $is_cat, $search, |
| 18 | 18 | $error, $feed_last_updated) { |
| 19 | 19 | |
| 20 | - if ($is_cat) $cat_q = "&is_cat=$is_cat"; |
|
| 20 | + if ($is_cat) { |
|
| 21 | + $cat_q = "&is_cat=$is_cat"; |
|
| 22 | + } |
|
| 21 | 23 | |
| 22 | 24 | if ($search) { |
| 23 | 25 | $search_q = "&q=$search"; |
@@ -48,8 +50,9 @@ discard block |
||
| 48 | 50 | $reply .= strip_tags($feed_title); |
| 49 | 51 | } |
| 50 | 52 | |
| 51 | - if ($error) |
|
| 52 | - $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
| 53 | + if ($error) { |
|
| 54 | + $reply .= " <i title=\"" . htmlspecialchars($error) . "\" class='material-icons icon-error'>error</i>"; |
|
| 55 | + } |
|
| 53 | 56 | |
| 54 | 57 | $reply .= "</span>"; |
| 55 | 58 | $reply .= "<span id='feed_current_unread' style='display: none'></span>"; |
@@ -127,8 +130,12 @@ discard block |
||
| 127 | 130 | $rgba_cache = array(); |
| 128 | 131 | $topmost_article_ids = array(); |
| 129 | 132 | |
| 130 | - if (!$offset) $offset = 0; |
|
| 131 | - if ($method == "undefined") $method = ""; |
|
| 133 | + if (!$offset) { |
|
| 134 | + $offset = 0; |
|
| 135 | + } |
|
| 136 | + if ($method == "undefined") { |
|
| 137 | + $method = ""; |
|
| 138 | + } |
|
| 132 | 139 | |
| 133 | 140 | $method_split = explode(":", $method); |
| 134 | 141 | |
@@ -274,14 +281,17 @@ discard block |
||
| 274 | 281 | $label_cache = json_decode($label_cache, true); |
| 275 | 282 | |
| 276 | 283 | if ($label_cache) { |
| 277 | - if ($label_cache["no-labels"] == 1) |
|
| 278 | - $labels = array(); |
|
| 279 | - else |
|
| 280 | - $labels = $label_cache; |
|
| 284 | + if ($label_cache["no-labels"] == 1) { |
|
| 285 | + $labels = array(); |
|
| 286 | + } else { |
|
| 287 | + $labels = $label_cache; |
|
| 288 | + } |
|
| 281 | 289 | } |
| 282 | 290 | } |
| 283 | 291 | |
| 284 | - if (!is_array($labels)) $labels = Article::get_article_labels($id); |
|
| 292 | + if (!is_array($labels)) { |
|
| 293 | + $labels = Article::get_article_labels($id); |
|
| 294 | + } |
|
| 285 | 295 | |
| 286 | 296 | $labels_str = "<span class=\"HLLCTR-$id\">"; |
| 287 | 297 | $labels_str .= Article::format_article_labels($labels); |
@@ -293,7 +303,9 @@ discard block |
||
| 293 | 303 | array_push($topmost_article_ids, $id); |
| 294 | 304 | } |
| 295 | 305 | |
| 296 | - if (!$line["feed_title"]) $line["feed_title"] = ""; |
|
| 306 | + if (!$line["feed_title"]) { |
|
| 307 | + $line["feed_title"] = ""; |
|
| 308 | + } |
|
| 297 | 309 | |
| 298 | 310 | $line["buttons_left"] = ""; |
| 299 | 311 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_LEFT_BUTTON) as $p) { |
@@ -314,10 +326,11 @@ discard block |
||
| 314 | 326 | |
| 315 | 327 | $line['content'] = DiskCache::rewriteUrls($line['content']); |
| 316 | 328 | |
| 317 | - if ($line['note']) |
|
| 318 | - $line['note'] = Article::format_article_note($id, $line['note']); |
|
| 319 | - else |
|
| 320 | - $line['note'] = ""; |
|
| 329 | + if ($line['note']) { |
|
| 330 | + $line['note'] = Article::format_article_note($id, $line['note']); |
|
| 331 | + } else { |
|
| 332 | + $line['note'] = ""; |
|
| 333 | + } |
|
| 321 | 334 | |
| 322 | 335 | if (!get_pref("CDM_EXPANDED")) { |
| 323 | 336 | $line["cdm_excerpt"] = "<span class='collapse'> |
@@ -350,10 +363,11 @@ discard block |
||
| 350 | 363 | $line['imported'] = T_sprintf("Imported at %s", |
| 351 | 364 | make_local_datetime($line["date_entered"], false)); |
| 352 | 365 | |
| 353 | - if ($line["tag_cache"]) |
|
| 354 | - $tags = explode(",", $line["tag_cache"]); |
|
| 355 | - else |
|
| 356 | - $tags = false; |
|
| 366 | + if ($line["tag_cache"]) { |
|
| 367 | + $tags = explode(",", $line["tag_cache"]); |
|
| 368 | + } else { |
|
| 369 | + $tags = false; |
|
| 370 | + } |
|
| 357 | 371 | |
| 358 | 372 | $line["tags_str"] = Article::format_tags_string($tags); |
| 359 | 373 | |
@@ -383,8 +397,9 @@ discard block |
||
| 383 | 397 | /* we don't need those */ |
| 384 | 398 | |
| 385 | 399 | foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color", |
| 386 | - "uuid", "label_cache", "yyiw"] as $k) |
|
| 387 | - unset($line[$k]); |
|
| 400 | + "uuid", "label_cache", "yyiw"] as $k) { |
|
| 401 | + unset($line[$k]); |
|
| 402 | + } |
|
| 388 | 403 | |
| 389 | 404 | array_push($reply['content'], $line); |
| 390 | 405 | } |
@@ -474,7 +489,9 @@ discard block |
||
| 474 | 489 | $order_by = $_REQUEST["order_by"]; |
| 475 | 490 | $check_first_id = $_REQUEST["fid"]; |
| 476 | 491 | |
| 477 | - if (is_numeric($feed)) $feed = (int) $feed; |
|
| 492 | + if (is_numeric($feed)) { |
|
| 493 | + $feed = (int) $feed; |
|
| 494 | + } |
|
| 478 | 495 | |
| 479 | 496 | /* Feed -5 is a special case: it is used to display auxiliary information |
| 480 | 497 | * when there's nothing to load - e.g. no stuff in fresh feed */ |
@@ -562,10 +579,11 @@ discard block |
||
| 562 | 579 | $disable_cache = $ret[3]; |
| 563 | 580 | $reply['headlines'] = $ret[4]; |
| 564 | 581 | |
| 565 | - if (!$next_unread_feed) |
|
| 566 | - $reply['headlines']['id'] = $feed; |
|
| 567 | - else |
|
| 568 | - $reply['headlines']['id'] = $next_unread_feed; |
|
| 582 | + if (!$next_unread_feed) { |
|
| 583 | + $reply['headlines']['id'] = $feed; |
|
| 584 | + } else { |
|
| 585 | + $reply['headlines']['id'] = $next_unread_feed; |
|
| 586 | + } |
|
| 569 | 587 | |
| 570 | 588 | $reply['headlines']['is_cat'] = (bool) $cat_view; |
| 571 | 589 | |
@@ -851,7 +869,9 @@ discard block |
||
| 851 | 869 | |
| 852 | 870 | public static function catchup_feed($feed, $cat_view, $owner_uid = false, $mode = 'all', $search = false) { |
| 853 | 871 | |
| 854 | - if (!$owner_uid) $owner_uid = $_SESSION['uid']; |
|
| 872 | + if (!$owner_uid) { |
|
| 873 | + $owner_uid = $_SESSION['uid']; |
|
| 874 | + } |
|
| 855 | 875 | |
| 856 | 876 | $pdo = Db::pdo(); |
| 857 | 877 | |
@@ -1026,7 +1046,9 @@ discard block |
||
| 1026 | 1046 | |
| 1027 | 1047 | $pdo = Db::pdo(); |
| 1028 | 1048 | |
| 1029 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 1049 | + if (!$owner_uid) { |
|
| 1050 | + $owner_uid = $_SESSION["uid"]; |
|
| 1051 | + } |
|
| 1030 | 1052 | |
| 1031 | 1053 | if ($unread_only) { |
| 1032 | 1054 | $unread_qpart = "unread = true"; |
@@ -1142,7 +1164,9 @@ discard block |
||
| 1142 | 1164 | |
| 1143 | 1165 | $url = Feeds::fix_url($url); |
| 1144 | 1166 | |
| 1145 | - if (!$url || !Feeds::validate_feed_url($url)) return array("code" => 2); |
|
| 1167 | + if (!$url || !Feeds::validate_feed_url($url)) { |
|
| 1168 | + return array("code" => 2); |
|
| 1169 | + } |
|
| 1146 | 1170 | |
| 1147 | 1171 | $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass); |
| 1148 | 1172 | |
@@ -1170,7 +1194,9 @@ discard block |
||
| 1170 | 1194 | $url = key($feedUrls); |
| 1171 | 1195 | } |
| 1172 | 1196 | |
| 1173 | - if (!$cat_id) $cat_id = null; |
|
| 1197 | + if (!$cat_id) { |
|
| 1198 | + $cat_id = null; |
|
| 1199 | + } |
|
| 1174 | 1200 | |
| 1175 | 1201 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
| 1176 | 1202 | WHERE feed_url = ? AND owner_uid = ?"); |
@@ -1287,13 +1313,17 @@ discard block |
||
| 1287 | 1313 | |
| 1288 | 1314 | public static function getCategoryUnread($cat, $owner_uid = false) { |
| 1289 | 1315 | |
| 1290 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 1316 | + if (!$owner_uid) { |
|
| 1317 | + $owner_uid = $_SESSION["uid"]; |
|
| 1318 | + } |
|
| 1291 | 1319 | |
| 1292 | 1320 | $pdo = Db::pdo(); |
| 1293 | 1321 | |
| 1294 | 1322 | if ($cat >= 0) { |
| 1295 | 1323 | |
| 1296 | - if (!$cat) $cat = null; |
|
| 1324 | + if (!$cat) { |
|
| 1325 | + $cat = null; |
|
| 1326 | + } |
|
| 1297 | 1327 | |
| 1298 | 1328 | $sth = $pdo->prepare("SELECT id FROM ttrss_feeds |
| 1299 | 1329 | WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL)) |
@@ -1306,7 +1336,9 @@ discard block |
||
| 1306 | 1336 | array_push($cat_feeds, "feed_id = " . (int)$line["id"]); |
| 1307 | 1337 | } |
| 1308 | 1338 | |
| 1309 | - if (count($cat_feeds) == 0) return 0; |
|
| 1339 | + if (count($cat_feeds) == 0) { |
|
| 1340 | + return 0; |
|
| 1341 | + } |
|
| 1310 | 1342 | |
| 1311 | 1343 | $match_part = implode(" OR ", $cat_feeds); |
| 1312 | 1344 | |
@@ -1341,7 +1373,9 @@ discard block |
||
| 1341 | 1373 | |
| 1342 | 1374 | // only accepts real cats (>= 0) |
| 1343 | 1375 | public static function getCategoryChildrenUnread($cat, $owner_uid = false) { |
| 1344 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 1376 | + if (!$owner_uid) { |
|
| 1377 | + $owner_uid = $_SESSION["uid"]; |
|
| 1378 | + } |
|
| 1345 | 1379 | |
| 1346 | 1380 | $pdo = Db::pdo(); |
| 1347 | 1381 | |
@@ -1361,7 +1395,9 @@ discard block |
||
| 1361 | 1395 | |
| 1362 | 1396 | public static function getGlobalUnread($user_id = false) { |
| 1363 | 1397 | |
| 1364 | - if (!$user_id) $user_id = $_SESSION["uid"]; |
|
| 1398 | + if (!$user_id) { |
|
| 1399 | + $user_id = $_SESSION["uid"]; |
|
| 1400 | + } |
|
| 1365 | 1401 | |
| 1366 | 1402 | $pdo = Db::pdo(); |
| 1367 | 1403 | |
@@ -1396,7 +1432,9 @@ discard block |
||
| 1396 | 1432 | } |
| 1397 | 1433 | |
| 1398 | 1434 | public static function getLabelUnread($label_id, $owner_uid = false) { |
| 1399 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 1435 | + if (!$owner_uid) { |
|
| 1436 | + $owner_uid = $_SESSION["uid"]; |
|
| 1437 | + } |
|
| 1400 | 1438 | |
| 1401 | 1439 | $pdo = Db::pdo(); |
| 1402 | 1440 | |
@@ -1491,8 +1529,9 @@ discard block |
||
| 1491 | 1529 | |
| 1492 | 1530 | $unread = getFeedUnread($feed, $cat_view); |
| 1493 | 1531 | |
| 1494 | - if ($cat_view && $feed > 0 && $include_children) |
|
| 1495 | - $unread += Feeds::getCategoryChildrenUnread($feed); |
|
| 1532 | + if ($cat_view && $feed > 0 && $include_children) { |
|
| 1533 | + $unread += Feeds::getCategoryChildrenUnread($feed); |
|
| 1534 | + } |
|
| 1496 | 1535 | |
| 1497 | 1536 | if ($unread > 0) { |
| 1498 | 1537 | $view_query_part = " unread = true AND "; |
@@ -1604,7 +1643,9 @@ discard block |
||
| 1604 | 1643 | $allow_archived = true; |
| 1605 | 1644 | $ignore_vfeed_group = true; |
| 1606 | 1645 | |
| 1607 | - if (!$override_order) $override_order = "last_read DESC"; |
|
| 1646 | + if (!$override_order) { |
|
| 1647 | + $override_order = "last_read DESC"; |
|
| 1648 | + } |
|
| 1608 | 1649 | |
| 1609 | 1650 | } else if ($feed == -3) { // fresh virtual feed |
| 1610 | 1651 | $query_strategy_part = "unread = true AND score >= 0"; |
@@ -1715,13 +1756,16 @@ discard block |
||
| 1715 | 1756 | LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)"; |
| 1716 | 1757 | } |
| 1717 | 1758 | |
| 1718 | - if ($vfeed_query_part) $vfeed_query_part .= "favicon_avg_color,"; |
|
| 1759 | + if ($vfeed_query_part) { |
|
| 1760 | + $vfeed_query_part .= "favicon_avg_color,"; |
|
| 1761 | + } |
|
| 1719 | 1762 | |
| 1720 | 1763 | $first_id = 0; |
| 1721 | 1764 | $first_id_query_strategy_part = $query_strategy_part; |
| 1722 | 1765 | |
| 1723 | - if ($feed == -3) |
|
| 1724 | - $first_id_query_strategy_part = "true"; |
|
| 1766 | + if ($feed == -3) { |
|
| 1767 | + $first_id_query_strategy_part = "true"; |
|
| 1768 | + } |
|
| 1725 | 1769 | |
| 1726 | 1770 | if (DB_TYPE == "pgsql") { |
| 1727 | 1771 | $sanity_interval_qpart = "date_entered >= NOW() - INTERVAL '1 hour' AND"; |
@@ -1853,7 +1897,9 @@ discard block |
||
| 1853 | 1897 | $query_strategy_part ORDER BY $order_by |
| 1854 | 1898 | $limit_query_part $offset_query_part"; |
| 1855 | 1899 | |
| 1856 | - if ($_REQUEST["debug"]) print $query; |
|
| 1900 | + if ($_REQUEST["debug"]) { |
|
| 1901 | + print $query; |
|
| 1902 | + } |
|
| 1857 | 1903 | |
| 1858 | 1904 | $res = $pdo->query($query); |
| 1859 | 1905 | } |
@@ -2003,18 +2049,23 @@ discard block |
||
| 2003 | 2049 | } |
| 2004 | 2050 | } |
| 2005 | 2051 | |
| 2006 | - if ($url != "http:///") |
|
| 2007 | - return $url; |
|
| 2008 | - else |
|
| 2009 | - return ''; |
|
| 2052 | + if ($url != "http:///") { |
|
| 2053 | + return $url; |
|
| 2054 | + } else { |
|
| 2055 | + return ''; |
|
| 2056 | + } |
|
| 2010 | 2057 | } |
| 2011 | 2058 | |
| 2012 | 2059 | public static function add_feed_category($feed_cat, $parent_cat_id = false, $order_id = 0) { |
| 2013 | 2060 | |
| 2014 | - if (!$feed_cat) return false; |
|
| 2061 | + if (!$feed_cat) { |
|
| 2062 | + return false; |
|
| 2063 | + } |
|
| 2015 | 2064 | |
| 2016 | 2065 | $feed_cat = mb_substr($feed_cat, 0, 250); |
| 2017 | - if (!$parent_cat_id) $parent_cat_id = null; |
|
| 2066 | + if (!$parent_cat_id) { |
|
| 2067 | + $parent_cat_id = null; |
|
| 2068 | + } |
|
| 2018 | 2069 | |
| 2019 | 2070 | $pdo = Db::pdo(); |
| 2020 | 2071 | $tr_in_progress = false; |
@@ -2036,7 +2087,9 @@ discard block |
||
| 2036 | 2087 | VALUES (?, ?, ?, ?)"); |
| 2037 | 2088 | $sth->execute([$_SESSION['uid'], $feed_cat, $parent_cat_id, (int)$order_id]); |
| 2038 | 2089 | |
| 2039 | - if (!$tr_in_progress) $pdo->commit(); |
|
| 2090 | + if (!$tr_in_progress) { |
|
| 2091 | + $pdo->commit(); |
|
| 2092 | + } |
|
| 2040 | 2093 | |
| 2041 | 2094 | return true; |
| 2042 | 2095 | } |
@@ -2048,7 +2101,9 @@ discard block |
||
| 2048 | 2101 | |
| 2049 | 2102 | public static function get_feed_access_key($feed_id, $is_cat, $owner_uid = false) { |
| 2050 | 2103 | |
| 2051 | - if (!$owner_uid) $owner_uid = $_SESSION["uid"]; |
|
| 2104 | + if (!$owner_uid) { |
|
| 2105 | + $owner_uid = $_SESSION["uid"]; |
|
| 2106 | + } |
|
| 2052 | 2107 | |
| 2053 | 2108 | $is_cat = bool_to_sql_bool($is_cat); |
| 2054 | 2109 | |
@@ -2086,7 +2141,9 @@ discard block |
||
| 2086 | 2141 | */ |
| 2087 | 2142 | public static function purge_feed($feed_id, $purge_interval) { |
| 2088 | 2143 | |
| 2089 | - if (!$purge_interval) $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
| 2144 | + if (!$purge_interval) { |
|
| 2145 | + $purge_interval = Feeds::feed_purge_interval($feed_id); |
|
| 2146 | + } |
|
| 2090 | 2147 | |
| 2091 | 2148 | $pdo = Db::pdo(); |
| 2092 | 2149 | |
@@ -2106,7 +2163,9 @@ discard block |
||
| 2106 | 2163 | return; |
| 2107 | 2164 | } |
| 2108 | 2165 | |
| 2109 | - if (!$owner_uid) return; |
|
| 2166 | + if (!$owner_uid) { |
|
| 2167 | + return; |
|
| 2168 | + } |
|
| 2110 | 2169 | |
| 2111 | 2170 | if (FORCE_ARTICLE_PURGE == 0) { |
| 2112 | 2171 | $purge_unread = get_pref("PURGE_UNREAD_ARTICLES", |
@@ -2116,10 +2175,11 @@ discard block |
||
| 2116 | 2175 | $purge_interval = FORCE_ARTICLE_PURGE; |
| 2117 | 2176 | } |
| 2118 | 2177 | |
| 2119 | - if (!$purge_unread) |
|
| 2120 | - $query_limit = " unread = false AND "; |
|
| 2121 | - else |
|
| 2122 | - $query_limit = ""; |
|
| 2178 | + if (!$purge_unread) { |
|
| 2179 | + $query_limit = " unread = false AND "; |
|
| 2180 | + } else { |
|
| 2181 | + $query_limit = ""; |
|
| 2182 | + } |
|
| 2123 | 2183 | |
| 2124 | 2184 | $purge_interval = (int) $purge_interval; |
| 2125 | 2185 | |
@@ -2166,8 +2226,10 @@ discard block |
||
| 2166 | 2226 | $purge_interval = $row["purge_interval"]; |
| 2167 | 2227 | $owner_uid = $row["owner_uid"]; |
| 2168 | 2228 | |
| 2169 | - if ($purge_interval == 0) $purge_interval = get_pref( |
|
| 2229 | + if ($purge_interval == 0) { |
|
| 2230 | + $purge_interval = get_pref( |
|
| 2170 | 2231 | 'PURGE_OLD_DAYS', $owner_uid); |
| 2232 | + } |
|
| 2171 | 2233 | |
| 2172 | 2234 | return $purge_interval; |
| 2173 | 2235 | |
@@ -2185,10 +2247,11 @@ discard block |
||
| 2185 | 2247 | |
| 2186 | 2248 | $pdo = Db::pdo(); |
| 2187 | 2249 | |
| 2188 | - if ($search_language) |
|
| 2189 | - $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
| 2190 | - else |
|
| 2191 | - $search_language = $pdo->quote("english"); |
|
| 2250 | + if ($search_language) { |
|
| 2251 | + $search_language = $pdo->quote(mb_strtolower($search_language)); |
|
| 2252 | + } else { |
|
| 2253 | + $search_language = $pdo->quote("english"); |
|
| 2254 | + } |
|
| 2192 | 2255 | |
| 2193 | 2256 | foreach ($keywords as $k) { |
| 2194 | 2257 | if (strpos($k, "-") === 0) { |
@@ -2223,56 +2286,68 @@ discard block |
||
| 2223 | 2286 | break; |
| 2224 | 2287 | case "note": |
| 2225 | 2288 | if ($commandpair[1]) { |
| 2226 | - if ($commandpair[1] == "true") |
|
| 2227 | - array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
| 2228 | - else if ($commandpair[1] == "false") |
|
| 2229 | - array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
| 2230 | - else |
|
| 2231 | - array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
| 2289 | + if ($commandpair[1] == "true") { |
|
| 2290 | + array_push($query_keywords, "($not (note IS NOT NULL AND note != ''))"); |
|
| 2291 | + } else if ($commandpair[1] == "false") { |
|
| 2292 | + array_push($query_keywords, "($not (note IS NULL OR note = ''))"); |
|
| 2293 | + } else { |
|
| 2294 | + array_push($query_keywords, "($not (LOWER(note) LIKE ". |
|
| 2232 | 2295 | $pdo->quote('%' . mb_strtolower($commandpair[1]) . '%')."))"); |
| 2296 | + } |
|
| 2233 | 2297 | } else { |
| 2234 | 2298 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2235 | 2299 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2236 | - if (!$not) array_push($search_words, $k); |
|
| 2300 | + if (!$not) { |
|
| 2301 | + array_push($search_words, $k); |
|
| 2302 | + } |
|
| 2237 | 2303 | } |
| 2238 | 2304 | break; |
| 2239 | 2305 | case "star": |
| 2240 | 2306 | |
| 2241 | 2307 | if ($commandpair[1]) { |
| 2242 | - if ($commandpair[1] == "true") |
|
| 2243 | - array_push($query_keywords, "($not (marked = true))"); |
|
| 2244 | - else |
|
| 2245 | - array_push($query_keywords, "($not (marked = false))"); |
|
| 2308 | + if ($commandpair[1] == "true") { |
|
| 2309 | + array_push($query_keywords, "($not (marked = true))"); |
|
| 2310 | + } else { |
|
| 2311 | + array_push($query_keywords, "($not (marked = false))"); |
|
| 2312 | + } |
|
| 2246 | 2313 | } else { |
| 2247 | 2314 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2248 | 2315 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2249 | - if (!$not) array_push($search_words, $k); |
|
| 2316 | + if (!$not) { |
|
| 2317 | + array_push($search_words, $k); |
|
| 2318 | + } |
|
| 2250 | 2319 | } |
| 2251 | 2320 | break; |
| 2252 | 2321 | case "pub": |
| 2253 | 2322 | if ($commandpair[1]) { |
| 2254 | - if ($commandpair[1] == "true") |
|
| 2255 | - array_push($query_keywords, "($not (published = true))"); |
|
| 2256 | - else |
|
| 2257 | - array_push($query_keywords, "($not (published = false))"); |
|
| 2323 | + if ($commandpair[1] == "true") { |
|
| 2324 | + array_push($query_keywords, "($not (published = true))"); |
|
| 2325 | + } else { |
|
| 2326 | + array_push($query_keywords, "($not (published = false))"); |
|
| 2327 | + } |
|
| 2258 | 2328 | |
| 2259 | 2329 | } else { |
| 2260 | 2330 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER('%$k%') |
| 2261 | 2331 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2262 | - if (!$not) array_push($search_words, $k); |
|
| 2332 | + if (!$not) { |
|
| 2333 | + array_push($search_words, $k); |
|
| 2334 | + } |
|
| 2263 | 2335 | } |
| 2264 | 2336 | break; |
| 2265 | 2337 | case "unread": |
| 2266 | 2338 | if ($commandpair[1]) { |
| 2267 | - if ($commandpair[1] == "true") |
|
| 2268 | - array_push($query_keywords, "($not (unread = true))"); |
|
| 2269 | - else |
|
| 2270 | - array_push($query_keywords, "($not (unread = false))"); |
|
| 2339 | + if ($commandpair[1] == "true") { |
|
| 2340 | + array_push($query_keywords, "($not (unread = true))"); |
|
| 2341 | + } else { |
|
| 2342 | + array_push($query_keywords, "($not (unread = false))"); |
|
| 2343 | + } |
|
| 2271 | 2344 | |
| 2272 | 2345 | } else { |
| 2273 | 2346 | array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") |
| 2274 | 2347 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2275 | - if (!$not) array_push($search_words, $k); |
|
| 2348 | + if (!$not) { |
|
| 2349 | + array_push($search_words, $k); |
|
| 2350 | + } |
|
| 2276 | 2351 | } |
| 2277 | 2352 | break; |
| 2278 | 2353 | default: |
@@ -2295,7 +2370,9 @@ discard block |
||
| 2295 | 2370 | OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); |
| 2296 | 2371 | } |
| 2297 | 2372 | |
| 2298 | - if (!$not) array_push($search_words, $k); |
|
| 2373 | + if (!$not) { |
|
| 2374 | + array_push($search_words, $k); |
|
| 2375 | + } |
|
| 2299 | 2376 | } |
| 2300 | 2377 | } |
| 2301 | 2378 | } |
@@ -2,72 +2,72 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Logger { |
| 4 | 4 | |
| 5 | - /** |
|
| 6 | - * @var Logger |
|
| 7 | - */ |
|
| 8 | - private static $instance; |
|
| 5 | + /** |
|
| 6 | + * @var Logger |
|
| 7 | + */ |
|
| 8 | + private static $instance; |
|
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * @var bool|Logger_SQL|Logger_Syslog |
|
| 12 | - */ |
|
| 13 | - private $adapter; |
|
| 10 | + /** |
|
| 11 | + * @var bool|Logger_SQL|Logger_Syslog |
|
| 12 | + */ |
|
| 13 | + private $adapter; |
|
| 14 | 14 | |
| 15 | - public static $errornames = array( |
|
| 16 | - 1 => 'E_ERROR', |
|
| 17 | - 2 => 'E_WARNING', |
|
| 18 | - 4 => 'E_PARSE', |
|
| 19 | - 8 => 'E_NOTICE', |
|
| 20 | - 16 => 'E_CORE_ERROR', |
|
| 21 | - 32 => 'E_CORE_WARNING', |
|
| 22 | - 64 => 'E_COMPILE_ERROR', |
|
| 23 | - 128 => 'E_COMPILE_WARNING', |
|
| 24 | - 256 => 'E_USER_ERROR', |
|
| 25 | - 512 => 'E_USER_WARNING', |
|
| 26 | - 1024 => 'E_USER_NOTICE', |
|
| 27 | - 2048 => 'E_STRICT', |
|
| 28 | - 4096 => 'E_RECOVERABLE_ERROR', |
|
| 29 | - 8192 => 'E_DEPRECATED', |
|
| 30 | - 16384 => 'E_USER_DEPRECATED', |
|
| 31 | - 32767 => 'E_ALL'); |
|
| 15 | + public static $errornames = array( |
|
| 16 | + 1 => 'E_ERROR', |
|
| 17 | + 2 => 'E_WARNING', |
|
| 18 | + 4 => 'E_PARSE', |
|
| 19 | + 8 => 'E_NOTICE', |
|
| 20 | + 16 => 'E_CORE_ERROR', |
|
| 21 | + 32 => 'E_CORE_WARNING', |
|
| 22 | + 64 => 'E_COMPILE_ERROR', |
|
| 23 | + 128 => 'E_COMPILE_WARNING', |
|
| 24 | + 256 => 'E_USER_ERROR', |
|
| 25 | + 512 => 'E_USER_WARNING', |
|
| 26 | + 1024 => 'E_USER_NOTICE', |
|
| 27 | + 2048 => 'E_STRICT', |
|
| 28 | + 4096 => 'E_RECOVERABLE_ERROR', |
|
| 29 | + 8192 => 'E_DEPRECATED', |
|
| 30 | + 16384 => 'E_USER_DEPRECATED', |
|
| 31 | + 32767 => 'E_ALL'); |
|
| 32 | 32 | |
| 33 | - public function log_error($errno, $errstr, $file, $line, $context) { |
|
| 34 | - if ($errno === E_NOTICE) { |
|
| 35 | - return false; |
|
| 36 | - } |
|
| 33 | + public function log_error($errno, $errstr, $file, $line, $context) { |
|
| 34 | + if ($errno === E_NOTICE) { |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - if ($this->adapter) { |
|
| 39 | - return $this->adapter->log_error($errno, $errstr, $file, $line, $context); |
|
| 40 | - } |
|
| 38 | + if ($this->adapter) { |
|
| 39 | + return $this->adapter->log_error($errno, $errstr, $file, $line, $context); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return false; |
|
| 43 | - } |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function log($string, $context = "") { |
|
| 46 | - if ($this->adapter) { |
|
| 47 | - return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context); |
|
| 48 | - } |
|
| 45 | + public function log($string, $context = "") { |
|
| 46 | + if ($this->adapter) { |
|
| 47 | + return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return false; |
|
| 51 | - } |
|
| 50 | + return false; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function __construct() { |
|
| 54 | - switch (LOG_DESTINATION) { |
|
| 55 | - case "sql": |
|
| 56 | - $this->adapter = new Logger_SQL(); |
|
| 57 | - break; |
|
| 58 | - case "syslog": |
|
| 59 | - $this->adapter = new Logger_Syslog(); |
|
| 60 | - break; |
|
| 61 | - default: |
|
| 62 | - $this->adapter = false; |
|
| 63 | - } |
|
| 64 | - } |
|
| 53 | + public function __construct() { |
|
| 54 | + switch (LOG_DESTINATION) { |
|
| 55 | + case "sql": |
|
| 56 | + $this->adapter = new Logger_SQL(); |
|
| 57 | + break; |
|
| 58 | + case "syslog": |
|
| 59 | + $this->adapter = new Logger_Syslog(); |
|
| 60 | + break; |
|
| 61 | + default: |
|
| 62 | + $this->adapter = false; |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - public static function get(): Logger { |
|
| 67 | - if (self::$instance == null) { |
|
| 68 | - self::$instance = new self(); |
|
| 69 | - } |
|
| 70 | - return self::$instance; |
|
| 71 | - } |
|
| 66 | + public static function get(): Logger { |
|
| 67 | + if (self::$instance == null) { |
|
| 68 | + self::$instance = new self(); |
|
| 69 | + } |
|
| 70 | + return self::$instance; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | } |
@@ -52,14 +52,14 @@ |
||
| 52 | 52 | |
| 53 | 53 | public function __construct() { |
| 54 | 54 | switch (LOG_DESTINATION) { |
| 55 | - case "sql": |
|
| 56 | - $this->adapter = new Logger_SQL(); |
|
| 57 | - break; |
|
| 58 | - case "syslog": |
|
| 59 | - $this->adapter = new Logger_Syslog(); |
|
| 60 | - break; |
|
| 61 | - default: |
|
| 62 | - $this->adapter = false; |
|
| 55 | + case "sql": |
|
| 56 | + $this->adapter = new Logger_SQL(); |
|
| 57 | + break; |
|
| 58 | + case "syslog": |
|
| 59 | + $this->adapter = new Logger_Syslog(); |
|
| 60 | + break; |
|
| 61 | + default: |
|
| 62 | + $this->adapter = false; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |