@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @package SPIP\Core\Drapeaux\Edition |
| 31 | 31 | **/ |
| 32 | 32 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 33 | - return; |
|
| 33 | + return; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -45,46 +45,46 @@ discard block |
||
| 45 | 45 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 46 | 46 | **/ |
| 47 | 47 | function lire_tableau_edition() { |
| 48 | - $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | - if (!$edition) { |
|
| 50 | - return []; |
|
| 51 | - } |
|
| 52 | - $changed = false; |
|
| 48 | + $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | + if (!$edition) { |
|
| 50 | + return []; |
|
| 51 | + } |
|
| 52 | + $changed = false; |
|
| 53 | 53 | |
| 54 | - $bon_pour_le_service = time() - 3600; |
|
| 55 | - // parcourir le tableau et virer les vieux |
|
| 56 | - foreach ($edition as $objet => $data) { |
|
| 57 | - if (!is_array($data)) { |
|
| 58 | - unset($edition[$objet]); |
|
| 59 | - } // vieille version |
|
| 60 | - else { |
|
| 61 | - foreach ($data as $id => $tab) { |
|
| 62 | - if (!is_array($tab)) { |
|
| 63 | - unset($edition[$objet][$tab]); |
|
| 64 | - } // vieille version |
|
| 65 | - else { |
|
| 66 | - foreach ($tab as $n => $duo) { |
|
| 67 | - if (current($duo) < $bon_pour_le_service) { |
|
| 68 | - unset($edition[$objet][$id][$n]); |
|
| 69 | - $changed = true; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - if (!$edition[$objet][$id]) { |
|
| 74 | - unset($edition[$objet][$id]); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - if (!$edition[$objet]) { |
|
| 79 | - unset($edition[$objet]); |
|
| 80 | - } |
|
| 81 | - } |
|
| 54 | + $bon_pour_le_service = time() - 3600; |
|
| 55 | + // parcourir le tableau et virer les vieux |
|
| 56 | + foreach ($edition as $objet => $data) { |
|
| 57 | + if (!is_array($data)) { |
|
| 58 | + unset($edition[$objet]); |
|
| 59 | + } // vieille version |
|
| 60 | + else { |
|
| 61 | + foreach ($data as $id => $tab) { |
|
| 62 | + if (!is_array($tab)) { |
|
| 63 | + unset($edition[$objet][$tab]); |
|
| 64 | + } // vieille version |
|
| 65 | + else { |
|
| 66 | + foreach ($tab as $n => $duo) { |
|
| 67 | + if (current($duo) < $bon_pour_le_service) { |
|
| 68 | + unset($edition[$objet][$id][$n]); |
|
| 69 | + $changed = true; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + if (!$edition[$objet][$id]) { |
|
| 74 | + unset($edition[$objet][$id]); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + if (!$edition[$objet]) { |
|
| 79 | + unset($edition[$objet]); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if ($changed) { |
|
| 84 | - ecrire_tableau_edition($edition); |
|
| 85 | - } |
|
| 83 | + if ($changed) { |
|
| 84 | + ecrire_tableau_edition($edition); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return $edition; |
|
| 87 | + return $edition; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 98 | 98 | **/ |
| 99 | 99 | function ecrire_tableau_edition($edition) { |
| 100 | - ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 100 | + ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | * Type d'objet édité |
| 118 | 118 | */ |
| 119 | 119 | function signale_edition($id, $auteur, $type = 'article') { |
| 120 | - include_spip('base/objets'); |
|
| 121 | - include_spip('inc/filtres'); |
|
| 122 | - if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | - return; |
|
| 124 | - } |
|
| 120 | + include_spip('base/objets'); |
|
| 121 | + include_spip('inc/filtres'); |
|
| 122 | + if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $edition = lire_tableau_edition(); |
|
| 127 | - if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | - $nom = $auteur['nom']; |
|
| 129 | - } else { |
|
| 130 | - $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | - } |
|
| 126 | + $edition = lire_tableau_edition(); |
|
| 127 | + if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | + $nom = $auteur['nom']; |
|
| 129 | + } else { |
|
| 130 | + $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | - $edition[$type][$id] = []; |
|
| 135 | - } |
|
| 136 | - $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | - ecrire_tableau_edition($edition); |
|
| 133 | + if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | + $edition[$type][$id] = []; |
|
| 135 | + } |
|
| 136 | + $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | + ecrire_tableau_edition($edition); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function qui_edite($id, $type = 'article') { |
| 153 | 153 | |
| 154 | - $edition = lire_tableau_edition(); |
|
| 154 | + $edition = lire_tableau_edition(); |
|
| 155 | 155 | |
| 156 | - return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 156 | + return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,22 +167,22 @@ discard block |
||
| 167 | 167 | * Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]` |
| 168 | 168 | */ |
| 169 | 169 | function mention_qui_edite($id, $type = 'article') { |
| 170 | - $modif = qui_edite($id, $type); |
|
| 171 | - unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 170 | + $modif = qui_edite($id, $type); |
|
| 171 | + unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 172 | 172 | |
| 173 | - if ($modif) { |
|
| 174 | - $quand = 0; |
|
| 175 | - foreach ($modif as $duo) { |
|
| 176 | - $auteurs[] = typo(key($duo)); |
|
| 177 | - $quand = max($quand, current($duo)); |
|
| 178 | - } |
|
| 173 | + if ($modif) { |
|
| 174 | + $quand = 0; |
|
| 175 | + foreach ($modif as $duo) { |
|
| 176 | + $auteurs[] = typo(key($duo)); |
|
| 177 | + $quand = max($quand, current($duo)); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | - return [ |
|
| 182 | - 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | - 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | - ]; |
|
| 185 | - } |
|
| 180 | + // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | + return [ |
|
| 182 | + 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | + 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | + ]; |
|
| 185 | + } |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -196,25 +196,25 @@ discard block |
||
| 196 | 196 | * Liste de tableaux `['objet' => x, 'id_objet' => n]` |
| 197 | 197 | */ |
| 198 | 198 | function liste_drapeau_edition($id_auteur) { |
| 199 | - $edition = lire_tableau_edition(); |
|
| 200 | - $objets_ouverts = []; |
|
| 199 | + $edition = lire_tableau_edition(); |
|
| 200 | + $objets_ouverts = []; |
|
| 201 | 201 | |
| 202 | - foreach ($edition as $objet => $data) { |
|
| 203 | - foreach ($data as $id => $auteurs) { |
|
| 204 | - if ( |
|
| 205 | - isset($auteurs[$id_auteur]) |
|
| 206 | - and is_array($auteurs[$id_auteur]) // precaution |
|
| 207 | - and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 208 | - ) { |
|
| 209 | - $objets_ouverts[] = [ |
|
| 210 | - 'objet' => $objet, |
|
| 211 | - 'id_objet' => $id, |
|
| 212 | - ]; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 202 | + foreach ($edition as $objet => $data) { |
|
| 203 | + foreach ($data as $id => $auteurs) { |
|
| 204 | + if ( |
|
| 205 | + isset($auteurs[$id_auteur]) |
|
| 206 | + and is_array($auteurs[$id_auteur]) // precaution |
|
| 207 | + and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 208 | + ) { |
|
| 209 | + $objets_ouverts[] = [ |
|
| 210 | + 'objet' => $objet, |
|
| 211 | + 'id_objet' => $id, |
|
| 212 | + ]; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return $objets_ouverts; |
|
| 217 | + return $objets_ouverts; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | * @return void |
| 228 | 228 | */ |
| 229 | 229 | function debloquer_tous($id_auteur) { |
| 230 | - $edition = lire_tableau_edition(); |
|
| 231 | - foreach ($edition as $objet => $data) { |
|
| 232 | - foreach ($data as $id => $auteurs) { |
|
| 233 | - if (isset($auteurs[$id_auteur])) { |
|
| 234 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 235 | - ecrire_tableau_edition($edition); |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 230 | + $edition = lire_tableau_edition(); |
|
| 231 | + foreach ($edition as $objet => $data) { |
|
| 232 | + foreach ($data as $id => $auteurs) { |
|
| 233 | + if (isset($auteurs[$id_auteur])) { |
|
| 234 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 235 | + ecrire_tableau_edition($edition); |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -253,19 +253,19 @@ discard block |
||
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | 255 | function debloquer_edition($id_auteur, $id_objet, $type = 'article') { |
| 256 | - $edition = lire_tableau_edition(); |
|
| 256 | + $edition = lire_tableau_edition(); |
|
| 257 | 257 | |
| 258 | - foreach ($edition as $objet => $data) { |
|
| 259 | - if ($objet == $type) { |
|
| 260 | - foreach ($data as $id => $auteurs) { |
|
| 261 | - if ( |
|
| 262 | - $id == $id_objet |
|
| 263 | - and isset($auteurs[$id_auteur]) |
|
| 264 | - ) { |
|
| 265 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 266 | - ecrire_tableau_edition($edition); |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - } |
|
| 258 | + foreach ($edition as $objet => $data) { |
|
| 259 | + if ($objet == $type) { |
|
| 260 | + foreach ($data as $id => $auteurs) { |
|
| 261 | + if ( |
|
| 262 | + $id == $id_objet |
|
| 263 | + and isset($auteurs[$id_auteur]) |
|
| 264 | + ) { |
|
| 265 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 266 | + ecrire_tableau_edition($edition); |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | 271 | } |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -47,27 +47,27 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | **/ |
| 49 | 49 | function liste_plugin_files($dir_plugins = null) { |
| 50 | - static $plugin_files = []; |
|
| 51 | - if (is_null($dir_plugins)) { |
|
| 52 | - $dir_plugins = _DIR_PLUGINS; |
|
| 53 | - } |
|
| 54 | - if ( |
|
| 55 | - !isset($plugin_files[$dir_plugins]) |
|
| 56 | - or count($plugin_files[$dir_plugins]) == 0 |
|
| 57 | - ) { |
|
| 58 | - $plugin_files[$dir_plugins] = []; |
|
| 59 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | - $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - sort($plugin_files[$dir_plugins]); |
|
| 64 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | - $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return $plugin_files[$dir_plugins]; |
|
| 50 | + static $plugin_files = []; |
|
| 51 | + if (is_null($dir_plugins)) { |
|
| 52 | + $dir_plugins = _DIR_PLUGINS; |
|
| 53 | + } |
|
| 54 | + if ( |
|
| 55 | + !isset($plugin_files[$dir_plugins]) |
|
| 56 | + or count($plugin_files[$dir_plugins]) == 0 |
|
| 57 | + ) { |
|
| 58 | + $plugin_files[$dir_plugins] = []; |
|
| 59 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | + $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + sort($plugin_files[$dir_plugins]); |
|
| 64 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | + $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return $plugin_files[$dir_plugins]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -83,45 +83,45 @@ discard block |
||
| 83 | 83 | * Liste complète des répeertoires |
| 84 | 84 | **/ |
| 85 | 85 | function fast_find_plugin_dirs($dir, $max_prof = 100) { |
| 86 | - $fichiers = []; |
|
| 87 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | - if ($dir == '') { |
|
| 91 | - $dir = '.'; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (!is_dir($dir)) { |
|
| 95 | - return $fichiers; |
|
| 96 | - } |
|
| 97 | - if (is_plugin_dir($dir, '')) { |
|
| 98 | - $fichiers[] = $dir; |
|
| 99 | - |
|
| 100 | - return $fichiers; |
|
| 101 | - } |
|
| 102 | - if ($max_prof <= 0) { |
|
| 103 | - return $fichiers; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $subdirs = []; |
|
| 107 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | - while (($f = readdir($d)) !== false) { |
|
| 109 | - if ( |
|
| 110 | - $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | - and $f != 'CVS' |
|
| 112 | - and is_dir($f = "$dir/$f") |
|
| 113 | - ) { |
|
| 114 | - $subdirs[] = $f; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - closedir($d); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - foreach ($subdirs as $d) { |
|
| 121 | - $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $fichiers; |
|
| 86 | + $fichiers = []; |
|
| 87 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | + if ($dir == '') { |
|
| 91 | + $dir = '.'; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (!is_dir($dir)) { |
|
| 95 | + return $fichiers; |
|
| 96 | + } |
|
| 97 | + if (is_plugin_dir($dir, '')) { |
|
| 98 | + $fichiers[] = $dir; |
|
| 99 | + |
|
| 100 | + return $fichiers; |
|
| 101 | + } |
|
| 102 | + if ($max_prof <= 0) { |
|
| 103 | + return $fichiers; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $subdirs = []; |
|
| 107 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | + while (($f = readdir($d)) !== false) { |
|
| 109 | + if ( |
|
| 110 | + $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | + and $f != 'CVS' |
|
| 112 | + and is_dir($f = "$dir/$f") |
|
| 113 | + ) { |
|
| 114 | + $subdirs[] = $f; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + closedir($d); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + foreach ($subdirs as $d) { |
|
| 121 | + $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $fichiers; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,27 +142,27 @@ discard block |
||
| 142 | 142 | **/ |
| 143 | 143 | function is_plugin_dir($dir, $dir_plugins = null) { |
| 144 | 144 | |
| 145 | - if (is_array($dir)) { |
|
| 146 | - foreach ($dir as $k => $d) { |
|
| 147 | - if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | - unset($dir[$k]); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $dir; |
|
| 153 | - } |
|
| 154 | - if (is_null($dir_plugins)) { |
|
| 155 | - $dir_plugins = _DIR_PLUGINS; |
|
| 156 | - } |
|
| 157 | - $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | - |
|
| 159 | - foreach ($search as $s) { |
|
| 160 | - if (file_exists($s)) { |
|
| 161 | - return $dir; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return ''; |
|
| 145 | + if (is_array($dir)) { |
|
| 146 | + foreach ($dir as $k => $d) { |
|
| 147 | + if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | + unset($dir[$k]); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $dir; |
|
| 153 | + } |
|
| 154 | + if (is_null($dir_plugins)) { |
|
| 155 | + $dir_plugins = _DIR_PLUGINS; |
|
| 156 | + } |
|
| 157 | + $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | + |
|
| 159 | + foreach ($search as $s) { |
|
| 160 | + if (file_exists($s)) { |
|
| 161 | + return $dir; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return ''; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** Regexp d'extraction des informations d'un intervalle de compatibilité */ |
@@ -189,51 +189,51 @@ discard block |
||
| 189 | 189 | **/ |
| 190 | 190 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 191 | 191 | |
| 192 | - if (!strlen($intervalle)) { |
|
| 193 | - return true; |
|
| 194 | - } |
|
| 195 | - if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | - $minimum = $regs[1]; |
|
| 201 | - $maximum = $regs[2]; |
|
| 202 | - |
|
| 203 | - // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | - // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | - // entre plugins) |
|
| 208 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | - if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | - return true; |
|
| 211 | - } |
|
| 212 | - // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | - // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $minimum_inc = $intervalle[0] == '['; |
|
| 217 | - $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | - |
|
| 219 | - if (strlen($minimum)) { |
|
| 220 | - if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | - return false; |
|
| 222 | - } |
|
| 223 | - if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | - return false; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - if (strlen($maximum)) { |
|
| 228 | - if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | - return false; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return true; |
|
| 192 | + if (!strlen($intervalle)) { |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 195 | + if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | + $minimum = $regs[1]; |
|
| 201 | + $maximum = $regs[2]; |
|
| 202 | + |
|
| 203 | + // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | + // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | + // entre plugins) |
|
| 208 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | + if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | + return true; |
|
| 211 | + } |
|
| 212 | + // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | + // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $minimum_inc = $intervalle[0] == '['; |
|
| 217 | + $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | + |
|
| 219 | + if (strlen($minimum)) { |
|
| 220 | + if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 223 | + if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + if (strlen($maximum)) { |
|
| 228 | + if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | + return false; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + return true; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -250,62 +250,62 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function liste_plugin_valides($liste_plug, $force = false) { |
| 253 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | - $infos = [ |
|
| 256 | - // lister les extensions qui sont automatiquement actives |
|
| 257 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | - ]; |
|
| 260 | - |
|
| 261 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | - $liste_non_classee = [ |
|
| 267 | - 'SPIP' => [ |
|
| 268 | - 'nom' => 'SPIP', |
|
| 269 | - 'etat' => 'stable', |
|
| 270 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | - 'dir' => '', |
|
| 273 | - ] |
|
| 274 | - ]; |
|
| 275 | - |
|
| 276 | - $invalides = []; |
|
| 277 | - foreach ($liste_ext as $plug) { |
|
| 278 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - foreach ($liste_plug as $plug) { |
|
| 283 | - if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | - if (is_array($r)) { |
|
| 286 | - $invalides = array_merge($invalides, $r); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | - foreach ($liste_plug as $plug) { |
|
| 294 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | - if (is_array($r)) { |
|
| 297 | - $invalides = array_merge($invalides, $r); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | - |
|
| 305 | - // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | - $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | - |
|
| 308 | - return [$infos, $liste_non_classee, $invalides]; |
|
| 253 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | + $infos = [ |
|
| 256 | + // lister les extensions qui sont automatiquement actives |
|
| 257 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | + ]; |
|
| 260 | + |
|
| 261 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | + $liste_non_classee = [ |
|
| 267 | + 'SPIP' => [ |
|
| 268 | + 'nom' => 'SPIP', |
|
| 269 | + 'etat' => 'stable', |
|
| 270 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | + 'dir' => '', |
|
| 273 | + ] |
|
| 274 | + ]; |
|
| 275 | + |
|
| 276 | + $invalides = []; |
|
| 277 | + foreach ($liste_ext as $plug) { |
|
| 278 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + foreach ($liste_plug as $plug) { |
|
| 283 | + if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | + if (is_array($r)) { |
|
| 286 | + $invalides = array_merge($invalides, $r); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | + foreach ($liste_plug as $plug) { |
|
| 294 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | + if (is_array($r)) { |
|
| 297 | + $invalides = array_merge($invalides, $r); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | + |
|
| 305 | + // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | + $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | + |
|
| 308 | + return [$infos, $liste_non_classee, $invalides]; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -325,30 +325,30 @@ discard block |
||
| 325 | 325 | * array description short si on ne le retient pas (pour memorisation dans une table des erreurs) |
| 326 | 326 | */ |
| 327 | 327 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) { |
| 328 | - $i = $infos[$dir_type][$plug]; |
|
| 329 | - $p = strtoupper($i['prefix']); |
|
| 330 | - $short_desc = [ |
|
| 331 | - 'nom' => $i['nom'], |
|
| 332 | - 'etat' => $i['etat'], |
|
| 333 | - 'version' => $i['version'], |
|
| 334 | - 'dir' => $plug, |
|
| 335 | - 'dir_type' => $dir_type |
|
| 336 | - ]; |
|
| 337 | - if (isset($i['erreur']) and $i['erreur']) { |
|
| 338 | - $short_desc['erreur'] = $i['erreur']; |
|
| 339 | - return [$p => $short_desc]; |
|
| 340 | - } |
|
| 341 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 342 | - return [$p => $short_desc]; |
|
| 343 | - } |
|
| 344 | - if ( |
|
| 345 | - !isset($liste[$p]) |
|
| 346 | - or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 347 | - ) { |
|
| 348 | - $liste[$p] = $short_desc; |
|
| 349 | - } |
|
| 350 | - // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 351 | - return $p; |
|
| 328 | + $i = $infos[$dir_type][$plug]; |
|
| 329 | + $p = strtoupper($i['prefix']); |
|
| 330 | + $short_desc = [ |
|
| 331 | + 'nom' => $i['nom'], |
|
| 332 | + 'etat' => $i['etat'], |
|
| 333 | + 'version' => $i['version'], |
|
| 334 | + 'dir' => $plug, |
|
| 335 | + 'dir_type' => $dir_type |
|
| 336 | + ]; |
|
| 337 | + if (isset($i['erreur']) and $i['erreur']) { |
|
| 338 | + $short_desc['erreur'] = $i['erreur']; |
|
| 339 | + return [$p => $short_desc]; |
|
| 340 | + } |
|
| 341 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 342 | + return [$p => $short_desc]; |
|
| 343 | + } |
|
| 344 | + if ( |
|
| 345 | + !isset($liste[$p]) |
|
| 346 | + or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 347 | + ) { |
|
| 348 | + $liste[$p] = $short_desc; |
|
| 349 | + } |
|
| 350 | + // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 351 | + return $p; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -364,47 +364,47 @@ discard block |
||
| 364 | 364 | * @param array $infos |
| 365 | 365 | */ |
| 366 | 366 | function plugin_fixer_procure(&$liste, &$infos) { |
| 367 | - foreach ($liste as $p => $resume) { |
|
| 368 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 369 | - if (isset($i['procure']) and $i['procure']) { |
|
| 370 | - foreach ($i['procure'] as $procure) { |
|
| 371 | - $p = strtoupper($procure['nom']); |
|
| 372 | - $dir = $resume['dir']; |
|
| 373 | - if ($dir) { |
|
| 374 | - $dir .= '/'; |
|
| 375 | - } |
|
| 376 | - $dir .= 'procure:' . $procure['nom']; |
|
| 377 | - |
|
| 378 | - $procure['etat'] = '?'; |
|
| 379 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 380 | - $procure['dir'] = $dir; |
|
| 381 | - |
|
| 382 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 383 | - // on ajoute cette version a la liste |
|
| 384 | - if ( |
|
| 385 | - !isset($liste[$p]) |
|
| 386 | - or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 387 | - ) { |
|
| 388 | - $liste[$p] = $procure; |
|
| 389 | - |
|
| 390 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 391 | - $infos[$resume['dir_type']][$dir] = [ |
|
| 392 | - 'prefix' => $procure['nom'], |
|
| 393 | - 'nom' => $procure['nom'], |
|
| 394 | - 'etat' => $procure['etat'], |
|
| 395 | - 'version' => $procure['version'], |
|
| 396 | - 'chemin' => [], |
|
| 397 | - 'necessite' => [], |
|
| 398 | - 'utilise' => [], |
|
| 399 | - 'lib' => [], |
|
| 400 | - 'menu' => [], |
|
| 401 | - 'onglet' => [], |
|
| 402 | - 'procure' => [], |
|
| 403 | - ]; |
|
| 404 | - } |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - } |
|
| 367 | + foreach ($liste as $p => $resume) { |
|
| 368 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 369 | + if (isset($i['procure']) and $i['procure']) { |
|
| 370 | + foreach ($i['procure'] as $procure) { |
|
| 371 | + $p = strtoupper($procure['nom']); |
|
| 372 | + $dir = $resume['dir']; |
|
| 373 | + if ($dir) { |
|
| 374 | + $dir .= '/'; |
|
| 375 | + } |
|
| 376 | + $dir .= 'procure:' . $procure['nom']; |
|
| 377 | + |
|
| 378 | + $procure['etat'] = '?'; |
|
| 379 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 380 | + $procure['dir'] = $dir; |
|
| 381 | + |
|
| 382 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 383 | + // on ajoute cette version a la liste |
|
| 384 | + if ( |
|
| 385 | + !isset($liste[$p]) |
|
| 386 | + or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 387 | + ) { |
|
| 388 | + $liste[$p] = $procure; |
|
| 389 | + |
|
| 390 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 391 | + $infos[$resume['dir_type']][$dir] = [ |
|
| 392 | + 'prefix' => $procure['nom'], |
|
| 393 | + 'nom' => $procure['nom'], |
|
| 394 | + 'etat' => $procure['etat'], |
|
| 395 | + 'version' => $procure['version'], |
|
| 396 | + 'chemin' => [], |
|
| 397 | + 'necessite' => [], |
|
| 398 | + 'utilise' => [], |
|
| 399 | + 'lib' => [], |
|
| 400 | + 'menu' => [], |
|
| 401 | + 'onglet' => [], |
|
| 402 | + 'procure' => [], |
|
| 403 | + ]; |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + } |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -418,20 +418,20 @@ discard block |
||
| 418 | 418 | * @return array |
| 419 | 419 | */ |
| 420 | 420 | function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) { |
| 421 | - foreach ($liste as $prefix => $infos) { |
|
| 422 | - if ( |
|
| 423 | - !$dir_plugins |
|
| 424 | - or ( |
|
| 425 | - defined($infos['dir_type']) |
|
| 426 | - and constant($infos['dir_type']) == $dir_plugins) |
|
| 427 | - ) { |
|
| 428 | - $liste[$prefix] = $infos['dir']; |
|
| 429 | - } else { |
|
| 430 | - unset($liste[$prefix]); |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - return $liste; |
|
| 421 | + foreach ($liste as $prefix => $infos) { |
|
| 422 | + if ( |
|
| 423 | + !$dir_plugins |
|
| 424 | + or ( |
|
| 425 | + defined($infos['dir_type']) |
|
| 426 | + and constant($infos['dir_type']) == $dir_plugins) |
|
| 427 | + ) { |
|
| 428 | + $liste[$prefix] = $infos['dir']; |
|
| 429 | + } else { |
|
| 430 | + unset($liste[$prefix]); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + return $liste; |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | /** |
@@ -446,9 +446,9 @@ discard block |
||
| 446 | 446 | * @return array |
| 447 | 447 | */ |
| 448 | 448 | function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) { |
| 449 | - include_spip('plugins/installer'); |
|
| 449 | + include_spip('plugins/installer'); |
|
| 450 | 450 | |
| 451 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 451 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -479,54 +479,54 @@ discard block |
||
| 479 | 479 | * qui n'ont pas satisfait leurs dépendances |
| 480 | 480 | **/ |
| 481 | 481 | function plugin_trier($infos, $liste_non_classee) { |
| 482 | - $toute_la_liste = $liste_non_classee; |
|
| 483 | - $liste = $ordre = []; |
|
| 484 | - $count = 0; |
|
| 485 | - |
|
| 486 | - while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 487 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 488 | - $count = $c; |
|
| 489 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 490 | - $plug = $resume['dir']; |
|
| 491 | - $dir_type = $resume['dir_type']; |
|
| 492 | - $info1 = $infos[$dir_type][$plug]; |
|
| 493 | - // si des plugins sont necessaires, |
|
| 494 | - // on ne peut inserer qu'apres eux |
|
| 495 | - foreach ($info1['necessite'] as $need) { |
|
| 496 | - $nom = strtoupper($need['nom']); |
|
| 497 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 498 | - if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 499 | - $info1 = false; |
|
| 500 | - break; |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - if (!$info1) { |
|
| 504 | - continue; |
|
| 505 | - } |
|
| 506 | - // idem si des plugins sont utiles, |
|
| 507 | - // sauf si ils sont de toute facon absents de la liste |
|
| 508 | - foreach ($info1['utilise'] as $need) { |
|
| 509 | - $nom = strtoupper($need['nom']); |
|
| 510 | - $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 511 | - if (isset($toute_la_liste[$nom])) { |
|
| 512 | - if ( |
|
| 513 | - !isset($liste[$nom]) or |
|
| 514 | - !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 515 | - ) { |
|
| 516 | - $info1 = false; |
|
| 517 | - break; |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - } |
|
| 521 | - if ($info1) { |
|
| 522 | - $ordre[$p] = $info1; |
|
| 523 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 524 | - unset($liste_non_classee[$p]); |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - return [$liste, $ordre, $liste_non_classee]; |
|
| 482 | + $toute_la_liste = $liste_non_classee; |
|
| 483 | + $liste = $ordre = []; |
|
| 484 | + $count = 0; |
|
| 485 | + |
|
| 486 | + while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 487 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 488 | + $count = $c; |
|
| 489 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 490 | + $plug = $resume['dir']; |
|
| 491 | + $dir_type = $resume['dir_type']; |
|
| 492 | + $info1 = $infos[$dir_type][$plug]; |
|
| 493 | + // si des plugins sont necessaires, |
|
| 494 | + // on ne peut inserer qu'apres eux |
|
| 495 | + foreach ($info1['necessite'] as $need) { |
|
| 496 | + $nom = strtoupper($need['nom']); |
|
| 497 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 498 | + if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 499 | + $info1 = false; |
|
| 500 | + break; |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + if (!$info1) { |
|
| 504 | + continue; |
|
| 505 | + } |
|
| 506 | + // idem si des plugins sont utiles, |
|
| 507 | + // sauf si ils sont de toute facon absents de la liste |
|
| 508 | + foreach ($info1['utilise'] as $need) { |
|
| 509 | + $nom = strtoupper($need['nom']); |
|
| 510 | + $compat = isset($need['compatibilite']) ? $need['compatibilite'] : ''; |
|
| 511 | + if (isset($toute_la_liste[$nom])) { |
|
| 512 | + if ( |
|
| 513 | + !isset($liste[$nom]) or |
|
| 514 | + !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 515 | + ) { |
|
| 516 | + $info1 = false; |
|
| 517 | + break; |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + } |
|
| 521 | + if ($info1) { |
|
| 522 | + $ordre[$p] = $info1; |
|
| 523 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 524 | + unset($liste_non_classee[$p]); |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return [$liste, $ordre, $liste_non_classee]; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | /** |
@@ -543,40 +543,40 @@ discard block |
||
| 543 | 543 | * Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent |
| 544 | 544 | **/ |
| 545 | 545 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) { |
| 546 | - static $erreurs = []; |
|
| 547 | - |
|
| 548 | - if (!is_array($liste)) { |
|
| 549 | - $liste = []; |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 553 | - $liste = array_diff_key($liste, $liste_non_classee); |
|
| 554 | - |
|
| 555 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 556 | - $dir_type = $resume['dir_type']; |
|
| 557 | - $plug = $resume['dir']; |
|
| 558 | - $k = $infos[$dir_type][$plug]; |
|
| 559 | - |
|
| 560 | - $plug = constant($dir_type) . $plug; |
|
| 561 | - if (!isset($msg[$p])) { |
|
| 562 | - if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 563 | - $msg[$p] = [$resume['erreur']]; |
|
| 564 | - } |
|
| 565 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | - $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 567 | - } |
|
| 568 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | - $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 570 | - } |
|
| 571 | - } else { |
|
| 572 | - foreach ($msg[$p] as $c => $l) { |
|
| 573 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 574 | - } |
|
| 575 | - } |
|
| 576 | - $erreurs[$plug] = $msg[$p]; |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 546 | + static $erreurs = []; |
|
| 547 | + |
|
| 548 | + if (!is_array($liste)) { |
|
| 549 | + $liste = []; |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 553 | + $liste = array_diff_key($liste, $liste_non_classee); |
|
| 554 | + |
|
| 555 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 556 | + $dir_type = $resume['dir_type']; |
|
| 557 | + $plug = $resume['dir']; |
|
| 558 | + $k = $infos[$dir_type][$plug]; |
|
| 559 | + |
|
| 560 | + $plug = constant($dir_type) . $plug; |
|
| 561 | + if (!isset($msg[$p])) { |
|
| 562 | + if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 563 | + $msg[$p] = [$resume['erreur']]; |
|
| 564 | + } |
|
| 565 | + elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | + $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 567 | + } |
|
| 568 | + elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | + $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 570 | + } |
|
| 571 | + } else { |
|
| 572 | + foreach ($msg[$p] as $c => $l) { |
|
| 573 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | + $erreurs[$plug] = $msg[$p]; |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -591,25 +591,25 @@ discard block |
||
| 591 | 591 | * - Liste des erreurs ou code HTML des erreurs |
| 592 | 592 | **/ |
| 593 | 593 | function plugin_donne_erreurs($raw = false, $raz = true) { |
| 594 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 595 | - return $raw ? [] : ''; |
|
| 596 | - } |
|
| 597 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 598 | - // Compat ancienne version |
|
| 599 | - if (!$list) { |
|
| 600 | - $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 601 | - } elseif (!$raw) { |
|
| 602 | - foreach ($list as $plug => $msg) { |
|
| 603 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 605 | - } |
|
| 606 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 607 | - } |
|
| 608 | - if ($raz) { |
|
| 609 | - effacer_meta('plugin_erreur_activation'); |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - return $list; |
|
| 594 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 595 | + return $raw ? [] : ''; |
|
| 596 | + } |
|
| 597 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 598 | + // Compat ancienne version |
|
| 599 | + if (!$list) { |
|
| 600 | + $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 601 | + } elseif (!$raw) { |
|
| 602 | + foreach ($list as $plug => $msg) { |
|
| 603 | + $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | + . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 605 | + } |
|
| 606 | + $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 607 | + } |
|
| 608 | + if ($raz) { |
|
| 609 | + effacer_meta('plugin_erreur_activation'); |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + return $list; |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -629,21 +629,21 @@ discard block |
||
| 629 | 629 | * |
| 630 | 630 | **/ |
| 631 | 631 | function plugin_necessite($n, $liste, $balise = 'necessite') { |
| 632 | - $msg = []; |
|
| 633 | - foreach ($n as $need) { |
|
| 634 | - $id = strtoupper($need['nom']); |
|
| 635 | - $r = plugin_controler_necessite( |
|
| 636 | - $liste, |
|
| 637 | - $id, |
|
| 638 | - isset($need['compatibilite']) ? $need['compatibilite'] : '', |
|
| 639 | - $balise |
|
| 640 | - ); |
|
| 641 | - if ($r) { |
|
| 642 | - $msg[] = $r; |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - return $msg; |
|
| 632 | + $msg = []; |
|
| 633 | + foreach ($n as $need) { |
|
| 634 | + $id = strtoupper($need['nom']); |
|
| 635 | + $r = plugin_controler_necessite( |
|
| 636 | + $liste, |
|
| 637 | + $id, |
|
| 638 | + isset($need['compatibilite']) ? $need['compatibilite'] : '', |
|
| 639 | + $balise |
|
| 640 | + ); |
|
| 641 | + if ($r) { |
|
| 642 | + $msg[] = $r; |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + return $msg; |
|
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | /** |
@@ -665,19 +665,19 @@ discard block |
||
| 665 | 665 | * Message d'erreur lorsque la dépendance est absente. |
| 666 | 666 | **/ |
| 667 | 667 | function plugin_controler_necessite($liste, $nom, $intervalle, $balise) { |
| 668 | - if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 669 | - return ''; |
|
| 670 | - } |
|
| 671 | - // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 672 | - if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 673 | - return ''; |
|
| 674 | - } |
|
| 675 | - return plugin_message_incompatibilite( |
|
| 676 | - $intervalle, |
|
| 677 | - (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 678 | - $nom, |
|
| 679 | - $balise |
|
| 680 | - ); |
|
| 668 | + if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 669 | + return ''; |
|
| 670 | + } |
|
| 671 | + // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 672 | + if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 673 | + return ''; |
|
| 674 | + } |
|
| 675 | + return plugin_message_incompatibilite( |
|
| 676 | + $intervalle, |
|
| 677 | + (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 678 | + $nom, |
|
| 679 | + $balise |
|
| 680 | + ); |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -694,70 +694,70 @@ discard block |
||
| 694 | 694 | */ |
| 695 | 695 | function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) { |
| 696 | 696 | |
| 697 | - // prendre en compte les erreurs de dépendances à PHP |
|
| 698 | - // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 699 | - $type = 'plugin'; |
|
| 700 | - if ($nom === 'SPIP') { |
|
| 701 | - $type = 'spip'; |
|
| 702 | - } elseif ($nom === 'PHP') { |
|
| 703 | - $type = 'php'; |
|
| 704 | - } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 705 | - $type = 'extension_php'; |
|
| 706 | - list(,$nom) = explode(':', $nom, 2); |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 710 | - $minimum = $regs[1]; |
|
| 711 | - $maximum = $regs[2]; |
|
| 712 | - |
|
| 713 | - $minimum_inclus = $intervalle[0] == '['; |
|
| 714 | - $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 715 | - |
|
| 716 | - if (strlen($minimum)) { |
|
| 717 | - if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 718 | - return _T("plugin_${balise}_${type}", [ |
|
| 719 | - 'plugin' => $nom, |
|
| 720 | - 'version' => ' ≥ ' . $minimum |
|
| 721 | - ]); |
|
| 722 | - } |
|
| 723 | - if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 724 | - return _T("plugin_${balise}_${type}", [ |
|
| 725 | - 'plugin' => $nom, |
|
| 726 | - 'version' => ' > ' . $minimum |
|
| 727 | - ]); |
|
| 728 | - } |
|
| 729 | - } |
|
| 730 | - |
|
| 731 | - if (strlen($maximum)) { |
|
| 732 | - if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 733 | - return _T("plugin_${balise}_${type}", [ |
|
| 734 | - 'plugin' => $nom, |
|
| 735 | - 'version' => ' ≤ ' . $maximum |
|
| 736 | - ]); |
|
| 737 | - } |
|
| 738 | - if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 739 | - return _T("plugin_${balise}_plugin", [ |
|
| 740 | - 'plugin' => $nom, |
|
| 741 | - 'version' => ' < ' . $maximum |
|
| 742 | - ]); |
|
| 743 | - } |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - // note : il ne peut pas y avoir d'erreur sur |
|
| 748 | - // - un 'utilise' sans version. |
|
| 749 | - // - un 'php' sans version. |
|
| 750 | - return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]); |
|
| 697 | + // prendre en compte les erreurs de dépendances à PHP |
|
| 698 | + // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 699 | + $type = 'plugin'; |
|
| 700 | + if ($nom === 'SPIP') { |
|
| 701 | + $type = 'spip'; |
|
| 702 | + } elseif ($nom === 'PHP') { |
|
| 703 | + $type = 'php'; |
|
| 704 | + } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 705 | + $type = 'extension_php'; |
|
| 706 | + list(,$nom) = explode(':', $nom, 2); |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 710 | + $minimum = $regs[1]; |
|
| 711 | + $maximum = $regs[2]; |
|
| 712 | + |
|
| 713 | + $minimum_inclus = $intervalle[0] == '['; |
|
| 714 | + $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 715 | + |
|
| 716 | + if (strlen($minimum)) { |
|
| 717 | + if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 718 | + return _T("plugin_${balise}_${type}", [ |
|
| 719 | + 'plugin' => $nom, |
|
| 720 | + 'version' => ' ≥ ' . $minimum |
|
| 721 | + ]); |
|
| 722 | + } |
|
| 723 | + if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 724 | + return _T("plugin_${balise}_${type}", [ |
|
| 725 | + 'plugin' => $nom, |
|
| 726 | + 'version' => ' > ' . $minimum |
|
| 727 | + ]); |
|
| 728 | + } |
|
| 729 | + } |
|
| 730 | + |
|
| 731 | + if (strlen($maximum)) { |
|
| 732 | + if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 733 | + return _T("plugin_${balise}_${type}", [ |
|
| 734 | + 'plugin' => $nom, |
|
| 735 | + 'version' => ' ≤ ' . $maximum |
|
| 736 | + ]); |
|
| 737 | + } |
|
| 738 | + if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 739 | + return _T("plugin_${balise}_plugin", [ |
|
| 740 | + 'plugin' => $nom, |
|
| 741 | + 'version' => ' < ' . $maximum |
|
| 742 | + ]); |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + // note : il ne peut pas y avoir d'erreur sur |
|
| 748 | + // - un 'utilise' sans version. |
|
| 749 | + // - un 'php' sans version. |
|
| 750 | + return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]); |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | |
| 754 | 754 | function plugin_controler_lib($lib, $url) { |
| 755 | - /* Feature sortie du core, voir STP |
|
| 755 | + /* Feature sortie du core, voir STP |
|
| 756 | 756 | * if ($url) { |
| 757 | 757 | include_spip('inc/charger_plugin'); |
| 758 | 758 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 759 | 759 | }*/ |
| 760 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 760 | + return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | * true si il y a eu des modifications sur la liste des plugins actifs, false sinon |
| 773 | 773 | **/ |
| 774 | 774 | function actualise_plugins_actifs($pipe_recherche = false) { |
| 775 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 775 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | |
@@ -799,116 +799,116 @@ discard block |
||
| 799 | 799 | **/ |
| 800 | 800 | function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') { |
| 801 | 801 | |
| 802 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 803 | - $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 804 | - |
|
| 805 | - // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 806 | - if (!$cache and !spip_connect()) { |
|
| 807 | - return false; |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - if ($operation != 'raz') { |
|
| 811 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 812 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 813 | - if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 814 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 815 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 816 | - $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 817 | - } |
|
| 818 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 819 | - // on les reinjecte ici |
|
| 820 | - if ( |
|
| 821 | - isset($GLOBALS['meta']['plugin_attente']) |
|
| 822 | - and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 823 | - ) { |
|
| 824 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 825 | - } |
|
| 826 | - |
|
| 827 | - if ($operation == 'ajoute') { |
|
| 828 | - $plugin = array_merge($plugin_valides, $plugin); |
|
| 829 | - } elseif ($operation == 'enleve') { |
|
| 830 | - $plugin = array_diff($plugin_valides, $plugin); |
|
| 831 | - } else { |
|
| 832 | - $plugin = $plugin_valides; |
|
| 833 | - } |
|
| 834 | - } |
|
| 835 | - $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : ''; |
|
| 836 | - |
|
| 837 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 838 | - if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 839 | - $plugin = $ajouter_dependances($plugin); |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - // recharger le xml des plugins a activer |
|
| 843 | - // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 844 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 845 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 846 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 847 | - list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true); |
|
| 848 | - // trouver l'ordre d'activation |
|
| 849 | - list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste); |
|
| 850 | - if ($invalides or $reste) { |
|
| 851 | - plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 852 | - } |
|
| 853 | - |
|
| 854 | - // Ignorer les plugins necessitant une lib absente |
|
| 855 | - // et preparer la meta d'entete Http |
|
| 856 | - $err = $msg = $header = []; |
|
| 857 | - foreach ($plugin_valides as $p => $resume) { |
|
| 858 | - // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 859 | - if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 860 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 861 | - } |
|
| 862 | - if ($resume['dir']) { |
|
| 863 | - foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 864 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 865 | - $err[$p] = $resume; |
|
| 866 | - $msg[$p][] = $l; |
|
| 867 | - unset($plugin_valides[$p]); |
|
| 868 | - } |
|
| 869 | - } |
|
| 870 | - } |
|
| 871 | - } |
|
| 872 | - if ($err) { |
|
| 873 | - plugins_erreurs($err, '', $infos, $msg); |
|
| 874 | - } |
|
| 875 | - |
|
| 876 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 877 | - effacer_meta('message_crash_plugins'); |
|
| 878 | - } |
|
| 879 | - ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 880 | - $liste = array_diff_key($liste, $plugin_valides); |
|
| 881 | - ecrire_meta('plugin_attente', serialize($liste)); |
|
| 882 | - $header = strtolower(implode(',', $header)); |
|
| 883 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 884 | - ecrire_fichier( |
|
| 885 | - _DIR_VAR . 'config.txt', |
|
| 886 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 887 | - ); |
|
| 888 | - } else { |
|
| 889 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 890 | - } |
|
| 891 | - // generer charger_plugins_chemin.php |
|
| 892 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 893 | - // generer les fichiers |
|
| 894 | - // - charger_plugins_options.php |
|
| 895 | - // - charger_plugins_fonctions.php |
|
| 896 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 897 | - // charger les chemins des plugins et les fichiers d'options |
|
| 898 | - // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 899 | - plugins_amorcer_plugins_actifs(); |
|
| 900 | - // mise a jour de la matrice des pipelines |
|
| 901 | - $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 902 | - // generer le fichier _CACHE_PIPELINE |
|
| 903 | - pipeline_precompile($prepend_code); |
|
| 904 | - |
|
| 905 | - if (spip_connect()) { |
|
| 906 | - // lancer et initialiser les nouveaux crons ! |
|
| 907 | - include_spip('inc/genie'); |
|
| 908 | - genie_queue_watch_dist(); |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 802 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 803 | + $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 804 | + |
|
| 805 | + // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 806 | + if (!$cache and !spip_connect()) { |
|
| 807 | + return false; |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + if ($operation != 'raz') { |
|
| 811 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 812 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 813 | + if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 814 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 815 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 816 | + $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 817 | + } |
|
| 818 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 819 | + // on les reinjecte ici |
|
| 820 | + if ( |
|
| 821 | + isset($GLOBALS['meta']['plugin_attente']) |
|
| 822 | + and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 823 | + ) { |
|
| 824 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 825 | + } |
|
| 826 | + |
|
| 827 | + if ($operation == 'ajoute') { |
|
| 828 | + $plugin = array_merge($plugin_valides, $plugin); |
|
| 829 | + } elseif ($operation == 'enleve') { |
|
| 830 | + $plugin = array_diff($plugin_valides, $plugin); |
|
| 831 | + } else { |
|
| 832 | + $plugin = $plugin_valides; |
|
| 833 | + } |
|
| 834 | + } |
|
| 835 | + $actifs_avant = isset($GLOBALS['meta']['plugin']) ? $GLOBALS['meta']['plugin'] : ''; |
|
| 836 | + |
|
| 837 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 838 | + if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 839 | + $plugin = $ajouter_dependances($plugin); |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + // recharger le xml des plugins a activer |
|
| 843 | + // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 844 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 845 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 846 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 847 | + list($infos, $liste, $invalides) = liste_plugin_valides($plugin, true); |
|
| 848 | + // trouver l'ordre d'activation |
|
| 849 | + list($plugin_valides, $ordre, $reste) = plugin_trier($infos, $liste); |
|
| 850 | + if ($invalides or $reste) { |
|
| 851 | + plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 852 | + } |
|
| 853 | + |
|
| 854 | + // Ignorer les plugins necessitant une lib absente |
|
| 855 | + // et preparer la meta d'entete Http |
|
| 856 | + $err = $msg = $header = []; |
|
| 857 | + foreach ($plugin_valides as $p => $resume) { |
|
| 858 | + // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 859 | + if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 860 | + $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 861 | + } |
|
| 862 | + if ($resume['dir']) { |
|
| 863 | + foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 864 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 865 | + $err[$p] = $resume; |
|
| 866 | + $msg[$p][] = $l; |
|
| 867 | + unset($plugin_valides[$p]); |
|
| 868 | + } |
|
| 869 | + } |
|
| 870 | + } |
|
| 871 | + } |
|
| 872 | + if ($err) { |
|
| 873 | + plugins_erreurs($err, '', $infos, $msg); |
|
| 874 | + } |
|
| 875 | + |
|
| 876 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 877 | + effacer_meta('message_crash_plugins'); |
|
| 878 | + } |
|
| 879 | + ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 880 | + $liste = array_diff_key($liste, $plugin_valides); |
|
| 881 | + ecrire_meta('plugin_attente', serialize($liste)); |
|
| 882 | + $header = strtolower(implode(',', $header)); |
|
| 883 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 884 | + ecrire_fichier( |
|
| 885 | + _DIR_VAR . 'config.txt', |
|
| 886 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 887 | + ); |
|
| 888 | + } else { |
|
| 889 | + @unlink(_DIR_VAR . 'config.txt'); |
|
| 890 | + } |
|
| 891 | + // generer charger_plugins_chemin.php |
|
| 892 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 893 | + // generer les fichiers |
|
| 894 | + // - charger_plugins_options.php |
|
| 895 | + // - charger_plugins_fonctions.php |
|
| 896 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 897 | + // charger les chemins des plugins et les fichiers d'options |
|
| 898 | + // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 899 | + plugins_amorcer_plugins_actifs(); |
|
| 900 | + // mise a jour de la matrice des pipelines |
|
| 901 | + $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 902 | + // generer le fichier _CACHE_PIPELINE |
|
| 903 | + pipeline_precompile($prepend_code); |
|
| 904 | + |
|
| 905 | + if (spip_connect()) { |
|
| 906 | + // lancer et initialiser les nouveaux crons ! |
|
| 907 | + include_spip('inc/genie'); |
|
| 908 | + genie_queue_watch_dist(); |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | /** |
@@ -927,74 +927,74 @@ discard block |
||
| 927 | 927 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 928 | 928 | **/ |
| 929 | 929 | function plugins_precompile_chemin($plugin_valides, $ordre) { |
| 930 | - $chemins = [ |
|
| 931 | - 'public' => [], |
|
| 932 | - 'prive' => [] |
|
| 933 | - ]; |
|
| 934 | - $contenu = ''; |
|
| 935 | - foreach ($ordre as $p => $info) { |
|
| 936 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 937 | - if (isset($plugin_valides[$p])) { |
|
| 938 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 939 | - $plug = $plugin_valides[$p]['dir']; |
|
| 940 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 941 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 942 | - |
|
| 943 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 944 | - |
|
| 945 | - $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 946 | - if ( |
|
| 947 | - $prefix !== 'SPIP' |
|
| 948 | - and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 949 | - ) { |
|
| 950 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 951 | - if (!$info['chemin']) { |
|
| 952 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 953 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 954 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 955 | - $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 956 | - } |
|
| 957 | - } |
|
| 958 | - else { |
|
| 959 | - foreach ($info['chemin'] as $chemin) { |
|
| 960 | - if ( |
|
| 961 | - !isset($chemin['version']) or plugin_version_compatible( |
|
| 962 | - $chemin['version'], |
|
| 963 | - $GLOBALS['spip_version_branche'], |
|
| 964 | - 'spip' |
|
| 965 | - ) |
|
| 966 | - ) { |
|
| 967 | - $dir = $chemin['path']; |
|
| 968 | - if (strlen($dir) and $dir[0] == '/') { |
|
| 969 | - $dir = substr($dir, 1); |
|
| 970 | - } |
|
| 971 | - if (strlen($dir) and $dir == './') { |
|
| 972 | - $dir = ''; |
|
| 973 | - } |
|
| 974 | - if (strlen($dir)) { |
|
| 975 | - $dir = rtrim($dir, '/') . '/'; |
|
| 976 | - } |
|
| 977 | - if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 978 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 979 | - } |
|
| 980 | - if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 981 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 982 | - } |
|
| 983 | - } |
|
| 984 | - } |
|
| 985 | - } |
|
| 986 | - } |
|
| 987 | - } |
|
| 988 | - } |
|
| 989 | - if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 990 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 991 | - ',', |
|
| 992 | - array_reverse($chemins['public']) |
|
| 993 | - ) . "]);\n" |
|
| 994 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 995 | - } |
|
| 996 | - |
|
| 997 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 930 | + $chemins = [ |
|
| 931 | + 'public' => [], |
|
| 932 | + 'prive' => [] |
|
| 933 | + ]; |
|
| 934 | + $contenu = ''; |
|
| 935 | + foreach ($ordre as $p => $info) { |
|
| 936 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 937 | + if (isset($plugin_valides[$p])) { |
|
| 938 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 939 | + $plug = $plugin_valides[$p]['dir']; |
|
| 940 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 941 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 942 | + |
|
| 943 | + $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 944 | + |
|
| 945 | + $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 946 | + if ( |
|
| 947 | + $prefix !== 'SPIP' |
|
| 948 | + and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 949 | + ) { |
|
| 950 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 951 | + if (!$info['chemin']) { |
|
| 952 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 953 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 954 | + if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 955 | + $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 956 | + } |
|
| 957 | + } |
|
| 958 | + else { |
|
| 959 | + foreach ($info['chemin'] as $chemin) { |
|
| 960 | + if ( |
|
| 961 | + !isset($chemin['version']) or plugin_version_compatible( |
|
| 962 | + $chemin['version'], |
|
| 963 | + $GLOBALS['spip_version_branche'], |
|
| 964 | + 'spip' |
|
| 965 | + ) |
|
| 966 | + ) { |
|
| 967 | + $dir = $chemin['path']; |
|
| 968 | + if (strlen($dir) and $dir[0] == '/') { |
|
| 969 | + $dir = substr($dir, 1); |
|
| 970 | + } |
|
| 971 | + if (strlen($dir) and $dir == './') { |
|
| 972 | + $dir = ''; |
|
| 973 | + } |
|
| 974 | + if (strlen($dir)) { |
|
| 975 | + $dir = rtrim($dir, '/') . '/'; |
|
| 976 | + } |
|
| 977 | + if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 978 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 979 | + } |
|
| 980 | + if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 981 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 982 | + } |
|
| 983 | + } |
|
| 984 | + } |
|
| 985 | + } |
|
| 986 | + } |
|
| 987 | + } |
|
| 988 | + } |
|
| 989 | + if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 990 | + $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 991 | + ',', |
|
| 992 | + array_reverse($chemins['public']) |
|
| 993 | + ) . "]);\n" |
|
| 994 | + . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 995 | + } |
|
| 996 | + |
|
| 997 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | /** |
@@ -1012,67 +1012,67 @@ discard block |
||
| 1012 | 1012 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 1013 | 1013 | **/ |
| 1014 | 1014 | function plugins_precompile_xxxtions($plugin_valides, $ordre) { |
| 1015 | - $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1016 | - $boutons = []; |
|
| 1017 | - $onglets = []; |
|
| 1018 | - $sign = ''; |
|
| 1019 | - |
|
| 1020 | - foreach ($ordre as $p => $info) { |
|
| 1021 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1022 | - if (isset($plugin_valides[$p])) { |
|
| 1023 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1024 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1025 | - $dir = constant($dir_type); |
|
| 1026 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1027 | - if ($info['menu']) { |
|
| 1028 | - $boutons = array_merge($boutons, $info['menu']); |
|
| 1029 | - } |
|
| 1030 | - if ($info['onglet']) { |
|
| 1031 | - $onglets = array_merge($onglets, $info['onglet']); |
|
| 1032 | - } |
|
| 1033 | - foreach ($contenu as $charge => $v) { |
|
| 1034 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1035 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1036 | - // donc ni sa relecture, ni sa detection |
|
| 1037 | - if ( |
|
| 1038 | - !isset($info[$charge]) |
|
| 1039 | - and $dir // exclure le cas du plugin "SPIP" |
|
| 1040 | - and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 1041 | - and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1042 | - ) { |
|
| 1043 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1044 | - $info[$charge] = [$file]; |
|
| 1045 | - } |
|
| 1046 | - } |
|
| 1047 | - if (isset($info[$charge])) { |
|
| 1048 | - $files = $info[$charge]; |
|
| 1049 | - foreach ($files as $k => $file) { |
|
| 1050 | - // on genere un if file_exists devant chaque include |
|
| 1051 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 1052 | - $file = trim($file); |
|
| 1053 | - if ( |
|
| 1054 | - !is_readable("$dir$plug/$file") |
|
| 1055 | - // uniquement pour les paquet.xml |
|
| 1056 | - and file_exists("$dir$plug/paquet.xml") |
|
| 1057 | - ) { |
|
| 1058 | - unset($info[$charge][$k]); |
|
| 1059 | - } else { |
|
| 1060 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1061 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1062 | - } |
|
| 1063 | - } |
|
| 1064 | - } |
|
| 1065 | - } |
|
| 1066 | - $sign .= md5(serialize($info)); |
|
| 1067 | - } |
|
| 1068 | - } |
|
| 1069 | - |
|
| 1070 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1071 | - $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1072 | - . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1073 | - |
|
| 1074 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1075 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1015 | + $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1016 | + $boutons = []; |
|
| 1017 | + $onglets = []; |
|
| 1018 | + $sign = ''; |
|
| 1019 | + |
|
| 1020 | + foreach ($ordre as $p => $info) { |
|
| 1021 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1022 | + if (isset($plugin_valides[$p])) { |
|
| 1023 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1024 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1025 | + $dir = constant($dir_type); |
|
| 1026 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1027 | + if ($info['menu']) { |
|
| 1028 | + $boutons = array_merge($boutons, $info['menu']); |
|
| 1029 | + } |
|
| 1030 | + if ($info['onglet']) { |
|
| 1031 | + $onglets = array_merge($onglets, $info['onglet']); |
|
| 1032 | + } |
|
| 1033 | + foreach ($contenu as $charge => $v) { |
|
| 1034 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1035 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1036 | + // donc ni sa relecture, ni sa detection |
|
| 1037 | + if ( |
|
| 1038 | + !isset($info[$charge]) |
|
| 1039 | + and $dir // exclure le cas du plugin "SPIP" |
|
| 1040 | + and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 1041 | + and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1042 | + ) { |
|
| 1043 | + if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1044 | + $info[$charge] = [$file]; |
|
| 1045 | + } |
|
| 1046 | + } |
|
| 1047 | + if (isset($info[$charge])) { |
|
| 1048 | + $files = $info[$charge]; |
|
| 1049 | + foreach ($files as $k => $file) { |
|
| 1050 | + // on genere un if file_exists devant chaque include |
|
| 1051 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 1052 | + $file = trim($file); |
|
| 1053 | + if ( |
|
| 1054 | + !is_readable("$dir$plug/$file") |
|
| 1055 | + // uniquement pour les paquet.xml |
|
| 1056 | + and file_exists("$dir$plug/paquet.xml") |
|
| 1057 | + ) { |
|
| 1058 | + unset($info[$charge][$k]); |
|
| 1059 | + } else { |
|
| 1060 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1061 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1062 | + } |
|
| 1063 | + } |
|
| 1064 | + } |
|
| 1065 | + } |
|
| 1066 | + $sign .= md5(serialize($info)); |
|
| 1067 | + } |
|
| 1068 | + } |
|
| 1069 | + |
|
| 1070 | + $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1071 | + $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1072 | + . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1073 | + |
|
| 1074 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1075 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1076 | 1076 | } |
| 1077 | 1077 | |
| 1078 | 1078 | /** |
@@ -1091,24 +1091,24 @@ discard block |
||
| 1091 | 1091 | * @return string Code php |
| 1092 | 1092 | */ |
| 1093 | 1093 | function plugin_ongletbouton($nom, $val) { |
| 1094 | - if (!$val) { |
|
| 1095 | - $val = []; |
|
| 1096 | - } |
|
| 1097 | - |
|
| 1098 | - $val = serialize($val); |
|
| 1099 | - $md5 = md5($val); |
|
| 1100 | - |
|
| 1101 | - if (!defined("_UPDATED_$nom")) { |
|
| 1102 | - define("_UPDATED_$nom", $val); |
|
| 1103 | - define("_UPDATED_md5_$nom", $md5); |
|
| 1104 | - } |
|
| 1105 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1106 | - |
|
| 1107 | - return |
|
| 1108 | - "if (!function_exists('$nom')) {\n" |
|
| 1109 | - . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1110 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1111 | - . "}\n"; |
|
| 1094 | + if (!$val) { |
|
| 1095 | + $val = []; |
|
| 1096 | + } |
|
| 1097 | + |
|
| 1098 | + $val = serialize($val); |
|
| 1099 | + $md5 = md5($val); |
|
| 1100 | + |
|
| 1101 | + if (!defined("_UPDATED_$nom")) { |
|
| 1102 | + define("_UPDATED_$nom", $val); |
|
| 1103 | + define("_UPDATED_md5_$nom", $md5); |
|
| 1104 | + } |
|
| 1105 | + $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1106 | + |
|
| 1107 | + return |
|
| 1108 | + "if (!function_exists('$nom')) {\n" |
|
| 1109 | + . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1110 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1111 | + . "}\n"; |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
@@ -1123,15 +1123,15 @@ discard block |
||
| 1123 | 1123 | **/ |
| 1124 | 1124 | function plugins_amorcer_plugins_actifs() { |
| 1125 | 1125 | |
| 1126 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1127 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1128 | - } |
|
| 1126 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1127 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1128 | + } |
|
| 1129 | 1129 | |
| 1130 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1131 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 1132 | - } else { |
|
| 1133 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1134 | - } |
|
| 1130 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1131 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 1132 | + } else { |
|
| 1133 | + spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1134 | + } |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | /** |
@@ -1154,140 +1154,140 @@ discard block |
||
| 1154 | 1154 | * Couples (nom du pipeline => Code PHP à insérer au début du pipeline) |
| 1155 | 1155 | **/ |
| 1156 | 1156 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) { |
| 1157 | - static $liste_pipe_manquants = []; |
|
| 1158 | - if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1159 | - $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1160 | - } |
|
| 1161 | - |
|
| 1162 | - $prepend_code = []; |
|
| 1163 | - |
|
| 1164 | - foreach ($ordre as $p => $info) { |
|
| 1165 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1166 | - if (isset($plugin_valides[$p])) { |
|
| 1167 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1168 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1169 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1170 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1171 | - if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1172 | - foreach ($info['pipeline'] as $pipe) { |
|
| 1173 | - $nom = $pipe['nom']; |
|
| 1174 | - if (isset($pipe['action'])) { |
|
| 1175 | - $action = $pipe['action']; |
|
| 1176 | - } else { |
|
| 1177 | - $action = $nom; |
|
| 1178 | - } |
|
| 1179 | - $nomlower = strtolower($nom); |
|
| 1180 | - if ( |
|
| 1181 | - $nomlower != $nom |
|
| 1182 | - and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1183 | - and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1184 | - ) { |
|
| 1185 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1186 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1187 | - } |
|
| 1188 | - $nom = $nomlower; |
|
| 1189 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1190 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1191 | - $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1192 | - } |
|
| 1193 | - if ($action) { |
|
| 1194 | - if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
|
| 1195 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1196 | - ',(\|\||$),', |
|
| 1197 | - "|$prefix$action\\1", |
|
| 1198 | - $GLOBALS['spip_pipeline'][$nom], |
|
| 1199 | - 1 |
|
| 1200 | - ); |
|
| 1201 | - } |
|
| 1202 | - if (isset($pipe['inclure'])) { |
|
| 1203 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1204 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1205 | - } |
|
| 1206 | - } |
|
| 1207 | - } |
|
| 1208 | - } |
|
| 1209 | - if (isset($info['genie']) and count($info['genie'])) { |
|
| 1210 | - if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1211 | - $prepend_code['taches_generales_cron'] = ''; |
|
| 1212 | - } |
|
| 1213 | - foreach ($info['genie'] as $genie) { |
|
| 1214 | - $nom = $prefix . $genie['nom']; |
|
| 1215 | - $periode = max(60, intval($genie['periode'])); |
|
| 1216 | - if (charger_fonction($nom, 'genie', true)) { |
|
| 1217 | - $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1218 | - } else { |
|
| 1219 | - spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1220 | - } |
|
| 1221 | - } |
|
| 1222 | - } |
|
| 1223 | - if (isset($info['style']) and count($info['style'])) { |
|
| 1224 | - if (!isset($prepend_code['insert_head_css'])) { |
|
| 1225 | - $prepend_code['insert_head_css'] = ''; |
|
| 1226 | - } |
|
| 1227 | - if (!isset($prepend_code['header_prive_css'])) { |
|
| 1228 | - $prepend_code['header_prive_css'] = ''; |
|
| 1229 | - } |
|
| 1230 | - foreach ($info['style'] as $style) { |
|
| 1231 | - if (isset($style['path']) and $style['path']) { |
|
| 1232 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1233 | - } else { |
|
| 1234 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1235 | - } |
|
| 1236 | - $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1237 | - if (isset($style['media']) and strlen($style['media'])) { |
|
| 1238 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1239 | - } |
|
| 1240 | - $code .= "/>';\n"; |
|
| 1241 | - if ($style['type'] != 'prive') { |
|
| 1242 | - $prepend_code['insert_head_css'] .= $code; |
|
| 1243 | - } |
|
| 1244 | - if ($style['type'] != 'public') { |
|
| 1245 | - $prepend_code['header_prive_css'] .= $code; |
|
| 1246 | - } |
|
| 1247 | - } |
|
| 1248 | - } |
|
| 1249 | - if (!isset($prepend_code['insert_head'])) { |
|
| 1250 | - $prepend_code['insert_head'] = ''; |
|
| 1251 | - } |
|
| 1252 | - if (!isset($prepend_code['header_prive'])) { |
|
| 1253 | - $prepend_code['header_prive'] = ''; |
|
| 1254 | - } |
|
| 1255 | - if (isset($info['script']) and count($info['script'])) { |
|
| 1256 | - foreach ($info['script'] as $script) { |
|
| 1257 | - if (isset($script['path']) and $script['path']) { |
|
| 1258 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1259 | - } else { |
|
| 1260 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1261 | - } |
|
| 1262 | - $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1263 | - if ($script['type'] != 'prive') { |
|
| 1264 | - $prepend_code['insert_head'] .= $code; |
|
| 1265 | - } |
|
| 1266 | - if ($script['type'] != 'public') { |
|
| 1267 | - $prepend_code['header_prive'] .= $code; |
|
| 1268 | - } |
|
| 1269 | - } |
|
| 1270 | - } |
|
| 1271 | - } |
|
| 1272 | - } |
|
| 1273 | - |
|
| 1274 | - $prepend_code['insert_head'] = |
|
| 1275 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1276 | - . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1277 | - . $prepend_code['insert_head']; |
|
| 1278 | - $prepend_code['header_prive'] = |
|
| 1279 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1280 | - . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1281 | - . $prepend_code['header_prive']; |
|
| 1282 | - |
|
| 1283 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 1284 | - foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1285 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1286 | - $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1287 | - } |
|
| 1288 | - } |
|
| 1289 | - |
|
| 1290 | - return $prepend_code; |
|
| 1157 | + static $liste_pipe_manquants = []; |
|
| 1158 | + if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1159 | + $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1160 | + } |
|
| 1161 | + |
|
| 1162 | + $prepend_code = []; |
|
| 1163 | + |
|
| 1164 | + foreach ($ordre as $p => $info) { |
|
| 1165 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1166 | + if (isset($plugin_valides[$p])) { |
|
| 1167 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1168 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1169 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1170 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1171 | + if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1172 | + foreach ($info['pipeline'] as $pipe) { |
|
| 1173 | + $nom = $pipe['nom']; |
|
| 1174 | + if (isset($pipe['action'])) { |
|
| 1175 | + $action = $pipe['action']; |
|
| 1176 | + } else { |
|
| 1177 | + $action = $nom; |
|
| 1178 | + } |
|
| 1179 | + $nomlower = strtolower($nom); |
|
| 1180 | + if ( |
|
| 1181 | + $nomlower != $nom |
|
| 1182 | + and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1183 | + and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1184 | + ) { |
|
| 1185 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1186 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1187 | + } |
|
| 1188 | + $nom = $nomlower; |
|
| 1189 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1190 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1191 | + $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1192 | + } |
|
| 1193 | + if ($action) { |
|
| 1194 | + if (strpos($GLOBALS['spip_pipeline'][$nom], "|$prefix$action") === false) { |
|
| 1195 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1196 | + ',(\|\||$),', |
|
| 1197 | + "|$prefix$action\\1", |
|
| 1198 | + $GLOBALS['spip_pipeline'][$nom], |
|
| 1199 | + 1 |
|
| 1200 | + ); |
|
| 1201 | + } |
|
| 1202 | + if (isset($pipe['inclure'])) { |
|
| 1203 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1204 | + "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1205 | + } |
|
| 1206 | + } |
|
| 1207 | + } |
|
| 1208 | + } |
|
| 1209 | + if (isset($info['genie']) and count($info['genie'])) { |
|
| 1210 | + if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1211 | + $prepend_code['taches_generales_cron'] = ''; |
|
| 1212 | + } |
|
| 1213 | + foreach ($info['genie'] as $genie) { |
|
| 1214 | + $nom = $prefix . $genie['nom']; |
|
| 1215 | + $periode = max(60, intval($genie['periode'])); |
|
| 1216 | + if (charger_fonction($nom, 'genie', true)) { |
|
| 1217 | + $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1218 | + } else { |
|
| 1219 | + spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1220 | + } |
|
| 1221 | + } |
|
| 1222 | + } |
|
| 1223 | + if (isset($info['style']) and count($info['style'])) { |
|
| 1224 | + if (!isset($prepend_code['insert_head_css'])) { |
|
| 1225 | + $prepend_code['insert_head_css'] = ''; |
|
| 1226 | + } |
|
| 1227 | + if (!isset($prepend_code['header_prive_css'])) { |
|
| 1228 | + $prepend_code['header_prive_css'] = ''; |
|
| 1229 | + } |
|
| 1230 | + foreach ($info['style'] as $style) { |
|
| 1231 | + if (isset($style['path']) and $style['path']) { |
|
| 1232 | + $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1233 | + } else { |
|
| 1234 | + $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1235 | + } |
|
| 1236 | + $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1237 | + if (isset($style['media']) and strlen($style['media'])) { |
|
| 1238 | + $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1239 | + } |
|
| 1240 | + $code .= "/>';\n"; |
|
| 1241 | + if ($style['type'] != 'prive') { |
|
| 1242 | + $prepend_code['insert_head_css'] .= $code; |
|
| 1243 | + } |
|
| 1244 | + if ($style['type'] != 'public') { |
|
| 1245 | + $prepend_code['header_prive_css'] .= $code; |
|
| 1246 | + } |
|
| 1247 | + } |
|
| 1248 | + } |
|
| 1249 | + if (!isset($prepend_code['insert_head'])) { |
|
| 1250 | + $prepend_code['insert_head'] = ''; |
|
| 1251 | + } |
|
| 1252 | + if (!isset($prepend_code['header_prive'])) { |
|
| 1253 | + $prepend_code['header_prive'] = ''; |
|
| 1254 | + } |
|
| 1255 | + if (isset($info['script']) and count($info['script'])) { |
|
| 1256 | + foreach ($info['script'] as $script) { |
|
| 1257 | + if (isset($script['path']) and $script['path']) { |
|
| 1258 | + $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1259 | + } else { |
|
| 1260 | + $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1261 | + } |
|
| 1262 | + $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1263 | + if ($script['type'] != 'prive') { |
|
| 1264 | + $prepend_code['insert_head'] .= $code; |
|
| 1265 | + } |
|
| 1266 | + if ($script['type'] != 'public') { |
|
| 1267 | + $prepend_code['header_prive'] .= $code; |
|
| 1268 | + } |
|
| 1269 | + } |
|
| 1270 | + } |
|
| 1271 | + } |
|
| 1272 | + } |
|
| 1273 | + |
|
| 1274 | + $prepend_code['insert_head'] = |
|
| 1275 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1276 | + . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1277 | + . $prepend_code['insert_head']; |
|
| 1278 | + $prepend_code['header_prive'] = |
|
| 1279 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1280 | + . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1281 | + . $prepend_code['header_prive']; |
|
| 1282 | + |
|
| 1283 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 1284 | + foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1285 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1286 | + $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1287 | + } |
|
| 1288 | + } |
|
| 1289 | + |
|
| 1290 | + return $prepend_code; |
|
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | 1293 | /** |
@@ -1314,62 +1314,62 @@ discard block |
||
| 1314 | 1314 | **/ |
| 1315 | 1315 | function pipeline_precompile($prepend_code = []) { |
| 1316 | 1316 | |
| 1317 | - $all_pipes = $all_pipes_end = ''; |
|
| 1318 | - if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1319 | - $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1320 | - unset($GLOBALS['spip_pipeline']['all']); |
|
| 1321 | - $all_pipes = trim(array_shift($a)); |
|
| 1322 | - if ($all_pipes) { |
|
| 1323 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1324 | - } |
|
| 1325 | - if (count($a)) { |
|
| 1326 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1327 | - } |
|
| 1328 | - } |
|
| 1329 | - $content = ''; |
|
| 1330 | - foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1331 | - $s_inc = ''; |
|
| 1332 | - $s_call = ''; |
|
| 1333 | - if ($all_pipes) { |
|
| 1334 | - $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1335 | - } |
|
| 1336 | - if ($all_pipes_end) { |
|
| 1337 | - $pipeline .= $all_pipes_end; |
|
| 1338 | - } |
|
| 1339 | - $pipe = array_filter(explode('|', $pipeline)); |
|
| 1340 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1341 | - foreach ($pipe as $fonc) { |
|
| 1342 | - $fonc = trim($fonc); |
|
| 1343 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1344 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1345 | - $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1346 | - $file = "'$file'"; |
|
| 1347 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1348 | - if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1349 | - $dir = $regs[1]; |
|
| 1350 | - $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1351 | - if (defined($root_dir)) { |
|
| 1352 | - $dir = $root_dir; |
|
| 1353 | - } |
|
| 1354 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1355 | - $file = str_replace("''.", '', $file); |
|
| 1356 | - $file = str_replace(constant($dir), '', $file); |
|
| 1357 | - } |
|
| 1358 | - $s_inc .= "include_once_check($file);\n"; |
|
| 1359 | - } |
|
| 1360 | - } |
|
| 1361 | - if (strlen($s_inc)) { |
|
| 1362 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1363 | - } |
|
| 1364 | - $content .= "// Pipeline $action \n" |
|
| 1365 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 1366 | - . $s_inc |
|
| 1367 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1368 | - . $s_call |
|
| 1369 | - . "return \$val;\n}\n"; |
|
| 1370 | - } |
|
| 1371 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1372 | - clear_path_cache(); |
|
| 1317 | + $all_pipes = $all_pipes_end = ''; |
|
| 1318 | + if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1319 | + $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1320 | + unset($GLOBALS['spip_pipeline']['all']); |
|
| 1321 | + $all_pipes = trim(array_shift($a)); |
|
| 1322 | + if ($all_pipes) { |
|
| 1323 | + $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1324 | + } |
|
| 1325 | + if (count($a)) { |
|
| 1326 | + $all_pipes_end = '||' . array_shift($a); |
|
| 1327 | + } |
|
| 1328 | + } |
|
| 1329 | + $content = ''; |
|
| 1330 | + foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1331 | + $s_inc = ''; |
|
| 1332 | + $s_call = ''; |
|
| 1333 | + if ($all_pipes) { |
|
| 1334 | + $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1335 | + } |
|
| 1336 | + if ($all_pipes_end) { |
|
| 1337 | + $pipeline .= $all_pipes_end; |
|
| 1338 | + } |
|
| 1339 | + $pipe = array_filter(explode('|', $pipeline)); |
|
| 1340 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1341 | + foreach ($pipe as $fonc) { |
|
| 1342 | + $fonc = trim($fonc); |
|
| 1343 | + $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1344 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1345 | + $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1346 | + $file = "'$file'"; |
|
| 1347 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1348 | + if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1349 | + $dir = $regs[1]; |
|
| 1350 | + $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1351 | + if (defined($root_dir)) { |
|
| 1352 | + $dir = $root_dir; |
|
| 1353 | + } |
|
| 1354 | + $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1355 | + $file = str_replace("''.", '', $file); |
|
| 1356 | + $file = str_replace(constant($dir), '', $file); |
|
| 1357 | + } |
|
| 1358 | + $s_inc .= "include_once_check($file);\n"; |
|
| 1359 | + } |
|
| 1360 | + } |
|
| 1361 | + if (strlen($s_inc)) { |
|
| 1362 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1363 | + } |
|
| 1364 | + $content .= "// Pipeline $action \n" |
|
| 1365 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 1366 | + . $s_inc |
|
| 1367 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1368 | + . $s_call |
|
| 1369 | + . "return \$val;\n}\n"; |
|
| 1370 | + } |
|
| 1371 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1372 | + clear_path_cache(); |
|
| 1373 | 1373 | } |
| 1374 | 1374 | |
| 1375 | 1375 | |
@@ -1382,12 +1382,12 @@ discard block |
||
| 1382 | 1382 | * true si le plugin est actif, false sinon |
| 1383 | 1383 | **/ |
| 1384 | 1384 | function plugin_est_installe($plug_path) { |
| 1385 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1386 | - if (!$plugin_installes) { |
|
| 1387 | - return false; |
|
| 1388 | - } |
|
| 1385 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1386 | + if (!$plugin_installes) { |
|
| 1387 | + return false; |
|
| 1388 | + } |
|
| 1389 | 1389 | |
| 1390 | - return in_array($plug_path, $plugin_installes); |
|
| 1390 | + return in_array($plug_path, $plugin_installes); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | |
| 1393 | 1393 | |
@@ -1400,46 +1400,46 @@ discard block |
||
| 1400 | 1400 | * @uses plugins_installer_dist() |
| 1401 | 1401 | **/ |
| 1402 | 1402 | function plugin_installes_meta() { |
| 1403 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1404 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 1405 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1406 | - } |
|
| 1407 | - |
|
| 1408 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1409 | - $meta_plug_installes = []; |
|
| 1410 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1411 | - if ($plug = $resume['dir']) { |
|
| 1412 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1413 | - if ($infos) { |
|
| 1414 | - if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1415 | - $meta_plug_installes[] = $plug; |
|
| 1416 | - } |
|
| 1417 | - if (is_array($infos)) { |
|
| 1418 | - list($ok, $trace) = $infos['install_test']; |
|
| 1419 | - $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1420 | - $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1421 | - if (_IS_CLI) { |
|
| 1422 | - include_spip('inc/filtres'); |
|
| 1423 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1424 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1425 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1426 | - $trace, |
|
| 1427 | - "\n"; |
|
| 1428 | - } |
|
| 1429 | - else { |
|
| 1430 | - include_spip('inc/filtres_boites'); |
|
| 1431 | - echo "<div class='install-plugins svp_retour'>" |
|
| 1432 | - . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1433 | - . $trace |
|
| 1434 | - . "<div class='result'>$result</div>" |
|
| 1435 | - . boite_fermer() |
|
| 1436 | - . '</div>'; |
|
| 1437 | - } |
|
| 1438 | - } |
|
| 1439 | - } |
|
| 1440 | - } |
|
| 1441 | - } |
|
| 1442 | - ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1403 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1404 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 1405 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1406 | + } |
|
| 1407 | + |
|
| 1408 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1409 | + $meta_plug_installes = []; |
|
| 1410 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1411 | + if ($plug = $resume['dir']) { |
|
| 1412 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1413 | + if ($infos) { |
|
| 1414 | + if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1415 | + $meta_plug_installes[] = $plug; |
|
| 1416 | + } |
|
| 1417 | + if (is_array($infos)) { |
|
| 1418 | + list($ok, $trace) = $infos['install_test']; |
|
| 1419 | + $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1420 | + $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1421 | + if (_IS_CLI) { |
|
| 1422 | + include_spip('inc/filtres'); |
|
| 1423 | + $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1424 | + $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1425 | + echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1426 | + $trace, |
|
| 1427 | + "\n"; |
|
| 1428 | + } |
|
| 1429 | + else { |
|
| 1430 | + include_spip('inc/filtres_boites'); |
|
| 1431 | + echo "<div class='install-plugins svp_retour'>" |
|
| 1432 | + . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1433 | + . $trace |
|
| 1434 | + . "<div class='result'>$result</div>" |
|
| 1435 | + . boite_fermer() |
|
| 1436 | + . '</div>'; |
|
| 1437 | + } |
|
| 1438 | + } |
|
| 1439 | + } |
|
| 1440 | + } |
|
| 1441 | + } |
|
| 1442 | + ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | /** |
@@ -1453,29 +1453,29 @@ discard block |
||
| 1453 | 1453 | * Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante |
| 1454 | 1454 | **/ |
| 1455 | 1455 | function ecrire_fichier_php($nom, $contenu, $comment = '') { |
| 1456 | - if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1457 | - $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1458 | - } |
|
| 1459 | - |
|
| 1460 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1461 | - // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1462 | - // si pas de modif on ne touche pas au fichier initial |
|
| 1463 | - if (file_exists($nom)) { |
|
| 1464 | - if (substr($nom, -4) == '.php') { |
|
| 1465 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1466 | - } |
|
| 1467 | - else { |
|
| 1468 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1469 | - } |
|
| 1470 | - file_put_contents($fichier_tmp, $contenu); |
|
| 1471 | - if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1472 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1473 | - @unlink($fichier_tmp); |
|
| 1474 | - return; |
|
| 1475 | - } |
|
| 1476 | - @unlink($fichier_tmp); |
|
| 1477 | - } |
|
| 1478 | - ecrire_fichier($nom, $contenu); |
|
| 1479 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1480 | - spip_clear_opcode_cache(realpath($nom)); |
|
| 1456 | + if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1457 | + $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1458 | + } |
|
| 1459 | + |
|
| 1460 | + $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1461 | + // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1462 | + // si pas de modif on ne touche pas au fichier initial |
|
| 1463 | + if (file_exists($nom)) { |
|
| 1464 | + if (substr($nom, -4) == '.php') { |
|
| 1465 | + $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1466 | + } |
|
| 1467 | + else { |
|
| 1468 | + $fichier_tmp = $nom . '.tmp'; |
|
| 1469 | + } |
|
| 1470 | + file_put_contents($fichier_tmp, $contenu); |
|
| 1471 | + if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1472 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1473 | + @unlink($fichier_tmp); |
|
| 1474 | + return; |
|
| 1475 | + } |
|
| 1476 | + @unlink($fichier_tmp); |
|
| 1477 | + } |
|
| 1478 | + ecrire_fichier($nom, $contenu); |
|
| 1479 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1480 | + spip_clear_opcode_cache(realpath($nom)); |
|
| 1481 | 1481 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | if ($dir) { |
| 374 | 374 | $dir .= '/'; |
| 375 | 375 | } |
| 376 | - $dir .= 'procure:' . $procure['nom']; |
|
| 376 | + $dir .= 'procure:'.$procure['nom']; |
|
| 377 | 377 | |
| 378 | 378 | $procure['etat'] = '?'; |
| 379 | 379 | $procure['dir_type'] = $resume['dir_type']; |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $plug = $resume['dir']; |
| 558 | 558 | $k = $infos[$dir_type][$plug]; |
| 559 | 559 | |
| 560 | - $plug = constant($dir_type) . $plug; |
|
| 560 | + $plug = constant($dir_type).$plug; |
|
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
@@ -600,10 +600,10 @@ discard block |
||
| 600 | 600 | $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
| 601 | 601 | } elseif (!$raw) { |
| 602 | 602 | foreach ($list as $plug => $msg) { |
| 603 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 603 | + $list[$plug] = '<li>'._T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | + . '<ul><li>'.implode('</li><li>', $msg).'</li></ul></li>'; |
|
| 605 | 605 | } |
| 606 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 606 | + $list = '<ul>'.join("\n", $list).'</ul>'; |
|
| 607 | 607 | } |
| 608 | 608 | if ($raz) { |
| 609 | 609 | effacer_meta('plugin_erreur_activation'); |
@@ -717,13 +717,13 @@ discard block |
||
| 717 | 717 | if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
| 718 | 718 | return _T("plugin_${balise}_${type}", [ |
| 719 | 719 | 'plugin' => $nom, |
| 720 | - 'version' => ' ≥ ' . $minimum |
|
| 720 | + 'version' => ' ≥ '.$minimum |
|
| 721 | 721 | ]); |
| 722 | 722 | } |
| 723 | 723 | if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
| 724 | 724 | return _T("plugin_${balise}_${type}", [ |
| 725 | 725 | 'plugin' => $nom, |
| 726 | - 'version' => ' > ' . $minimum |
|
| 726 | + 'version' => ' > '.$minimum |
|
| 727 | 727 | ]); |
| 728 | 728 | } |
| 729 | 729 | } |
@@ -732,13 +732,13 @@ discard block |
||
| 732 | 732 | if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
| 733 | 733 | return _T("plugin_${balise}_${type}", [ |
| 734 | 734 | 'plugin' => $nom, |
| 735 | - 'version' => ' ≤ ' . $maximum |
|
| 735 | + 'version' => ' ≤ '.$maximum |
|
| 736 | 736 | ]); |
| 737 | 737 | } |
| 738 | 738 | if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
| 739 | 739 | return _T("plugin_${balise}_plugin", [ |
| 740 | 740 | 'plugin' => $nom, |
| 741 | - 'version' => ' < ' . $maximum |
|
| 741 | + 'version' => ' < '.$maximum |
|
| 742 | 742 | ]); |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | include_spip('inc/charger_plugin'); |
| 758 | 758 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 759 | 759 | }*/ |
| 760 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 760 | + return _T('plugin_necessite_lib', ['lib' => $lib])." <a href='$url'>$url</a>"; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | foreach ($plugin_valides as $p => $resume) { |
| 858 | 858 | // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
| 859 | 859 | if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
| 860 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 860 | + $header[] = $p.($resume['version'] ? '('.$resume['version'].')' : ''); |
|
| 861 | 861 | } |
| 862 | 862 | if ($resume['dir']) { |
| 863 | 863 | foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
@@ -882,11 +882,11 @@ discard block |
||
| 882 | 882 | $header = strtolower(implode(',', $header)); |
| 883 | 883 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 884 | 884 | ecrire_fichier( |
| 885 | - _DIR_VAR . 'config.txt', |
|
| 886 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 885 | + _DIR_VAR.'config.txt', |
|
| 886 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP').' '.$GLOBALS['spip_version_affichee'].' @ www.spip.net + '.$header |
|
| 887 | 887 | ); |
| 888 | 888 | } else { |
| 889 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 889 | + @unlink(_DIR_VAR.'config.txt'); |
|
| 890 | 890 | } |
| 891 | 891 | // generer charger_plugins_chemin.php |
| 892 | 892 | plugins_precompile_chemin($plugin_valides, $ordre); |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | // definir le plugin, donc le path avant l'include du fichier options |
| 941 | 941 | // permet de faire des include_spip pour attraper un inc_ du plugin |
| 942 | 942 | |
| 943 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 943 | + $dir = $dir_type.".'".$plug."/'"; |
|
| 944 | 944 | |
| 945 | 945 | $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
| 946 | 946 | if ( |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | if (!$info['chemin']) { |
| 952 | 952 | $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
| 953 | 953 | $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
| 954 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 954 | + if (is_dir(constant($dir_type).$plug.'/squelettes/')) { |
|
| 955 | 955 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 956 | } |
| 957 | 957 | } |
@@ -972,13 +972,13 @@ discard block |
||
| 972 | 972 | $dir = ''; |
| 973 | 973 | } |
| 974 | 974 | if (strlen($dir)) { |
| 975 | - $dir = rtrim($dir, '/') . '/'; |
|
| 975 | + $dir = rtrim($dir, '/').'/'; |
|
| 976 | 976 | } |
| 977 | 977 | if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
| 978 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 978 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 979 | 979 | } |
| 980 | 980 | if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
| 981 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 981 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | } |
@@ -987,11 +987,11 @@ discard block |
||
| 987 | 987 | } |
| 988 | 988 | } |
| 989 | 989 | if (count($chemins['public']) or count($chemins['prive'])) { |
| 990 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 990 | + $contenu .= 'if (_DIR_RESTREINT) _chemin(['.implode( |
|
| 991 | 991 | ',', |
| 992 | 992 | array_reverse($chemins['public']) |
| 993 | - ) . "]);\n" |
|
| 994 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 993 | + )."]);\n" |
|
| 994 | + . 'else _chemin(['.implode(',', array_reverse($chemins['prive']))."]);\n"; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | and strpos($dir, ':') === false // exclure le cas des procure: |
| 1041 | 1041 | and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
| 1042 | 1042 | ) { |
| 1043 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1043 | + if (is_readable("$dir$plug/".($file = $info['prefix'].'_'.$charge.'.php'))) { |
|
| 1044 | 1044 | $info[$charge] = [$file]; |
| 1045 | 1045 | } |
| 1046 | 1046 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | ) { |
| 1058 | 1058 | unset($info[$charge][$k]); |
| 1059 | 1059 | } else { |
| 1060 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1060 | + $_file = $root_dir_type.".'$plug/$file'"; |
|
| 1061 | 1061 | $contenu[$charge] .= "include_once_check($_file);\n"; |
| 1062 | 1062 | } |
| 1063 | 1063 | } |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1070 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options']; |
|
| 1071 | 1071 | $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
| 1072 | 1072 | . plugin_ongletbouton('onglets_plugins', $onglets); |
| 1073 | 1073 | |
@@ -1102,12 +1102,12 @@ discard block |
||
| 1102 | 1102 | define("_UPDATED_$nom", $val); |
| 1103 | 1103 | define("_UPDATED_md5_$nom", $md5); |
| 1104 | 1104 | } |
| 1105 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1105 | + $val = "unserialize('".str_replace("'", "\'", $val)."')"; |
|
| 1106 | 1106 | |
| 1107 | 1107 | return |
| 1108 | 1108 | "if (!function_exists('$nom')) {\n" |
| 1109 | 1109 | . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
| 1110 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1110 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 1111 | 1111 | . "}\n"; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | if (@is_readable(_CACHE_PLUGINS_OPT)) { |
| 1131 | 1131 | include_once(_CACHE_PLUGINS_OPT); |
| 1132 | 1132 | } else { |
| 1133 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1133 | + spip_log('pipelines desactives: impossible de produire '._CACHE_PLUGINS_OPT); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | 1136 | |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | $dir_type = $plugin_valides[$p]['dir_type']; |
| 1168 | 1168 | $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
| 1169 | 1169 | $plug = $plugin_valides[$p]['dir']; |
| 1170 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1170 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'].'_'); |
|
| 1171 | 1171 | if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
| 1172 | 1172 | foreach ($info['pipeline'] as $pipe) { |
| 1173 | 1173 | $nom = $pipe['nom']; |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | } |
| 1202 | 1202 | if (isset($pipe['inclure'])) { |
| 1203 | 1203 | $GLOBALS['spip_matrice']["$prefix$action"] = |
| 1204 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1204 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 1205 | 1205 | } |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | $prepend_code['taches_generales_cron'] = ''; |
| 1212 | 1212 | } |
| 1213 | 1213 | foreach ($info['genie'] as $genie) { |
| 1214 | - $nom = $prefix . $genie['nom']; |
|
| 1214 | + $nom = $prefix.$genie['nom']; |
|
| 1215 | 1215 | $periode = max(60, intval($genie['periode'])); |
| 1216 | 1216 | if (charger_fonction($nom, 'genie', true)) { |
| 1217 | 1217 | $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
@@ -1229,13 +1229,13 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | foreach ($info['style'] as $style) { |
| 1231 | 1231 | if (isset($style['path']) and $style['path']) { |
| 1232 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1232 | + $code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) "; |
|
| 1233 | 1233 | } else { |
| 1234 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1234 | + $code = "if (\$f='".addslashes($style['url'])."') "; |
|
| 1235 | 1235 | } |
| 1236 | 1236 | $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
| 1237 | 1237 | if (isset($style['media']) and strlen($style['media'])) { |
| 1238 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1238 | + $code .= ' media="'.addslashes($style['media']).'"'; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | $code .= "/>';\n"; |
| 1241 | 1241 | if ($style['type'] != 'prive') { |
@@ -1255,9 +1255,9 @@ discard block |
||
| 1255 | 1255 | if (isset($info['script']) and count($info['script'])) { |
| 1256 | 1256 | foreach ($info['script'] as $script) { |
| 1257 | 1257 | if (isset($script['path']) and $script['path']) { |
| 1258 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1258 | + $code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) "; |
|
| 1259 | 1259 | } else { |
| 1260 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1260 | + $code = "if (\$f='".addslashes($script['url'])."') "; |
|
| 1261 | 1261 | } |
| 1262 | 1262 | $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
| 1263 | 1263 | if ($script['type'] != 'prive') { |
@@ -1320,10 +1320,10 @@ discard block |
||
| 1320 | 1320 | unset($GLOBALS['spip_pipeline']['all']); |
| 1321 | 1321 | $all_pipes = trim(array_shift($a)); |
| 1322 | 1322 | if ($all_pipes) { |
| 1323 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1323 | + $all_pipes = '|'.ltrim($all_pipes, '|'); |
|
| 1324 | 1324 | } |
| 1325 | 1325 | if (count($a)) { |
| 1326 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1326 | + $all_pipes_end = '||'.array_shift($a); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | } |
| 1329 | 1329 | $content = ''; |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | // Eclater le pipeline en filtres et appliquer chaque filtre |
| 1341 | 1341 | foreach ($pipe as $fonc) { |
| 1342 | 1342 | $fonc = trim($fonc); |
| 1343 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1343 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 1344 | 1344 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 1345 | 1345 | $file = $GLOBALS['spip_matrice'][$fonc]; |
| 1346 | 1346 | $file = "'$file'"; |
@@ -1351,7 +1351,7 @@ discard block |
||
| 1351 | 1351 | if (defined($root_dir)) { |
| 1352 | 1352 | $dir = $root_dir; |
| 1353 | 1353 | } |
| 1354 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1354 | + $file = str_replace($regs[0], "'.".$dir.".'", $file); |
|
| 1355 | 1355 | $file = str_replace("''.", '', $file); |
| 1356 | 1356 | $file = str_replace(constant($dir), '', $file); |
| 1357 | 1357 | } |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | $content .= "// Pipeline $action \n" |
| 1365 | 1365 | . "function execute_pipeline_$action(&\$val){\n" |
| 1366 | 1366 | . $s_inc |
| 1367 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1367 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '') |
|
| 1368 | 1368 | . $s_call |
| 1369 | 1369 | . "return \$val;\n}\n"; |
| 1370 | 1370 | } |
@@ -1420,9 +1420,9 @@ discard block |
||
| 1420 | 1420 | $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
| 1421 | 1421 | if (_IS_CLI) { |
| 1422 | 1422 | include_spip('inc/filtres'); |
| 1423 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1424 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1425 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1423 | + $trace = ltrim(textebrut($trace)."\n".$result); |
|
| 1424 | + $trace = ' '.str_replace("\n", "\n ", $trace); |
|
| 1425 | + echo "\n".($ok ? 'OK ' : '/!\ ').textebrut($titre)."\n", |
|
| 1426 | 1426 | $trace, |
| 1427 | 1427 | "\n"; |
| 1428 | 1428 | } |
@@ -1457,15 +1457,15 @@ discard block |
||
| 1457 | 1457 | $GLOBALS['fichier_php_compile_recent'] = 0; |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1460 | + $contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>'; |
|
| 1461 | 1461 | // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
| 1462 | 1462 | // si pas de modif on ne touche pas au fichier initial |
| 1463 | 1463 | if (file_exists($nom)) { |
| 1464 | 1464 | if (substr($nom, -4) == '.php') { |
| 1465 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1465 | + $fichier_tmp = substr($nom, 0, -4).'.tmp.php'; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | else { |
| 1468 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1468 | + $fichier_tmp = $nom.'.tmp'; |
|
| 1469 | 1469 | } |
| 1470 | 1470 | file_put_contents($fichier_tmp, $contenu); |
| 1471 | 1471 | if (md5_file($nom) == md5_file($fichier_tmp)) { |
@@ -561,11 +561,9 @@ discard block |
||
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
| 564 | - } |
|
| 565 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 564 | + } elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | 565 | $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
| 567 | - } |
|
| 568 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 566 | + } elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | 567 | $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
| 570 | 568 | } |
| 571 | 569 | } else { |
@@ -954,8 +952,7 @@ discard block |
||
| 954 | 952 | if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
| 955 | 953 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 954 | } |
| 957 | - } |
|
| 958 | - else { |
|
| 955 | + } else { |
|
| 959 | 956 | foreach ($info['chemin'] as $chemin) { |
| 960 | 957 | if ( |
| 961 | 958 | !isset($chemin['version']) or plugin_version_compatible( |
@@ -1425,8 +1422,7 @@ discard block |
||
| 1425 | 1422 | echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
| 1426 | 1423 | $trace, |
| 1427 | 1424 | "\n"; |
| 1428 | - } |
|
| 1429 | - else { |
|
| 1425 | + } else { |
|
| 1430 | 1426 | include_spip('inc/filtres_boites'); |
| 1431 | 1427 | echo "<div class='install-plugins svp_retour'>" |
| 1432 | 1428 | . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
@@ -1463,8 +1459,7 @@ discard block |
||
| 1463 | 1459 | if (file_exists($nom)) { |
| 1464 | 1460 | if (substr($nom, -4) == '.php') { |
| 1465 | 1461 | $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
| 1466 | - } |
|
| 1467 | - else { |
|
| 1462 | + } else { |
|
| 1468 | 1463 | $fichier_tmp = $nom . '.tmp'; |
| 1469 | 1464 | } |
| 1470 | 1465 | file_put_contents($fichier_tmp, $contenu); |
@@ -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 | include_spip('inc/filtres_images_lib_mini'); // par precaution |
| 24 | 24 | |
@@ -31,161 +31,161 @@ discard block |
||
| 31 | 31 | * Le code hexadécimal de la couleur (sans le #) ou le code couleur textuel si non trouvé |
| 32 | 32 | */ |
| 33 | 33 | function couleur_html_to_hex($couleur) { |
| 34 | - $couleurs_html = [ |
|
| 35 | - 'aliceblue' => 'F0F8FF', |
|
| 36 | - 'antiquewhite' => 'FAEBD7', |
|
| 37 | - 'aqua' => '00FFFF', |
|
| 38 | - 'aquamarine' => '7FFFD4', |
|
| 39 | - 'azure' => 'F0FFFF', |
|
| 40 | - 'beige' => 'F5F5DC', |
|
| 41 | - 'bisque' => 'FFE4C4', |
|
| 42 | - 'black' => '000000', |
|
| 43 | - 'blanchedalmond' => 'FFEBCD', |
|
| 44 | - 'blue' => '0000FF', |
|
| 45 | - 'blueviolet' => '8A2BE2', |
|
| 46 | - 'brown' => 'A52A2A', |
|
| 47 | - 'burlywood' => 'DEB887', |
|
| 48 | - 'cadetblue' => '5F9EA0', |
|
| 49 | - 'chartreuse' => '7FFF00', |
|
| 50 | - 'chocolate' => 'D2691E', |
|
| 51 | - 'coral' => 'FF7F50', |
|
| 52 | - 'cornflowerblue' => '6495ED', |
|
| 53 | - 'cornsilk' => 'FFF8DC', |
|
| 54 | - 'crimson' => 'DC143C', |
|
| 55 | - 'cyan' => '00FFFF', |
|
| 56 | - 'darkblue' => '00008B', |
|
| 57 | - 'darkcyan' => '008B8B', |
|
| 58 | - 'darkgoldenrod' => 'B8860B', |
|
| 59 | - 'darkgray' => 'A9A9A9', |
|
| 60 | - 'darkgreen' => '006400', |
|
| 61 | - 'darkgrey' => 'A9A9A9', |
|
| 62 | - 'darkkhaki' => 'BDB76B', |
|
| 63 | - 'darkmagenta' => '8B008B', |
|
| 64 | - 'darkolivegreen' => '556B2F', |
|
| 65 | - 'darkorange' => 'FF8C00', |
|
| 66 | - 'darkorchid' => '9932CC', |
|
| 67 | - 'darkred' => '8B0000', |
|
| 68 | - 'darksalmon' => 'E9967A', |
|
| 69 | - 'darkseagreen' => '8FBC8F', |
|
| 70 | - 'darkslateblue' => '483D8B', |
|
| 71 | - 'darkslategray' => '2F4F4F', |
|
| 72 | - 'darkslategrey' => '2F4F4F', |
|
| 73 | - 'darkturquoise' => '00CED1', |
|
| 74 | - 'darkviolet' => '9400D3', |
|
| 75 | - 'deeppink' => 'FF1493', |
|
| 76 | - 'deepskyblue' => '00BFFF', |
|
| 77 | - 'dimgray' => '696969', |
|
| 78 | - 'dimgrey' => '696969', |
|
| 79 | - 'dodgerblue' => '1E90FF', |
|
| 80 | - 'firebrick' => 'B22222', |
|
| 81 | - 'floralwhite' => 'FFFAF0', |
|
| 82 | - 'forestgreen' => '228B22', |
|
| 83 | - 'fuchsia' => 'FF00FF', |
|
| 84 | - 'gainsboro' => 'DCDCDC', |
|
| 85 | - 'ghostwhite' => 'F8F8FF', |
|
| 86 | - 'gold' => 'FFD700', |
|
| 87 | - 'goldenrod' => 'DAA520', |
|
| 88 | - 'gray' => '808080', |
|
| 89 | - 'green' => '008000', |
|
| 90 | - 'greenyellow' => 'ADFF2F', |
|
| 91 | - 'grey' => '808080', |
|
| 92 | - 'honeydew' => 'F0FFF0', |
|
| 93 | - 'hotpink' => 'FF69B4', |
|
| 94 | - 'indianred' => 'CD5C5C', |
|
| 95 | - 'indigo' => '4B0082', |
|
| 96 | - 'ivory' => 'FFFFF0', |
|
| 97 | - 'khaki' => 'F0E68C', |
|
| 98 | - 'lavender' => 'E6E6FA', |
|
| 99 | - 'lavenderblush' => 'FFF0F5', |
|
| 100 | - 'lawngreen' => '7CFC00', |
|
| 101 | - 'lemonchiffon' => 'FFFACD', |
|
| 102 | - 'lightblue' => 'ADD8E6', |
|
| 103 | - 'lightcoral' => 'F08080', |
|
| 104 | - 'lightcyan' => 'E0FFFF', |
|
| 105 | - 'lightgoldenrodyellow' => 'FAFAD2', |
|
| 106 | - 'lightgray' => 'D3D3D3', |
|
| 107 | - 'lightgreen' => '90EE90', |
|
| 108 | - 'lightgrey' => 'D3D3D3', |
|
| 109 | - 'lightpink' => 'FFB6C1', |
|
| 110 | - 'lightsalmon' => 'FFA07A', |
|
| 111 | - 'lightseagreen' => '20B2AA', |
|
| 112 | - 'lightskyblue' => '87CEFA', |
|
| 113 | - 'lightslategray' => '778899', |
|
| 114 | - 'lightslategrey' => '778899', |
|
| 115 | - 'lightsteelblue' => 'B0C4DE', |
|
| 116 | - 'lightyellow' => 'FFFFE0', |
|
| 117 | - 'lime' => '00FF00', |
|
| 118 | - 'limegreen' => '32CD32', |
|
| 119 | - 'linen' => 'FAF0E6', |
|
| 120 | - 'magenta' => 'FF00FF', |
|
| 121 | - 'maroon' => '800000', |
|
| 122 | - 'mediumaquamarine' => '66CDAA', |
|
| 123 | - 'mediumblue' => '0000CD', |
|
| 124 | - 'mediumorchid' => 'BA55D3', |
|
| 125 | - 'mediumpurple' => '9370DB', |
|
| 126 | - 'mediumseagreen' => '3CB371', |
|
| 127 | - 'mediumslateblue' => '7B68EE', |
|
| 128 | - 'mediumspringgreen' => '00FA9A', |
|
| 129 | - 'mediumturquoise' => '48D1CC', |
|
| 130 | - 'mediumvioletred' => 'C71585', |
|
| 131 | - 'midnightblue' => '191970', |
|
| 132 | - 'mintcream' => 'F5FFFA', |
|
| 133 | - 'mistyrose' => 'FFE4E1', |
|
| 134 | - 'moccasin' => 'FFE4B5', |
|
| 135 | - 'navajowhite' => 'FFDEAD', |
|
| 136 | - 'navy' => '000080', |
|
| 137 | - 'oldlace' => 'FDF5E6', |
|
| 138 | - 'olive' => '808000', |
|
| 139 | - 'olivedrab' => '6B8E23', |
|
| 140 | - 'orange' => 'FFA500', |
|
| 141 | - 'orangered' => 'FF4500', |
|
| 142 | - 'orchid' => 'DA70D6', |
|
| 143 | - 'palegoldenrod' => 'EEE8AA', |
|
| 144 | - 'palegreen' => '98FB98', |
|
| 145 | - 'paleturquoise' => 'AFEEEE', |
|
| 146 | - 'palevioletred' => 'DB7093', |
|
| 147 | - 'papayawhip' => 'FFEFD5', |
|
| 148 | - 'peachpuff' => 'FFDAB9', |
|
| 149 | - 'peru' => 'CD853F', |
|
| 150 | - 'pink' => 'FFC0CB', |
|
| 151 | - 'plum' => 'DDA0DD', |
|
| 152 | - 'powderblue' => 'B0E0E6', |
|
| 153 | - 'purple' => '800080', |
|
| 154 | - 'rebeccapurple' => '663399', |
|
| 155 | - 'red' => 'FF0000', |
|
| 156 | - 'rosybrown' => 'BC8F8F', |
|
| 157 | - 'royalblue' => '4169E1', |
|
| 158 | - 'saddlebrown' => '8B4513', |
|
| 159 | - 'salmon' => 'FA8072', |
|
| 160 | - 'sandybrown' => 'F4A460', |
|
| 161 | - 'seagreen' => '2E8B57', |
|
| 162 | - 'seashell' => 'FFF5EE', |
|
| 163 | - 'sienna' => 'A0522D', |
|
| 164 | - 'silver' => 'C0C0C0', |
|
| 165 | - 'skyblue' => '87CEEB', |
|
| 166 | - 'slateblue' => '6A5ACD', |
|
| 167 | - 'slategray' => '708090', |
|
| 168 | - 'slategrey' => '708090', |
|
| 169 | - 'snow' => 'FFFAFA', |
|
| 170 | - 'springgreen' => '00FF7F', |
|
| 171 | - 'steelblue' => '4682B4', |
|
| 172 | - 'tan' => 'D2B48C', |
|
| 173 | - 'teal' => '008080', |
|
| 174 | - 'thistle' => 'D8BFD8', |
|
| 175 | - 'tomato' => 'FF6347', |
|
| 176 | - 'turquoise' => '40E0D0', |
|
| 177 | - 'violet' => 'EE82EE', |
|
| 178 | - 'wheat' => 'F5DEB3', |
|
| 179 | - 'white' => 'FFFFFF', |
|
| 180 | - 'whitesmoke' => 'F5F5F5', |
|
| 181 | - 'yellow' => 'FFFF00', |
|
| 182 | - 'yellowgreen' => '9ACD32', |
|
| 183 | - ]; |
|
| 184 | - if (isset($couleurs_html[$lc = strtolower($couleur)])) { |
|
| 185 | - return $couleurs_html[$lc]; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - return $couleur; |
|
| 34 | + $couleurs_html = [ |
|
| 35 | + 'aliceblue' => 'F0F8FF', |
|
| 36 | + 'antiquewhite' => 'FAEBD7', |
|
| 37 | + 'aqua' => '00FFFF', |
|
| 38 | + 'aquamarine' => '7FFFD4', |
|
| 39 | + 'azure' => 'F0FFFF', |
|
| 40 | + 'beige' => 'F5F5DC', |
|
| 41 | + 'bisque' => 'FFE4C4', |
|
| 42 | + 'black' => '000000', |
|
| 43 | + 'blanchedalmond' => 'FFEBCD', |
|
| 44 | + 'blue' => '0000FF', |
|
| 45 | + 'blueviolet' => '8A2BE2', |
|
| 46 | + 'brown' => 'A52A2A', |
|
| 47 | + 'burlywood' => 'DEB887', |
|
| 48 | + 'cadetblue' => '5F9EA0', |
|
| 49 | + 'chartreuse' => '7FFF00', |
|
| 50 | + 'chocolate' => 'D2691E', |
|
| 51 | + 'coral' => 'FF7F50', |
|
| 52 | + 'cornflowerblue' => '6495ED', |
|
| 53 | + 'cornsilk' => 'FFF8DC', |
|
| 54 | + 'crimson' => 'DC143C', |
|
| 55 | + 'cyan' => '00FFFF', |
|
| 56 | + 'darkblue' => '00008B', |
|
| 57 | + 'darkcyan' => '008B8B', |
|
| 58 | + 'darkgoldenrod' => 'B8860B', |
|
| 59 | + 'darkgray' => 'A9A9A9', |
|
| 60 | + 'darkgreen' => '006400', |
|
| 61 | + 'darkgrey' => 'A9A9A9', |
|
| 62 | + 'darkkhaki' => 'BDB76B', |
|
| 63 | + 'darkmagenta' => '8B008B', |
|
| 64 | + 'darkolivegreen' => '556B2F', |
|
| 65 | + 'darkorange' => 'FF8C00', |
|
| 66 | + 'darkorchid' => '9932CC', |
|
| 67 | + 'darkred' => '8B0000', |
|
| 68 | + 'darksalmon' => 'E9967A', |
|
| 69 | + 'darkseagreen' => '8FBC8F', |
|
| 70 | + 'darkslateblue' => '483D8B', |
|
| 71 | + 'darkslategray' => '2F4F4F', |
|
| 72 | + 'darkslategrey' => '2F4F4F', |
|
| 73 | + 'darkturquoise' => '00CED1', |
|
| 74 | + 'darkviolet' => '9400D3', |
|
| 75 | + 'deeppink' => 'FF1493', |
|
| 76 | + 'deepskyblue' => '00BFFF', |
|
| 77 | + 'dimgray' => '696969', |
|
| 78 | + 'dimgrey' => '696969', |
|
| 79 | + 'dodgerblue' => '1E90FF', |
|
| 80 | + 'firebrick' => 'B22222', |
|
| 81 | + 'floralwhite' => 'FFFAF0', |
|
| 82 | + 'forestgreen' => '228B22', |
|
| 83 | + 'fuchsia' => 'FF00FF', |
|
| 84 | + 'gainsboro' => 'DCDCDC', |
|
| 85 | + 'ghostwhite' => 'F8F8FF', |
|
| 86 | + 'gold' => 'FFD700', |
|
| 87 | + 'goldenrod' => 'DAA520', |
|
| 88 | + 'gray' => '808080', |
|
| 89 | + 'green' => '008000', |
|
| 90 | + 'greenyellow' => 'ADFF2F', |
|
| 91 | + 'grey' => '808080', |
|
| 92 | + 'honeydew' => 'F0FFF0', |
|
| 93 | + 'hotpink' => 'FF69B4', |
|
| 94 | + 'indianred' => 'CD5C5C', |
|
| 95 | + 'indigo' => '4B0082', |
|
| 96 | + 'ivory' => 'FFFFF0', |
|
| 97 | + 'khaki' => 'F0E68C', |
|
| 98 | + 'lavender' => 'E6E6FA', |
|
| 99 | + 'lavenderblush' => 'FFF0F5', |
|
| 100 | + 'lawngreen' => '7CFC00', |
|
| 101 | + 'lemonchiffon' => 'FFFACD', |
|
| 102 | + 'lightblue' => 'ADD8E6', |
|
| 103 | + 'lightcoral' => 'F08080', |
|
| 104 | + 'lightcyan' => 'E0FFFF', |
|
| 105 | + 'lightgoldenrodyellow' => 'FAFAD2', |
|
| 106 | + 'lightgray' => 'D3D3D3', |
|
| 107 | + 'lightgreen' => '90EE90', |
|
| 108 | + 'lightgrey' => 'D3D3D3', |
|
| 109 | + 'lightpink' => 'FFB6C1', |
|
| 110 | + 'lightsalmon' => 'FFA07A', |
|
| 111 | + 'lightseagreen' => '20B2AA', |
|
| 112 | + 'lightskyblue' => '87CEFA', |
|
| 113 | + 'lightslategray' => '778899', |
|
| 114 | + 'lightslategrey' => '778899', |
|
| 115 | + 'lightsteelblue' => 'B0C4DE', |
|
| 116 | + 'lightyellow' => 'FFFFE0', |
|
| 117 | + 'lime' => '00FF00', |
|
| 118 | + 'limegreen' => '32CD32', |
|
| 119 | + 'linen' => 'FAF0E6', |
|
| 120 | + 'magenta' => 'FF00FF', |
|
| 121 | + 'maroon' => '800000', |
|
| 122 | + 'mediumaquamarine' => '66CDAA', |
|
| 123 | + 'mediumblue' => '0000CD', |
|
| 124 | + 'mediumorchid' => 'BA55D3', |
|
| 125 | + 'mediumpurple' => '9370DB', |
|
| 126 | + 'mediumseagreen' => '3CB371', |
|
| 127 | + 'mediumslateblue' => '7B68EE', |
|
| 128 | + 'mediumspringgreen' => '00FA9A', |
|
| 129 | + 'mediumturquoise' => '48D1CC', |
|
| 130 | + 'mediumvioletred' => 'C71585', |
|
| 131 | + 'midnightblue' => '191970', |
|
| 132 | + 'mintcream' => 'F5FFFA', |
|
| 133 | + 'mistyrose' => 'FFE4E1', |
|
| 134 | + 'moccasin' => 'FFE4B5', |
|
| 135 | + 'navajowhite' => 'FFDEAD', |
|
| 136 | + 'navy' => '000080', |
|
| 137 | + 'oldlace' => 'FDF5E6', |
|
| 138 | + 'olive' => '808000', |
|
| 139 | + 'olivedrab' => '6B8E23', |
|
| 140 | + 'orange' => 'FFA500', |
|
| 141 | + 'orangered' => 'FF4500', |
|
| 142 | + 'orchid' => 'DA70D6', |
|
| 143 | + 'palegoldenrod' => 'EEE8AA', |
|
| 144 | + 'palegreen' => '98FB98', |
|
| 145 | + 'paleturquoise' => 'AFEEEE', |
|
| 146 | + 'palevioletred' => 'DB7093', |
|
| 147 | + 'papayawhip' => 'FFEFD5', |
|
| 148 | + 'peachpuff' => 'FFDAB9', |
|
| 149 | + 'peru' => 'CD853F', |
|
| 150 | + 'pink' => 'FFC0CB', |
|
| 151 | + 'plum' => 'DDA0DD', |
|
| 152 | + 'powderblue' => 'B0E0E6', |
|
| 153 | + 'purple' => '800080', |
|
| 154 | + 'rebeccapurple' => '663399', |
|
| 155 | + 'red' => 'FF0000', |
|
| 156 | + 'rosybrown' => 'BC8F8F', |
|
| 157 | + 'royalblue' => '4169E1', |
|
| 158 | + 'saddlebrown' => '8B4513', |
|
| 159 | + 'salmon' => 'FA8072', |
|
| 160 | + 'sandybrown' => 'F4A460', |
|
| 161 | + 'seagreen' => '2E8B57', |
|
| 162 | + 'seashell' => 'FFF5EE', |
|
| 163 | + 'sienna' => 'A0522D', |
|
| 164 | + 'silver' => 'C0C0C0', |
|
| 165 | + 'skyblue' => '87CEEB', |
|
| 166 | + 'slateblue' => '6A5ACD', |
|
| 167 | + 'slategray' => '708090', |
|
| 168 | + 'slategrey' => '708090', |
|
| 169 | + 'snow' => 'FFFAFA', |
|
| 170 | + 'springgreen' => '00FF7F', |
|
| 171 | + 'steelblue' => '4682B4', |
|
| 172 | + 'tan' => 'D2B48C', |
|
| 173 | + 'teal' => '008080', |
|
| 174 | + 'thistle' => 'D8BFD8', |
|
| 175 | + 'tomato' => 'FF6347', |
|
| 176 | + 'turquoise' => '40E0D0', |
|
| 177 | + 'violet' => 'EE82EE', |
|
| 178 | + 'wheat' => 'F5DEB3', |
|
| 179 | + 'white' => 'FFFFFF', |
|
| 180 | + 'whitesmoke' => 'F5F5F5', |
|
| 181 | + 'yellow' => 'FFFF00', |
|
| 182 | + 'yellowgreen' => '9ACD32', |
|
| 183 | + ]; |
|
| 184 | + if (isset($couleurs_html[$lc = strtolower($couleur)])) { |
|
| 185 | + return $couleurs_html[$lc]; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + return $couleur; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -201,16 +201,16 @@ discard block |
||
| 201 | 201 | * @return string Couleur tel que "hsl(200, 40%, 34%)" ou valeur formattée |
| 202 | 202 | */ |
| 203 | 203 | function couleur_hex_to_hsl($couleur, $format = null) { |
| 204 | - $hsl = _couleur_hex_to_hsl($couleur); |
|
| 205 | - $hsl = [ |
|
| 206 | - 'h' => round($hsl['h'] * 360), |
|
| 207 | - 's' => round($hsl['s'] * 100) . '%', |
|
| 208 | - 'l' => round($hsl['l'] * 100) . '%' |
|
| 209 | - ]; |
|
| 210 | - if ($format === null) { |
|
| 211 | - return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})"; |
|
| 212 | - } |
|
| 213 | - return str_replace(array_keys($hsl), $hsl, $format); |
|
| 204 | + $hsl = _couleur_hex_to_hsl($couleur); |
|
| 205 | + $hsl = [ |
|
| 206 | + 'h' => round($hsl['h'] * 360), |
|
| 207 | + 's' => round($hsl['s'] * 100) . '%', |
|
| 208 | + 'l' => round($hsl['l'] * 100) . '%' |
|
| 209 | + ]; |
|
| 210 | + if ($format === null) { |
|
| 211 | + return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})"; |
|
| 212 | + } |
|
| 213 | + return str_replace(array_keys($hsl), $hsl, $format); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | |
@@ -227,16 +227,16 @@ discard block |
||
| 227 | 227 | * @return string Couleur tel que "rgb(200, 40, 84)" ou valeur formattée |
| 228 | 228 | */ |
| 229 | 229 | function couleur_hex_to_rgb($couleur, $format = null) { |
| 230 | - $rgb = _couleur_hex_to_dec($couleur); |
|
| 231 | - $rgb = [ |
|
| 232 | - 'r' => $rgb['red'], |
|
| 233 | - 'g' => $rgb['green'], |
|
| 234 | - 'b' => $rgb['blue'], |
|
| 235 | - ]; |
|
| 236 | - if ($format === null) { |
|
| 237 | - return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})"; |
|
| 238 | - } |
|
| 239 | - return str_replace(array_keys($rgb), $rgb, $format); |
|
| 230 | + $rgb = _couleur_hex_to_dec($couleur); |
|
| 231 | + $rgb = [ |
|
| 232 | + 'r' => $rgb['red'], |
|
| 233 | + 'g' => $rgb['green'], |
|
| 234 | + 'b' => $rgb['blue'], |
|
| 235 | + ]; |
|
| 236 | + if ($format === null) { |
|
| 237 | + return "rgb({$rgb['r']}, {$rgb['g']}, {$rgb['b']})"; |
|
| 238 | + } |
|
| 239 | + return str_replace(array_keys($rgb), $rgb, $format); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -252,15 +252,15 @@ discard block |
||
| 252 | 252 | * Code hexadécimal de la couleur plus foncée |
| 253 | 253 | */ |
| 254 | 254 | function couleur_foncer($couleur, $coeff = 0.5) { |
| 255 | - $couleurs = _couleur_hex_to_dec($couleur); |
|
| 255 | + $couleurs = _couleur_hex_to_dec($couleur); |
|
| 256 | 256 | |
| 257 | - $red = $couleurs['red'] - round(($couleurs['red']) * $coeff); |
|
| 258 | - $green = $couleurs['green'] - round(($couleurs['green']) * $coeff); |
|
| 259 | - $blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff); |
|
| 257 | + $red = $couleurs['red'] - round(($couleurs['red']) * $coeff); |
|
| 258 | + $green = $couleurs['green'] - round(($couleurs['green']) * $coeff); |
|
| 259 | + $blue = $couleurs['blue'] - round(($couleurs['blue']) * $coeff); |
|
| 260 | 260 | |
| 261 | - $couleur = _couleur_dec_to_hex($red, $green, $blue); |
|
| 261 | + $couleur = _couleur_dec_to_hex($red, $green, $blue); |
|
| 262 | 262 | |
| 263 | - return $couleur; |
|
| 263 | + return $couleur; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -276,15 +276,15 @@ discard block |
||
| 276 | 276 | * Code hexadécimal de la couleur éclaircie |
| 277 | 277 | */ |
| 278 | 278 | function couleur_eclaircir($couleur, $coeff = 0.5) { |
| 279 | - $couleurs = _couleur_hex_to_dec($couleur); |
|
| 279 | + $couleurs = _couleur_hex_to_dec($couleur); |
|
| 280 | 280 | |
| 281 | - $red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff); |
|
| 282 | - $green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff); |
|
| 283 | - $blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff); |
|
| 281 | + $red = $couleurs['red'] + round((255 - $couleurs['red']) * $coeff); |
|
| 282 | + $green = $couleurs['green'] + round((255 - $couleurs['green']) * $coeff); |
|
| 283 | + $blue = $couleurs['blue'] + round((255 - $couleurs['blue']) * $coeff); |
|
| 284 | 284 | |
| 285 | - $couleur = _couleur_dec_to_hex($red, $green, $blue); |
|
| 285 | + $couleur = _couleur_dec_to_hex($red, $green, $blue); |
|
| 286 | 286 | |
| 287 | - return $couleur; |
|
| 287 | + return $couleur; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -307,28 +307,28 @@ discard block |
||
| 307 | 307 | * Le tag html `<img src=... />` avec une class `filtre_inactif` ou pas |
| 308 | 308 | */ |
| 309 | 309 | function image_select($img, $width_min = 0, $height_min = 0, $width_max = 10000, $height_max = 1000) { |
| 310 | - if (!$img) { |
|
| 311 | - return $img; |
|
| 312 | - } |
|
| 313 | - list($h, $l) = taille_image($img); |
|
| 314 | - $select = true; |
|
| 315 | - if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) { |
|
| 316 | - $select = false; |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - $class = extraire_attribut($img, 'class'); |
|
| 320 | - $p = strpos($class, 'filtre_inactif'); |
|
| 321 | - if (($select == false) and ($p === false)) { |
|
| 322 | - $class .= ' filtre_inactif'; |
|
| 323 | - $img = inserer_attribut($img, 'class', $class); |
|
| 324 | - } |
|
| 325 | - if (($select == true) and ($p !== false)) { |
|
| 326 | - // no_image_filtrer : historique, a virer |
|
| 327 | - $class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class); |
|
| 328 | - $img = inserer_attribut($img, 'class', $class); |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - return $img; |
|
| 310 | + if (!$img) { |
|
| 311 | + return $img; |
|
| 312 | + } |
|
| 313 | + list($h, $l) = taille_image($img); |
|
| 314 | + $select = true; |
|
| 315 | + if ($l < $width_min or $l > $width_max or $h < $height_min or $h > $height_max) { |
|
| 316 | + $select = false; |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + $class = extraire_attribut($img, 'class'); |
|
| 320 | + $p = strpos($class, 'filtre_inactif'); |
|
| 321 | + if (($select == false) and ($p === false)) { |
|
| 322 | + $class .= ' filtre_inactif'; |
|
| 323 | + $img = inserer_attribut($img, 'class', $class); |
|
| 324 | + } |
|
| 325 | + if (($select == true) and ($p !== false)) { |
|
| 326 | + // no_image_filtrer : historique, a virer |
|
| 327 | + $class = preg_replace(',\s*(filtre_inactif|no_image_filtrer),', '', $class); |
|
| 328 | + $img = inserer_attribut($img, 'class', $class); |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + return $img; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -376,45 +376,45 @@ discard block |
||
| 376 | 376 | * Code HTML de l'image ou du texte. |
| 377 | 377 | **/ |
| 378 | 378 | function image_passe_partout( |
| 379 | - $img, |
|
| 380 | - $taille_x = -1, |
|
| 381 | - $taille_y = -1, |
|
| 382 | - $force = false, |
|
| 383 | - $cherche_image = false, |
|
| 384 | - $process = 'AUTO' |
|
| 379 | + $img, |
|
| 380 | + $taille_x = -1, |
|
| 381 | + $taille_y = -1, |
|
| 382 | + $force = false, |
|
| 383 | + $cherche_image = false, |
|
| 384 | + $process = 'AUTO' |
|
| 385 | 385 | ) { |
| 386 | - // PHP 7+ type hint |
|
| 387 | - $img = (string)$img; |
|
| 388 | - $taille_x = (int)$taille_x; |
|
| 389 | - $taille_y = (int)$taille_y; |
|
| 390 | - $force = (bool)$force; |
|
| 391 | - $process = (string)$process; |
|
| 392 | - |
|
| 393 | - if (!$img) { |
|
| 394 | - return ''; |
|
| 395 | - } |
|
| 396 | - list($hauteur, $largeur) = taille_image($img); |
|
| 397 | - if ($taille_x === -1) { |
|
| 398 | - $taille_x = isset($GLOBALS['meta']['taille_preview']) ? $GLOBALS['meta']['taille_preview'] : 150; |
|
| 399 | - } |
|
| 400 | - if ($taille_y === -1) { |
|
| 401 | - $taille_y = $taille_x; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - if ($taille_x === 0 and $taille_y > 0) { |
|
| 405 | - $taille_x = 1; |
|
| 406 | - } # {0,300} -> c'est 300 qui compte |
|
| 407 | - elseif ($taille_x > 0 and $taille_y === 0) { |
|
| 408 | - $taille_y = 1; |
|
| 409 | - } # {300,0} -> c'est 300 qui compte |
|
| 410 | - elseif ($taille_x == 0 and $taille_y === 0) { |
|
| 411 | - return ''; |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - list($destWidth, $destHeight, $ratio) = ratio_passe_partout($largeur, $hauteur, $taille_x, $taille_y); |
|
| 415 | - $fonction = ['image_passe_partout', func_get_args()]; |
|
| 416 | - |
|
| 417 | - return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process); |
|
| 386 | + // PHP 7+ type hint |
|
| 387 | + $img = (string)$img; |
|
| 388 | + $taille_x = (int)$taille_x; |
|
| 389 | + $taille_y = (int)$taille_y; |
|
| 390 | + $force = (bool)$force; |
|
| 391 | + $process = (string)$process; |
|
| 392 | + |
|
| 393 | + if (!$img) { |
|
| 394 | + return ''; |
|
| 395 | + } |
|
| 396 | + list($hauteur, $largeur) = taille_image($img); |
|
| 397 | + if ($taille_x === -1) { |
|
| 398 | + $taille_x = isset($GLOBALS['meta']['taille_preview']) ? $GLOBALS['meta']['taille_preview'] : 150; |
|
| 399 | + } |
|
| 400 | + if ($taille_y === -1) { |
|
| 401 | + $taille_y = $taille_x; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + if ($taille_x === 0 and $taille_y > 0) { |
|
| 405 | + $taille_x = 1; |
|
| 406 | + } # {0,300} -> c'est 300 qui compte |
|
| 407 | + elseif ($taille_x > 0 and $taille_y === 0) { |
|
| 408 | + $taille_y = 1; |
|
| 409 | + } # {300,0} -> c'est 300 qui compte |
|
| 410 | + elseif ($taille_x == 0 and $taille_y === 0) { |
|
| 411 | + return ''; |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + list($destWidth, $destHeight, $ratio) = ratio_passe_partout($largeur, $hauteur, $taille_x, $taille_y); |
|
| 415 | + $fonction = ['image_passe_partout', func_get_args()]; |
|
| 416 | + |
|
| 417 | + return process_image_reduire($fonction, $img, $destWidth, $destHeight, $force, $process); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -457,44 +457,44 @@ discard block |
||
| 457 | 457 | * Code HTML de l'image ou du texte. |
| 458 | 458 | **/ |
| 459 | 459 | function image_reduire( |
| 460 | - $img, |
|
| 461 | - $taille = -1, |
|
| 462 | - $taille_y = -1, |
|
| 463 | - $force = false, |
|
| 464 | - $cherche_image = false, |
|
| 465 | - $process = 'AUTO' |
|
| 460 | + $img, |
|
| 461 | + $taille = -1, |
|
| 462 | + $taille_y = -1, |
|
| 463 | + $force = false, |
|
| 464 | + $cherche_image = false, |
|
| 465 | + $process = 'AUTO' |
|
| 466 | 466 | ) { |
| 467 | - // PHP 7+ type hint |
|
| 468 | - $img = (string)$img; |
|
| 469 | - $taille = (int)$taille; |
|
| 470 | - $taille_y = (int)$taille_y; |
|
| 471 | - $force = (bool)$force; |
|
| 472 | - $process = (string)$process; |
|
| 473 | - |
|
| 474 | - // Determiner la taille x,y maxi |
|
| 475 | - // prendre le reglage de previsu par defaut |
|
| 476 | - if ($taille === -1) { |
|
| 477 | - $taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview'])) |
|
| 478 | - ? intval($GLOBALS['meta']['taille_preview']) |
|
| 479 | - : 150; |
|
| 480 | - } |
|
| 481 | - if ($taille_y === -1) { |
|
| 482 | - $taille_y = $taille; |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - if ($taille === 0 and $taille_y > 0) { |
|
| 486 | - $taille = 10000; |
|
| 487 | - } # {0,300} -> c'est 300 qui compte |
|
| 488 | - elseif ($taille > 0 and $taille_y === 0) { |
|
| 489 | - $taille_y = 10000; |
|
| 490 | - } # {300,0} -> c'est 300 qui compte |
|
| 491 | - elseif ($taille == 0 and $taille_y === 0) { |
|
| 492 | - return ''; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - $fonction = ['image_reduire', func_get_args()]; |
|
| 496 | - |
|
| 497 | - return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process); |
|
| 467 | + // PHP 7+ type hint |
|
| 468 | + $img = (string)$img; |
|
| 469 | + $taille = (int)$taille; |
|
| 470 | + $taille_y = (int)$taille_y; |
|
| 471 | + $force = (bool)$force; |
|
| 472 | + $process = (string)$process; |
|
| 473 | + |
|
| 474 | + // Determiner la taille x,y maxi |
|
| 475 | + // prendre le reglage de previsu par defaut |
|
| 476 | + if ($taille === -1) { |
|
| 477 | + $taille = (isset($GLOBALS['meta']['taille_preview']) and intval($GLOBALS['meta']['taille_preview'])) |
|
| 478 | + ? intval($GLOBALS['meta']['taille_preview']) |
|
| 479 | + : 150; |
|
| 480 | + } |
|
| 481 | + if ($taille_y === -1) { |
|
| 482 | + $taille_y = $taille; |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + if ($taille === 0 and $taille_y > 0) { |
|
| 486 | + $taille = 10000; |
|
| 487 | + } # {0,300} -> c'est 300 qui compte |
|
| 488 | + elseif ($taille > 0 and $taille_y === 0) { |
|
| 489 | + $taille_y = 10000; |
|
| 490 | + } # {300,0} -> c'est 300 qui compte |
|
| 491 | + elseif ($taille == 0 and $taille_y === 0) { |
|
| 492 | + return ''; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + $fonction = ['image_reduire', func_get_args()]; |
|
| 496 | + |
|
| 497 | + return process_image_reduire($fonction, $img, $taille, $taille_y, $force, $process); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -505,16 +505,16 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | **/ |
| 507 | 507 | function image_recadre_avec_fallback( |
| 508 | - $im, |
|
| 509 | - $width, |
|
| 510 | - $height = '-', |
|
| 511 | - $position = 'focus', |
|
| 512 | - $background_color = 'white' |
|
| 508 | + $im, |
|
| 509 | + $width, |
|
| 510 | + $height = '-', |
|
| 511 | + $position = 'focus', |
|
| 512 | + $background_color = 'white' |
|
| 513 | 513 | ) { |
| 514 | - if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') { |
|
| 515 | - return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height); |
|
| 516 | - } else { return image_passe_partout($im, $width, $height); |
|
| 517 | - } |
|
| 514 | + if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') { |
|
| 515 | + return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height); |
|
| 516 | + } else { return image_passe_partout($im, $width, $height); |
|
| 517 | + } |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
@@ -532,25 +532,25 @@ discard block |
||
| 532 | 532 | * Code HTML de l'image ou du texte. |
| 533 | 533 | **/ |
| 534 | 534 | function image_reduire_par($img, $val = 1, $force = false) { |
| 535 | - // PHP 7+ type hint |
|
| 536 | - $img = (string)$img; |
|
| 537 | - $val = (int)$val; |
|
| 538 | - $force = (bool)$force; |
|
| 535 | + // PHP 7+ type hint |
|
| 536 | + $img = (string)$img; |
|
| 537 | + $val = (int)$val; |
|
| 538 | + $force = (bool)$force; |
|
| 539 | 539 | |
| 540 | - list($hauteur, $largeur) = taille_image($img); |
|
| 540 | + list($hauteur, $largeur) = taille_image($img); |
|
| 541 | 541 | |
| 542 | - $l = round($largeur / $val); |
|
| 543 | - $h = round($hauteur / $val); |
|
| 542 | + $l = round($largeur / $val); |
|
| 543 | + $h = round($hauteur / $val); |
|
| 544 | 544 | |
| 545 | - if ($l > $h) { |
|
| 546 | - $h = 0; |
|
| 547 | - } else { |
|
| 548 | - $l = 0; |
|
| 549 | - } |
|
| 545 | + if ($l > $h) { |
|
| 546 | + $h = 0; |
|
| 547 | + } else { |
|
| 548 | + $l = 0; |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | - $img = image_reduire($img, $l, $h, $force); |
|
| 551 | + $img = image_reduire($img, $l, $h, $force); |
|
| 552 | 552 | |
| 553 | - return $img; |
|
| 553 | + return $img; |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | /** |
@@ -573,10 +573,10 @@ discard block |
||
| 573 | 573 | * Couleur en écriture hexadécimale. |
| 574 | 574 | **/ |
| 575 | 575 | function filtre_couleur_saturation_dist($couleur, $val, $strict = false) { |
| 576 | - if (function_exists('couleur_saturation')) { |
|
| 577 | - return couleur_saturation($couleur, $val, $strict); |
|
| 578 | - } |
|
| 579 | - return $couleur; |
|
| 576 | + if (function_exists('couleur_saturation')) { |
|
| 577 | + return couleur_saturation($couleur, $val, $strict); |
|
| 578 | + } |
|
| 579 | + return $couleur; |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -597,8 +597,8 @@ discard block |
||
| 597 | 597 | * Couleur en écriture hexadécimale. |
| 598 | 598 | **/ |
| 599 | 599 | function filtre_couleur_luminance_dist($couleur, $val) { |
| 600 | - if (function_exists('couleur_luminance')) { |
|
| 601 | - return couleur_luminance($couleur, $val); |
|
| 602 | - } |
|
| 603 | - return $couleur; |
|
| 600 | + if (function_exists('couleur_luminance')) { |
|
| 601 | + return couleur_luminance($couleur, $val); |
|
| 602 | + } |
|
| 603 | + return $couleur; |
|
| 604 | 604 | } |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | $hsl = _couleur_hex_to_hsl($couleur); |
| 205 | 205 | $hsl = [ |
| 206 | 206 | 'h' => round($hsl['h'] * 360), |
| 207 | - 's' => round($hsl['s'] * 100) . '%', |
|
| 208 | - 'l' => round($hsl['l'] * 100) . '%' |
|
| 207 | + 's' => round($hsl['s'] * 100).'%', |
|
| 208 | + 'l' => round($hsl['l'] * 100).'%' |
|
| 209 | 209 | ]; |
| 210 | 210 | if ($format === null) { |
| 211 | 211 | return "hsl({$hsl['h']}, {$hsl['s']}, {$hsl['l']})"; |
@@ -384,11 +384,11 @@ discard block |
||
| 384 | 384 | $process = 'AUTO' |
| 385 | 385 | ) { |
| 386 | 386 | // PHP 7+ type hint |
| 387 | - $img = (string)$img; |
|
| 388 | - $taille_x = (int)$taille_x; |
|
| 389 | - $taille_y = (int)$taille_y; |
|
| 390 | - $force = (bool)$force; |
|
| 391 | - $process = (string)$process; |
|
| 387 | + $img = (string) $img; |
|
| 388 | + $taille_x = (int) $taille_x; |
|
| 389 | + $taille_y = (int) $taille_y; |
|
| 390 | + $force = (bool) $force; |
|
| 391 | + $process = (string) $process; |
|
| 392 | 392 | |
| 393 | 393 | if (!$img) { |
| 394 | 394 | return ''; |
@@ -465,11 +465,11 @@ discard block |
||
| 465 | 465 | $process = 'AUTO' |
| 466 | 466 | ) { |
| 467 | 467 | // PHP 7+ type hint |
| 468 | - $img = (string)$img; |
|
| 469 | - $taille = (int)$taille; |
|
| 470 | - $taille_y = (int)$taille_y; |
|
| 471 | - $force = (bool)$force; |
|
| 472 | - $process = (string)$process; |
|
| 468 | + $img = (string) $img; |
|
| 469 | + $taille = (int) $taille; |
|
| 470 | + $taille_y = (int) $taille_y; |
|
| 471 | + $force = (bool) $force; |
|
| 472 | + $process = (string) $process; |
|
| 473 | 473 | |
| 474 | 474 | // Determiner la taille x,y maxi |
| 475 | 475 | // prendre le reglage de previsu par defaut |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | $background_color = 'white' |
| 513 | 513 | ) { |
| 514 | 514 | if (function_exists('image_recadre') && ($GLOBALS['meta']['image_process'] ?? '') === 'gd2') { |
| 515 | - return image_reduire(image_recadre($im, $width . ':' . $height, '-', $position, $background_color), $width, $height); |
|
| 515 | + return image_reduire(image_recadre($im, $width.':'.$height, '-', $position, $background_color), $width, $height); |
|
| 516 | 516 | } else { return image_passe_partout($im, $width, $height); |
| 517 | 517 | } |
| 518 | 518 | } |
@@ -533,9 +533,9 @@ discard block |
||
| 533 | 533 | **/ |
| 534 | 534 | function image_reduire_par($img, $val = 1, $force = false) { |
| 535 | 535 | // PHP 7+ type hint |
| 536 | - $img = (string)$img; |
|
| 537 | - $val = (int)$val; |
|
| 538 | - $force = (bool)$force; |
|
| 536 | + $img = (string) $img; |
|
| 537 | + $val = (int) $val; |
|
| 538 | + $force = (bool) $force; |
|
| 539 | 539 | |
| 540 | 540 | list($hauteur, $largeur) = taille_image($img); |
| 541 | 541 | |
@@ -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 | |
| 17 | 17 | include_spip('inc/charsets'); |
@@ -42,22 +42,22 @@ discard block |
||
| 42 | 42 | * @return array |
| 43 | 43 | */ |
| 44 | 44 | function importer_csv_importcharset($texte, $definir_charset_source = false) { |
| 45 | - // le plus frequent, en particulier avec les trucs de ms@@@ |
|
| 46 | - static $charset_source = 'iso-8859-1'; |
|
| 47 | - if ($definir_charset_source) { |
|
| 48 | - if ($definir_charset_source === true) { |
|
| 49 | - $charset_source = 'iso-8859-1'; |
|
| 50 | - } else { |
|
| 51 | - $charset_source = $definir_charset_source; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - // mais open-office sait faire mieux, donc mefiance ! |
|
| 55 | - if (is_utf8($texte)) { |
|
| 56 | - $charset = 'utf-8'; |
|
| 57 | - } else { |
|
| 58 | - $charset = $charset_source; |
|
| 59 | - } |
|
| 60 | - return importer_charset($texte, $charset); |
|
| 45 | + // le plus frequent, en particulier avec les trucs de ms@@@ |
|
| 46 | + static $charset_source = 'iso-8859-1'; |
|
| 47 | + if ($definir_charset_source) { |
|
| 48 | + if ($definir_charset_source === true) { |
|
| 49 | + $charset_source = 'iso-8859-1'; |
|
| 50 | + } else { |
|
| 51 | + $charset_source = $definir_charset_source; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + // mais open-office sait faire mieux, donc mefiance ! |
|
| 55 | + if (is_utf8($texte)) { |
|
| 56 | + $charset = 'utf-8'; |
|
| 57 | + } else { |
|
| 58 | + $charset = $charset_source; |
|
| 59 | + } |
|
| 60 | + return importer_charset($texte, $charset); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return string |
| 69 | 69 | */ |
| 70 | 70 | function importer_csv_nettoie_key($key) { |
| 71 | - return translitteration($key); |
|
| 71 | + return translitteration($key); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -87,77 +87,77 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | function inc_importer_csv_dist($file, $options = []) { |
| 89 | 89 | |
| 90 | - // support ancienne syntaxe |
|
| 91 | - // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '') |
|
| 92 | - if (!is_array($options)) { |
|
| 93 | - $args = func_get_args(); |
|
| 94 | - $options = []; |
|
| 95 | - foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) { |
|
| 96 | - if (!empty($args[$k])) { |
|
| 97 | - $options[$option] = $args[$k]; |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 90 | + // support ancienne syntaxe |
|
| 91 | + // inc_importer_csv_dist($file, $head = false, $delim = ',', $enclos = '"', $len = 10000, $charset_source = '') |
|
| 92 | + if (!is_array($options)) { |
|
| 93 | + $args = func_get_args(); |
|
| 94 | + $options = []; |
|
| 95 | + foreach ([1 => 'head', 2 => 'delim', 3 => 'enclos', 4 => 'len', 5 => 'charset_source'] as $k => $option) { |
|
| 96 | + if (!empty($args[$k])) { |
|
| 97 | + $options[$option] = $args[$k]; |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - $default_options = [ |
|
| 103 | - 'head' => false, |
|
| 104 | - 'delim' => ',', |
|
| 105 | - 'enclos' => '"', |
|
| 106 | - 'len' => 10000, |
|
| 107 | - 'charset_source' => '', |
|
| 108 | - ]; |
|
| 109 | - $options = array_merge($default_options, $options); |
|
| 102 | + $default_options = [ |
|
| 103 | + 'head' => false, |
|
| 104 | + 'delim' => ',', |
|
| 105 | + 'enclos' => '"', |
|
| 106 | + 'len' => 10000, |
|
| 107 | + 'charset_source' => '', |
|
| 108 | + ]; |
|
| 109 | + $options = array_merge($default_options, $options); |
|
| 110 | 110 | |
| 111 | 111 | |
| 112 | - $return = false; |
|
| 113 | - if ( |
|
| 114 | - @file_exists($file) |
|
| 115 | - and $handle = fopen($file, 'r') |
|
| 116 | - ) { |
|
| 117 | - if ($options['charset_source']) { |
|
| 118 | - importer_csv_importcharset('', $options['charset_source']); |
|
| 119 | - } |
|
| 120 | - if ($options['head']) { |
|
| 121 | - $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']); |
|
| 122 | - if ($header) { |
|
| 123 | - $header = array_map('importer_csv_importcharset', $header); |
|
| 124 | - $header = array_map('importer_csv_nettoie_key', $header); |
|
| 125 | - $header_type = []; |
|
| 126 | - foreach ($header as $heading) { |
|
| 127 | - if (!isset($header_type[$heading])) { |
|
| 128 | - $header_type[$heading] = 'scalar'; |
|
| 129 | - } else { |
|
| 130 | - $header_type[$heading] = 'array'; |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - } |
|
| 112 | + $return = false; |
|
| 113 | + if ( |
|
| 114 | + @file_exists($file) |
|
| 115 | + and $handle = fopen($file, 'r') |
|
| 116 | + ) { |
|
| 117 | + if ($options['charset_source']) { |
|
| 118 | + importer_csv_importcharset('', $options['charset_source']); |
|
| 119 | + } |
|
| 120 | + if ($options['head']) { |
|
| 121 | + $header = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos']); |
|
| 122 | + if ($header) { |
|
| 123 | + $header = array_map('importer_csv_importcharset', $header); |
|
| 124 | + $header = array_map('importer_csv_nettoie_key', $header); |
|
| 125 | + $header_type = []; |
|
| 126 | + foreach ($header as $heading) { |
|
| 127 | + if (!isset($header_type[$heading])) { |
|
| 128 | + $header_type[$heading] = 'scalar'; |
|
| 129 | + } else { |
|
| 130 | + $header_type[$heading] = 'array'; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) { |
|
| 137 | - $data = array_map('importer_csv_importcharset', $data); |
|
| 138 | - if ($options['head'] and isset($header)) { |
|
| 139 | - $row = []; |
|
| 140 | - foreach ($header as $key => $heading) { |
|
| 141 | - if ($header_type[$heading] == 'array') { |
|
| 142 | - if (!isset($row[$heading])) { |
|
| 143 | - $row[$heading] = []; |
|
| 144 | - } |
|
| 145 | - if (isset($data[$key]) and strlen($data[$key])) { |
|
| 146 | - $row[$heading][] = $data[$key]; |
|
| 147 | - } |
|
| 148 | - } else { |
|
| 149 | - $row[$heading] = (isset($data[$key])) ? $data[$key] : ''; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - $return[] = $row; |
|
| 153 | - } else { |
|
| 154 | - $return[] = $data; |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - if ($options['charset_source']) { |
|
| 158 | - importer_csv_importcharset('', true); |
|
| 159 | - } |
|
| 160 | - } |
|
| 136 | + while (($data = fgetcsv($handle, $options['len'], $options['delim'], $options['enclos'])) !== false) { |
|
| 137 | + $data = array_map('importer_csv_importcharset', $data); |
|
| 138 | + if ($options['head'] and isset($header)) { |
|
| 139 | + $row = []; |
|
| 140 | + foreach ($header as $key => $heading) { |
|
| 141 | + if ($header_type[$heading] == 'array') { |
|
| 142 | + if (!isset($row[$heading])) { |
|
| 143 | + $row[$heading] = []; |
|
| 144 | + } |
|
| 145 | + if (isset($data[$key]) and strlen($data[$key])) { |
|
| 146 | + $row[$heading][] = $data[$key]; |
|
| 147 | + } |
|
| 148 | + } else { |
|
| 149 | + $row[$heading] = (isset($data[$key])) ? $data[$key] : ''; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + $return[] = $row; |
|
| 153 | + } else { |
|
| 154 | + $return[] = $data; |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + if ($options['charset_source']) { |
|
| 158 | + importer_csv_importcharset('', true); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return $return; |
|
| 162 | + return $return; |
|
| 163 | 163 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | **/ |
| 23 | 23 | |
| 24 | 24 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 25 | - return; |
|
| 25 | + return; |
|
| 26 | 26 | } |
| 27 | 27 | include_spip('inc/filtres'); |
| 28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @return string Rien. |
| 40 | 40 | **/ |
| 41 | 41 | function filtre_image_dist($t) { |
| 42 | - return ''; |
|
| 42 | + return ''; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @return string Rien. |
| 53 | 53 | **/ |
| 54 | 54 | function filtre_audio_dist($t) { |
| 55 | - return ''; |
|
| 55 | + return ''; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @return string Rien. |
| 66 | 66 | **/ |
| 67 | 67 | function filtre_video_dist($t) { |
| 68 | - return ''; |
|
| 68 | + return ''; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return string Rien. |
| 79 | 79 | **/ |
| 80 | 80 | function filtre_application_dist($t) { |
| 81 | - return ''; |
|
| 81 | + return ''; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @return string Rien. |
| 92 | 92 | **/ |
| 93 | 93 | function filtre_message_dist($t) { |
| 94 | - return ''; |
|
| 94 | + return ''; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return string Rien. |
| 105 | 105 | **/ |
| 106 | 106 | function filtre_multipart_dist($t) { |
| 107 | - return ''; |
|
| 107 | + return ''; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | * @return string Contenu échappé. |
| 118 | 118 | **/ |
| 119 | 119 | function filtre_text_dist($t) { |
| 120 | - static $t1 = ['&', '<', '>']; |
|
| 121 | - static $t2 = ['&', '<', '>']; |
|
| 120 | + static $t1 = ['&', '<', '>']; |
|
| 121 | + static $t2 = ['&', '<', '>']; |
|
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 123 | + return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -135,21 +135,21 @@ discard block |
||
| 135 | 135 | * Tableau (formaté en SPIP) |
| 136 | 136 | **/ |
| 137 | 137 | function filtre_text_csv_dist($t) { |
| 138 | - include_spip('inc/csv'); |
|
| 139 | - list($entete, $lignes, $caption) = analyse_csv($t); |
|
| 140 | - foreach ($lignes as &$l) { |
|
| 141 | - $l = join('|', $l); |
|
| 142 | - } |
|
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 149 | - str_replace("\n", "|\n|", $corps); |
|
| 150 | - include_spip('inc/texte'); |
|
| 151 | - |
|
| 152 | - return propre($corps); |
|
| 138 | + include_spip('inc/csv'); |
|
| 139 | + list($entete, $lignes, $caption) = analyse_csv($t); |
|
| 140 | + foreach ($lignes as &$l) { |
|
| 141 | + $l = join('|', $l); |
|
| 142 | + } |
|
| 143 | + $corps = join("\n", $lignes) . "\n"; |
|
| 144 | + $corps = $caption . |
|
| 145 | + "\n|{{" . |
|
| 146 | + join('}}|{{', $entete) . |
|
| 147 | + '}}|' . |
|
| 148 | + "\n|" . |
|
| 149 | + str_replace("\n", "|\n|", $corps); |
|
| 150 | + include_spip('inc/texte'); |
|
| 151 | + |
|
| 152 | + return propre($corps); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -163,33 +163,33 @@ discard block |
||
| 163 | 163 | * @return string Code html sécurisé ou texte échappé |
| 164 | 164 | **/ |
| 165 | 165 | function filtre_text_html_dist($t) { |
| 166 | - if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 167 | - return appliquer_filtre($t, 'text/plain'); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - list(, $h, $t) = $r; |
|
| 171 | - |
|
| 172 | - $style = ''; |
|
| 173 | - // recuperer les styles internes |
|
| 174 | - if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 175 | - $style = join("\n", $r[1]); |
|
| 176 | - } |
|
| 177 | - // ... et externes |
|
| 178 | - |
|
| 179 | - include_spip('inc/distant'); |
|
| 180 | - if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 181 | - foreach ($r[0] as $l) { |
|
| 182 | - preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 183 | - $page = recuperer_url($m[1]); |
|
| 184 | - $page = $page['page'] ?? ''; |
|
| 185 | - $style .= "\n/* $l */\n" |
|
| 186 | - . str_replace('<', '', $page); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 190 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 191 | - |
|
| 192 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 166 | + if (!preg_match(',^(.*?)<body[^>]*>(.*)</body>,is', $t, $r)) { |
|
| 167 | + return appliquer_filtre($t, 'text/plain'); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + list(, $h, $t) = $r; |
|
| 171 | + |
|
| 172 | + $style = ''; |
|
| 173 | + // recuperer les styles internes |
|
| 174 | + if (preg_match_all(',<style>(.*?)</style>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 175 | + $style = join("\n", $r[1]); |
|
| 176 | + } |
|
| 177 | + // ... et externes |
|
| 178 | + |
|
| 179 | + include_spip('inc/distant'); |
|
| 180 | + if (preg_match_all(',<link[^>]+type=.text/css[^>]*>,is', $h, $r, PREG_PATTERN_ORDER)) { |
|
| 181 | + foreach ($r[0] as $l) { |
|
| 182 | + preg_match("/href='([^']*)'/", str_replace('"', "'", $l), $m); |
|
| 183 | + $page = recuperer_url($m[1]); |
|
| 184 | + $page = $page['page'] ?? ''; |
|
| 185 | + $style .= "\n/* $l */\n" |
|
| 186 | + . str_replace('<', '', $page); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
|
| 190 | + $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 191 | + |
|
| 192 | + return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return string Code HTML des balises `<param>` |
| 203 | 203 | **/ |
| 204 | 204 | function filtre_audio_x_pn_realaudio($id) { |
| 205 | - return " |
|
| 205 | + return " |
|
| 206 | 206 | <param name='controls' value='PositionSlider' /> |
| 207 | 207 | <param name='controls' value='ImageWindow' /> |
| 208 | 208 | <param name='controls' value='PlayButton' /> |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | static $t1 = ['&', '<', '>']; |
| 121 | 121 | static $t2 = ['&', '<', '>']; |
| 122 | 122 | |
| 123 | - return '<pre>' . str_replace($t1, $t2, $t) . '</pre>'; |
|
| 123 | + return '<pre>'.str_replace($t1, $t2, $t).'</pre>'; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | foreach ($lignes as &$l) { |
| 141 | 141 | $l = join('|', $l); |
| 142 | 142 | } |
| 143 | - $corps = join("\n", $lignes) . "\n"; |
|
| 144 | - $corps = $caption . |
|
| 145 | - "\n|{{" . |
|
| 146 | - join('}}|{{', $entete) . |
|
| 147 | - '}}|' . |
|
| 148 | - "\n|" . |
|
| 143 | + $corps = join("\n", $lignes)."\n"; |
|
| 144 | + $corps = $caption. |
|
| 145 | + "\n|{{". |
|
| 146 | + join('}}|{{', $entete). |
|
| 147 | + '}}|'. |
|
| 148 | + "\n|". |
|
| 149 | 149 | str_replace("\n", "|\n|", $corps); |
| 150 | 150 | include_spip('inc/texte'); |
| 151 | 151 | |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | // Pourquoi SafeHtml transforme-t-il en texte les scripts dans Body ? |
| 190 | - $t = safehtml(preg_replace(',<script' . '.*?</script>,is', '', $t)); |
|
| 190 | + $t = safehtml(preg_replace(',<script'.'.*?</script>,is', '', $t)); |
|
| 191 | 191 | |
| 192 | - return (!$style ? '' : "\n<style>" . $style . '</style>') . $t; |
|
| 192 | + return (!$style ? '' : "\n<style>".$style.'</style>').$t; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -20,21 +20,21 @@ |
||
| 20 | 20 | * Retourne la liste des menus favoris par défaut ainsi que leur rang |
| 21 | 21 | */ |
| 22 | 22 | function inc_definir_menus_favoris_dist() { |
| 23 | - $liste = [ |
|
| 23 | + $liste = [ |
|
| 24 | 24 | |
| 25 | - // Menu Édition, |
|
| 26 | - 'auteurs' => 1, |
|
| 27 | - 'rubriques' => 2, |
|
| 28 | - 'articles' => 3, |
|
| 25 | + // Menu Édition, |
|
| 26 | + 'auteurs' => 1, |
|
| 27 | + 'rubriques' => 2, |
|
| 28 | + 'articles' => 3, |
|
| 29 | 29 | |
| 30 | - // Menu Maintenance |
|
| 31 | - 'admin_vider' => 1, |
|
| 30 | + // Menu Maintenance |
|
| 31 | + 'admin_vider' => 1, |
|
| 32 | 32 | |
| 33 | - // Menu Configurations |
|
| 34 | - 'configurer_identite' => 1, |
|
| 35 | - 'admin_plugin' => 2, |
|
| 33 | + // Menu Configurations |
|
| 34 | + 'configurer_identite' => 1, |
|
| 35 | + 'admin_plugin' => 2, |
|
| 36 | 36 | |
| 37 | - ]; |
|
| 37 | + ]; |
|
| 38 | 38 | |
| 39 | - return $liste; |
|
| 39 | + return $liste; |
|
| 40 | 40 | } |
@@ -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 | |
| 17 | 17 | include_spip('inc/texte'); |
@@ -19,105 +19,105 @@ discard block |
||
| 19 | 19 | // https://code.spip.net/@inc_plonger_dist |
| 20 | 20 | function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') { |
| 21 | 21 | |
| 22 | - if ($list) { |
|
| 23 | - $id_rubrique = $list[$col - 1]; |
|
| 24 | - } |
|
| 22 | + if ($list) { |
|
| 23 | + $id_rubrique = $list[$col - 1]; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - $ret = ''; |
|
| 26 | + $ret = ''; |
|
| 27 | 27 | |
| 28 | - # recherche les filles et petites-filles de la rubrique donnee |
|
| 29 | - # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 30 | - # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 31 | - # racine... sauf vers elle-meme ou sa propre branche) |
|
| 32 | - $ordre = []; |
|
| 33 | - $rub = []; |
|
| 28 | + # recherche les filles et petites-filles de la rubrique donnee |
|
| 29 | + # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on |
|
| 30 | + # deplace une rubrique, on peut la deplacer partout a partir de la |
|
| 31 | + # racine... sauf vers elle-meme ou sa propre branche) |
|
| 32 | + $ordre = []; |
|
| 33 | + $rub = []; |
|
| 34 | 34 | |
| 35 | - $res = sql_select( |
|
| 36 | - 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 37 | - 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 38 | - 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 35 | + $res = sql_select( |
|
| 36 | + 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
|
| 37 | + 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
|
| 38 | + 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 39 | 39 | AND rub1.id_rubrique!=' . sql_quote($exclu) . ' |
| 40 | 40 | AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')', |
| 41 | - '', |
|
| 42 | - '0+rub1.titre,rub1.titre' |
|
| 43 | - ); |
|
| 41 | + '', |
|
| 42 | + '0+rub1.titre,rub1.titre' |
|
| 43 | + ); |
|
| 44 | 44 | |
| 45 | - while ($row = sql_fetch($res)) { |
|
| 46 | - if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 47 | - $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 48 | - if ($row['id_parent'] == $id_rubrique) { |
|
| 49 | - $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 50 | - if ($row['langue_choisie'] != 'oui') { |
|
| 51 | - $t .= ' <small title="' |
|
| 52 | - . traduire_nom_langue($row['lang']) |
|
| 53 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 54 | - } |
|
| 55 | - $ordre[$row['id_rubrique']] = $t; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 60 | - if ($ordre) { |
|
| 61 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 62 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 63 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 45 | + while ($row = sql_fetch($res)) { |
|
| 46 | + if (autoriser('voir', 'rubrique', $row['id_rubrique'])) { |
|
| 47 | + $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant']; |
|
| 48 | + if ($row['id_parent'] == $id_rubrique) { |
|
| 49 | + $t = trim(typo(supprimer_numero($row['titre']))); |
|
| 50 | + if ($row['langue_choisie'] != 'oui') { |
|
| 51 | + $t .= ' <small title="' |
|
| 52 | + . traduire_nom_langue($row['lang']) |
|
| 53 | + . '">[' . $row['lang'] . ']</small>'; |
|
| 54 | + } |
|
| 55 | + $ordre[$row['id_rubrique']] = $t; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + $next = isset($list[$col]) ? $list[$col] : 0; |
|
| 60 | + if ($ordre) { |
|
| 61 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 62 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 63 | + $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 64 | 64 | |
| 65 | - foreach ($ordre as $id => $titrebrut) { |
|
| 66 | - $titre = supprimer_numero($titrebrut); |
|
| 65 | + foreach ($ordre as $id => $titrebrut) { |
|
| 66 | + $titre = supprimer_numero($titrebrut); |
|
| 67 | 67 | |
| 68 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 69 | - if (isset($rub[$id]['enfants'])) { |
|
| 70 | - $classe2 = " class='rub-ouverte'"; |
|
| 71 | - $url = "\nhref='$rec&id=$id'"; |
|
| 72 | - } else { |
|
| 73 | - $classe2 = $url = ''; |
|
| 74 | - $url = "\nhref='javascript:void(0)'"; |
|
| 75 | - } |
|
| 68 | + $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 69 | + if (isset($rub[$id]['enfants'])) { |
|
| 70 | + $classe2 = " class='rub-ouverte'"; |
|
| 71 | + $url = "\nhref='$rec&id=$id'"; |
|
| 72 | + } else { |
|
| 73 | + $classe2 = $url = ''; |
|
| 74 | + $url = "\nhref='javascript:void(0)'"; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $js_func = $do . '_selection_titre'; |
|
| 78 | - $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 79 | - . (!is_array($list) ? ' false' |
|
| 80 | - : "aff_selection_provisoire($id,$args)") |
|
| 77 | + $js_func = $do . '_selection_titre'; |
|
| 78 | + $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
|
| 79 | + . (!is_array($list) ? ' false' |
|
| 80 | + : "aff_selection_provisoire($id,$args)") |
|
| 81 | 81 | # ce lien provoque la selection (directe) de la rubrique cliquee |
| 82 | 82 | # et l'affichage de son titre dans le bandeau |
| 83 | - . "\"\nondblclick=\"" |
|
| 84 | - . "$js_func(this." |
|
| 85 | - . 'firstChild.nodeValue,' |
|
| 86 | - . $id |
|
| 87 | - . ",'selection_rubrique','id_parent');" |
|
| 88 | - . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 89 | - . '"'; |
|
| 83 | + . "\"\nondblclick=\"" |
|
| 84 | + . "$js_func(this." |
|
| 85 | + . 'firstChild.nodeValue,' |
|
| 86 | + . $id |
|
| 87 | + . ",'selection_rubrique','id_parent');" |
|
| 88 | + . "\nreturn aff_selection_provisoire($id,$args);" |
|
| 89 | + . '"'; |
|
| 90 | 90 | |
| 91 | - $ret .= "<div class='" |
|
| 92 | - . (($id == $next) ? 'item on' : 'item') |
|
| 93 | - . "'><div class='" |
|
| 94 | - . $classe1 |
|
| 95 | - . "'><div$classe2><a" |
|
| 96 | - . $url |
|
| 97 | - . $click |
|
| 98 | - . '>' |
|
| 99 | - . $titre |
|
| 100 | - . '</a></div></div></div>'; |
|
| 101 | - } |
|
| 102 | - } |
|
| 91 | + $ret .= "<div class='" |
|
| 92 | + . (($id == $next) ? 'item on' : 'item') |
|
| 93 | + . "'><div class='" |
|
| 94 | + . $classe1 |
|
| 95 | + . "'><div$classe2><a" |
|
| 96 | + . $url |
|
| 97 | + . $click |
|
| 98 | + . '>' |
|
| 99 | + . $titre |
|
| 100 | + . '</a></div></div></div>'; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $idom2 = $idom . '_col_' . ($col + 1); |
|
| 105 | - $left = ($col * 250); |
|
| 104 | + $idom2 = $idom . '_col_' . ($col + 1); |
|
| 105 | + $left = ($col * 250); |
|
| 106 | 106 | |
| 107 | - return http_img_pack( |
|
| 108 | - 'loader.svg', |
|
| 109 | - '', |
|
| 110 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 111 | - . ($left - 30) |
|
| 112 | - . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 113 | - ) |
|
| 114 | - . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 115 | - . ($left - 250) |
|
| 116 | - . "px;'>" |
|
| 117 | - . $ret |
|
| 118 | - . "\n</div>\n<div id='$idom2'>" |
|
| 119 | - . ($next |
|
| 120 | - ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 121 | - : '') |
|
| 122 | - . "\n</div>"; |
|
| 107 | + return http_img_pack( |
|
| 108 | + 'loader.svg', |
|
| 109 | + '', |
|
| 110 | + "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 111 | + . ($left - 30) |
|
| 112 | + . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
|
| 113 | + ) |
|
| 114 | + . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 115 | + . ($left - 250) |
|
| 116 | + . "px;'>" |
|
| 117 | + . $ret |
|
| 118 | + . "\n</div>\n<div id='$idom2'>" |
|
| 119 | + . ($next |
|
| 120 | + ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu) |
|
| 121 | + : '') |
|
| 122 | + . "\n</div>"; |
|
| 123 | 123 | } |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | $res = sql_select( |
| 36 | 36 | 'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant', |
| 37 | 37 | 'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)', |
| 38 | - 'rub1.id_parent = ' . sql_quote($id_rubrique) . ' |
|
| 39 | - AND rub1.id_rubrique!=' . sql_quote($exclu) . ' |
|
| 40 | - AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')', |
|
| 38 | + 'rub1.id_parent = '.sql_quote($id_rubrique).' |
|
| 39 | + AND rub1.id_rubrique!=' . sql_quote($exclu).' |
|
| 40 | + AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu).')', |
|
| 41 | 41 | '', |
| 42 | 42 | '0+rub1.titre,rub1.titre' |
| 43 | 43 | ); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | if ($row['langue_choisie'] != 'oui') { |
| 51 | 51 | $t .= ' <small title="' |
| 52 | 52 | . traduire_nom_langue($row['lang']) |
| 53 | - . '">[' . $row['lang'] . ']</small>'; |
|
| 53 | + . '">['.$row['lang'].']</small>'; |
|
| 54 | 54 | } |
| 55 | 55 | $ordre[$row['id_rubrique']] = $t; |
| 56 | 56 | } |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | $next = isset($list[$col]) ? $list[$col] : 0; |
| 60 | 60 | if ($ordre) { |
| 61 | - $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1)); |
|
| 61 | + $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1)); |
|
| 62 | 62 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
| 63 | - $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event"; |
|
| 63 | + $args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event"; |
|
| 64 | 64 | |
| 65 | 65 | foreach ($ordre as $id => $titrebrut) { |
| 66 | 66 | $titre = supprimer_numero($titrebrut); |
| 67 | 67 | |
| 68 | - $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 68 | + $classe1 = 'petit-item '.($id_rubrique ? 'petite-rubrique' : 'petit-secteur'); |
|
| 69 | 69 | if (isset($rub[$id]['enfants'])) { |
| 70 | 70 | $classe2 = " class='rub-ouverte'"; |
| 71 | 71 | $url = "\nhref='$rec&id=$id'"; |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $url = "\nhref='javascript:void(0)'"; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $js_func = $do . '_selection_titre'; |
|
| 77 | + $js_func = $do.'_selection_titre'; |
|
| 78 | 78 | $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn " |
| 79 | 79 | . (!is_array($list) ? ' false' |
| 80 | 80 | : "aff_selection_provisoire($id,$args)") |
@@ -101,17 +101,17 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $idom2 = $idom . '_col_' . ($col + 1); |
|
| 104 | + $idom2 = $idom.'_col_'.($col + 1); |
|
| 105 | 105 | $left = ($col * 250); |
| 106 | 106 | |
| 107 | 107 | return http_img_pack( |
| 108 | 108 | 'loader.svg', |
| 109 | 109 | '', |
| 110 | - "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 110 | + "class='loader' style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].': ' |
|
| 111 | 111 | . ($left - 30) |
| 112 | 112 | . "px; top: 2px; z-index: 2;' id='img_$idom2'" |
| 113 | 113 | ) |
| 114 | - . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': ' |
|
| 114 | + . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].': ' |
|
| 115 | 115 | . ($left - 250) |
| 116 | 116 | . "px;'>" |
| 117 | 117 | . $ret |
@@ -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/boutons'); |
@@ -37,33 +37,33 @@ discard block |
||
| 37 | 37 | * Contexte |
| 38 | 38 | **/ |
| 39 | 39 | function definir_barre_contexte($contexte = null) { |
| 40 | - if (is_null($contexte)) { |
|
| 41 | - $contexte = $_GET; |
|
| 42 | - } elseif (is_string($contexte)) { |
|
| 43 | - $contexte = unserialize($contexte); |
|
| 44 | - } |
|
| 45 | - if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | - if (!function_exists('trouver_objet_exec')) { |
|
| 47 | - include_spip('inc/pipelines_ecrire'); |
|
| 48 | - } |
|
| 49 | - if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | - $_id = $e['id_table_objet']; |
|
| 51 | - if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | - $table = $e['table_objet_sql']; |
|
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | - if (isset($row['id_rubrique'])) { |
|
| 55 | - $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | - if (isset($row['id_secteur'])) { |
|
| 57 | - $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | - } |
|
| 59 | - } elseif (isset($row['id_groupe'])) { |
|
| 60 | - // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | - $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $contexte; |
|
| 40 | + if (is_null($contexte)) { |
|
| 41 | + $contexte = $_GET; |
|
| 42 | + } elseif (is_string($contexte)) { |
|
| 43 | + $contexte = unserialize($contexte); |
|
| 44 | + } |
|
| 45 | + if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | + if (!function_exists('trouver_objet_exec')) { |
|
| 47 | + include_spip('inc/pipelines_ecrire'); |
|
| 48 | + } |
|
| 49 | + if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | + $_id = $e['id_table_objet']; |
|
| 51 | + if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | + $table = $e['table_objet_sql']; |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | + if (isset($row['id_rubrique'])) { |
|
| 55 | + $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | + if (isset($row['id_secteur'])) { |
|
| 57 | + $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | + } |
|
| 59 | + } elseif (isset($row['id_groupe'])) { |
|
| 60 | + // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | + $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $contexte; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -79,92 +79,92 @@ discard block |
||
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | 81 | function definir_barre_boutons($contexte = [], $icones = true, $autorise = true) { |
| 82 | - include_spip('inc/autoriser'); |
|
| 83 | - $boutons_admin = []; |
|
| 82 | + include_spip('inc/autoriser'); |
|
| 83 | + $boutons_admin = []; |
|
| 84 | 84 | |
| 85 | - // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | - $liste_boutons = []; |
|
| 85 | + // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | + $liste_boutons = []; |
|
| 87 | 87 | |
| 88 | - // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | - if ( |
|
| 90 | - function_exists('boutons_plugins') |
|
| 91 | - and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 92 | - ) { |
|
| 93 | - $liste_boutons = &$liste_boutons_plugins; |
|
| 94 | - } |
|
| 88 | + // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | + if ( |
|
| 90 | + function_exists('boutons_plugins') |
|
| 91 | + and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 92 | + ) { |
|
| 93 | + $liste_boutons = &$liste_boutons_plugins; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - foreach ($liste_boutons as $id => $infos) { |
|
| 97 | - $parent = ''; |
|
| 98 | - // les boutons principaux ne sont pas soumis a autorisation |
|
| 99 | - if ( |
|
| 100 | - !isset($infos['parent']) |
|
| 101 | - or !($parent = $infos['parent']) |
|
| 102 | - or !$autorise |
|
| 103 | - or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 104 | - ) { |
|
| 105 | - if ( |
|
| 106 | - $parent |
|
| 107 | - and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 108 | - and isset($boutons_admin[$parent]) |
|
| 109 | - ) { |
|
| 110 | - if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 111 | - $boutons_admin[$parent]->sousmenu = []; |
|
| 112 | - } |
|
| 113 | - $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 114 | - if ($position < 0) { |
|
| 115 | - $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 116 | - } |
|
| 117 | - $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 118 | - + [ |
|
| 119 | - $id => new Bouton( |
|
| 120 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | - $infos['titre'], // titre |
|
| 122 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 123 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 124 | - ) |
|
| 125 | - ] |
|
| 126 | - + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 127 | - } |
|
| 128 | - if ( |
|
| 129 | - !$parent |
|
| 130 | - // provisoire, eviter les vieux boutons |
|
| 131 | - and (!in_array($id, ['forum', 'statistiques_visites'])) |
|
| 132 | - and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 133 | - ) { |
|
| 134 | - $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 135 | - $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 136 | - + [ |
|
| 137 | - $id => new Bouton( |
|
| 138 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | - $infos['titre'], // titre |
|
| 140 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 141 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 142 | - ) |
|
| 143 | - ] |
|
| 144 | - + array_slice($boutons_admin, $position, 100); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 96 | + foreach ($liste_boutons as $id => $infos) { |
|
| 97 | + $parent = ''; |
|
| 98 | + // les boutons principaux ne sont pas soumis a autorisation |
|
| 99 | + if ( |
|
| 100 | + !isset($infos['parent']) |
|
| 101 | + or !($parent = $infos['parent']) |
|
| 102 | + or !$autorise |
|
| 103 | + or autoriser('menu', "_$id", 0, null, ['contexte' => $contexte]) |
|
| 104 | + ) { |
|
| 105 | + if ( |
|
| 106 | + $parent |
|
| 107 | + and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 108 | + and isset($boutons_admin[$parent]) |
|
| 109 | + ) { |
|
| 110 | + if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 111 | + $boutons_admin[$parent]->sousmenu = []; |
|
| 112 | + } |
|
| 113 | + $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 114 | + if ($position < 0) { |
|
| 115 | + $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 116 | + } |
|
| 117 | + $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 118 | + + [ |
|
| 119 | + $id => new Bouton( |
|
| 120 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | + $infos['titre'], // titre |
|
| 122 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 123 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 124 | + ) |
|
| 125 | + ] |
|
| 126 | + + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 127 | + } |
|
| 128 | + if ( |
|
| 129 | + !$parent |
|
| 130 | + // provisoire, eviter les vieux boutons |
|
| 131 | + and (!in_array($id, ['forum', 'statistiques_visites'])) |
|
| 132 | + and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, ['contexte' => $contexte])) |
|
| 133 | + ) { |
|
| 134 | + $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 135 | + $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 136 | + + [ |
|
| 137 | + $id => new Bouton( |
|
| 138 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | + $infos['titre'], // titre |
|
| 140 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 141 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 142 | + ) |
|
| 143 | + ] |
|
| 144 | + + array_slice($boutons_admin, $position, 100); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 149 | 149 | |
| 150 | - // définir les favoris et positions d’origine |
|
| 151 | - if ($boutons_admin) { |
|
| 152 | - $menus_favoris = obtenir_menus_favoris(); |
|
| 153 | - $i = 1; |
|
| 154 | - foreach ($boutons_admin as $key => $menu) { |
|
| 155 | - $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 156 | - $menu->position = $i++; |
|
| 157 | - if ($menu->sousmenu) { |
|
| 158 | - $j = 1; |
|
| 159 | - foreach ($menu->sousmenu as $key => $bouton) { |
|
| 160 | - $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 161 | - $bouton->position = $j++; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - } |
|
| 150 | + // définir les favoris et positions d’origine |
|
| 151 | + if ($boutons_admin) { |
|
| 152 | + $menus_favoris = obtenir_menus_favoris(); |
|
| 153 | + $i = 1; |
|
| 154 | + foreach ($boutons_admin as $key => $menu) { |
|
| 155 | + $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 156 | + $menu->position = $i++; |
|
| 157 | + if ($menu->sousmenu) { |
|
| 158 | + $j = 1; |
|
| 159 | + foreach ($menu->sousmenu as $key => $bouton) { |
|
| 160 | + $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 161 | + $bouton->position = $j++; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - return $boutons_admin; |
|
| 167 | + return $boutons_admin; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | * @return Bouton[] |
| 177 | 177 | */ |
| 178 | 178 | function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) { |
| 179 | - foreach ($menus as $menu) { |
|
| 180 | - if ($menu->sousmenu) { |
|
| 181 | - $libelles = $isfavoris = $favoris = []; |
|
| 182 | - foreach ($menu->sousmenu as $key => $item) { |
|
| 183 | - $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 184 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 185 | - $favoris[$key] = $item->favori; |
|
| 186 | - } |
|
| 187 | - if ($avec_favoris) { |
|
| 188 | - array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 189 | - } else { |
|
| 190 | - array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - return $menus; |
|
| 179 | + foreach ($menus as $menu) { |
|
| 180 | + if ($menu->sousmenu) { |
|
| 181 | + $libelles = $isfavoris = $favoris = []; |
|
| 182 | + foreach ($menu->sousmenu as $key => $item) { |
|
| 183 | + $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 184 | + $isfavoris[$key] = (bool)$item->favori; |
|
| 185 | + $favoris[$key] = $item->favori; |
|
| 186 | + } |
|
| 187 | + if ($avec_favoris) { |
|
| 188 | + array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 189 | + } else { |
|
| 190 | + array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + return $menus; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return Bouton[] |
| 203 | 203 | */ |
| 204 | 204 | function trier_boutons_enfants_par_favoris_alpha($menus) { |
| 205 | - return trier_boutons_enfants_par_alpha($menus, true); |
|
| 205 | + return trier_boutons_enfants_par_alpha($menus, true); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
@@ -215,23 +215,23 @@ discard block |
||
| 215 | 215 | * @return string |
| 216 | 216 | */ |
| 217 | 217 | function bandeau_creer_url($url, $args = '', $contexte = null) { |
| 218 | - if (!preg_match(',[\/\?],', $url)) { |
|
| 219 | - $url = generer_url_ecrire($url, $args, true); |
|
| 220 | - // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 221 | - // &truc=@machin@ |
|
| 222 | - // @machin@ etant remplace par _request('machin') |
|
| 223 | - $url = str_replace('&', '&', $url); |
|
| 224 | - while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 225 | - if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 226 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 227 | - } |
|
| 228 | - $val = _request($matches[2], $contexte); |
|
| 229 | - $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 230 | - } |
|
| 231 | - $url = str_replace('&', '&', $url); |
|
| 232 | - } |
|
| 218 | + if (!preg_match(',[\/\?],', $url)) { |
|
| 219 | + $url = generer_url_ecrire($url, $args, true); |
|
| 220 | + // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 221 | + // &truc=@machin@ |
|
| 222 | + // @machin@ etant remplace par _request('machin') |
|
| 223 | + $url = str_replace('&', '&', $url); |
|
| 224 | + while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 225 | + if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 226 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 227 | + } |
|
| 228 | + $val = _request($matches[2], $contexte); |
|
| 229 | + $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 230 | + } |
|
| 231 | + $url = str_replace('&', '&', $url); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - return $url; |
|
| 234 | + return $url; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * Code HTML du bandeau |
| 242 | 242 | */ |
| 243 | 243 | function inc_bandeau_dist() { |
| 244 | - return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 244 | + return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
@@ -250,13 +250,13 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function obtenir_menus_favoris() { |
| 253 | - if ( |
|
| 254 | - isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 255 | - and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 256 | - and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 257 | - ) { |
|
| 258 | - return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 259 | - } |
|
| 260 | - $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 261 | - return $definir_menus_favoris(); |
|
| 253 | + if ( |
|
| 254 | + isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 255 | + and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 256 | + and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 257 | + ) { |
|
| 258 | + return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 259 | + } |
|
| 260 | + $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 261 | + return $definir_menus_favoris(); |
|
| 262 | 262 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $_id = $e['id_table_objet']; |
| 51 | 51 | if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
| 52 | 52 | $table = $e['table_objet_sql']; |
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=".intval($id)); |
|
| 54 | 54 | if (isset($row['id_rubrique'])) { |
| 55 | 55 | $contexte['id_rubrique'] = $row['id_rubrique']; |
| 56 | 56 | if (isset($row['id_secteur'])) { |
@@ -117,8 +117,8 @@ discard block |
||
| 117 | 117 | $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
| 118 | 118 | + [ |
| 119 | 119 | $id => new Bouton( |
| 120 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | - $infos['titre'], // titre |
|
| 120 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 121 | + $infos['titre'], // titre |
|
| 122 | 122 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 123 | 123 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 124 | 124 | ) |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | $boutons_admin = array_slice($boutons_admin, 0, $position) |
| 136 | 136 | + [ |
| 137 | 137 | $id => new Bouton( |
| 138 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | - $infos['titre'], // titre |
|
| 138 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 139 | + $infos['titre'], // titre |
|
| 140 | 140 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 141 | 141 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 142 | 142 | ) |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $libelles = $isfavoris = $favoris = []; |
| 182 | 182 | foreach ($menu->sousmenu as $key => $item) { |
| 183 | 183 | $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
| 184 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 184 | + $isfavoris[$key] = (bool) $item->favori; |
|
| 185 | 185 | $favoris[$key] = $item->favori; |
| 186 | 186 | } |
| 187 | 187 | if ($avec_favoris) { |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | $url = str_replace('&', '&', $url); |
| 224 | 224 | while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
| 225 | 225 | if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
| 226 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 226 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($contexte['id_rubrique'])); |
|
| 227 | 227 | } |
| 228 | 228 | $val = _request($matches[2], $contexte); |
| 229 | 229 | $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
@@ -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 | include_spip('base/objets'); |
| 23 | 23 | |
@@ -57,115 +57,115 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | */ |
| 59 | 59 | function urls_decoder_url($url, $fond = '', $contexte = [], $assembler = false) { |
| 60 | - static $current_base = null; |
|
| 60 | + static $current_base = null; |
|
| 61 | 61 | |
| 62 | - // les anciennes fonctions modifient directement les globales |
|
| 63 | - // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | - $save = [ |
|
| 65 | - isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null, |
|
| 66 | - isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null, |
|
| 67 | - isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null, |
|
| 68 | - isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null, |
|
| 69 | - $GLOBALS['profondeur_url'] |
|
| 70 | - ]; |
|
| 62 | + // les anciennes fonctions modifient directement les globales |
|
| 63 | + // on les sauve avant l'appel, et on les retablit apres ! |
|
| 64 | + $save = [ |
|
| 65 | + isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null, |
|
| 66 | + isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null, |
|
| 67 | + isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null, |
|
| 68 | + isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null, |
|
| 69 | + $GLOBALS['profondeur_url'] |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | - if (is_null($current_base)) { |
|
| 73 | - include_spip('inc/filtres_mini'); |
|
| 74 | - // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | - $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './'); |
|
| 76 | - } |
|
| 77 | - if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | - $url = substr($url, strlen($current_base)); |
|
| 79 | - } |
|
| 72 | + if (is_null($current_base)) { |
|
| 73 | + include_spip('inc/filtres_mini'); |
|
| 74 | + // le decodage des urls se fait toujours par rapport au site public |
|
| 75 | + $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './'); |
|
| 76 | + } |
|
| 77 | + if (strncmp($url, $current_base, strlen($current_base)) == 0) { |
|
| 78 | + $url = substr($url, strlen($current_base)); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // si on est en train d'assembler la page principale, |
|
| 82 | - // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | - // sinon extraire la bonne portion d'url |
|
| 84 | - if ($assembler) { |
|
| 85 | - if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | - $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | - } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | - $url = $_ENV['url_propre']; |
|
| 89 | - } else { |
|
| 90 | - $qs = explode('?', $url); |
|
| 91 | - // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | - $url = ltrim($qs[0], '/'); |
|
| 93 | - $url = explode('/', $url); |
|
| 94 | - while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | - array_shift($url); |
|
| 96 | - } |
|
| 97 | - $qs[0] = implode('/', $url); |
|
| 98 | - $url = implode('?', $qs); |
|
| 99 | - } |
|
| 100 | - } |
|
| 81 | + // si on est en train d'assembler la page principale, |
|
| 82 | + // recuperer l'url depuis les globales url propres si fournies |
|
| 83 | + // sinon extraire la bonne portion d'url |
|
| 84 | + if ($assembler) { |
|
| 85 | + if (isset($_SERVER['REDIRECT_url_propre'])) { |
|
| 86 | + $url = $_SERVER['REDIRECT_url_propre']; |
|
| 87 | + } elseif (isset($_ENV['url_propre'])) { |
|
| 88 | + $url = $_ENV['url_propre']; |
|
| 89 | + } else { |
|
| 90 | + $qs = explode('?', $url); |
|
| 91 | + // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee |
|
| 92 | + $url = ltrim($qs[0], '/'); |
|
| 93 | + $url = explode('/', $url); |
|
| 94 | + while (count($url) > $GLOBALS['profondeur_url'] + 1) { |
|
| 95 | + array_shift($url); |
|
| 96 | + } |
|
| 97 | + $qs[0] = implode('/', $url); |
|
| 98 | + $url = implode('?', $qs); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | - unset($_ENV['url_propre']); |
|
| 104 | - include_spip('inc/filtres_mini'); |
|
| 105 | - if (strpos($url, '://') === false) { |
|
| 106 | - $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | - } else { |
|
| 108 | - $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | - } |
|
| 102 | + unset($_SERVER['REDIRECT_url_propre']); |
|
| 103 | + unset($_ENV['url_propre']); |
|
| 104 | + include_spip('inc/filtres_mini'); |
|
| 105 | + if (strpos($url, '://') === false) { |
|
| 106 | + $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/'); |
|
| 107 | + } else { |
|
| 108 | + $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/')); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - $url_redirect = ''; |
|
| 112 | - $renommer = generer_url_entite('', '', '', '', true); |
|
| 113 | - if (!$renommer and !function_exists('recuperer_parametres_url')) { |
|
| 114 | - $renommer = charger_fonction('page', 'urls'); |
|
| 115 | - } // fallback pour decoder l'url |
|
| 116 | - if ($renommer) { |
|
| 117 | - $a = $renommer($url, $fond, $contexte); |
|
| 118 | - if (is_array($a)) { |
|
| 119 | - list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 120 | - if ($url_redirect == $url) { |
|
| 121 | - $url_redirect = ''; |
|
| 122 | - } // securite pour eviter une redirection infinie |
|
| 123 | - if ($assembler and strlen($url_redirect)) { |
|
| 124 | - spip_log("Redirige $url vers $url_redirect"); |
|
| 125 | - include_spip('inc/headers'); |
|
| 126 | - redirige_par_entete($url_redirect, '', 301); |
|
| 127 | - } |
|
| 128 | - if (isset($nfond)) { |
|
| 129 | - $fond = $nfond; |
|
| 130 | - } else { |
|
| 131 | - if ( |
|
| 132 | - $fond == '' |
|
| 133 | - or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 134 | - ) { |
|
| 135 | - $fond = $type; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - if (isset($ncontexte)) { |
|
| 139 | - $contexte = $ncontexte; |
|
| 140 | - } |
|
| 141 | - if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 142 | - $contexte['type'] = $type; |
|
| 143 | - } |
|
| 144 | - if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 145 | - $contexte['type-page'] = $type; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } // compatibilite <= 1.9.2 |
|
| 149 | - elseif (function_exists('recuperer_parametres_url')) { |
|
| 150 | - $GLOBALS['fond'] = $fond; |
|
| 151 | - $GLOBALS['contexte'] = $contexte; |
|
| 152 | - recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 153 | - // fond est en principe modifiee directement |
|
| 154 | - $contexte = $GLOBALS['contexte']; |
|
| 155 | - } |
|
| 111 | + $url_redirect = ''; |
|
| 112 | + $renommer = generer_url_entite('', '', '', '', true); |
|
| 113 | + if (!$renommer and !function_exists('recuperer_parametres_url')) { |
|
| 114 | + $renommer = charger_fonction('page', 'urls'); |
|
| 115 | + } // fallback pour decoder l'url |
|
| 116 | + if ($renommer) { |
|
| 117 | + $a = $renommer($url, $fond, $contexte); |
|
| 118 | + if (is_array($a)) { |
|
| 119 | + list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null); |
|
| 120 | + if ($url_redirect == $url) { |
|
| 121 | + $url_redirect = ''; |
|
| 122 | + } // securite pour eviter une redirection infinie |
|
| 123 | + if ($assembler and strlen($url_redirect)) { |
|
| 124 | + spip_log("Redirige $url vers $url_redirect"); |
|
| 125 | + include_spip('inc/headers'); |
|
| 126 | + redirige_par_entete($url_redirect, '', 301); |
|
| 127 | + } |
|
| 128 | + if (isset($nfond)) { |
|
| 129 | + $fond = $nfond; |
|
| 130 | + } else { |
|
| 131 | + if ( |
|
| 132 | + $fond == '' |
|
| 133 | + or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */ |
|
| 134 | + ) { |
|
| 135 | + $fond = $type; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + if (isset($ncontexte)) { |
|
| 139 | + $contexte = $ncontexte; |
|
| 140 | + } |
|
| 141 | + if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) { |
|
| 142 | + $contexte['type'] = $type; |
|
| 143 | + } |
|
| 144 | + if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) { |
|
| 145 | + $contexte['type-page'] = $type; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } // compatibilite <= 1.9.2 |
|
| 149 | + elseif (function_exists('recuperer_parametres_url')) { |
|
| 150 | + $GLOBALS['fond'] = $fond; |
|
| 151 | + $GLOBALS['contexte'] = $contexte; |
|
| 152 | + recuperer_parametres_url($fond, nettoyer_uri()); |
|
| 153 | + // fond est en principe modifiee directement |
|
| 154 | + $contexte = $GLOBALS['contexte']; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - // retablir les globales |
|
| 158 | - list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save; |
|
| 157 | + // retablir les globales |
|
| 158 | + list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save; |
|
| 159 | 159 | |
| 160 | - // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 161 | - // d'inversion url => objet |
|
| 162 | - // maintenir pour compat ? |
|
| 163 | - #if ($assembler) { |
|
| 164 | - # unset($_SERVER['REDIRECT_url_propre']); |
|
| 165 | - # unset($_ENV['url_propre']); |
|
| 166 | - #} |
|
| 160 | + // vider les globales url propres qui ne doivent plus etre utilisees en cas |
|
| 161 | + // d'inversion url => objet |
|
| 162 | + // maintenir pour compat ? |
|
| 163 | + #if ($assembler) { |
|
| 164 | + # unset($_SERVER['REDIRECT_url_propre']); |
|
| 165 | + # unset($_ENV['url_propre']); |
|
| 166 | + #} |
|
| 167 | 167 | |
| 168 | - return [$fond, $contexte, $url_redirect]; |
|
| 168 | + return [$fond, $contexte, $url_redirect]; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
@@ -179,24 +179,24 @@ discard block |
||
| 179 | 179 | * @return string|array |
| 180 | 180 | */ |
| 181 | 181 | function urls_liste_objets($preg = true) { |
| 182 | - static $url_objets = null; |
|
| 183 | - if (is_null($url_objets)) { |
|
| 184 | - $url_objets = []; |
|
| 185 | - // recuperer les tables_objets_sql declarees |
|
| 186 | - $tables_objets = lister_tables_objets_sql(); |
|
| 187 | - foreach ($tables_objets as $t => $infos) { |
|
| 188 | - if ($infos['page']) { |
|
| 189 | - $url_objets[] = $infos['type']; |
|
| 190 | - $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 194 | - } |
|
| 195 | - if (!$preg) { |
|
| 196 | - return $url_objets; |
|
| 197 | - } |
|
| 182 | + static $url_objets = null; |
|
| 183 | + if (is_null($url_objets)) { |
|
| 184 | + $url_objets = []; |
|
| 185 | + // recuperer les tables_objets_sql declarees |
|
| 186 | + $tables_objets = lister_tables_objets_sql(); |
|
| 187 | + foreach ($tables_objets as $t => $infos) { |
|
| 188 | + if ($infos['page']) { |
|
| 189 | + $url_objets[] = $infos['type']; |
|
| 190 | + $url_objets = array_merge($url_objets, $infos['type_surnoms']); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + $url_objets = pipeline('declarer_url_objets', $url_objets); |
|
| 194 | + } |
|
| 195 | + if (!$preg) { |
|
| 196 | + return $url_objets; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - return implode('|', array_map('preg_quote', $url_objets)); |
|
| 199 | + return implode('|', array_map('preg_quote', $url_objets)); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | /** |
@@ -210,26 +210,26 @@ discard block |
||
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | 212 | function nettoyer_url_page($url, $contexte = []) { |
| 213 | - $url_objets = urls_liste_objets(); |
|
| 214 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 213 | + $url_objets = urls_liste_objets(); |
|
| 214 | + $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | + $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 217 | 217 | |
| 218 | - if ( |
|
| 219 | - preg_match($raccourci_url_page_html, $url, $regs) |
|
| 220 | - or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 221 | - or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 222 | - ) { |
|
| 223 | - $regs = array_pad($regs, 4, null); |
|
| 224 | - $type = objet_type($regs[1]); |
|
| 225 | - $_id = id_table_objet($type); |
|
| 226 | - $contexte[$_id] = $regs[2]; |
|
| 227 | - $suite = $regs[3]; |
|
| 218 | + if ( |
|
| 219 | + preg_match($raccourci_url_page_html, $url, $regs) |
|
| 220 | + or preg_match($raccourci_url_page_id, $url, $regs) |
|
| 221 | + or preg_match($raccourci_url_page_spip, $url, $regs) |
|
| 222 | + ) { |
|
| 223 | + $regs = array_pad($regs, 4, null); |
|
| 224 | + $type = objet_type($regs[1]); |
|
| 225 | + $_id = id_table_objet($type); |
|
| 226 | + $contexte[$_id] = $regs[2]; |
|
| 227 | + $suite = $regs[3]; |
|
| 228 | 228 | |
| 229 | - return [$contexte, $type, null, $type, $suite]; |
|
| 230 | - } |
|
| 229 | + return [$contexte, $type, null, $type, $suite]; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - return []; |
|
| 232 | + return []; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | /** |
@@ -248,33 +248,33 @@ discard block |
||
| 248 | 248 | * |
| 249 | 249 | */ |
| 250 | 250 | function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, $connect = '') { |
| 251 | - static $furls = []; |
|
| 252 | - if (!isset($furls[$objet])) { |
|
| 253 | - if ( |
|
| 254 | - function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 255 | - // ou definie par un plugin |
|
| 256 | - or $f = charger_fonction($f, 'urls', true) |
|
| 257 | - ) { |
|
| 258 | - $furls[$objet] = $f; |
|
| 259 | - } else { |
|
| 260 | - $furls[$objet] = ''; |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - if ($furls[$objet]) { |
|
| 264 | - return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 265 | - } |
|
| 266 | - // si pas de flag public fourni |
|
| 267 | - // le calculer en fonction de la declaration de statut |
|
| 268 | - if (is_null($public) and !$connect) { |
|
| 269 | - $public = objet_test_si_publie($objet, $id, $connect); |
|
| 270 | - } |
|
| 271 | - if ($public or $connect) { |
|
| 272 | - return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 273 | - } |
|
| 274 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 275 | - if (!function_exists('objet_info')) { |
|
| 276 | - include_spip('inc/filtres'); |
|
| 277 | - } |
|
| 251 | + static $furls = []; |
|
| 252 | + if (!isset($furls[$objet])) { |
|
| 253 | + if ( |
|
| 254 | + function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 255 | + // ou definie par un plugin |
|
| 256 | + or $f = charger_fonction($f, 'urls', true) |
|
| 257 | + ) { |
|
| 258 | + $furls[$objet] = $f; |
|
| 259 | + } else { |
|
| 260 | + $furls[$objet] = ''; |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + if ($furls[$objet]) { |
|
| 264 | + return $furls[$objet]($id, $args, $ancre, $public, $connect); |
|
| 265 | + } |
|
| 266 | + // si pas de flag public fourni |
|
| 267 | + // le calculer en fonction de la declaration de statut |
|
| 268 | + if (is_null($public) and !$connect) { |
|
| 269 | + $public = objet_test_si_publie($objet, $id, $connect); |
|
| 270 | + } |
|
| 271 | + if ($public or $connect) { |
|
| 272 | + return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
|
| 273 | + } |
|
| 274 | + $a = id_table_objet($objet) . '=' . intval($id); |
|
| 275 | + if (!function_exists('objet_info')) { |
|
| 276 | + include_spip('inc/filtres'); |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 279 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 280 | 280 | } |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function nettoyer_url_page($url, $contexte = []) { |
| 213 | 213 | $url_objets = urls_liste_objets(); |
| 214 | - $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | - $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | - $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,'; |
|
| 214 | + $raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,'; |
|
| 215 | + $raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,'; |
|
| 216 | + $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,'; |
|
| 217 | 217 | |
| 218 | 218 | if ( |
| 219 | 219 | preg_match($raccourci_url_page_html, $url, $regs) |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | static $furls = []; |
| 252 | 252 | if (!isset($furls[$objet])) { |
| 253 | 253 | if ( |
| 254 | - function_exists($f = 'generer_url_ecrire_' . $objet) |
|
| 254 | + function_exists($f = 'generer_url_ecrire_'.$objet) |
|
| 255 | 255 | // ou definie par un plugin |
| 256 | 256 | or $f = charger_fonction($f, 'urls', true) |
| 257 | 257 | ) { |
@@ -271,10 +271,10 @@ discard block |
||
| 271 | 271 | if ($public or $connect) { |
| 272 | 272 | return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect); |
| 273 | 273 | } |
| 274 | - $a = id_table_objet($objet) . '=' . intval($id); |
|
| 274 | + $a = id_table_objet($objet).'='.intval($id); |
|
| 275 | 275 | if (!function_exists('objet_info')) { |
| 276 | 276 | include_spip('inc/filtres'); |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : ''); |
|
| 279 | + return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : ''); |
|
| 280 | 280 | } |