@@ -36,7 +36,7 @@ |
||
36 | 36 | * @author Donovan Jimenez <[email protected]> |
37 | 37 | */ |
38 | 38 | |
39 | -require_once(dirname(__FILE__) . '/ParserException.php'); |
|
39 | +require_once(dirname(__FILE__).'/ParserException.php'); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Represents a Solr response. Parses the raw response into a set of stdClass objects |
@@ -217,8 +217,7 @@ |
||
217 | 217 | if ($this->_createDocuments) |
218 | 218 | { |
219 | 219 | $document = new Apache_Solr_Document(); |
220 | - } |
|
221 | - else |
|
220 | + } else |
|
222 | 221 | { |
223 | 222 | $document = $originalDocument; |
224 | 223 | } |
@@ -121,8 +121,7 @@ discard block |
||
121 | 121 | if ($boost > 0.0) |
122 | 122 | { |
123 | 123 | $this->_documentBoost = $boost; |
124 | - } |
|
125 | - else |
|
124 | + } else |
|
126 | 125 | { |
127 | 126 | $this->_documentBoost = false; |
128 | 127 | } |
@@ -157,8 +156,7 @@ discard block |
||
157 | 156 | { |
158 | 157 | // create holding array if this is the first value |
159 | 158 | $this->_fields[$key] = array(); |
160 | - } |
|
161 | - else if (!is_array($this->_fields[$key])) |
|
159 | + } else if (!is_array($this->_fields[$key])) |
|
162 | 160 | { |
163 | 161 | // move existing value into array if it is not already an array |
164 | 162 | $this->_fields[$key] = array($this->_fields[$key]); |
@@ -168,8 +166,7 @@ discard block |
||
168 | 166 | { |
169 | 167 | // boost not already set, set it now |
170 | 168 | $this->setFieldBoost($key, $boost); |
171 | - } |
|
172 | - else if ((float) $boost > 0.0) |
|
169 | + } else if ((float) $boost > 0.0) |
|
173 | 170 | { |
174 | 171 | // multiply passed boost with current field boost - similar to SolrJ implementation |
175 | 172 | $this->_fieldBoosts[$key] *= (float) $boost; |
@@ -252,8 +249,7 @@ discard block |
||
252 | 249 | if ($boost > 0.0) |
253 | 250 | { |
254 | 251 | $this->_fieldBoosts[$key] = $boost; |
255 | - } |
|
256 | - else |
|
252 | + } else |
|
257 | 253 | { |
258 | 254 | $this->_fieldBoosts[$key] = false; |
259 | 255 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | // See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1) |
40 | 40 | // Doesn't follow typical include path conventions, but is more convenient for users |
41 | -require_once(dirname(dirname(__FILE__)) . '/Service.php'); |
|
41 | +require_once(dirname(dirname(__FILE__)).'/Service.php'); |
|
42 | 42 | |
43 | -require_once(dirname(dirname(__FILE__)) . '/NoServiceAvailableException.php'); |
|
43 | +require_once(dirname(dirname(__FILE__)).'/NoServiceAvailableException.php'); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Reference Implementation for using multiple Solr services in a distribution. Functionality |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | protected $_writePingTimeout = 4; |
73 | 73 | |
74 | 74 | // Configuration for server selection backoff intervals |
75 | - protected $_useBackoff = false; // Set to true to use more resillient write server selection |
|
76 | - protected $_backoffLimit = 600; // 10 minute default maximum |
|
77 | - protected $_backoffEscalation = 2.0; // Rate at which to increase backoff period |
|
78 | - protected $_defaultBackoff = 2.0; // Default backoff interval |
|
75 | + protected $_useBackoff = false; // Set to true to use more resillient write server selection |
|
76 | + protected $_backoffLimit = 600; // 10 minute default maximum |
|
77 | + protected $_backoffEscalation = 2.0; // Rate at which to increase backoff period |
|
78 | + protected $_defaultBackoff = 2.0; // Default backoff interval |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc. |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function _getServiceId($host, $port, $path) |
160 | 160 | { |
161 | - return $host . ':' . $port . $path; |
|
161 | + return $host.':'.$port.$path; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | { |
182 | 182 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
183 | 183 | { |
184 | - $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
|
184 | + $id = $this->_getServiceId((string) $service['host'], (int) $service['port'], (string) $service['path']); |
|
185 | 185 | |
186 | 186 | $this->_readableServices[$id] = $service; |
187 | 187 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | { |
212 | 212 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
213 | 213 | { |
214 | - $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
|
214 | + $id = $this->_getServiceId((string) $service['host'], (int) $service['port'], (string) $service['path']); |
|
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | { |
250 | 250 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
251 | 251 | { |
252 | - $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
|
252 | + $id = $this->_getServiceId((string) $service['host'], (int) $service['port'], (string) $service['path']); |
|
253 | 253 | |
254 | 254 | $this->_writeableServices[$id] = $service; |
255 | 255 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | { |
280 | 280 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
281 | 281 | { |
282 | - $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
|
282 | + $id = $this->_getServiceId((string) $service['host'], (int) $service['port'], (string) $service['path']); |
|
283 | 283 | } |
284 | 284 | else |
285 | 285 | { |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | */ |
356 | 356 | protected function _selectWriteService($forceSelect = false) |
357 | 357 | { |
358 | - if($this->_useBackoff) |
|
358 | + if ($this->_useBackoff) |
|
359 | 359 | { |
360 | 360 | return $this->_selectWriteServiceSafe($forceSelect); |
361 | 361 | } |
@@ -435,12 +435,12 @@ discard block |
||
435 | 435 | |
436 | 436 | $backoff *= $this->_backoffEscalation; |
437 | 437 | |
438 | - if($backoff > $this->_backoffLimit) |
|
438 | + if ($backoff > $this->_backoffLimit) |
|
439 | 439 | { |
440 | 440 | throw new Apache_Solr_NoServiceAvailableException('No write services were available. All timeouts exceeded.'); |
441 | 441 | } |
442 | 442 | |
443 | - } while($this->_writeableServices[$this->_currentWriteService]->ping($backoff) === false); |
|
443 | + } while ($this->_writeableServices[$this->_currentWriteService]->ping($backoff) === false); |
|
444 | 444 | } |
445 | 445 | else |
446 | 446 | { |
@@ -176,16 +176,14 @@ discard block |
||
176 | 176 | $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); |
177 | 177 | |
178 | 178 | $this->_readableServices[$id] = $service; |
179 | - } |
|
180 | - else if (is_array($service)) |
|
179 | + } else if (is_array($service)) |
|
181 | 180 | { |
182 | 181 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
183 | 182 | { |
184 | 183 | $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
185 | 184 | |
186 | 185 | $this->_readableServices[$id] = $service; |
187 | - } |
|
188 | - else |
|
186 | + } else |
|
189 | 187 | { |
190 | 188 | throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path'); |
191 | 189 | } |
@@ -206,19 +204,16 @@ discard block |
||
206 | 204 | if ($service instanceof Apache_Solr_Service) |
207 | 205 | { |
208 | 206 | $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); |
209 | - } |
|
210 | - else if (is_array($service)) |
|
207 | + } else if (is_array($service)) |
|
211 | 208 | { |
212 | 209 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
213 | 210 | { |
214 | 211 | $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
215 | - } |
|
216 | - else |
|
212 | + } else |
|
217 | 213 | { |
218 | 214 | throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path'); |
219 | 215 | } |
220 | - } |
|
221 | - else if (is_string($service)) |
|
216 | + } else if (is_string($service)) |
|
222 | 217 | { |
223 | 218 | $id = $service; |
224 | 219 | } |
@@ -244,16 +239,14 @@ discard block |
||
244 | 239 | $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); |
245 | 240 | |
246 | 241 | $this->_writeableServices[$id] = $service; |
247 | - } |
|
248 | - else if (is_array($service)) |
|
242 | + } else if (is_array($service)) |
|
249 | 243 | { |
250 | 244 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
251 | 245 | { |
252 | 246 | $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
253 | 247 | |
254 | 248 | $this->_writeableServices[$id] = $service; |
255 | - } |
|
256 | - else |
|
249 | + } else |
|
257 | 250 | { |
258 | 251 | throw new Apache_Solr_InvalidArgumentException('A Writeable Service description array does not have all required elements of host, port, and path'); |
259 | 252 | } |
@@ -274,19 +267,16 @@ discard block |
||
274 | 267 | if ($service instanceof Apache_Solr_Service) |
275 | 268 | { |
276 | 269 | $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); |
277 | - } |
|
278 | - else if (is_array($service)) |
|
270 | + } else if (is_array($service)) |
|
279 | 271 | { |
280 | 272 | if (isset($service['host']) && isset($service['port']) && isset($service['path'])) |
281 | 273 | { |
282 | 274 | $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); |
283 | - } |
|
284 | - else |
|
275 | + } else |
|
285 | 276 | { |
286 | 277 | throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path'); |
287 | 278 | } |
288 | - } |
|
289 | - else if (is_string($service)) |
|
279 | + } else if (is_string($service)) |
|
290 | 280 | { |
291 | 281 | $id = $service; |
292 | 282 | } |
@@ -335,8 +325,7 @@ discard block |
||
335 | 325 | |
336 | 326 | $service->setCreateDocuments($this->_createDocuments); |
337 | 327 | $this->_currentReadService = $id; |
338 | - } |
|
339 | - else |
|
328 | + } else |
|
340 | 329 | { |
341 | 330 | throw new Apache_Solr_NoServiceAvailableException('No read services were available'); |
342 | 331 | } |
@@ -387,8 +376,7 @@ discard block |
||
387 | 376 | } |
388 | 377 | |
389 | 378 | $this->_currentWriteService = $id; |
390 | - } |
|
391 | - else |
|
379 | + } else |
|
392 | 380 | { |
393 | 381 | throw new Apache_Solr_NoServiceAvailableException('No write services were available'); |
394 | 382 | } |
@@ -441,8 +429,7 @@ discard block |
||
441 | 429 | } |
442 | 430 | |
443 | 431 | } while($this->_writeableServices[$this->_currentWriteService]->ping($backoff) === false); |
444 | - } |
|
445 | - else |
|
432 | + } else |
|
446 | 433 | { |
447 | 434 | throw new Apache_Solr_NoServiceAvailableException('No write services were available'); |
448 | 435 | } |
@@ -497,13 +484,14 @@ discard block |
||
497 | 484 | try |
498 | 485 | { |
499 | 486 | return $service->add($rawPost); |
500 | - } |
|
501 | - catch (Apache_Solr_HttpTransportException $e) |
|
487 | + } catch (Apache_Solr_HttpTransportException $e) |
|
502 | 488 | { |
503 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
489 | + if ($e->getCode() != 0) { |
|
490 | + //IF NOT COMMUNICATION ERROR |
|
504 | 491 | { |
505 | 492 | throw $e; |
506 | 493 | } |
494 | + } |
|
507 | 495 | } |
508 | 496 | |
509 | 497 | $service = $this->_selectWriteService(true); |
@@ -532,13 +520,14 @@ discard block |
||
532 | 520 | try |
533 | 521 | { |
534 | 522 | return $service->addDocument($document, $allowDups, $overwritePending, $overwriteCommitted); |
535 | - } |
|
536 | - catch (Apache_Solr_HttpTransportException $e) |
|
523 | + } catch (Apache_Solr_HttpTransportException $e) |
|
537 | 524 | { |
538 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
525 | + if ($e->getCode() != 0) { |
|
526 | + //IF NOT COMMUNICATION ERROR |
|
539 | 527 | { |
540 | 528 | throw $e; |
541 | 529 | } |
530 | + } |
|
542 | 531 | } |
543 | 532 | |
544 | 533 | $service = $this->_selectWriteService(true); |
@@ -567,13 +556,14 @@ discard block |
||
567 | 556 | try |
568 | 557 | { |
569 | 558 | return $service->addDocuments($documents, $allowDups, $overwritePending, $overwriteCommitted); |
570 | - } |
|
571 | - catch (Apache_Solr_HttpTransportException $e) |
|
559 | + } catch (Apache_Solr_HttpTransportException $e) |
|
572 | 560 | { |
573 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
561 | + if ($e->getCode() != 0) { |
|
562 | + //IF NOT COMMUNICATION ERROR |
|
574 | 563 | { |
575 | 564 | throw $e; |
576 | 565 | } |
566 | + } |
|
577 | 567 | } |
578 | 568 | |
579 | 569 | $service = $this->_selectWriteService(true); |
@@ -601,13 +591,14 @@ discard block |
||
601 | 591 | try |
602 | 592 | { |
603 | 593 | return $service->commit($optimize, $waitFlush, $waitSearcher, $timeout); |
604 | - } |
|
605 | - catch (Apache_Solr_HttpTransportException $e) |
|
594 | + } catch (Apache_Solr_HttpTransportException $e) |
|
606 | 595 | { |
607 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
596 | + if ($e->getCode() != 0) { |
|
597 | + //IF NOT COMMUNICATION ERROR |
|
608 | 598 | { |
609 | 599 | throw $e; |
610 | 600 | } |
601 | + } |
|
611 | 602 | } |
612 | 603 | |
613 | 604 | $service = $this->_selectWriteService(true); |
@@ -635,13 +626,14 @@ discard block |
||
635 | 626 | try |
636 | 627 | { |
637 | 628 | return $service->delete($rawPost, $timeout); |
638 | - } |
|
639 | - catch (Apache_Solr_HttpTransportException $e) |
|
629 | + } catch (Apache_Solr_HttpTransportException $e) |
|
640 | 630 | { |
641 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
631 | + if ($e->getCode() != 0) { |
|
632 | + //IF NOT COMMUNICATION ERROR |
|
642 | 633 | { |
643 | 634 | throw $e; |
644 | 635 | } |
636 | + } |
|
645 | 637 | } |
646 | 638 | |
647 | 639 | $service = $this->_selectWriteService(true); |
@@ -670,13 +662,14 @@ discard block |
||
670 | 662 | try |
671 | 663 | { |
672 | 664 | return $service->deleteById($id, $fromPending, $fromCommitted, $timeout); |
673 | - } |
|
674 | - catch (Apache_Solr_HttpTransportException $e) |
|
665 | + } catch (Apache_Solr_HttpTransportException $e) |
|
675 | 666 | { |
676 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
667 | + if ($e->getCode() != 0) { |
|
668 | + //IF NOT COMMUNICATION ERROR |
|
677 | 669 | { |
678 | 670 | throw $e; |
679 | 671 | } |
672 | + } |
|
680 | 673 | } |
681 | 674 | |
682 | 675 | $service = $this->_selectWriteService(true); |
@@ -705,13 +698,14 @@ discard block |
||
705 | 698 | try |
706 | 699 | { |
707 | 700 | return $service->deleteByMultipleId($ids, $fromPending, $fromCommitted, $timeout); |
708 | - } |
|
709 | - catch (Apache_Solr_HttpTransportException $e) |
|
701 | + } catch (Apache_Solr_HttpTransportException $e) |
|
710 | 702 | { |
711 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
703 | + if ($e->getCode() != 0) { |
|
704 | + //IF NOT COMMUNICATION ERROR |
|
712 | 705 | { |
713 | 706 | throw $e; |
714 | 707 | } |
708 | + } |
|
715 | 709 | } |
716 | 710 | |
717 | 711 | $service = $this->_selectWriteService(true); |
@@ -740,13 +734,14 @@ discard block |
||
740 | 734 | try |
741 | 735 | { |
742 | 736 | return $service->deleteByQuery($rawQuery, $fromPending, $fromCommitted, $timeout); |
743 | - } |
|
744 | - catch (Apache_Solr_HttpTransportException $e) |
|
737 | + } catch (Apache_Solr_HttpTransportException $e) |
|
745 | 738 | { |
746 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
739 | + if ($e->getCode() != 0) { |
|
740 | + //IF NOT COMMUNICATION ERROR |
|
747 | 741 | { |
748 | 742 | throw $e; |
749 | 743 | } |
744 | + } |
|
750 | 745 | } |
751 | 746 | |
752 | 747 | $service = $this->_selectWriteService(true); |
@@ -782,13 +777,14 @@ discard block |
||
782 | 777 | try |
783 | 778 | { |
784 | 779 | return $service->extract($file, $params, $document, $mimetype); |
785 | - } |
|
786 | - catch (Apache_Solr_HttpTransportException $e) |
|
780 | + } catch (Apache_Solr_HttpTransportException $e) |
|
787 | 781 | { |
788 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
782 | + if ($e->getCode() != 0) { |
|
783 | + //IF NOT COMMUNICATION ERROR |
|
789 | 784 | { |
790 | 785 | throw $e; |
791 | 786 | } |
787 | + } |
|
792 | 788 | } |
793 | 789 | |
794 | 790 | $service = $this->_selectWriteService(true); |
@@ -826,13 +822,14 @@ discard block |
||
826 | 822 | try |
827 | 823 | { |
828 | 824 | return $service->extractFromString($data, $params, $document, $mimetype); |
829 | - } |
|
830 | - catch (Apache_Solr_HttpTransportException $e) |
|
825 | + } catch (Apache_Solr_HttpTransportException $e) |
|
831 | 826 | { |
832 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
827 | + if ($e->getCode() != 0) { |
|
828 | + //IF NOT COMMUNICATION ERROR |
|
833 | 829 | { |
834 | 830 | throw $e; |
835 | 831 | } |
832 | + } |
|
836 | 833 | } |
837 | 834 | |
838 | 835 | $service = $this->_selectWriteService(true); |
@@ -861,13 +858,14 @@ discard block |
||
861 | 858 | try |
862 | 859 | { |
863 | 860 | return $service->optimize($waitFlush, $waitSearcher, $timeout); |
864 | - } |
|
865 | - catch (Apache_Solr_HttpTransportException $e) |
|
861 | + } catch (Apache_Solr_HttpTransportException $e) |
|
866 | 862 | { |
867 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
863 | + if ($e->getCode() != 0) { |
|
864 | + //IF NOT COMMUNICATION ERROR |
|
868 | 865 | { |
869 | 866 | throw $e; |
870 | 867 | } |
868 | + } |
|
871 | 869 | } |
872 | 870 | |
873 | 871 | $service = $this->_selectWriteService(true); |
@@ -897,13 +895,14 @@ discard block |
||
897 | 895 | try |
898 | 896 | { |
899 | 897 | return $service->search($query, $offset, $limit, $params, $method); |
900 | - } |
|
901 | - catch (Apache_Solr_HttpTransportException $e) |
|
898 | + } catch (Apache_Solr_HttpTransportException $e) |
|
902 | 899 | { |
903 | - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR |
|
900 | + if ($e->getCode() != 0) { |
|
901 | + //IF NOT COMMUNICATION ERROR |
|
904 | 902 | { |
905 | 903 | throw $e; |
906 | 904 | } |
905 | + } |
|
907 | 906 | } |
908 | 907 | |
909 | 908 | $service = $this->_selectReadService(true); |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | // See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1) |
40 | 40 | // Doesn't follow typical include path conventions, but is more convenient for users |
41 | -require_once(dirname(__FILE__) . '/Exception.php'); |
|
42 | -require_once(dirname(__FILE__) . '/HttpTransportException.php'); |
|
43 | -require_once(dirname(__FILE__) . '/InvalidArgumentException.php'); |
|
41 | +require_once(dirname(__FILE__).'/Exception.php'); |
|
42 | +require_once(dirname(__FILE__).'/HttpTransportException.php'); |
|
43 | +require_once(dirname(__FILE__).'/InvalidArgumentException.php'); |
|
44 | 44 | |
45 | -require_once(dirname(__FILE__) . '/Document.php'); |
|
46 | -require_once(dirname(__FILE__) . '/Response.php'); |
|
45 | +require_once(dirname(__FILE__).'/Document.php'); |
|
46 | +require_once(dirname(__FILE__).'/Response.php'); |
|
47 | 47 | |
48 | -require_once(dirname(__FILE__) . '/HttpTransport/Interface.php'); |
|
48 | +require_once(dirname(__FILE__).'/HttpTransport/Interface.php'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Starting point for the Solr API. Represents a Solr server resource and has |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | */ |
221 | 221 | static public function phrase($value) |
222 | 222 | { |
223 | - return '"' . self::escapePhrase($value) . '"'; |
|
223 | + return '"'.self::escapePhrase($value).'"'; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -264,17 +264,17 @@ discard block |
||
264 | 264 | |
265 | 265 | foreach ($params as $key => $value) |
266 | 266 | { |
267 | - $escapedParams[] = urlencode($key) . '=' . urlencode($value); |
|
267 | + $escapedParams[] = urlencode($key).'='.urlencode($value); |
|
268 | 268 | } |
269 | 269 | |
270 | - $queryString = $this->_queryDelimiter . implode($this->_queryStringDelimiter, $escapedParams); |
|
270 | + $queryString = $this->_queryDelimiter.implode($this->_queryStringDelimiter, $escapedParams); |
|
271 | 271 | } |
272 | 272 | else |
273 | 273 | { |
274 | 274 | $queryString = ''; |
275 | 275 | } |
276 | 276 | |
277 | - return 'http://' . $this->_host . ':' . $this->_port . $this->_path . $servlet . $queryString; |
|
277 | + return 'http://'.$this->_host.':'.$this->_port.$this->_path.$servlet.$queryString; |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | $this->_extractUrl = $this->_constructUrl(self::EXTRACT_SERVLET); |
287 | 287 | $this->_pingUrl = $this->_constructUrl(self::PING_SERVLET); |
288 | 288 | $this->_searchUrl = $this->_constructUrl(self::SEARCH_SERVLET); |
289 | - $this->_threadsUrl = $this->_constructUrl(self::THREADS_SERVLET, array('wt' => self::SOLR_WRITER )); |
|
290 | - $this->_updateUrl = $this->_constructUrl(self::UPDATE_SERVLET, array('wt' => self::SOLR_WRITER )); |
|
289 | + $this->_threadsUrl = $this->_constructUrl(self::THREADS_SERVLET, array('wt' => self::SOLR_WRITER)); |
|
290 | + $this->_updateUrl = $this->_constructUrl(self::UPDATE_SERVLET, array('wt' => self::SOLR_WRITER)); |
|
291 | 291 | |
292 | 292 | $this->_urlsInited = true; |
293 | 293 | } |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | { |
459 | 459 | $path = trim($path, '/'); |
460 | 460 | |
461 | - $this->_path = '/' . $path . '/'; |
|
461 | + $this->_path = '/'.$path.'/'; |
|
462 | 462 | |
463 | 463 | if ($this->_urlsInited) |
464 | 464 | { |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | // lazy load a default if one has not be set |
477 | 477 | if ($this->_httpTransport === false) |
478 | 478 | { |
479 | - require_once(dirname(__FILE__) . '/HttpTransport/FileGetContents.php'); |
|
479 | + require_once(dirname(__FILE__).'/HttpTransport/FileGetContents.php'); |
|
480 | 480 | |
481 | 481 | $this->_httpTransport = new Apache_Solr_HttpTransport_FileGetContents(); |
482 | 482 | } |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | |
745 | 745 | if ($document->getBoost() !== false) |
746 | 746 | { |
747 | - $xml .= ' boost="' . $document->getBoost() . '"'; |
|
747 | + $xml .= ' boost="'.$document->getBoost().'"'; |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | $xml .= '>'; |
@@ -758,11 +758,11 @@ discard block |
||
758 | 758 | { |
759 | 759 | foreach ($value as $multivalue) |
760 | 760 | { |
761 | - $xml .= '<field name="' . $key . '"'; |
|
761 | + $xml .= '<field name="'.$key.'"'; |
|
762 | 762 | |
763 | 763 | if ($fieldBoost !== false) |
764 | 764 | { |
765 | - $xml .= ' boost="' . $fieldBoost . '"'; |
|
765 | + $xml .= ' boost="'.$fieldBoost.'"'; |
|
766 | 766 | |
767 | 767 | // only set the boost for the first field in the set |
768 | 768 | $fieldBoost = false; |
@@ -770,21 +770,21 @@ discard block |
||
770 | 770 | |
771 | 771 | $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8'); |
772 | 772 | |
773 | - $xml .= '>' . $multivalue . '</field>'; |
|
773 | + $xml .= '>'.$multivalue.'</field>'; |
|
774 | 774 | } |
775 | 775 | } |
776 | 776 | else |
777 | 777 | { |
778 | - $xml .= '<field name="' . $key . '"'; |
|
778 | + $xml .= '<field name="'.$key.'"'; |
|
779 | 779 | |
780 | 780 | if ($fieldBoost !== false) |
781 | 781 | { |
782 | - $xml .= ' boost="' . $fieldBoost . '"'; |
|
782 | + $xml .= ' boost="'.$fieldBoost.'"'; |
|
783 | 783 | } |
784 | 784 | |
785 | 785 | $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); |
786 | 786 | |
787 | - $xml .= '>' . $value . '</field>'; |
|
787 | + $xml .= '>'.$value.'</field>'; |
|
788 | 788 | } |
789 | 789 | } |
790 | 790 | |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | $flushValue = $waitFlush ? 'true' : 'false'; |
825 | 825 | $searcherValue = $waitSearcher ? 'true' : 'false'; |
826 | 826 | |
827 | - $rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />'; |
|
827 | + $rawPost = '<commit expungeDeletes="'.$expungeValue.'" waitFlush="'.$flushValue.'" waitSearcher="'.$searcherValue.'" />'; |
|
828 | 828 | |
829 | 829 | return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); |
830 | 830 | } |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | //escape special xml characters |
864 | 864 | $id = htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8'); |
865 | 865 | |
866 | - $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '"><id>' . $id . '</id></delete>'; |
|
866 | + $rawPost = '<delete fromPending="'.$pendingValue.'" fromCommitted="'.$committedValue.'"><id>'.$id.'</id></delete>'; |
|
867 | 867 | |
868 | 868 | return $this->delete($rawPost, $timeout); |
869 | 869 | } |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | $pendingValue = $fromPending ? 'true' : 'false'; |
885 | 885 | $committedValue = $fromCommitted ? 'true' : 'false'; |
886 | 886 | |
887 | - $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '">'; |
|
887 | + $rawPost = '<delete fromPending="'.$pendingValue.'" fromCommitted="'.$committedValue.'">'; |
|
888 | 888 | |
889 | 889 | foreach ($ids as $id) |
890 | 890 | { |
891 | 891 | //escape special xml characters |
892 | 892 | $id = htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8'); |
893 | 893 | |
894 | - $rawPost .= '<id>' . $id . '</id>'; |
|
894 | + $rawPost .= '<id>'.$id.'</id>'; |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | $rawPost .= '</delete>'; |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | // escape special xml characters |
919 | 919 | $rawQuery = htmlspecialchars($rawQuery, ENT_NOQUOTES, 'UTF-8'); |
920 | 920 | |
921 | - $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '"><query>' . $rawQuery . '</query></delete>'; |
|
921 | + $rawPost = '<delete fromPending="'.$pendingValue.'" fromCommitted="'.$committedValue.'"><query>'.$rawQuery.'</query></delete>'; |
|
922 | 922 | |
923 | 923 | return $this->delete($rawPost, $timeout); |
924 | 924 | } |
@@ -1044,7 +1044,7 @@ discard block |
||
1044 | 1044 | $queryString = $this->_generateQueryString($params); |
1045 | 1045 | |
1046 | 1046 | // the file contents will be sent to SOLR as the POST BODY - we use application/octect-stream as default mimetype |
1047 | - return $this->_sendRawPost($this->_extractUrl . $this->_queryDelimiter . $queryString, $data, false, $mimetype); |
|
1047 | + return $this->_sendRawPost($this->_extractUrl.$this->_queryDelimiter.$queryString, $data, false, $mimetype); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | /** |
@@ -1119,7 +1119,7 @@ discard block |
||
1119 | 1119 | $flushValue = $waitFlush ? 'true' : 'false'; |
1120 | 1120 | $searcherValue = $waitSearcher ? 'true' : 'false'; |
1121 | 1121 | |
1122 | - $rawPost = '<optimize waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />'; |
|
1122 | + $rawPost = '<optimize waitFlush="'.$flushValue.'" waitSearcher="'.$searcherValue.'" />'; |
|
1123 | 1123 | |
1124 | 1124 | return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); |
1125 | 1125 | } |
@@ -1167,7 +1167,7 @@ discard block |
||
1167 | 1167 | |
1168 | 1168 | if ($method == self::METHOD_GET) |
1169 | 1169 | { |
1170 | - return $this->_sendRawGet($this->_searchUrl . $this->_queryDelimiter . $queryString); |
|
1170 | + return $this->_sendRawGet($this->_searchUrl.$this->_queryDelimiter.$queryString); |
|
1171 | 1171 | } |
1172 | 1172 | else if ($method == self::METHOD_POST) |
1173 | 1173 | { |
@@ -268,8 +268,7 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | $queryString = $this->_queryDelimiter . implode($this->_queryStringDelimiter, $escapedParams); |
271 | - } |
|
272 | - else |
|
271 | + } else |
|
273 | 272 | { |
274 | 273 | $queryString = ''; |
275 | 274 | } |
@@ -309,8 +308,7 @@ discard block |
||
309 | 308 | { |
310 | 309 | $queryString = http_build_query($params, null, $this->_queryStringDelimiter); |
311 | 310 | return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString); |
312 | - } |
|
313 | - else |
|
311 | + } else |
|
314 | 312 | { |
315 | 313 | $queryString = http_build_query($params); |
316 | 314 | return preg_replace('/\\[(?:[0-9]|[1-9][0-9]+)\\]=/', '=', $queryString); |
@@ -390,8 +388,7 @@ discard block |
||
390 | 388 | if (empty($host)) |
391 | 389 | { |
392 | 390 | throw new Apache_Solr_InvalidArgumentException('Host parameter is empty'); |
393 | - } |
|
394 | - else |
|
391 | + } else |
|
395 | 392 | { |
396 | 393 | $this->_host = $host; |
397 | 394 | } |
@@ -427,8 +424,7 @@ discard block |
||
427 | 424 | if ($port <= 0) |
428 | 425 | { |
429 | 426 | throw new Apache_Solr_InvalidArgumentException('Port is not a valid port number'); |
430 | - } |
|
431 | - else |
|
427 | + } else |
|
432 | 428 | { |
433 | 429 | $this->_port = $port; |
434 | 430 | } |
@@ -635,8 +631,7 @@ discard block |
||
635 | 631 | if ($solrResponse->getHttpStatus() == 200) |
636 | 632 | { |
637 | 633 | return microtime(true) - $start; |
638 | - } |
|
639 | - else |
|
634 | + } else |
|
640 | 635 | { |
641 | 636 | return false; |
642 | 637 | } |
@@ -772,8 +767,7 @@ discard block |
||
772 | 767 | |
773 | 768 | $xml .= '>' . $multivalue . '</field>'; |
774 | 769 | } |
775 | - } |
|
776 | - else |
|
770 | + } else |
|
777 | 771 | { |
778 | 772 | $xml .= '<field name="' . $key . '"'; |
779 | 773 | |
@@ -950,8 +944,7 @@ discard block |
||
950 | 944 | { |
951 | 945 | throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); |
952 | 946 | } |
953 | - } |
|
954 | - else |
|
947 | + } else |
|
955 | 948 | { |
956 | 949 | $params = array(); |
957 | 950 | } |
@@ -975,8 +968,7 @@ discard block |
||
975 | 968 | |
976 | 969 | // delegate the rest to extractFromString |
977 | 970 | return $this->extractFromString($contents, $params, $document, $mimetype); |
978 | - } |
|
979 | - else |
|
971 | + } else |
|
980 | 972 | { |
981 | 973 | throw new Apache_Solr_InvalidArgumentException("File '{$file}' is empty or could not be read"); |
982 | 974 | } |
@@ -1011,8 +1003,7 @@ discard block |
||
1011 | 1003 | { |
1012 | 1004 | throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); |
1013 | 1005 | } |
1014 | - } |
|
1015 | - else |
|
1006 | + } else |
|
1016 | 1007 | { |
1017 | 1008 | $params = array(); |
1018 | 1009 | } |
@@ -1074,8 +1065,7 @@ discard block |
||
1074 | 1065 | { |
1075 | 1066 | throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); |
1076 | 1067 | } |
1077 | - } |
|
1078 | - else |
|
1068 | + } else |
|
1079 | 1069 | { |
1080 | 1070 | $params = array(); |
1081 | 1071 | } |
@@ -1096,8 +1086,7 @@ discard block |
||
1096 | 1086 | |
1097 | 1087 | // delegate the rest to extractFromString |
1098 | 1088 | return $this->extractFromString($httpResponse->getBody(), $params, $document, $mimetype); |
1099 | - } |
|
1100 | - else |
|
1089 | + } else |
|
1101 | 1090 | { |
1102 | 1091 | throw new Apache_Solr_InvalidArgumentException("URL '{$url}' returned non 200 response code"); |
1103 | 1092 | } |
@@ -1147,8 +1136,7 @@ discard block |
||
1147 | 1136 | // params was specified but was not an array - invalid |
1148 | 1137 | throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); |
1149 | 1138 | } |
1150 | - } |
|
1151 | - else |
|
1139 | + } else |
|
1152 | 1140 | { |
1153 | 1141 | $params = array(); |
1154 | 1142 | } |
@@ -1168,12 +1156,10 @@ discard block |
||
1168 | 1156 | if ($method == self::METHOD_GET) |
1169 | 1157 | { |
1170 | 1158 | return $this->_sendRawGet($this->_searchUrl . $this->_queryDelimiter . $queryString); |
1171 | - } |
|
1172 | - else if ($method == self::METHOD_POST) |
|
1159 | + } else if ($method == self::METHOD_POST) |
|
1173 | 1160 | { |
1174 | 1161 | return $this->_sendRawPost($this->_searchUrl, $queryString, FALSE, 'application/x-www-form-urlencoded; charset=UTF-8'); |
1175 | - } |
|
1176 | - else |
|
1162 | + } else |
|
1177 | 1163 | { |
1178 | 1164 | throw new Apache_Solr_InvalidArgumentException("Unsupported method '$method', please use the Apache_Solr_Service::METHOD_* constants"); |
1179 | 1165 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | |
39 | 39 | // require Apache_Solr_HttpTransport_Response |
40 | -require_once(dirname(__FILE__) . '/Response.php'); |
|
40 | +require_once(dirname(__FILE__).'/Response.php'); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Interface that all Transport (HTTP Requester) implementations must implement. These |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | |
39 | 39 | // Require Apache_Solr_HttpTransport_Abstract |
40 | -require_once(dirname(__FILE__) . '/Abstract.php'); |
|
40 | +require_once(dirname(__FILE__).'/Abstract.php'); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * An alternative Curl HTTP transport that opens and closes a curl session for |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | |
39 | 39 | // Require Apache_Solr_HttpTransport_Abstract |
40 | -require_once(dirname(__FILE__) . '/Abstract.php'); |
|
40 | +require_once(dirname(__FILE__).'/Abstract.php'); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * A Curl based HTTP transport. Uses a single curl session for all requests. |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | |
39 | 39 | // Require Apache_Solr_HttpTransport_Abstract |
40 | -require_once(dirname(__FILE__) . '/Abstract.php'); |
|
40 | +require_once(dirname(__FILE__).'/Abstract.php'); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents |
@@ -81,8 +81,7 @@ |
||
81 | 81 | $timeout = (float) $timeout / 2; |
82 | 82 | |
83 | 83 | stream_context_set_option($this->_getContext, 'http', 'timeout', $timeout); |
84 | - } |
|
85 | - else |
|
84 | + } else |
|
86 | 85 | { |
87 | 86 | // use the default timeout pulled from default_socket_timeout otherwise |
88 | 87 | stream_context_set_option($this->_getContext, 'http', 'timeout', $this->getDefaultTimeout()); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | if (!defined('TYPO3_cliMode')) { |
13 | 13 | |
14 | - die('You cannot run this script directly!'); |
|
14 | + die('You cannot run this script directly!'); |
|
15 | 15 | |
16 | 16 | } |
17 | 17 | |
@@ -25,208 +25,208 @@ discard block |
||
25 | 25 | */ |
26 | 26 | class tx_dlf_cli extends \TYPO3\CMS\Core\Controller\CommandLineController { |
27 | 27 | |
28 | - /** |
|
29 | - * This is the return code. |
|
30 | - * |
|
31 | - * @var integer |
|
32 | - * @access protected |
|
33 | - */ |
|
34 | - protected $return = 0; |
|
28 | + /** |
|
29 | + * This is the return code. |
|
30 | + * |
|
31 | + * @var integer |
|
32 | + * @access protected |
|
33 | + */ |
|
34 | + protected $return = 0; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Main function of the script. |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public function main() { |
|
36 | + /** |
|
37 | + * Main function of the script. |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public function main() { |
|
44 | 44 | |
45 | - switch ((string) $this->cli_args['_DEFAULT'][1]) { |
|
45 | + switch ((string) $this->cli_args['_DEFAULT'][1]) { |
|
46 | 46 | |
47 | - // (Re-)Index a single document. |
|
48 | - case 'index': |
|
47 | + // (Re-)Index a single document. |
|
48 | + case 'index': |
|
49 | 49 | |
50 | - // Add command line arguments. |
|
51 | - $this->cli_options[] = array ('-doc UID/URL', 'UID or (properly encoded) URL of the document.'); |
|
50 | + // Add command line arguments. |
|
51 | + $this->cli_options[] = array ('-doc UID/URL', 'UID or (properly encoded) URL of the document.'); |
|
52 | 52 | |
53 | - $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
|
53 | + $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
|
54 | 54 | |
55 | - $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
|
55 | + $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
|
56 | 56 | |
57 | - // Check the command line arguments. |
|
58 | - $this->cli_validateArgs(); |
|
57 | + // Check the command line arguments. |
|
58 | + $this->cli_validateArgs(); |
|
59 | 59 | |
60 | - if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-doc'][0]) |
|
61 | - && !\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($this->cli_args['-doc'][0])) { |
|
60 | + if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-doc'][0]) |
|
61 | + && !\TYPO3\CMS\Core\Utility\GeneralUtility::isValidUrl($this->cli_args['-doc'][0])) { |
|
62 | 62 | |
63 | - $this->cli_echo('ERROR: "'.$this->cli_args['-doc'][0].'" is not a valid document UID or URL.'.LF, TRUE); |
|
63 | + $this->cli_echo('ERROR: "'.$this->cli_args['-doc'][0].'" is not a valid document UID or URL.'.LF, TRUE); |
|
64 | 64 | |
65 | - $this->return = 1; |
|
65 | + $this->return = 1; |
|
66 | 66 | |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-pid'][0])) { |
|
69 | + if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-pid'][0])) { |
|
70 | 70 | |
71 | - $this->cli_echo('ERROR: "'.$this->cli_args['-pid'][0].'" is not a valid page UID.'.LF, TRUE); |
|
71 | + $this->cli_echo('ERROR: "'.$this->cli_args['-pid'][0].'" is not a valid page UID.'.LF, TRUE); |
|
72 | 72 | |
73 | - $this->return = 1; |
|
73 | + $this->return = 1; |
|
74 | 74 | |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | - if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-core'][0])) { |
|
77 | + if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-core'][0])) { |
|
78 | 78 | |
79 | - $this->cli_echo('ERROR: "'.$this->cli_args['-core'][0].'" is not a valid core UID.'.LF, TRUE); |
|
79 | + $this->cli_echo('ERROR: "'.$this->cli_args['-core'][0].'" is not a valid core UID.'.LF, TRUE); |
|
80 | 80 | |
81 | - $this->return = 1; |
|
81 | + $this->return = 1; |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | - if ($this->return > 0) { |
|
85 | + if ($this->return > 0) { |
|
86 | 86 | |
87 | - break; |
|
87 | + break; |
|
88 | 88 | |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | - // Get the document... |
|
92 | - $doc =& tx_dlf_document::getInstance($this->cli_args['-doc'][0], $this->cli_args['-pid'][0], TRUE); |
|
91 | + // Get the document... |
|
92 | + $doc =& tx_dlf_document::getInstance($this->cli_args['-doc'][0], $this->cli_args['-pid'][0], TRUE); |
|
93 | 93 | |
94 | - if ($doc->ready) { |
|
94 | + if ($doc->ready) { |
|
95 | 95 | |
96 | - // ...and save it to the database... |
|
97 | - if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { |
|
96 | + // ...and save it to the database... |
|
97 | + if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { |
|
98 | 98 | |
99 | - $this->cli_echo('ERROR: Document "'.$this->cli_args['-doc'][0].'" not saved and indexed.'.LF, TRUE); |
|
99 | + $this->cli_echo('ERROR: Document "'.$this->cli_args['-doc'][0].'" not saved and indexed.'.LF, TRUE); |
|
100 | 100 | |
101 | - $this->return = 1; |
|
101 | + $this->return = 1; |
|
102 | 102 | |
103 | - } |
|
103 | + } |
|
104 | 104 | |
105 | - } else { |
|
105 | + } else { |
|
106 | 106 | |
107 | - $this->cli_echo('ERROR: Document "'.$this->cli_args['-doc'][0].'" could not be loaded.'.LF, TRUE); |
|
107 | + $this->cli_echo('ERROR: Document "'.$this->cli_args['-doc'][0].'" could not be loaded.'.LF, TRUE); |
|
108 | 108 | |
109 | - $this->return = 1; |
|
109 | + $this->return = 1; |
|
110 | 110 | |
111 | - } |
|
111 | + } |
|
112 | 112 | |
113 | - break; |
|
113 | + break; |
|
114 | 114 | |
115 | - // Re-index all documents of a collection. |
|
116 | - case 'reindex': |
|
115 | + // Re-index all documents of a collection. |
|
116 | + case 'reindex': |
|
117 | 117 | |
118 | - // Add command line arguments. |
|
119 | - $this->cli_options[] = array ('-coll UID', 'UID of the collection.'); |
|
118 | + // Add command line arguments. |
|
119 | + $this->cli_options[] = array ('-coll UID', 'UID of the collection.'); |
|
120 | 120 | |
121 | - $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
|
121 | + $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
|
122 | 122 | |
123 | - $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
|
123 | + $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
|
124 | 124 | |
125 | - // Check the command line arguments. |
|
126 | - $this->cli_validateArgs(); |
|
125 | + // Check the command line arguments. |
|
126 | + $this->cli_validateArgs(); |
|
127 | 127 | |
128 | - if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-coll'][0])) { |
|
128 | + if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-coll'][0])) { |
|
129 | 129 | |
130 | - $this->cli_echo('ERROR: "'.$this->cli_args['-coll'][0].'" is not a valid collection UID.'.LF, TRUE); |
|
130 | + $this->cli_echo('ERROR: "'.$this->cli_args['-coll'][0].'" is not a valid collection UID.'.LF, TRUE); |
|
131 | 131 | |
132 | - $this->return = 1; |
|
132 | + $this->return = 1; |
|
133 | 133 | |
134 | - } |
|
134 | + } |
|
135 | 135 | |
136 | - if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-pid'][0])) { |
|
136 | + if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-pid'][0])) { |
|
137 | 137 | |
138 | - $this->cli_echo('ERROR: "'.$this->cli_args['-pid'][0].'" is not a valid page UID.'.LF, TRUE); |
|
138 | + $this->cli_echo('ERROR: "'.$this->cli_args['-pid'][0].'" is not a valid page UID.'.LF, TRUE); |
|
139 | 139 | |
140 | - $this->return = 1; |
|
140 | + $this->return = 1; |
|
141 | 141 | |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | - if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-core'][0])) { |
|
144 | + if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->cli_args['-core'][0])) { |
|
145 | 145 | |
146 | - $this->cli_echo('ERROR: "'.$this->cli_args['-core'][0].'" is not a valid core UID.'.LF, TRUE); |
|
146 | + $this->cli_echo('ERROR: "'.$this->cli_args['-core'][0].'" is not a valid core UID.'.LF, TRUE); |
|
147 | 147 | |
148 | - $this->return = 1; |
|
148 | + $this->return = 1; |
|
149 | 149 | |
150 | - } |
|
150 | + } |
|
151 | 151 | |
152 | - if ($this->return > 0) { |
|
152 | + if ($this->return > 0) { |
|
153 | 153 | |
154 | - break; |
|
154 | + break; |
|
155 | 155 | |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | - // Get the collection. |
|
159 | - $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
|
160 | - 'tx_dlf_documents.uid AS uid', |
|
161 | - 'tx_dlf_documents', |
|
162 | - 'tx_dlf_relations', |
|
163 | - 'tx_dlf_collections', |
|
164 | - 'AND tx_dlf_collections.uid='.intval($this->cli_args['-coll'][0]).' AND tx_dlf_collections.pid='.intval($this->cli_args['-pid'][0]).' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations').tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'), |
|
165 | - '', |
|
166 | - '', |
|
167 | - '' |
|
168 | - ); |
|
158 | + // Get the collection. |
|
159 | + $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( |
|
160 | + 'tx_dlf_documents.uid AS uid', |
|
161 | + 'tx_dlf_documents', |
|
162 | + 'tx_dlf_relations', |
|
163 | + 'tx_dlf_collections', |
|
164 | + 'AND tx_dlf_collections.uid='.intval($this->cli_args['-coll'][0]).' AND tx_dlf_collections.pid='.intval($this->cli_args['-pid'][0]).' AND tx_dlf_relations.ident='.$GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations').tx_dlf_helper::whereClause('tx_dlf_documents').tx_dlf_helper::whereClause('tx_dlf_collections'), |
|
165 | + '', |
|
166 | + '', |
|
167 | + '' |
|
168 | + ); |
|
169 | 169 | |
170 | - while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
170 | + while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
|
171 | 171 | |
172 | - // Get the document... |
|
173 | - $doc =& tx_dlf_document::getInstance($resArray['uid'], $this->cli_args['-pid'][0], TRUE); |
|
172 | + // Get the document... |
|
173 | + $doc =& tx_dlf_document::getInstance($resArray['uid'], $this->cli_args['-pid'][0], TRUE); |
|
174 | 174 | |
175 | - if ($doc->ready) { |
|
175 | + if ($doc->ready) { |
|
176 | 176 | |
177 | - // ...and save it to the database... |
|
178 | - if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { |
|
177 | + // ...and save it to the database... |
|
178 | + if (!$doc->save(intval($this->cli_args['-pid'][0]), intval($this->cli_args['-core'][0]))) { |
|
179 | 179 | |
180 | - $this->cli_echo('ERROR: Document "'.$resArray['uid'].'" not saved and indexed.'.LF, TRUE); |
|
180 | + $this->cli_echo('ERROR: Document "'.$resArray['uid'].'" not saved and indexed.'.LF, TRUE); |
|
181 | 181 | |
182 | - $this->return = 1; |
|
182 | + $this->return = 1; |
|
183 | 183 | |
184 | - } |
|
184 | + } |
|
185 | 185 | |
186 | - } else { |
|
186 | + } else { |
|
187 | 187 | |
188 | - $this->cli_echo('ERROR: Document "'.$resArray['uid'].'" could not be loaded.'.LF, TRUE); |
|
188 | + $this->cli_echo('ERROR: Document "'.$resArray['uid'].'" could not be loaded.'.LF, TRUE); |
|
189 | 189 | |
190 | - $this->return = 1; |
|
190 | + $this->return = 1; |
|
191 | 191 | |
192 | - } |
|
192 | + } |
|
193 | 193 | |
194 | - // Clear document registry to prevent memory exhaustion. |
|
195 | - tx_dlf_document::clearRegistry(); |
|
194 | + // Clear document registry to prevent memory exhaustion. |
|
195 | + tx_dlf_document::clearRegistry(); |
|
196 | 196 | |
197 | - } |
|
197 | + } |
|
198 | 198 | |
199 | - break; |
|
199 | + break; |
|
200 | 200 | |
201 | - default: |
|
201 | + default: |
|
202 | 202 | |
203 | - $this->cli_help(); |
|
203 | + $this->cli_help(); |
|
204 | 204 | |
205 | - break; |
|
205 | + break; |
|
206 | 206 | |
207 | - } |
|
207 | + } |
|
208 | 208 | |
209 | - exit ($this->return); |
|
209 | + exit ($this->return); |
|
210 | 210 | |
211 | - } |
|
211 | + } |
|
212 | 212 | |
213 | - public function __construct() { |
|
213 | + public function __construct() { |
|
214 | 214 | |
215 | - // Set basic information about the script. |
|
216 | - $this->cli_help = array ( |
|
217 | - 'name' => 'Command Line Interface for Kitodo.Presentation', |
|
218 | - 'synopsis' => '###OPTIONS###', |
|
219 | - 'description' => 'Currently the only tasks available are "index" and "reindex".'.LF.'Try "/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK" for more options.', |
|
220 | - 'examples' => '/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK -ARG1=VALUE1 -ARG2=VALUE2', |
|
221 | - 'options' => '', |
|
222 | - 'license' => 'GNU GPL - free software!', |
|
223 | - 'author' => 'Kitodo. Key to digital objects e.V. <[email protected]>', |
|
224 | - ); |
|
215 | + // Set basic information about the script. |
|
216 | + $this->cli_help = array ( |
|
217 | + 'name' => 'Command Line Interface for Kitodo.Presentation', |
|
218 | + 'synopsis' => '###OPTIONS###', |
|
219 | + 'description' => 'Currently the only tasks available are "index" and "reindex".'.LF.'Try "/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK" for more options.', |
|
220 | + 'examples' => '/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK -ARG1=VALUE1 -ARG2=VALUE2', |
|
221 | + 'options' => '', |
|
222 | + 'license' => 'GNU GPL - free software!', |
|
223 | + 'author' => 'Kitodo. Key to digital objects e.V. <[email protected]>', |
|
224 | + ); |
|
225 | 225 | |
226 | - // Run parent constructor. |
|
227 | - parent::__construct(); |
|
226 | + // Run parent constructor. |
|
227 | + parent::__construct(); |
|
228 | 228 | |
229 | - } |
|
229 | + } |
|
230 | 230 | |
231 | 231 | } |
232 | 232 |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | case 'index': |
49 | 49 | |
50 | 50 | // Add command line arguments. |
51 | - $this->cli_options[] = array ('-doc UID/URL', 'UID or (properly encoded) URL of the document.'); |
|
51 | + $this->cli_options[] = array('-doc UID/URL', 'UID or (properly encoded) URL of the document.'); |
|
52 | 52 | |
53 | - $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
|
53 | + $this->cli_options[] = array('-pid UID', 'UID of the page the document should be added to.'); |
|
54 | 54 | |
55 | - $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
|
55 | + $this->cli_options[] = array('-core UID', 'UID of the Solr core the document should be added to.'); |
|
56 | 56 | |
57 | 57 | // Check the command line arguments. |
58 | 58 | $this->cli_validateArgs(); |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | // Get the document... |
92 | - $doc =& tx_dlf_document::getInstance($this->cli_args['-doc'][0], $this->cli_args['-pid'][0], TRUE); |
|
92 | + $doc = & tx_dlf_document::getInstance($this->cli_args['-doc'][0], $this->cli_args['-pid'][0], TRUE); |
|
93 | 93 | |
94 | 94 | if ($doc->ready) { |
95 | 95 | |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | case 'reindex': |
117 | 117 | |
118 | 118 | // Add command line arguments. |
119 | - $this->cli_options[] = array ('-coll UID', 'UID of the collection.'); |
|
119 | + $this->cli_options[] = array('-coll UID', 'UID of the collection.'); |
|
120 | 120 | |
121 | - $this->cli_options[] = array ('-pid UID', 'UID of the page the document should be added to.'); |
|
121 | + $this->cli_options[] = array('-pid UID', 'UID of the page the document should be added to.'); |
|
122 | 122 | |
123 | - $this->cli_options[] = array ('-core UID', 'UID of the Solr core the document should be added to.'); |
|
123 | + $this->cli_options[] = array('-core UID', 'UID of the Solr core the document should be added to.'); |
|
124 | 124 | |
125 | 125 | // Check the command line arguments. |
126 | 126 | $this->cli_validateArgs(); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { |
171 | 171 | |
172 | 172 | // Get the document... |
173 | - $doc =& tx_dlf_document::getInstance($resArray['uid'], $this->cli_args['-pid'][0], TRUE); |
|
173 | + $doc = & tx_dlf_document::getInstance($resArray['uid'], $this->cli_args['-pid'][0], TRUE); |
|
174 | 174 | |
175 | 175 | if ($doc->ready) { |
176 | 176 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | public function __construct() { |
214 | 214 | |
215 | 215 | // Set basic information about the script. |
216 | - $this->cli_help = array ( |
|
216 | + $this->cli_help = array( |
|
217 | 217 | 'name' => 'Command Line Interface for Kitodo.Presentation', |
218 | 218 | 'synopsis' => '###OPTIONS###', |
219 | 219 | 'description' => 'Currently the only tasks available are "index" and "reindex".'.LF.'Try "/PATH/TO/TYPO3/cli_dispatch.phpsh dlf TASK" for more options.', |