Changeset 82769 in spip-zone
- Timestamp:
- May 27, 2014, 7:31:25 AM (7 years ago)
- Location:
- _plugins_/indexer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/indexer/trunk/iterateur/sphinx.php
r82747 r82769 101 101 102 102 $this->command = $command + array( 103 'index' => array(), 104 'selection' => array(), 105 'recherche' => array(), 106 'orderby' => array(), 107 'group' => array(), 108 'snippet' => array(), 109 'facet' => array(), 110 'filter' => array(), 103 'index' => array(), 104 'selection' => array(), 105 'recherche' => array(), 106 'orderby' => array(), 107 'group' => array(), 108 'snippet' => array(), 109 'facet' => array(), 110 'filter' => array(), 111 'filters_mono' => array(), 112 'filters_multijson' => array(), 111 113 ); 112 114 … … 127 129 128 130 $this->setFilter($this->command['filter']); 131 $this->setFiltersMono($this->command['filters_mono']); 132 $this->setFiltersMultiJson($this->command['filters_multijson']); 129 133 130 134 $this->setSnippet($this->command); … … 576 580 } 577 581 } 578 579 582 583 function setFiltersMono($filters){ 584 $filters = array_filter($filters); 585 if (!$filters) { 586 return false; 587 } 588 589 $ok = true; 590 foreach ($filters as $filter){ 591 $ok &= $this->queryApi->setApiFilterMono($filter); 592 } 593 594 return $ok; 595 } 596 597 function setFiltersMultiJson($filters){ 598 $filters = array_filter($filters); 599 if (!$filters) { 600 return false; 601 } 602 603 $ok = true; 604 foreach ($filters as $filter){ 605 $ok &= $this->queryApi->setApiFilterMultiJson($filter); 606 } 607 608 return $ok; 609 } 610 580 611 /** 581 612 * Revenir au depart … … 765 796 } 766 797 798 /** 799 * Indiquer les filtres mono-valués de la requête 800 * 801 * @param string $idb 802 * @param object $boucles 803 * @param object $crit 804 */ 805 function critere_SPHINX_filtermono_dist($idb, &$boucles, $crit) { 806 $boucle = &$boucles[$idb]; 807 808 if (isset($crit->param[0])) { 809 $test = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent); 810 } 811 if (isset($crit->param[1])) { 812 $field = calculer_liste($crit->param[1], array(), $boucles, $boucles[$idb]->id_parent); 813 } 814 if (isset($crit->param[2])) { 815 $values = calculer_liste($crit->param[2], array(), $boucles, $boucles[$idb]->id_parent); 816 } 817 if (isset($crit->param[3])) { 818 $comparison = calculer_liste($crit->param[3], array(), $boucles, $boucles[$idb]->id_parent); 819 } 820 821 // Test 822 $boucle->hash .= "\n\tif ($test) {\n"; 823 824 // Critere multiple 825 $boucle->hash .= "\t\tif (!isset(\$filters_mono_init)) { \$command['filters_mono'] = array(); \$filters_mono_init = true; }\n"; 826 827 $boucle->hash .= "\t\t\$command['filters_mono'][] = array(\n" 828 . (isset($crit->param[1]) ? "\t\t\t'field' => $field,\n" : '') 829 . (isset($crit->param[2]) ? "\t\t\t'values' => $values,\n" : '') 830 . (isset($crit->param[3]) ? "\t\t\t'comparison' => $comparison,\n" : '') 831 . "\t\t);\n"; 832 833 // Fin de test 834 $boucle->hash .= "\t}\n"; 835 } 836 837 /** 838 * Indiquer les filtres multi-valués JSON de la requête 839 * 840 * @param string $idb 841 * @param object $boucles 842 * @param object $crit 843 */ 844 function critere_SPHINX_filtermultijson_dist($idb, &$boucles, $crit) { 845 $boucle = &$boucles[$idb]; 846 847 if (isset($crit->param[0])) { 848 $test = calculer_liste($crit->param[0], array(), $boucles, $boucles[$idb]->id_parent); 849 } 850 if (isset($crit->param[1])) { 851 $field = calculer_liste($crit->param[1], array(), $boucles, $boucles[$idb]->id_parent); 852 } 853 if (isset($crit->param[2])) { 854 $values = calculer_liste($crit->param[2], array(), $boucles, $boucles[$idb]->id_parent); 855 } 856 857 // Test 858 $boucle->hash .= "\n\tif ($test) {\n"; 859 860 // Critere multiple 861 $boucle->hash .= "\t\tif (!isset(\$filters_multijson_init)) { \$command['filters_multijson'] = array(); \$filters_multijson_init = true; }\n"; 862 863 $boucle->hash .= "\t\t\$command['filters_multijson'][] = array(\n" 864 . (isset($crit->param[1]) ? "\t\t\t'field' => $field,\n" : '') 865 . (isset($crit->param[2]) ? "\t\t\t'values' => $values,\n" : '') 866 . "\t\t);\n"; 867 868 // Fin de test 869 $boucle->hash .= "\t}\n"; 870 } 767 871 768 872 /** -
_plugins_/indexer/trunk/lib/Sphinx/SphinxQL/QueryApi.php
r82741 r82769 362 362 switch ($filter['type']) { 363 363 case 'mono': 364 $ok &= $this->set FilterMono($filter);364 $ok &= $this->setApiFilterMono($filter); 365 365 break; 366 366 case 'multi_json': 367 $ok &= $this->set FilterMultiJson($filter);367 $ok &= $this->setApiFilterMultiJson($filter); 368 368 break; 369 369 } … … 380 380 * @return bool Return true if the filter has been added 381 381 */ 382 public function set FilterMono($filter) {382 public function setApiFilterMono($filter) { 383 383 if ( 384 384 !isset($filter['field']) … … 428 428 * Return true if the filter has been added 429 429 */ 430 public function set FilterMultiJson($filter) {430 public function setApiFilterMultiJson($filter) { 431 431 static $as_count = 0; 432 432
Note: See TracChangeset
for help on using the changeset viewer.