Changeset 82628 in spip-zone
- Timestamp:
- May 20, 2014, 8:01:50 PM (7 years ago)
- Location:
- _plugins_/indexer/trunk
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/indexer/trunk/aside/sphinx.html
r82462 r82628 5 5 6 6 [(#INCLURE{fond=inclure/liste_sphinx_facette, env, 7 facette=properties.authors,7 critere=properties.authors, 8 8 cle=auteur, 9 9 titre=Liste des auteurs, … … 13 13 14 14 [(#INCLURE{fond=inclure/liste_sphinx_facette, env, 15 facette=properties.tags,15 critere=properties.tags, 16 16 cle=tag, 17 17 titre=Liste des tags, … … 20 20 21 21 [(#INCLURE{fond=inclure/liste_sphinx_facette, env, 22 facette=YEAR(date),22 critere=YEAR(date), 23 23 cle=annee, 24 24 titre=Par année, 25 25 texte_vide=Non renseignée, 26 order=date DESC 26 tri=date, 27 sens_tri=-1 27 28 })] 28 29 -
_plugins_/indexer/trunk/inclure/liste_sphinx_facette.html
r82537 r82628 1 [(#ENV{order}|=={date}|?{#SET{order,date DESC}})]2 1 3 [(#SET{sqlf, [(#ENV{source,spip} 4 |sphinx_get_query_facette{ 5 #ENV{facette}, 6 #ENV{cle}, 7 #ENV*{recherche}, 8 #GET{order}})]})] 2 #SET{tri,#ENV{tri,nb}} 3 #SET{sens_tri,#ENV{sens_tri,DESC}} 4 #SET{groupby,#ENV{critere}} 9 5 10 <BOUCLE_resultats(DATA) {source SphinxQL, #GET{sqlf}}> 11 <B_facette> 12 <h2>#ENV{titre}</h2> 13 <div class='liste'> 14 <ul class='liste-items'> 15 <BOUCLE_facette(DATA){source tableau, #DOCS}{0, 10}> 16 <li class='item'> 17 <a href="[(#SELF|parametre_url{#ENV{cle},[(#VALEUR{facette}|sinon{-})]})]"> 18 [(#VALEUR{facette}|sinon{<i>#ENV{texte_vide}</i>})] 19 </a> (#VALEUR{c} documents) 20 </li> 21 </BOUCLE_facette> 22 </ul> 23 </div> 24 </B_facette> 25 </BOUCLE_resultats> 6 [(#ENV{critere}|match{'\[\(\]'}|oui) 7 #SET{groupby,valeur} 8 ] 9 10 <B_resultats_facette> 11 <h2>#ENV{titre}</h2> 12 <div class='liste'> 13 <ul class='liste-items'> 14 <BOUCLE_resultats_facette(SPHINX2) 15 {index #ENV{source,spip}} 16 {recherche #ENV*{recherche}} 17 18 {select COUNT(*) AS nb} 19 {select GROUPBY() AS facette} 20 {select (#ENV{critere}|concat{' '}) AS valeur} 21 22 {groupby #GET{groupby}} 23 24 {filter #ENV{annee}, 'YEAR(date) = @valeur' } 25 {filter #ENV{tag}, 'IN(properties.tags, @valeurs)', 'LENGTH(properties.tags) = 0'} 26 {filter #ENV{auteur}, 'IN(properties.authors, @valeurs)', 'LENGTH(properties.authors) = 0'} 27 28 {par #GET{tri}}{inverse #GET{sens_tri}} 29 30 {0,10} 31 > 32 <li class='item'> 33 <a href="[(#SELF|parametre_url{#ENV{cle},[(#FACETTE|sinon{-})]})]"> 34 [(#FACETTE|sinon{<i>#ENV{texte_vide}</i>})] 35 </a> (#NB documents) 36 </li> 37 </BOUCLE_resultats_facette> 38 </ul> 39 </div> 40 </B_resultats_facette> -
_plugins_/indexer/trunk/iterateur/sphinx.php
r82627 r82628 103 103 'selection' => array(), 104 104 'recherche' => array(), 105 'orderby' => array(), 106 'groupby' => array(), 105 107 'snippet' => array(), 106 108 'facet' => array(), 107 'filter' => array(),109 'filter' => array(), 108 110 ); 109 111 … … 119 121 $this->setSelection($this->command['selection']); 120 122 $this->setRecherche($this->command['recherche']); 121 $this->setOrderBy($this->command['orderby']); 123 $this->setOrderBy($this->command['order']); 124 $this->setGroupBy($this->command['groupby']); 122 125 $this->setFacet($this->command['facet']); 123 126 … … 239 242 } 240 243 $this->queryApi->orderby($order); 244 } 245 return true; 246 } 247 248 249 public function setGroupby($groupby) { 250 if (!is_array($groupby)) $groupby = array($groupby); 251 $groupby = array_filter($groupby); 252 if (!$groupby) { 253 return false; 254 } 255 foreach ($groupby as $group) { 256 $this->queryApi->groupby($group); 241 257 } 242 258 return true; -
_plugins_/indexer/trunk/iterateur/sphinx2.php
r82627 r82628 109 109 'selection' => array(), 110 110 'recherche' => array(), 111 'orderby' => array(), 112 'group' => array(), 111 113 'snippet' => array(), 112 114 'facet' => array(), 113 'filter' => array(),115 'filter' => array(), 114 116 ); 115 117 … … 126 128 $this->setRecherche($this->command['recherche']); 127 129 $this->setOrderBy($this->command['orderby']); 130 $this->setGroupBy($this->command['group']); // groupby interfère avec spip :/ 128 131 $this->setFacet($this->command['facet']); 129 132 … … 249 252 } 250 253 $this->queryApi->orderby($order); 254 } 255 return true; 256 } 257 258 public function setGroupby($groupby) { 259 if (!is_array($groupby)) $groupby = array($groupby); 260 $groupby = array_filter($groupby); 261 if (!$groupby) { 262 return false; 263 } 264 foreach ($groupby as $group) { 265 $this->queryApi->groupby($group); 251 266 } 252 267 return true; … … 475 490 */ 476 491 public function rewind() { 492 if (!is_array($this->result['docs'])) return false; 477 493 reset($this->result['docs']); 478 494 list($this->cle, $this->valeur) = each($this->result['docs']); … … 585 601 586 602 /** 603 * Indiquer les group by de la requête 604 * 605 * @param string $idb 606 * @param object $boucles 607 * @param object $crit 608 */ 609 function critere_SPHINX2_groupby_dist($idb, &$boucles, $crit) { 610 $boucle = &$boucles[$idb]; 611 // critere multiple 612 $boucle->hash .= "\n\tif (!isset(\$group_init)) { \$command['group'] = array(); \$group_init = true; }\n"; 613 614 foreach ($crit->param as $param){ 615 $boucle->hash .= "\t\$command['group'][] = " 616 . calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent) . ";\n"; 617 } 618 } 619 620 621 /** 587 622 * Indiquer les snippets de la requête 588 623 * … … 708 743 $t = $order.$sens; 709 744 $boucle->order[] = $t; 710 }711 }712 713 function critere_SPHINX2_pages_dist($idb, &$boucles, $crit) {714 $boucle = &$boucles[$idb];715 716 // critere multiple717 $boucle->hash .= "\n\tif (!isset(\$pagination_init)) { \$command['pagination'] = array(); \$pagination_init = true; }\n";718 719 foreach ($crit->param as $param){720 $boucle->hash .= "\t\$command['pagination'][] = "721 . calculer_liste($param, array(), $boucles, $boucles[$idb]->id_parent) . ";\n";722 745 } 723 746 } -
_plugins_/indexer/trunk/liste/sphinx_documents.html
r82620 r82628 9 9 [<div class="pagination">(#DEBUT_DOCUMENTS|?{#PAGINATION,#ANCRE_PAGINATION})</div>] 10 10 <ul class='liste-items'> 11 <BOUCLE_documents(DATA){source tableau, #DOCS}{pagination 100}>11 <BOUCLE_documents(DATA){source tableau, #DOCS}{pagination 20}> 12 12 [(#SET{properties,#PROPERTIES|json_decode{1}})] 13 13 <li class='item'>
Note: See TracChangeset
for help on using the changeset viewer.