@@ -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 | /** |
@@ -40,29 +40,29 @@ discard block |
||
| 40 | 40 | * Pile complétée par le code à générer |
| 41 | 41 | */ |
| 42 | 42 | function balise_INFO__dist($p) { |
| 43 | - $info = $p->nom_champ; |
|
| 44 | - $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | - $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | - if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | - $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | - erreur_squelette($msg, $p); |
|
| 49 | - $p->interdire_scripts = true; |
|
| 43 | + $info = $p->nom_champ; |
|
| 44 | + $type_objet = interprete_argument_balise(1, $p); |
|
| 45 | + $id_objet = interprete_argument_balise(2, $p); |
|
| 46 | + if ($info === 'INFO_' or !$type_objet or !$id_objet) { |
|
| 47 | + $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']); |
|
| 48 | + erreur_squelette($msg, $p); |
|
| 49 | + $p->interdire_scripts = true; |
|
| 50 | 50 | |
| 51 | - return $p; |
|
| 52 | - } else { |
|
| 53 | - // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | - $_params = '['; |
|
| 55 | - $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | - for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | - $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | - } |
|
| 59 | - $_params .= ']'; |
|
| 51 | + return $p; |
|
| 52 | + } else { |
|
| 53 | + // Récupérer tous les params à la suite de objet et id_objet |
|
| 54 | + $_params = '['; |
|
| 55 | + $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus |
|
| 56 | + for ($i = 3; $i < $nb_params; $i++) { |
|
| 57 | + $_params .= interprete_argument_balise($i, $p) . ','; |
|
| 58 | + } |
|
| 59 | + $_params .= ']'; |
|
| 60 | 60 | |
| 61 | - $info_sql = strtolower(substr($info, 5)); |
|
| 62 | - $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | - $p->code = champ_sql($info, $p, $code); |
|
| 64 | - $p->interdire_scripts = true; |
|
| 61 | + $info_sql = strtolower(substr($info, 5)); |
|
| 62 | + $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)"; |
|
| 63 | + $p->code = champ_sql($info, $p, $code); |
|
| 64 | + $p->interdire_scripts = true; |
|
| 65 | 65 | |
| 66 | - return $p; |
|
| 67 | - } |
|
| 66 | + return $p; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -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/autoriser'); |
@@ -35,42 +35,42 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function action_menu_rubriques_dist() { |
| 37 | 37 | |
| 38 | - // si pas acces a ecrire, pas acces au menu |
|
| 39 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | - if (!autoriser('ecrire')) { |
|
| 41 | - $retour = |
|
| 42 | - '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | - '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | - '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | - '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | - '</a>' . |
|
| 47 | - '</li>' . |
|
| 48 | - '</ul>'; |
|
| 49 | - include_spip('inc/actions'); |
|
| 50 | - ajax_retour($retour); |
|
| 51 | - exit; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($date = intval(_request('date'))) { |
|
| 55 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - $r = gen_liste_rubriques(); |
|
| 59 | - if ( |
|
| 60 | - !$r |
|
| 61 | - and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | - ) { |
|
| 64 | - include_spip('inc/headers'); |
|
| 65 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | - http_response_code(304); |
|
| 67 | - exit; |
|
| 68 | - } else { |
|
| 69 | - include_spip('inc/actions'); |
|
| 70 | - $ret = menu_rubriques(); |
|
| 71 | - ajax_retour($ret); |
|
| 72 | - exit; |
|
| 73 | - } |
|
| 38 | + // si pas acces a ecrire, pas acces au menu |
|
| 39 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | + if (!autoriser('ecrire')) { |
|
| 41 | + $retour = |
|
| 42 | + '<ul class="deroulant__sous-menu" data-profondeur="1">' . |
|
| 43 | + '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' . |
|
| 44 | + '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' . |
|
| 45 | + '<span class="libelle">' . _T('public:lien_connecter') . '</span>' . |
|
| 46 | + '</a>' . |
|
| 47 | + '</li>' . |
|
| 48 | + '</ul>'; |
|
| 49 | + include_spip('inc/actions'); |
|
| 50 | + ajax_retour($retour); |
|
| 51 | + exit; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($date = intval(_request('date'))) { |
|
| 55 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT'); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + $r = gen_liste_rubriques(); |
|
| 59 | + if ( |
|
| 60 | + !$r |
|
| 61 | + and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 62 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 63 | + ) { |
|
| 64 | + include_spip('inc/headers'); |
|
| 65 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 66 | + http_response_code(304); |
|
| 67 | + exit; |
|
| 68 | + } else { |
|
| 69 | + include_spip('inc/actions'); |
|
| 70 | + $ret = menu_rubriques(); |
|
| 71 | + ajax_retour($ret); |
|
| 72 | + exit; |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -84,44 +84,44 @@ discard block |
||
| 84 | 84 | * Code HTML présentant la liste des rubriques |
| 85 | 85 | **/ |
| 86 | 86 | function menu_rubriques($complet = true) { |
| 87 | - $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | - . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | - . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | - . '</a>' |
|
| 91 | - . '</li>'; |
|
| 92 | - |
|
| 93 | - if (!$complet) { |
|
| 94 | - return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | - gen_liste_rubriques(); |
|
| 99 | - } |
|
| 100 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | - |
|
| 102 | - $total_lignes = $i = sizeof($arr_low); |
|
| 103 | - |
|
| 104 | - if ($i > 0) { |
|
| 105 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | - if ($nb_col <= 1) { |
|
| 107 | - $nb_col = ceil($total_lignes / 10); |
|
| 108 | - } |
|
| 109 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | - $i++; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | - $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | - . $ret |
|
| 119 | - . "\n</ul>\n"; |
|
| 120 | - } else { |
|
| 121 | - $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $ret; |
|
| 87 | + $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">' |
|
| 88 | + . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">' |
|
| 89 | + . '<span class="libelle">' . _T('info_tout_site') . '</span>' |
|
| 90 | + . '</a>' |
|
| 91 | + . '</li>'; |
|
| 92 | + |
|
| 93 | + if (!$complet) { |
|
| 94 | + return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 98 | + gen_liste_rubriques(); |
|
| 99 | + } |
|
| 100 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 101 | + |
|
| 102 | + $total_lignes = $i = sizeof($arr_low); |
|
| 103 | + |
|
| 104 | + if ($i > 0) { |
|
| 105 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 106 | + if ($nb_col <= 1) { |
|
| 107 | + $nb_col = ceil($total_lignes / 10); |
|
| 108 | + } |
|
| 109 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 110 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 111 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 112 | + $i++; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 117 | + $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">" |
|
| 118 | + . $ret |
|
| 119 | + . "\n</ul>\n"; |
|
| 120 | + } else { |
|
| 121 | + $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $ret; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,48 +142,48 @@ discard block |
||
| 142 | 142 | * Code HTML présentant la liste des rubriques |
| 143 | 143 | **/ |
| 144 | 144 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) { |
| 145 | - static $zmax = 6; |
|
| 146 | - $profondeur_next = $profondeur + 1; |
|
| 147 | - |
|
| 148 | - $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | - . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | - . "</a>\n"; |
|
| 151 | - |
|
| 152 | - // Limiter volontairement le nombre de sous-menus |
|
| 153 | - if (!(--$zmax)) { |
|
| 154 | - $zmax++; |
|
| 155 | - |
|
| 156 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | - $i = sizeof($arr_rub); |
|
| 161 | - if (!$i) { |
|
| 162 | - $zmax++; |
|
| 163 | - |
|
| 164 | - return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - $nb_col = 1; |
|
| 169 | - if ($nb_rub = count($arr_rub)) { |
|
| 170 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | - } |
|
| 172 | - $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | - $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | - . $nav |
|
| 175 | - . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | - $i++; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - $ret .= "</ul></li>\n"; |
|
| 184 | - $zmax++; |
|
| 185 | - |
|
| 186 | - return $ret; |
|
| 145 | + static $zmax = 6; |
|
| 146 | + $profondeur_next = $profondeur + 1; |
|
| 147 | + |
|
| 148 | + $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">" |
|
| 149 | + . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>' |
|
| 150 | + . "</a>\n"; |
|
| 151 | + |
|
| 152 | + // Limiter volontairement le nombre de sous-menus |
|
| 153 | + if (!(--$zmax)) { |
|
| 154 | + $zmax++; |
|
| 155 | + |
|
| 156 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 160 | + $i = sizeof($arr_rub); |
|
| 161 | + if (!$i) { |
|
| 162 | + $zmax++; |
|
| 163 | + |
|
| 164 | + return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>"; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + $nb_col = 1; |
|
| 169 | + if ($nb_rub = count($arr_rub)) { |
|
| 170 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 171 | + } |
|
| 172 | + $class_cols = ($nb_col > 1 ? "cols-$nb_col" : ''); |
|
| 173 | + $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">" |
|
| 174 | + . $nav |
|
| 175 | + . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">"; |
|
| 176 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 177 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 178 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 179 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next); |
|
| 180 | + $i++; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + $ret .= "</ul></li>\n"; |
|
| 184 | + $zmax++; |
|
| 185 | + |
|
| 186 | + return $ret; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 202 | 202 | **/ |
| 203 | 203 | function extraire_article($id_p, $t) { |
| 204 | - return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 204 | + return array_key_exists($id_p, $t) ? $t[$id_p] : []; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -217,42 +217,42 @@ discard block |
||
| 217 | 217 | **/ |
| 218 | 218 | function gen_liste_rubriques() { |
| 219 | 219 | |
| 220 | - $cache = null; |
|
| 221 | - include_spip('inc/config'); |
|
| 222 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | - [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | - if ($date == $last) { |
|
| 227 | - return false; |
|
| 228 | - } // c'etait en cache :-) |
|
| 229 | - } |
|
| 230 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | - |
|
| 232 | - $where = sql_in_select( |
|
| 233 | - 'id_rubrique', |
|
| 234 | - 'id_rubrique', |
|
| 235 | - 'spip_rubriques', |
|
| 236 | - '', |
|
| 237 | - '', |
|
| 238 | - 'id_parent=0 DESC, date DESC', |
|
| 239 | - _CACHE_RUBRIQUES_MAX |
|
| 240 | - ); |
|
| 241 | - |
|
| 242 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | - |
|
| 244 | - $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | - |
|
| 246 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | - // car on met le resultat en cache, commun a tout le monde |
|
| 248 | - $GLOBALS['db_art_cache'] = []; |
|
| 249 | - while ($r = sql_fetch($res)) { |
|
| 250 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | - |
|
| 257 | - return true; |
|
| 220 | + $cache = null; |
|
| 221 | + include_spip('inc/config'); |
|
| 222 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 223 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 224 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 225 | + [$date, $GLOBALS['db_art_cache']] = @unserialize($cache); |
|
| 226 | + if ($date == $last) { |
|
| 227 | + return false; |
|
| 228 | + } // c'etait en cache :-) |
|
| 229 | + } |
|
| 230 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 231 | + |
|
| 232 | + $where = sql_in_select( |
|
| 233 | + 'id_rubrique', |
|
| 234 | + 'id_rubrique', |
|
| 235 | + 'spip_rubriques', |
|
| 236 | + '', |
|
| 237 | + '', |
|
| 238 | + 'id_parent=0 DESC, date DESC', |
|
| 239 | + _CACHE_RUBRIQUES_MAX |
|
| 240 | + ); |
|
| 241 | + |
|
| 242 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 243 | + |
|
| 244 | + $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre'); |
|
| 245 | + |
|
| 246 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 247 | + // car on met le resultat en cache, commun a tout le monde |
|
| 248 | + $GLOBALS['db_art_cache'] = []; |
|
| 249 | + while ($r = sql_fetch($res)) { |
|
| 250 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 251 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $t = [$last ?: time(), $GLOBALS['db_art_cache']]; |
|
| 255 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 256 | + |
|
| 257 | + return true; |
|
| 258 | 258 | } |
@@ -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 | /** |
@@ -36,56 +36,56 @@ discard block |
||
| 36 | 36 | * ``` |
| 37 | 37 | **/ |
| 38 | 38 | function action_redirect_dist() { |
| 39 | - $type = _request('type'); |
|
| 40 | - $id = intval(_request('id')); |
|
| 41 | - $page = false; |
|
| 39 | + $type = _request('type'); |
|
| 40 | + $id = intval(_request('id')); |
|
| 41 | + $page = false; |
|
| 42 | 42 | |
| 43 | - // verifier le type ou page transmis |
|
| 44 | - if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | - $page = _request('page'); |
|
| 46 | - if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - } |
|
| 43 | + // verifier le type ou page transmis |
|
| 44 | + if (!preg_match('/^\w+$/', $type)) { |
|
| 45 | + $page = _request('page'); |
|
| 46 | + if (!preg_match('/^\w+$/', $page)) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - if ($var_mode = _request('var_mode')) { |
|
| 52 | - // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | - if (!defined('_VAR_URLS')) { |
|
| 54 | - define('_VAR_URLS', true); |
|
| 55 | - } |
|
| 56 | - } |
|
| 51 | + if ($var_mode = _request('var_mode')) { |
|
| 52 | + // forcer la mise a jour de l'url de cet objet ! |
|
| 53 | + if (!defined('_VAR_URLS')) { |
|
| 54 | + define('_VAR_URLS', true); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - if ($page) { |
|
| 59 | - $url = generer_url_public($page, '', true); |
|
| 60 | - } else { |
|
| 61 | - $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | - } |
|
| 58 | + if ($page) { |
|
| 59 | + $url = generer_url_public($page, '', true); |
|
| 60 | + } else { |
|
| 61 | + $url = calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - $status = '302'; |
|
| 65 | - if ($url) { |
|
| 66 | - if ($var_mode) { |
|
| 67 | - $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | - } |
|
| 64 | + $status = '302'; |
|
| 65 | + if ($url) { |
|
| 66 | + if ($var_mode) { |
|
| 67 | + $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - if ( |
|
| 71 | - $var_mode == 'preview' |
|
| 72 | - and defined('_PREVIEW_TOKEN') |
|
| 73 | - and _PREVIEW_TOKEN |
|
| 74 | - and autoriser('previsualiser') |
|
| 75 | - ) { |
|
| 76 | - include_spip('inc/securiser_action'); |
|
| 77 | - $token = calculer_token_previsu($url); |
|
| 78 | - $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | - } |
|
| 70 | + if ( |
|
| 71 | + $var_mode == 'preview' |
|
| 72 | + and defined('_PREVIEW_TOKEN') |
|
| 73 | + and _PREVIEW_TOKEN |
|
| 74 | + and autoriser('previsualiser') |
|
| 75 | + ) { |
|
| 76 | + include_spip('inc/securiser_action'); |
|
| 77 | + $token = calculer_token_previsu($url); |
|
| 78 | + $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (_request('status') and _request('status') == '301') { |
|
| 82 | - $status = '301'; |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $url = generer_url_public('404', '', true); |
|
| 86 | - } |
|
| 81 | + if (_request('status') and _request('status') == '301') { |
|
| 82 | + $status = '301'; |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $url = generer_url_public('404', '', true); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 88 | + redirige_par_entete(str_replace('&', '&', $url), '', $status); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -100,35 +100,35 @@ discard block |
||
| 100 | 100 | * @return string|null |
| 101 | 101 | */ |
| 102 | 102 | function calculer_url_redirect_entite($type, $id, $var_mode) { |
| 103 | - $desc = null; |
|
| 104 | - $publie = null; |
|
| 105 | - $url = null; |
|
| 106 | - // invalider le cache à chaque modif en bdd |
|
| 107 | - $date = 0; |
|
| 108 | - if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | - $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | - } |
|
| 111 | - $key = "url-$date-$type-$id"; |
|
| 103 | + $desc = null; |
|
| 104 | + $publie = null; |
|
| 105 | + $url = null; |
|
| 106 | + // invalider le cache à chaque modif en bdd |
|
| 107 | + $date = 0; |
|
| 108 | + if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 109 | + $date = $GLOBALS['meta']['derniere_modif']; |
|
| 110 | + } |
|
| 111 | + $key = "url-$date-$type-$id"; |
|
| 112 | 112 | |
| 113 | - // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | - if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | - [$url, $publie] = $desc; |
|
| 116 | - } |
|
| 117 | - // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | - if (empty($desc) or $var_mode) { |
|
| 119 | - $publie = objet_test_si_publie($type, $id); |
|
| 120 | - $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | - if (function_exists('cache_set')) { |
|
| 122 | - cache_set($key, [$url, $publie], 3600); |
|
| 123 | - } |
|
| 124 | - } |
|
| 113 | + // Obtenir l’url et si elle est publié du cache memoization |
|
| 114 | + if (function_exists('cache_get') and $desc = cache_get($key)) { |
|
| 115 | + [$url, $publie] = $desc; |
|
| 116 | + } |
|
| 117 | + // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 118 | + if (empty($desc) or $var_mode) { |
|
| 119 | + $publie = objet_test_si_publie($type, $id); |
|
| 120 | + $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 121 | + if (function_exists('cache_set')) { |
|
| 122 | + cache_set($key, [$url, $publie], 3600); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | - if ($publie) { |
|
| 128 | - return $url; |
|
| 129 | - } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | - return $url; |
|
| 131 | - } |
|
| 126 | + // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 127 | + if ($publie) { |
|
| 128 | + return $url; |
|
| 129 | + } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) { |
|
| 130 | + return $url; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return; |
|
| 133 | + return; |
|
| 134 | 134 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | * @return array|bool|null |
| 34 | 34 | */ |
| 35 | 35 | function quete_virtuel($id_article, $connect) { |
| 36 | - return sql_getfetsel( |
|
| 37 | - 'virtuel', |
|
| 38 | - 'spip_articles', |
|
| 39 | - ['id_article=' . intval($id_article), "statut='publie'"], |
|
| 40 | - '', |
|
| 41 | - '', |
|
| 42 | - '', |
|
| 43 | - '', |
|
| 44 | - $connect |
|
| 45 | - ); |
|
| 36 | + return sql_getfetsel( |
|
| 37 | + 'virtuel', |
|
| 38 | + 'spip_articles', |
|
| 39 | + ['id_article=' . intval($id_article), "statut='publie'"], |
|
| 40 | + '', |
|
| 41 | + '', |
|
| 42 | + '', |
|
| 43 | + '', |
|
| 44 | + $connect |
|
| 45 | + ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -57,41 +57,41 @@ discard block |
||
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | 59 | function quete_parent_lang($table, $id, string $connect = '') { |
| 60 | - static $cache_quete = []; |
|
| 61 | - |
|
| 62 | - if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | - if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | - if ( |
|
| 66 | - !$desc = $trouver_table( |
|
| 67 | - $table, |
|
| 68 | - $connect |
|
| 69 | - ) or !isset($desc['field']['id_rubrique']) |
|
| 70 | - ) { |
|
| 71 | - // pas de parent rubrique, on passe |
|
| 72 | - $cache_quete[$connect][$table]['_select'] = false; |
|
| 73 | - } else { |
|
| 74 | - $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 75 | - $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 76 | - $cache_quete[$connect][$table]['_select'] = $select; |
|
| 77 | - $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - if ($cache_quete[$connect][$table]['_select']) { |
|
| 81 | - $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 82 | - $cache_quete[$connect][$table]['_select'], |
|
| 83 | - $table, |
|
| 84 | - $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 85 | - '', |
|
| 86 | - '', |
|
| 87 | - '', |
|
| 88 | - '', |
|
| 89 | - $connect |
|
| 90 | - ); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return $cache_quete[$connect][$table][$id] ?? null; |
|
| 60 | + static $cache_quete = []; |
|
| 61 | + |
|
| 62 | + if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | + if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | + if ( |
|
| 66 | + !$desc = $trouver_table( |
|
| 67 | + $table, |
|
| 68 | + $connect |
|
| 69 | + ) or !isset($desc['field']['id_rubrique']) |
|
| 70 | + ) { |
|
| 71 | + // pas de parent rubrique, on passe |
|
| 72 | + $cache_quete[$connect][$table]['_select'] = false; |
|
| 73 | + } else { |
|
| 74 | + $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 75 | + $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 76 | + $cache_quete[$connect][$table]['_select'] = $select; |
|
| 77 | + $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + if ($cache_quete[$connect][$table]['_select']) { |
|
| 81 | + $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 82 | + $cache_quete[$connect][$table]['_select'], |
|
| 83 | + $table, |
|
| 84 | + $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 85 | + '', |
|
| 86 | + '', |
|
| 87 | + '', |
|
| 88 | + '', |
|
| 89 | + $connect |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return $cache_quete[$connect][$table][$id] ?? null; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | * @return int |
| 109 | 109 | */ |
| 110 | 110 | function quete_parent($id_rubrique, string $connect = '') { |
| 111 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 112 | - return 0; |
|
| 113 | - } |
|
| 114 | - $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 115 | - return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 111 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 112 | + return 0; |
|
| 113 | + } |
|
| 114 | + $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 115 | + return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | * @return int |
| 129 | 129 | */ |
| 130 | 130 | function quete_rubrique($id_article, $serveur) { |
| 131 | - $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 131 | + $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 132 | 132 | |
| 133 | - return $id_parent['id_rubrique']; |
|
| 133 | + return $id_parent['id_rubrique']; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | * @return int |
| 145 | 145 | */ |
| 146 | 146 | function quete_profondeur($id, string $connect = '') { |
| 147 | - $n = 0; |
|
| 148 | - while ($id) { |
|
| 149 | - $n++; |
|
| 150 | - $id = quete_parent($id, $connect); |
|
| 151 | - } |
|
| 147 | + $n = 0; |
|
| 148 | + while ($id) { |
|
| 149 | + $n++; |
|
| 150 | + $id = quete_parent($id, $connect); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - return $n; |
|
| 153 | + return $n; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | * Morceau de la requête SQL testant la date |
| 167 | 167 | */ |
| 168 | 168 | function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) { |
| 169 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 170 | - return '1=1'; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return |
|
| 174 | - (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | - and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 176 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 177 | - : '1=1'; |
|
| 169 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 170 | + return '1=1'; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return |
|
| 174 | + (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | + and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 176 | + ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 177 | + : '1=1'; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
@@ -194,101 +194,101 @@ discard block |
||
| 194 | 194 | * @return array|string |
| 195 | 195 | */ |
| 196 | 196 | function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) { |
| 197 | - static $cond = []; |
|
| 198 | - $key = func_get_args(); |
|
| 199 | - $key = implode('-', $key); |
|
| 200 | - if (isset($cond[$key])) { |
|
| 201 | - return $cond[$key]; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - $liste_statuts = $publie; |
|
| 205 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 206 | - $liste_statuts = $previsu; |
|
| 207 | - } |
|
| 208 | - $not = false; |
|
| 209 | - if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 210 | - $not = true; |
|
| 211 | - $liste_statuts = substr($liste_statuts, 1); |
|
| 212 | - } |
|
| 213 | - // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 214 | - if (!strlen($liste_statuts)) { |
|
| 215 | - return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - $liste_statuts = explode(',', $liste_statuts); |
|
| 219 | - $where = []; |
|
| 220 | - foreach ($liste_statuts as $k => $v) { |
|
| 221 | - // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 222 | - // a ceux de l'auteur identifie |
|
| 223 | - if (strpos($v, '/') !== false) { |
|
| 224 | - $v = explode('/', $v); |
|
| 225 | - $filtre = end($v); |
|
| 226 | - $v = reset($v); |
|
| 227 | - $v = preg_replace(',\W,', '', $v); |
|
| 228 | - if ( |
|
| 229 | - $filtre == 'auteur' |
|
| 230 | - and (strpos($mstatut, '.') !== false) |
|
| 231 | - and $objet = explode('.', $mstatut) |
|
| 232 | - and $id_table = reset($objet) |
|
| 233 | - and $objet = objet_type($id_table) |
|
| 234 | - ) { |
|
| 235 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 236 | - |
|
| 237 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 238 | - // sinon l’auteur en session |
|
| 239 | - include_spip('inc/securiser_action'); |
|
| 240 | - if ($desc = decrire_token_previsu()) { |
|
| 241 | - $id_auteur = $desc['id_auteur']; |
|
| 242 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 243 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 244 | - } else { |
|
| 245 | - $id_auteur = null; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 249 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 250 | - // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 251 | - if (!$id_auteur) { |
|
| 252 | - $where[] = $w; |
|
| 253 | - } else { |
|
| 254 | - $primary = id_table_objet($objet); |
|
| 255 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 256 | - 'ssss.id_objet', |
|
| 257 | - 'spip_auteurs_liens AS ssss', |
|
| 258 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 259 | - '', |
|
| 260 | - '', |
|
| 261 | - '', |
|
| 262 | - '', |
|
| 263 | - $serveur |
|
| 264 | - ) . '))'; |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 268 | - else { |
|
| 269 | - $v = ''; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - // securite |
|
| 273 | - $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 274 | - } |
|
| 275 | - $liste_statuts = array_filter($liste_statuts); |
|
| 276 | - if (count($liste_statuts) == 1) { |
|
| 277 | - $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 278 | - } else { |
|
| 279 | - $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - while (count($where) > 1) { |
|
| 283 | - $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 284 | - $where[] = $and; |
|
| 285 | - } |
|
| 286 | - $cond[$key] = reset($where); |
|
| 287 | - if ($not) { |
|
| 288 | - $cond[$key] = ['NOT', $cond[$key]]; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return $cond[$key]; |
|
| 197 | + static $cond = []; |
|
| 198 | + $key = func_get_args(); |
|
| 199 | + $key = implode('-', $key); |
|
| 200 | + if (isset($cond[$key])) { |
|
| 201 | + return $cond[$key]; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + $liste_statuts = $publie; |
|
| 205 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 206 | + $liste_statuts = $previsu; |
|
| 207 | + } |
|
| 208 | + $not = false; |
|
| 209 | + if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 210 | + $not = true; |
|
| 211 | + $liste_statuts = substr($liste_statuts, 1); |
|
| 212 | + } |
|
| 213 | + // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 214 | + if (!strlen($liste_statuts)) { |
|
| 215 | + return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + $liste_statuts = explode(',', $liste_statuts); |
|
| 219 | + $where = []; |
|
| 220 | + foreach ($liste_statuts as $k => $v) { |
|
| 221 | + // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 222 | + // a ceux de l'auteur identifie |
|
| 223 | + if (strpos($v, '/') !== false) { |
|
| 224 | + $v = explode('/', $v); |
|
| 225 | + $filtre = end($v); |
|
| 226 | + $v = reset($v); |
|
| 227 | + $v = preg_replace(',\W,', '', $v); |
|
| 228 | + if ( |
|
| 229 | + $filtre == 'auteur' |
|
| 230 | + and (strpos($mstatut, '.') !== false) |
|
| 231 | + and $objet = explode('.', $mstatut) |
|
| 232 | + and $id_table = reset($objet) |
|
| 233 | + and $objet = objet_type($id_table) |
|
| 234 | + ) { |
|
| 235 | + $w = "$mstatut<>" . sql_quote($v); |
|
| 236 | + |
|
| 237 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 238 | + // sinon l’auteur en session |
|
| 239 | + include_spip('inc/securiser_action'); |
|
| 240 | + if ($desc = decrire_token_previsu()) { |
|
| 241 | + $id_auteur = $desc['id_auteur']; |
|
| 242 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 243 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 244 | + } else { |
|
| 245 | + $id_auteur = null; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 249 | + if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 250 | + // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 251 | + if (!$id_auteur) { |
|
| 252 | + $where[] = $w; |
|
| 253 | + } else { |
|
| 254 | + $primary = id_table_objet($objet); |
|
| 255 | + $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 256 | + 'ssss.id_objet', |
|
| 257 | + 'spip_auteurs_liens AS ssss', |
|
| 258 | + 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 259 | + '', |
|
| 260 | + '', |
|
| 261 | + '', |
|
| 262 | + '', |
|
| 263 | + $serveur |
|
| 264 | + ) . '))'; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 268 | + else { |
|
| 269 | + $v = ''; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + // securite |
|
| 273 | + $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 274 | + } |
|
| 275 | + $liste_statuts = array_filter($liste_statuts); |
|
| 276 | + if (count($liste_statuts) == 1) { |
|
| 277 | + $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 278 | + } else { |
|
| 279 | + $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + while (count($where) > 1) { |
|
| 283 | + $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 284 | + $where[] = $and; |
|
| 285 | + } |
|
| 286 | + $cond[$key] = reset($where); |
|
| 287 | + if ($not) { |
|
| 288 | + $cond[$key] = ['NOT', $cond[$key]]; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return $cond[$key]; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return array|bool|null |
| 300 | 300 | */ |
| 301 | 301 | function quete_fichier($id_document, $serveur = '') { |
| 302 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 302 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @return array|bool |
| 311 | 311 | */ |
| 312 | 312 | function quete_document($id_document, $serveur = '') { |
| 313 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 313 | + return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @return array|bool|null |
| 322 | 322 | */ |
| 323 | 323 | function quete_meta($nom, $serveur) { |
| 324 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 324 | + return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -347,66 +347,66 @@ discard block |
||
| 347 | 347 | * Retourne soit un tableau, soit le chemin du fichier. |
| 348 | 348 | */ |
| 349 | 349 | function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag) { |
| 350 | - include_spip('base/objets'); |
|
| 351 | - $nom = strtolower($onoff); |
|
| 352 | - |
|
| 353 | - $cle_objet = id_table_objet($cle_objet); |
|
| 354 | - |
|
| 355 | - while (1) { |
|
| 356 | - $objet = objet_type($cle_objet); |
|
| 357 | - |
|
| 358 | - $on = quete_logo_objet($id, $objet, $nom); |
|
| 359 | - |
|
| 360 | - if ($on) { |
|
| 361 | - if ($flag) { |
|
| 362 | - return basename($on['chemin']); |
|
| 363 | - } else { |
|
| 364 | - $taille = @spip_getimagesize($on['chemin']); |
|
| 365 | - |
|
| 366 | - // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 367 | - // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 368 | - // alors on ne cherche pas du tout le survol ici |
|
| 369 | - if ($onoff != 'ON') { |
|
| 370 | - $off = ''; |
|
| 371 | - } else { |
|
| 372 | - // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 373 | - $off = quete_logo_objet($id, $objet, 'off'); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - // on retourne une url du type IMG/artonXX?timestamp |
|
| 377 | - // qui permet de distinguer le changement de logo |
|
| 378 | - // et placer un expire sur le dossier IMG/ |
|
| 379 | - $res = [ |
|
| 380 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 381 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 382 | - (!$taille ? '' : (' ' . $taille[3])) |
|
| 383 | - ]; |
|
| 384 | - $res['src'] = $res[0]; |
|
| 385 | - $res['logo_on'] = $res[0]; |
|
| 386 | - $res['logo_off'] = $res[1]; |
|
| 387 | - $res['width'] = ($taille ? $taille[0] : ''); |
|
| 388 | - $res['height'] = ($taille ? $taille[1] : ''); |
|
| 389 | - |
|
| 390 | - return $res; |
|
| 391 | - } |
|
| 392 | - } else { |
|
| 393 | - if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 394 | - return ''; |
|
| 395 | - } else { |
|
| 396 | - if ($id_rubrique) { |
|
| 397 | - $cle_objet = 'id_rubrique'; |
|
| 398 | - $id = $id_rubrique; |
|
| 399 | - $id_rubrique = 0; |
|
| 400 | - } else { |
|
| 401 | - if ($id and $cle_objet == 'id_rubrique') { |
|
| 402 | - $id = quete_parent($id); |
|
| 403 | - } else { |
|
| 404 | - return ''; |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } |
|
| 350 | + include_spip('base/objets'); |
|
| 351 | + $nom = strtolower($onoff); |
|
| 352 | + |
|
| 353 | + $cle_objet = id_table_objet($cle_objet); |
|
| 354 | + |
|
| 355 | + while (1) { |
|
| 356 | + $objet = objet_type($cle_objet); |
|
| 357 | + |
|
| 358 | + $on = quete_logo_objet($id, $objet, $nom); |
|
| 359 | + |
|
| 360 | + if ($on) { |
|
| 361 | + if ($flag) { |
|
| 362 | + return basename($on['chemin']); |
|
| 363 | + } else { |
|
| 364 | + $taille = @spip_getimagesize($on['chemin']); |
|
| 365 | + |
|
| 366 | + // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 367 | + // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 368 | + // alors on ne cherche pas du tout le survol ici |
|
| 369 | + if ($onoff != 'ON') { |
|
| 370 | + $off = ''; |
|
| 371 | + } else { |
|
| 372 | + // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 373 | + $off = quete_logo_objet($id, $objet, 'off'); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + // on retourne une url du type IMG/artonXX?timestamp |
|
| 377 | + // qui permet de distinguer le changement de logo |
|
| 378 | + // et placer un expire sur le dossier IMG/ |
|
| 379 | + $res = [ |
|
| 380 | + $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 381 | + ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 382 | + (!$taille ? '' : (' ' . $taille[3])) |
|
| 383 | + ]; |
|
| 384 | + $res['src'] = $res[0]; |
|
| 385 | + $res['logo_on'] = $res[0]; |
|
| 386 | + $res['logo_off'] = $res[1]; |
|
| 387 | + $res['width'] = ($taille ? $taille[0] : ''); |
|
| 388 | + $res['height'] = ($taille ? $taille[1] : ''); |
|
| 389 | + |
|
| 390 | + return $res; |
|
| 391 | + } |
|
| 392 | + } else { |
|
| 393 | + if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 394 | + return ''; |
|
| 395 | + } else { |
|
| 396 | + if ($id_rubrique) { |
|
| 397 | + $cle_objet = 'id_rubrique'; |
|
| 398 | + $id = $id_rubrique; |
|
| 399 | + $id_rubrique = 0; |
|
| 400 | + } else { |
|
| 401 | + if ($id and $cle_objet == 'id_rubrique') { |
|
| 402 | + $id = quete_parent($id); |
|
| 403 | + } else { |
|
| 404 | + return ''; |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -420,37 +420,37 @@ discard block |
||
| 420 | 420 | * "on" ou "off" suivant le logo normal ou survol |
| 421 | 421 | **/ |
| 422 | 422 | function quete_logo_objet($id_objet, $objet, $mode) { |
| 423 | - static $chercher_logo; |
|
| 424 | - if (is_null($chercher_logo)) { |
|
| 425 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 426 | - } |
|
| 427 | - $cle_objet = id_table_objet($objet); |
|
| 428 | - |
|
| 429 | - // On cherche pas la méthode classique |
|
| 430 | - $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 431 | - // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 432 | - if (!empty($infos_logo)) { |
|
| 433 | - $infos_logo = [ |
|
| 434 | - 'chemin' => $infos_logo[0], |
|
| 435 | - 'timestamp' => $infos_logo[4], |
|
| 436 | - ]; |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - // On passe cette recherche de logo dans un pipeline |
|
| 440 | - $infos_logo = pipeline( |
|
| 441 | - 'quete_logo_objet', |
|
| 442 | - [ |
|
| 443 | - 'args' => [ |
|
| 444 | - 'id_objet' => $id_objet, |
|
| 445 | - 'objet' => $objet, |
|
| 446 | - 'cle_objet' => $cle_objet, |
|
| 447 | - 'mode' => $mode, |
|
| 448 | - ], |
|
| 449 | - 'data' => $infos_logo, |
|
| 450 | - ] |
|
| 451 | - ); |
|
| 452 | - |
|
| 453 | - return $infos_logo; |
|
| 423 | + static $chercher_logo; |
|
| 424 | + if (is_null($chercher_logo)) { |
|
| 425 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 426 | + } |
|
| 427 | + $cle_objet = id_table_objet($objet); |
|
| 428 | + |
|
| 429 | + // On cherche pas la méthode classique |
|
| 430 | + $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 431 | + // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 432 | + if (!empty($infos_logo)) { |
|
| 433 | + $infos_logo = [ |
|
| 434 | + 'chemin' => $infos_logo[0], |
|
| 435 | + 'timestamp' => $infos_logo[4], |
|
| 436 | + ]; |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + // On passe cette recherche de logo dans un pipeline |
|
| 440 | + $infos_logo = pipeline( |
|
| 441 | + 'quete_logo_objet', |
|
| 442 | + [ |
|
| 443 | + 'args' => [ |
|
| 444 | + 'id_objet' => $id_objet, |
|
| 445 | + 'objet' => $objet, |
|
| 446 | + 'cle_objet' => $cle_objet, |
|
| 447 | + 'mode' => $mode, |
|
| 448 | + ], |
|
| 449 | + 'data' => $infos_logo, |
|
| 450 | + ] |
|
| 451 | + ); |
|
| 452 | + |
|
| 453 | + return $infos_logo; |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | /** |
@@ -463,25 +463,25 @@ discard block |
||
| 463 | 463 | * @return bool|string |
| 464 | 464 | */ |
| 465 | 465 | function quete_logo_file($row, $connect = null) { |
| 466 | - include_spip('inc/documents'); |
|
| 467 | - $logo = vignette_logo_document($row, $connect); |
|
| 468 | - if (!$logo) { |
|
| 469 | - $logo = image_du_document($row, $connect); |
|
| 470 | - } |
|
| 471 | - if (!$logo) { |
|
| 472 | - $f = charger_fonction('vignette', 'inc'); |
|
| 473 | - $logo = $f($row['extension'], false); |
|
| 474 | - } |
|
| 475 | - // si c'est une vignette type doc, la renvoyer direct |
|
| 476 | - if ( |
|
| 477 | - strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 478 | - or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 479 | - or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 480 | - ) { |
|
| 481 | - return $logo; |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - return get_spip_doc($logo); |
|
| 466 | + include_spip('inc/documents'); |
|
| 467 | + $logo = vignette_logo_document($row, $connect); |
|
| 468 | + if (!$logo) { |
|
| 469 | + $logo = image_du_document($row, $connect); |
|
| 470 | + } |
|
| 471 | + if (!$logo) { |
|
| 472 | + $f = charger_fonction('vignette', 'inc'); |
|
| 473 | + $logo = $f($row['extension'], false); |
|
| 474 | + } |
|
| 475 | + // si c'est une vignette type doc, la renvoyer direct |
|
| 476 | + if ( |
|
| 477 | + strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 478 | + or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 479 | + or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 480 | + ) { |
|
| 481 | + return $logo; |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + return get_spip_doc($logo); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -509,20 +509,20 @@ discard block |
||
| 509 | 509 | */ |
| 510 | 510 | function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, string $connect = '') { |
| 511 | 511 | |
| 512 | - include_spip('inc/documents'); |
|
| 513 | - $logo = ''; |
|
| 514 | - if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 515 | - $logo = vignette_logo_document($row, $connect); |
|
| 516 | - } |
|
| 517 | - // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 518 | - if ($mode_logo == 'vignette' and !$logo) { |
|
| 519 | - return ''; |
|
| 520 | - } |
|
| 521 | - if ($mode_logo == 'icone') { |
|
| 522 | - $row['fichier'] = ''; |
|
| 523 | - } |
|
| 524 | - |
|
| 525 | - return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 512 | + include_spip('inc/documents'); |
|
| 513 | + $logo = ''; |
|
| 514 | + if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 515 | + $logo = vignette_logo_document($row, $connect); |
|
| 516 | + } |
|
| 517 | + // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 518 | + if ($mode_logo == 'vignette' and !$logo) { |
|
| 519 | + return ''; |
|
| 520 | + } |
|
| 521 | + if ($mode_logo == 'icone') { |
|
| 522 | + $row['fichier'] = ''; |
|
| 523 | + } |
|
| 524 | + |
|
| 525 | + return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** |
@@ -534,19 +534,19 @@ discard block |
||
| 534 | 534 | */ |
| 535 | 535 | function quete_html_logo($logo, $align, $lien) { |
| 536 | 536 | |
| 537 | - if (!is_array($logo)) { |
|
| 538 | - return ''; |
|
| 539 | - } |
|
| 540 | - |
|
| 541 | - $contexte = []; |
|
| 542 | - foreach ($logo as $k => $v) { |
|
| 543 | - if (!is_numeric($k)) { |
|
| 544 | - $contexte[$k] = $v; |
|
| 545 | - } |
|
| 546 | - } |
|
| 547 | - $contexte['align'] = $align; |
|
| 548 | - $contexte['lien'] = $lien; |
|
| 549 | - return recuperer_fond('modeles/logo', $contexte); |
|
| 537 | + if (!is_array($logo)) { |
|
| 538 | + return ''; |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + $contexte = []; |
|
| 542 | + foreach ($logo as $k => $v) { |
|
| 543 | + if (!is_numeric($k)) { |
|
| 544 | + $contexte[$k] = $v; |
|
| 545 | + } |
|
| 546 | + } |
|
| 547 | + $contexte['align'] = $align; |
|
| 548 | + $contexte['lien'] = $lien; |
|
| 549 | + return recuperer_fond('modeles/logo', $contexte); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -560,14 +560,14 @@ discard block |
||
| 560 | 560 | * @return string|false |
| 561 | 561 | */ |
| 562 | 562 | function document_spip_externe($fichier, $connect) { |
| 563 | - if ($connect) { |
|
| 564 | - $site = quete_meta('adresse_site', $connect); |
|
| 565 | - if ($site) { |
|
| 566 | - $dir = quete_meta('dir_img', $connect); |
|
| 567 | - return "$site/$dir$fichier"; |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - return false; |
|
| 563 | + if ($connect) { |
|
| 564 | + $site = quete_meta('adresse_site', $connect); |
|
| 565 | + if ($site) { |
|
| 566 | + $dir = quete_meta('dir_img', $connect); |
|
| 567 | + return "$site/$dir$fichier"; |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + return false; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -581,23 +581,23 @@ discard block |
||
| 581 | 581 | */ |
| 582 | 582 | function vignette_logo_document($row, string $connect = '') { |
| 583 | 583 | |
| 584 | - if (!$row or empty($row['id_vignette'])) { |
|
| 585 | - return ''; |
|
| 586 | - } |
|
| 587 | - $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 588 | - if ($url = document_spip_externe($fichier, $connect)) { |
|
| 589 | - return $url; |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - $f = get_spip_doc($fichier); |
|
| 593 | - if ($f and @file_exists($f)) { |
|
| 594 | - return $f; |
|
| 595 | - } |
|
| 596 | - if ($row['mode'] !== 'vignette') { |
|
| 597 | - return ''; |
|
| 598 | - } |
|
| 599 | - |
|
| 600 | - return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 584 | + if (!$row or empty($row['id_vignette'])) { |
|
| 585 | + return ''; |
|
| 586 | + } |
|
| 587 | + $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 588 | + if ($url = document_spip_externe($fichier, $connect)) { |
|
| 589 | + return $url; |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + $f = get_spip_doc($fichier); |
|
| 593 | + if ($f and @file_exists($f)) { |
|
| 594 | + return $f; |
|
| 595 | + } |
|
| 596 | + if ($row['mode'] !== 'vignette') { |
|
| 597 | + return ''; |
|
| 598 | + } |
|
| 599 | + |
|
| 600 | + return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | /** |
@@ -613,66 +613,66 @@ discard block |
||
| 613 | 613 | * @return bool|string |
| 614 | 614 | */ |
| 615 | 615 | function calcul_exposer($id, $prim, $reference, $parent, $type, string $connect = '') { |
| 616 | - static $exposer = []; |
|
| 617 | - |
|
| 618 | - // Que faut-il exposer ? Tous les elements de $reference |
|
| 619 | - // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 620 | - // qu'une fois (par squelette) et on conserve le resultat |
|
| 621 | - // en static. |
|
| 622 | - if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 623 | - $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 624 | - // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 625 | - // il n'est donc pas utile |
|
| 626 | - $parent = 0; |
|
| 627 | - if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 628 | - $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 629 | - if (isset($enfants[$type])) { |
|
| 630 | - foreach ($enfants[$type] as $t) { |
|
| 631 | - if ( |
|
| 632 | - isset($reference[$t]) |
|
| 633 | - // cas de la reference donnee dynamiquement par la pagination |
|
| 634 | - or isset($reference["@$t"]) |
|
| 635 | - ) { |
|
| 636 | - $type = $t; |
|
| 637 | - $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 638 | - continue; |
|
| 639 | - } |
|
| 640 | - } |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - $exposer[$m][$type] = []; |
|
| 644 | - if ($principal) { |
|
| 645 | - $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 646 | - foreach ($principaux as $principal) { |
|
| 647 | - $exposer[$m][$type][$principal] = true; |
|
| 648 | - if ($type == 'id_mot') { |
|
| 649 | - if (!$parent) { |
|
| 650 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 651 | - } |
|
| 652 | - if ($parent) { |
|
| 653 | - $exposer[$m]['id_groupe'][$parent] = true; |
|
| 654 | - } |
|
| 655 | - } else { |
|
| 656 | - if ($type != 'id_groupe') { |
|
| 657 | - if (!$parent) { |
|
| 658 | - if ($type == 'id_rubrique') { |
|
| 659 | - $parent = $principal; |
|
| 660 | - } |
|
| 661 | - if ($type == 'id_article') { |
|
| 662 | - $parent = quete_rubrique($principal, $connect); |
|
| 663 | - } |
|
| 664 | - } |
|
| 665 | - do { |
|
| 666 | - $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 667 | - } while ($parent = quete_parent($parent, $connect)); |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - } |
|
| 671 | - } |
|
| 672 | - } |
|
| 673 | - |
|
| 674 | - // And the winner is... |
|
| 675 | - return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 616 | + static $exposer = []; |
|
| 617 | + |
|
| 618 | + // Que faut-il exposer ? Tous les elements de $reference |
|
| 619 | + // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 620 | + // qu'une fois (par squelette) et on conserve le resultat |
|
| 621 | + // en static. |
|
| 622 | + if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 623 | + $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 624 | + // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 625 | + // il n'est donc pas utile |
|
| 626 | + $parent = 0; |
|
| 627 | + if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 628 | + $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 629 | + if (isset($enfants[$type])) { |
|
| 630 | + foreach ($enfants[$type] as $t) { |
|
| 631 | + if ( |
|
| 632 | + isset($reference[$t]) |
|
| 633 | + // cas de la reference donnee dynamiquement par la pagination |
|
| 634 | + or isset($reference["@$t"]) |
|
| 635 | + ) { |
|
| 636 | + $type = $t; |
|
| 637 | + $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 638 | + continue; |
|
| 639 | + } |
|
| 640 | + } |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + $exposer[$m][$type] = []; |
|
| 644 | + if ($principal) { |
|
| 645 | + $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 646 | + foreach ($principaux as $principal) { |
|
| 647 | + $exposer[$m][$type][$principal] = true; |
|
| 648 | + if ($type == 'id_mot') { |
|
| 649 | + if (!$parent) { |
|
| 650 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 651 | + } |
|
| 652 | + if ($parent) { |
|
| 653 | + $exposer[$m]['id_groupe'][$parent] = true; |
|
| 654 | + } |
|
| 655 | + } else { |
|
| 656 | + if ($type != 'id_groupe') { |
|
| 657 | + if (!$parent) { |
|
| 658 | + if ($type == 'id_rubrique') { |
|
| 659 | + $parent = $principal; |
|
| 660 | + } |
|
| 661 | + if ($type == 'id_article') { |
|
| 662 | + $parent = quete_rubrique($principal, $connect); |
|
| 663 | + } |
|
| 664 | + } |
|
| 665 | + do { |
|
| 666 | + $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 667 | + } while ($parent = quete_parent($parent, $connect)); |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + } |
|
| 671 | + } |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + // And the winner is... |
|
| 675 | + return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | 678 | /** |
@@ -687,23 +687,23 @@ discard block |
||
| 687 | 687 | * @return int |
| 688 | 688 | */ |
| 689 | 689 | function quete_debut_pagination($primary, $valeur, $pas, $iter) { |
| 690 | - // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 691 | - // ou composee, mais verifions |
|
| 692 | - if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 693 | - return 0; |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - $pos = 0; |
|
| 697 | - while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 698 | - $pos++; |
|
| 699 | - } |
|
| 700 | - // si on a pas trouve |
|
| 701 | - if (!$row or $row[$primary] != $valeur) { |
|
| 702 | - return 0; |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - // sinon, calculer le bon numero de page |
|
| 706 | - return floor($pos / $pas) * $pas; |
|
| 690 | + // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 691 | + // ou composee, mais verifions |
|
| 692 | + if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 693 | + return 0; |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + $pos = 0; |
|
| 697 | + while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 698 | + $pos++; |
|
| 699 | + } |
|
| 700 | + // si on a pas trouve |
|
| 701 | + if (!$row or $row[$primary] != $valeur) { |
|
| 702 | + return 0; |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + // sinon, calculer le bon numero de page |
|
| 706 | + return floor($pos / $pas) * $pas; |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
@@ -714,11 +714,11 @@ discard block |
||
| 714 | 714 | * @return boolean |
| 715 | 715 | */ |
| 716 | 716 | function is_whereable($value): bool { |
| 717 | - if (is_array($value) && count($value)) { |
|
| 718 | - return true; |
|
| 719 | - } |
|
| 720 | - if (is_scalar($value) && strlen($value)) { |
|
| 721 | - return true; |
|
| 722 | - } |
|
| 723 | - return false; |
|
| 717 | + if (is_array($value) && count($value)) { |
|
| 718 | + return true; |
|
| 719 | + } |
|
| 720 | + if (is_scalar($value) && strlen($value)) { |
|
| 721 | + return true; |
|
| 722 | + } |
|
| 723 | + return false; |
|
| 724 | 724 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/charsets'); |
| 17 | 17 | |
@@ -27,90 +27,90 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function plugins_afficher_liste_dist( |
| 30 | - $url_page, |
|
| 31 | - $liste_plugins, |
|
| 32 | - $liste_plugins_checked, |
|
| 33 | - $liste_plugins_actifs, |
|
| 34 | - $dir_plugins = _DIR_PLUGINS, |
|
| 35 | - $afficher_un = 'afficher_plugin' |
|
| 30 | + $url_page, |
|
| 31 | + $liste_plugins, |
|
| 32 | + $liste_plugins_checked, |
|
| 33 | + $liste_plugins_actifs, |
|
| 34 | + $dir_plugins = _DIR_PLUGINS, |
|
| 35 | + $afficher_un = 'afficher_plugin' |
|
| 36 | 36 | ) { |
| 37 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 37 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 38 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 39 | 39 | |
| 40 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 40 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 41 | 41 | |
| 42 | - $all_infos = pipeline( |
|
| 43 | - 'filtrer_liste_plugins', |
|
| 44 | - [ |
|
| 45 | - 'args' => [ |
|
| 46 | - 'liste_plugins' => $liste_plugins, |
|
| 47 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | - 'dir_plugins' => $dir_plugins |
|
| 50 | - ], |
|
| 51 | - 'data' => $all_infos |
|
| 52 | - ] |
|
| 53 | - ); |
|
| 42 | + $all_infos = pipeline( |
|
| 43 | + 'filtrer_liste_plugins', |
|
| 44 | + [ |
|
| 45 | + 'args' => [ |
|
| 46 | + 'liste_plugins' => $liste_plugins, |
|
| 47 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | + 'dir_plugins' => $dir_plugins |
|
| 50 | + ], |
|
| 51 | + 'data' => $all_infos |
|
| 52 | + ] |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - $liste_plugins = array_flip($liste_plugins); |
|
| 56 | - foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | - if (isset($all_infos[$chemin])) { |
|
| 59 | - $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | - } else { |
|
| 61 | - unset($liste_plugins[$chemin]); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - asort($liste_plugins); |
|
| 65 | - $exposed = urldecode(_request('plugin') ?? ''); |
|
| 55 | + $liste_plugins = array_flip($liste_plugins); |
|
| 56 | + foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | + if (isset($all_infos[$chemin])) { |
|
| 59 | + $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | + } else { |
|
| 61 | + unset($liste_plugins[$chemin]); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + asort($liste_plugins); |
|
| 65 | + $exposed = urldecode(_request('plugin') ?? ''); |
|
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | - $fast_liste_plugins_actifs = []; |
|
| 69 | - $fast_liste_plugins_checked = []; |
|
| 70 | - if (is_array($liste_plugins_actifs)) { |
|
| 71 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | - } |
|
| 73 | - if (is_array($liste_plugins_checked)) { |
|
| 74 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | - } |
|
| 67 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | + $fast_liste_plugins_actifs = []; |
|
| 69 | + $fast_liste_plugins_checked = []; |
|
| 70 | + if (is_array($liste_plugins_actifs)) { |
|
| 71 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | + } |
|
| 73 | + if (is_array($liste_plugins_checked)) { |
|
| 74 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $res = ''; |
|
| 78 | - $block = ''; |
|
| 79 | - $initiale = ''; |
|
| 80 | - $block_actif = false; |
|
| 81 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | - $initiale = $i; |
|
| 85 | - $block = ''; |
|
| 86 | - $block_actif = false; |
|
| 87 | - } |
|
| 88 | - // le rep suivant |
|
| 89 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | - $block_actif = $block_actif | $actif; |
|
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | - $dir_plugins, |
|
| 94 | - strlen(_DIR_RACINE) |
|
| 95 | - ) . $plug)); |
|
| 96 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | - } |
|
| 98 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | - $class = basename($dir_plugins); |
|
| 77 | + $res = ''; |
|
| 78 | + $block = ''; |
|
| 79 | + $initiale = ''; |
|
| 80 | + $block_actif = false; |
|
| 81 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | + $initiale = $i; |
|
| 85 | + $block = ''; |
|
| 86 | + $block_actif = false; |
|
| 87 | + } |
|
| 88 | + // le rep suivant |
|
| 89 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | + $block_actif = $block_actif | $actif; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr( |
|
| 93 | + $dir_plugins, |
|
| 94 | + strlen(_DIR_RACINE) |
|
| 95 | + ) . $plug)); |
|
| 96 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n"; |
|
| 97 | + } |
|
| 98 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 99 | + $class = basename($dir_plugins); |
|
| 100 | 100 | |
| 101 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 101 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ''; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 106 | - if (strlen($block)) { |
|
| 107 | - return "<li class='item'>" |
|
| 108 | - . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | - . debut_block_depliable($block_actif) |
|
| 110 | - . "<ul>$block</ul>" |
|
| 111 | - . fin_block() |
|
| 112 | - . '</li>'; |
|
| 113 | - } |
|
| 106 | + if (strlen($block)) { |
|
| 107 | + return "<li class='item'>" |
|
| 108 | + . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 109 | + . debut_block_depliable($block_actif) |
|
| 110 | + . "<ul>$block</ul>" |
|
| 111 | + . fin_block() |
|
| 112 | + . '</li>'; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - return ''; |
|
| 115 | + return ''; |
|
| 116 | 116 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * Code compilé |
| 38 | 38 | **/ |
| 39 | 39 | function generer_generer_url($type, $p) { |
| 40 | - $_id = interprete_argument_balise(1, $p); |
|
| 40 | + $_id = interprete_argument_balise(1, $p); |
|
| 41 | 41 | |
| 42 | - if (!$_id) { |
|
| 43 | - $primary = id_table_objet($type); |
|
| 44 | - $_id = champ_sql($primary, $p); |
|
| 45 | - } |
|
| 42 | + if (!$_id) { |
|
| 43 | + $primary = id_table_objet($type); |
|
| 44 | + $_id = champ_sql($primary, $p); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return generer_generer_url_arg($type, $p, $_id); |
|
| 47 | + return generer_generer_url_arg($type, $p, $_id); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -73,28 +73,28 @@ discard block |
||
| 73 | 73 | * Code compilé |
| 74 | 74 | **/ |
| 75 | 75 | function generer_generer_url_arg($type, $p, $_id) { |
| 76 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | - return $f($type, $_id, $s); |
|
| 80 | - } |
|
| 81 | - if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | - return null; |
|
| 83 | - } |
|
| 84 | - $s = _q($s); |
|
| 85 | - # exception des urls de documents sur un serveur distant... |
|
| 86 | - if ($type == 'document') { |
|
| 87 | - return |
|
| 88 | - "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | - "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | - "quete_fichier($_id,$s)"; |
|
| 91 | - } |
|
| 92 | - $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | - } else { |
|
| 94 | - $s = ", '', '', true"; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 76 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 77 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 78 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 79 | + return $f($type, $_id, $s); |
|
| 80 | + } |
|
| 81 | + if (!$GLOBALS['connexions'][strtolower($s)]['spip_connect_version']) { |
|
| 82 | + return null; |
|
| 83 | + } |
|
| 84 | + $s = _q($s); |
|
| 85 | + # exception des urls de documents sur un serveur distant... |
|
| 86 | + if ($type == 'document') { |
|
| 87 | + return |
|
| 88 | + "quete_meta('adresse_site', $s) . '/' .\n\t" . |
|
| 89 | + "quete_meta('dir_img', $s) . \n\t" . |
|
| 90 | + "quete_fichier($_id,$s)"; |
|
| 91 | + } |
|
| 92 | + $s = ", '', '', $s, quete_meta('type_urls', $s)"; |
|
| 93 | + } else { |
|
| 94 | + $s = ", '', '', true"; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + return "urlencode_1738(generer_objet_url($_id, '$type'$s))"; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -119,27 +119,27 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | function balise_URL__dist($p) { |
| 121 | 121 | |
| 122 | - $nom = $p->nom_champ; |
|
| 123 | - if ($nom === 'URL_') { |
|
| 124 | - $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | - erreur_squelette($msg, $p); |
|
| 126 | - $p->interdire_scripts = false; |
|
| 127 | - |
|
| 128 | - return $p; |
|
| 129 | - } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | - return $f($p); |
|
| 131 | - } else { |
|
| 132 | - $nom = strtolower($nom); |
|
| 133 | - $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | - $code = champ_sql($nom, $p, $code); |
|
| 135 | - $p->code = $code; |
|
| 136 | - if (!$p->etoile) { |
|
| 137 | - $p->code = "vider_url($code)"; |
|
| 138 | - } |
|
| 139 | - $p->interdire_scripts = false; |
|
| 140 | - |
|
| 141 | - return $p; |
|
| 142 | - } |
|
| 122 | + $nom = $p->nom_champ; |
|
| 123 | + if ($nom === 'URL_') { |
|
| 124 | + $msg = ['zbug_balise_sans_argument', ['balise' => ' URL_']]; |
|
| 125 | + erreur_squelette($msg, $p); |
|
| 126 | + $p->interdire_scripts = false; |
|
| 127 | + |
|
| 128 | + return $p; |
|
| 129 | + } elseif ($f = charger_fonction($nom, 'balise', true)) { |
|
| 130 | + return $f($p); |
|
| 131 | + } else { |
|
| 132 | + $nom = strtolower($nom); |
|
| 133 | + $code = generer_generer_url(substr($nom, 4), $p); |
|
| 134 | + $code = champ_sql($nom, $p, $code); |
|
| 135 | + $p->code = $code; |
|
| 136 | + if (!$p->etoile) { |
|
| 137 | + $p->code = "vider_url($code)"; |
|
| 138 | + } |
|
| 139 | + $p->interdire_scripts = false; |
|
| 140 | + |
|
| 141 | + return $p; |
|
| 142 | + } |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -163,20 +163,20 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | function balise_URL_ARTICLE_dist($p) { |
| 165 | 165 | |
| 166 | - // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | - if ($p->type_requete == 'syndic_articles') { |
|
| 168 | - $code = champ_sql('url', $p); |
|
| 169 | - } else { |
|
| 170 | - $code = generer_generer_url('article', $p); |
|
| 171 | - } |
|
| 166 | + // Cas particulier des boucles (SYNDIC_ARTICLES) |
|
| 167 | + if ($p->type_requete == 'syndic_articles') { |
|
| 168 | + $code = champ_sql('url', $p); |
|
| 169 | + } else { |
|
| 170 | + $code = generer_generer_url('article', $p); |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $p->code = $code; |
|
| 174 | - if (!$p->etoile) { |
|
| 175 | - $p->code = "vider_url($code)"; |
|
| 176 | - } |
|
| 177 | - $p->interdire_scripts = false; |
|
| 173 | + $p->code = $code; |
|
| 174 | + if (!$p->etoile) { |
|
| 175 | + $p->code = "vider_url($code)"; |
|
| 176 | + } |
|
| 177 | + $p->interdire_scripts = false; |
|
| 178 | 178 | |
| 179 | - return $p; |
|
| 179 | + return $p; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -196,21 +196,21 @@ discard block |
||
| 196 | 196 | * Pile complétée par le code à générer |
| 197 | 197 | */ |
| 198 | 198 | function balise_URL_SITE_dist($p) { |
| 199 | - $code = champ_sql('url_site', $p, ''); |
|
| 200 | - if (!$code) { |
|
| 201 | - $code = generer_generer_url('site', $p); |
|
| 202 | - if ($code === null) { |
|
| 203 | - return null; |
|
| 204 | - } |
|
| 205 | - } else { |
|
| 206 | - if (!$p->etoile) { |
|
| 207 | - $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - $p->code = $code; |
|
| 211 | - $p->interdire_scripts = false; |
|
| 212 | - |
|
| 213 | - return $p; |
|
| 199 | + $code = champ_sql('url_site', $p, ''); |
|
| 200 | + if (!$code) { |
|
| 201 | + $code = generer_generer_url('site', $p); |
|
| 202 | + if ($code === null) { |
|
| 203 | + return null; |
|
| 204 | + } |
|
| 205 | + } else { |
|
| 206 | + if (!$p->etoile) { |
|
| 207 | + $code = "calculer_url($code,'','url', \$connect)"; |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + $p->code = $code; |
|
| 211 | + $p->interdire_scripts = false; |
|
| 212 | + |
|
| 213 | + return $p; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | // Autres balises URL_*, qui ne concernent pas une table |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | * Pile complétée par le code à générer |
| 230 | 230 | */ |
| 231 | 231 | function balise_URL_SITE_SPIP_dist($p) { |
| 232 | - $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | - $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | - $p->interdire_scripts = false; |
|
| 232 | + $p->code = "sinon(\$GLOBALS['meta']['adresse_site'],'.')"; |
|
| 233 | + $p->code = 'spip_htmlspecialchars(' . $p->code . ')'; |
|
| 234 | + $p->interdire_scripts = false; |
|
| 235 | 235 | |
| 236 | - return $p; |
|
| 236 | + return $p; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
@@ -262,42 +262,42 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | function balise_URL_PAGE_dist($p) { |
| 264 | 264 | |
| 265 | - $code = interprete_argument_balise(1, $p); |
|
| 266 | - $args = interprete_argument_balise(2, $p); |
|
| 267 | - if ($args == null) { |
|
| 268 | - $args = "''"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | - // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | - // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | - if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | - if ($args and $args !== "''") { |
|
| 276 | - $code .= ", $args"; |
|
| 277 | - } |
|
| 278 | - $code = $f('page', $code, $s); |
|
| 279 | - $p->code = $code; |
|
| 280 | - return $p; |
|
| 281 | - } |
|
| 282 | - $s = 'connect=' . addslashes($s); |
|
| 283 | - $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - if (!$code) { |
|
| 287 | - $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | - $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | - } else { |
|
| 290 | - if (!$args) { |
|
| 291 | - $args = "''"; |
|
| 292 | - } |
|
| 293 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | - $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | - } |
|
| 296 | - $p->code = $code; |
|
| 297 | - spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | - |
|
| 299 | - #$p->interdire_scripts = true; |
|
| 300 | - return $p; |
|
| 265 | + $code = interprete_argument_balise(1, $p); |
|
| 266 | + $args = interprete_argument_balise(2, $p); |
|
| 267 | + if ($args == null) { |
|
| 268 | + $args = "''"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if ($s = trouver_nom_serveur_distant($p)) { |
|
| 272 | + // si une fonction de generation des url a ete definie pour ce connect l'utiliser |
|
| 273 | + // elle devra aussi traiter le cas derogatoire type=page |
|
| 274 | + if (function_exists($f = 'generer_generer_url_' . $s)) { |
|
| 275 | + if ($args and $args !== "''") { |
|
| 276 | + $code .= ", $args"; |
|
| 277 | + } |
|
| 278 | + $code = $f('page', $code, $s); |
|
| 279 | + $p->code = $code; |
|
| 280 | + return $p; |
|
| 281 | + } |
|
| 282 | + $s = 'connect=' . addslashes($s); |
|
| 283 | + $args = (($args and $args !== "''") ? "$args . '&$s'" : "'$s'"); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + if (!$code) { |
|
| 287 | + $noentities = $p->etoile ? "'&'" : ''; |
|
| 288 | + $code = "url_de_base() . preg_replace(',^./,', '', self($noentities))"; |
|
| 289 | + } else { |
|
| 290 | + if (!$args) { |
|
| 291 | + $args = "''"; |
|
| 292 | + } |
|
| 293 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 294 | + $code = "generer_url_public($code, $args$noentities)"; |
|
| 295 | + } |
|
| 296 | + $p->code = $code; |
|
| 297 | + spip_log("Calcul url page : connect vaut $s ca donne :" . $p->code . " args $args", _LOG_INFO); |
|
| 298 | + |
|
| 299 | + #$p->interdire_scripts = true; |
|
| 300 | + return $p; |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
@@ -324,24 +324,24 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | function balise_URL_ECRIRE_dist($p) { |
| 326 | 326 | |
| 327 | - $code = interprete_argument_balise(1, $p); |
|
| 328 | - if (!$code) { |
|
| 329 | - $fonc = "''"; |
|
| 330 | - } else { |
|
| 331 | - $fonc = $code; |
|
| 332 | - $args = interprete_argument_balise(2, $p); |
|
| 333 | - if ($args === null) { |
|
| 334 | - $args = "''"; |
|
| 335 | - } |
|
| 336 | - $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | - if (($args != "''") or $noentities) { |
|
| 338 | - $fonc .= ",$args$noentities"; |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | - $p->interdire_scripts = false; |
|
| 343 | - |
|
| 344 | - return $p; |
|
| 327 | + $code = interprete_argument_balise(1, $p); |
|
| 328 | + if (!$code) { |
|
| 329 | + $fonc = "''"; |
|
| 330 | + } else { |
|
| 331 | + $fonc = $code; |
|
| 332 | + $args = interprete_argument_balise(2, $p); |
|
| 333 | + if ($args === null) { |
|
| 334 | + $args = "''"; |
|
| 335 | + } |
|
| 336 | + $noentities = $p->etoile ? ', true' : ''; |
|
| 337 | + if (($args != "''") or $noentities) { |
|
| 338 | + $fonc .= ",$args$noentities"; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + $p->code = 'generer_url_ecrire(' . $fonc . ')'; |
|
| 342 | + $p->interdire_scripts = false; |
|
| 343 | + |
|
| 344 | + return $p; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | |
@@ -367,24 +367,24 @@ discard block |
||
| 367 | 367 | * Pile complétée par le code à générer |
| 368 | 368 | */ |
| 369 | 369 | function balise_URL_ACTION_AUTEUR_dist($p) { |
| 370 | - $p->descr['session'] = true; |
|
| 371 | - |
|
| 372 | - $p->code = interprete_argument_balise(1, $p); |
|
| 373 | - |
|
| 374 | - $args = interprete_argument_balise(2, $p); |
|
| 375 | - if ($args != "''" && $args !== null) { |
|
| 376 | - $p->code .= ',' . $args; |
|
| 377 | - } |
|
| 378 | - $redirect = interprete_argument_balise(3, $p); |
|
| 379 | - if ($redirect != "''" && $redirect !== null) { |
|
| 380 | - if ($args == "''" || $args === null) { |
|
| 381 | - $p->code .= ",''"; |
|
| 382 | - } |
|
| 383 | - $p->code .= ',' . $redirect; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | - $p->interdire_scripts = false; |
|
| 388 | - |
|
| 389 | - return $p; |
|
| 370 | + $p->descr['session'] = true; |
|
| 371 | + |
|
| 372 | + $p->code = interprete_argument_balise(1, $p); |
|
| 373 | + |
|
| 374 | + $args = interprete_argument_balise(2, $p); |
|
| 375 | + if ($args != "''" && $args !== null) { |
|
| 376 | + $p->code .= ',' . $args; |
|
| 377 | + } |
|
| 378 | + $redirect = interprete_argument_balise(3, $p); |
|
| 379 | + if ($redirect != "''" && $redirect !== null) { |
|
| 380 | + if ($args == "''" || $args === null) { |
|
| 381 | + $p->code .= ",''"; |
|
| 382 | + } |
|
| 383 | + $p->code .= ',' . $redirect; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + $p->code = 'generer_action_auteur(' . $p->code . ')'; |
|
| 387 | + $p->interdire_scripts = false; |
|
| 388 | + |
|
| 389 | + return $p; |
|
| 390 | 390 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Pipelines |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -35,36 +35,36 @@ discard block |
||
| 35 | 35 | * @return string Contenu complété des scripts javascripts, dont jQuery |
| 36 | 36 | **/ |
| 37 | 37 | function f_jQuery_prive($texte) { |
| 38 | - $x = ''; |
|
| 39 | - $jquery_plugins = pipeline( |
|
| 40 | - 'jquery_plugins', |
|
| 41 | - [ |
|
| 42 | - 'prive/javascript/jquery.js', |
|
| 43 | - 'prive/javascript/jquery.form.js', |
|
| 44 | - 'prive/javascript/jquery.autosave.js', |
|
| 45 | - 'prive/javascript/jquery.placeholder-label.js', |
|
| 46 | - 'prive/javascript/ajaxCallback.js', |
|
| 47 | - 'prive/javascript/js.cookie.js', |
|
| 48 | - 'prive/javascript/spip_barre.js', |
|
| 49 | - ] |
|
| 50 | - ); |
|
| 51 | - foreach (array_unique($jquery_plugins) as $script) { |
|
| 52 | - if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 53 | - $script = timestamp($script); |
|
| 54 | - $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - // inserer avant le premier script externe ou a la fin |
|
| 58 | - if ( |
|
| 59 | - preg_match(',<script[^><]*src=,', $texte, $match) |
|
| 60 | - and $p = strpos($texte, (string) $match[0]) |
|
| 61 | - ) { |
|
| 62 | - $texte = substr_replace($texte, $x, $p, 0); |
|
| 63 | - } else { |
|
| 64 | - $texte .= $x; |
|
| 65 | - } |
|
| 38 | + $x = ''; |
|
| 39 | + $jquery_plugins = pipeline( |
|
| 40 | + 'jquery_plugins', |
|
| 41 | + [ |
|
| 42 | + 'prive/javascript/jquery.js', |
|
| 43 | + 'prive/javascript/jquery.form.js', |
|
| 44 | + 'prive/javascript/jquery.autosave.js', |
|
| 45 | + 'prive/javascript/jquery.placeholder-label.js', |
|
| 46 | + 'prive/javascript/ajaxCallback.js', |
|
| 47 | + 'prive/javascript/js.cookie.js', |
|
| 48 | + 'prive/javascript/spip_barre.js', |
|
| 49 | + ] |
|
| 50 | + ); |
|
| 51 | + foreach (array_unique($jquery_plugins) as $script) { |
|
| 52 | + if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 53 | + $script = timestamp($script); |
|
| 54 | + $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + // inserer avant le premier script externe ou a la fin |
|
| 58 | + if ( |
|
| 59 | + preg_match(',<script[^><]*src=,', $texte, $match) |
|
| 60 | + and $p = strpos($texte, (string) $match[0]) |
|
| 61 | + ) { |
|
| 62 | + $texte = substr_replace($texte, $x, $p, 0); |
|
| 63 | + } else { |
|
| 64 | + $texte .= $x; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - return $texte; |
|
| 67 | + return $texte; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -77,42 +77,42 @@ discard block |
||
| 77 | 77 | * @return string |
| 78 | 78 | */ |
| 79 | 79 | function affichage_final_prive_title_auto($texte) { |
| 80 | - if ( |
|
| 81 | - strpos($texte, '<title>') === false |
|
| 82 | - and |
|
| 83 | - (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) |
|
| 84 | - or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 85 | - and $match = textebrut(trim($match[1])) |
|
| 86 | - and ($p = strpos($texte, '<head>')) !== false |
|
| 87 | - ) { |
|
| 88 | - if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 89 | - $nom_site_spip = _T('info_mon_site_spip'); |
|
| 90 | - } |
|
| 80 | + if ( |
|
| 81 | + strpos($texte, '<title>') === false |
|
| 82 | + and |
|
| 83 | + (preg_match(',<h1[^>]*>(.+)</h1>,Uims', $texte, $match) |
|
| 84 | + or preg_match(',<h[23][^>]*>(.+)</h[23]>,Uims', $texte, $match)) |
|
| 85 | + and $match = textebrut(trim($match[1])) |
|
| 86 | + and ($p = strpos($texte, '<head>')) !== false |
|
| 87 | + ) { |
|
| 88 | + if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 89 | + $nom_site_spip = _T('info_mon_site_spip'); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $titre = '<title>[' |
|
| 93 | - . $nom_site_spip |
|
| 94 | - . '] ' . $match |
|
| 95 | - . '</title>'; |
|
| 92 | + $titre = '<title>[' |
|
| 93 | + . $nom_site_spip |
|
| 94 | + . '] ' . $match |
|
| 95 | + . '</title>'; |
|
| 96 | 96 | |
| 97 | - $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 98 | - } |
|
| 97 | + $texte = substr_replace($texte, $titre, $p + 6, 0); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - return $texte; |
|
| 100 | + return $texte; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | // Fonction standard pour le pipeline 'boite_infos' |
| 105 | 105 | function f_boite_infos($flux) { |
| 106 | - $args = $flux['args']; |
|
| 107 | - $type = $args['type']; |
|
| 108 | - unset($args['row']); |
|
| 109 | - if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 110 | - $type = 'objet'; |
|
| 111 | - } |
|
| 112 | - $args['espace_prive'] = 1; |
|
| 113 | - $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 106 | + $args = $flux['args']; |
|
| 107 | + $type = $args['type']; |
|
| 108 | + unset($args['row']); |
|
| 109 | + if (!trouver_fond($type, 'prive/objets/infos/')) { |
|
| 110 | + $type = 'objet'; |
|
| 111 | + } |
|
| 112 | + $args['espace_prive'] = 1; |
|
| 113 | + $flux['data'] .= recuperer_fond("prive/objets/infos/$type", $args); |
|
| 114 | 114 | |
| 115 | - return $flux; |
|
| 115 | + return $flux; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | |
@@ -131,97 +131,97 @@ discard block |
||
| 131 | 131 | * @return array Données du pipeline |
| 132 | 132 | */ |
| 133 | 133 | function f_afficher_blocs_ecrire($flux) { |
| 134 | - static $o = []; |
|
| 135 | - if (is_string($fond = $flux['args']['fond'])) { |
|
| 136 | - $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 137 | - if (!isset($o[$exec])) { |
|
| 138 | - $o[$exec] = trouver_objet_exec($exec); |
|
| 139 | - } |
|
| 140 | - // cas particulier |
|
| 141 | - if ($exec == 'infos_perso') { |
|
| 142 | - $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 143 | - } |
|
| 144 | - $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 145 | - if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 146 | - $flux['data']['texte'] = pipeline( |
|
| 147 | - 'affiche_gauche', |
|
| 148 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 149 | - ); |
|
| 150 | - } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 151 | - include_spip('inc/presentation_mini'); |
|
| 152 | - $flux['data']['texte'] = pipeline( |
|
| 153 | - 'affiche_droite', |
|
| 154 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 155 | - ) . liste_objets_bloques( |
|
| 156 | - $exec, |
|
| 157 | - $flux['args']['contexte'] |
|
| 158 | - ); |
|
| 159 | - } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) { |
|
| 160 | - // id non defini sur les formulaire de nouveaux objets |
|
| 161 | - $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 162 | - $flux['data']['texte'] = pipeline( |
|
| 163 | - 'affiche_hierarchie', |
|
| 164 | - ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 165 | - ); |
|
| 166 | - } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 167 | - // Préparation du marqueur affiche_milieu |
|
| 168 | - // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 169 | - $est_page_objet = !empty($o[$exec]['type']); |
|
| 170 | - $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true); |
|
| 171 | - $encapsuler_milieu = ($est_page_objet and !$est_en_edition); |
|
| 172 | - $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 173 | - $flux['data']['texte'], |
|
| 174 | - '<!--affiche_milieu-->', |
|
| 175 | - '<div id=["\']wysiwyg', |
|
| 176 | - $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 177 | - $encapsuler_milieu ? '</div>' : '' |
|
| 178 | - ); |
|
| 179 | - if ( |
|
| 180 | - $o[$exec] |
|
| 181 | - and $objet = $o[$exec]['type'] |
|
| 182 | - and $o[$exec]['edition'] == false |
|
| 183 | - and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 184 | - and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 185 | - ) { |
|
| 186 | - // inserer le formulaire de traduction |
|
| 187 | - $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 188 | - 'prive/objets/editer/traductions', |
|
| 189 | - ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 190 | - ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 191 | - $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 192 | - 'args' => [ |
|
| 193 | - 'contexte' => $flux['args']['contexte'], |
|
| 194 | - 'type' => $objet, |
|
| 195 | - 'id' => $id |
|
| 196 | - ], |
|
| 197 | - 'data' => $flux['data']['texte'] |
|
| 198 | - ]); |
|
| 199 | - } |
|
| 200 | - $flux['data']['texte'] = pipeline( |
|
| 201 | - 'affiche_milieu', |
|
| 202 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 203 | - ); |
|
| 204 | - } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 205 | - $flux['data']['texte'] = pipeline( |
|
| 206 | - 'affiche_pied', |
|
| 207 | - ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 208 | - ); |
|
| 209 | - } elseif ( |
|
| 210 | - strncmp($fond, 'prive/objets/contenu/', 21) == 0 |
|
| 211 | - and $objet = basename($fond) |
|
| 212 | - and $objet == substr($fond, 21) |
|
| 213 | - and isset($o[$objet]) |
|
| 214 | - and $o[$objet] |
|
| 215 | - ) { |
|
| 216 | - $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 217 | - $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 218 | - 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 219 | - 'data' => $flux['data']['texte'] |
|
| 220 | - ]); |
|
| 221 | - } |
|
| 222 | - } |
|
| 134 | + static $o = []; |
|
| 135 | + if (is_string($fond = $flux['args']['fond'])) { |
|
| 136 | + $exec = $flux['args']['contexte']['exec'] ?? _request('exec'); |
|
| 137 | + if (!isset($o[$exec])) { |
|
| 138 | + $o[$exec] = trouver_objet_exec($exec); |
|
| 139 | + } |
|
| 140 | + // cas particulier |
|
| 141 | + if ($exec == 'infos_perso') { |
|
| 142 | + $flux['args']['contexte']['id_auteur'] = $GLOBALS['visiteur_session']['id_auteur']; |
|
| 143 | + } |
|
| 144 | + $typepage = ($flux['args']['contexte']['type-page'] ?? $exec); |
|
| 145 | + if ($fond == "prive/squelettes/navigation/$typepage") { |
|
| 146 | + $flux['data']['texte'] = pipeline( |
|
| 147 | + 'affiche_gauche', |
|
| 148 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 149 | + ); |
|
| 150 | + } elseif ($fond == "prive/squelettes/extra/$typepage") { |
|
| 151 | + include_spip('inc/presentation_mini'); |
|
| 152 | + $flux['data']['texte'] = pipeline( |
|
| 153 | + 'affiche_droite', |
|
| 154 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 155 | + ) . liste_objets_bloques( |
|
| 156 | + $exec, |
|
| 157 | + $flux['args']['contexte'] |
|
| 158 | + ); |
|
| 159 | + } elseif ($fond == "prive/squelettes/hierarchie/$typepage" and $o[$exec]) { |
|
| 160 | + // id non defini sur les formulaire de nouveaux objets |
|
| 161 | + $id = isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) ? intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) : 0; |
|
| 162 | + $flux['data']['texte'] = pipeline( |
|
| 163 | + 'affiche_hierarchie', |
|
| 164 | + ['args' => ['objet' => $o[$exec]['type'], 'id_objet' => $id], 'data' => $flux['data']['texte']] |
|
| 165 | + ); |
|
| 166 | + } elseif ($fond == "prive/squelettes/contenu/$typepage") { |
|
| 167 | + // Préparation du marqueur affiche_milieu |
|
| 168 | + // Si c'est la page d'un objet pas en édition, on l'encapsule dans un div |
|
| 169 | + $est_page_objet = !empty($o[$exec]['type']); |
|
| 170 | + $est_en_edition = (isset($o[$exec]['edition']) and $o[$exec]['edition'] === true); |
|
| 171 | + $encapsuler_milieu = ($est_page_objet and !$est_en_edition); |
|
| 172 | + $flux['data']['texte'] = afficher_blocs_ecrire_preparer_marqueur( |
|
| 173 | + $flux['data']['texte'], |
|
| 174 | + '<!--affiche_milieu-->', |
|
| 175 | + '<div id=["\']wysiwyg', |
|
| 176 | + $encapsuler_milieu ? '<div class="affiche_milieu">' : '', |
|
| 177 | + $encapsuler_milieu ? '</div>' : '' |
|
| 178 | + ); |
|
| 179 | + if ( |
|
| 180 | + $o[$exec] |
|
| 181 | + and $objet = $o[$exec]['type'] |
|
| 182 | + and $o[$exec]['edition'] == false |
|
| 183 | + and isset($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 184 | + and $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]) |
|
| 185 | + ) { |
|
| 186 | + // inserer le formulaire de traduction |
|
| 187 | + $flux['data']['texte'] = str_replace('<!--affiche_milieu-->', recuperer_fond( |
|
| 188 | + 'prive/objets/editer/traductions', |
|
| 189 | + ['objet' => $objet, 'id_objet' => $id, 'espace_prive' => 1] |
|
| 190 | + ) . '<!--affiche_milieu-->', $flux['data']['texte']); |
|
| 191 | + $flux['data']['texte'] = pipeline('afficher_fiche_objet', [ |
|
| 192 | + 'args' => [ |
|
| 193 | + 'contexte' => $flux['args']['contexte'], |
|
| 194 | + 'type' => $objet, |
|
| 195 | + 'id' => $id |
|
| 196 | + ], |
|
| 197 | + 'data' => $flux['data']['texte'] |
|
| 198 | + ]); |
|
| 199 | + } |
|
| 200 | + $flux['data']['texte'] = pipeline( |
|
| 201 | + 'affiche_milieu', |
|
| 202 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 203 | + ); |
|
| 204 | + } elseif ($fond == 'prive/squelettes/inclure/pied') { |
|
| 205 | + $flux['data']['texte'] = pipeline( |
|
| 206 | + 'affiche_pied', |
|
| 207 | + ['args' => $flux['args']['contexte'], 'data' => $flux['data']['texte']] |
|
| 208 | + ); |
|
| 209 | + } elseif ( |
|
| 210 | + strncmp($fond, 'prive/objets/contenu/', 21) == 0 |
|
| 211 | + and $objet = basename($fond) |
|
| 212 | + and $objet == substr($fond, 21) |
|
| 213 | + and isset($o[$objet]) |
|
| 214 | + and $o[$objet] |
|
| 215 | + ) { |
|
| 216 | + $id = intval($flux['args']['contexte'][$o[$exec]['id_table_objet']]); |
|
| 217 | + $flux['data']['texte'] = pipeline('afficher_contenu_objet', [ |
|
| 218 | + 'args' => ['type' => $objet, 'id_objet' => $id, 'contexte' => $flux['args']['contexte']], |
|
| 219 | + 'data' => $flux['data']['texte'] |
|
| 220 | + ]); |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - return $flux; |
|
| 224 | + return $flux; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -249,36 +249,36 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | function afficher_blocs_ecrire_preparer_marqueur(?string $texte, string $marqueur, string $inserer_avant, string $ouvrir = '', string $fermer = ''): ?string { |
| 251 | 251 | |
| 252 | - if ($texte) { |
|
| 253 | - $encapsuler = (($ouvrir and $fermer) ? true : false); |
|
| 254 | - $marqueur_pos = strpos($texte, $marqueur); |
|
| 255 | - $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 252 | + if ($texte) { |
|
| 253 | + $encapsuler = (($ouvrir and $fermer) ? true : false); |
|
| 254 | + $marqueur_pos = strpos($texte, $marqueur); |
|
| 255 | + $full_marqueur = "$ouvrir$marqueur$fermer"; |
|
| 256 | 256 | |
| 257 | - // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 258 | - if ($marqueur_pos === false) { |
|
| 259 | - $texte = preg_replace( |
|
| 260 | - ",$inserer_avant,", |
|
| 261 | - "$full_marqueur\\0", |
|
| 262 | - $texte |
|
| 263 | - ); |
|
| 264 | - // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 265 | - // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 266 | - // Il ne faut donc aucun espace blanc en trop. |
|
| 267 | - } elseif ( |
|
| 268 | - $marqueur_pos !== false |
|
| 269 | - and $encapsuler |
|
| 270 | - and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 271 | - ) { |
|
| 272 | - $texte = substr_replace( |
|
| 273 | - $texte, |
|
| 274 | - $full_marqueur, |
|
| 275 | - $marqueur_pos, |
|
| 276 | - strlen($marqueur) |
|
| 277 | - ); |
|
| 278 | - } |
|
| 279 | - } |
|
| 257 | + // Le marqueur est absent : on l'ajoute avant l'élément indiqué |
|
| 258 | + if ($marqueur_pos === false) { |
|
| 259 | + $texte = preg_replace( |
|
| 260 | + ",$inserer_avant,", |
|
| 261 | + "$full_marqueur\\0", |
|
| 262 | + $texte |
|
| 263 | + ); |
|
| 264 | + // Le marqueur est présent mais pas encapsulé : on ajoute les balises ouvrantes et fermantes. |
|
| 265 | + // Pour vérifier, on prend le texte précédent et on regarde si ça correspond à la balise ouvrante. |
|
| 266 | + // Il ne faut donc aucun espace blanc en trop. |
|
| 267 | + } elseif ( |
|
| 268 | + $marqueur_pos !== false |
|
| 269 | + and $encapsuler |
|
| 270 | + and substr($texte, $marqueur_pos - strlen($ouvrir), strlen($ouvrir)) !== $ouvrir |
|
| 271 | + ) { |
|
| 272 | + $texte = substr_replace( |
|
| 273 | + $texte, |
|
| 274 | + $full_marqueur, |
|
| 275 | + $marqueur_pos, |
|
| 276 | + strlen($marqueur) |
|
| 277 | + ); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - return $texte; |
|
| 281 | + return $texte; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -289,23 +289,23 @@ discard block |
||
| 289 | 289 | * @return string |
| 290 | 290 | */ |
| 291 | 291 | function f_queue_affiche_milieu($flux) { |
| 292 | - $args = $flux['args']; |
|
| 293 | - $res = ''; |
|
| 294 | - foreach ($args as $key => $arg) { |
|
| 295 | - if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) { |
|
| 296 | - $objet = preg_replace(',^id_,', '', $key); |
|
| 297 | - $res .= recuperer_fond( |
|
| 298 | - 'modeles/object_jobs_list', |
|
| 299 | - ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 300 | - ['ajax' => true] |
|
| 301 | - ); |
|
| 302 | - } |
|
| 303 | - } |
|
| 304 | - if ($res) { |
|
| 305 | - $flux['data'] = $res . $flux['data']; |
|
| 306 | - } |
|
| 292 | + $args = $flux['args']; |
|
| 293 | + $res = ''; |
|
| 294 | + foreach ($args as $key => $arg) { |
|
| 295 | + if (preg_match(',^id_,', $key) and is_numeric($arg) and $arg = intval($arg)) { |
|
| 296 | + $objet = preg_replace(',^id_,', '', $key); |
|
| 297 | + $res .= recuperer_fond( |
|
| 298 | + 'modeles/object_jobs_list', |
|
| 299 | + ['id_objet' => $arg, 'objet' => $objet, 'espace_prive' => 1], |
|
| 300 | + ['ajax' => true] |
|
| 301 | + ); |
|
| 302 | + } |
|
| 303 | + } |
|
| 304 | + if ($res) { |
|
| 305 | + $flux['data'] = $res . $flux['data']; |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - return $flux; |
|
| 308 | + return $flux; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -319,39 +319,39 @@ discard block |
||
| 319 | 319 | * @return array|bool |
| 320 | 320 | */ |
| 321 | 321 | function trouver_objet_exec(?string $exec) { |
| 322 | - static $objet_exec = []; |
|
| 323 | - if (!$exec) { |
|
| 324 | - return false; |
|
| 325 | - } |
|
| 326 | - // cas particulier |
|
| 327 | - if ($exec === 'infos_perso') { |
|
| 328 | - $exec = 'auteur'; |
|
| 329 | - set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 330 | - } |
|
| 331 | - if (!isset($objet_exec[$exec])) { |
|
| 332 | - $objet_exec[$exec] = false; |
|
| 333 | - $infos = lister_tables_objets_sql(); |
|
| 334 | - foreach ($infos as $t => $info) { |
|
| 335 | - if ($exec === $info['url_edit'] and $info['editable']) { |
|
| 336 | - return $objet_exec[$exec] = [ |
|
| 337 | - 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 338 | - 'table_objet_sql' => $t, |
|
| 339 | - 'table' => $info['table_objet'], |
|
| 340 | - 'type' => $info['type'], |
|
| 341 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 342 | - ]; |
|
| 343 | - } |
|
| 344 | - if ($exec === $info['url_voir']) { |
|
| 345 | - return $objet_exec[$exec] = [ |
|
| 346 | - 'edition' => false, |
|
| 347 | - 'table_objet_sql' => $t, |
|
| 348 | - 'table' => $info['table_objet'], |
|
| 349 | - 'type' => $info['type'], |
|
| 350 | - 'id_table_objet' => id_table_objet($info['type']) |
|
| 351 | - ]; |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - } |
|
| 322 | + static $objet_exec = []; |
|
| 323 | + if (!$exec) { |
|
| 324 | + return false; |
|
| 325 | + } |
|
| 326 | + // cas particulier |
|
| 327 | + if ($exec === 'infos_perso') { |
|
| 328 | + $exec = 'auteur'; |
|
| 329 | + set_request('id_auteur', $GLOBALS['visiteur_session']['id_auteur']); |
|
| 330 | + } |
|
| 331 | + if (!isset($objet_exec[$exec])) { |
|
| 332 | + $objet_exec[$exec] = false; |
|
| 333 | + $infos = lister_tables_objets_sql(); |
|
| 334 | + foreach ($infos as $t => $info) { |
|
| 335 | + if ($exec === $info['url_edit'] and $info['editable']) { |
|
| 336 | + return $objet_exec[$exec] = [ |
|
| 337 | + 'edition' => $exec == $info['url_voir'] ? '' : true, |
|
| 338 | + 'table_objet_sql' => $t, |
|
| 339 | + 'table' => $info['table_objet'], |
|
| 340 | + 'type' => $info['type'], |
|
| 341 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 342 | + ]; |
|
| 343 | + } |
|
| 344 | + if ($exec === $info['url_voir']) { |
|
| 345 | + return $objet_exec[$exec] = [ |
|
| 346 | + 'edition' => false, |
|
| 347 | + 'table_objet_sql' => $t, |
|
| 348 | + 'table' => $info['table_objet'], |
|
| 349 | + 'type' => $info['type'], |
|
| 350 | + 'id_table_objet' => id_table_objet($info['type']) |
|
| 351 | + ]; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - return $objet_exec[$exec]; |
|
| 356 | + return $objet_exec[$exec]; |
|
| 357 | 357 | } |
@@ -1,22 +1,22 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 4 | - return; |
|
| 4 | + return; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function trier_rss($texte) { |
| 8 | - if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | - $placeholder = '<!--REINSERT-->'; |
|
| 10 | - $items = []; |
|
| 11 | - foreach ($matches as $match) { |
|
| 12 | - if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | - $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | - $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | - } |
|
| 16 | - } |
|
| 17 | - krsort($items); |
|
| 18 | - $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | - } |
|
| 8 | + if (preg_match_all(',<item.*</item>\s*?,Uims', $texte, $matches, PREG_SET_ORDER)) { |
|
| 9 | + $placeholder = '<!--REINSERT-->'; |
|
| 10 | + $items = []; |
|
| 11 | + foreach ($matches as $match) { |
|
| 12 | + if (preg_match(',<dc:date>(.*)</dc:date>,Uims', $match[0], $r)) { |
|
| 13 | + $items[strtotime($r[1])] = trim($match[0]); |
|
| 14 | + $texte = str_replace($match[0], unique($placeholder), $texte); |
|
| 15 | + } |
|
| 16 | + } |
|
| 17 | + krsort($items); |
|
| 18 | + $texte = str_replace($placeholder, implode("\n\t", $items) . "\n", $texte); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - return $texte; |
|
| 21 | + return $texte; |
|
| 22 | 22 | } |
@@ -17,212 +17,212 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('inc/charsets'); |
| 23 | 23 | include_spip('inc/texte'); |
| 24 | 24 | include_spip('inc/plugin'); // pour plugin_est_installe |
| 25 | 25 | |
| 26 | 26 | function plugins_afficher_plugin_dist( |
| 27 | - $url_page, |
|
| 28 | - $plug_file, |
|
| 29 | - $checked, |
|
| 30 | - $actif, |
|
| 31 | - $expose = false, |
|
| 32 | - $class_li = 'item', |
|
| 33 | - $dir_plugins = _DIR_PLUGINS |
|
| 27 | + $url_page, |
|
| 28 | + $plug_file, |
|
| 29 | + $checked, |
|
| 30 | + $actif, |
|
| 31 | + $expose = false, |
|
| 32 | + $class_li = 'item', |
|
| 33 | + $dir_plugins = _DIR_PLUGINS |
|
| 34 | 34 | ) { |
| 35 | 35 | |
| 36 | - static $id_input = 0; |
|
| 37 | - static $versions = []; |
|
| 38 | - |
|
| 39 | - $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 40 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 41 | - $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 42 | - $prefix = $info['prefix']; |
|
| 43 | - $cfg = ''; |
|
| 44 | - $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 45 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 46 | - $erreur = ''; |
|
| 47 | - |
|
| 48 | - if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 49 | - $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 50 | - $erreur = http_img_pack( |
|
| 51 | - 'plugin-dis-32.png', |
|
| 52 | - _T('plugin_info_non_compatible_spip'), |
|
| 53 | - " class='picto_err'", |
|
| 54 | - _T('plugin_info_non_compatible_spip') |
|
| 55 | - ); |
|
| 56 | - $class_li .= ' disabled'; |
|
| 57 | - $checkable = false; |
|
| 58 | - } elseif (isset($info['erreur'])) { |
|
| 59 | - $class_li .= ' error'; |
|
| 60 | - $erreur = http_img_pack( |
|
| 61 | - 'plugin-err-32.png', |
|
| 62 | - _T('plugin_info_erreur_xml'), |
|
| 63 | - " class='picto_err'", |
|
| 64 | - _T('plugin_info_erreur_xml') |
|
| 65 | - ) |
|
| 66 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 67 | - $checkable = false; |
|
| 68 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 69 | - $class_li .= ' error'; |
|
| 70 | - $erreur = http_img_pack( |
|
| 71 | - 'plugin-err-32.png', |
|
| 72 | - _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 73 | - " class='picto_err'", |
|
| 74 | - _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 75 | - ) |
|
| 76 | - . "<div class='erreur'>" . implode( |
|
| 77 | - '<br />', |
|
| 78 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 79 | - ) . '</div>'; |
|
| 80 | - } else { |
|
| 81 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 82 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 83 | - //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 84 | - $erreur = http_img_pack( |
|
| 85 | - 'plugin-dis-32.png', |
|
| 86 | - _T('plugin_info_non_compatible_spip'), |
|
| 87 | - " class='picto_err picto_compat_forcee'", |
|
| 88 | - _L('Version incompatible : compatibilité forcée') |
|
| 89 | - ); |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // numerotons les occurrences d'un meme prefix |
|
| 94 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 95 | - |
|
| 96 | - $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 97 | - |
|
| 98 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 99 | - . ((!$checkable and !$checked) |
|
| 100 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 101 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 102 | - . $cfg |
|
| 103 | - . $erreur |
|
| 104 | - . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 105 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 106 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 107 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 108 | - . '</div>' |
|
| 109 | - . '</li>'; |
|
| 36 | + static $id_input = 0; |
|
| 37 | + static $versions = []; |
|
| 38 | + |
|
| 39 | + $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 40 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 41 | + $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 42 | + $prefix = $info['prefix']; |
|
| 43 | + $cfg = ''; |
|
| 44 | + $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 45 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 46 | + $erreur = ''; |
|
| 47 | + |
|
| 48 | + if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 49 | + $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 50 | + $erreur = http_img_pack( |
|
| 51 | + 'plugin-dis-32.png', |
|
| 52 | + _T('plugin_info_non_compatible_spip'), |
|
| 53 | + " class='picto_err'", |
|
| 54 | + _T('plugin_info_non_compatible_spip') |
|
| 55 | + ); |
|
| 56 | + $class_li .= ' disabled'; |
|
| 57 | + $checkable = false; |
|
| 58 | + } elseif (isset($info['erreur'])) { |
|
| 59 | + $class_li .= ' error'; |
|
| 60 | + $erreur = http_img_pack( |
|
| 61 | + 'plugin-err-32.png', |
|
| 62 | + _T('plugin_info_erreur_xml'), |
|
| 63 | + " class='picto_err'", |
|
| 64 | + _T('plugin_info_erreur_xml') |
|
| 65 | + ) |
|
| 66 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 67 | + $checkable = false; |
|
| 68 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 69 | + $class_li .= ' error'; |
|
| 70 | + $erreur = http_img_pack( |
|
| 71 | + 'plugin-err-32.png', |
|
| 72 | + _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 73 | + " class='picto_err'", |
|
| 74 | + _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 75 | + ) |
|
| 76 | + . "<div class='erreur'>" . implode( |
|
| 77 | + '<br />', |
|
| 78 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 79 | + ) . '</div>'; |
|
| 80 | + } else { |
|
| 81 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 82 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 83 | + //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 84 | + $erreur = http_img_pack( |
|
| 85 | + 'plugin-dis-32.png', |
|
| 86 | + _T('plugin_info_non_compatible_spip'), |
|
| 87 | + " class='picto_err picto_compat_forcee'", |
|
| 88 | + _L('Version incompatible : compatibilité forcée') |
|
| 89 | + ); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // numerotons les occurrences d'un meme prefix |
|
| 94 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 95 | + |
|
| 96 | + $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 97 | + |
|
| 98 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 99 | + . ((!$checkable and !$checked) |
|
| 100 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 101 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 102 | + . $cfg |
|
| 103 | + . $erreur |
|
| 104 | + . (($dir_plugins !== _DIR_PLUGINS_DIST and plugin_est_installe($plug_file)) |
|
| 105 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 106 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 107 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 108 | + . '</div>' |
|
| 109 | + . '</li>'; |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | function plugin_bouton_config($nom, $infos, $dir) { |
| 113 | - // la verification se base sur le filesystem |
|
| 114 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 115 | - $prefix = strtolower($infos['prefix']); |
|
| 116 | - // si paquet.xml fournit un squelette, le prendre |
|
| 117 | - if (isset($infos['config']) and $infos['config']) { |
|
| 118 | - return recuperer_fond( |
|
| 119 | - "$dir$nom/" . $infos['config'], |
|
| 120 | - [ |
|
| 121 | - 'script' => 'configurer_' . $prefix, |
|
| 122 | - 'nom' => $nom |
|
| 123 | - ] |
|
| 124 | - ); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - // sinon prendre le squelette std sur le nom std |
|
| 128 | - return recuperer_fond( |
|
| 129 | - 'prive/squelettes/inclure/cfg', |
|
| 130 | - [ |
|
| 131 | - 'script' => 'configurer_' . $prefix, |
|
| 132 | - 'nom' => $nom |
|
| 133 | - ] |
|
| 134 | - ); |
|
| 113 | + // la verification se base sur le filesystem |
|
| 114 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 115 | + $prefix = strtolower($infos['prefix']); |
|
| 116 | + // si paquet.xml fournit un squelette, le prendre |
|
| 117 | + if (isset($infos['config']) and $infos['config']) { |
|
| 118 | + return recuperer_fond( |
|
| 119 | + "$dir$nom/" . $infos['config'], |
|
| 120 | + [ |
|
| 121 | + 'script' => 'configurer_' . $prefix, |
|
| 122 | + 'nom' => $nom |
|
| 123 | + ] |
|
| 124 | + ); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + // sinon prendre le squelette std sur le nom std |
|
| 128 | + return recuperer_fond( |
|
| 129 | + 'prive/squelettes/inclure/cfg', |
|
| 130 | + [ |
|
| 131 | + 'script' => 'configurer_' . $prefix, |
|
| 132 | + 'nom' => $nom |
|
| 133 | + ] |
|
| 134 | + ); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // checkbox pour activer ou desactiver |
| 138 | 138 | // si ce n'est pas une extension |
| 139 | 139 | |
| 140 | 140 | function plugin_checkbox($id_input, $file, $actif) { |
| 141 | - $name = substr(md5($file), 0, 16); |
|
| 142 | - |
|
| 143 | - return "<div class='check'>\n" |
|
| 144 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 145 | - . ($actif ? " checked='checked'" : '') |
|
| 146 | - . " class='checkbox' value='O' />" |
|
| 147 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 148 | - . '</div>'; |
|
| 141 | + $name = substr(md5($file), 0, 16); |
|
| 142 | + |
|
| 143 | + return "<div class='check'>\n" |
|
| 144 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 145 | + . ($actif ? " checked='checked'" : '') |
|
| 146 | + . " class='checkbox' value='O' />" |
|
| 147 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 148 | + . '</div>'; |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 152 | - $prefix = $info['prefix']; |
|
| 153 | - $dir = "$dir_plugins$plug_file"; |
|
| 154 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 155 | - if ($info['dtd'] == 'paquet') { |
|
| 156 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 157 | - if (!$nom) { |
|
| 158 | - $nom = typo($info['nom']); |
|
| 159 | - } |
|
| 160 | - } else { |
|
| 161 | - $nom = typo(attribut_html($info['nom'])); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - return trim($nom); |
|
| 152 | + $prefix = $info['prefix']; |
|
| 153 | + $dir = "$dir_plugins$plug_file"; |
|
| 154 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 155 | + if ($info['dtd'] == 'paquet') { |
|
| 156 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 157 | + if (!$nom) { |
|
| 158 | + $nom = typo($info['nom']); |
|
| 159 | + } |
|
| 160 | + } else { |
|
| 161 | + $nom = typo(attribut_html($info['nom'])); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + return trim($nom); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Cartouche Resume |
| 168 | 168 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 169 | - $prefix = $info['prefix']; |
|
| 170 | - $dir = "$dir_plugins$plug_file"; |
|
| 171 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 172 | - // une seule ligne dans le slogan : couper si besoin |
|
| 173 | - if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 174 | - $slogan = substr($slogan, 0, $p); |
|
| 175 | - } |
|
| 176 | - // couper par securite |
|
| 177 | - $slogan = couper($slogan, 80); |
|
| 178 | - |
|
| 179 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 180 | - |
|
| 181 | - $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 182 | - |
|
| 183 | - $icon_class = 'icon'; |
|
| 184 | - $img = ''; |
|
| 185 | - if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 186 | - $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 187 | - if (!extraire_attribut($img, 'src')) { |
|
| 188 | - $img = ''; |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - if (!$img) { |
|
| 192 | - $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 193 | - $icon_class .= ' no-logo'; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 197 | - |
|
| 198 | - return "<div class='resume'>" |
|
| 199 | - . "<h3><a href='$url' rel='info'>" |
|
| 200 | - . $nom |
|
| 201 | - . '</a></h3>' |
|
| 202 | - . " <span class='version'>" . $info['version'] . '</span>' |
|
| 203 | - . " <span class='etat'> - " |
|
| 204 | - . plugin_etat_en_clair($info['etat']) |
|
| 205 | - . '</span>' |
|
| 206 | - . "<div class='short'>" . $slogan . '</div>' |
|
| 207 | - . $i |
|
| 208 | - . '</div>'; |
|
| 169 | + $prefix = $info['prefix']; |
|
| 170 | + $dir = "$dir_plugins$plug_file"; |
|
| 171 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 172 | + // une seule ligne dans le slogan : couper si besoin |
|
| 173 | + if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 174 | + $slogan = substr($slogan, 0, $p); |
|
| 175 | + } |
|
| 176 | + // couper par securite |
|
| 177 | + $slogan = couper($slogan, 80); |
|
| 178 | + |
|
| 179 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 180 | + |
|
| 181 | + $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 182 | + |
|
| 183 | + $icon_class = 'icon'; |
|
| 184 | + $img = ''; |
|
| 185 | + if (isset($info['logo']) and $i = trim($info['logo'])) { |
|
| 186 | + $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 187 | + if (!extraire_attribut($img, 'src')) { |
|
| 188 | + $img = ''; |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + if (!$img) { |
|
| 192 | + $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 193 | + $icon_class .= ' no-logo'; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 197 | + |
|
| 198 | + return "<div class='resume'>" |
|
| 199 | + . "<h3><a href='$url' rel='info'>" |
|
| 200 | + . $nom |
|
| 201 | + . '</a></h3>' |
|
| 202 | + . " <span class='version'>" . $info['version'] . '</span>' |
|
| 203 | + . " <span class='etat'> - " |
|
| 204 | + . plugin_etat_en_clair($info['etat']) |
|
| 205 | + . '</span>' |
|
| 206 | + . "<div class='short'>" . $slogan . '</div>' |
|
| 207 | + . $i |
|
| 208 | + . '</div>'; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 212 | - if (!$dir_plugins) { |
|
| 213 | - $dir_plugins = _DIR_PLUGINS; |
|
| 214 | - } |
|
| 212 | + if (!$dir_plugins) { |
|
| 213 | + $dir_plugins = _DIR_PLUGINS; |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 217 | - $text = _T('bouton_desinstaller'); |
|
| 218 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 219 | - $file = basename($plug_file); |
|
| 216 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 217 | + $text = _T('bouton_desinstaller'); |
|
| 218 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 219 | + $file = basename($plug_file); |
|
| 220 | 220 | |
| 221 | - return "<div class='actions'>[" . |
|
| 222 | - "<a href='$action' |
|
| 221 | + return "<div class='actions'>[" . |
|
| 222 | + "<a href='$action' |
|
| 223 | 223 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 224 | - . $text |
|
| 225 | - . '</a>]</div>'; |
|
| 224 | + . $text |
|
| 225 | + . '</a>]</div>'; |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -236,145 +236,145 @@ discard block |
||
| 236 | 236 | * Traduction de l'état dans la langue en cours |
| 237 | 237 | **/ |
| 238 | 238 | function plugin_etat_en_clair($etat) { |
| 239 | - if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 240 | - $etat = 'developpement'; |
|
| 241 | - } |
|
| 239 | + if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 240 | + $etat = 'developpement'; |
|
| 241 | + } |
|
| 242 | 242 | |
| 243 | - return _T('plugin_etat_' . $etat); |
|
| 243 | + return _T('plugin_etat_' . $etat); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | function plugin_propre($texte, $module = '', $propre = 'propre') { |
| 247 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 248 | - if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 249 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 250 | - } |
|
| 251 | - if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 252 | - $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return $propre($texte); |
|
| 247 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 248 | + if (_DIR_RACINE and strncmp($module, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 249 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 250 | + } |
|
| 251 | + if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 252 | + $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return $propre($texte); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | function plugin_typo($texte, $module = '') { |
| 259 | - return plugin_propre($texte, $module, 'typo'); |
|
| 259 | + return plugin_propre($texte, $module, 'typo'); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | |
| 263 | 263 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 264 | - $log = null; |
|
| 265 | - if (!$dir_plugins) { |
|
| 266 | - $dir_plugins = _DIR_PLUGINS; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - $prefix = $info['prefix']; |
|
| 270 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 271 | - |
|
| 272 | - $s = ''; |
|
| 273 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 274 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 275 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 276 | - $description = ''; |
|
| 277 | - if (isset($info['description'])) { |
|
| 278 | - $description = plugin_propre($info['description'], $dir); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - if ( |
|
| 282 | - isset($info['documentation']) |
|
| 283 | - and $lien = $info['documentation'] |
|
| 284 | - ) { |
|
| 285 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 286 | - } |
|
| 287 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 288 | - |
|
| 289 | - if (isset($info['auteur'])) { |
|
| 290 | - if (is_array($info['auteur'])) { |
|
| 291 | - $a = formater_credits($info['auteur'], ', '); |
|
| 292 | - } // pour compat mais ne doit plus arriver |
|
| 293 | - else { |
|
| 294 | - $a = trim($info['auteur']); |
|
| 295 | - } |
|
| 296 | - if ($a) { |
|
| 297 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 298 | - $a, |
|
| 299 | - $dir |
|
| 300 | - )) . "</dd>\n"; |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - if (isset($info['credit'])) { |
|
| 305 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 306 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 307 | - $a, |
|
| 308 | - $dir |
|
| 309 | - )) . "</dd>\n"; |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - if (isset($info['licence'])) { |
|
| 314 | - if (is_array($info['licence'])) { |
|
| 315 | - $a = formater_credits($info['licence'], ', '); |
|
| 316 | - } // pour compat mais ne doit plus arriver |
|
| 317 | - else { |
|
| 318 | - $a = trim($info['licence']); |
|
| 319 | - } |
|
| 320 | - if ($a) { |
|
| 321 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 322 | - $a, |
|
| 323 | - $dir |
|
| 324 | - )) . "</dd>\n"; |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - $s = "<dl class='description'>$s</dl>"; |
|
| 329 | - |
|
| 330 | - // |
|
| 331 | - // Ajouter les infos techniques |
|
| 332 | - // |
|
| 333 | - $infotech = []; |
|
| 334 | - |
|
| 335 | - $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 336 | - // Version VCS |
|
| 337 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 338 | - $version .= ' ' . $vcs; |
|
| 339 | - } |
|
| 340 | - $version .= '</dd>'; |
|
| 341 | - $infotech[] = $version; |
|
| 342 | - $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 343 | - // source zip le cas echeant |
|
| 344 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 345 | - and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 346 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 347 | - : ''; |
|
| 348 | - |
|
| 349 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 350 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 351 | - ' ', |
|
| 352 | - array_map('array_shift', $info['necessite']) |
|
| 353 | - ) . '</dd>'); |
|
| 354 | - |
|
| 355 | - $s .= "<dl class='tech'>" |
|
| 356 | - . join('', $infotech) |
|
| 357 | - . '</dl>'; |
|
| 358 | - |
|
| 359 | - |
|
| 360 | - return $s; |
|
| 264 | + $log = null; |
|
| 265 | + if (!$dir_plugins) { |
|
| 266 | + $dir_plugins = _DIR_PLUGINS; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + $prefix = $info['prefix']; |
|
| 270 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 271 | + |
|
| 272 | + $s = ''; |
|
| 273 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 274 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 275 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 276 | + $description = ''; |
|
| 277 | + if (isset($info['description'])) { |
|
| 278 | + $description = plugin_propre($info['description'], $dir); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + if ( |
|
| 282 | + isset($info['documentation']) |
|
| 283 | + and $lien = $info['documentation'] |
|
| 284 | + ) { |
|
| 285 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 286 | + } |
|
| 287 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 288 | + |
|
| 289 | + if (isset($info['auteur'])) { |
|
| 290 | + if (is_array($info['auteur'])) { |
|
| 291 | + $a = formater_credits($info['auteur'], ', '); |
|
| 292 | + } // pour compat mais ne doit plus arriver |
|
| 293 | + else { |
|
| 294 | + $a = trim($info['auteur']); |
|
| 295 | + } |
|
| 296 | + if ($a) { |
|
| 297 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 298 | + $a, |
|
| 299 | + $dir |
|
| 300 | + )) . "</dd>\n"; |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + if (isset($info['credit'])) { |
|
| 305 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 306 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 307 | + $a, |
|
| 308 | + $dir |
|
| 309 | + )) . "</dd>\n"; |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + if (isset($info['licence'])) { |
|
| 314 | + if (is_array($info['licence'])) { |
|
| 315 | + $a = formater_credits($info['licence'], ', '); |
|
| 316 | + } // pour compat mais ne doit plus arriver |
|
| 317 | + else { |
|
| 318 | + $a = trim($info['licence']); |
|
| 319 | + } |
|
| 320 | + if ($a) { |
|
| 321 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 322 | + $a, |
|
| 323 | + $dir |
|
| 324 | + )) . "</dd>\n"; |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + $s = "<dl class='description'>$s</dl>"; |
|
| 329 | + |
|
| 330 | + // |
|
| 331 | + // Ajouter les infos techniques |
|
| 332 | + // |
|
| 333 | + $infotech = []; |
|
| 334 | + |
|
| 335 | + $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 336 | + // Version VCS |
|
| 337 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 338 | + $version .= ' ' . $vcs; |
|
| 339 | + } |
|
| 340 | + $version .= '</dd>'; |
|
| 341 | + $infotech[] = $version; |
|
| 342 | + $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 343 | + // source zip le cas echeant |
|
| 344 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) |
|
| 345 | + and preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 346 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 347 | + : ''; |
|
| 348 | + |
|
| 349 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 350 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 351 | + ' ', |
|
| 352 | + array_map('array_shift', $info['necessite']) |
|
| 353 | + ) . '</dd>'); |
|
| 354 | + |
|
| 355 | + $s .= "<dl class='tech'>" |
|
| 356 | + . join('', $infotech) |
|
| 357 | + . '</dl>'; |
|
| 358 | + |
|
| 359 | + |
|
| 360 | + return $s; |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | function formater_credits($infos, $sep = ', ') { |
| 364 | - $texte = ''; |
|
| 365 | - |
|
| 366 | - foreach ($infos as $_credit) { |
|
| 367 | - if ($texte) { |
|
| 368 | - $texte .= $sep; |
|
| 369 | - } |
|
| 370 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 371 | - $texte .= |
|
| 372 | - (!is_array($_credit)) |
|
| 373 | - ? PtoBR(propre($_credit)) |
|
| 374 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 375 | - $_credit['nom'] . |
|
| 376 | - ($_credit['url'] ? '</a>' : ''); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - return $texte; |
|
| 364 | + $texte = ''; |
|
| 365 | + |
|
| 366 | + foreach ($infos as $_credit) { |
|
| 367 | + if ($texte) { |
|
| 368 | + $texte .= $sep; |
|
| 369 | + } |
|
| 370 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 371 | + $texte .= |
|
| 372 | + (!is_array($_credit)) |
|
| 373 | + ? PtoBR(propre($_credit)) |
|
| 374 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 375 | + $_credit['nom'] . |
|
| 376 | + ($_credit['url'] ? '</a>' : ''); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + return $texte; |
|
| 380 | 380 | } |