@@ -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/xml'); |
@@ -19,208 +19,208 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | // http://code.spip.net/@plugin_verifie_conformite |
| 21 | 21 | function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) { |
| 22 | - static $etats = array('dev', 'experimental', 'test', 'stable'); |
|
| 22 | + static $etats = array('dev', 'experimental', 'test', 'stable'); |
|
| 23 | 23 | |
| 24 | - $matches = array(); |
|
| 25 | - $silence = false; |
|
| 26 | - $p = null; |
|
| 27 | - // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 28 | - if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) { |
|
| 29 | - // version de SPIP |
|
| 30 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 31 | - foreach ($matches as $tag => $sous) { |
|
| 32 | - list($tagname, $atts) = spip_xml_decompose_tag($tag); |
|
| 33 | - if ($tagname == 'plugin' and is_array($sous)) { |
|
| 34 | - // On rajoute la condition sur $n : |
|
| 35 | - // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 36 | - // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 37 | - // de la meme facon. |
|
| 38 | - if (!isset($atts['spip']) |
|
| 39 | - or $n == 1 |
|
| 40 | - or plugin_version_compatible($atts['spip'], $vspip, 'spip') |
|
| 41 | - ) { |
|
| 42 | - // on prend la derniere declaration avec ce nom |
|
| 43 | - $p = end($sous); |
|
| 44 | - $compat_spip = isset($atts['spip']) ? $atts['spip'] : ''; |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - if (is_null($p)) { |
|
| 50 | - $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug")); |
|
| 51 | - $silence = true; |
|
| 52 | - } else { |
|
| 53 | - $arbre = $p; |
|
| 54 | - } |
|
| 55 | - if (!is_array($arbre)) { |
|
| 56 | - $arbre = array(); |
|
| 57 | - } |
|
| 58 | - // verification de la conformite du plugin avec quelques |
|
| 59 | - // precautions elementaires |
|
| 60 | - if (!isset($arbre['nom'])) { |
|
| 61 | - if (!$silence) { |
|
| 62 | - $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 63 | - } |
|
| 64 | - $arbre['nom'] = array(""); |
|
| 65 | - } |
|
| 66 | - if (!isset($arbre['version'])) { |
|
| 67 | - if (!$silence) { |
|
| 68 | - $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 69 | - } |
|
| 70 | - $arbre['version'] = array(""); |
|
| 71 | - } |
|
| 72 | - if (!isset($arbre['prefix'])) { |
|
| 73 | - if (!$silence) { |
|
| 74 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 75 | - } |
|
| 76 | - $arbre['prefix'] = array(""); |
|
| 77 | - } else { |
|
| 78 | - $prefix = trim(end($arbre['prefix'])); |
|
| 79 | - if (strtoupper($prefix) == 'SPIP' and $plug != "./") { |
|
| 80 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 81 | - } |
|
| 82 | - if (isset($arbre['etat'])) { |
|
| 83 | - $etat = trim(end($arbre['etat'])); |
|
| 84 | - if (!in_array($etat, $etats)) { |
|
| 85 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 86 | - } |
|
| 87 | - } |
|
| 88 | - if (isset($arbre['options'])) { |
|
| 89 | - foreach ($arbre['options'] as $optfile) { |
|
| 90 | - $optfile = trim($optfile); |
|
| 91 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 92 | - if (!$silence) { |
|
| 93 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - if (isset($arbre['fonctions'])) { |
|
| 99 | - foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | - $optfile = trim($optfile); |
|
| 101 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 102 | - if (!$silence) { |
|
| 103 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - $fonctions = array(); |
|
| 109 | - if (isset($arbre['fonctions'])) { |
|
| 110 | - $fonctions = $arbre['fonctions']; |
|
| 111 | - } |
|
| 112 | - $liste_methodes_reservees = array( |
|
| 113 | - '__construct', |
|
| 114 | - '__destruct', |
|
| 115 | - 'plugin', |
|
| 116 | - 'install', |
|
| 117 | - 'uninstall', |
|
| 118 | - strtolower($prefix) |
|
| 119 | - ); |
|
| 24 | + $matches = array(); |
|
| 25 | + $silence = false; |
|
| 26 | + $p = null; |
|
| 27 | + // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 28 | + if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) { |
|
| 29 | + // version de SPIP |
|
| 30 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 31 | + foreach ($matches as $tag => $sous) { |
|
| 32 | + list($tagname, $atts) = spip_xml_decompose_tag($tag); |
|
| 33 | + if ($tagname == 'plugin' and is_array($sous)) { |
|
| 34 | + // On rajoute la condition sur $n : |
|
| 35 | + // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 36 | + // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 37 | + // de la meme facon. |
|
| 38 | + if (!isset($atts['spip']) |
|
| 39 | + or $n == 1 |
|
| 40 | + or plugin_version_compatible($atts['spip'], $vspip, 'spip') |
|
| 41 | + ) { |
|
| 42 | + // on prend la derniere declaration avec ce nom |
|
| 43 | + $p = end($sous); |
|
| 44 | + $compat_spip = isset($atts['spip']) ? $atts['spip'] : ''; |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + if (is_null($p)) { |
|
| 50 | + $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug")); |
|
| 51 | + $silence = true; |
|
| 52 | + } else { |
|
| 53 | + $arbre = $p; |
|
| 54 | + } |
|
| 55 | + if (!is_array($arbre)) { |
|
| 56 | + $arbre = array(); |
|
| 57 | + } |
|
| 58 | + // verification de la conformite du plugin avec quelques |
|
| 59 | + // precautions elementaires |
|
| 60 | + if (!isset($arbre['nom'])) { |
|
| 61 | + if (!$silence) { |
|
| 62 | + $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 63 | + } |
|
| 64 | + $arbre['nom'] = array(""); |
|
| 65 | + } |
|
| 66 | + if (!isset($arbre['version'])) { |
|
| 67 | + if (!$silence) { |
|
| 68 | + $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 69 | + } |
|
| 70 | + $arbre['version'] = array(""); |
|
| 71 | + } |
|
| 72 | + if (!isset($arbre['prefix'])) { |
|
| 73 | + if (!$silence) { |
|
| 74 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 75 | + } |
|
| 76 | + $arbre['prefix'] = array(""); |
|
| 77 | + } else { |
|
| 78 | + $prefix = trim(end($arbre['prefix'])); |
|
| 79 | + if (strtoupper($prefix) == 'SPIP' and $plug != "./") { |
|
| 80 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 81 | + } |
|
| 82 | + if (isset($arbre['etat'])) { |
|
| 83 | + $etat = trim(end($arbre['etat'])); |
|
| 84 | + if (!in_array($etat, $etats)) { |
|
| 85 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 86 | + } |
|
| 87 | + } |
|
| 88 | + if (isset($arbre['options'])) { |
|
| 89 | + foreach ($arbre['options'] as $optfile) { |
|
| 90 | + $optfile = trim($optfile); |
|
| 91 | + if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 92 | + if (!$silence) { |
|
| 93 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + if (isset($arbre['fonctions'])) { |
|
| 99 | + foreach ($arbre['fonctions'] as $optfile) { |
|
| 100 | + $optfile = trim($optfile); |
|
| 101 | + if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 102 | + if (!$silence) { |
|
| 103 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + $fonctions = array(); |
|
| 109 | + if (isset($arbre['fonctions'])) { |
|
| 110 | + $fonctions = $arbre['fonctions']; |
|
| 111 | + } |
|
| 112 | + $liste_methodes_reservees = array( |
|
| 113 | + '__construct', |
|
| 114 | + '__destruct', |
|
| 115 | + 'plugin', |
|
| 116 | + 'install', |
|
| 117 | + 'uninstall', |
|
| 118 | + strtolower($prefix) |
|
| 119 | + ); |
|
| 120 | 120 | |
| 121 | - $extraire_pipelines = charger_fonction("extraire_pipelines", "plugins"); |
|
| 122 | - $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 123 | - foreach ($arbre['pipeline'] as $pipe) { |
|
| 124 | - if (!isset($pipe['nom'])) { |
|
| 125 | - if (!$silence) { |
|
| 126 | - $arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini"); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - if (isset($pipe['action'])) { |
|
| 130 | - $action = $pipe['action']; |
|
| 131 | - } else { |
|
| 132 | - $action = $pipe['nom']; |
|
| 133 | - } |
|
| 134 | - // verif que la methode a un nom autorise |
|
| 135 | - if (in_array(strtolower($action), $liste_methodes_reservees)) { |
|
| 136 | - if (!$silence) { |
|
| 137 | - $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action"; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - if (isset($pipe['inclure'])) { |
|
| 141 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 142 | - if (!@is_readable($inclure)) { |
|
| 143 | - if (!$silence) { |
|
| 144 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - $necessite = array(); |
|
| 150 | - $spip_trouve = false; |
|
| 151 | - if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 152 | - foreach (array_keys($needs) as $tag) { |
|
| 153 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 154 | - if (!isset($att['id'])) { |
|
| 155 | - if (!$silence) { |
|
| 156 | - $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 157 | - array('attribut' => 'id', 'balise' => $att)); |
|
| 158 | - } |
|
| 159 | - } else { |
|
| 160 | - $necessite[] = $att; |
|
| 161 | - } |
|
| 162 | - if (strtolower($att['id']) == 'spip') { |
|
| 163 | - $spip_trouve = true; |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - } |
|
| 167 | - if ($compat_spip and !$spip_trouve) { |
|
| 168 | - $necessite[] = array('id' => 'spip', 'version' => $compat_spip); |
|
| 169 | - } |
|
| 170 | - $arbre['necessite'] = $necessite; |
|
| 171 | - $utilise = array(); |
|
| 172 | - if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 173 | - foreach (array_keys($uses) as $tag) { |
|
| 174 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 175 | - if (!isset($att['id'])) { |
|
| 176 | - if (!$silence) { |
|
| 177 | - $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 178 | - array('attribut' => 'id', 'balise' => $att)); |
|
| 179 | - } |
|
| 180 | - } else { |
|
| 181 | - $utilise[] = $att; |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - } |
|
| 185 | - $arbre['utilise'] = $utilise; |
|
| 186 | - $procure = array(); |
|
| 187 | - if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 188 | - foreach (array_keys($uses) as $tag) { |
|
| 189 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 190 | - $procure[] = $att; |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - $arbre['procure'] = $procure; |
|
| 194 | - $path = array(); |
|
| 195 | - if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 196 | - foreach (array_keys($paths) as $tag) { |
|
| 197 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 198 | - $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 199 | - $path[] = $att; |
|
| 200 | - } |
|
| 201 | - } else { |
|
| 202 | - $path = array(array('dir' => '')); |
|
| 203 | - } // initialiser par defaut |
|
| 204 | - $arbre['path'] = $path; |
|
| 205 | - // exposer les noisettes |
|
| 206 | - if (isset($arbre['noisette'])) { |
|
| 207 | - foreach ($arbre['noisette'] as $k => $nut) { |
|
| 208 | - $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
|
| 209 | - $arbre['noisette'][$k] = $nut; |
|
| 210 | - if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 211 | - if (!$silence) { |
|
| 212 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - } |
|
| 217 | - $traduire = array(); |
|
| 218 | - if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 219 | - foreach (array_keys($trads) as $tag) { |
|
| 220 | - list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 221 | - $traduire[] = $att; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - $arbre['traduire'] = $traduire; |
|
| 225 | - } |
|
| 121 | + $extraire_pipelines = charger_fonction("extraire_pipelines", "plugins"); |
|
| 122 | + $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 123 | + foreach ($arbre['pipeline'] as $pipe) { |
|
| 124 | + if (!isset($pipe['nom'])) { |
|
| 125 | + if (!$silence) { |
|
| 126 | + $arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini"); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + if (isset($pipe['action'])) { |
|
| 130 | + $action = $pipe['action']; |
|
| 131 | + } else { |
|
| 132 | + $action = $pipe['nom']; |
|
| 133 | + } |
|
| 134 | + // verif que la methode a un nom autorise |
|
| 135 | + if (in_array(strtolower($action), $liste_methodes_reservees)) { |
|
| 136 | + if (!$silence) { |
|
| 137 | + $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action"; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + if (isset($pipe['inclure'])) { |
|
| 141 | + $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 142 | + if (!@is_readable($inclure)) { |
|
| 143 | + if (!$silence) { |
|
| 144 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + $necessite = array(); |
|
| 150 | + $spip_trouve = false; |
|
| 151 | + if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 152 | + foreach (array_keys($needs) as $tag) { |
|
| 153 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 154 | + if (!isset($att['id'])) { |
|
| 155 | + if (!$silence) { |
|
| 156 | + $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 157 | + array('attribut' => 'id', 'balise' => $att)); |
|
| 158 | + } |
|
| 159 | + } else { |
|
| 160 | + $necessite[] = $att; |
|
| 161 | + } |
|
| 162 | + if (strtolower($att['id']) == 'spip') { |
|
| 163 | + $spip_trouve = true; |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + } |
|
| 167 | + if ($compat_spip and !$spip_trouve) { |
|
| 168 | + $necessite[] = array('id' => 'spip', 'version' => $compat_spip); |
|
| 169 | + } |
|
| 170 | + $arbre['necessite'] = $necessite; |
|
| 171 | + $utilise = array(); |
|
| 172 | + if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 173 | + foreach (array_keys($uses) as $tag) { |
|
| 174 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 175 | + if (!isset($att['id'])) { |
|
| 176 | + if (!$silence) { |
|
| 177 | + $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant', |
|
| 178 | + array('attribut' => 'id', 'balise' => $att)); |
|
| 179 | + } |
|
| 180 | + } else { |
|
| 181 | + $utilise[] = $att; |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + $arbre['utilise'] = $utilise; |
|
| 186 | + $procure = array(); |
|
| 187 | + if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 188 | + foreach (array_keys($uses) as $tag) { |
|
| 189 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 190 | + $procure[] = $att; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + $arbre['procure'] = $procure; |
|
| 194 | + $path = array(); |
|
| 195 | + if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 196 | + foreach (array_keys($paths) as $tag) { |
|
| 197 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 198 | + $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 199 | + $path[] = $att; |
|
| 200 | + } |
|
| 201 | + } else { |
|
| 202 | + $path = array(array('dir' => '')); |
|
| 203 | + } // initialiser par defaut |
|
| 204 | + $arbre['path'] = $path; |
|
| 205 | + // exposer les noisettes |
|
| 206 | + if (isset($arbre['noisette'])) { |
|
| 207 | + foreach ($arbre['noisette'] as $k => $nut) { |
|
| 208 | + $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
|
| 209 | + $arbre['noisette'][$k] = $nut; |
|
| 210 | + if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 211 | + if (!$silence) { |
|
| 212 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + } |
|
| 217 | + $traduire = array(); |
|
| 218 | + if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 219 | + foreach (array_keys($trads) as $tag) { |
|
| 220 | + list($tag, $att) = spip_xml_decompose_tag($tag); |
|
| 221 | + $traduire[] = $att; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + $arbre['traduire'] = $traduire; |
|
| 225 | + } |
|
| 226 | 226 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | if (is_null($p)) { |
| 50 | - $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug")); |
|
| 50 | + $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent')." : $plug")); |
|
| 51 | 51 | $silence = true; |
| 52 | 52 | } else { |
| 53 | 53 | $arbre = $p; |
@@ -82,15 +82,15 @@ discard block |
||
| 82 | 82 | if (isset($arbre['etat'])) { |
| 83 | 83 | $etat = trim(end($arbre['etat'])); |
| 84 | 84 | if (!in_array($etat, $etats)) { |
| 85 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 85 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu')." : '$etat'"; |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | if (isset($arbre['options'])) { |
| 89 | 89 | foreach ($arbre['options'] as $optfile) { |
| 90 | 90 | $optfile = trim($optfile); |
| 91 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 91 | + if (!@is_readable($dir_plugins."$plug/$optfile")) { |
|
| 92 | 92 | if (!$silence) { |
| 93 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 93 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | if (isset($arbre['fonctions'])) { |
| 99 | 99 | foreach ($arbre['fonctions'] as $optfile) { |
| 100 | 100 | $optfile = trim($optfile); |
| 101 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 101 | + if (!@is_readable($dir_plugins."$plug/$optfile")) { |
|
| 102 | 102 | if (!$silence) { |
| 103 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 103 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | // verif que la methode a un nom autorise |
| 135 | 135 | if (in_array(strtolower($action), $liste_methodes_reservees)) { |
| 136 | 136 | if (!$silence) { |
| 137 | - $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action"; |
|
| 137 | + $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit")." : $action"; |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | if (isset($pipe['inclure'])) { |
| 141 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 141 | + $inclure = $dir_plugins."$plug/".$pipe['inclure']; |
|
| 142 | 142 | if (!@is_readable($inclure)) { |
| 143 | 143 | if (!$silence) { |
| 144 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 144 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $inclure"; |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | foreach ($arbre['noisette'] as $k => $nut) { |
| 208 | 208 | $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
| 209 | 209 | $arbre['noisette'][$k] = $nut; |
| 210 | - if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 210 | + if (!@is_readable($dir_plugins."$plug/$nut.html")) { |
|
| 211 | 211 | if (!$silence) { |
| 212 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 212 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $nut"; |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -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 | /** |
@@ -21,30 +21,30 @@ discard block |
||
| 21 | 21 | * @return <type> |
| 22 | 22 | */ |
| 23 | 23 | function plugins_extraire_boutons_dist($arbre) { |
| 24 | - $ret = array('bouton' => array(), 'onglet' => array()); |
|
| 25 | - // recuperer les boutons et onglets si necessaire |
|
| 26 | - spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons); |
|
| 27 | - if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | - $ret['bouton'] = array(); |
|
| 29 | - $ret['onglet'] = array(); |
|
| 30 | - foreach ($les_boutons as $bouton => $val) { |
|
| 31 | - $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | - $type = reset($bouton); |
|
| 33 | - $bouton = end($bouton); |
|
| 34 | - if (isset($bouton['id'])) { |
|
| 35 | - $id = $bouton['id']; |
|
| 36 | - $val = reset($val); |
|
| 37 | - if (is_array($val)) { |
|
| 38 | - $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : ''; |
|
| 39 | - $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : ''; |
|
| 40 | - $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | - $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 42 | - $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 43 | - $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - } |
|
| 24 | + $ret = array('bouton' => array(), 'onglet' => array()); |
|
| 25 | + // recuperer les boutons et onglets si necessaire |
|
| 26 | + spip_xml_match_nodes(",^(bouton|onglet)\s,", $arbre, $les_boutons); |
|
| 27 | + if (is_array($les_boutons) && count($les_boutons)) { |
|
| 28 | + $ret['bouton'] = array(); |
|
| 29 | + $ret['onglet'] = array(); |
|
| 30 | + foreach ($les_boutons as $bouton => $val) { |
|
| 31 | + $bouton = spip_xml_decompose_tag($bouton); |
|
| 32 | + $type = reset($bouton); |
|
| 33 | + $bouton = end($bouton); |
|
| 34 | + if (isset($bouton['id'])) { |
|
| 35 | + $id = $bouton['id']; |
|
| 36 | + $val = reset($val); |
|
| 37 | + if (is_array($val)) { |
|
| 38 | + $ret[$type][$id]['parent'] = isset($bouton['parent']) ? $bouton['parent'] : ''; |
|
| 39 | + $ret[$type][$id]['position'] = isset($bouton['position']) ? $bouton['position'] : ''; |
|
| 40 | + $ret[$type][$id]['titre'] = isset($val['titre']) ? trim(spip_xml_aplatit($val['titre'])) : ''; |
|
| 41 | + $ret[$type][$id]['icone'] = isset($val['icone']) ? trim(end($val['icone'])) : ''; |
|
| 42 | + $ret[$type][$id]['action'] = isset($val['url']) ? trim(end($val['url'])) : ''; |
|
| 43 | + $ret[$type][$id]['parametres'] = isset($val['args']) ? trim(end($val['args'])) : ''; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $ret; |
|
| 49 | + return $ret; |
|
| 50 | 50 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/charsets'); |
| 17 | 17 | |
@@ -28,88 +28,88 @@ discard block |
||
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | 30 | function plugins_afficher_liste_dist( |
| 31 | - $url_page, |
|
| 32 | - $liste_plugins, |
|
| 33 | - $liste_plugins_checked, |
|
| 34 | - $liste_plugins_actifs, |
|
| 35 | - $dir_plugins = _DIR_PLUGINS, |
|
| 36 | - $afficher_un = 'afficher_plugin' |
|
| 31 | + $url_page, |
|
| 32 | + $liste_plugins, |
|
| 33 | + $liste_plugins_checked, |
|
| 34 | + $liste_plugins_actifs, |
|
| 35 | + $dir_plugins = _DIR_PLUGINS, |
|
| 36 | + $afficher_un = 'afficher_plugin' |
|
| 37 | 37 | ) { |
| 38 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 39 | - $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 38 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 39 | + $ligne_plug = charger_fonction($afficher_un, 'plugins'); |
|
| 40 | 40 | |
| 41 | - $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 41 | + $all_infos = $get_infos($liste_plugins, false, $dir_plugins); |
|
| 42 | 42 | |
| 43 | - $all_infos = pipeline('filtrer_liste_plugins', |
|
| 44 | - array( |
|
| 45 | - 'args' => array( |
|
| 46 | - 'liste_plugins' => $liste_plugins, |
|
| 47 | - 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | - 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | - 'dir_plugins' => $dir_plugins |
|
| 50 | - ), |
|
| 51 | - 'data' => $all_infos |
|
| 52 | - ) |
|
| 53 | - ); |
|
| 43 | + $all_infos = pipeline('filtrer_liste_plugins', |
|
| 44 | + array( |
|
| 45 | + 'args' => array( |
|
| 46 | + 'liste_plugins' => $liste_plugins, |
|
| 47 | + 'liste_plugins_checked' => $liste_plugins_checked, |
|
| 48 | + 'liste_plugins_actifs' => $liste_plugins_actifs, |
|
| 49 | + 'dir_plugins' => $dir_plugins |
|
| 50 | + ), |
|
| 51 | + 'data' => $all_infos |
|
| 52 | + ) |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - $liste_plugins = array_flip($liste_plugins); |
|
| 56 | - foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | - // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | - if (isset($all_infos[$chemin])) { |
|
| 59 | - $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | - } else { |
|
| 61 | - unset($liste_plugins[$chemin]); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - asort($liste_plugins); |
|
| 65 | - $exposed = urldecode(_request('plugin')); |
|
| 55 | + $liste_plugins = array_flip($liste_plugins); |
|
| 56 | + foreach ($liste_plugins as $chemin => $v) { |
|
| 57 | + // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte. |
|
| 58 | + if (isset($all_infos[$chemin])) { |
|
| 59 | + $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom'])))))); |
|
| 60 | + } else { |
|
| 61 | + unset($liste_plugins[$chemin]); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + asort($liste_plugins); |
|
| 65 | + $exposed = urldecode(_request('plugin')); |
|
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | - $fast_liste_plugins_actifs = array(); |
|
| 69 | - $fast_liste_plugins_checked = array(); |
|
| 70 | - if (is_array($liste_plugins_actifs)) { |
|
| 71 | - $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | - } |
|
| 73 | - if (is_array($liste_plugins_checked)) { |
|
| 74 | - $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | - } |
|
| 67 | + $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 68 | + $fast_liste_plugins_actifs = array(); |
|
| 69 | + $fast_liste_plugins_checked = array(); |
|
| 70 | + if (is_array($liste_plugins_actifs)) { |
|
| 71 | + $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs); |
|
| 72 | + } |
|
| 73 | + if (is_array($liste_plugins_checked)) { |
|
| 74 | + $fast_liste_plugins_checked = array_flip($liste_plugins_checked); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - $res = ''; |
|
| 78 | - $block = ''; |
|
| 79 | - $initiale = ''; |
|
| 80 | - $block_actif = false; |
|
| 81 | - foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | - if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | - $initiale = $i; |
|
| 85 | - $block = ''; |
|
| 86 | - $block_actif = false; |
|
| 87 | - } |
|
| 88 | - // le rep suivant |
|
| 89 | - $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | - $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | - $block_actif = $block_actif | $actif; |
|
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, |
|
| 93 | - strlen(_DIR_RACINE)) . $plug)); |
|
| 94 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n"; |
|
| 95 | - } |
|
| 96 | - $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 97 | - $class = basename($dir_plugins); |
|
| 77 | + $res = ''; |
|
| 78 | + $block = ''; |
|
| 79 | + $initiale = ''; |
|
| 80 | + $block_actif = false; |
|
| 81 | + foreach ($liste_plugins as $plug => $nom) { |
|
| 82 | + if (($i = substr($nom, 0, 1)) !== $initiale) { |
|
| 83 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 84 | + $initiale = $i; |
|
| 85 | + $block = ''; |
|
| 86 | + $block_actif = false; |
|
| 87 | + } |
|
| 88 | + // le rep suivant |
|
| 89 | + $actif = isset($fast_liste_plugins_actifs[$plug]); |
|
| 90 | + $checked = isset($fast_liste_plugins_checked[$plug]); |
|
| 91 | + $block_actif = $block_actif | $actif; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, |
|
| 93 | + strlen(_DIR_RACINE)) . $plug)); |
|
| 94 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n"; |
|
| 95 | + } |
|
| 96 | + $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
|
| 97 | + $class = basename($dir_plugins); |
|
| 98 | 98 | |
| 99 | - return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ""; |
|
| 99 | + return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : ""; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | // http://code.spip.net/@affiche_block_initiale |
| 104 | 104 | function affiche_block_initiale($initiale, $block, $block_actif) { |
| 105 | - if (strlen($block)) { |
|
| 106 | - return "<li class='item'>" |
|
| 107 | - . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 108 | - . debut_block_depliable($block_actif) |
|
| 109 | - . "<ul>$block</ul>" |
|
| 110 | - . fin_block() |
|
| 111 | - . "</li>"; |
|
| 112 | - } |
|
| 105 | + if (strlen($block)) { |
|
| 106 | + return "<li class='item'>" |
|
| 107 | + . bouton_block_depliable($initiale, $block_actif ? true : false) |
|
| 108 | + . debut_block_depliable($block_actif) |
|
| 109 | + . "<ul>$block</ul>" |
|
| 110 | + . fin_block() |
|
| 111 | + . "</li>"; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - return ""; |
|
| 114 | + return ""; |
|
| 115 | 115 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | asort($liste_plugins); |
| 65 | 65 | $exposed = urldecode(_request('plugin')); |
| 66 | 66 | |
| 67 | - $block_par_lettre = false;//count($liste_plugins)>10; |
|
| 67 | + $block_par_lettre = false; //count($liste_plugins)>10; |
|
| 68 | 68 | $fast_liste_plugins_actifs = array(); |
| 69 | 69 | $fast_liste_plugins_checked = array(); |
| 70 | 70 | if (is_array($liste_plugins_actifs)) { |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | $actif = isset($fast_liste_plugins_actifs[$plug]); |
| 90 | 90 | $checked = isset($fast_liste_plugins_checked[$plug]); |
| 91 | 91 | $block_actif = $block_actif | $actif; |
| 92 | - $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins, |
|
| 93 | - strlen(_DIR_RACINE)) . $plug)); |
|
| 94 | - $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n"; |
|
| 92 | + $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins.$plug or $exposed == substr($dir_plugins, |
|
| 93 | + strlen(_DIR_RACINE)).$plug)); |
|
| 94 | + $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins)."\n"; |
|
| 95 | 95 | } |
| 96 | 96 | $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block; |
| 97 | 97 | $class = basename($dir_plugins); |
@@ -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 | define('URLS_PAGE_EXEMPLE', 'spip.php?article12'); |
@@ -30,74 +30,74 @@ discard block |
||
| 30 | 30 | // http://code.spip.net/@_generer_url_page |
| 31 | 31 | function _generer_url_page($type, $id, $args = '', $ancre = '') { |
| 32 | 32 | |
| 33 | - if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) { |
|
| 34 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 35 | - if (null != $url) { |
|
| 36 | - return $url; |
|
| 37 | - } |
|
| 38 | - } |
|
| 33 | + if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) { |
|
| 34 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 35 | + if (null != $url) { |
|
| 36 | + return $url; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | - . $id . _terminaison_urls_page; |
|
| 40 | + $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | + . $id . _terminaison_urls_page; |
|
| 42 | 42 | |
| 43 | - if ($args) { |
|
| 44 | - $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 45 | - } |
|
| 43 | + if ($args) { |
|
| 44 | + $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 47 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // retrouve le fond et les parametres d'une URL abregee |
| 51 | 51 | // le contexte deja existant est fourni dans args sous forme de tableau ou query string |
| 52 | 52 | // http://code.spip.net/@urls_page_dist |
| 53 | 53 | function urls_page_dist($i, &$entite, $args = '', $ancre = '') { |
| 54 | - if (is_numeric($i)) { |
|
| 55 | - return _generer_url_page($entite, $i, $args, $ancre); |
|
| 56 | - } |
|
| 54 | + if (is_numeric($i)) { |
|
| 55 | + return _generer_url_page($entite, $i, $args, $ancre); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 59 | - if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 60 | - return array(array(), '404'); |
|
| 61 | - } |
|
| 58 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 59 | + if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 60 | + return array(array(), '404'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 64 | - if (is_array($args)) { |
|
| 65 | - $contexte = $args; |
|
| 66 | - } else { |
|
| 67 | - parse_str($args, $contexte); |
|
| 68 | - } |
|
| 69 | - include_spip('inc/urls'); |
|
| 70 | - $r = nettoyer_url_page($i, $contexte); |
|
| 71 | - if ($r) { |
|
| 72 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | - return $r; |
|
| 74 | - } |
|
| 63 | + // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 64 | + if (is_array($args)) { |
|
| 65 | + $contexte = $args; |
|
| 66 | + } else { |
|
| 67 | + parse_str($args, $contexte); |
|
| 68 | + } |
|
| 69 | + include_spip('inc/urls'); |
|
| 70 | + $r = nettoyer_url_page($i, $contexte); |
|
| 71 | + if ($r) { |
|
| 72 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | + return $r; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /* |
|
| 76 | + /* |
|
| 77 | 77 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 78 | 78 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 79 | 79 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 80 | 80 | * et votre .htaccess |
| 81 | 81 | */ |
| 82 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | - $url = $i; |
|
| 85 | - $url_propre = isset($url) |
|
| 86 | - ? $url |
|
| 87 | - : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 88 | - ? $_SERVER['REDIRECT_url_propre'] |
|
| 89 | - : (isset($_ENV['url_propre']) |
|
| 90 | - ? $_ENV['url_propre'] |
|
| 91 | - : '' |
|
| 92 | - )); |
|
| 93 | - if ($url_propre) { |
|
| 94 | - if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 95 | - $urls_anciennes = charger_fonction('propres', 'urls', true); |
|
| 96 | - } else { |
|
| 97 | - $urls_anciennes = charger_fonction('arbo', 'urls', true); |
|
| 98 | - } |
|
| 82 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | + $url = $i; |
|
| 85 | + $url_propre = isset($url) |
|
| 86 | + ? $url |
|
| 87 | + : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 88 | + ? $_SERVER['REDIRECT_url_propre'] |
|
| 89 | + : (isset($_ENV['url_propre']) |
|
| 90 | + ? $_ENV['url_propre'] |
|
| 91 | + : '' |
|
| 92 | + )); |
|
| 93 | + if ($url_propre) { |
|
| 94 | + if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 95 | + $urls_anciennes = charger_fonction('propres', 'urls', true); |
|
| 96 | + } else { |
|
| 97 | + $urls_anciennes = charger_fonction('arbo', 'urls', true); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : ''; |
|
| 101 | - } |
|
| 102 | - /* Fin du bloc compatibilite url-propres */ |
|
| 100 | + return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : ''; |
|
| 101 | + } |
|
| 102 | + /* Fin du bloc compatibilite url-propres */ |
|
| 103 | 103 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite |
| 24 | 24 | define('_separateur_urls_page', ''); |
| 25 | 25 | # on peut indiquer '' si on a installe le .htaccess |
| 26 | -define('_debut_urls_page', get_spip_script('./') . '?'); |
|
| 26 | +define('_debut_urls_page', get_spip_script('./').'?'); |
|
| 27 | 27 | ####### |
| 28 | 28 | |
| 29 | 29 | |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | - . $id . _terminaison_urls_page; |
|
| 40 | + $url = _debut_urls_page.$type._separateur_urls_page |
|
| 41 | + . $id._terminaison_urls_page; |
|
| 42 | 42 | |
| 43 | 43 | if ($args) { |
| 44 | 44 | $args = strpos($url, '?') ? "&$args" : "?$args"; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 47 | + return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : ''); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // retrouve le fond et les parametres d'une URL abregee |
@@ -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 | define('_REGEXP_DOCTYPE', |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
| 34 | 34 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 35 | 35 | define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
| 36 | - _SUB_REGEXP_SYMBOL . |
|
| 37 | - '+;?)\s+(' . |
|
| 38 | - _REGEXP_TYPE_XML . |
|
| 39 | - ')?\s*(' . |
|
| 40 | - "('([^']*)')" . |
|
| 41 | - '|("([^"]*)")' . |
|
| 42 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 43 | - ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 36 | + _SUB_REGEXP_SYMBOL . |
|
| 37 | + '+;?)\s+(' . |
|
| 38 | + _REGEXP_TYPE_XML . |
|
| 39 | + ')?\s*(' . |
|
| 40 | + "('([^']*)')" . |
|
| 41 | + '|("([^"]*)")' . |
|
| 42 | + '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 43 | + ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 44 | 44 | |
| 45 | 45 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
| 46 | 46 | |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | * Document Type Compilation |
| 51 | 51 | **/ |
| 52 | 52 | class DTC { |
| 53 | - public $macros = array(); |
|
| 54 | - public $elements = array(); |
|
| 55 | - public $peres = array(); |
|
| 56 | - public $attributs = array(); |
|
| 57 | - public $entites = array(); |
|
| 58 | - public $regles = array(); |
|
| 59 | - public $pcdata = array(); |
|
| 53 | + public $macros = array(); |
|
| 54 | + public $elements = array(); |
|
| 55 | + public $peres = array(); |
|
| 56 | + public $attributs = array(); |
|
| 57 | + public $entites = array(); |
|
| 58 | + public $regles = array(); |
|
| 59 | + public $pcdata = array(); |
|
| 60 | 60 | } |
@@ -23,23 +23,23 @@ |
||
| 23 | 23 | |
| 24 | 24 | define('_SUB_REGEXP_SYMBOL', '[\w_:.-]'); |
| 25 | 25 | |
| 26 | -define('_REGEXP_NMTOKEN', '/^' . _SUB_REGEXP_SYMBOL . '+$/'); |
|
| 26 | +define('_REGEXP_NMTOKEN', '/^'._SUB_REGEXP_SYMBOL.'+$/'); |
|
| 27 | 27 | |
| 28 | -define('_REGEXP_NMTOKENS', '/^(' . _SUB_REGEXP_SYMBOL . '+\s*)*$/'); |
|
| 28 | +define('_REGEXP_NMTOKENS', '/^('._SUB_REGEXP_SYMBOL.'+\s*)*$/'); |
|
| 29 | 29 | |
| 30 | -define('_REGEXP_ID', '/^[A-Za-z_:]' . _SUB_REGEXP_SYMBOL . '*$/'); |
|
| 30 | +define('_REGEXP_ID', '/^[A-Za-z_:]'._SUB_REGEXP_SYMBOL.'*$/'); |
|
| 31 | 31 | |
| 32 | -define('_REGEXP_ENTITY_USE', '/%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
|
| 33 | -define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
|
| 32 | +define('_REGEXP_ENTITY_USE', '/%('._SUB_REGEXP_SYMBOL.'+);/'); |
|
| 33 | +define('_REGEXP_ENTITY_DEF', '/^%('._SUB_REGEXP_SYMBOL.'+);/'); |
|
| 34 | 34 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 35 | -define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
|
| 36 | - _SUB_REGEXP_SYMBOL . |
|
| 37 | - '+;?)\s+(' . |
|
| 38 | - _REGEXP_TYPE_XML . |
|
| 39 | - ')?\s*(' . |
|
| 40 | - "('([^']*)')" . |
|
| 41 | - '|("([^"]*)")' . |
|
| 42 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 35 | +define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*('. |
|
| 36 | + _SUB_REGEXP_SYMBOL. |
|
| 37 | + '+;?)\s+('. |
|
| 38 | + _REGEXP_TYPE_XML. |
|
| 39 | + ')?\s*('. |
|
| 40 | + "('([^']*)')". |
|
| 41 | + '|("([^"]*)")'. |
|
| 42 | + '|\s*(%'._SUB_REGEXP_SYMBOL.'+;)\s*'. |
|
| 43 | 43 | ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
| 44 | 44 | |
| 45 | 45 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
@@ -11,61 +11,61 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | class IndenteurXML { |
| 18 | 18 | |
| 19 | - // http://code.spip.net/@debutElement |
|
| 20 | - public function debutElement($phraseur, $name, $attrs) { |
|
| 21 | - xml_debutElement($this, $name, $attrs); |
|
| 22 | - } |
|
| 19 | + // http://code.spip.net/@debutElement |
|
| 20 | + public function debutElement($phraseur, $name, $attrs) { |
|
| 21 | + xml_debutElement($this, $name, $attrs); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - // http://code.spip.net/@finElement |
|
| 25 | - public function finElement($phraseur, $name) { |
|
| 26 | - xml_finElement($this, $name); |
|
| 27 | - } |
|
| 24 | + // http://code.spip.net/@finElement |
|
| 25 | + public function finElement($phraseur, $name) { |
|
| 26 | + xml_finElement($this, $name); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - // http://code.spip.net/@textElement |
|
| 30 | - public function textElement($phraseur, $data) { |
|
| 31 | - xml_textElement($this, $data); |
|
| 32 | - } |
|
| 29 | + // http://code.spip.net/@textElement |
|
| 30 | + public function textElement($phraseur, $data) { |
|
| 31 | + xml_textElement($this, $data); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function piElement($phraseur, $target, $data) { |
|
| 35 | - xml_PiElement($this, $target, $data); |
|
| 36 | - } |
|
| 34 | + public function piElement($phraseur, $target, $data) { |
|
| 35 | + xml_PiElement($this, $target, $data); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - // http://code.spip.net/@defautElement |
|
| 39 | - public function defaultElement($phraseur, $data) { |
|
| 40 | - xml_defaultElement($this, $data); |
|
| 41 | - } |
|
| 38 | + // http://code.spip.net/@defautElement |
|
| 39 | + public function defaultElement($phraseur, $data) { |
|
| 40 | + xml_defaultElement($this, $data); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // http://code.spip.net/@phraserTout |
|
| 44 | - public function phraserTout($phraseur, $data) { |
|
| 45 | - xml_parsestring($this, $data); |
|
| 46 | - } |
|
| 43 | + // http://code.spip.net/@phraserTout |
|
| 44 | + public function phraserTout($phraseur, $data) { |
|
| 45 | + xml_parsestring($this, $data); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public $depth = ""; |
|
| 49 | - public $res = ""; |
|
| 50 | - public $err = array(); |
|
| 51 | - public $contenu = array(); |
|
| 52 | - public $ouvrant = array(); |
|
| 53 | - public $reperes = array(); |
|
| 54 | - public $entete = ''; |
|
| 55 | - public $page = ''; |
|
| 56 | - public $dtc = null; |
|
| 57 | - public $sax = null; |
|
| 48 | + public $depth = ""; |
|
| 49 | + public $res = ""; |
|
| 50 | + public $err = array(); |
|
| 51 | + public $contenu = array(); |
|
| 52 | + public $ouvrant = array(); |
|
| 53 | + public $reperes = array(); |
|
| 54 | + public $entete = ''; |
|
| 55 | + public $page = ''; |
|
| 56 | + public $dtc = null; |
|
| 57 | + public $sax = null; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // http://code.spip.net/@xml_indenter_dist |
| 61 | 61 | function xml_indenter_dist($page, $apply = false) { |
| 62 | - $sax = charger_fonction('sax', 'xml'); |
|
| 63 | - $f = new IndenteurXML(); |
|
| 64 | - $sax($page, $apply, $f); |
|
| 65 | - if (!$f->err) { |
|
| 66 | - return $f->entete . $f->res; |
|
| 67 | - } |
|
| 68 | - spip_log("indentation impossible " . count($f->err) . " erreurs de validation"); |
|
| 62 | + $sax = charger_fonction('sax', 'xml'); |
|
| 63 | + $f = new IndenteurXML(); |
|
| 64 | + $sax($page, $apply, $f); |
|
| 65 | + if (!$f->err) { |
|
| 66 | + return $f->entete . $f->res; |
|
| 67 | + } |
|
| 68 | + spip_log("indentation impossible " . count($f->err) . " erreurs de validation"); |
|
| 69 | 69 | |
| 70 | - return $f->entete . $f->page; |
|
| 70 | + return $f->entete . $f->page; |
|
| 71 | 71 | } |
@@ -63,9 +63,9 @@ |
||
| 63 | 63 | $f = new IndenteurXML(); |
| 64 | 64 | $sax($page, $apply, $f); |
| 65 | 65 | if (!$f->err) { |
| 66 | - return $f->entete . $f->res; |
|
| 66 | + return $f->entete.$f->res; |
|
| 67 | 67 | } |
| 68 | - spip_log("indentation impossible " . count($f->err) . " erreurs de validation"); |
|
| 68 | + spip_log("indentation impossible ".count($f->err)." erreurs de validation"); |
|
| 69 | 69 | |
| 70 | - return $f->entete . $f->page; |
|
| 70 | + return $f->entete.$f->page; |
|
| 71 | 71 | } |
@@ -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 | /** |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | * @return string |
| 28 | 28 | */ |
| 29 | 29 | function generer_nom_fichier_cache($contexte, $page) { |
| 30 | - $u = md5(var_export(array($contexte, $page), true)); |
|
| 30 | + $u = md5(var_export(array($contexte, $page), true)); |
|
| 31 | 31 | |
| 32 | - return $u . ".cache"; |
|
| 32 | + return $u . ".cache"; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | 42 | function ecrire_cache($nom_cache, $valeur) { |
| 43 | - $d = substr($nom_cache, 0, 2); |
|
| 44 | - $u = substr($nom_cache, 2, 2); |
|
| 45 | - $rep = _DIR_CACHE; |
|
| 46 | - $rep = sous_repertoire($rep, '', false, true); |
|
| 47 | - $rep = sous_repertoire($rep, $d, false, true); |
|
| 43 | + $d = substr($nom_cache, 0, 2); |
|
| 44 | + $u = substr($nom_cache, 2, 2); |
|
| 45 | + $rep = _DIR_CACHE; |
|
| 46 | + $rep = sous_repertoire($rep, '', false, true); |
|
| 47 | + $rep = sous_repertoire($rep, $d, false, true); |
|
| 48 | 48 | |
| 49 | - return ecrire_fichier($rep . $u . ".cache", serialize(array("nom_cache" => $nom_cache, "valeur" => $valeur))); |
|
| 49 | + return ecrire_fichier($rep . $u . ".cache", serialize(array("nom_cache" => $nom_cache, "valeur" => $valeur))); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,31 +56,31 @@ discard block |
||
| 56 | 56 | * @return mixed |
| 57 | 57 | */ |
| 58 | 58 | function lire_cache($nom_cache) { |
| 59 | - $d = substr($nom_cache, 0, 2); |
|
| 60 | - $u = substr($nom_cache, 2, 2); |
|
| 61 | - if (file_exists($f = _DIR_CACHE . "$d/$u.cache") |
|
| 62 | - and lire_fichier($f, $tmp) |
|
| 63 | - and $tmp = unserialize($tmp) |
|
| 64 | - and $tmp['nom_cache'] == $nom_cache |
|
| 65 | - and isset($tmp['valeur']) |
|
| 66 | - ) { |
|
| 67 | - return $tmp['valeur']; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return false; |
|
| 59 | + $d = substr($nom_cache, 0, 2); |
|
| 60 | + $u = substr($nom_cache, 2, 2); |
|
| 61 | + if (file_exists($f = _DIR_CACHE . "$d/$u.cache") |
|
| 62 | + and lire_fichier($f, $tmp) |
|
| 63 | + and $tmp = unserialize($tmp) |
|
| 64 | + and $tmp['nom_cache'] == $nom_cache |
|
| 65 | + and isset($tmp['valeur']) |
|
| 66 | + ) { |
|
| 67 | + return $tmp['valeur']; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return false; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // Parano : on signe le cache, afin d'interdire un hack d'injection |
| 74 | 74 | // dans notre memcache |
| 75 | 75 | function cache_signature(&$page) { |
| 76 | - if (!isset($GLOBALS['meta']['cache_signature'])) { |
|
| 77 | - include_spip('inc/acces'); |
|
| 78 | - include_spip('auth/sha256.inc'); |
|
| 79 | - ecrire_meta('cache_signature', |
|
| 80 | - _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non'); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - return crc32($GLOBALS['meta']['cache_signature'] . $page['texte']); |
|
| 76 | + if (!isset($GLOBALS['meta']['cache_signature'])) { |
|
| 77 | + include_spip('inc/acces'); |
|
| 78 | + include_spip('auth/sha256.inc'); |
|
| 79 | + ecrire_meta('cache_signature', |
|
| 80 | + _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non'); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + return crc32($GLOBALS['meta']['cache_signature'] . $page['texte']); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | * @return array |
| 95 | 95 | */ |
| 96 | 96 | function gzip_page($page) { |
| 97 | - if (function_exists('gzcompress') and strlen($page['texte']) > 16 * 1024) { |
|
| 98 | - $page['gz'] = true; |
|
| 99 | - $page['texte'] = gzcompress($page['texte']); |
|
| 100 | - } else { |
|
| 101 | - $page['gz'] = false; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - return $page; |
|
| 97 | + if (function_exists('gzcompress') and strlen($page['texte']) > 16 * 1024) { |
|
| 98 | + $page['gz'] = true; |
|
| 99 | + $page['texte'] = gzcompress($page['texte']); |
|
| 100 | + } else { |
|
| 101 | + $page['gz'] = false; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + return $page; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | * @return void |
| 117 | 117 | */ |
| 118 | 118 | function gunzip_page(&$page) { |
| 119 | - if ($page['gz']) { |
|
| 120 | - $page['texte'] = gzuncompress($page['texte']); |
|
| 121 | - $page['gz'] = false; // ne pas gzuncompress deux fois une meme page |
|
| 122 | - } |
|
| 119 | + if ($page['gz']) { |
|
| 120 | + $page['texte'] = gzuncompress($page['texte']); |
|
| 121 | + $page['gz'] = false; // ne pas gzuncompress deux fois une meme page |
|
| 122 | + } |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
@@ -135,72 +135,72 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | /// http://code.spip.net/@cache_valide |
| 137 | 137 | function cache_valide(&$page, $date) { |
| 138 | - $now = $_SERVER['REQUEST_TIME']; |
|
| 139 | - |
|
| 140 | - // Apparition d'un nouvel article post-date ? |
|
| 141 | - if (isset($GLOBALS['meta']['post_dates']) |
|
| 142 | - and $GLOBALS['meta']['post_dates'] == 'non' |
|
| 143 | - and isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 144 | - and $now > $GLOBALS['meta']['date_prochain_postdate'] |
|
| 145 | - ) { |
|
| 146 | - spip_log('Un article post-date invalide le cache'); |
|
| 147 | - include_spip('inc/rubriques'); |
|
| 148 | - calculer_prochain_postdate(true); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - if (defined('_VAR_NOCACHE') and _VAR_NOCACHE) { |
|
| 152 | - return -1; |
|
| 153 | - } |
|
| 154 | - if (isset($GLOBALS['meta']['cache_inhib']) and $_SERVER['REQUEST_TIME'] < $GLOBALS['meta']['cache_inhib']) { |
|
| 155 | - return -1; |
|
| 156 | - } |
|
| 157 | - if (defined('_NO_CACHE')) { |
|
| 158 | - return (_NO_CACHE == 0 and !isset($page['texte'])) ? 1 : _NO_CACHE; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - // pas de cache ? on le met a jour, sauf pour les bots (on leur calcule la page sans mise en cache) |
|
| 162 | - if (!$page or !isset($page['texte']) or !isset($page['entetes']['X-Spip-Cache'])) { |
|
| 163 | - return _IS_BOT ? -1 : 1; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - // controle de la signature |
|
| 167 | - if ($page['sig'] !== cache_signature($page)) { |
|
| 168 | - return _IS_BOT ? -1 : 1; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - // #CACHE{n,statique} => on n'invalide pas avec derniere_modif |
|
| 172 | - // cf. ecrire/public/balises.php, balise_CACHE_dist() |
|
| 173 | - if (!isset($page['entetes']['X-Spip-Statique']) or $page['entetes']['X-Spip-Statique'] !== 'oui') { |
|
| 174 | - |
|
| 175 | - // Cache invalide par la meta 'derniere_modif' |
|
| 176 | - // sauf pour les bots, qui utilisent toujours le cache |
|
| 177 | - if (!_IS_BOT |
|
| 178 | - and $GLOBALS['derniere_modif_invalide'] |
|
| 179 | - and isset($GLOBALS['meta']['derniere_modif']) |
|
| 180 | - and $date < $GLOBALS['meta']['derniere_modif'] |
|
| 181 | - ) { |
|
| 182 | - return 1; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // Sinon comparer l'age du fichier a sa duree de cache |
|
| 188 | - $duree = intval($page['entetes']['X-Spip-Cache']); |
|
| 189 | - $cache_mark = (isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0); |
|
| 190 | - if ($duree == 0) #CACHE{0} |
|
| 191 | - { |
|
| 192 | - return -1; |
|
| 193 | - } // sauf pour les bots, qui utilisent toujours le cache |
|
| 194 | - else { |
|
| 195 | - if ((!_IS_BOT and $date + $duree < $now) |
|
| 196 | - # le cache est anterieur a la derniere purge : l'ignorer, meme pour les bots |
|
| 197 | - or $date < $cache_mark |
|
| 198 | - ) { |
|
| 199 | - return _IS_BOT ? -1 : 1; |
|
| 200 | - } else { |
|
| 201 | - return 0; |
|
| 202 | - } |
|
| 203 | - } |
|
| 138 | + $now = $_SERVER['REQUEST_TIME']; |
|
| 139 | + |
|
| 140 | + // Apparition d'un nouvel article post-date ? |
|
| 141 | + if (isset($GLOBALS['meta']['post_dates']) |
|
| 142 | + and $GLOBALS['meta']['post_dates'] == 'non' |
|
| 143 | + and isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 144 | + and $now > $GLOBALS['meta']['date_prochain_postdate'] |
|
| 145 | + ) { |
|
| 146 | + spip_log('Un article post-date invalide le cache'); |
|
| 147 | + include_spip('inc/rubriques'); |
|
| 148 | + calculer_prochain_postdate(true); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + if (defined('_VAR_NOCACHE') and _VAR_NOCACHE) { |
|
| 152 | + return -1; |
|
| 153 | + } |
|
| 154 | + if (isset($GLOBALS['meta']['cache_inhib']) and $_SERVER['REQUEST_TIME'] < $GLOBALS['meta']['cache_inhib']) { |
|
| 155 | + return -1; |
|
| 156 | + } |
|
| 157 | + if (defined('_NO_CACHE')) { |
|
| 158 | + return (_NO_CACHE == 0 and !isset($page['texte'])) ? 1 : _NO_CACHE; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + // pas de cache ? on le met a jour, sauf pour les bots (on leur calcule la page sans mise en cache) |
|
| 162 | + if (!$page or !isset($page['texte']) or !isset($page['entetes']['X-Spip-Cache'])) { |
|
| 163 | + return _IS_BOT ? -1 : 1; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + // controle de la signature |
|
| 167 | + if ($page['sig'] !== cache_signature($page)) { |
|
| 168 | + return _IS_BOT ? -1 : 1; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + // #CACHE{n,statique} => on n'invalide pas avec derniere_modif |
|
| 172 | + // cf. ecrire/public/balises.php, balise_CACHE_dist() |
|
| 173 | + if (!isset($page['entetes']['X-Spip-Statique']) or $page['entetes']['X-Spip-Statique'] !== 'oui') { |
|
| 174 | + |
|
| 175 | + // Cache invalide par la meta 'derniere_modif' |
|
| 176 | + // sauf pour les bots, qui utilisent toujours le cache |
|
| 177 | + if (!_IS_BOT |
|
| 178 | + and $GLOBALS['derniere_modif_invalide'] |
|
| 179 | + and isset($GLOBALS['meta']['derniere_modif']) |
|
| 180 | + and $date < $GLOBALS['meta']['derniere_modif'] |
|
| 181 | + ) { |
|
| 182 | + return 1; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // Sinon comparer l'age du fichier a sa duree de cache |
|
| 188 | + $duree = intval($page['entetes']['X-Spip-Cache']); |
|
| 189 | + $cache_mark = (isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0); |
|
| 190 | + if ($duree == 0) #CACHE{0} |
|
| 191 | + { |
|
| 192 | + return -1; |
|
| 193 | + } // sauf pour les bots, qui utilisent toujours le cache |
|
| 194 | + else { |
|
| 195 | + if ((!_IS_BOT and $date + $duree < $now) |
|
| 196 | + # le cache est anterieur a la derniere purge : l'ignorer, meme pour les bots |
|
| 197 | + or $date < $cache_mark |
|
| 198 | + ) { |
|
| 199 | + return _IS_BOT ? -1 : 1; |
|
| 200 | + } else { |
|
| 201 | + return 0; |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -215,55 +215,55 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | function creer_cache(&$page, &$chemin_cache) { |
| 217 | 217 | |
| 218 | - // Ne rien faire si on est en preview, debug, ou si une erreur |
|
| 219 | - // grave s'est presentee (compilation du squelette, MySQL, etc) |
|
| 220 | - // le cas var_nocache ne devrait jamais arriver ici (securite) |
|
| 221 | - // le cas spip_interdire_cache correspond a une ereur SQL grave non anticipable |
|
| 222 | - if ((defined('_VAR_NOCACHE') and _VAR_NOCACHE) |
|
| 223 | - or defined('spip_interdire_cache') |
|
| 224 | - ) { |
|
| 225 | - return; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - // Si la page c1234 a un invalideur de session 'zz', sauver dans |
|
| 229 | - // 'tmp/cache/MD5(chemin_cache)_zz' |
|
| 230 | - if (isset($page['invalideurs']) |
|
| 231 | - and isset($page['invalideurs']['session']) |
|
| 232 | - ) { |
|
| 233 | - // on verifie que le contenu du chemin cache indique seulement |
|
| 234 | - // "cache sessionne" ; sa date indique la date de validite |
|
| 235 | - // des caches sessionnes |
|
| 236 | - if (!$tmp = lire_cache($chemin_cache)) { |
|
| 237 | - spip_log('Creation cache sessionne ' . $chemin_cache); |
|
| 238 | - $tmp = array( |
|
| 239 | - 'invalideurs' => array('session' => ''), |
|
| 240 | - 'lastmodified' => $_SERVER['REQUEST_TIME'] |
|
| 241 | - ); |
|
| 242 | - ecrire_cache($chemin_cache, $tmp); |
|
| 243 | - } |
|
| 244 | - $chemin_cache = generer_nom_fichier_cache(array("chemin_cache" => $chemin_cache), |
|
| 245 | - array("session" => $page['invalideurs']['session'])); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // ajouter la date de production dans le cache lui meme |
|
| 249 | - // (qui contient deja sa duree de validite) |
|
| 250 | - $page['lastmodified'] = $_SERVER['REQUEST_TIME']; |
|
| 251 | - |
|
| 252 | - // compresser le contenu si besoin |
|
| 253 | - $pagez = gzip_page($page); |
|
| 254 | - |
|
| 255 | - // signer le contenu |
|
| 256 | - $pagez['sig'] = cache_signature($pagez); |
|
| 257 | - |
|
| 258 | - // l'enregistrer, compresse ou non... |
|
| 259 | - $ok = ecrire_cache($chemin_cache, $pagez); |
|
| 260 | - |
|
| 261 | - spip_log((_IS_BOT ? "Bot:" : "") . "Creation du cache $chemin_cache pour " |
|
| 262 | - . $page['entetes']['X-Spip-Cache'] . " secondes" . ($ok ? '' : ' (erreur!)'), _LOG_INFO_IMPORTANTE); |
|
| 263 | - |
|
| 264 | - // Inserer ses invalideurs |
|
| 265 | - include_spip('inc/invalideur'); |
|
| 266 | - maj_invalideurs($chemin_cache, $page); |
|
| 218 | + // Ne rien faire si on est en preview, debug, ou si une erreur |
|
| 219 | + // grave s'est presentee (compilation du squelette, MySQL, etc) |
|
| 220 | + // le cas var_nocache ne devrait jamais arriver ici (securite) |
|
| 221 | + // le cas spip_interdire_cache correspond a une ereur SQL grave non anticipable |
|
| 222 | + if ((defined('_VAR_NOCACHE') and _VAR_NOCACHE) |
|
| 223 | + or defined('spip_interdire_cache') |
|
| 224 | + ) { |
|
| 225 | + return; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + // Si la page c1234 a un invalideur de session 'zz', sauver dans |
|
| 229 | + // 'tmp/cache/MD5(chemin_cache)_zz' |
|
| 230 | + if (isset($page['invalideurs']) |
|
| 231 | + and isset($page['invalideurs']['session']) |
|
| 232 | + ) { |
|
| 233 | + // on verifie que le contenu du chemin cache indique seulement |
|
| 234 | + // "cache sessionne" ; sa date indique la date de validite |
|
| 235 | + // des caches sessionnes |
|
| 236 | + if (!$tmp = lire_cache($chemin_cache)) { |
|
| 237 | + spip_log('Creation cache sessionne ' . $chemin_cache); |
|
| 238 | + $tmp = array( |
|
| 239 | + 'invalideurs' => array('session' => ''), |
|
| 240 | + 'lastmodified' => $_SERVER['REQUEST_TIME'] |
|
| 241 | + ); |
|
| 242 | + ecrire_cache($chemin_cache, $tmp); |
|
| 243 | + } |
|
| 244 | + $chemin_cache = generer_nom_fichier_cache(array("chemin_cache" => $chemin_cache), |
|
| 245 | + array("session" => $page['invalideurs']['session'])); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // ajouter la date de production dans le cache lui meme |
|
| 249 | + // (qui contient deja sa duree de validite) |
|
| 250 | + $page['lastmodified'] = $_SERVER['REQUEST_TIME']; |
|
| 251 | + |
|
| 252 | + // compresser le contenu si besoin |
|
| 253 | + $pagez = gzip_page($page); |
|
| 254 | + |
|
| 255 | + // signer le contenu |
|
| 256 | + $pagez['sig'] = cache_signature($pagez); |
|
| 257 | + |
|
| 258 | + // l'enregistrer, compresse ou non... |
|
| 259 | + $ok = ecrire_cache($chemin_cache, $pagez); |
|
| 260 | + |
|
| 261 | + spip_log((_IS_BOT ? "Bot:" : "") . "Creation du cache $chemin_cache pour " |
|
| 262 | + . $page['entetes']['X-Spip-Cache'] . " secondes" . ($ok ? '' : ' (erreur!)'), _LOG_INFO_IMPORTANTE); |
|
| 263 | + |
|
| 264 | + // Inserer ses invalideurs |
|
| 265 | + include_spip('inc/invalideur'); |
|
| 266 | + maj_invalideurs($chemin_cache, $page); |
|
| 267 | 267 | |
| 268 | 268 | } |
| 269 | 269 | |
@@ -279,15 +279,15 @@ discard block |
||
| 279 | 279 | * @return void |
| 280 | 280 | */ |
| 281 | 281 | function nettoyer_petit_cache($prefix, $duree = 300) { |
| 282 | - // determiner le repertoire a purger : 'tmp/CACHE/rech/' |
|
| 283 | - $dircache = sous_repertoire(_DIR_CACHE, $prefix); |
|
| 284 | - if (spip_touch($dircache . 'purger_' . $prefix, $duree, true)) { |
|
| 285 | - foreach (preg_files($dircache, '[.]txt$') as $f) { |
|
| 286 | - if ($_SERVER['REQUEST_TIME'] - (@file_exists($f) ? @filemtime($f) : 0) > $duree) { |
|
| 287 | - spip_unlink($f); |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - } |
|
| 282 | + // determiner le repertoire a purger : 'tmp/CACHE/rech/' |
|
| 283 | + $dircache = sous_repertoire(_DIR_CACHE, $prefix); |
|
| 284 | + if (spip_touch($dircache . 'purger_' . $prefix, $duree, true)) { |
|
| 285 | + foreach (preg_files($dircache, '[.]txt$') as $f) { |
|
| 286 | + if ($_SERVER['REQUEST_TIME'] - (@file_exists($f) ? @filemtime($f) : 0) > $duree) { |
|
| 287 | + spip_unlink($f); |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | |
@@ -317,126 +317,126 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | function public_cacher_dist($contexte, &$use_cache, &$chemin_cache, &$page, &$lastmodified) { |
| 319 | 319 | |
| 320 | - # fonction de cache minimale : dire "non on ne met rien en cache" |
|
| 321 | - # $use_cache = -1; return; |
|
| 322 | - |
|
| 323 | - // Second appel, destine a l'enregistrement du cache sur le disque |
|
| 324 | - if (isset($chemin_cache)) { |
|
| 325 | - return creer_cache($page, $chemin_cache); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - // Toute la suite correspond au premier appel |
|
| 329 | - $contexte_implicite = $page['contexte_implicite']; |
|
| 330 | - |
|
| 331 | - // Cas ignorant le cache car completement dynamique |
|
| 332 | - if ($_SERVER['REQUEST_METHOD'] == 'POST' |
|
| 333 | - or _request('connect') |
|
| 334 | - ) { |
|
| 335 | - $use_cache = -1; |
|
| 336 | - $lastmodified = 0; |
|
| 337 | - $chemin_cache = ""; |
|
| 338 | - $page = array(); |
|
| 339 | - |
|
| 340 | - return; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - // Controler l'existence d'un cache nous correspondant |
|
| 344 | - $chemin_cache = generer_nom_fichier_cache($contexte, $page); |
|
| 345 | - $lastmodified = 0; |
|
| 346 | - |
|
| 347 | - // charger le cache s'il existe (et si il a bien le bon hash = anticollision) |
|
| 348 | - if (!$page = lire_cache($chemin_cache)) { |
|
| 349 | - $page = array(); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - // s'il est sessionne, charger celui correspondant a notre session |
|
| 353 | - if (isset($page['invalideurs']) |
|
| 354 | - and isset($page['invalideurs']['session']) |
|
| 355 | - ) { |
|
| 356 | - $chemin_cache_session = generer_nom_fichier_cache(array("chemin_cache" => $chemin_cache), |
|
| 357 | - array("session" => spip_session())); |
|
| 358 | - if ($page_session = lire_cache($chemin_cache_session) |
|
| 359 | - and $page_session['lastmodified'] >= $page['lastmodified'] |
|
| 360 | - ) { |
|
| 361 | - $page = $page_session; |
|
| 362 | - } else { |
|
| 363 | - $page = array(); |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - |
|
| 368 | - // Faut-il effacer des pages invalidees (en particulier ce cache-ci) ? |
|
| 369 | - if (isset($GLOBALS['meta']['invalider'])) { |
|
| 370 | - // ne le faire que si la base est disponible |
|
| 371 | - if (spip_connect()) { |
|
| 372 | - include_spip('inc/invalideur'); |
|
| 373 | - retire_caches($chemin_cache); # API invalideur inutile |
|
| 374 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 375 | - if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 376 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - // Si un calcul, recalcul [ou preview, mais c'est recalcul] est demande, |
|
| 382 | - // on supprime le cache |
|
| 383 | - if (defined('_VAR_MODE') && _VAR_MODE && |
|
| 384 | - (isset($_COOKIE['spip_session']) |
|
| 385 | - || isset($_COOKIE['spip_admin']) |
|
| 386 | - || @file_exists(_ACCESS_FILE_NAME)) |
|
| 387 | - ) { |
|
| 388 | - $page = array('contexte_implicite' => $contexte_implicite); // ignorer le cache deja lu |
|
| 389 | - include_spip('inc/invalideur'); |
|
| 390 | - retire_caches($chemin_cache); # API invalideur inutile |
|
| 391 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 392 | - if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 393 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - // $delais par defaut |
|
| 398 | - // pour toutes les pages sans #CACHE{} hors modeles/ et espace privé |
|
| 399 | - // qui sont a cache nul par defaut |
|
| 400 | - if (!isset($GLOBALS['delais'])) { |
|
| 401 | - if (!defined('_DUREE_CACHE_DEFAUT')) { |
|
| 402 | - define('_DUREE_CACHE_DEFAUT', 24 * 3600); |
|
| 403 | - } |
|
| 404 | - $GLOBALS['delais'] = _DUREE_CACHE_DEFAUT; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - // determiner la validite de la page |
|
| 408 | - if ($page) { |
|
| 409 | - $use_cache = cache_valide($page, isset($page['lastmodified']) ? $page['lastmodified'] : 0); |
|
| 410 | - // le contexte implicite n'est pas stocke dans le cache, mais il y a equivalence |
|
| 411 | - // par le nom du cache. On le reinjecte donc ici pour utilisation eventuelle au calcul |
|
| 412 | - $page['contexte_implicite'] = $contexte_implicite; |
|
| 413 | - if (!$use_cache) { |
|
| 414 | - // $page est un cache utilisable |
|
| 415 | - gunzip_page($page); |
|
| 416 | - |
|
| 417 | - return; |
|
| 418 | - } |
|
| 419 | - } else { |
|
| 420 | - $page = array('contexte_implicite' => $contexte_implicite); |
|
| 421 | - $use_cache = cache_valide($page, 0); // fichier cache absent : provoque le calcul |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - // Si pas valide mais pas de connexion a la base, le garder quand meme |
|
| 425 | - if (!spip_connect()) { |
|
| 426 | - if (isset($page['texte'])) { |
|
| 427 | - gunzip_page($page); |
|
| 428 | - $use_cache = 0; |
|
| 429 | - } else { |
|
| 430 | - spip_log("Erreur base de donnees, impossible utiliser $chemin_cache"); |
|
| 431 | - include_spip('inc/minipres'); |
|
| 432 | - |
|
| 433 | - return minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), array('status' => 503)); |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - if ($use_cache < 0) { |
|
| 438 | - $chemin_cache = ''; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - return; |
|
| 320 | + # fonction de cache minimale : dire "non on ne met rien en cache" |
|
| 321 | + # $use_cache = -1; return; |
|
| 322 | + |
|
| 323 | + // Second appel, destine a l'enregistrement du cache sur le disque |
|
| 324 | + if (isset($chemin_cache)) { |
|
| 325 | + return creer_cache($page, $chemin_cache); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + // Toute la suite correspond au premier appel |
|
| 329 | + $contexte_implicite = $page['contexte_implicite']; |
|
| 330 | + |
|
| 331 | + // Cas ignorant le cache car completement dynamique |
|
| 332 | + if ($_SERVER['REQUEST_METHOD'] == 'POST' |
|
| 333 | + or _request('connect') |
|
| 334 | + ) { |
|
| 335 | + $use_cache = -1; |
|
| 336 | + $lastmodified = 0; |
|
| 337 | + $chemin_cache = ""; |
|
| 338 | + $page = array(); |
|
| 339 | + |
|
| 340 | + return; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + // Controler l'existence d'un cache nous correspondant |
|
| 344 | + $chemin_cache = generer_nom_fichier_cache($contexte, $page); |
|
| 345 | + $lastmodified = 0; |
|
| 346 | + |
|
| 347 | + // charger le cache s'il existe (et si il a bien le bon hash = anticollision) |
|
| 348 | + if (!$page = lire_cache($chemin_cache)) { |
|
| 349 | + $page = array(); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + // s'il est sessionne, charger celui correspondant a notre session |
|
| 353 | + if (isset($page['invalideurs']) |
|
| 354 | + and isset($page['invalideurs']['session']) |
|
| 355 | + ) { |
|
| 356 | + $chemin_cache_session = generer_nom_fichier_cache(array("chemin_cache" => $chemin_cache), |
|
| 357 | + array("session" => spip_session())); |
|
| 358 | + if ($page_session = lire_cache($chemin_cache_session) |
|
| 359 | + and $page_session['lastmodified'] >= $page['lastmodified'] |
|
| 360 | + ) { |
|
| 361 | + $page = $page_session; |
|
| 362 | + } else { |
|
| 363 | + $page = array(); |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + |
|
| 368 | + // Faut-il effacer des pages invalidees (en particulier ce cache-ci) ? |
|
| 369 | + if (isset($GLOBALS['meta']['invalider'])) { |
|
| 370 | + // ne le faire que si la base est disponible |
|
| 371 | + if (spip_connect()) { |
|
| 372 | + include_spip('inc/invalideur'); |
|
| 373 | + retire_caches($chemin_cache); # API invalideur inutile |
|
| 374 | + supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 375 | + if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 376 | + supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + // Si un calcul, recalcul [ou preview, mais c'est recalcul] est demande, |
|
| 382 | + // on supprime le cache |
|
| 383 | + if (defined('_VAR_MODE') && _VAR_MODE && |
|
| 384 | + (isset($_COOKIE['spip_session']) |
|
| 385 | + || isset($_COOKIE['spip_admin']) |
|
| 386 | + || @file_exists(_ACCESS_FILE_NAME)) |
|
| 387 | + ) { |
|
| 388 | + $page = array('contexte_implicite' => $contexte_implicite); // ignorer le cache deja lu |
|
| 389 | + include_spip('inc/invalideur'); |
|
| 390 | + retire_caches($chemin_cache); # API invalideur inutile |
|
| 391 | + supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 392 | + if (isset($chemin_cache_session) and $chemin_cache_session) { |
|
| 393 | + supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + // $delais par defaut |
|
| 398 | + // pour toutes les pages sans #CACHE{} hors modeles/ et espace privé |
|
| 399 | + // qui sont a cache nul par defaut |
|
| 400 | + if (!isset($GLOBALS['delais'])) { |
|
| 401 | + if (!defined('_DUREE_CACHE_DEFAUT')) { |
|
| 402 | + define('_DUREE_CACHE_DEFAUT', 24 * 3600); |
|
| 403 | + } |
|
| 404 | + $GLOBALS['delais'] = _DUREE_CACHE_DEFAUT; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + // determiner la validite de la page |
|
| 408 | + if ($page) { |
|
| 409 | + $use_cache = cache_valide($page, isset($page['lastmodified']) ? $page['lastmodified'] : 0); |
|
| 410 | + // le contexte implicite n'est pas stocke dans le cache, mais il y a equivalence |
|
| 411 | + // par le nom du cache. On le reinjecte donc ici pour utilisation eventuelle au calcul |
|
| 412 | + $page['contexte_implicite'] = $contexte_implicite; |
|
| 413 | + if (!$use_cache) { |
|
| 414 | + // $page est un cache utilisable |
|
| 415 | + gunzip_page($page); |
|
| 416 | + |
|
| 417 | + return; |
|
| 418 | + } |
|
| 419 | + } else { |
|
| 420 | + $page = array('contexte_implicite' => $contexte_implicite); |
|
| 421 | + $use_cache = cache_valide($page, 0); // fichier cache absent : provoque le calcul |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + // Si pas valide mais pas de connexion a la base, le garder quand meme |
|
| 425 | + if (!spip_connect()) { |
|
| 426 | + if (isset($page['texte'])) { |
|
| 427 | + gunzip_page($page); |
|
| 428 | + $use_cache = 0; |
|
| 429 | + } else { |
|
| 430 | + spip_log("Erreur base de donnees, impossible utiliser $chemin_cache"); |
|
| 431 | + include_spip('inc/minipres'); |
|
| 432 | + |
|
| 433 | + return minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'), array('status' => 503)); |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + if ($use_cache < 0) { |
|
| 438 | + $chemin_cache = ''; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + return; |
|
| 442 | 442 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | function generer_nom_fichier_cache($contexte, $page) { |
| 30 | 30 | $u = md5(var_export(array($contexte, $page), true)); |
| 31 | 31 | |
| 32 | - return $u . ".cache"; |
|
| 32 | + return $u.".cache"; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $rep = sous_repertoire($rep, '', false, true); |
| 47 | 47 | $rep = sous_repertoire($rep, $d, false, true); |
| 48 | 48 | |
| 49 | - return ecrire_fichier($rep . $u . ".cache", serialize(array("nom_cache" => $nom_cache, "valeur" => $valeur))); |
|
| 49 | + return ecrire_fichier($rep.$u.".cache", serialize(array("nom_cache" => $nom_cache, "valeur" => $valeur))); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | function lire_cache($nom_cache) { |
| 59 | 59 | $d = substr($nom_cache, 0, 2); |
| 60 | 60 | $u = substr($nom_cache, 2, 2); |
| 61 | - if (file_exists($f = _DIR_CACHE . "$d/$u.cache") |
|
| 61 | + if (file_exists($f = _DIR_CACHE."$d/$u.cache") |
|
| 62 | 62 | and lire_fichier($f, $tmp) |
| 63 | 63 | and $tmp = unserialize($tmp) |
| 64 | 64 | and $tmp['nom_cache'] == $nom_cache |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | include_spip('inc/acces'); |
| 78 | 78 | include_spip('auth/sha256.inc'); |
| 79 | 79 | ecrire_meta('cache_signature', |
| 80 | - _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non'); |
|
| 80 | + _nano_sha256($_SERVER["DOCUMENT_ROOT"].$_SERVER["SERVER_SIGNATURE"].creer_uniqid()), 'non'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - return crc32($GLOBALS['meta']['cache_signature'] . $page['texte']); |
|
| 83 | + return crc32($GLOBALS['meta']['cache_signature'].$page['texte']); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // "cache sessionne" ; sa date indique la date de validite |
| 235 | 235 | // des caches sessionnes |
| 236 | 236 | if (!$tmp = lire_cache($chemin_cache)) { |
| 237 | - spip_log('Creation cache sessionne ' . $chemin_cache); |
|
| 237 | + spip_log('Creation cache sessionne '.$chemin_cache); |
|
| 238 | 238 | $tmp = array( |
| 239 | 239 | 'invalideurs' => array('session' => ''), |
| 240 | 240 | 'lastmodified' => $_SERVER['REQUEST_TIME'] |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | // l'enregistrer, compresse ou non... |
| 259 | 259 | $ok = ecrire_cache($chemin_cache, $pagez); |
| 260 | 260 | |
| 261 | - spip_log((_IS_BOT ? "Bot:" : "") . "Creation du cache $chemin_cache pour " |
|
| 262 | - . $page['entetes']['X-Spip-Cache'] . " secondes" . ($ok ? '' : ' (erreur!)'), _LOG_INFO_IMPORTANTE); |
|
| 261 | + spip_log((_IS_BOT ? "Bot:" : "")."Creation du cache $chemin_cache pour " |
|
| 262 | + . $page['entetes']['X-Spip-Cache']." secondes".($ok ? '' : ' (erreur!)'), _LOG_INFO_IMPORTANTE); |
|
| 263 | 263 | |
| 264 | 264 | // Inserer ses invalideurs |
| 265 | 265 | include_spip('inc/invalideur'); |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | function nettoyer_petit_cache($prefix, $duree = 300) { |
| 282 | 282 | // determiner le repertoire a purger : 'tmp/CACHE/rech/' |
| 283 | 283 | $dircache = sous_repertoire(_DIR_CACHE, $prefix); |
| 284 | - if (spip_touch($dircache . 'purger_' . $prefix, $duree, true)) { |
|
| 284 | + if (spip_touch($dircache.'purger_'.$prefix, $duree, true)) { |
|
| 285 | 285 | foreach (preg_files($dircache, '[.]txt$') as $f) { |
| 286 | 286 | if ($_SERVER['REQUEST_TIME'] - (@file_exists($f) ? @filemtime($f) : 0) > $duree) { |
| 287 | 287 | spip_unlink($f); |
@@ -371,9 +371,9 @@ discard block |
||
| 371 | 371 | if (spip_connect()) { |
| 372 | 372 | include_spip('inc/invalideur'); |
| 373 | 373 | retire_caches($chemin_cache); # API invalideur inutile |
| 374 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 374 | + supprimer_fichier(_DIR_CACHE.$chemin_cache); |
|
| 375 | 375 | if (isset($chemin_cache_session) and $chemin_cache_session) { |
| 376 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 376 | + supprimer_fichier(_DIR_CACHE.$chemin_cache_session); |
|
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | } |
@@ -388,9 +388,9 @@ discard block |
||
| 388 | 388 | $page = array('contexte_implicite' => $contexte_implicite); // ignorer le cache deja lu |
| 389 | 389 | include_spip('inc/invalideur'); |
| 390 | 390 | retire_caches($chemin_cache); # API invalideur inutile |
| 391 | - supprimer_fichier(_DIR_CACHE . $chemin_cache); |
|
| 391 | + supprimer_fichier(_DIR_CACHE.$chemin_cache); |
|
| 392 | 392 | if (isset($chemin_cache_session) and $chemin_cache_session) { |
| 393 | - supprimer_fichier(_DIR_CACHE . $chemin_cache_session); |
|
| 393 | + supprimer_fichier(_DIR_CACHE.$chemin_cache_session); |
|
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | 396 | |
@@ -187,9 +187,11 @@ |
||
| 187 | 187 | // Sinon comparer l'age du fichier a sa duree de cache |
| 188 | 188 | $duree = intval($page['entetes']['X-Spip-Cache']); |
| 189 | 189 | $cache_mark = (isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0); |
| 190 | - if ($duree == 0) #CACHE{0} |
|
| 190 | + if ($duree == 0) { |
|
| 191 | + #CACHE{0} |
|
| 191 | 192 | { |
| 192 | 193 | return -1; |
| 194 | + } |
|
| 193 | 195 | } // sauf pour les bots, qui utilisent toujours le cache |
| 194 | 196 | else { |
| 195 | 197 | if ((!_IS_BOT and $date + $duree < $now) |
@@ -11,127 +11,127 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // Decompilation de l'arbre de syntaxe abstraite d'un squelette SPIP |
| 18 | 18 | |
| 19 | 19 | function decompiler_boucle($struct, $fmt = '', $prof = 0) { |
| 20 | - $nom = $struct->id_boucle; |
|
| 21 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 22 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 23 | - $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 24 | - $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 25 | - |
|
| 26 | - $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 27 | - $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 28 | - $struct->table_optionnelle); |
|
| 29 | - |
|
| 30 | - if ($struct->jointures_explicites) { |
|
| 31 | - $type .= " " . $struct->jointures_explicites; |
|
| 32 | - } |
|
| 33 | - if ($struct->table_optionnelle) { |
|
| 34 | - $type .= "?"; |
|
| 35 | - } |
|
| 36 | - // Revoir le cas de la boucle recursive |
|
| 37 | - |
|
| 38 | - $crit = $struct->param; |
|
| 39 | - if ($crit and !is_array($crit[0])) { |
|
| 40 | - $type = strtolower($type) . array_shift($crit); |
|
| 41 | - } |
|
| 42 | - $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 43 | - |
|
| 44 | - $f = 'format_boucle_' . $fmt; |
|
| 45 | - |
|
| 46 | - return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof); |
|
| 20 | + $nom = $struct->id_boucle; |
|
| 21 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 22 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 23 | + $altern = decompiler_($struct->altern, $fmt, $prof); |
|
| 24 | + $milieu = decompiler_($struct->milieu, $fmt, $prof); |
|
| 25 | + |
|
| 26 | + $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
|
| 27 | + $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 28 | + $struct->table_optionnelle); |
|
| 29 | + |
|
| 30 | + if ($struct->jointures_explicites) { |
|
| 31 | + $type .= " " . $struct->jointures_explicites; |
|
| 32 | + } |
|
| 33 | + if ($struct->table_optionnelle) { |
|
| 34 | + $type .= "?"; |
|
| 35 | + } |
|
| 36 | + // Revoir le cas de la boucle recursive |
|
| 37 | + |
|
| 38 | + $crit = $struct->param; |
|
| 39 | + if ($crit and !is_array($crit[0])) { |
|
| 40 | + $type = strtolower($type) . array_shift($crit); |
|
| 41 | + } |
|
| 42 | + $crit = decompiler_criteres($struct, $fmt, $prof); |
|
| 43 | + |
|
| 44 | + $f = 'format_boucle_' . $fmt; |
|
| 45 | + |
|
| 46 | + return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | function decompiler_include($struct, $fmt = '', $prof = 0) { |
| 50 | - $res = array(); |
|
| 51 | - foreach ($struct->param ? $struct->param : array() as $couple) { |
|
| 52 | - array_shift($couple); |
|
| 53 | - foreach ($couple as $v) { |
|
| 54 | - $res[] = decompiler_($v, $fmt, $prof); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 58 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 59 | - $f = 'format_inclure_' . $fmt; |
|
| 60 | - |
|
| 61 | - return $f($file, $res, $prof); |
|
| 50 | + $res = array(); |
|
| 51 | + foreach ($struct->param ? $struct->param : array() as $couple) { |
|
| 52 | + array_shift($couple); |
|
| 53 | + foreach ($couple as $v) { |
|
| 54 | + $res[] = decompiler_($v, $fmt, $prof); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + $file = is_string($struct->texte) ? $struct->texte : |
|
| 58 | + decompiler_($struct->texte, $fmt, $prof); |
|
| 59 | + $f = 'format_inclure_' . $fmt; |
|
| 60 | + |
|
| 61 | + return $f($file, $res, $prof); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | function decompiler_texte($struct, $fmt = '', $prof = 0) { |
| 65 | - $f = 'format_texte_' . $fmt; |
|
| 65 | + $f = 'format_texte_' . $fmt; |
|
| 66 | 66 | |
| 67 | - return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 67 | + return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | function decompiler_polyglotte($struct, $fmt = '', $prof = 0) { |
| 71 | - $f = 'format_polyglotte_' . $fmt; |
|
| 71 | + $f = 'format_polyglotte_' . $fmt; |
|
| 72 | 72 | |
| 73 | - return $f($struct->traductions, $prof); |
|
| 73 | + return $f($struct->traductions, $prof); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | function decompiler_idiome($struct, $fmt = '', $prof = 0) { |
| 77 | - $args = array(); |
|
| 78 | - foreach ($struct->arg as $k => $v) { |
|
| 79 | - $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 80 | - } |
|
| 77 | + $args = array(); |
|
| 78 | + foreach ($struct->arg as $k => $v) { |
|
| 79 | + $args[$k] = public_decompiler($v, $fmt, $prof); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 82 | + $filtres = decompiler_liste($struct->param, $fmt, $prof); |
|
| 83 | 83 | |
| 84 | - $f = 'format_idiome_' . $fmt; |
|
| 84 | + $f = 'format_idiome_' . $fmt; |
|
| 85 | 85 | |
| 86 | - return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 86 | + return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | function decompiler_champ($struct, $fmt = '', $prof = 0) { |
| 90 | - $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 91 | - $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 92 | - $args = $filtres = ''; |
|
| 93 | - if ($p = $struct->param) { |
|
| 94 | - if ($p[0][0] === '') { |
|
| 95 | - $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 96 | - } |
|
| 97 | - $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 98 | - } |
|
| 99 | - $f = 'format_champ_' . $fmt; |
|
| 100 | - |
|
| 101 | - return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 90 | + $avant = decompiler_($struct->avant, $fmt, $prof); |
|
| 91 | + $apres = decompiler_($struct->apres, $fmt, $prof); |
|
| 92 | + $args = $filtres = ''; |
|
| 93 | + if ($p = $struct->param) { |
|
| 94 | + if ($p[0][0] === '') { |
|
| 95 | + $args = decompiler_liste(array(array_shift($p)), $fmt, $prof); |
|
| 96 | + } |
|
| 97 | + $filtres = decompiler_liste($p, $fmt, $prof); |
|
| 98 | + } |
|
| 99 | + $f = 'format_champ_' . $fmt; |
|
| 100 | + |
|
| 101 | + return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | function decompiler_liste($sources, $fmt = '', $prof = 0) { |
| 105 | - if (!is_array($sources)) { |
|
| 106 | - return ''; |
|
| 107 | - } |
|
| 108 | - $f = 'format_liste_' . $fmt; |
|
| 109 | - $res = ''; |
|
| 110 | - foreach ($sources as $arg) { |
|
| 111 | - if (!is_array($arg)) { |
|
| 112 | - continue; // ne devrait pas arriver. |
|
| 113 | - } else { |
|
| 114 | - $r = array_shift($arg); |
|
| 115 | - } |
|
| 116 | - $args = array(); |
|
| 117 | - foreach ($arg as $v) { |
|
| 118 | - // cas des arguments entoures de ' ou " |
|
| 119 | - if ((count($v) == 1) |
|
| 120 | - and $v[0]->type == 'texte' |
|
| 121 | - and (strlen($v[0]->apres) == 1) |
|
| 122 | - and $v[0]->apres == $v[0]->avant |
|
| 123 | - ) { |
|
| 124 | - $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 125 | - } else { |
|
| 126 | - $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - if (($r !== '') or $args) { |
|
| 130 | - $res .= $f($r, $args, $prof); |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - return $res; |
|
| 105 | + if (!is_array($sources)) { |
|
| 106 | + return ''; |
|
| 107 | + } |
|
| 108 | + $f = 'format_liste_' . $fmt; |
|
| 109 | + $res = ''; |
|
| 110 | + foreach ($sources as $arg) { |
|
| 111 | + if (!is_array($arg)) { |
|
| 112 | + continue; // ne devrait pas arriver. |
|
| 113 | + } else { |
|
| 114 | + $r = array_shift($arg); |
|
| 115 | + } |
|
| 116 | + $args = array(); |
|
| 117 | + foreach ($arg as $v) { |
|
| 118 | + // cas des arguments entoures de ' ou " |
|
| 119 | + if ((count($v) == 1) |
|
| 120 | + and $v[0]->type == 'texte' |
|
| 121 | + and (strlen($v[0]->apres) == 1) |
|
| 122 | + and $v[0]->apres == $v[0]->avant |
|
| 123 | + ) { |
|
| 124 | + $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 125 | + } else { |
|
| 126 | + $args[] = decompiler_($v, $fmt, 0 - $prof); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + if (($r !== '') or $args) { |
|
| 130 | + $res .= $f($r, $args, $prof); |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + return $res; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Decompilation des criteres: on triche et on deroge: |
@@ -139,91 +139,91 @@ discard block |
||
| 139 | 139 | // - le champ apres signale le critere {"separateur"} ou {'separateur'} |
| 140 | 140 | // - les champs sont implicitement etendus (crochets implicites mais interdits) |
| 141 | 141 | function decompiler_criteres($boucle, $fmt = '', $prof = 0) { |
| 142 | - $sources = $boucle->param; |
|
| 143 | - if (!is_array($sources)) { |
|
| 144 | - return ''; |
|
| 145 | - } |
|
| 146 | - $res = ''; |
|
| 147 | - $f = 'format_critere_' . $fmt; |
|
| 148 | - foreach ($sources as $crit) { |
|
| 149 | - if (!is_array($crit)) { |
|
| 150 | - continue; |
|
| 151 | - } // boucle recursive |
|
| 152 | - array_shift($crit); |
|
| 153 | - $args = array(); |
|
| 154 | - foreach ($crit as $i => $v) { |
|
| 155 | - if ((count($v) == 1) |
|
| 156 | - and $v[0]->type == 'texte' |
|
| 157 | - and $v[0]->apres |
|
| 158 | - ) { |
|
| 159 | - $args[] = array(array('texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 160 | - } else { |
|
| 161 | - $res2 = array(); |
|
| 162 | - foreach ($v as $k => $p) { |
|
| 163 | - if (isset($p->type) |
|
| 164 | - and function_exists($d = 'decompiler_' . $p->type) |
|
| 165 | - ) { |
|
| 166 | - $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
|
| 167 | - $res2[] = array($p->type, $r); |
|
| 168 | - } else { |
|
| 169 | - spip_log("critere $i / $k mal forme"); |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - $args[] = $res2; |
|
| 173 | - } |
|
| 174 | - } |
|
| 175 | - $res .= $f($args); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - return $res; |
|
| 142 | + $sources = $boucle->param; |
|
| 143 | + if (!is_array($sources)) { |
|
| 144 | + return ''; |
|
| 145 | + } |
|
| 146 | + $res = ''; |
|
| 147 | + $f = 'format_critere_' . $fmt; |
|
| 148 | + foreach ($sources as $crit) { |
|
| 149 | + if (!is_array($crit)) { |
|
| 150 | + continue; |
|
| 151 | + } // boucle recursive |
|
| 152 | + array_shift($crit); |
|
| 153 | + $args = array(); |
|
| 154 | + foreach ($crit as $i => $v) { |
|
| 155 | + if ((count($v) == 1) |
|
| 156 | + and $v[0]->type == 'texte' |
|
| 157 | + and $v[0]->apres |
|
| 158 | + ) { |
|
| 159 | + $args[] = array(array('texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 160 | + } else { |
|
| 161 | + $res2 = array(); |
|
| 162 | + foreach ($v as $k => $p) { |
|
| 163 | + if (isset($p->type) |
|
| 164 | + and function_exists($d = 'decompiler_' . $p->type) |
|
| 165 | + ) { |
|
| 166 | + $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
|
| 167 | + $res2[] = array($p->type, $r); |
|
| 168 | + } else { |
|
| 169 | + spip_log("critere $i / $k mal forme"); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + $args[] = $res2; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | + $res .= $f($args); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + return $res; |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | |
| 182 | 182 | function decompiler_($liste, $fmt = '', $prof = 0) { |
| 183 | - if (!is_array($liste)) { |
|
| 184 | - return ''; |
|
| 185 | - } |
|
| 186 | - $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 187 | - $contenu = array(); |
|
| 188 | - foreach ($liste as $k => $p) { |
|
| 189 | - if (!isset($p->type)) { |
|
| 190 | - continue; |
|
| 191 | - } #?????? |
|
| 192 | - $d = 'decompiler_' . $p->type; |
|
| 193 | - $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
|
| 194 | - // Forcer le champ etendu si son source (pas les reecritures) |
|
| 195 | - // contenait des args et s'il est suivi d'espaces, |
|
| 196 | - // le champ simple les eliminant est un bug helas perenne. |
|
| 197 | - |
|
| 198 | - if ($next |
|
| 199 | - and ($next->type == 'texte') |
|
| 200 | - and $p->type == 'champ' |
|
| 201 | - and !$p->apres |
|
| 202 | - and !$p->avant |
|
| 203 | - and $p->fonctions |
|
| 204 | - ) { |
|
| 205 | - $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 206 | - if ($n) { |
|
| 207 | - $champ = new Texte; |
|
| 208 | - $champ->texte = substr($next->texte, 0, $n); |
|
| 209 | - $champ->ligne = $p->ligne; |
|
| 210 | - $p->apres = array($champ); |
|
| 211 | - $next->texte = substr($next->texte, $n); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
|
| 215 | - |
|
| 216 | - } |
|
| 217 | - $f = 'format_suite_' . $fmt; |
|
| 218 | - |
|
| 219 | - return $f($contenu); |
|
| 183 | + if (!is_array($liste)) { |
|
| 184 | + return ''; |
|
| 185 | + } |
|
| 186 | + $prof2 = ($prof < 0) ? ($prof - 1) : ($prof + 1); |
|
| 187 | + $contenu = array(); |
|
| 188 | + foreach ($liste as $k => $p) { |
|
| 189 | + if (!isset($p->type)) { |
|
| 190 | + continue; |
|
| 191 | + } #?????? |
|
| 192 | + $d = 'decompiler_' . $p->type; |
|
| 193 | + $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
|
| 194 | + // Forcer le champ etendu si son source (pas les reecritures) |
|
| 195 | + // contenait des args et s'il est suivi d'espaces, |
|
| 196 | + // le champ simple les eliminant est un bug helas perenne. |
|
| 197 | + |
|
| 198 | + if ($next |
|
| 199 | + and ($next->type == 'texte') |
|
| 200 | + and $p->type == 'champ' |
|
| 201 | + and !$p->apres |
|
| 202 | + and !$p->avant |
|
| 203 | + and $p->fonctions |
|
| 204 | + ) { |
|
| 205 | + $n = strlen($next->texte) - strlen(ltrim($next->texte)); |
|
| 206 | + if ($n) { |
|
| 207 | + $champ = new Texte; |
|
| 208 | + $champ->texte = substr($next->texte, 0, $n); |
|
| 209 | + $champ->ligne = $p->ligne; |
|
| 210 | + $p->apres = array($champ); |
|
| 211 | + $next->texte = substr($next->texte, $n); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
|
| 215 | + |
|
| 216 | + } |
|
| 217 | + $f = 'format_suite_' . $fmt; |
|
| 218 | + |
|
| 219 | + return $f($contenu); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') { |
| 223 | - if (!include_spip('public/format_' . $fmt)) { |
|
| 224 | - return "'$fmt'?"; |
|
| 225 | - } |
|
| 226 | - $f = 'decompiler_' . $quoi; |
|
| 223 | + if (!include_spip('public/format_' . $fmt)) { |
|
| 224 | + return "'$fmt'?"; |
|
| 225 | + } |
|
| 226 | + $f = 'decompiler_' . $quoi; |
|
| 227 | 227 | |
| 228 | - return $f($liste, $fmt, $prof); |
|
| 228 | + return $f($liste, $fmt, $prof); |
|
| 229 | 229 | } |
@@ -24,11 +24,10 @@ discard block |
||
| 24 | 24 | $milieu = decompiler_($struct->milieu, $fmt, $prof); |
| 25 | 25 | |
| 26 | 26 | $type = $struct->sql_serveur ? "$struct->sql_serveur:" : ''; |
| 27 | - $type .= ($struct->type_requete ? $struct->type_requete : |
|
| 28 | - $struct->table_optionnelle); |
|
| 27 | + $type .= ($struct->type_requete ? $struct->type_requete : $struct->table_optionnelle); |
|
| 29 | 28 | |
| 30 | 29 | if ($struct->jointures_explicites) { |
| 31 | - $type .= " " . $struct->jointures_explicites; |
|
| 30 | + $type .= " ".$struct->jointures_explicites; |
|
| 32 | 31 | } |
| 33 | 32 | if ($struct->table_optionnelle) { |
| 34 | 33 | $type .= "?"; |
@@ -37,11 +36,11 @@ discard block |
||
| 37 | 36 | |
| 38 | 37 | $crit = $struct->param; |
| 39 | 38 | if ($crit and !is_array($crit[0])) { |
| 40 | - $type = strtolower($type) . array_shift($crit); |
|
| 39 | + $type = strtolower($type).array_shift($crit); |
|
| 41 | 40 | } |
| 42 | 41 | $crit = decompiler_criteres($struct, $fmt, $prof); |
| 43 | 42 | |
| 44 | - $f = 'format_boucle_' . $fmt; |
|
| 43 | + $f = 'format_boucle_'.$fmt; |
|
| 45 | 44 | |
| 46 | 45 | return $f($avant, $nom, $type, $crit, $milieu, $apres, $altern, $prof); |
| 47 | 46 | } |
@@ -54,21 +53,20 @@ discard block |
||
| 54 | 53 | $res[] = decompiler_($v, $fmt, $prof); |
| 55 | 54 | } |
| 56 | 55 | } |
| 57 | - $file = is_string($struct->texte) ? $struct->texte : |
|
| 58 | - decompiler_($struct->texte, $fmt, $prof); |
|
| 59 | - $f = 'format_inclure_' . $fmt; |
|
| 56 | + $file = is_string($struct->texte) ? $struct->texte : decompiler_($struct->texte, $fmt, $prof); |
|
| 57 | + $f = 'format_inclure_'.$fmt; |
|
| 60 | 58 | |
| 61 | 59 | return $f($file, $res, $prof); |
| 62 | 60 | } |
| 63 | 61 | |
| 64 | 62 | function decompiler_texte($struct, $fmt = '', $prof = 0) { |
| 65 | - $f = 'format_texte_' . $fmt; |
|
| 63 | + $f = 'format_texte_'.$fmt; |
|
| 66 | 64 | |
| 67 | 65 | return strlen($struct->texte) ? $f($struct->texte, $prof) : ''; |
| 68 | 66 | } |
| 69 | 67 | |
| 70 | 68 | function decompiler_polyglotte($struct, $fmt = '', $prof = 0) { |
| 71 | - $f = 'format_polyglotte_' . $fmt; |
|
| 69 | + $f = 'format_polyglotte_'.$fmt; |
|
| 72 | 70 | |
| 73 | 71 | return $f($struct->traductions, $prof); |
| 74 | 72 | } |
@@ -81,7 +79,7 @@ discard block |
||
| 81 | 79 | |
| 82 | 80 | $filtres = decompiler_liste($struct->param, $fmt, $prof); |
| 83 | 81 | |
| 84 | - $f = 'format_idiome_' . $fmt; |
|
| 82 | + $f = 'format_idiome_'.$fmt; |
|
| 85 | 83 | |
| 86 | 84 | return $f($struct->nom_champ, $struct->module, $args, $filtres, $prof); |
| 87 | 85 | } |
@@ -96,7 +94,7 @@ discard block |
||
| 96 | 94 | } |
| 97 | 95 | $filtres = decompiler_liste($p, $fmt, $prof); |
| 98 | 96 | } |
| 99 | - $f = 'format_champ_' . $fmt; |
|
| 97 | + $f = 'format_champ_'.$fmt; |
|
| 100 | 98 | |
| 101 | 99 | return $f($struct->nom_champ, $struct->nom_boucle, $struct->etoile, $avant, $apres, $args, $filtres, $prof); |
| 102 | 100 | } |
@@ -105,7 +103,7 @@ discard block |
||
| 105 | 103 | if (!is_array($sources)) { |
| 106 | 104 | return ''; |
| 107 | 105 | } |
| 108 | - $f = 'format_liste_' . $fmt; |
|
| 106 | + $f = 'format_liste_'.$fmt; |
|
| 109 | 107 | $res = ''; |
| 110 | 108 | foreach ($sources as $arg) { |
| 111 | 109 | if (!is_array($arg)) { |
@@ -121,7 +119,7 @@ discard block |
||
| 121 | 119 | and (strlen($v[0]->apres) == 1) |
| 122 | 120 | and $v[0]->apres == $v[0]->avant |
| 123 | 121 | ) { |
| 124 | - $args[] = $v[0]->avant . $v[0]->texte . $v[0]->apres; |
|
| 122 | + $args[] = $v[0]->avant.$v[0]->texte.$v[0]->apres; |
|
| 125 | 123 | } else { |
| 126 | 124 | $args[] = decompiler_($v, $fmt, 0 - $prof); |
| 127 | 125 | } |
@@ -144,7 +142,7 @@ discard block |
||
| 144 | 142 | return ''; |
| 145 | 143 | } |
| 146 | 144 | $res = ''; |
| 147 | - $f = 'format_critere_' . $fmt; |
|
| 145 | + $f = 'format_critere_'.$fmt; |
|
| 148 | 146 | foreach ($sources as $crit) { |
| 149 | 147 | if (!is_array($crit)) { |
| 150 | 148 | continue; |
@@ -156,12 +154,12 @@ discard block |
||
| 156 | 154 | and $v[0]->type == 'texte' |
| 157 | 155 | and $v[0]->apres |
| 158 | 156 | ) { |
| 159 | - $args[] = array(array('texte', ($v[0]->apres . $v[0]->texte . $v[0]->apres))); |
|
| 157 | + $args[] = array(array('texte', ($v[0]->apres.$v[0]->texte.$v[0]->apres))); |
|
| 160 | 158 | } else { |
| 161 | 159 | $res2 = array(); |
| 162 | 160 | foreach ($v as $k => $p) { |
| 163 | 161 | if (isset($p->type) |
| 164 | - and function_exists($d = 'decompiler_' . $p->type) |
|
| 162 | + and function_exists($d = 'decompiler_'.$p->type) |
|
| 165 | 163 | ) { |
| 166 | 164 | $r = $d($p, $fmt, (0 - $prof), @$v[$k + 1]); |
| 167 | 165 | $res2[] = array($p->type, $r); |
@@ -189,7 +187,7 @@ discard block |
||
| 189 | 187 | if (!isset($p->type)) { |
| 190 | 188 | continue; |
| 191 | 189 | } #?????? |
| 192 | - $d = 'decompiler_' . $p->type; |
|
| 190 | + $d = 'decompiler_'.$p->type; |
|
| 193 | 191 | $next = isset($liste[$k + 1]) ? $liste[$k + 1] : false; |
| 194 | 192 | // Forcer le champ etendu si son source (pas les reecritures) |
| 195 | 193 | // contenait des args et s'il est suivi d'espaces, |
@@ -214,16 +212,16 @@ discard block |
||
| 214 | 212 | $contenu[] = array($d($p, $fmt, $prof2), $p->type); |
| 215 | 213 | |
| 216 | 214 | } |
| 217 | - $f = 'format_suite_' . $fmt; |
|
| 215 | + $f = 'format_suite_'.$fmt; |
|
| 218 | 216 | |
| 219 | 217 | return $f($contenu); |
| 220 | 218 | } |
| 221 | 219 | |
| 222 | 220 | function public_decompiler($liste, $fmt = '', $prof = 0, $quoi = '') { |
| 223 | - if (!include_spip('public/format_' . $fmt)) { |
|
| 221 | + if (!include_spip('public/format_'.$fmt)) { |
|
| 224 | 222 | return "'$fmt'?"; |
| 225 | 223 | } |
| 226 | - $f = 'decompiler_' . $quoi; |
|
| 224 | + $f = 'decompiler_'.$quoi; |
|
| 227 | 225 | |
| 228 | 226 | return $f($liste, $fmt, $prof); |
| 229 | 227 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | **/ |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // Ce fichier doit imperativement definir la fonction ci-dessous: |
@@ -39,53 +39,53 @@ discard block |
||
| 39 | 39 | * @return array |
| 40 | 40 | */ |
| 41 | 41 | function public_styliser_dist($fond, $contexte, $lang = '', $connect = '') { |
| 42 | - static $styliser_par_z; |
|
| 43 | - |
|
| 44 | - // s'assurer que le fond est licite |
|
| 45 | - // car il peut etre construit a partir d'une variable d'environnement |
|
| 46 | - if (strpos($fond, "../") !== false or strncmp($fond, '/', 1) == 0) { |
|
| 47 | - $fond = "404"; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // Choisir entre $fond-dist.html, $fond=7.html, etc? |
|
| 51 | - $id_rubrique = 0; |
|
| 52 | - // Chercher le fond qui va servir de squelette |
|
| 53 | - if ($r = quete_rubrique_fond($contexte)) { |
|
| 54 | - list($id_rubrique, $lang) = $r; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - // trouver un squelette du nom demande |
|
| 58 | - // ne rien dire si on ne trouve pas, |
|
| 59 | - // c'est l'appelant qui sait comment gerer la situation |
|
| 60 | - // ou les plugins qui feront mieux dans le pipeline |
|
| 61 | - $squelette = trouver_fond($fond, "", true); |
|
| 62 | - $ext = $squelette['extension']; |
|
| 63 | - |
|
| 64 | - $flux = array( |
|
| 65 | - 'args' => array( |
|
| 66 | - 'id_rubrique' => $id_rubrique, |
|
| 67 | - 'ext' => $ext, |
|
| 68 | - 'fond' => $fond, |
|
| 69 | - 'lang' => $lang, |
|
| 70 | - 'contexte' => $contexte, // le style d'un objet peut dependre de lui meme |
|
| 71 | - 'connect' => $connect |
|
| 72 | - ), |
|
| 73 | - 'data' => $squelette['fond'], |
|
| 74 | - ); |
|
| 75 | - |
|
| 76 | - if (test_espace_prive() or defined('_ZPIP')) { |
|
| 77 | - if (!$styliser_par_z) { |
|
| 78 | - $styliser_par_z = charger_fonction('styliser_par_z', 'public'); |
|
| 79 | - } |
|
| 80 | - $flux = $styliser_par_z($flux); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $flux = styliser_par_objets($flux); |
|
| 84 | - |
|
| 85 | - // pipeline styliser |
|
| 86 | - $squelette = pipeline('styliser', $flux); |
|
| 87 | - |
|
| 88 | - return array($squelette, $ext, $ext, "$squelette.$ext"); |
|
| 42 | + static $styliser_par_z; |
|
| 43 | + |
|
| 44 | + // s'assurer que le fond est licite |
|
| 45 | + // car il peut etre construit a partir d'une variable d'environnement |
|
| 46 | + if (strpos($fond, "../") !== false or strncmp($fond, '/', 1) == 0) { |
|
| 47 | + $fond = "404"; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // Choisir entre $fond-dist.html, $fond=7.html, etc? |
|
| 51 | + $id_rubrique = 0; |
|
| 52 | + // Chercher le fond qui va servir de squelette |
|
| 53 | + if ($r = quete_rubrique_fond($contexte)) { |
|
| 54 | + list($id_rubrique, $lang) = $r; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + // trouver un squelette du nom demande |
|
| 58 | + // ne rien dire si on ne trouve pas, |
|
| 59 | + // c'est l'appelant qui sait comment gerer la situation |
|
| 60 | + // ou les plugins qui feront mieux dans le pipeline |
|
| 61 | + $squelette = trouver_fond($fond, "", true); |
|
| 62 | + $ext = $squelette['extension']; |
|
| 63 | + |
|
| 64 | + $flux = array( |
|
| 65 | + 'args' => array( |
|
| 66 | + 'id_rubrique' => $id_rubrique, |
|
| 67 | + 'ext' => $ext, |
|
| 68 | + 'fond' => $fond, |
|
| 69 | + 'lang' => $lang, |
|
| 70 | + 'contexte' => $contexte, // le style d'un objet peut dependre de lui meme |
|
| 71 | + 'connect' => $connect |
|
| 72 | + ), |
|
| 73 | + 'data' => $squelette['fond'], |
|
| 74 | + ); |
|
| 75 | + |
|
| 76 | + if (test_espace_prive() or defined('_ZPIP')) { |
|
| 77 | + if (!$styliser_par_z) { |
|
| 78 | + $styliser_par_z = charger_fonction('styliser_par_z', 'public'); |
|
| 79 | + } |
|
| 80 | + $flux = $styliser_par_z($flux); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $flux = styliser_par_objets($flux); |
|
| 84 | + |
|
| 85 | + // pipeline styliser |
|
| 86 | + $squelette = pipeline('styliser', $flux); |
|
| 87 | + |
|
| 88 | + return array($squelette, $ext, $ext, "$squelette.$ext"); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -104,31 +104,31 @@ discard block |
||
| 104 | 104 | * Données du pipeline styliser |
| 105 | 105 | **/ |
| 106 | 106 | function styliser_par_objets($flux) { |
| 107 | - if (test_espace_prive() |
|
| 108 | - and !$squelette = $flux['data'] |
|
| 109 | - and strncmp($flux['args']['fond'], 'prive/objets/', 13) == 0 |
|
| 110 | - and $echafauder = charger_fonction('echafauder', 'prive', true) |
|
| 111 | - ) { |
|
| 112 | - if (strncmp($flux['args']['fond'], 'prive/objets/liste/', 19) == 0) { |
|
| 113 | - $table = table_objet(substr($flux['args']['fond'], 19)); |
|
| 114 | - $table_sql = table_objet_sql($table); |
|
| 115 | - $objets = lister_tables_objets_sql(); |
|
| 116 | - if (isset($objets[$table_sql])) { |
|
| 117 | - $flux['data'] = $echafauder($table, $table, $table_sql, "prive/objets/liste/objets", $flux['args']['ext']); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - if (strncmp($flux['args']['fond'], 'prive/objets/contenu/', 21) == 0) { |
|
| 121 | - $type = substr($flux['args']['fond'], 21); |
|
| 122 | - $table = table_objet($type); |
|
| 123 | - $table_sql = table_objet_sql($table); |
|
| 124 | - $objets = lister_tables_objets_sql(); |
|
| 125 | - if (isset($objets[$table_sql])) { |
|
| 126 | - $flux['data'] = $echafauder($type, $table, $table_sql, "prive/objets/contenu/objet", $flux['args']['ext']); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - return $flux; |
|
| 107 | + if (test_espace_prive() |
|
| 108 | + and !$squelette = $flux['data'] |
|
| 109 | + and strncmp($flux['args']['fond'], 'prive/objets/', 13) == 0 |
|
| 110 | + and $echafauder = charger_fonction('echafauder', 'prive', true) |
|
| 111 | + ) { |
|
| 112 | + if (strncmp($flux['args']['fond'], 'prive/objets/liste/', 19) == 0) { |
|
| 113 | + $table = table_objet(substr($flux['args']['fond'], 19)); |
|
| 114 | + $table_sql = table_objet_sql($table); |
|
| 115 | + $objets = lister_tables_objets_sql(); |
|
| 116 | + if (isset($objets[$table_sql])) { |
|
| 117 | + $flux['data'] = $echafauder($table, $table, $table_sql, "prive/objets/liste/objets", $flux['args']['ext']); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + if (strncmp($flux['args']['fond'], 'prive/objets/contenu/', 21) == 0) { |
|
| 121 | + $type = substr($flux['args']['fond'], 21); |
|
| 122 | + $table = table_objet($type); |
|
| 123 | + $table_sql = table_objet_sql($table); |
|
| 124 | + $objets = lister_tables_objets_sql(); |
|
| 125 | + if (isset($objets[$table_sql])) { |
|
| 126 | + $flux['data'] = $echafauder($type, $table, $table_sql, "prive/objets/contenu/objet", $flux['args']['ext']); |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + return $flux; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -144,49 +144,49 @@ discard block |
||
| 144 | 144 | * @return array |
| 145 | 145 | */ |
| 146 | 146 | function quete_rubrique_fond($contexte) { |
| 147 | - static $liste_objets = null; |
|
| 148 | - static $quete = array(); |
|
| 149 | - if (is_null($liste_objets)) { |
|
| 150 | - $liste_objets = array(); |
|
| 151 | - include_spip('inc/urls'); |
|
| 152 | - include_spip('public/quete'); |
|
| 153 | - $l = urls_liste_objets(false); |
|
| 154 | - // placer la rubrique en tete des objets |
|
| 155 | - $l = array_diff($l, array('rubrique')); |
|
| 156 | - array_unshift($l, 'rubrique'); |
|
| 157 | - foreach ($l as $objet) { |
|
| 158 | - $id = id_table_objet($objet); |
|
| 159 | - if (!isset($liste_objets[$id])) { |
|
| 160 | - $liste_objets[$id] = objet_type($objet, false); |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - $c = array_intersect_key($contexte, $liste_objets); |
|
| 165 | - if (!count($c)) { |
|
| 166 | - return false; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - $c = array_map('intval', $c); |
|
| 170 | - $s = serialize($c); |
|
| 171 | - if (isset($quete[$s])) { |
|
| 172 | - return $quete[$s]; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if (isset($c['id_rubrique']) and $r = $c['id_rubrique']) { |
|
| 176 | - unset($c['id_rubrique']); |
|
| 177 | - $c = array('id_rubrique' => $r) + $c; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - foreach ($c as $_id => $id) { |
|
| 181 | - if ($id |
|
| 182 | - and $row = quete_parent_lang(table_objet_sql($liste_objets[$_id]), $id) |
|
| 183 | - ) { |
|
| 184 | - $lang = isset($row['lang']) ? $row['lang'] : ''; |
|
| 185 | - if ($_id == 'id_rubrique' or (isset($row['id_rubrique']) and $id = $row['id_rubrique'])) { |
|
| 186 | - return $quete[$s] = array($id, $lang); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return $quete[$s] = false; |
|
| 147 | + static $liste_objets = null; |
|
| 148 | + static $quete = array(); |
|
| 149 | + if (is_null($liste_objets)) { |
|
| 150 | + $liste_objets = array(); |
|
| 151 | + include_spip('inc/urls'); |
|
| 152 | + include_spip('public/quete'); |
|
| 153 | + $l = urls_liste_objets(false); |
|
| 154 | + // placer la rubrique en tete des objets |
|
| 155 | + $l = array_diff($l, array('rubrique')); |
|
| 156 | + array_unshift($l, 'rubrique'); |
|
| 157 | + foreach ($l as $objet) { |
|
| 158 | + $id = id_table_objet($objet); |
|
| 159 | + if (!isset($liste_objets[$id])) { |
|
| 160 | + $liste_objets[$id] = objet_type($objet, false); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + $c = array_intersect_key($contexte, $liste_objets); |
|
| 165 | + if (!count($c)) { |
|
| 166 | + return false; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + $c = array_map('intval', $c); |
|
| 170 | + $s = serialize($c); |
|
| 171 | + if (isset($quete[$s])) { |
|
| 172 | + return $quete[$s]; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if (isset($c['id_rubrique']) and $r = $c['id_rubrique']) { |
|
| 176 | + unset($c['id_rubrique']); |
|
| 177 | + $c = array('id_rubrique' => $r) + $c; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + foreach ($c as $_id => $id) { |
|
| 181 | + if ($id |
|
| 182 | + and $row = quete_parent_lang(table_objet_sql($liste_objets[$_id]), $id) |
|
| 183 | + ) { |
|
| 184 | + $lang = isset($row['lang']) ? $row['lang'] : ''; |
|
| 185 | + if ($_id == 'id_rubrique' or (isset($row['id_rubrique']) and $id = $row['id_rubrique'])) { |
|
| 186 | + return $quete[$s] = array($id, $lang); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return $quete[$s] = false; |
|
| 192 | 192 | } |