@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -27,51 +27,51 @@ discard block |
||
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | 29 | function action_confirmer_inscription_dist() { |
| 30 | - $jeton = _request('jeton'); |
|
| 31 | - $email = _request('email'); |
|
| 30 | + $jeton = _request('jeton'); |
|
| 31 | + $email = _request('email'); |
|
| 32 | 32 | |
| 33 | - include_spip('action/inscrire_auteur'); |
|
| 34 | - if ( |
|
| 35 | - ($auteur = auteur_verifier_jeton($jeton)) |
|
| 36 | - && $auteur['email'] == $email |
|
| 37 | - && $auteur['statut'] == 'nouveau' |
|
| 38 | - ) { |
|
| 39 | - // d'abord on confirme son statut |
|
| 40 | - $auteur = confirmer_statut_inscription($auteur); |
|
| 33 | + include_spip('action/inscrire_auteur'); |
|
| 34 | + if ( |
|
| 35 | + ($auteur = auteur_verifier_jeton($jeton)) |
|
| 36 | + && $auteur['email'] == $email |
|
| 37 | + && $auteur['statut'] == 'nouveau' |
|
| 38 | + ) { |
|
| 39 | + // d'abord on confirme son statut |
|
| 40 | + $auteur = confirmer_statut_inscription($auteur); |
|
| 41 | 41 | |
| 42 | - // OK c'est un nouvel inscrit qui confirme : |
|
| 43 | - // on le loge => ca va confirmer son statut et c'est plus sympa |
|
| 44 | - include_spip('inc/auth'); |
|
| 45 | - auth_loger($auteur); |
|
| 42 | + // OK c'est un nouvel inscrit qui confirme : |
|
| 43 | + // on le loge => ca va confirmer son statut et c'est plus sympa |
|
| 44 | + include_spip('inc/auth'); |
|
| 45 | + auth_loger($auteur); |
|
| 46 | 46 | |
| 47 | - // et on efface son jeton |
|
| 48 | - auteur_effacer_jeton($auteur['id_auteur']); |
|
| 47 | + // et on efface son jeton |
|
| 48 | + auteur_effacer_jeton($auteur['id_auteur']); |
|
| 49 | 49 | |
| 50 | - // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur |
|
| 51 | - // TODO: ne semble pas marcher si inscrit non visiteur, a debug |
|
| 52 | - if (!_request('redirect')) { |
|
| 53 | - // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 54 | - if (autoriser('ecrire', '', '', $auteur['id_auteur'])) { |
|
| 55 | - // poser un cookie admin aussi |
|
| 56 | - $cookie = charger_fonction('cookie', 'action'); |
|
| 57 | - $cookie('@' . $GLOBALS['visiteur_session']['login']); |
|
| 58 | - $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 59 | - } else { |
|
| 60 | - $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } else { |
|
| 64 | - // lien perime : |
|
| 65 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 66 | - // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 67 | - if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 68 | - $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 69 | - } else { |
|
| 70 | - $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 71 | - } |
|
| 72 | - } else { |
|
| 73 | - // rediriger vers la page de login si pas encore loge |
|
| 74 | - $GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect')); |
|
| 75 | - } |
|
| 76 | - } |
|
| 50 | + // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur |
|
| 51 | + // TODO: ne semble pas marcher si inscrit non visiteur, a debug |
|
| 52 | + if (!_request('redirect')) { |
|
| 53 | + // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 54 | + if (autoriser('ecrire', '', '', $auteur['id_auteur'])) { |
|
| 55 | + // poser un cookie admin aussi |
|
| 56 | + $cookie = charger_fonction('cookie', 'action'); |
|
| 57 | + $cookie('@' . $GLOBALS['visiteur_session']['login']); |
|
| 58 | + $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 59 | + } else { |
|
| 60 | + $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } else { |
|
| 64 | + // lien perime : |
|
| 65 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 66 | + // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 67 | + if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 68 | + $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 69 | + } else { |
|
| 70 | + $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 71 | + } |
|
| 72 | + } else { |
|
| 73 | + // rediriger vers la page de login si pas encore loge |
|
| 74 | + $GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect')); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/autoriser'); |
@@ -34,42 +34,42 @@ discard block |
||
| 34 | 34 | **/ |
| 35 | 35 | function action_menu_rubriques_dist() { |
| 36 | 36 | |
| 37 | - // si pas acces a ecrire, pas acces au menu |
|
| 38 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 39 | - if (!autoriser('ecrire')) { |
|
| 40 | - $retour = |
|
| 41 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | - '</a>' . |
|
| 46 | - '</li>' . |
|
| 47 | - '</ul>'; |
|
| 48 | - include_spip('inc/actions'); |
|
| 49 | - ajax_retour($retour); |
|
| 50 | - exit; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if ($date = (int) _request('date')) { |
|
| 54 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $r = gen_liste_rubriques(); |
|
| 58 | - if ( |
|
| 59 | - !$r |
|
| 60 | - && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 61 | - && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 62 | - ) { |
|
| 63 | - include_spip('inc/headers'); |
|
| 64 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | - http_response_code(304); |
|
| 66 | - exit; |
|
| 67 | - } else { |
|
| 68 | - include_spip('inc/actions'); |
|
| 69 | - $ret = menu_rubriques(); |
|
| 70 | - ajax_retour($ret); |
|
| 71 | - exit; |
|
| 72 | - } |
|
| 37 | + // si pas acces a ecrire, pas acces au menu |
|
| 38 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 39 | + if (!autoriser('ecrire')) { |
|
| 40 | + $retour = |
|
| 41 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 42 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 43 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 44 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 45 | + '</a>' . |
|
| 46 | + '</li>' . |
|
| 47 | + '</ul>'; |
|
| 48 | + include_spip('inc/actions'); |
|
| 49 | + ajax_retour($retour); |
|
| 50 | + exit; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if ($date = (int) _request('date')) { |
|
| 54 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $r = gen_liste_rubriques(); |
|
| 58 | + if ( |
|
| 59 | + !$r |
|
| 60 | + && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 61 | + && !strstr((string) $_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 62 | + ) { |
|
| 63 | + include_spip('inc/headers'); |
|
| 64 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 65 | + http_response_code(304); |
|
| 66 | + exit; |
|
| 67 | + } else { |
|
| 68 | + include_spip('inc/actions'); |
|
| 69 | + $ret = menu_rubriques(); |
|
| 70 | + ajax_retour($ret); |
|
| 71 | + exit; |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -83,44 +83,44 @@ discard block |
||
| 83 | 83 | * Code HTML présentant la liste des rubriques |
| 84 | 84 | **/ |
| 85 | 85 | function menu_rubriques($complet = true) { |
| 86 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 87 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 89 | - . '</a>' |
|
| 90 | - . '</li>'; |
|
| 91 | - |
|
| 92 | - if (!$complet) { |
|
| 93 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 97 | - gen_liste_rubriques(); |
|
| 98 | - } |
|
| 99 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 100 | - |
|
| 101 | - $total_lignes = $i = count($arr_low); |
|
| 102 | - |
|
| 103 | - if ($i > 0) { |
|
| 104 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 105 | - if ($nb_col <= 1) { |
|
| 106 | - $nb_col = ceil($total_lignes / 10); |
|
| 107 | - } |
|
| 108 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 109 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 110 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 111 | - $i++; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 116 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 117 | - . $ret |
|
| 118 | - . "\n</ul>\n"; |
|
| 119 | - } else { |
|
| 120 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - return $ret; |
|
| 86 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 87 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 88 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 89 | + . '</a>' |
|
| 90 | + . '</li>'; |
|
| 91 | + |
|
| 92 | + if (!$complet) { |
|
| 93 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 97 | + gen_liste_rubriques(); |
|
| 98 | + } |
|
| 99 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 100 | + |
|
| 101 | + $total_lignes = $i = count($arr_low); |
|
| 102 | + |
|
| 103 | + if ($i > 0) { |
|
| 104 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 105 | + if ($nb_col <= 1) { |
|
| 106 | + $nb_col = ceil($total_lignes / 10); |
|
| 107 | + } |
|
| 108 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 109 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 110 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 111 | + $i++; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 116 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 117 | + . $ret |
|
| 118 | + . "\n</ul>\n"; |
|
| 119 | + } else { |
|
| 120 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + return $ret; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -141,47 +141,47 @@ discard block |
||
| 141 | 141 | * Code HTML présentant la liste des rubriques |
| 142 | 142 | **/ |
| 143 | 143 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 144 | - static $zmax = 6; |
|
| 145 | - $profondeur_next = $profondeur + 1; |
|
| 146 | - |
|
| 147 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 149 | - . "</a>\n"; |
|
| 150 | - |
|
| 151 | - // Limiter volontairement le nombre de sous-menus |
|
| 152 | - if (!(--$zmax)) { |
|
| 153 | - $zmax++; |
|
| 154 | - |
|
| 155 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 159 | - $i = count($arr_rub); |
|
| 160 | - if (!$i) { |
|
| 161 | - $zmax++; |
|
| 162 | - |
|
| 163 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - $nb_col = 1; |
|
| 168 | - if ($nb_rub = count($arr_rub)) { |
|
| 169 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 170 | - } |
|
| 171 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 172 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 173 | - . $nav |
|
| 174 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 175 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 176 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 177 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 178 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 179 | - $i++; |
|
| 180 | - } |
|
| 181 | - } |
|
| 182 | - $zmax++; |
|
| 183 | - |
|
| 184 | - return $ret . "</ul></li>\n"; |
|
| 144 | + static $zmax = 6; |
|
| 145 | + $profondeur_next = $profondeur + 1; |
|
| 146 | + |
|
| 147 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 148 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 149 | + . "</a>\n"; |
|
| 150 | + |
|
| 151 | + // Limiter volontairement le nombre de sous-menus |
|
| 152 | + if (!(--$zmax)) { |
|
| 153 | + $zmax++; |
|
| 154 | + |
|
| 155 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 159 | + $i = count($arr_rub); |
|
| 160 | + if (!$i) { |
|
| 161 | + $zmax++; |
|
| 162 | + |
|
| 163 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + $nb_col = 1; |
|
| 168 | + if ($nb_rub = count($arr_rub)) { |
|
| 169 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 170 | + } |
|
| 171 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 172 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 173 | + . $nav |
|
| 174 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 175 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 176 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 177 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 178 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 179 | + $i++; |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + $zmax++; |
|
| 183 | + |
|
| 184 | + return $ret . "</ul></li>\n"; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 200 | 200 | **/ |
| 201 | 201 | function extraire_article($id_p, $t) { |
| 202 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 202 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -215,42 +215,42 @@ discard block |
||
| 215 | 215 | **/ |
| 216 | 216 | function gen_liste_rubriques() { |
| 217 | 217 | |
| 218 | - $cache = null; |
|
| 219 | - include_spip('inc/config'); |
|
| 220 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 221 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 222 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 223 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 224 | - if ($date == $last) { |
|
| 225 | - return false; |
|
| 226 | - } // c'etait en cache :-) |
|
| 227 | - } |
|
| 228 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 229 | - |
|
| 230 | - $where = sql_in_select( |
|
| 231 | - 'id_rubrique', |
|
| 232 | - 'id_rubrique', |
|
| 233 | - 'spip_rubriques', |
|
| 234 | - '', |
|
| 235 | - '', |
|
| 236 | - 'id_parent=0 DESC, date DESC', |
|
| 237 | - _CACHE_RUBRIQUES_MAX |
|
| 238 | - ); |
|
| 239 | - |
|
| 240 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 241 | - |
|
| 242 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 243 | - |
|
| 244 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 245 | - // car on met le resultat en cache, commun a tout le monde |
|
| 246 | - $GLOBALS['db_art_cache'] = []; |
|
| 247 | - while ($r = sql_fetch($res)) { |
|
| 248 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 249 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 253 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 254 | - |
|
| 255 | - return true; |
|
| 218 | + $cache = null; |
|
| 219 | + include_spip('inc/config'); |
|
| 220 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 221 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 222 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 223 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 224 | + if ($date == $last) { |
|
| 225 | + return false; |
|
| 226 | + } // c'etait en cache :-) |
|
| 227 | + } |
|
| 228 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 229 | + |
|
| 230 | + $where = sql_in_select( |
|
| 231 | + 'id_rubrique', |
|
| 232 | + 'id_rubrique', |
|
| 233 | + 'spip_rubriques', |
|
| 234 | + '', |
|
| 235 | + '', |
|
| 236 | + 'id_parent=0 DESC, date DESC', |
|
| 237 | + _CACHE_RUBRIQUES_MAX |
|
| 238 | + ); |
|
| 239 | + |
|
| 240 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 241 | + |
|
| 242 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 243 | + |
|
| 244 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 245 | + // car on met le resultat en cache, commun a tout le monde |
|
| 246 | + $GLOBALS['db_art_cache'] = []; |
|
| 247 | + while ($r = sql_fetch($res)) { |
|
| 248 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 249 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 253 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 254 | + |
|
| 255 | + return true; |
|
| 256 | 256 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -31,28 +31,28 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function action_desinstaller_plugin_dist() { |
| 33 | 33 | |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 36 | - [$dir_plugins, $plugin] = explode('::', (string) $arg); |
|
| 37 | - $dir_type = '_DIR_PLUGINS'; |
|
| 38 | - if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 39 | - $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 40 | - } |
|
| 41 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 42 | - $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 43 | - if ($infos && !$infos['install_test'][0]) { |
|
| 44 | - include_spip('inc/plugin'); |
|
| 45 | - ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 46 | - $erreur = ''; |
|
| 47 | - } else { |
|
| 48 | - $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 49 | - } |
|
| 50 | - if ($redirect = _request('redirect')) { |
|
| 51 | - include_spip('inc/headers'); |
|
| 52 | - if ($erreur) { |
|
| 53 | - $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 54 | - } |
|
| 55 | - $redirect = str_replace('&', '&', (string) $redirect); |
|
| 56 | - redirige_par_entete($redirect); |
|
| 57 | - } |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | + [$dir_plugins, $plugin] = explode('::', (string) $arg); |
|
| 37 | + $dir_type = '_DIR_PLUGINS'; |
|
| 38 | + if (defined('_DIR_PLUGINS_SUPPL') && $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 39 | + $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 40 | + } |
|
| 41 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 42 | + $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 43 | + if ($infos && !$infos['install_test'][0]) { |
|
| 44 | + include_spip('inc/plugin'); |
|
| 45 | + ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 46 | + $erreur = ''; |
|
| 47 | + } else { |
|
| 48 | + $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 49 | + } |
|
| 50 | + if ($redirect = _request('redirect')) { |
|
| 51 | + include_spip('inc/headers'); |
|
| 52 | + if ($erreur) { |
|
| 53 | + $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 54 | + } |
|
| 55 | + $redirect = str_replace('&', '&', (string) $redirect); |
|
| 56 | + redirige_par_entete($redirect); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -28,24 +28,24 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | function action_instituer_objet_dist($arg = null) { |
| 30 | 30 | |
| 31 | - if (is_null($arg)) { |
|
| 32 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | - $arg = $securiser_action(); |
|
| 34 | - } |
|
| 31 | + if (is_null($arg)) { |
|
| 32 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | + $arg = $securiser_action(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - [$objet, $id_objet, $statut] = preg_split('/\W/', (string) $arg); |
|
| 37 | - if (!$statut) { |
|
| 38 | - $statut = _request('statut_nouv'); |
|
| 39 | - } // cas POST |
|
| 40 | - if (!$statut) { |
|
| 41 | - return; |
|
| 42 | - } // impossible mais sait-on jamais |
|
| 36 | + [$objet, $id_objet, $statut] = preg_split('/\W/', (string) $arg); |
|
| 37 | + if (!$statut) { |
|
| 38 | + $statut = _request('statut_nouv'); |
|
| 39 | + } // cas POST |
|
| 40 | + if (!$statut) { |
|
| 41 | + return; |
|
| 42 | + } // impossible mais sait-on jamais |
|
| 43 | 43 | |
| 44 | - if ( |
|
| 45 | - ($id_objet = (int) $id_objet) |
|
| 46 | - && autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut]) |
|
| 47 | - ) { |
|
| 48 | - include_spip('action/editer_objet'); |
|
| 49 | - objet_modifier($objet, $id_objet, ['statut' => $statut]); |
|
| 50 | - } |
|
| 44 | + if ( |
|
| 45 | + ($id_objet = (int) $id_objet) |
|
| 46 | + && autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut]) |
|
| 47 | + ) { |
|
| 48 | + include_spip('action/editer_objet'); |
|
| 49 | + objet_modifier($objet, $id_objet, ['statut' => $statut]); |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | 27 | function action_annuler_job_dist() { |
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $id_job = $securiser_action(); |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $id_job = $securiser_action(); |
|
| 30 | 30 | |
| 31 | - if ( |
|
| 32 | - ($id_job = (int) $id_job) |
|
| 33 | - && autoriser('annuler', 'job', $id_job) |
|
| 34 | - ) { |
|
| 35 | - job_queue_remove($id_job); |
|
| 36 | - } |
|
| 31 | + if ( |
|
| 32 | + ($id_job = (int) $id_job) |
|
| 33 | + && autoriser('annuler', 'job', $id_job) |
|
| 34 | + ) { |
|
| 35 | + job_queue_remove($id_job); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -15,98 +15,98 @@ |
||
| 15 | 15 | * Collecte les raccourcis liens [titre->url] de SPIP |
| 16 | 16 | */ |
| 17 | 17 | class Liens extends AbstractCollecteur { |
| 18 | - protected static string $markPrefix = 'LIEN'; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * La preg pour découper et collecter les modèles |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected string $preg_lien; |
|
| 25 | - |
|
| 26 | - public function __construct(?string $preg = null) { |
|
| 27 | - |
|
| 28 | - // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
|
| 29 | - // Laisser passer des paires de crochets pour la balise multi |
|
| 30 | - // mais refuser plus d'imbrications ou de mauvaises imbrications |
|
| 31 | - // sinon les crochets ne peuvent plus servir qu'a ce type de raccourci |
|
| 32 | - $this->preg_lien = ($preg ?: '/\[([^][]*?([[][^]>-]*[]][^][]*)*)->(>?)([^]]*)\]/msS'); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Sanitizer une collection d'occurences de liens : il faut sanitizer le href et le texte uniquement |
|
| 38 | - * |
|
| 39 | - * @param array $collection |
|
| 40 | - * @param string $sanitize_callback |
|
| 41 | - * @return array |
|
| 42 | - */ |
|
| 43 | - protected function sanitizer_collection(array $collection, string $sanitize_callback): array { |
|
| 44 | - foreach ($collection as &$lien) { |
|
| 45 | - $t = $sanitize_callback($lien['texte']); |
|
| 46 | - if ($t !== $lien['texte']) { |
|
| 47 | - $lien['raw'] = str_replace($lien['texte'], $t, (string) $lien['raw']); |
|
| 48 | - $lien['texte'] = $t; |
|
| 49 | - } |
|
| 50 | - $href = $sanitize_callback($lien['href']); |
|
| 51 | - if ($href !== $lien['href']) { |
|
| 52 | - $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 53 | - $lien['href'] = $href; |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - return $collection; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @param string $texte |
|
| 62 | - * @param array $options |
|
| 63 | - * bool $collecter_liens |
|
| 64 | - * @return array |
|
| 65 | - */ |
|
| 66 | - public function collecter(string $texte, array $options = []): array { |
|
| 67 | - if (!$texte) { |
|
| 68 | - return []; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $liens = []; |
|
| 72 | - if (str_contains($texte, '->')) { |
|
| 73 | - $desechappe_crochets = false; |
|
| 74 | - // si il y a un crochet ouvrant échappé ou un crochet fermant échappé, les substituer pour les ignorer |
|
| 75 | - if (str_contains($texte, '\[') || str_contains($texte, '\]')) { |
|
| 76 | - $texte = str_replace(['\[', '\]'], ["\x1\x5", "\x1\x6"], $texte); |
|
| 77 | - $desechappe_crochets = true; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // collecter les matchs de la preg |
|
| 81 | - $liens = static::collecteur($texte, '->', '[', $this->preg_lien, empty($options['detecter_presence']) ? 0 : 1); |
|
| 82 | - |
|
| 83 | - // si on veut seulement detecter la présence, on peut retourner tel quel |
|
| 84 | - if (empty($options['detecter_presence'])) { |
|
| 85 | - foreach ($liens as $k => &$lien) { |
|
| 86 | - $lien['href'] = end($lien['match']); |
|
| 87 | - $lien['texte'] = $lien['match'][1]; |
|
| 88 | - $lien['ouvrant'] = $lien['match'][3] ?? ''; |
|
| 89 | - |
|
| 90 | - // la mise en lien automatique est passee par la a tort ! |
|
| 91 | - // corrigeons pour eviter d'avoir un <a...> dans un href... |
|
| 92 | - if (str_starts_with((string) $lien['href'], '<a')) { |
|
| 93 | - $href = extraire_attribut($lien['href'], 'href'); |
|
| 94 | - // remplacons dans la source qui peut etre reinjectee dans les arguments |
|
| 95 | - // d'un modele |
|
| 96 | - $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 97 | - // et prenons le href comme la vraie url a linker |
|
| 98 | - $lien['href'] = $href; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - if ($desechappe_crochets && str_contains((string) $lien['raw'], "\x1")) { |
|
| 102 | - $lien['raw'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['raw']); |
|
| 103 | - $lien['texte'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['texte']); |
|
| 104 | - $lien['href'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['href']); |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return $liens; |
|
| 111 | - } |
|
| 18 | + protected static string $markPrefix = 'LIEN'; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * La preg pour découper et collecter les modèles |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected string $preg_lien; |
|
| 25 | + |
|
| 26 | + public function __construct(?string $preg = null) { |
|
| 27 | + |
|
| 28 | + // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
|
| 29 | + // Laisser passer des paires de crochets pour la balise multi |
|
| 30 | + // mais refuser plus d'imbrications ou de mauvaises imbrications |
|
| 31 | + // sinon les crochets ne peuvent plus servir qu'a ce type de raccourci |
|
| 32 | + $this->preg_lien = ($preg ?: '/\[([^][]*?([[][^]>-]*[]][^][]*)*)->(>?)([^]]*)\]/msS'); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Sanitizer une collection d'occurences de liens : il faut sanitizer le href et le texte uniquement |
|
| 38 | + * |
|
| 39 | + * @param array $collection |
|
| 40 | + * @param string $sanitize_callback |
|
| 41 | + * @return array |
|
| 42 | + */ |
|
| 43 | + protected function sanitizer_collection(array $collection, string $sanitize_callback): array { |
|
| 44 | + foreach ($collection as &$lien) { |
|
| 45 | + $t = $sanitize_callback($lien['texte']); |
|
| 46 | + if ($t !== $lien['texte']) { |
|
| 47 | + $lien['raw'] = str_replace($lien['texte'], $t, (string) $lien['raw']); |
|
| 48 | + $lien['texte'] = $t; |
|
| 49 | + } |
|
| 50 | + $href = $sanitize_callback($lien['href']); |
|
| 51 | + if ($href !== $lien['href']) { |
|
| 52 | + $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 53 | + $lien['href'] = $href; |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + return $collection; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param string $texte |
|
| 62 | + * @param array $options |
|
| 63 | + * bool $collecter_liens |
|
| 64 | + * @return array |
|
| 65 | + */ |
|
| 66 | + public function collecter(string $texte, array $options = []): array { |
|
| 67 | + if (!$texte) { |
|
| 68 | + return []; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $liens = []; |
|
| 72 | + if (str_contains($texte, '->')) { |
|
| 73 | + $desechappe_crochets = false; |
|
| 74 | + // si il y a un crochet ouvrant échappé ou un crochet fermant échappé, les substituer pour les ignorer |
|
| 75 | + if (str_contains($texte, '\[') || str_contains($texte, '\]')) { |
|
| 76 | + $texte = str_replace(['\[', '\]'], ["\x1\x5", "\x1\x6"], $texte); |
|
| 77 | + $desechappe_crochets = true; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // collecter les matchs de la preg |
|
| 81 | + $liens = static::collecteur($texte, '->', '[', $this->preg_lien, empty($options['detecter_presence']) ? 0 : 1); |
|
| 82 | + |
|
| 83 | + // si on veut seulement detecter la présence, on peut retourner tel quel |
|
| 84 | + if (empty($options['detecter_presence'])) { |
|
| 85 | + foreach ($liens as $k => &$lien) { |
|
| 86 | + $lien['href'] = end($lien['match']); |
|
| 87 | + $lien['texte'] = $lien['match'][1]; |
|
| 88 | + $lien['ouvrant'] = $lien['match'][3] ?? ''; |
|
| 89 | + |
|
| 90 | + // la mise en lien automatique est passee par la a tort ! |
|
| 91 | + // corrigeons pour eviter d'avoir un <a...> dans un href... |
|
| 92 | + if (str_starts_with((string) $lien['href'], '<a')) { |
|
| 93 | + $href = extraire_attribut($lien['href'], 'href'); |
|
| 94 | + // remplacons dans la source qui peut etre reinjectee dans les arguments |
|
| 95 | + // d'un modele |
|
| 96 | + $lien['raw'] = str_replace($lien['href'], $href, (string) $lien['raw']); |
|
| 97 | + // et prenons le href comme la vraie url a linker |
|
| 98 | + $lien['href'] = $href; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + if ($desechappe_crochets && str_contains((string) $lien['raw'], "\x1")) { |
|
| 102 | + $lien['raw'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['raw']); |
|
| 103 | + $lien['texte'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['texte']); |
|
| 104 | + $lien['href'] = str_replace(["\x1\x5", "\x1\x6"], ['[', ']'], (string) $lien['href']); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return $liens; |
|
| 111 | + } |
|
| 112 | 112 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | /** |
@@ -25,68 +25,68 @@ discard block |
||
| 25 | 25 | * @return string Code HTML du cadre dépliable |
| 26 | 26 | **/ |
| 27 | 27 | function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') { |
| 28 | - $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 28 | + $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 29 | 29 | |
| 30 | - return |
|
| 31 | - debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 32 | - . debut_block_depliable($deplie, $ids) |
|
| 33 | - . "<div class='cadre_padding'>\n" |
|
| 34 | - . $contenu |
|
| 35 | - . "</div>\n" |
|
| 36 | - . fin_block() |
|
| 37 | - . fin_cadre(); |
|
| 30 | + return |
|
| 31 | + debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 32 | + . debut_block_depliable($deplie, $ids) |
|
| 33 | + . "<div class='cadre_padding'>\n" |
|
| 34 | + . $contenu |
|
| 35 | + . "</div>\n" |
|
| 36 | + . fin_block() |
|
| 37 | + . fin_cadre(); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) { |
| 41 | - return "\n" |
|
| 42 | - . bouton_block_depliable($invite, $visible, $nom) |
|
| 43 | - . debut_block_depliable($visible, $nom) |
|
| 44 | - . $masque |
|
| 45 | - . fin_block(); |
|
| 41 | + return "\n" |
|
| 42 | + . bouton_block_depliable($invite, $visible, $nom) |
|
| 43 | + . debut_block_depliable($visible, $nom) |
|
| 44 | + . $masque |
|
| 45 | + . fin_block(); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function debut_block_depliable($deplie, $id = '') { |
| 49 | - $class = ' blocdeplie'; |
|
| 50 | - // si on n'accepte pas js, ne pas fermer |
|
| 51 | - if (!$deplie) { |
|
| 52 | - $class = ' blocreplie'; |
|
| 53 | - } |
|
| 49 | + $class = ' blocdeplie'; |
|
| 50 | + // si on n'accepte pas js, ne pas fermer |
|
| 51 | + if (!$deplie) { |
|
| 52 | + $class = ' blocreplie'; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>"; |
|
| 55 | + return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>"; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function fin_block() { |
| 59 | - return "<div class='nettoyeur'></div>\n</div>"; |
|
| 59 | + return "<div class='nettoyeur'></div>\n</div>"; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // $texte : texte du bouton |
| 63 | 63 | // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page |
| 64 | 64 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 65 | 65 | function bouton_block_depliable($texte, $deplie, $ids = '') { |
| 66 | - $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 66 | + $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 67 | 67 | |
| 68 | - $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie'); |
|
| 69 | - if (strlen((string) $ids)) { |
|
| 70 | - $cible = explode(',', (string) $ids); |
|
| 71 | - $cible = '#' . implode(',#', $cible); |
|
| 72 | - } else { |
|
| 73 | - $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 74 | - } |
|
| 68 | + $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie'); |
|
| 69 | + if (strlen((string) $ids)) { |
|
| 70 | + $cible = explode(',', (string) $ids); |
|
| 71 | + $cible = '#' . implode(',#', $cible); |
|
| 72 | + } else { |
|
| 73 | + $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $b = (str_contains((string) $texte, '<h') ? 'div' : 'h3'); |
|
| 76 | + $b = (str_contains((string) $texte, '<h') ? 'div' : 'h3'); |
|
| 77 | 77 | |
| 78 | - return "<$b " |
|
| 79 | - . ($bouton_id ? "id='$bouton_id' " : '') |
|
| 80 | - . "class='titrem$class'" |
|
| 81 | - . (($deplie === -1) |
|
| 82 | - ? '' |
|
| 83 | - : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 84 | - ) |
|
| 85 | - . '>' |
|
| 86 | - // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 87 | - . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 88 | - . "$texte</$b>" |
|
| 89 | - . http_script(($deplie === 'incertain') |
|
| 90 | - ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 91 | - : ''); |
|
| 78 | + return "<$b " |
|
| 79 | + . ($bouton_id ? "id='$bouton_id' " : '') |
|
| 80 | + . "class='titrem$class'" |
|
| 81 | + . (($deplie === -1) |
|
| 82 | + ? '' |
|
| 83 | + : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 84 | + ) |
|
| 85 | + . '>' |
|
| 86 | + // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 87 | + . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 88 | + . "$texte</$b>" |
|
| 89 | + . http_script(($deplie === 'incertain') |
|
| 90 | + ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 91 | + : ''); |
|
| 92 | 92 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -32,16 +32,16 @@ discard block |
||
| 32 | 32 | * @return array|bool|null |
| 33 | 33 | */ |
| 34 | 34 | function quete_virtuel($id_article, $connect) { |
| 35 | - return sql_getfetsel( |
|
| 36 | - 'virtuel', |
|
| 37 | - 'spip_articles', |
|
| 38 | - ['id_article=' . (int) $id_article, "statut='publie'"], |
|
| 39 | - '', |
|
| 40 | - '', |
|
| 41 | - '', |
|
| 42 | - '', |
|
| 43 | - $connect |
|
| 44 | - ); |
|
| 35 | + return sql_getfetsel( |
|
| 36 | + 'virtuel', |
|
| 37 | + 'spip_articles', |
|
| 38 | + ['id_article=' . (int) $id_article, "statut='publie'"], |
|
| 39 | + '', |
|
| 40 | + '', |
|
| 41 | + '', |
|
| 42 | + '', |
|
| 43 | + $connect |
|
| 44 | + ); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -56,39 +56,39 @@ discard block |
||
| 56 | 56 | * @return array |
| 57 | 57 | */ |
| 58 | 58 | function quete_parent_lang($table, $id, string $connect = '') { |
| 59 | - static $cache_quete = []; |
|
| 60 | - |
|
| 61 | - if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 62 | - if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 63 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | - if ( |
|
| 65 | - !($desc = $trouver_table($table, $connect)) |
|
| 66 | - || !isset($desc['field']['id_rubrique']) |
|
| 67 | - ) { |
|
| 68 | - // pas de parent rubrique, on passe |
|
| 69 | - $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | - } else { |
|
| 71 | - $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | - $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | - $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | - $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | - $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | - $cache_quete[$connect][$table]['_select'], |
|
| 80 | - $table, |
|
| 81 | - $cache_quete[$connect][$table]['_id'] . '=' . (int) $id, |
|
| 82 | - '', |
|
| 83 | - '', |
|
| 84 | - '', |
|
| 85 | - '', |
|
| 86 | - $connect |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return $cache_quete[$connect][$table][$id] ?? null; |
|
| 59 | + static $cache_quete = []; |
|
| 60 | + |
|
| 61 | + if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 62 | + if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 63 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 64 | + if ( |
|
| 65 | + !($desc = $trouver_table($table, $connect)) |
|
| 66 | + || !isset($desc['field']['id_rubrique']) |
|
| 67 | + ) { |
|
| 68 | + // pas de parent rubrique, on passe |
|
| 69 | + $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | + } else { |
|
| 71 | + $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | + $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | + $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | + $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | + $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | + $cache_quete[$connect][$table]['_select'], |
|
| 80 | + $table, |
|
| 81 | + $cache_quete[$connect][$table]['_id'] . '=' . (int) $id, |
|
| 82 | + '', |
|
| 83 | + '', |
|
| 84 | + '', |
|
| 85 | + '', |
|
| 86 | + $connect |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return $cache_quete[$connect][$table][$id] ?? null; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | * @return int |
| 106 | 106 | */ |
| 107 | 107 | function quete_parent($id_rubrique, string $connect = '') { |
| 108 | - if (!$id_rubrique = (int) $id_rubrique) { |
|
| 109 | - return 0; |
|
| 110 | - } |
|
| 111 | - $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 112 | - return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 108 | + if (!$id_rubrique = (int) $id_rubrique) { |
|
| 109 | + return 0; |
|
| 110 | + } |
|
| 111 | + $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 112 | + return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | * @return int |
| 126 | 126 | */ |
| 127 | 127 | function quete_rubrique($id_article, $serveur) { |
| 128 | - $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 128 | + $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 129 | 129 | |
| 130 | - return $id_parent['id_rubrique'] ?? 0; |
|
| 130 | + return $id_parent['id_rubrique'] ?? 0; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -140,13 +140,13 @@ discard block |
||
| 140 | 140 | * @return int |
| 141 | 141 | */ |
| 142 | 142 | function quete_profondeur($id, string $connect = '') { |
| 143 | - $n = 0; |
|
| 144 | - while ($id) { |
|
| 145 | - $n++; |
|
| 146 | - $id = quete_parent($id, $connect); |
|
| 147 | - } |
|
| 143 | + $n = 0; |
|
| 144 | + while ($id) { |
|
| 145 | + $n++; |
|
| 146 | + $id = quete_parent($id, $connect); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return $n; |
|
| 149 | + return $n; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
@@ -162,15 +162,15 @@ discard block |
||
| 162 | 162 | * Morceau de la requête SQL testant la date |
| 163 | 163 | */ |
| 164 | 164 | function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) { |
| 165 | - if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 166 | - return '1=1'; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - return |
|
| 170 | - (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 171 | - && $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 172 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 173 | - : '1=1'; |
|
| 165 | + if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 166 | + return '1=1'; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + return |
|
| 170 | + (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 171 | + && $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 172 | + ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 173 | + : '1=1'; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | |
@@ -190,101 +190,101 @@ discard block |
||
| 190 | 190 | * @return array|string |
| 191 | 191 | */ |
| 192 | 192 | function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) { |
| 193 | - static $cond = []; |
|
| 194 | - $key = func_get_args(); |
|
| 195 | - $key = implode('-', $key); |
|
| 196 | - if (isset($cond[$key])) { |
|
| 197 | - return $cond[$key]; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $liste_statuts = $publie; |
|
| 201 | - if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 202 | - $liste_statuts = $previsu; |
|
| 203 | - } |
|
| 204 | - $not = false; |
|
| 205 | - if (str_starts_with($liste_statuts, '!')) { |
|
| 206 | - $not = true; |
|
| 207 | - $liste_statuts = substr($liste_statuts, 1); |
|
| 208 | - } |
|
| 209 | - // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 210 | - if (!strlen($liste_statuts)) { |
|
| 211 | - return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - $liste_statuts = explode(',', $liste_statuts); |
|
| 215 | - $where = []; |
|
| 216 | - foreach ($liste_statuts as $k => $v) { |
|
| 217 | - // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 218 | - // a ceux de l'auteur identifie |
|
| 219 | - if (str_contains($v, '/')) { |
|
| 220 | - $v = explode('/', $v); |
|
| 221 | - $filtre = end($v); |
|
| 222 | - $v = reset($v); |
|
| 223 | - $v = preg_replace(',\W,', '', $v); |
|
| 224 | - if ( |
|
| 225 | - $filtre == 'auteur' |
|
| 226 | - && str_contains($mstatut, '.') |
|
| 227 | - && ($objet = explode('.', $mstatut)) |
|
| 228 | - && ($id_table = reset($objet)) |
|
| 229 | - && ($objet = objet_type($id_table)) |
|
| 230 | - ) { |
|
| 231 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | - |
|
| 233 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 234 | - // sinon l’auteur en session |
|
| 235 | - include_spip('inc/securiser_action'); |
|
| 236 | - if ($desc = decrire_token_previsu()) { |
|
| 237 | - $id_auteur = $desc['id_auteur']; |
|
| 238 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 239 | - $id_auteur = (int) $GLOBALS['visiteur_session']['id_auteur']; |
|
| 240 | - } else { |
|
| 241 | - $id_auteur = null; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 245 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | - // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 247 | - if (!$id_auteur) { |
|
| 248 | - $where[] = $w; |
|
| 249 | - } else { |
|
| 250 | - $primary = id_table_objet($objet); |
|
| 251 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | - 'ssss.id_objet', |
|
| 253 | - 'spip_auteurs_liens AS ssss', |
|
| 254 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . (int) $id_auteur, |
|
| 255 | - '', |
|
| 256 | - '', |
|
| 257 | - '', |
|
| 258 | - '', |
|
| 259 | - $serveur |
|
| 260 | - ) . '))'; |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 264 | - else { |
|
| 265 | - $v = ''; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - // securite |
|
| 269 | - $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 270 | - } |
|
| 271 | - $liste_statuts = array_filter($liste_statuts); |
|
| 272 | - if (count($liste_statuts) == 1) { |
|
| 273 | - $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 274 | - } else { |
|
| 275 | - $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - while (count($where) > 1) { |
|
| 279 | - $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 280 | - $where[] = $and; |
|
| 281 | - } |
|
| 282 | - $cond[$key] = reset($where); |
|
| 283 | - if ($not) { |
|
| 284 | - $cond[$key] = ['NOT', $cond[$key]]; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - return $cond[$key]; |
|
| 193 | + static $cond = []; |
|
| 194 | + $key = func_get_args(); |
|
| 195 | + $key = implode('-', $key); |
|
| 196 | + if (isset($cond[$key])) { |
|
| 197 | + return $cond[$key]; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $liste_statuts = $publie; |
|
| 201 | + if (defined('_VAR_PREVIEW') && _VAR_PREVIEW && !$ignore_previsu) { |
|
| 202 | + $liste_statuts = $previsu; |
|
| 203 | + } |
|
| 204 | + $not = false; |
|
| 205 | + if (str_starts_with($liste_statuts, '!')) { |
|
| 206 | + $not = true; |
|
| 207 | + $liste_statuts = substr($liste_statuts, 1); |
|
| 208 | + } |
|
| 209 | + // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 210 | + if (!strlen($liste_statuts)) { |
|
| 211 | + return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + $liste_statuts = explode(',', $liste_statuts); |
|
| 215 | + $where = []; |
|
| 216 | + foreach ($liste_statuts as $k => $v) { |
|
| 217 | + // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 218 | + // a ceux de l'auteur identifie |
|
| 219 | + if (str_contains($v, '/')) { |
|
| 220 | + $v = explode('/', $v); |
|
| 221 | + $filtre = end($v); |
|
| 222 | + $v = reset($v); |
|
| 223 | + $v = preg_replace(',\W,', '', $v); |
|
| 224 | + if ( |
|
| 225 | + $filtre == 'auteur' |
|
| 226 | + && str_contains($mstatut, '.') |
|
| 227 | + && ($objet = explode('.', $mstatut)) |
|
| 228 | + && ($id_table = reset($objet)) |
|
| 229 | + && ($objet = objet_type($id_table)) |
|
| 230 | + ) { |
|
| 231 | + $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | + |
|
| 233 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 234 | + // sinon l’auteur en session |
|
| 235 | + include_spip('inc/securiser_action'); |
|
| 236 | + if ($desc = decrire_token_previsu()) { |
|
| 237 | + $id_auteur = $desc['id_auteur']; |
|
| 238 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 239 | + $id_auteur = (int) $GLOBALS['visiteur_session']['id_auteur']; |
|
| 240 | + } else { |
|
| 241 | + $id_auteur = null; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 245 | + if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | + // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 247 | + if (!$id_auteur) { |
|
| 248 | + $where[] = $w; |
|
| 249 | + } else { |
|
| 250 | + $primary = id_table_objet($objet); |
|
| 251 | + $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | + 'ssss.id_objet', |
|
| 253 | + 'spip_auteurs_liens AS ssss', |
|
| 254 | + 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . (int) $id_auteur, |
|
| 255 | + '', |
|
| 256 | + '', |
|
| 257 | + '', |
|
| 258 | + '', |
|
| 259 | + $serveur |
|
| 260 | + ) . '))'; |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 264 | + else { |
|
| 265 | + $v = ''; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + // securite |
|
| 269 | + $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 270 | + } |
|
| 271 | + $liste_statuts = array_filter($liste_statuts); |
|
| 272 | + if (count($liste_statuts) == 1) { |
|
| 273 | + $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 274 | + } else { |
|
| 275 | + $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + while (count($where) > 1) { |
|
| 279 | + $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 280 | + $where[] = $and; |
|
| 281 | + } |
|
| 282 | + $cond[$key] = reset($where); |
|
| 283 | + if ($not) { |
|
| 284 | + $cond[$key] = ['NOT', $cond[$key]]; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + return $cond[$key]; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * @return array|bool|null |
| 296 | 296 | */ |
| 297 | 297 | function quete_fichier($id_document, $serveur = '') { |
| 298 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 298 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | * @return array|bool |
| 307 | 307 | */ |
| 308 | 308 | function quete_document($id_document, $serveur = '') { |
| 309 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 309 | + return sql_fetsel('*', 'spip_documents', ('id_document=' . (int) $id_document), '', [], '', '', $serveur); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /** |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | * @return array|bool|null |
| 318 | 318 | */ |
| 319 | 319 | function quete_meta($nom, $serveur) { |
| 320 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 320 | + return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /** |
@@ -343,67 +343,67 @@ discard block |
||
| 343 | 343 | * Retourne soit un tableau, soit le chemin du fichier. |
| 344 | 344 | */ |
| 345 | 345 | function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag = false) { |
| 346 | - include_spip('base/objets'); |
|
| 347 | - $nom = strtolower($onoff); |
|
| 348 | - |
|
| 349 | - $cle_objet = id_table_objet($cle_objet); |
|
| 350 | - |
|
| 351 | - while (1) { |
|
| 352 | - $objet = objet_type($cle_objet); |
|
| 353 | - |
|
| 354 | - $on = quete_logo_objet($id, $objet, $nom); |
|
| 355 | - |
|
| 356 | - if ($on) { |
|
| 357 | - if ($flag) { |
|
| 358 | - return $on['fichier']; |
|
| 359 | - } else { |
|
| 360 | - $taille = @spip_getimagesize($on['chemin']); |
|
| 361 | - |
|
| 362 | - // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 363 | - // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 364 | - // alors on ne cherche pas du tout le survol ici |
|
| 365 | - $off = $onoff != 'ON' ? '' : quete_logo_objet($id, $objet, 'off'); |
|
| 366 | - |
|
| 367 | - // on retourne une url du type IMG/artonXX?timestamp |
|
| 368 | - // qui permet de distinguer le changement de logo |
|
| 369 | - // et placer un expire sur le dossier IMG/ |
|
| 370 | - $res = [ |
|
| 371 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 372 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 373 | - ($taille ? ' ' . $taille[3] : ('')) |
|
| 374 | - ]; |
|
| 375 | - $res['src'] = $res[0]; |
|
| 376 | - $res['logo_on'] = $res[0]; |
|
| 377 | - $res['logo_off'] = $res[1]; |
|
| 378 | - $res['width'] = ($taille ? $taille[0] : ''); |
|
| 379 | - $res['height'] = ($taille ? $taille[1] : ''); |
|
| 380 | - $res['fichier'] = $on['fichier']; |
|
| 381 | - $res['titre'] = ($on['titre'] ?? ''); |
|
| 382 | - $res['descriptif'] = ($on['descriptif'] ?? ''); |
|
| 383 | - $res['credits'] = ($on['credits'] ?? ''); |
|
| 384 | - $res['alt'] = ($on['alt'] ?? ''); |
|
| 385 | - $res['id'] = ($on['id_document'] ?? 0); |
|
| 386 | - |
|
| 387 | - return $res; |
|
| 388 | - } |
|
| 389 | - } else { |
|
| 390 | - if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 391 | - return ''; |
|
| 392 | - } else { |
|
| 393 | - if ($id_rubrique) { |
|
| 394 | - $cle_objet = 'id_rubrique'; |
|
| 395 | - $id = $id_rubrique; |
|
| 396 | - $id_rubrique = 0; |
|
| 397 | - } else { |
|
| 398 | - if ($id && $cle_objet == 'id_rubrique') { |
|
| 399 | - $id = quete_parent($id); |
|
| 400 | - } else { |
|
| 401 | - return ''; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - } |
|
| 346 | + include_spip('base/objets'); |
|
| 347 | + $nom = strtolower($onoff); |
|
| 348 | + |
|
| 349 | + $cle_objet = id_table_objet($cle_objet); |
|
| 350 | + |
|
| 351 | + while (1) { |
|
| 352 | + $objet = objet_type($cle_objet); |
|
| 353 | + |
|
| 354 | + $on = quete_logo_objet($id, $objet, $nom); |
|
| 355 | + |
|
| 356 | + if ($on) { |
|
| 357 | + if ($flag) { |
|
| 358 | + return $on['fichier']; |
|
| 359 | + } else { |
|
| 360 | + $taille = @spip_getimagesize($on['chemin']); |
|
| 361 | + |
|
| 362 | + // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 363 | + // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 364 | + // alors on ne cherche pas du tout le survol ici |
|
| 365 | + $off = $onoff != 'ON' ? '' : quete_logo_objet($id, $objet, 'off'); |
|
| 366 | + |
|
| 367 | + // on retourne une url du type IMG/artonXX?timestamp |
|
| 368 | + // qui permet de distinguer le changement de logo |
|
| 369 | + // et placer un expire sur le dossier IMG/ |
|
| 370 | + $res = [ |
|
| 371 | + $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 372 | + ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 373 | + ($taille ? ' ' . $taille[3] : ('')) |
|
| 374 | + ]; |
|
| 375 | + $res['src'] = $res[0]; |
|
| 376 | + $res['logo_on'] = $res[0]; |
|
| 377 | + $res['logo_off'] = $res[1]; |
|
| 378 | + $res['width'] = ($taille ? $taille[0] : ''); |
|
| 379 | + $res['height'] = ($taille ? $taille[1] : ''); |
|
| 380 | + $res['fichier'] = $on['fichier']; |
|
| 381 | + $res['titre'] = ($on['titre'] ?? ''); |
|
| 382 | + $res['descriptif'] = ($on['descriptif'] ?? ''); |
|
| 383 | + $res['credits'] = ($on['credits'] ?? ''); |
|
| 384 | + $res['alt'] = ($on['alt'] ?? ''); |
|
| 385 | + $res['id'] = ($on['id_document'] ?? 0); |
|
| 386 | + |
|
| 387 | + return $res; |
|
| 388 | + } |
|
| 389 | + } else { |
|
| 390 | + if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 391 | + return ''; |
|
| 392 | + } else { |
|
| 393 | + if ($id_rubrique) { |
|
| 394 | + $cle_objet = 'id_rubrique'; |
|
| 395 | + $id = $id_rubrique; |
|
| 396 | + $id_rubrique = 0; |
|
| 397 | + } else { |
|
| 398 | + if ($id && $cle_objet == 'id_rubrique') { |
|
| 399 | + $id = quete_parent($id); |
|
| 400 | + } else { |
|
| 401 | + return ''; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -418,43 +418,43 @@ discard block |
||
| 418 | 418 | * @return bool|array |
| 419 | 419 | **/ |
| 420 | 420 | function quete_logo_objet($id_objet, $objet, $mode) { |
| 421 | - static $chercher_logo; |
|
| 422 | - if (is_null($chercher_logo)) { |
|
| 423 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 424 | - } |
|
| 425 | - $cle_objet = id_table_objet($objet); |
|
| 426 | - |
|
| 427 | - // On cherche pas la méthode classique |
|
| 428 | - $infos_logo = $chercher_logo((int) $id_objet, $cle_objet, $mode); |
|
| 429 | - |
|
| 430 | - // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 431 | - if (!empty($infos_logo)) { |
|
| 432 | - $infos = [ |
|
| 433 | - 'chemin' => $infos_logo[0], |
|
| 434 | - 'timestamp' => $infos_logo[4], |
|
| 435 | - 'id_document' => ($infos_logo[5]['id_document'] ?? ''), |
|
| 436 | - ]; |
|
| 437 | - foreach (['fichier', 'titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 438 | - $infos[$champ] = ($infos_logo[5][$champ] ?? ''); |
|
| 439 | - } |
|
| 440 | - $infos_logo = $infos; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - // On passe cette recherche de logo dans un pipeline |
|
| 444 | - $infos_logo = pipeline( |
|
| 445 | - 'quete_logo_objet', |
|
| 446 | - [ |
|
| 447 | - 'args' => [ |
|
| 448 | - 'id_objet' => $id_objet, |
|
| 449 | - 'objet' => $objet, |
|
| 450 | - 'cle_objet' => $cle_objet, |
|
| 451 | - 'mode' => $mode, |
|
| 452 | - ], |
|
| 453 | - 'data' => $infos_logo, |
|
| 454 | - ] |
|
| 455 | - ); |
|
| 456 | - |
|
| 457 | - return $infos_logo; |
|
| 421 | + static $chercher_logo; |
|
| 422 | + if (is_null($chercher_logo)) { |
|
| 423 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 424 | + } |
|
| 425 | + $cle_objet = id_table_objet($objet); |
|
| 426 | + |
|
| 427 | + // On cherche pas la méthode classique |
|
| 428 | + $infos_logo = $chercher_logo((int) $id_objet, $cle_objet, $mode); |
|
| 429 | + |
|
| 430 | + // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 431 | + if (!empty($infos_logo)) { |
|
| 432 | + $infos = [ |
|
| 433 | + 'chemin' => $infos_logo[0], |
|
| 434 | + 'timestamp' => $infos_logo[4], |
|
| 435 | + 'id_document' => ($infos_logo[5]['id_document'] ?? ''), |
|
| 436 | + ]; |
|
| 437 | + foreach (['fichier', 'titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 438 | + $infos[$champ] = ($infos_logo[5][$champ] ?? ''); |
|
| 439 | + } |
|
| 440 | + $infos_logo = $infos; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + // On passe cette recherche de logo dans un pipeline |
|
| 444 | + $infos_logo = pipeline( |
|
| 445 | + 'quete_logo_objet', |
|
| 446 | + [ |
|
| 447 | + 'args' => [ |
|
| 448 | + 'id_objet' => $id_objet, |
|
| 449 | + 'objet' => $objet, |
|
| 450 | + 'cle_objet' => $cle_objet, |
|
| 451 | + 'mode' => $mode, |
|
| 452 | + ], |
|
| 453 | + 'data' => $infos_logo, |
|
| 454 | + ] |
|
| 455 | + ); |
|
| 456 | + |
|
| 457 | + return $infos_logo; |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -467,25 +467,25 @@ discard block |
||
| 467 | 467 | * @return bool|string |
| 468 | 468 | */ |
| 469 | 469 | function quete_logo_file($row, $connect = null) { |
| 470 | - include_spip('inc/documents'); |
|
| 471 | - $logo = vignette_logo_document($row, $connect); |
|
| 472 | - if (!$logo) { |
|
| 473 | - $logo = image_du_document($row, $connect); |
|
| 474 | - } |
|
| 475 | - if (!$logo) { |
|
| 476 | - $f = charger_fonction('vignette', 'inc'); |
|
| 477 | - $logo = $f($row['extension'], false); |
|
| 478 | - } |
|
| 479 | - // si c'est une vignette type doc, la renvoyer direct |
|
| 480 | - if ( |
|
| 481 | - strcmp((string) $logo, (string) _DIR_PLUGINS) == 0 |
|
| 482 | - || strcmp((string) $logo, (string) _DIR_PLUGINS_DIST) == 0 |
|
| 483 | - || strcmp((string) $logo, _DIR_RACINE . 'prive/') == 0 |
|
| 484 | - ) { |
|
| 485 | - return $logo; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - return get_spip_doc($logo); |
|
| 470 | + include_spip('inc/documents'); |
|
| 471 | + $logo = vignette_logo_document($row, $connect); |
|
| 472 | + if (!$logo) { |
|
| 473 | + $logo = image_du_document($row, $connect); |
|
| 474 | + } |
|
| 475 | + if (!$logo) { |
|
| 476 | + $f = charger_fonction('vignette', 'inc'); |
|
| 477 | + $logo = $f($row['extension'], false); |
|
| 478 | + } |
|
| 479 | + // si c'est une vignette type doc, la renvoyer direct |
|
| 480 | + if ( |
|
| 481 | + strcmp((string) $logo, (string) _DIR_PLUGINS) == 0 |
|
| 482 | + || strcmp((string) $logo, (string) _DIR_PLUGINS_DIST) == 0 |
|
| 483 | + || strcmp((string) $logo, _DIR_RACINE . 'prive/') == 0 |
|
| 484 | + ) { |
|
| 485 | + return $logo; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + return get_spip_doc($logo); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -513,20 +513,20 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, string $connect = '') { |
| 515 | 515 | |
| 516 | - include_spip('inc/documents'); |
|
| 517 | - $logo = ''; |
|
| 518 | - if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 519 | - $logo = vignette_logo_document($row, $connect); |
|
| 520 | - } |
|
| 521 | - // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 522 | - if ($mode_logo == 'vignette' && !$logo) { |
|
| 523 | - return ''; |
|
| 524 | - } |
|
| 525 | - if ($mode_logo == 'icone') { |
|
| 526 | - $row['fichier'] = ''; |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 516 | + include_spip('inc/documents'); |
|
| 517 | + $logo = ''; |
|
| 518 | + if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 519 | + $logo = vignette_logo_document($row, $connect); |
|
| 520 | + } |
|
| 521 | + // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 522 | + if ($mode_logo == 'vignette' && !$logo) { |
|
| 523 | + return ''; |
|
| 524 | + } |
|
| 525 | + if ($mode_logo == 'icone') { |
|
| 526 | + $row['fichier'] = ''; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -538,26 +538,26 @@ discard block |
||
| 538 | 538 | */ |
| 539 | 539 | function quete_html_logo($logo, $align, $lien) { |
| 540 | 540 | |
| 541 | - if (!is_array($logo)) { |
|
| 542 | - return ''; |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - $contexte = []; |
|
| 546 | - foreach ($logo as $k => $v) { |
|
| 547 | - if (!is_numeric($k)) { |
|
| 548 | - $contexte[$k] = $v; |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - foreach (['titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 553 | - if (!empty($contexte[$champ])) { |
|
| 554 | - $contexte[$champ] = appliquer_traitement_champ($contexte[$champ], $champ, 'document'); |
|
| 555 | - } |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - $contexte['align'] = $align; |
|
| 559 | - $contexte['lien'] = $lien; |
|
| 560 | - return recuperer_fond('modeles/logo', $contexte); |
|
| 541 | + if (!is_array($logo)) { |
|
| 542 | + return ''; |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + $contexte = []; |
|
| 546 | + foreach ($logo as $k => $v) { |
|
| 547 | + if (!is_numeric($k)) { |
|
| 548 | + $contexte[$k] = $v; |
|
| 549 | + } |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + foreach (['titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 553 | + if (!empty($contexte[$champ])) { |
|
| 554 | + $contexte[$champ] = appliquer_traitement_champ($contexte[$champ], $champ, 'document'); |
|
| 555 | + } |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + $contexte['align'] = $align; |
|
| 559 | + $contexte['lien'] = $lien; |
|
| 560 | + return recuperer_fond('modeles/logo', $contexte); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | /** |
@@ -571,14 +571,14 @@ discard block |
||
| 571 | 571 | * @return string|false |
| 572 | 572 | */ |
| 573 | 573 | function document_spip_externe($fichier, $connect) { |
| 574 | - if ($connect) { |
|
| 575 | - $site = quete_meta('adresse_site', $connect); |
|
| 576 | - if ($site) { |
|
| 577 | - $dir = quete_meta('dir_img', $connect); |
|
| 578 | - return "$site/$dir$fichier"; |
|
| 579 | - } |
|
| 580 | - } |
|
| 581 | - return false; |
|
| 574 | + if ($connect) { |
|
| 575 | + $site = quete_meta('adresse_site', $connect); |
|
| 576 | + if ($site) { |
|
| 577 | + $dir = quete_meta('dir_img', $connect); |
|
| 578 | + return "$site/$dir$fichier"; |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | + return false; |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | /** |
@@ -591,23 +591,23 @@ discard block |
||
| 591 | 591 | */ |
| 592 | 592 | function vignette_logo_document($row, string $connect = '') { |
| 593 | 593 | |
| 594 | - if (!$row || empty($row['id_vignette'])) { |
|
| 595 | - return ''; |
|
| 596 | - } |
|
| 597 | - $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 598 | - if ($url = document_spip_externe($fichier, $connect)) { |
|
| 599 | - return $url; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - $f = get_spip_doc($fichier); |
|
| 603 | - if ($f && @file_exists($f)) { |
|
| 604 | - return $f; |
|
| 605 | - } |
|
| 606 | - if ($row['mode'] !== 'vignette') { |
|
| 607 | - return ''; |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 594 | + if (!$row || empty($row['id_vignette'])) { |
|
| 595 | + return ''; |
|
| 596 | + } |
|
| 597 | + $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 598 | + if ($url = document_spip_externe($fichier, $connect)) { |
|
| 599 | + return $url; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + $f = get_spip_doc($fichier); |
|
| 603 | + if ($f && @file_exists($f)) { |
|
| 604 | + return $f; |
|
| 605 | + } |
|
| 606 | + if ($row['mode'] !== 'vignette') { |
|
| 607 | + return ''; |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 611 | 611 | } |
| 612 | 612 | |
| 613 | 613 | /** |
@@ -622,66 +622,66 @@ discard block |
||
| 622 | 622 | * @return bool|string |
| 623 | 623 | */ |
| 624 | 624 | function calcul_exposer($id, $prim, $reference, $parent, $type, string $connect = '') { |
| 625 | - static $exposer = []; |
|
| 626 | - |
|
| 627 | - // Que faut-il exposer ? Tous les elements de $reference |
|
| 628 | - // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 629 | - // qu'une fois (par squelette) et on conserve le resultat |
|
| 630 | - // en static. |
|
| 631 | - if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 632 | - $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 633 | - // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 634 | - // il n'est donc pas utile |
|
| 635 | - $parent = 0; |
|
| 636 | - if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 637 | - $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 638 | - if (isset($enfants[$type])) { |
|
| 639 | - foreach ($enfants[$type] as $t) { |
|
| 640 | - if ( |
|
| 641 | - isset($reference[$t]) |
|
| 642 | - // cas de la reference donnee dynamiquement par la pagination |
|
| 643 | - || isset($reference["@$t"]) |
|
| 644 | - ) { |
|
| 645 | - $type = $t; |
|
| 646 | - $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 647 | - continue; |
|
| 648 | - } |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - $exposer[$m][$type] = []; |
|
| 653 | - if ($principal) { |
|
| 654 | - $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 655 | - foreach ($principaux as $principal) { |
|
| 656 | - $exposer[$m][$type][$principal] = true; |
|
| 657 | - if ($type == 'id_mot') { |
|
| 658 | - if (!$parent) { |
|
| 659 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . (int) $principal, '', '', '', '', $connect); |
|
| 660 | - } |
|
| 661 | - if ($parent) { |
|
| 662 | - $exposer[$m]['id_groupe'][$parent] = true; |
|
| 663 | - } |
|
| 664 | - } else { |
|
| 665 | - if ($type != 'id_groupe') { |
|
| 666 | - if (!$parent) { |
|
| 667 | - if ($type == 'id_rubrique') { |
|
| 668 | - $parent = $principal; |
|
| 669 | - } |
|
| 670 | - if ($type == 'id_article') { |
|
| 671 | - $parent = quete_rubrique($principal, $connect); |
|
| 672 | - } |
|
| 673 | - } |
|
| 674 | - do { |
|
| 675 | - $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 676 | - } while ($parent = quete_parent($parent, $connect)); |
|
| 677 | - } |
|
| 678 | - } |
|
| 679 | - } |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - // And the winner is... |
|
| 684 | - return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 625 | + static $exposer = []; |
|
| 626 | + |
|
| 627 | + // Que faut-il exposer ? Tous les elements de $reference |
|
| 628 | + // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 629 | + // qu'une fois (par squelette) et on conserve le resultat |
|
| 630 | + // en static. |
|
| 631 | + if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 632 | + $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 633 | + // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 634 | + // il n'est donc pas utile |
|
| 635 | + $parent = 0; |
|
| 636 | + if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 637 | + $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 638 | + if (isset($enfants[$type])) { |
|
| 639 | + foreach ($enfants[$type] as $t) { |
|
| 640 | + if ( |
|
| 641 | + isset($reference[$t]) |
|
| 642 | + // cas de la reference donnee dynamiquement par la pagination |
|
| 643 | + || isset($reference["@$t"]) |
|
| 644 | + ) { |
|
| 645 | + $type = $t; |
|
| 646 | + $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 647 | + continue; |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + $exposer[$m][$type] = []; |
|
| 653 | + if ($principal) { |
|
| 654 | + $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 655 | + foreach ($principaux as $principal) { |
|
| 656 | + $exposer[$m][$type][$principal] = true; |
|
| 657 | + if ($type == 'id_mot') { |
|
| 658 | + if (!$parent) { |
|
| 659 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . (int) $principal, '', '', '', '', $connect); |
|
| 660 | + } |
|
| 661 | + if ($parent) { |
|
| 662 | + $exposer[$m]['id_groupe'][$parent] = true; |
|
| 663 | + } |
|
| 664 | + } else { |
|
| 665 | + if ($type != 'id_groupe') { |
|
| 666 | + if (!$parent) { |
|
| 667 | + if ($type == 'id_rubrique') { |
|
| 668 | + $parent = $principal; |
|
| 669 | + } |
|
| 670 | + if ($type == 'id_article') { |
|
| 671 | + $parent = quete_rubrique($principal, $connect); |
|
| 672 | + } |
|
| 673 | + } |
|
| 674 | + do { |
|
| 675 | + $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 676 | + } while ($parent = quete_parent($parent, $connect)); |
|
| 677 | + } |
|
| 678 | + } |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + // And the winner is... |
|
| 684 | + return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -696,23 +696,23 @@ discard block |
||
| 696 | 696 | * @return int |
| 697 | 697 | */ |
| 698 | 698 | function quete_debut_pagination($primary, $valeur, $pas, $iter) { |
| 699 | - // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 700 | - // ou composee, mais verifions |
|
| 701 | - if (!$primary || preg_match('/[,\s]/', $primary)) { |
|
| 702 | - return 0; |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - $pos = 0; |
|
| 706 | - while (($row = $iter->fetch()) && $row[$primary] != $valeur) { |
|
| 707 | - $pos++; |
|
| 708 | - } |
|
| 709 | - // si on a pas trouve |
|
| 710 | - if (!$row || $row[$primary] != $valeur) { |
|
| 711 | - return 0; |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - // sinon, calculer le bon numero de page |
|
| 715 | - return floor($pos / $pas) * $pas; |
|
| 699 | + // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 700 | + // ou composee, mais verifions |
|
| 701 | + if (!$primary || preg_match('/[,\s]/', $primary)) { |
|
| 702 | + return 0; |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + $pos = 0; |
|
| 706 | + while (($row = $iter->fetch()) && $row[$primary] != $valeur) { |
|
| 707 | + $pos++; |
|
| 708 | + } |
|
| 709 | + // si on a pas trouve |
|
| 710 | + if (!$row || $row[$primary] != $valeur) { |
|
| 711 | + return 0; |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + // sinon, calculer le bon numero de page |
|
| 715 | + return floor($pos / $pas) * $pas; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | /** |
@@ -722,8 +722,8 @@ discard block |
||
| 722 | 722 | * @return boolean |
| 723 | 723 | */ |
| 724 | 724 | function is_whereable(mixed $value): bool { |
| 725 | - if (is_array($value) && count($value)) { |
|
| 726 | - return true; |
|
| 727 | - } |
|
| 728 | - return is_scalar($value) && strlen($value); |
|
| 725 | + if (is_array($value) && count($value)) { |
|
| 726 | + return true; |
|
| 727 | + } |
|
| 728 | + return is_scalar($value) && strlen($value); |
|
| 729 | 729 | } |
@@ -12,6 +12,6 @@ |
||
| 12 | 12 | * @return string Le SHA de la chaîne |
| 13 | 13 | */ |
| 14 | 14 | function spip_sha256($str) { |
| 15 | - trigger_deprecation('spip', '5.0', 'Using "%s" is deprecated, use "%s" instead.', 'spip_sha256($str)', 'hash(\'sha256\', $str)'); |
|
| 16 | - return hash('sha256', $str); |
|
| 15 | + trigger_deprecation('spip', '5.0', 'Using "%s" is deprecated, use "%s" instead.', 'spip_sha256($str)', 'hash(\'sha256\', $str)'); |
|
| 16 | + return hash('sha256', $str); |
|
| 17 | 17 | } |