@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | **/ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -24,32 +24,32 @@ discard block |
||
| 24 | 24 | * Code HTML et javascript |
| 25 | 25 | */ |
| 26 | 26 | function choisir_rubriques_admin_restreint( |
| 27 | - $id_auteur, |
|
| 28 | - $label = '', |
|
| 29 | - $sel_css = '#liste_rubriques_restreintes', |
|
| 30 | - $img_remove = '' |
|
| 27 | + $id_auteur, |
|
| 28 | + $label = '', |
|
| 29 | + $sel_css = '#liste_rubriques_restreintes', |
|
| 30 | + $img_remove = '' |
|
| 31 | 31 | ) { |
| 32 | - global $spip_lang; |
|
| 33 | - $res = ''; |
|
| 34 | - // Ajouter une rubrique a un administrateur restreint |
|
| 35 | - if ( |
|
| 36 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc') |
|
| 37 | - and $a = $chercher_rubrique(0, 'auteur', false) |
|
| 38 | - ) { |
|
| 39 | - if ($img_remove) { |
|
| 40 | - $img_remove = addslashes("<a href=\"#\" onclick=\"jQuery(this).parent().remove();return false;\" class=\"removelink\">$img_remove</a>"); |
|
| 41 | - } |
|
| 32 | + global $spip_lang; |
|
| 33 | + $res = ''; |
|
| 34 | + // Ajouter une rubrique a un administrateur restreint |
|
| 35 | + if ( |
|
| 36 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc') |
|
| 37 | + and $a = $chercher_rubrique(0, 'auteur', false) |
|
| 38 | + ) { |
|
| 39 | + if ($img_remove) { |
|
| 40 | + $img_remove = addslashes("<a href=\"#\" onclick=\"jQuery(this).parent().remove();return false;\" class=\"removelink\">$img_remove</a>"); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $res = |
|
| 44 | - "\n<div id='ajax_rubrique'>\n" |
|
| 45 | - . "<label>$label</label>\n" |
|
| 46 | - . "<input name='id_auteur' value='$id_auteur' type='hidden' />\n" |
|
| 47 | - . $a |
|
| 48 | - . "</div>\n" |
|
| 43 | + $res = |
|
| 44 | + "\n<div id='ajax_rubrique'>\n" |
|
| 45 | + . "<label>$label</label>\n" |
|
| 46 | + . "<input name='id_auteur' value='$id_auteur' type='hidden' />\n" |
|
| 47 | + . $a |
|
| 48 | + . "</div>\n" |
|
| 49 | 49 | |
| 50 | - // onchange = pour le menu |
|
| 51 | - // l'evenement doit etre provoque a la main par le selecteur ajax |
|
| 52 | - . "<script type='text/javascript'>/*<![CDATA[*/ |
|
| 50 | + // onchange = pour le menu |
|
| 51 | + // l'evenement doit etre provoque a la main par le selecteur ajax |
|
| 52 | + . "<script type='text/javascript'>/*<![CDATA[*/ |
|
| 53 | 53 | jQuery(function($){ |
| 54 | 54 | $('#id_parent').on('change', function(){ |
| 55 | 55 | var id_parent = parseInt(this.value); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | .attr('name','noname'); |
| 69 | 69 | }); |
| 70 | 70 | /*]]>*/</script>"; |
| 71 | - } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $res; |
|
| 73 | + return $res; |
|
| 74 | 74 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -39,65 +39,65 @@ discard block |
||
| 39 | 39 | * Contexte à transmettre au squelette du formulaire sinon |
| 40 | 40 | */ |
| 41 | 41 | function formulaires_traduire_charger_dist($objet, $id_objet, $retour = '', $traduire = true) { |
| 42 | - if (!intval($id_objet)) { |
|
| 43 | - return false; |
|
| 44 | - } |
|
| 45 | - $valeurs = formulaires_editer_objet_charger($objet, $id_objet, null, 0, $retour, ''); |
|
| 46 | - // verifier que l'objet indique possede bien des champs id_trad et lang |
|
| 47 | - // attention, charger renomme lang => langue pour ne pas perturber la langue d'affichage du squelette |
|
| 48 | - if (!isset($valeurs['langue'])) { |
|
| 49 | - return false; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $valeurs['editable'] = autoriser('changerlangue', $objet, $id_objet); |
|
| 53 | - $valeurs['_langue'] = ''; |
|
| 54 | - $langue_parent = ''; |
|
| 55 | - $id_parent = ''; |
|
| 56 | - if (isset($valeurs['id_rubrique'])) { |
|
| 57 | - $id_parent = $valeurs['id_rubrique']; |
|
| 58 | - } |
|
| 59 | - if (isset($valeurs['id_parent'])) { |
|
| 60 | - $id_parent = $valeurs['id_parent']; |
|
| 61 | - } |
|
| 62 | - if ($id_parent) { |
|
| 63 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if (!$langue_parent) { |
|
| 67 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 68 | - } |
|
| 69 | - if ( |
|
| 70 | - $valeurs['editable'] |
|
| 71 | - and in_array(table_objet_sql($objet), explode(',', $GLOBALS['meta']['multi_objets'])) |
|
| 72 | - ) { |
|
| 73 | - $valeurs['_langue'] = $valeurs['langue']; |
|
| 74 | - } |
|
| 75 | - $valeurs['langue_parent'] = $langue_parent; |
|
| 76 | - |
|
| 77 | - $valeurs['_objet'] = $objet; |
|
| 78 | - $valeurs['_id_objet'] = $id_objet; |
|
| 79 | - $valeurs['changer_lang'] = ''; |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - $valeurs['_traduisible'] = autoriser('changertraduction', $objet, $id_objet); |
|
| 83 | - $valeurs['_traduire'] = ''; |
|
| 84 | - if (isset($valeurs['id_trad'])) { |
|
| 85 | - $valeurs['_traduire'] = ($traduire ? ' ' : ''); |
|
| 86 | - $valeurs['_vue_traductions'] = 'prive/objets/liste/' . (trouver_fond( |
|
| 87 | - $f = table_objet($objet) . '-trad', |
|
| 88 | - 'prive/objets/liste' |
|
| 89 | - ) ? $f : 'objets-trad'); |
|
| 90 | - // pour afficher la liste des trad sur la base de l'id_trad en base |
|
| 91 | - // independamment d'une saisie en cours sur id_trad |
|
| 92 | - $valeurs['_lister_id_trad'] = $valeurs['id_trad']; |
|
| 93 | - $valeurs['_id_parent'] = $id_parent; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $valeurs['_saisie_en_cours'] = (!_request('annuler') and (_request('changer_lang') !== null |
|
| 97 | - or _request('changer_id_trad') !== null)); |
|
| 98 | - $valeurs['_pipeline'] = ['traduire', ['type' => $objet, 'id' => $id_objet]]; |
|
| 99 | - |
|
| 100 | - return $valeurs; |
|
| 42 | + if (!intval($id_objet)) { |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 45 | + $valeurs = formulaires_editer_objet_charger($objet, $id_objet, null, 0, $retour, ''); |
|
| 46 | + // verifier que l'objet indique possede bien des champs id_trad et lang |
|
| 47 | + // attention, charger renomme lang => langue pour ne pas perturber la langue d'affichage du squelette |
|
| 48 | + if (!isset($valeurs['langue'])) { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $valeurs['editable'] = autoriser('changerlangue', $objet, $id_objet); |
|
| 53 | + $valeurs['_langue'] = ''; |
|
| 54 | + $langue_parent = ''; |
|
| 55 | + $id_parent = ''; |
|
| 56 | + if (isset($valeurs['id_rubrique'])) { |
|
| 57 | + $id_parent = $valeurs['id_rubrique']; |
|
| 58 | + } |
|
| 59 | + if (isset($valeurs['id_parent'])) { |
|
| 60 | + $id_parent = $valeurs['id_parent']; |
|
| 61 | + } |
|
| 62 | + if ($id_parent) { |
|
| 63 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if (!$langue_parent) { |
|
| 67 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 68 | + } |
|
| 69 | + if ( |
|
| 70 | + $valeurs['editable'] |
|
| 71 | + and in_array(table_objet_sql($objet), explode(',', $GLOBALS['meta']['multi_objets'])) |
|
| 72 | + ) { |
|
| 73 | + $valeurs['_langue'] = $valeurs['langue']; |
|
| 74 | + } |
|
| 75 | + $valeurs['langue_parent'] = $langue_parent; |
|
| 76 | + |
|
| 77 | + $valeurs['_objet'] = $objet; |
|
| 78 | + $valeurs['_id_objet'] = $id_objet; |
|
| 79 | + $valeurs['changer_lang'] = ''; |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + $valeurs['_traduisible'] = autoriser('changertraduction', $objet, $id_objet); |
|
| 83 | + $valeurs['_traduire'] = ''; |
|
| 84 | + if (isset($valeurs['id_trad'])) { |
|
| 85 | + $valeurs['_traduire'] = ($traduire ? ' ' : ''); |
|
| 86 | + $valeurs['_vue_traductions'] = 'prive/objets/liste/' . (trouver_fond( |
|
| 87 | + $f = table_objet($objet) . '-trad', |
|
| 88 | + 'prive/objets/liste' |
|
| 89 | + ) ? $f : 'objets-trad'); |
|
| 90 | + // pour afficher la liste des trad sur la base de l'id_trad en base |
|
| 91 | + // independamment d'une saisie en cours sur id_trad |
|
| 92 | + $valeurs['_lister_id_trad'] = $valeurs['id_trad']; |
|
| 93 | + $valeurs['_id_parent'] = $id_parent; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $valeurs['_saisie_en_cours'] = (!_request('annuler') and (_request('changer_lang') !== null |
|
| 97 | + or _request('changer_id_trad') !== null)); |
|
| 98 | + $valeurs['_pipeline'] = ['traduire', ['type' => $objet, 'id' => $id_objet]]; |
|
| 99 | + |
|
| 100 | + return $valeurs; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -115,32 +115,32 @@ discard block |
||
| 115 | 115 | * Erreurs des saisies |
| 116 | 116 | */ |
| 117 | 117 | function formulaires_traduire_verifier_dist($objet, $id_objet, $retour = '', $traduire = true) { |
| 118 | - $erreurs = []; |
|
| 119 | - |
|
| 120 | - if (null !== _request('changer_lang')) { |
|
| 121 | - $erreurs = formulaires_editer_objet_verifier($objet, $id_objet, ['changer_lang']); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // si id_trad fourni, verifier que cela ne conflicte pas avec un id_trad existant |
|
| 125 | - // et que ca reference bien un objet existant |
|
| 126 | - if ($id_trad = _request('id_trad')) { |
|
| 127 | - $table_objet_sql = table_objet_sql($objet); |
|
| 128 | - $_id_table_objet = id_table_objet($objet); |
|
| 129 | - if ( |
|
| 130 | - sql_getfetsel( |
|
| 131 | - 'id_trad', |
|
| 132 | - $table_objet_sql, |
|
| 133 | - "$_id_table_objet=" . intval($id_objet) |
|
| 134 | - ) |
|
| 135 | - ) { |
|
| 136 | - // ne devrait jamais arriver sauf concurence de saisie |
|
| 137 | - $erreurs['id_trad'] = _L('Une traduction est deja referencee'); |
|
| 138 | - } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=" . intval($id_trad))) { |
|
| 139 | - $erreurs['id_trad'] = _L('Indiquez un contenu existant'); |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - return $erreurs; |
|
| 118 | + $erreurs = []; |
|
| 119 | + |
|
| 120 | + if (null !== _request('changer_lang')) { |
|
| 121 | + $erreurs = formulaires_editer_objet_verifier($objet, $id_objet, ['changer_lang']); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // si id_trad fourni, verifier que cela ne conflicte pas avec un id_trad existant |
|
| 125 | + // et que ca reference bien un objet existant |
|
| 126 | + if ($id_trad = _request('id_trad')) { |
|
| 127 | + $table_objet_sql = table_objet_sql($objet); |
|
| 128 | + $_id_table_objet = id_table_objet($objet); |
|
| 129 | + if ( |
|
| 130 | + sql_getfetsel( |
|
| 131 | + 'id_trad', |
|
| 132 | + $table_objet_sql, |
|
| 133 | + "$_id_table_objet=" . intval($id_objet) |
|
| 134 | + ) |
|
| 135 | + ) { |
|
| 136 | + // ne devrait jamais arriver sauf concurence de saisie |
|
| 137 | + $erreurs['id_trad'] = _L('Une traduction est deja referencee'); |
|
| 138 | + } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=" . intval($id_trad))) { |
|
| 139 | + $erreurs['id_trad'] = _L('Indiquez un contenu existant'); |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + return $erreurs; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | |
@@ -159,32 +159,32 @@ discard block |
||
| 159 | 159 | * Retour des traitements |
| 160 | 160 | */ |
| 161 | 161 | function formulaires_traduire_traiter_dist($objet, $id_objet, $retour = '', $traduire = true) { |
| 162 | - $res = []; |
|
| 163 | - if (!_request('annuler') and autoriser('changerlangue', $objet, $id_objet)) { |
|
| 164 | - // action/editer_xxx doit traiter la modif de changer_lang |
|
| 165 | - $res = formulaires_editer_objet_traiter($objet, $id_objet, 0, 0, $retour); |
|
| 166 | - } |
|
| 167 | - if (!_request('annuler') and autoriser('changertraduction', $objet, $id_objet)) { |
|
| 168 | - if ($id_trad = _request('id_trad') or _request('supprimer_trad')) { |
|
| 169 | - $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 170 | - $referencer_traduction($objet, $id_objet, intval($id_trad)); // 0 si supprimer_trad |
|
| 171 | - } elseif ( |
|
| 172 | - $new_id_trad = _request('changer_reference_trad') |
|
| 173 | - and $new_id_trad = array_keys($new_id_trad) |
|
| 174 | - and $new_id_trad = reset($new_id_trad) |
|
| 175 | - ) { |
|
| 176 | - $table_objet_sql = table_objet_sql($objet); |
|
| 177 | - $_id_table_objet = id_table_objet($objet); |
|
| 178 | - if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=" . intval($id_objet))) { |
|
| 179 | - $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 180 | - $referencer_traduction($objet, $id_trad, $new_id_trad); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - $res['editable'] = true; |
|
| 185 | - if (!isset($res['message_erreur'])) { |
|
| 186 | - set_request('annuler', 'annuler'); |
|
| 187 | - } // provoquer la fermeture du forumlaire |
|
| 188 | - |
|
| 189 | - return $res; |
|
| 162 | + $res = []; |
|
| 163 | + if (!_request('annuler') and autoriser('changerlangue', $objet, $id_objet)) { |
|
| 164 | + // action/editer_xxx doit traiter la modif de changer_lang |
|
| 165 | + $res = formulaires_editer_objet_traiter($objet, $id_objet, 0, 0, $retour); |
|
| 166 | + } |
|
| 167 | + if (!_request('annuler') and autoriser('changertraduction', $objet, $id_objet)) { |
|
| 168 | + if ($id_trad = _request('id_trad') or _request('supprimer_trad')) { |
|
| 169 | + $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 170 | + $referencer_traduction($objet, $id_objet, intval($id_trad)); // 0 si supprimer_trad |
|
| 171 | + } elseif ( |
|
| 172 | + $new_id_trad = _request('changer_reference_trad') |
|
| 173 | + and $new_id_trad = array_keys($new_id_trad) |
|
| 174 | + and $new_id_trad = reset($new_id_trad) |
|
| 175 | + ) { |
|
| 176 | + $table_objet_sql = table_objet_sql($objet); |
|
| 177 | + $_id_table_objet = id_table_objet($objet); |
|
| 178 | + if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=" . intval($id_objet))) { |
|
| 179 | + $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 180 | + $referencer_traduction($objet, $id_trad, $new_id_trad); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + $res['editable'] = true; |
|
| 185 | + if (!isset($res['message_erreur'])) { |
|
| 186 | + set_request('annuler', 'annuler'); |
|
| 187 | + } // provoquer la fermeture du forumlaire |
|
| 188 | + |
|
| 189 | + return $res; |
|
| 190 | 190 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $id_parent = $valeurs['id_parent']; |
| 61 | 61 | } |
| 62 | 62 | if ($id_parent) { |
| 63 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)); |
|
| 63 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_parent)); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!$langue_parent) { |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | $valeurs['_traduire'] = ''; |
| 84 | 84 | if (isset($valeurs['id_trad'])) { |
| 85 | 85 | $valeurs['_traduire'] = ($traduire ? ' ' : ''); |
| 86 | - $valeurs['_vue_traductions'] = 'prive/objets/liste/' . (trouver_fond( |
|
| 87 | - $f = table_objet($objet) . '-trad', |
|
| 86 | + $valeurs['_vue_traductions'] = 'prive/objets/liste/'.(trouver_fond( |
|
| 87 | + $f = table_objet($objet).'-trad', |
|
| 88 | 88 | 'prive/objets/liste' |
| 89 | 89 | ) ? $f : 'objets-trad'); |
| 90 | 90 | // pour afficher la liste des trad sur la base de l'id_trad en base |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | sql_getfetsel( |
| 131 | 131 | 'id_trad', |
| 132 | 132 | $table_objet_sql, |
| 133 | - "$_id_table_objet=" . intval($id_objet) |
|
| 133 | + "$_id_table_objet=".intval($id_objet) |
|
| 134 | 134 | ) |
| 135 | 135 | ) { |
| 136 | 136 | // ne devrait jamais arriver sauf concurence de saisie |
| 137 | 137 | $erreurs['id_trad'] = _L('Une traduction est deja referencee'); |
| 138 | - } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=" . intval($id_trad))) { |
|
| 138 | + } elseif (!sql_getfetsel($_id_table_objet, $table_objet_sql, "$_id_table_objet=".intval($id_trad))) { |
|
| 139 | 139 | $erreurs['id_trad'] = _L('Indiquez un contenu existant'); |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | ) { |
| 176 | 176 | $table_objet_sql = table_objet_sql($objet); |
| 177 | 177 | $_id_table_objet = id_table_objet($objet); |
| 178 | - if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=" . intval($id_objet))) { |
|
| 178 | + if ($id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$_id_table_objet=".intval($id_objet))) { |
|
| 179 | 179 | $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
| 180 | 180 | $referencer_traduction($objet, $id_trad, $new_id_trad); |
| 181 | 181 | } |
@@ -46,6 +46,6 @@ |
||
| 46 | 46 | 'recherche' => _request('recherche'), |
| 47 | 47 | 'lang' => $lang, |
| 48 | 48 | 'class' => $class, |
| 49 | - '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 49 | + '_id_champ' => 'rechercher_'.substr(md5($action.$class), 0, 4), |
|
| 50 | 50 | ]; |
| 51 | 51 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | * @return array Environnement du formulaire |
| 34 | 34 | **/ |
| 35 | 35 | function formulaires_recherche_ecrire_charger_dist($action = '', $class = '') { |
| 36 | - if ($GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 37 | - $lang = $GLOBALS['spip_lang']; |
|
| 38 | - } else { |
|
| 39 | - $lang = ''; |
|
| 40 | - } |
|
| 36 | + if ($GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 37 | + $lang = $GLOBALS['spip_lang']; |
|
| 38 | + } else { |
|
| 39 | + $lang = ''; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return |
|
| 43 | - [ |
|
| 44 | - 'action' => ($action ?: generer_url_ecrire('recherche')), |
|
| 45 | - # action specifique, ne passe pas par Verifier, ni Traiter |
|
| 46 | - 'recherche' => _request('recherche'), |
|
| 47 | - 'lang' => $lang, |
|
| 48 | - 'class' => $class, |
|
| 49 | - '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 50 | - ]; |
|
| 42 | + return |
|
| 43 | + [ |
|
| 44 | + 'action' => ($action ?: generer_url_ecrire('recherche')), |
|
| 45 | + # action specifique, ne passe pas par Verifier, ni Traiter |
|
| 46 | + 'recherche' => _request('recherche'), |
|
| 47 | + 'lang' => $lang, |
|
| 48 | + 'class' => $class, |
|
| 49 | + '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 50 | + ]; |
|
| 51 | 51 | } |
@@ -11,28 +11,28 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/presentation'); |
| 17 | 17 | |
| 18 | 18 | function formulaires_configurer_previsualiseur_charger_dist() { |
| 19 | - $valeurs = []; |
|
| 20 | - $valeurs['preview'] = explode(',', $GLOBALS['meta']['preview']); |
|
| 19 | + $valeurs = []; |
|
| 20 | + $valeurs['preview'] = explode(',', $GLOBALS['meta']['preview']); |
|
| 21 | 21 | |
| 22 | - return $valeurs; |
|
| 22 | + return $valeurs; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | function formulaires_configurer_previsualiseur_traiter_dist() { |
| 27 | - $res = ['editable' => true]; |
|
| 27 | + $res = ['editable' => true]; |
|
| 28 | 28 | |
| 29 | - if ($i = _request('preview') and is_array($i)) { |
|
| 30 | - $i = ',' . implode(',', $i) . ','; |
|
| 31 | - } |
|
| 29 | + if ($i = _request('preview') and is_array($i)) { |
|
| 30 | + $i = ',' . implode(',', $i) . ','; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - ecrire_meta('preview', $i); |
|
| 33 | + ecrire_meta('preview', $i); |
|
| 34 | 34 | |
| 35 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 35 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 36 | 36 | |
| 37 | - return $res; |
|
| 37 | + return $res; |
|
| 38 | 38 | } |
@@ -27,7 +27,7 @@ |
||
| 27 | 27 | $res = ['editable' => true]; |
| 28 | 28 | |
| 29 | 29 | if ($i = _request('preview') and is_array($i)) { |
| 30 | - $i = ',' . implode(',', $i) . ','; |
|
| 30 | + $i = ','.implode(',', $i).','; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | ecrire_meta('preview', $i); |
@@ -11,65 +11,65 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_rediriger_article_charger_dist($id_article, $retour = '') { |
| 18 | 18 | |
| 19 | - include_spip('inc/autoriser'); |
|
| 20 | - if (!autoriser('modifier', 'article', $id_article)) { |
|
| 21 | - return false; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 25 | - if (!$row['id_article']) { |
|
| 26 | - return false; |
|
| 27 | - } |
|
| 28 | - include_spip('inc/lien'); |
|
| 29 | - $redirection = virtuel_redirige($row['virtuel']); |
|
| 30 | - |
|
| 31 | - if ( |
|
| 32 | - !$redirection |
|
| 33 | - and $GLOBALS['meta']['articles_redirection'] != 'oui' |
|
| 34 | - ) { |
|
| 35 | - return false; |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - include_spip('inc/texte'); |
|
| 40 | - $valeurs = [ |
|
| 41 | - 'redirection' => $redirection, |
|
| 42 | - 'id' => $id_article, |
|
| 43 | - '_afficher_url' => ($redirection ? propre("[->$redirection]") : ''), |
|
| 44 | - ]; |
|
| 45 | - |
|
| 46 | - return $valeurs; |
|
| 19 | + include_spip('inc/autoriser'); |
|
| 20 | + if (!autoriser('modifier', 'article', $id_article)) { |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 25 | + if (!$row['id_article']) { |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 28 | + include_spip('inc/lien'); |
|
| 29 | + $redirection = virtuel_redirige($row['virtuel']); |
|
| 30 | + |
|
| 31 | + if ( |
|
| 32 | + !$redirection |
|
| 33 | + and $GLOBALS['meta']['articles_redirection'] != 'oui' |
|
| 34 | + ) { |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + include_spip('inc/texte'); |
|
| 40 | + $valeurs = [ |
|
| 41 | + 'redirection' => $redirection, |
|
| 42 | + 'id' => $id_article, |
|
| 43 | + '_afficher_url' => ($redirection ? propre("[->$redirection]") : ''), |
|
| 44 | + ]; |
|
| 45 | + |
|
| 46 | + return $valeurs; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function formulaires_rediriger_article_verifier_dist($id_article, $retour = '') { |
| 50 | - $erreurs = []; |
|
| 50 | + $erreurs = []; |
|
| 51 | 51 | |
| 52 | - if (($redirection = _request('redirection')) == $id_article || $redirection == 'art' . $id_article) { |
|
| 53 | - $erreurs['redirection'] = _T('info_redirection_boucle'); |
|
| 54 | - } |
|
| 52 | + if (($redirection = _request('redirection')) == $id_article || $redirection == 'art' . $id_article) { |
|
| 53 | + $erreurs['redirection'] = _T('info_redirection_boucle'); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - return $erreurs; |
|
| 56 | + return $erreurs; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | function formulaires_rediriger_article_traiter_dist($id_article, $retour = '') { |
| 60 | 60 | |
| 61 | - $url = preg_replace(',^\s*https?://$,i', '', rtrim(_request('redirection'))); |
|
| 62 | - if ($url) { |
|
| 63 | - $url = corriger_caracteres($url); |
|
| 64 | - } |
|
| 61 | + $url = preg_replace(',^\s*https?://$,i', '', rtrim(_request('redirection'))); |
|
| 62 | + if ($url) { |
|
| 63 | + $url = corriger_caracteres($url); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - include_spip('action/editer_article'); |
|
| 67 | - article_modifier($id_article, ['virtuel' => $url]); |
|
| 66 | + include_spip('action/editer_article'); |
|
| 67 | + article_modifier($id_article, ['virtuel' => $url]); |
|
| 68 | 68 | |
| 69 | - $js = _AJAX ? '<script type="text/javascript">if (window.ajaxReload) ajaxReload("wysiwyg");</script>' : ''; |
|
| 69 | + $js = _AJAX ? '<script type="text/javascript">if (window.ajaxReload) ajaxReload("wysiwyg");</script>' : ''; |
|
| 70 | 70 | |
| 71 | - return [ |
|
| 72 | - 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')) . $js, |
|
| 73 | - 'editable' => true |
|
| 74 | - ]; |
|
| 71 | + return [ |
|
| 72 | + 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')) . $js, |
|
| 73 | + 'editable' => true |
|
| 74 | + ]; |
|
| 75 | 75 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | return false; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 24 | + $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article='.intval($id_article)); |
|
| 25 | 25 | if (!$row['id_article']) { |
| 26 | 26 | return false; |
| 27 | 27 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | function formulaires_rediriger_article_verifier_dist($id_article, $retour = '') { |
| 50 | 50 | $erreurs = []; |
| 51 | 51 | |
| 52 | - if (($redirection = _request('redirection')) == $id_article || $redirection == 'art' . $id_article) { |
|
| 52 | + if (($redirection = _request('redirection')) == $id_article || $redirection == 'art'.$id_article) { |
|
| 53 | 53 | $erreurs['redirection'] = _T('info_redirection_boucle'); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $js = _AJAX ? '<script type="text/javascript">if (window.ajaxReload) ajaxReload("wysiwyg");</script>' : ''; |
| 70 | 70 | |
| 71 | 71 | return [ |
| 72 | - 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')) . $js, |
|
| 72 | + 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')).$js, |
|
| 73 | 73 | 'editable' => true |
| 74 | 74 | ]; |
| 75 | 75 | } |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | * Environnement du formulaire |
| 31 | 31 | **/ |
| 32 | 32 | function formulaires_configurer_preferences_menus_charger_dist() { |
| 33 | - // travailler sur des meta fraîches |
|
| 34 | - include_spip('inc/meta'); |
|
| 35 | - lire_metas(); |
|
| 36 | - $valeurs = []; |
|
| 37 | - $valeurs['activer_menudev'] = table_valeur($GLOBALS['visiteur_session'], 'prefs/activer_menudev', 'non'); |
|
| 38 | - $valeurs['menus_favoris'] = obtenir_menus_favoris(); |
|
| 39 | - return $valeurs; |
|
| 33 | + // travailler sur des meta fraîches |
|
| 34 | + include_spip('inc/meta'); |
|
| 35 | + lire_metas(); |
|
| 36 | + $valeurs = []; |
|
| 37 | + $valeurs['activer_menudev'] = table_valeur($GLOBALS['visiteur_session'], 'prefs/activer_menudev', 'non'); |
|
| 38 | + $valeurs['menus_favoris'] = obtenir_menus_favoris(); |
|
| 39 | + return $valeurs; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -47,32 +47,32 @@ discard block |
||
| 47 | 47 | **/ |
| 48 | 48 | function formulaires_configurer_preferences_menus_traiter_dist() { |
| 49 | 49 | |
| 50 | - $activer_menudev = _request('activer_menudev'); |
|
| 51 | - $menus_favoris = _request('menus_favoris'); |
|
| 52 | - $menus_favoris = array_filter($menus_favoris); |
|
| 53 | - $menus_favoris = array_map('intval', $menus_favoris); |
|
| 50 | + $activer_menudev = _request('activer_menudev'); |
|
| 51 | + $menus_favoris = _request('menus_favoris'); |
|
| 52 | + $menus_favoris = array_filter($menus_favoris); |
|
| 53 | + $menus_favoris = array_map('intval', $menus_favoris); |
|
| 54 | 54 | |
| 55 | - if (_request('reset')) { |
|
| 56 | - $menus_favoris = []; |
|
| 57 | - set_request('menus_favoris', null); |
|
| 58 | - } |
|
| 55 | + if (_request('reset')) { |
|
| 56 | + $menus_favoris = []; |
|
| 57 | + set_request('menus_favoris', null); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - // si le menu dev change, ou les menus favoris, on recharge toute la page. |
|
| 61 | - if ( |
|
| 62 | - table_valeur($GLOBALS['visiteur_session'], 'prefs/activer_menudev') != $activer_menudev |
|
| 63 | - or $menus_favoris != obtenir_menus_favoris() |
|
| 64 | - ) { |
|
| 65 | - refuser_traiter_formulaire_ajax(); |
|
| 60 | + // si le menu dev change, ou les menus favoris, on recharge toute la page. |
|
| 61 | + if ( |
|
| 62 | + table_valeur($GLOBALS['visiteur_session'], 'prefs/activer_menudev') != $activer_menudev |
|
| 63 | + or $menus_favoris != obtenir_menus_favoris() |
|
| 64 | + ) { |
|
| 65 | + refuser_traiter_formulaire_ajax(); |
|
| 66 | 66 | |
| 67 | - $GLOBALS['visiteur_session']['prefs']['activer_menudev'] = $activer_menudev; |
|
| 68 | - $GLOBALS['visiteur_session']['prefs']['menus_favoris'] = $menus_favoris; |
|
| 67 | + $GLOBALS['visiteur_session']['prefs']['activer_menudev'] = $activer_menudev; |
|
| 68 | + $GLOBALS['visiteur_session']['prefs']['menus_favoris'] = $menus_favoris; |
|
| 69 | 69 | |
| 70 | - if (intval($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 71 | - include_spip('action/editer_auteur'); |
|
| 72 | - $c = ['prefs' => serialize($GLOBALS['visiteur_session']['prefs'])]; |
|
| 73 | - auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c); |
|
| 74 | - } |
|
| 75 | - } |
|
| 70 | + if (intval($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 71 | + include_spip('action/editer_auteur'); |
|
| 72 | + $c = ['prefs' => serialize($GLOBALS['visiteur_session']['prefs'])]; |
|
| 73 | + auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - return ['message_ok' => _T('config_info_enregistree'), 'editable' => true]; |
|
| 77 | + return ['message_ok' => _T('config_info_enregistree'), 'editable' => true]; |
|
| 78 | 78 | } |
@@ -11,74 +11,74 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Correction typographique francaise |
| 18 | 18 | |
| 19 | 19 | function typographie_fr_dist($letexte) { |
| 20 | 20 | |
| 21 | - static $trans; |
|
| 21 | + static $trans; |
|
| 22 | 22 | |
| 23 | - // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ; |
|
| 24 | - // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe |
|
| 25 | - if (!$trans) { |
|
| 26 | - $trans = [ |
|
| 27 | - "'" => '’', |
|
| 28 | - ' ' => '~', |
|
| 29 | - '»' => '»', |
|
| 30 | - '«' => '«', |
|
| 31 | - '”' => '”', |
|
| 32 | - '“' => '“', |
|
| 33 | - '°' => '°' |
|
| 34 | - ]; |
|
| 35 | - $chars = [160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°']; |
|
| 36 | - $chars_trans = array_keys($chars); |
|
| 37 | - $chars = array_values($chars); |
|
| 38 | - $chars_trans = implode(' ', array_map('chr', $chars_trans)); |
|
| 39 | - $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer')); |
|
| 40 | - $chars_trans = explode(' ', $chars_trans); |
|
| 41 | - foreach ($chars as $k => $r) { |
|
| 42 | - $trans[$chars_trans[$k]] = $r; |
|
| 43 | - } |
|
| 44 | - } |
|
| 23 | + // Nettoyer 160 = nbsp ; 187 = raquo ; 171 = laquo ; 176 = deg ; |
|
| 24 | + // 147 = ldquo; 148 = rdquo; ' = zouli apostrophe |
|
| 25 | + if (!$trans) { |
|
| 26 | + $trans = [ |
|
| 27 | + "'" => '’', |
|
| 28 | + ' ' => '~', |
|
| 29 | + '»' => '»', |
|
| 30 | + '«' => '«', |
|
| 31 | + '”' => '”', |
|
| 32 | + '“' => '“', |
|
| 33 | + '°' => '°' |
|
| 34 | + ]; |
|
| 35 | + $chars = [160 => '~', 187 => '»', 171 => '«', 148 => '”', 147 => '“', 176 => '°']; |
|
| 36 | + $chars_trans = array_keys($chars); |
|
| 37 | + $chars = array_values($chars); |
|
| 38 | + $chars_trans = implode(' ', array_map('chr', $chars_trans)); |
|
| 39 | + $chars_trans = unicode2charset(charset2unicode($chars_trans, 'iso-8859-1', 'forcer')); |
|
| 40 | + $chars_trans = explode(' ', $chars_trans); |
|
| 41 | + foreach ($chars as $k => $r) { |
|
| 42 | + $trans[$chars_trans[$k]] = $r; |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - $letexte = strtr($letexte, $trans); |
|
| 46 | + $letexte = strtr($letexte, $trans); |
|
| 47 | 47 | |
| 48 | - $cherche1 = [ |
|
| 49 | - /* 1 */ |
|
| 50 | - '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S', |
|
| 51 | - /* 2 */ |
|
| 52 | - '/»| --?,|(?::(?!:)| %)(?:\W|$)/S', |
|
| 53 | - /* 3 */ |
|
| 54 | - '/([^[<(!?.])([!?][!?\.]*)/iS', |
|
| 55 | - /* 4 */ |
|
| 56 | - '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S' |
|
| 57 | - ]; |
|
| 58 | - $remplace1 = [ |
|
| 59 | - /* 1 */ |
|
| 60 | - '\1~;', |
|
| 61 | - /* 2 */ |
|
| 62 | - '~\0', |
|
| 63 | - /* 3 */ |
|
| 64 | - '\1~\2', |
|
| 65 | - /* 4 */ |
|
| 66 | - '\0~' |
|
| 67 | - ]; |
|
| 68 | - $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 69 | - $letexte = preg_replace('/ *~+ */S', '~', $letexte); |
|
| 48 | + $cherche1 = [ |
|
| 49 | + /* 1 */ |
|
| 50 | + '/((?:^|[^\#0-9a-zA-Z\&])[\#0-9a-zA-Z]*)\;/S', |
|
| 51 | + /* 2 */ |
|
| 52 | + '/»| --?,|(?::(?!:)| %)(?:\W|$)/S', |
|
| 53 | + /* 3 */ |
|
| 54 | + '/([^[<(!?.])([!?][!?\.]*)/iS', |
|
| 55 | + /* 4 */ |
|
| 56 | + '/«|(?:M(?:M?\.|mes?|r\.?)|[MnN]°) /S' |
|
| 57 | + ]; |
|
| 58 | + $remplace1 = [ |
|
| 59 | + /* 1 */ |
|
| 60 | + '\1~;', |
|
| 61 | + /* 2 */ |
|
| 62 | + '~\0', |
|
| 63 | + /* 3 */ |
|
| 64 | + '\1~\2', |
|
| 65 | + /* 4 */ |
|
| 66 | + '\0~' |
|
| 67 | + ]; |
|
| 68 | + $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 69 | + $letexte = preg_replace('/ *~+ */S', '~', $letexte); |
|
| 70 | 70 | |
| 71 | - $cherche2 = [ |
|
| 72 | - '/([^-\n]|^)--([^-]|$)/S', |
|
| 73 | - ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | - '/~/' |
|
| 75 | - ]; |
|
| 76 | - $remplace2 = [ |
|
| 77 | - '\1—\2', |
|
| 78 | - '\1\3\4', |
|
| 79 | - ' ' |
|
| 80 | - ]; |
|
| 81 | - $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 71 | + $cherche2 = [ |
|
| 72 | + '/([^-\n]|^)--([^-]|$)/S', |
|
| 73 | + ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | + '/~/' |
|
| 75 | + ]; |
|
| 76 | + $remplace2 = [ |
|
| 77 | + '\1—\2', |
|
| 78 | + '\1\3\4', |
|
| 79 | + ' ' |
|
| 80 | + ]; |
|
| 81 | + $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 82 | 82 | |
| 83 | - return $letexte; |
|
| 83 | + return $letexte; |
|
| 84 | 84 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | |
| 71 | 71 | $cherche2 = [ |
| 72 | 72 | '/([^-\n]|^)--([^-]|$)/S', |
| 73 | - ',(' . _PROTOCOLES_STD . ')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 73 | + ',('._PROTOCOLES_STD.')~((://[^"\'\s\[\]\}\)<>]+)~([?]))?,S', |
|
| 74 | 74 | '/~/' |
| 75 | 75 | ]; |
| 76 | 76 | $remplace2 = [ |
@@ -11,37 +11,37 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // rien sauf les "~" et "-," |
| 18 | 18 | |
| 19 | 19 | function typographie_en_dist($letexte) { |
| 20 | 20 | |
| 21 | - // zouli apostrophe |
|
| 22 | - $letexte = str_replace("'", '’', $letexte); |
|
| 21 | + // zouli apostrophe |
|
| 22 | + $letexte = str_replace("'", '’', $letexte); |
|
| 23 | 23 | |
| 24 | - $cherche1 = [ |
|
| 25 | - '/ --?,/S' |
|
| 26 | - ]; |
|
| 27 | - $remplace1 = [ |
|
| 28 | - '~\0' |
|
| 29 | - ]; |
|
| 30 | - $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 24 | + $cherche1 = [ |
|
| 25 | + '/ --?,/S' |
|
| 26 | + ]; |
|
| 27 | + $remplace1 = [ |
|
| 28 | + '~\0' |
|
| 29 | + ]; |
|
| 30 | + $letexte = preg_replace($cherche1, $remplace1, $letexte); |
|
| 31 | 31 | |
| 32 | - $letexte = str_replace(' ', '~', $letexte); |
|
| 33 | - $letexte = preg_replace('/ *~+ */', '~', $letexte); |
|
| 32 | + $letexte = str_replace(' ', '~', $letexte); |
|
| 33 | + $letexte = preg_replace('/ *~+ */', '~', $letexte); |
|
| 34 | 34 | |
| 35 | - $cherche2 = [ |
|
| 36 | - '/([^-\n]|^)--([^-]|$)/', |
|
| 37 | - '/~/' |
|
| 38 | - ]; |
|
| 39 | - $remplace2 = [ |
|
| 40 | - '\1—\2', |
|
| 41 | - ' ' |
|
| 42 | - ]; |
|
| 35 | + $cherche2 = [ |
|
| 36 | + '/([^-\n]|^)--([^-]|$)/', |
|
| 37 | + '/~/' |
|
| 38 | + ]; |
|
| 39 | + $remplace2 = [ |
|
| 40 | + '\1—\2', |
|
| 41 | + ' ' |
|
| 42 | + ]; |
|
| 43 | 43 | |
| 44 | - $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 44 | + $letexte = preg_replace($cherche2, $remplace2, $letexte); |
|
| 45 | 45 | |
| 46 | - return $letexte; |
|
| 46 | + return $letexte; |
|
| 47 | 47 | } |
@@ -177,14 +177,14 @@ discard block |
||
| 177 | 177 | // sache qu'il peut enlever ce where si il enleve la jointure |
| 178 | 178 | $boucle->where["JOIN-L$n"] = |
| 179 | 179 | $echap ? |
| 180 | - ["'='","'$obj'","sql_quote('$type')"] |
|
| 180 | + ["'='", "'$obj'", "sql_quote('$type')"] |
|
| 181 | 181 | : |
| 182 | - ['=',"$obj",sql_quote($type)]; |
|
| 182 | + ['=', "$obj", sql_quote($type)]; |
|
| 183 | 183 | $boucle->join["L$n"] = |
| 184 | 184 | $echap ? |
| 185 | 185 | ["'$id_table'", "'$j2'", "'$j1'", "'$obj='.sql_quote('$type')"] |
| 186 | 186 | : |
| 187 | - [$id_table, $j2, $j1, "$obj=" . sql_quote($type)]; |
|
| 187 | + [$id_table, $j2, $j1, "$obj=".sql_quote($type)]; |
|
| 188 | 188 | } else { |
| 189 | 189 | $boucle->join["L$n"] = $echap ? ["'$id_table'", "'$j'"] : [$id_table, $j]; |
| 190 | 190 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $groups = liste_champs_jointures($nom, $desc, true); |
| 219 | 219 | if (!$pk) { |
| 220 | 220 | foreach ($groups as $id_prim) { |
| 221 | - $id_field = $nom . '.' . $id_prim; |
|
| 221 | + $id_field = $nom.'.'.$id_prim; |
|
| 222 | 222 | if (!in_array($id_field, $boucle->group)) { |
| 223 | 223 | $boucle->group[] = $id_field; |
| 224 | 224 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -33,11 +33,11 @@ discard block |
||
| 33 | 33 | * Chaine sinon : le nom du champ (non décomposable donc) |
| 34 | 34 | */ |
| 35 | 35 | function decompose_champ_id_objet($champ) { |
| 36 | - if (($champ !== 'id_objet') and preg_match(',^id_([a-z_]+)$,', $champ, $regs)) { |
|
| 37 | - return ['id_objet', 'objet', objet_type($champ)]; |
|
| 38 | - } |
|
| 36 | + if (($champ !== 'id_objet') and preg_match(',^id_([a-z_]+)$,', $champ, $regs)) { |
|
| 37 | + return ['id_objet', 'objet', objet_type($champ)]; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $champ; |
|
| 40 | + return $champ; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -56,21 +56,21 @@ discard block |
||
| 56 | 56 | * - array(id_objet, objet), si le champ n'existe pas mais qu'on peut décomposer |
| 57 | 57 | */ |
| 58 | 58 | function trouver_champs_decomposes($champ, $desc) { |
| 59 | - if ( |
|
| 60 | - !is_array($desc) // on ne se risque pas en conjectures si on ne connait pas la table |
|
| 61 | - or array_key_exists($champ, $desc['field']) |
|
| 62 | - ) { |
|
| 63 | - return [$champ]; |
|
| 64 | - } |
|
| 65 | - // si le champ se décompose, tester que les colonnes décomposées sont présentes |
|
| 66 | - if (is_array($decompose = decompose_champ_id_objet($champ))) { |
|
| 67 | - array_pop($decompose); |
|
| 68 | - if (count(array_intersect($decompose, array_keys($desc['field']))) == count($decompose)) { |
|
| 69 | - return $decompose; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - return [$champ]; |
|
| 59 | + if ( |
|
| 60 | + !is_array($desc) // on ne se risque pas en conjectures si on ne connait pas la table |
|
| 61 | + or array_key_exists($champ, $desc['field']) |
|
| 62 | + ) { |
|
| 63 | + return [$champ]; |
|
| 64 | + } |
|
| 65 | + // si le champ se décompose, tester que les colonnes décomposées sont présentes |
|
| 66 | + if (is_array($decompose = decompose_champ_id_objet($champ))) { |
|
| 67 | + array_pop($decompose); |
|
| 68 | + if (count(array_intersect($decompose, array_keys($desc['field']))) == count($decompose)) { |
|
| 69 | + return $decompose; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + return [$champ]; |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | |
@@ -100,23 +100,23 @@ discard block |
||
| 100 | 100 | * Alias de la table de jointure (Lx) |
| 101 | 101 | */ |
| 102 | 102 | function calculer_jointure(&$boucle, $depart, $arrivee, $col = '', $cond = false, $max_liens = 5) { |
| 103 | - // les jointures minimales sont optimales : |
|
| 104 | - // on contraint le nombre d'etapes en l'augmentant |
|
| 105 | - // jusqu'a ce qu'on trouve une jointure ou qu'on atteigne la limite maxi |
|
| 106 | - $max = 1; |
|
| 107 | - $res = false; |
|
| 108 | - $milieu_exclus = ($col ?: []); |
|
| 109 | - while ($max <= $max_liens and !$res) { |
|
| 110 | - $res = calculer_chaine_jointures($boucle, $depart, $arrivee, [], $milieu_exclus, $max); |
|
| 111 | - $max++; |
|
| 112 | - } |
|
| 113 | - if (!$res) { |
|
| 114 | - return ''; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - [$nom, $desc] = $depart; |
|
| 118 | - |
|
| 119 | - return fabrique_jointures($boucle, $res, $cond, $desc, $nom, $col); |
|
| 103 | + // les jointures minimales sont optimales : |
|
| 104 | + // on contraint le nombre d'etapes en l'augmentant |
|
| 105 | + // jusqu'a ce qu'on trouve une jointure ou qu'on atteigne la limite maxi |
|
| 106 | + $max = 1; |
|
| 107 | + $res = false; |
|
| 108 | + $milieu_exclus = ($col ?: []); |
|
| 109 | + while ($max <= $max_liens and !$res) { |
|
| 110 | + $res = calculer_chaine_jointures($boucle, $depart, $arrivee, [], $milieu_exclus, $max); |
|
| 111 | + $max++; |
|
| 112 | + } |
|
| 113 | + if (!$res) { |
|
| 114 | + return ''; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + [$nom, $desc] = $depart; |
|
| 118 | + |
|
| 119 | + return fabrique_jointures($boucle, $res, $cond, $desc, $nom, $col); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -155,82 +155,82 @@ discard block |
||
| 155 | 155 | * Alias de la table de jointure (Lx) |
| 156 | 156 | */ |
| 157 | 157 | function fabrique_jointures(&$boucle, $res, $cond = false, $desc = [], $nom = '', $col = '', $echap = true) { |
| 158 | - $a = []; |
|
| 159 | - $j = null; |
|
| 160 | - $n = null; |
|
| 161 | - static $num = []; |
|
| 162 | - $id_table = ''; |
|
| 163 | - $cpt = &$num[$boucle->descr['nom']][$boucle->descr['gram']][$boucle->id_boucle]; |
|
| 164 | - foreach ($res as $cle => $r) { |
|
| 165 | - [$d, $a, $j] = $r; |
|
| 166 | - if (!$id_table) { |
|
| 167 | - $id_table = $d; |
|
| 168 | - } |
|
| 169 | - $n = ++$cpt; |
|
| 170 | - if (is_array($j)) { // c'est un lien sur un champ du type id_objet,objet,'article' |
|
| 171 | - [$j1, $j2, $obj, $type] = $j; |
|
| 172 | - // trouver de quel cote est (id_objet,objet) |
|
| 173 | - if ($j1 == "id_$obj") { |
|
| 174 | - $obj = "$id_table.$obj"; |
|
| 175 | - } else { |
|
| 176 | - $obj = "L$n.$obj"; |
|
| 177 | - } |
|
| 178 | - // le where complementaire est envoye dans la jointure et dans le where |
|
| 179 | - // on utilise une clé qui le relie a la jointure pour que l'optimiseur |
|
| 180 | - // sache qu'il peut enlever ce where si il enleve la jointure |
|
| 181 | - $boucle->where["JOIN-L$n"] = |
|
| 182 | - $echap ? |
|
| 183 | - ["'='","'$obj'","sql_quote('$type')"] |
|
| 184 | - : |
|
| 185 | - ['=',"$obj",sql_quote($type)]; |
|
| 186 | - $boucle->join["L$n"] = |
|
| 187 | - $echap ? |
|
| 188 | - ["'$id_table'", "'$j2'", "'$j1'", "'$obj='.sql_quote('$type')"] |
|
| 189 | - : |
|
| 190 | - [$id_table, $j2, $j1, "$obj=" . sql_quote($type)]; |
|
| 191 | - } else { |
|
| 192 | - $boucle->join["L$n"] = $echap ? ["'$id_table'", "'$j'"] : [$id_table, $j]; |
|
| 193 | - } |
|
| 194 | - $boucle->from[$id_table = "L$n"] = $a[0]; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - |
|
| 198 | - // pas besoin de group by |
|
| 199 | - // (cf http://article.gmane.org/gmane.comp.web.spip.devel/30555) |
|
| 200 | - // si une seule jointure et sur une table avec primary key formee |
|
| 201 | - // de l'index principal et de l'index de jointure (non conditionnel! [6031]) |
|
| 202 | - // et operateur d'egalite (https://core.spip.net/issues/477) |
|
| 203 | - |
|
| 204 | - if ($pk = (isset($a[1]) && (count($boucle->from) == 2) && !$cond)) { |
|
| 205 | - $pk = nogroupby_if($desc, $a[1], $col); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - // pas de group by |
|
| 209 | - // si une seule jointure |
|
| 210 | - // et si l'index de jointure est une primary key a l'arrivee ! |
|
| 211 | - if ( |
|
| 212 | - !$pk |
|
| 213 | - and (count($boucle->from) == 2) |
|
| 214 | - and isset($a[1]['key']['PRIMARY KEY']) |
|
| 215 | - and ($j == $a[1]['key']['PRIMARY KEY']) |
|
| 216 | - ) { |
|
| 217 | - $pk = true; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - // la clause Group by est en conflit avec ORDER BY, a completer |
|
| 221 | - $groups = liste_champs_jointures($nom, $desc, true); |
|
| 222 | - if (!$pk) { |
|
| 223 | - foreach ($groups as $id_prim) { |
|
| 224 | - $id_field = $nom . '.' . $id_prim; |
|
| 225 | - if (!in_array($id_field, $boucle->group)) { |
|
| 226 | - $boucle->group[] = $id_field; |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - $boucle->modificateur['lien'] = true; |
|
| 232 | - |
|
| 233 | - return "L$n"; |
|
| 158 | + $a = []; |
|
| 159 | + $j = null; |
|
| 160 | + $n = null; |
|
| 161 | + static $num = []; |
|
| 162 | + $id_table = ''; |
|
| 163 | + $cpt = &$num[$boucle->descr['nom']][$boucle->descr['gram']][$boucle->id_boucle]; |
|
| 164 | + foreach ($res as $cle => $r) { |
|
| 165 | + [$d, $a, $j] = $r; |
|
| 166 | + if (!$id_table) { |
|
| 167 | + $id_table = $d; |
|
| 168 | + } |
|
| 169 | + $n = ++$cpt; |
|
| 170 | + if (is_array($j)) { // c'est un lien sur un champ du type id_objet,objet,'article' |
|
| 171 | + [$j1, $j2, $obj, $type] = $j; |
|
| 172 | + // trouver de quel cote est (id_objet,objet) |
|
| 173 | + if ($j1 == "id_$obj") { |
|
| 174 | + $obj = "$id_table.$obj"; |
|
| 175 | + } else { |
|
| 176 | + $obj = "L$n.$obj"; |
|
| 177 | + } |
|
| 178 | + // le where complementaire est envoye dans la jointure et dans le where |
|
| 179 | + // on utilise une clé qui le relie a la jointure pour que l'optimiseur |
|
| 180 | + // sache qu'il peut enlever ce where si il enleve la jointure |
|
| 181 | + $boucle->where["JOIN-L$n"] = |
|
| 182 | + $echap ? |
|
| 183 | + ["'='","'$obj'","sql_quote('$type')"] |
|
| 184 | + : |
|
| 185 | + ['=',"$obj",sql_quote($type)]; |
|
| 186 | + $boucle->join["L$n"] = |
|
| 187 | + $echap ? |
|
| 188 | + ["'$id_table'", "'$j2'", "'$j1'", "'$obj='.sql_quote('$type')"] |
|
| 189 | + : |
|
| 190 | + [$id_table, $j2, $j1, "$obj=" . sql_quote($type)]; |
|
| 191 | + } else { |
|
| 192 | + $boucle->join["L$n"] = $echap ? ["'$id_table'", "'$j'"] : [$id_table, $j]; |
|
| 193 | + } |
|
| 194 | + $boucle->from[$id_table = "L$n"] = $a[0]; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + |
|
| 198 | + // pas besoin de group by |
|
| 199 | + // (cf http://article.gmane.org/gmane.comp.web.spip.devel/30555) |
|
| 200 | + // si une seule jointure et sur une table avec primary key formee |
|
| 201 | + // de l'index principal et de l'index de jointure (non conditionnel! [6031]) |
|
| 202 | + // et operateur d'egalite (https://core.spip.net/issues/477) |
|
| 203 | + |
|
| 204 | + if ($pk = (isset($a[1]) && (count($boucle->from) == 2) && !$cond)) { |
|
| 205 | + $pk = nogroupby_if($desc, $a[1], $col); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + // pas de group by |
|
| 209 | + // si une seule jointure |
|
| 210 | + // et si l'index de jointure est une primary key a l'arrivee ! |
|
| 211 | + if ( |
|
| 212 | + !$pk |
|
| 213 | + and (count($boucle->from) == 2) |
|
| 214 | + and isset($a[1]['key']['PRIMARY KEY']) |
|
| 215 | + and ($j == $a[1]['key']['PRIMARY KEY']) |
|
| 216 | + ) { |
|
| 217 | + $pk = true; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + // la clause Group by est en conflit avec ORDER BY, a completer |
|
| 221 | + $groups = liste_champs_jointures($nom, $desc, true); |
|
| 222 | + if (!$pk) { |
|
| 223 | + foreach ($groups as $id_prim) { |
|
| 224 | + $id_field = $nom . '.' . $id_prim; |
|
| 225 | + if (!in_array($id_field, $boucle->group)) { |
|
| 226 | + $boucle->group[] = $id_field; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + $boucle->modificateur['lien'] = true; |
|
| 232 | + |
|
| 233 | + return "L$n"; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -245,19 +245,19 @@ discard block |
||
| 245 | 245 | * @return bool |
| 246 | 246 | */ |
| 247 | 247 | function nogroupby_if($depart, $arrivee, $col) { |
| 248 | - if ( |
|
| 249 | - empty($arrivee['key']['PRIMARY KEY']) |
|
| 250 | - or !($pk = $arrivee['key']['PRIMARY KEY']) |
|
| 251 | - or empty($depart['key']['PRIMARY KEY']) |
|
| 252 | - ) { |
|
| 253 | - return false; |
|
| 254 | - } |
|
| 255 | - $id_primary = $depart['key']['PRIMARY KEY']; |
|
| 256 | - if (is_array($col)) { |
|
| 257 | - $col = implode(', *', $col); |
|
| 258 | - } // cas id_objet, objet |
|
| 259 | - return (preg_match("/^$id_primary, *$col$/", $pk) or |
|
| 260 | - preg_match("/^$col, *$id_primary$/", $pk)); |
|
| 248 | + if ( |
|
| 249 | + empty($arrivee['key']['PRIMARY KEY']) |
|
| 250 | + or !($pk = $arrivee['key']['PRIMARY KEY']) |
|
| 251 | + or empty($depart['key']['PRIMARY KEY']) |
|
| 252 | + ) { |
|
| 253 | + return false; |
|
| 254 | + } |
|
| 255 | + $id_primary = $depart['key']['PRIMARY KEY']; |
|
| 256 | + if (is_array($col)) { |
|
| 257 | + $col = implode(', *', $col); |
|
| 258 | + } // cas id_objet, objet |
|
| 259 | + return (preg_match("/^$id_primary, *$col$/", $pk) or |
|
| 260 | + preg_match("/^$col, *$id_primary$/", $pk)); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -275,46 +275,46 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | function liste_champs_jointures($nom, $desc, $primary = false) { |
| 277 | 277 | |
| 278 | - static $nojoin = ['idx', 'maj', 'date', 'statut']; |
|
| 278 | + static $nojoin = ['idx', 'maj', 'date', 'statut']; |
|
| 279 | 279 | |
| 280 | - // si cle primaire demandee, la privilegier |
|
| 281 | - if ($primary && isset($desc['key']['PRIMARY KEY'])) { |
|
| 282 | - return split_key($desc['key']['PRIMARY KEY']); |
|
| 283 | - } |
|
| 280 | + // si cle primaire demandee, la privilegier |
|
| 281 | + if ($primary && isset($desc['key']['PRIMARY KEY'])) { |
|
| 282 | + return split_key($desc['key']['PRIMARY KEY']); |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - // les champs declares explicitement pour les jointures |
|
| 286 | - if (isset($desc['join'])) { |
|
| 287 | - return $desc['join']; |
|
| 288 | - } |
|
| 289 | - /*elseif (isset($GLOBALS['tables_principales'][$nom]['join'])) return $GLOBALS['tables_principales'][$nom]['join']; |
|
| 285 | + // les champs declares explicitement pour les jointures |
|
| 286 | + if (isset($desc['join'])) { |
|
| 287 | + return $desc['join']; |
|
| 288 | + } |
|
| 289 | + /*elseif (isset($GLOBALS['tables_principales'][$nom]['join'])) return $GLOBALS['tables_principales'][$nom]['join']; |
|
| 290 | 290 | elseif (isset($GLOBALS['tables_auxiliaires'][$nom]['join'])) return $GLOBALS['tables_auxiliaires'][$nom]['join'];*/ |
| 291 | 291 | |
| 292 | - // si pas de cle, c'est fichu |
|
| 293 | - if (!isset($desc['key'])) { |
|
| 294 | - return []; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - // si cle primaire |
|
| 298 | - if (isset($desc['key']['PRIMARY KEY'])) { |
|
| 299 | - return split_key($desc['key']['PRIMARY KEY']); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - // ici on se rabat sur les cles secondaires, |
|
| 303 | - // en eliminant celles qui sont pas pertinentes (idx, maj) |
|
| 304 | - // si jamais le resultat n'est pas pertinent pour une table donnee, |
|
| 305 | - // il faut declarer explicitement le champ 'join' de sa description |
|
| 306 | - |
|
| 307 | - $join = []; |
|
| 308 | - foreach ($desc['key'] as $v) { |
|
| 309 | - $join = split_key($v, $join); |
|
| 310 | - } |
|
| 311 | - foreach ($join as $k) { |
|
| 312 | - if (in_array($k, $nojoin)) { |
|
| 313 | - unset($join[$k]); |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - return $join; |
|
| 292 | + // si pas de cle, c'est fichu |
|
| 293 | + if (!isset($desc['key'])) { |
|
| 294 | + return []; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + // si cle primaire |
|
| 298 | + if (isset($desc['key']['PRIMARY KEY'])) { |
|
| 299 | + return split_key($desc['key']['PRIMARY KEY']); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + // ici on se rabat sur les cles secondaires, |
|
| 303 | + // en eliminant celles qui sont pas pertinentes (idx, maj) |
|
| 304 | + // si jamais le resultat n'est pas pertinent pour une table donnee, |
|
| 305 | + // il faut declarer explicitement le champ 'join' de sa description |
|
| 306 | + |
|
| 307 | + $join = []; |
|
| 308 | + foreach ($desc['key'] as $v) { |
|
| 309 | + $join = split_key($v, $join); |
|
| 310 | + } |
|
| 311 | + foreach ($join as $k) { |
|
| 312 | + if (in_array($k, $nojoin)) { |
|
| 313 | + unset($join[$k]); |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + return $join; |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -325,14 +325,14 @@ discard block |
||
| 325 | 325 | * @return array |
| 326 | 326 | */ |
| 327 | 327 | function split_key($v, $join = []) { |
| 328 | - foreach (preg_split('/,\s*/', $v) as $k) { |
|
| 329 | - if (strpos($k, '(') !== false) { |
|
| 330 | - $k = explode('(', $k); |
|
| 331 | - $k = trim(reset($k)); |
|
| 332 | - } |
|
| 333 | - $join[$k] = $k; |
|
| 334 | - } |
|
| 335 | - return $join; |
|
| 328 | + foreach (preg_split('/,\s*/', $v) as $k) { |
|
| 329 | + if (strpos($k, '(') !== false) { |
|
| 330 | + $k = explode('(', $k); |
|
| 331 | + $k = trim(reset($k)); |
|
| 332 | + } |
|
| 333 | + $join[$k] = $k; |
|
| 334 | + } |
|
| 335 | + return $join; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -355,135 +355,135 @@ discard block |
||
| 355 | 355 | * @return array |
| 356 | 356 | */ |
| 357 | 357 | function calculer_chaine_jointures( |
| 358 | - &$boucle, |
|
| 359 | - $depart, |
|
| 360 | - $arrivee, |
|
| 361 | - $vu = [], |
|
| 362 | - $milieu_exclus = [], |
|
| 363 | - $max_liens = 5 |
|
| 358 | + &$boucle, |
|
| 359 | + $depart, |
|
| 360 | + $arrivee, |
|
| 361 | + $vu = [], |
|
| 362 | + $milieu_exclus = [], |
|
| 363 | + $max_liens = 5 |
|
| 364 | 364 | ) { |
| 365 | - static $trouver_table; |
|
| 366 | - if (!$trouver_table) { |
|
| 367 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - if (is_string($milieu_exclus)) { |
|
| 371 | - $milieu_exclus = [$milieu_exclus]; |
|
| 372 | - } |
|
| 373 | - // quand on a exclus id_objet comme cle de jointure, il faut aussi exclure objet |
|
| 374 | - // faire une jointure sur objet tout seul n'a pas de sens |
|
| 375 | - if (in_array('id_objet', $milieu_exclus) and !in_array('objet', $milieu_exclus)) { |
|
| 376 | - $milieu_exclus[] = 'objet'; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - [$dnom, $ddesc] = $depart; |
|
| 380 | - [$anom, $adesc] = $arrivee; |
|
| 381 | - if (!count($vu)) { |
|
| 382 | - $vu[] = $dnom; // ne pas oublier la table de depart |
|
| 383 | - $vu[] = $anom; // ne pas oublier la table d'arrivee |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - $akeys = []; |
|
| 387 | - foreach ($adesc['key'] as $k) { |
|
| 388 | - // respecter l'ordre de $adesc['key'] pour ne pas avoir id_trad en premier entre autres... |
|
| 389 | - $akeys = array_merge($akeys, preg_split('/,\s*/', $k)); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - // enlever les cles d'arrivee exclues par l'appel |
|
| 393 | - $akeys = array_diff($akeys, $milieu_exclus); |
|
| 394 | - |
|
| 395 | - // cles candidates au depart |
|
| 396 | - $keys = liste_champs_jointures($dnom, $ddesc); |
|
| 397 | - // enlever les cles dde depart exclues par l'appel |
|
| 398 | - $keys = array_diff($keys, $milieu_exclus); |
|
| 399 | - |
|
| 400 | - $v = !$keys ? false : array_intersect(array_values($keys), $akeys); |
|
| 401 | - |
|
| 402 | - if ($v) { |
|
| 403 | - return [[$dnom, [$adesc['table'], $adesc], array_shift($v)]]; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - // regarder si l'on a (id_objet,objet) au depart et si on peut le mapper sur un id_xx |
|
| 407 | - if (count(array_intersect(['id_objet', 'objet'], $keys)) == 2) { |
|
| 408 | - // regarder si l'une des cles d'arrivee peut se decomposer en |
|
| 409 | - // id_objet,objet |
|
| 410 | - // si oui on la prend |
|
| 411 | - foreach ($akeys as $key) { |
|
| 412 | - $v = decompose_champ_id_objet($key); |
|
| 413 | - if (is_array($v)) { |
|
| 414 | - $objet = array_shift($v); // objet,'article' |
|
| 415 | - array_unshift($v, $key); // id_article,objet,'article' |
|
| 416 | - array_unshift($v, $objet); // id_objet,id_article,objet,'article' |
|
| 417 | - return [[$dnom, [$adesc['table'], $adesc], $v]]; |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - } else { |
|
| 421 | - // regarder si l'une des cles de depart peut se decomposer en |
|
| 422 | - // id_objet,objet a l'arrivee |
|
| 423 | - // si oui on la prend |
|
| 424 | - foreach ($keys as $key) { |
|
| 425 | - if (count($v = trouver_champs_decomposes($key, $adesc)) > 1) { |
|
| 426 | - if (count($v) == count(array_intersect($v, $akeys))) { |
|
| 427 | - $v = decompose_champ_id_objet($key); // id_objet,objet,'article' |
|
| 428 | - array_unshift($v, $key); // id_article,id_objet,objet,'article' |
|
| 429 | - return [[$dnom, [$adesc['table'], $adesc], $v]]; |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - // si l'on voulait une jointure direct, c'est rate ! |
|
| 435 | - if ($max_liens <= 1) { |
|
| 436 | - return []; |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - // sinon essayer de passer par une autre table |
|
| 440 | - $new = $vu; |
|
| 441 | - foreach ($boucle->jointures as $v) { |
|
| 442 | - if ( |
|
| 443 | - $v |
|
| 444 | - and !in_array($v, $vu) |
|
| 445 | - and $def = $trouver_table($v, $boucle->sql_serveur) |
|
| 446 | - and !in_array($def['table_sql'], $vu) |
|
| 447 | - ) { |
|
| 448 | - // ne pas tester les cles qui sont exclues a l'appel |
|
| 449 | - // ie la cle de la jointure precedente |
|
| 450 | - $test_cles = $milieu_exclus; |
|
| 451 | - $new[] = $v; |
|
| 452 | - $max_iter = 50; // securite |
|
| 453 | - while ( |
|
| 454 | - count($jointure_directe_possible = calculer_chaine_jointures( |
|
| 455 | - $boucle, |
|
| 456 | - $depart, |
|
| 457 | - [$v, $def], |
|
| 458 | - $vu, |
|
| 459 | - $test_cles, |
|
| 460 | - 1 |
|
| 461 | - )) |
|
| 462 | - and $max_iter-- |
|
| 463 | - ) { |
|
| 464 | - $jointure_directe_possible = reset($jointure_directe_possible); |
|
| 465 | - $milieu = end($jointure_directe_possible); |
|
| 466 | - $exclure_fin = $milieu_exclus; |
|
| 467 | - if (is_string($milieu)) { |
|
| 468 | - $exclure_fin[] = $milieu; |
|
| 469 | - $test_cles[] = $milieu; |
|
| 470 | - } else { |
|
| 471 | - $exclure_fin = array_merge($exclure_fin, $milieu); |
|
| 472 | - $test_cles = array_merge($test_cles, $milieu); |
|
| 473 | - } |
|
| 474 | - // essayer de rejoindre l'arrivee a partir de cette etape intermediaire |
|
| 475 | - // sans repasser par la meme cle milieu, ni une cle deja vue ! |
|
| 476 | - $r = calculer_chaine_jointures($boucle, [$v, $def], $arrivee, $new, $exclure_fin, $max_liens - 1); |
|
| 477 | - if ($r) { |
|
| 478 | - array_unshift($r, $jointure_directe_possible); |
|
| 479 | - |
|
| 480 | - return $r; |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - return []; |
|
| 365 | + static $trouver_table; |
|
| 366 | + if (!$trouver_table) { |
|
| 367 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + if (is_string($milieu_exclus)) { |
|
| 371 | + $milieu_exclus = [$milieu_exclus]; |
|
| 372 | + } |
|
| 373 | + // quand on a exclus id_objet comme cle de jointure, il faut aussi exclure objet |
|
| 374 | + // faire une jointure sur objet tout seul n'a pas de sens |
|
| 375 | + if (in_array('id_objet', $milieu_exclus) and !in_array('objet', $milieu_exclus)) { |
|
| 376 | + $milieu_exclus[] = 'objet'; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + [$dnom, $ddesc] = $depart; |
|
| 380 | + [$anom, $adesc] = $arrivee; |
|
| 381 | + if (!count($vu)) { |
|
| 382 | + $vu[] = $dnom; // ne pas oublier la table de depart |
|
| 383 | + $vu[] = $anom; // ne pas oublier la table d'arrivee |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + $akeys = []; |
|
| 387 | + foreach ($adesc['key'] as $k) { |
|
| 388 | + // respecter l'ordre de $adesc['key'] pour ne pas avoir id_trad en premier entre autres... |
|
| 389 | + $akeys = array_merge($akeys, preg_split('/,\s*/', $k)); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + // enlever les cles d'arrivee exclues par l'appel |
|
| 393 | + $akeys = array_diff($akeys, $milieu_exclus); |
|
| 394 | + |
|
| 395 | + // cles candidates au depart |
|
| 396 | + $keys = liste_champs_jointures($dnom, $ddesc); |
|
| 397 | + // enlever les cles dde depart exclues par l'appel |
|
| 398 | + $keys = array_diff($keys, $milieu_exclus); |
|
| 399 | + |
|
| 400 | + $v = !$keys ? false : array_intersect(array_values($keys), $akeys); |
|
| 401 | + |
|
| 402 | + if ($v) { |
|
| 403 | + return [[$dnom, [$adesc['table'], $adesc], array_shift($v)]]; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + // regarder si l'on a (id_objet,objet) au depart et si on peut le mapper sur un id_xx |
|
| 407 | + if (count(array_intersect(['id_objet', 'objet'], $keys)) == 2) { |
|
| 408 | + // regarder si l'une des cles d'arrivee peut se decomposer en |
|
| 409 | + // id_objet,objet |
|
| 410 | + // si oui on la prend |
|
| 411 | + foreach ($akeys as $key) { |
|
| 412 | + $v = decompose_champ_id_objet($key); |
|
| 413 | + if (is_array($v)) { |
|
| 414 | + $objet = array_shift($v); // objet,'article' |
|
| 415 | + array_unshift($v, $key); // id_article,objet,'article' |
|
| 416 | + array_unshift($v, $objet); // id_objet,id_article,objet,'article' |
|
| 417 | + return [[$dnom, [$adesc['table'], $adesc], $v]]; |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + } else { |
|
| 421 | + // regarder si l'une des cles de depart peut se decomposer en |
|
| 422 | + // id_objet,objet a l'arrivee |
|
| 423 | + // si oui on la prend |
|
| 424 | + foreach ($keys as $key) { |
|
| 425 | + if (count($v = trouver_champs_decomposes($key, $adesc)) > 1) { |
|
| 426 | + if (count($v) == count(array_intersect($v, $akeys))) { |
|
| 427 | + $v = decompose_champ_id_objet($key); // id_objet,objet,'article' |
|
| 428 | + array_unshift($v, $key); // id_article,id_objet,objet,'article' |
|
| 429 | + return [[$dnom, [$adesc['table'], $adesc], $v]]; |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + // si l'on voulait une jointure direct, c'est rate ! |
|
| 435 | + if ($max_liens <= 1) { |
|
| 436 | + return []; |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + // sinon essayer de passer par une autre table |
|
| 440 | + $new = $vu; |
|
| 441 | + foreach ($boucle->jointures as $v) { |
|
| 442 | + if ( |
|
| 443 | + $v |
|
| 444 | + and !in_array($v, $vu) |
|
| 445 | + and $def = $trouver_table($v, $boucle->sql_serveur) |
|
| 446 | + and !in_array($def['table_sql'], $vu) |
|
| 447 | + ) { |
|
| 448 | + // ne pas tester les cles qui sont exclues a l'appel |
|
| 449 | + // ie la cle de la jointure precedente |
|
| 450 | + $test_cles = $milieu_exclus; |
|
| 451 | + $new[] = $v; |
|
| 452 | + $max_iter = 50; // securite |
|
| 453 | + while ( |
|
| 454 | + count($jointure_directe_possible = calculer_chaine_jointures( |
|
| 455 | + $boucle, |
|
| 456 | + $depart, |
|
| 457 | + [$v, $def], |
|
| 458 | + $vu, |
|
| 459 | + $test_cles, |
|
| 460 | + 1 |
|
| 461 | + )) |
|
| 462 | + and $max_iter-- |
|
| 463 | + ) { |
|
| 464 | + $jointure_directe_possible = reset($jointure_directe_possible); |
|
| 465 | + $milieu = end($jointure_directe_possible); |
|
| 466 | + $exclure_fin = $milieu_exclus; |
|
| 467 | + if (is_string($milieu)) { |
|
| 468 | + $exclure_fin[] = $milieu; |
|
| 469 | + $test_cles[] = $milieu; |
|
| 470 | + } else { |
|
| 471 | + $exclure_fin = array_merge($exclure_fin, $milieu); |
|
| 472 | + $test_cles = array_merge($test_cles, $milieu); |
|
| 473 | + } |
|
| 474 | + // essayer de rejoindre l'arrivee a partir de cette etape intermediaire |
|
| 475 | + // sans repasser par la meme cle milieu, ni une cle deja vue ! |
|
| 476 | + $r = calculer_chaine_jointures($boucle, [$v, $def], $arrivee, $new, $exclure_fin, $max_liens - 1); |
|
| 477 | + if ($r) { |
|
| 478 | + array_unshift($r, $jointure_directe_possible); |
|
| 479 | + |
|
| 480 | + return $r; |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + return []; |
|
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | /** |
@@ -494,18 +494,18 @@ discard block |
||
| 494 | 494 | * @return array |
| 495 | 495 | */ |
| 496 | 496 | function trouver_cles_table($keys) { |
| 497 | - $res = []; |
|
| 498 | - foreach ($keys as $v) { |
|
| 499 | - if (!strpos($v, ',')) { |
|
| 500 | - $res[$v] = 1; |
|
| 501 | - } else { |
|
| 502 | - foreach (preg_split('/\s*,\s*/', $v) as $k) { |
|
| 503 | - $res[$k] = 1; |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - return array_keys($res); |
|
| 497 | + $res = []; |
|
| 498 | + foreach ($keys as $v) { |
|
| 499 | + if (!strpos($v, ',')) { |
|
| 500 | + $res[$v] = 1; |
|
| 501 | + } else { |
|
| 502 | + foreach (preg_split('/\s*,\s*/', $v) as $k) { |
|
| 503 | + $res[$k] = 1; |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + return array_keys($res); |
|
| 509 | 509 | } |
| 510 | 510 | |
| 511 | 511 | |
@@ -532,34 +532,34 @@ discard block |
||
| 532 | 532 | * - 'alias' : alias utilisé pour la table (si pertinent. ie: avec `$boucle->from` transmis par exemple) |
| 533 | 533 | */ |
| 534 | 534 | function chercher_champ_dans_tables($cle, $tables, $connect, $checkarrivee = false) { |
| 535 | - static $trouver_table = ''; |
|
| 536 | - if (!$trouver_table) { |
|
| 537 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 538 | - } |
|
| 539 | - |
|
| 540 | - if (!is_array($cle)) { |
|
| 541 | - $cle = [$cle]; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - foreach ($tables as $k => $table) { |
|
| 545 | - if ($table && $desc = $trouver_table($table, $connect)) { |
|
| 546 | - if ( |
|
| 547 | - isset($desc['field']) |
|
| 548 | - // verifier que toutes les cles cherchees sont la |
|
| 549 | - and (count(array_intersect($cle, array_keys($desc['field']))) == count($cle)) |
|
| 550 | - // si on sait ou on veut arriver, il faut que ca colle |
|
| 551 | - and ($checkarrivee == false || $checkarrivee == $desc['table']) |
|
| 552 | - ) { |
|
| 553 | - return [ |
|
| 554 | - 'desc' => $desc, |
|
| 555 | - 'table' => $desc['table'], |
|
| 556 | - 'alias' => $k, |
|
| 557 | - ]; |
|
| 558 | - } |
|
| 559 | - } |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - return false; |
|
| 535 | + static $trouver_table = ''; |
|
| 536 | + if (!$trouver_table) { |
|
| 537 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 538 | + } |
|
| 539 | + |
|
| 540 | + if (!is_array($cle)) { |
|
| 541 | + $cle = [$cle]; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + foreach ($tables as $k => $table) { |
|
| 545 | + if ($table && $desc = $trouver_table($table, $connect)) { |
|
| 546 | + if ( |
|
| 547 | + isset($desc['field']) |
|
| 548 | + // verifier que toutes les cles cherchees sont la |
|
| 549 | + and (count(array_intersect($cle, array_keys($desc['field']))) == count($cle)) |
|
| 550 | + // si on sait ou on veut arriver, il faut que ca colle |
|
| 551 | + and ($checkarrivee == false || $checkarrivee == $desc['table']) |
|
| 552 | + ) { |
|
| 553 | + return [ |
|
| 554 | + 'desc' => $desc, |
|
| 555 | + 'table' => $desc['table'], |
|
| 556 | + 'alias' => $k, |
|
| 557 | + ]; |
|
| 558 | + } |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + return false; |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | /** |
@@ -585,52 +585,52 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | function trouver_champ_exterieur($cle, $joints, &$boucle, $checkarrivee = false) { |
| 587 | 587 | |
| 588 | - // support de la recherche multi champ : |
|
| 589 | - // si en seconde etape on a decompose le champ id_xx en id_objet,objet |
|
| 590 | - // on reentre ici soit en cherchant une table les 2 champs id_objet,objet |
|
| 591 | - // soit une table avec les 3 champs id_xx, id_objet, objet |
|
| 592 | - if (!is_array($cle)) { |
|
| 593 | - $cle = [$cle]; |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - if ($infos = chercher_champ_dans_tables($cle, $joints, $boucle->sql_serveur, $checkarrivee)) { |
|
| 597 | - return [$infos['table'], $infos['desc'], $cle]; |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - // au premier coup, on essaye de decomposer, si possible |
|
| 601 | - if ( |
|
| 602 | - count($cle) == 1 |
|
| 603 | - and $c = reset($cle) |
|
| 604 | - and is_array($decompose = decompose_champ_id_objet($c)) |
|
| 605 | - ) { |
|
| 606 | - $desc = $boucle->show; |
|
| 607 | - |
|
| 608 | - // cas 1 : la cle id_xx est dans la table de depart |
|
| 609 | - // -> on cherche uniquement id_objet,objet a l'arrivee |
|
| 610 | - if (isset($desc['field'][$c])) { |
|
| 611 | - $cle = []; |
|
| 612 | - $cle[] = array_shift($decompose); // id_objet |
|
| 613 | - $cle[] = array_shift($decompose); // objet |
|
| 614 | - return trouver_champ_exterieur($cle, $joints, $boucle, $checkarrivee); |
|
| 615 | - } |
|
| 616 | - // cas 2 : la cle id_xx n'est pas dans la table de depart |
|
| 617 | - // -> il faut trouver une cle de depart zzz telle que |
|
| 618 | - // id_objet,objet,zzz soit a l'arrivee |
|
| 619 | - else { |
|
| 620 | - $depart = liste_champs_jointures(($desc['table'] ?? ''), $desc); |
|
| 621 | - foreach ($depart as $d) { |
|
| 622 | - $cle = []; |
|
| 623 | - $cle[] = array_shift($decompose); // id_objet |
|
| 624 | - $cle[] = array_shift($decompose); // objet |
|
| 625 | - $cle[] = $d; |
|
| 626 | - if ($ext = trouver_champ_exterieur($cle, $joints, $boucle, $checkarrivee)) { |
|
| 627 | - return $ext; |
|
| 628 | - } |
|
| 629 | - } |
|
| 630 | - } |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - return ''; |
|
| 588 | + // support de la recherche multi champ : |
|
| 589 | + // si en seconde etape on a decompose le champ id_xx en id_objet,objet |
|
| 590 | + // on reentre ici soit en cherchant une table les 2 champs id_objet,objet |
|
| 591 | + // soit une table avec les 3 champs id_xx, id_objet, objet |
|
| 592 | + if (!is_array($cle)) { |
|
| 593 | + $cle = [$cle]; |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + if ($infos = chercher_champ_dans_tables($cle, $joints, $boucle->sql_serveur, $checkarrivee)) { |
|
| 597 | + return [$infos['table'], $infos['desc'], $cle]; |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + // au premier coup, on essaye de decomposer, si possible |
|
| 601 | + if ( |
|
| 602 | + count($cle) == 1 |
|
| 603 | + and $c = reset($cle) |
|
| 604 | + and is_array($decompose = decompose_champ_id_objet($c)) |
|
| 605 | + ) { |
|
| 606 | + $desc = $boucle->show; |
|
| 607 | + |
|
| 608 | + // cas 1 : la cle id_xx est dans la table de depart |
|
| 609 | + // -> on cherche uniquement id_objet,objet a l'arrivee |
|
| 610 | + if (isset($desc['field'][$c])) { |
|
| 611 | + $cle = []; |
|
| 612 | + $cle[] = array_shift($decompose); // id_objet |
|
| 613 | + $cle[] = array_shift($decompose); // objet |
|
| 614 | + return trouver_champ_exterieur($cle, $joints, $boucle, $checkarrivee); |
|
| 615 | + } |
|
| 616 | + // cas 2 : la cle id_xx n'est pas dans la table de depart |
|
| 617 | + // -> il faut trouver une cle de depart zzz telle que |
|
| 618 | + // id_objet,objet,zzz soit a l'arrivee |
|
| 619 | + else { |
|
| 620 | + $depart = liste_champs_jointures(($desc['table'] ?? ''), $desc); |
|
| 621 | + foreach ($depart as $d) { |
|
| 622 | + $cle = []; |
|
| 623 | + $cle[] = array_shift($decompose); // id_objet |
|
| 624 | + $cle[] = array_shift($decompose); // objet |
|
| 625 | + $cle[] = $d; |
|
| 626 | + if ($ext = trouver_champ_exterieur($cle, $joints, $boucle, $checkarrivee)) { |
|
| 627 | + return $ext; |
|
| 628 | + } |
|
| 629 | + } |
|
| 630 | + } |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + return ''; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -662,21 +662,21 @@ discard block |
||
| 662 | 662 | * @return string |
| 663 | 663 | */ |
| 664 | 664 | function trouver_jointure_champ($champ, &$boucle, $jointures = false, $cond = false, $checkarrivee = false) { |
| 665 | - if ($jointures === false) { |
|
| 666 | - $jointures = $boucle->jointures; |
|
| 667 | - } |
|
| 668 | - // TODO : aberration, on utilise $jointures pour trouver le champ |
|
| 669 | - // mais pas poour construire la jointure ensuite |
|
| 670 | - $arrivee = trouver_champ_exterieur($champ, $jointures, $boucle, $checkarrivee); |
|
| 671 | - if ($arrivee) { |
|
| 672 | - $desc = $boucle->show; |
|
| 673 | - array_pop($arrivee); // enlever la cle en 3eme argument |
|
| 674 | - $cle = calculer_jointure($boucle, [$desc['id_table'], $desc], $arrivee, '', $cond); |
|
| 675 | - if ($cle) { |
|
| 676 | - return $cle; |
|
| 677 | - } |
|
| 678 | - } |
|
| 679 | - spip_log("trouver_jointure_champ: $champ inconnu"); |
|
| 680 | - |
|
| 681 | - return ''; |
|
| 665 | + if ($jointures === false) { |
|
| 666 | + $jointures = $boucle->jointures; |
|
| 667 | + } |
|
| 668 | + // TODO : aberration, on utilise $jointures pour trouver le champ |
|
| 669 | + // mais pas poour construire la jointure ensuite |
|
| 670 | + $arrivee = trouver_champ_exterieur($champ, $jointures, $boucle, $checkarrivee); |
|
| 671 | + if ($arrivee) { |
|
| 672 | + $desc = $boucle->show; |
|
| 673 | + array_pop($arrivee); // enlever la cle en 3eme argument |
|
| 674 | + $cle = calculer_jointure($boucle, [$desc['id_table'], $desc], $arrivee, '', $cond); |
|
| 675 | + if ($cle) { |
|
| 676 | + return $cle; |
|
| 677 | + } |
|
| 678 | + } |
|
| 679 | + spip_log("trouver_jointure_champ: $champ inconnu"); |
|
| 680 | + |
|
| 681 | + return ''; |
|
| 682 | 682 | } |