@@ -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 | } |
@@ -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> |
@@ -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 | } |
@@ -173,29 +173,29 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * Maximum matrix size for maximum version (version 40 is 177*177 matrix). |
175 | 175 | */ |
176 | - define('QRSPEC_WIDTH_MAX', 177); |
|
176 | + define('QRSPEC_WIDTH_MAX', 177); |
|
177 | 177 | |
178 | 178 | // ----------------------------------------------------- |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Matrix index to get width from $capacity array. |
182 | 182 | */ |
183 | - define('QRCAP_WIDTH', 0); |
|
183 | + define('QRCAP_WIDTH', 0); |
|
184 | 184 | |
185 | - /** |
|
185 | + /** |
|
186 | 186 | * Matrix index to get number of words from $capacity array. |
187 | 187 | */ |
188 | - define('QRCAP_WORDS', 1); |
|
188 | + define('QRCAP_WORDS', 1); |
|
189 | 189 | |
190 | - /** |
|
190 | + /** |
|
191 | 191 | * Matrix index to get remainder from $capacity array. |
192 | 192 | */ |
193 | - define('QRCAP_REMINDER', 2); |
|
193 | + define('QRCAP_REMINDER', 2); |
|
194 | 194 | |
195 | - /** |
|
195 | + /** |
|
196 | 196 | * Matrix index to get error correction level from $capacity array. |
197 | 197 | */ |
198 | - define('QRCAP_EC', 3); |
|
198 | + define('QRCAP_EC', 3); |
|
199 | 199 | |
200 | 200 | // ----------------------------------------------------- |
201 | 201 | |
@@ -204,33 +204,33 @@ discard block |
||
204 | 204 | /** |
205 | 205 | * Number of header bits for structured mode |
206 | 206 | */ |
207 | - define('STRUCTURE_HEADER_BITS', 20); |
|
207 | + define('STRUCTURE_HEADER_BITS', 20); |
|
208 | 208 | |
209 | - /** |
|
209 | + /** |
|
210 | 210 | * Max number of symbols for structured mode |
211 | 211 | */ |
212 | - define('MAX_STRUCTURED_SYMBOLS', 16); |
|
212 | + define('MAX_STRUCTURED_SYMBOLS', 16); |
|
213 | 213 | |
214 | 214 | // ----------------------------------------------------- |
215 | 215 | |
216 | - // Masks |
|
216 | + // Masks |
|
217 | 217 | |
218 | - /** |
|
218 | + /** |
|
219 | 219 | * Down point base value for case 1 mask pattern (concatenation of same color in a line or a column) |
220 | 220 | */ |
221 | - define('N1', 3); |
|
221 | + define('N1', 3); |
|
222 | 222 | |
223 | - /** |
|
223 | + /** |
|
224 | 224 | * Down point base value for case 2 mask pattern (module block of same color) |
225 | 225 | */ |
226 | 226 | define('N2', 3); |
227 | 227 | |
228 | - /** |
|
228 | + /** |
|
229 | 229 | * Down point base value for case 3 mask pattern (1:1:3:1:1(dark:bright:dark:bright:dark)pattern in a line or a column) |
230 | 230 | */ |
231 | 231 | define('N3', 40); |
232 | 232 | |
233 | - /** |
|
233 | + /** |
|
234 | 234 | * Down point base value for case 4 mask pattern (ration of dark modules in whole) |
235 | 235 | */ |
236 | 236 | define('N4', 10); |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | |
265 | 265 | // for compaibility with PHP4 |
266 | 266 | if (!function_exists('str_split')) { |
267 | - /** |
|
268 | - * Convert a string to an array (needed for PHP4 compatibility) |
|
269 | - * @param string $string The input string. |
|
270 | - * @param int $split_length Maximum length of the chunk. |
|
271 | - * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
272 | - */ |
|
267 | + /** |
|
268 | + * Convert a string to an array (needed for PHP4 compatibility) |
|
269 | + * @param string $string The input string. |
|
270 | + * @param int $split_length Maximum length of the chunk. |
|
271 | + * @return If the optional split_length parameter is specified, the returned array will be broken down into chunks with each being split_length in length, otherwise each chunk will be one character in length. FALSE is returned if split_length is less than 1. If the split_length length exceeds the length of string , the entire string is returned as the first (and only) array element. |
|
272 | + */ |
|
273 | 273 | public function str_split($string, $split_length=1) { |
274 | 274 | if ((strlen($string) > $split_length) OR (!$split_length)) { |
275 | 275 | do { |
@@ -2622,7 +2622,7 @@ discard block |
||
2622 | 2622 | } |
2623 | 2623 | |
2624 | 2624 | /** |
2625 | - * Return block number 1 |
|
2625 | + * Return block number 1 |
|
2626 | 2626 | * @param array $spec |
2627 | 2627 | * @return int value |
2628 | 2628 | */ |
@@ -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 |
@@ -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) { |
@@ -1568,8 +1568,8 @@ |
||
1568 | 1568 | public static function remove_feed($id, $owner_uid) { |
1569 | 1569 | foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_UNSUBSCRIBE_FEED) as $p) { |
1570 | 1570 | if (! $p->hook_unsubscribe_feed($id, $owner_uid)) { |
1571 | - user_error("Feed $id (owner: $owner_uid) not removed due to plugin error (HOOK_UNSUBSCRIBE_FEED).", E_USER_WARNING); |
|
1572 | - return; |
|
1571 | + user_error("Feed $id (owner: $owner_uid) not removed due to plugin error (HOOK_UNSUBSCRIBE_FEED).", E_USER_WARNING); |
|
1572 | + return; |
|
1573 | 1573 | } |
1574 | 1574 | } |
1575 | 1575 |
@@ -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 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class Dlg extends Handler_Protected { |
3 | 3 | private $param; |
4 | - private $params; |
|
4 | + private $params; |
|
5 | 5 | |
6 | - function before($method) { |
|
6 | + function before($method) { |
|
7 | 7 | if (parent::before($method)) { |
8 | 8 | header("Content-Type: text/html"); # required for iframe |
9 | 9 | |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $tags[$line["tag_name"]] = $line["count"]; |
109 | 109 | } |
110 | 110 | |
111 | - if(count($tags) == 0 ){ return; } |
|
111 | + if(count($tags) == 0 ){ return; } |
|
112 | 112 | |
113 | 113 | ksort($tags); |
114 | 114 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | public function defaultPasswordWarning() { |
195 | 195 | |
196 | - print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
196 | + print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")); |
|
197 | 197 | |
198 | 198 | print "<footer class='text-center'>"; |
199 | 199 | print "<button dojoType='dijit.form.Button' onclick=\"document.location.href = 'prefs.php'\">". |