@@ -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 | /** |
@@ -33,64 +33,64 @@ discard block |
||
| 33 | 33 | // Cas d'une page contenant du PHP : |
| 34 | 34 | if (empty($page['process_ins']) or $page['process_ins'] != 'html') { |
| 35 | 35 | |
| 36 | - include_spip('inc/lang'); |
|
| 36 | + include_spip('inc/lang'); |
|
| 37 | 37 | |
| 38 | - // restaurer l'etat des notes avant calcul |
|
| 39 | - if (isset($page['notes']) |
|
| 40 | - and $page['notes'] |
|
| 41 | - and $notes = charger_fonction("notes", "inc", true) |
|
| 42 | - ) { |
|
| 43 | - $notes($page['notes'], 'restaurer_etat'); |
|
| 44 | - } |
|
| 45 | - ob_start(); |
|
| 46 | - if (strpos($page['texte'], '?xml') !== false) { |
|
| 47 | - $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']); |
|
| 48 | - } |
|
| 38 | + // restaurer l'etat des notes avant calcul |
|
| 39 | + if (isset($page['notes']) |
|
| 40 | + and $page['notes'] |
|
| 41 | + and $notes = charger_fonction("notes", "inc", true) |
|
| 42 | + ) { |
|
| 43 | + $notes($page['notes'], 'restaurer_etat'); |
|
| 44 | + } |
|
| 45 | + ob_start(); |
|
| 46 | + if (strpos($page['texte'], '?xml') !== false) { |
|
| 47 | + $page['texte'] = str_replace('<' . '?xml', "<\1?xml", $page['texte']); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - try { |
|
| 51 | - $res = eval('?' . '>' . $page['texte']); |
|
| 52 | - // error catching 5.2<=PHP<7 |
|
| 53 | - if ($res === false |
|
| 54 | - and function_exists('error_get_last') |
|
| 55 | - and ($erreur = error_get_last()) ) { |
|
| 56 | - $code = $page['texte']; |
|
| 57 | - $GLOBALS['numero_ligne_php'] = 1; |
|
| 58 | - if (!function_exists('numerote_ligne_php')){ |
|
| 59 | - function numerote_ligne_php($match){ |
|
| 60 | - $GLOBALS['numero_ligne_php']++; |
|
| 61 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 65 | - $code = trim(highlight_string($code,true)); |
|
| 66 | - erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 67 | - $page['texte'] = "<!-- Erreur -->"; |
|
| 68 | - } |
|
| 69 | - else { |
|
| 70 | - $page['texte'] = ob_get_contents(); |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - catch (Exception $e){ |
|
| 74 | - $code = $page['texte']; |
|
| 75 | - $GLOBALS['numero_ligne_php'] = 1; |
|
| 76 | - if (!function_exists('numerote_ligne_php')){ |
|
| 77 | - function numerote_ligne_php($match){ |
|
| 78 | - $GLOBALS['numero_ligne_php']++; |
|
| 79 | - return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 80 | - } |
|
| 81 | - } |
|
| 82 | - $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 83 | - $code = trim(highlight_string($code,true)); |
|
| 84 | - erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 85 | - $page['texte'] = "<!-- Erreur -->"; |
|
| 86 | - } |
|
| 87 | - ob_end_clean(); |
|
| 50 | + try { |
|
| 51 | + $res = eval('?' . '>' . $page['texte']); |
|
| 52 | + // error catching 5.2<=PHP<7 |
|
| 53 | + if ($res === false |
|
| 54 | + and function_exists('error_get_last') |
|
| 55 | + and ($erreur = error_get_last()) ) { |
|
| 56 | + $code = $page['texte']; |
|
| 57 | + $GLOBALS['numero_ligne_php'] = 1; |
|
| 58 | + if (!function_exists('numerote_ligne_php')){ |
|
| 59 | + function numerote_ligne_php($match){ |
|
| 60 | + $GLOBALS['numero_ligne_php']++; |
|
| 61 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 65 | + $code = trim(highlight_string($code,true)); |
|
| 66 | + erreur_squelette("L".$erreur['line'].": ".$erreur['message']."<br />".$code,array($page['source'],'',$erreur['file'],'',$GLOBALS['spip_lang'])); |
|
| 67 | + $page['texte'] = "<!-- Erreur -->"; |
|
| 68 | + } |
|
| 69 | + else { |
|
| 70 | + $page['texte'] = ob_get_contents(); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + catch (Exception $e){ |
|
| 74 | + $code = $page['texte']; |
|
| 75 | + $GLOBALS['numero_ligne_php'] = 1; |
|
| 76 | + if (!function_exists('numerote_ligne_php')){ |
|
| 77 | + function numerote_ligne_php($match){ |
|
| 78 | + $GLOBALS['numero_ligne_php']++; |
|
| 79 | + return "\n/*".str_pad($GLOBALS['numero_ligne_php'],3,"0",STR_PAD_LEFT)."*/"; |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | + $code = "/*001*/".preg_replace_callback(",\n,","numerote_ligne_php",$code); |
|
| 83 | + $code = trim(highlight_string($code,true)); |
|
| 84 | + erreur_squelette("L".$e->getLine().": ".$e->getMessage()."<br />".$code,array($page['source'],'',$e->getFile(),'',$GLOBALS['spip_lang'])); |
|
| 85 | + $page['texte'] = "<!-- Erreur -->"; |
|
| 86 | + } |
|
| 87 | + ob_end_clean(); |
|
| 88 | 88 | |
| 89 | - $page['process_ins'] = 'html'; |
|
| 89 | + $page['process_ins'] = 'html'; |
|
| 90 | 90 | |
| 91 | - if (strpos($page['texte'], '?xml') !== false) { |
|
| 92 | - $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']); |
|
| 93 | - } |
|
| 91 | + if (strpos($page['texte'], '?xml') !== false) { |
|
| 92 | + $page['texte'] = str_replace("<\1?xml", '<' . '?xml', $page['texte']); |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | page_base_href($page['texte']); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -34,32 +34,32 @@ discard block |
||
| 34 | 34 | * Contenu HTML, avec boutons d'administrations et sa CSS |
| 35 | 35 | **/ |
| 36 | 36 | function affiche_boutons_admin($contenu) { |
| 37 | - include_spip('inc/filtres'); |
|
| 37 | + include_spip('inc/filtres'); |
|
| 38 | 38 | |
| 39 | - // Inserer le css d'admin |
|
| 40 | - $css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css'))) |
|
| 41 | - . "' type='text/css' />\n"; |
|
| 42 | - if ($f = find_in_path('spip_admin_perso.css')) { |
|
| 43 | - $css .= "<link rel='stylesheet' href='" |
|
| 44 | - . url_absolue(direction_css($f)) . "' type='text/css' />\n"; |
|
| 45 | - } |
|
| 39 | + // Inserer le css d'admin |
|
| 40 | + $css = "<link rel='stylesheet' href='" . url_absolue(direction_css(find_in_path('spip_admin.css'))) |
|
| 41 | + . "' type='text/css' />\n"; |
|
| 42 | + if ($f = find_in_path('spip_admin_perso.css')) { |
|
| 43 | + $css .= "<link rel='stylesheet' href='" |
|
| 44 | + . url_absolue(direction_css($f)) . "' type='text/css' />\n"; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - ($pos = stripos($contenu, '</head>')) |
|
| 48 | - || ($pos = stripos($contenu, '<body>')) |
|
| 49 | - || ($pos = 0); |
|
| 50 | - $contenu = substr_replace($contenu, $css, $pos, 0); |
|
| 47 | + ($pos = stripos($contenu, '</head>')) |
|
| 48 | + || ($pos = stripos($contenu, '<body>')) |
|
| 49 | + || ($pos = 0); |
|
| 50 | + $contenu = substr_replace($contenu, $css, $pos, 0); |
|
| 51 | 51 | |
| 52 | 52 | |
| 53 | - // Inserer la balise #FORMULAIRE_ADMIN, en float |
|
| 54 | - $boutons_admin = inclure_balise_dynamique( |
|
| 55 | - balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'), |
|
| 56 | - false); |
|
| 53 | + // Inserer la balise #FORMULAIRE_ADMIN, en float |
|
| 54 | + $boutons_admin = inclure_balise_dynamique( |
|
| 55 | + balise_FORMULAIRE_ADMIN_dyn('spip-admin-float'), |
|
| 56 | + false); |
|
| 57 | 57 | |
| 58 | - ($pos = strripos($contenu, '</body>')) |
|
| 59 | - || ($pos = strripos($contenu, '</html>')) |
|
| 60 | - || ($pos = strlen($contenu)); |
|
| 61 | - $contenu = substr_replace($contenu, $boutons_admin, $pos, 0); |
|
| 58 | + ($pos = strripos($contenu, '</body>')) |
|
| 59 | + || ($pos = strripos($contenu, '</html>')) |
|
| 60 | + || ($pos = strlen($contenu)); |
|
| 61 | + $contenu = substr_replace($contenu, $boutons_admin, $pos, 0); |
|
| 62 | 62 | |
| 63 | 63 | |
| 64 | - return $contenu; |
|
| 64 | + return $contenu; |
|
| 65 | 65 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * @package SPIP\Core\Public\Styliser |
| 20 | 20 | **/ |
| 21 | 21 | if (!defined("_ECRIRE_INC_VERSION")) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -29,181 +29,181 @@ discard block |
||
| 29 | 29 | * @return array Données modifiées du pipeline |
| 30 | 30 | */ |
| 31 | 31 | function public_styliser_par_z_dist($flux) { |
| 32 | - static $prefix_path = null; |
|
| 33 | - static $prefix_length; |
|
| 34 | - static $z_blocs; |
|
| 35 | - static $apl_constant; |
|
| 36 | - static $page; |
|
| 37 | - static $disponible = array(); |
|
| 38 | - static $echafauder; |
|
| 39 | - static $prepend = ""; |
|
| 40 | - |
|
| 41 | - if (!isset($prefix_path)) { |
|
| 42 | - $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | - if (test_espace_prive()) { |
|
| 44 | - $prefix_path = "prive/squelettes/"; |
|
| 45 | - $prefix_length = strlen($prefix_path); |
|
| 46 | - $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | - $page = 'exec'; |
|
| 48 | - $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | - define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | - } else { |
|
| 51 | - $prefix_path = ""; |
|
| 52 | - $prefix_length = 0; |
|
| 53 | - $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | - $page = _SPIP_PAGE; |
|
| 55 | - $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | - define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST, |
|
| 57 | - '/') : '')); |
|
| 58 | - } |
|
| 59 | - $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ""); |
|
| 60 | - } |
|
| 61 | - $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 62 | - |
|
| 63 | - $fond = $flux['args']['fond']; |
|
| 64 | - |
|
| 65 | - if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 66 | - $fond = substr($fond, $prefix_length); |
|
| 67 | - $squelette = $flux['data']; |
|
| 68 | - $ext = $flux['args']['ext']; |
|
| 69 | - // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 70 | - if (defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 71 | - and $dir = explode('/', $fond) |
|
| 72 | - and count($dir) == 2 // pas un sous repertoire |
|
| 73 | - and $dir = reset($dir) |
|
| 74 | - and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 75 | - and defined($apl_constant) |
|
| 76 | - and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 77 | - and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 78 | - ) { |
|
| 79 | - $flux['data'] = $pipe; |
|
| 80 | - |
|
| 81 | - return $flux; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 85 | - if ($squelette and !z_fond_valide($squelette)) { |
|
| 86 | - $squelette = ""; |
|
| 87 | - $echafauder = ""; |
|
| 88 | - } |
|
| 89 | - if ($prepend) { |
|
| 90 | - $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 91 | - if ($squelette) { |
|
| 92 | - $flux['data'] = $squelette; |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - // gerer les squelettes non trouves |
|
| 97 | - // -> router vers les /dist.html |
|
| 98 | - // ou scaffolding ou page automatique les contenus |
|
| 99 | - if (!$squelette) { |
|
| 100 | - |
|
| 101 | - // si on est sur un ?page=XX non trouve |
|
| 102 | - if ((isset($flux['args']['contexte'][$page]) |
|
| 103 | - and $flux['args']['contexte'][$page] == $fond) |
|
| 104 | - or (isset($flux['args']['contexte']['type-page']) |
|
| 105 | - and $flux['args']['contexte']['type-page'] == $fond) |
|
| 106 | - or ($fond == 'sommaire' |
|
| 107 | - and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 108 | - ) { |
|
| 109 | - |
|
| 110 | - // si on est sur un ?page=XX non trouve |
|
| 111 | - // se brancher sur contenu/xx si il existe |
|
| 112 | - // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 113 | - if (!isset($disponible[$fond])) { |
|
| 114 | - $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - if ($disponible[$fond]) { |
|
| 118 | - $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // echafaudage : |
|
| 123 | - // si c'est un fond de contenu d'un objet en base |
|
| 124 | - // generer un fond automatique a la volee pour les webmestres |
|
| 125 | - elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 126 | - $type = substr($fond, strlen($z_contenu) + 1); |
|
| 127 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 128 | - $type = $flux['args']['contexte'][$page]; |
|
| 129 | - } |
|
| 130 | - if (!isset($disponible[$type])) { |
|
| 131 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 132 | - } |
|
| 133 | - if (is_string($disponible[$type])) { |
|
| 134 | - $flux['data'] = $disponible[$type]; |
|
| 135 | - } elseif ($echafauder |
|
| 136 | - and include_spip('inc/autoriser') |
|
| 137 | - and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 138 | - and autoriser('echafauder', $type) |
|
| 139 | - and $is = $disponible[$type] |
|
| 140 | - and is_array($is) |
|
| 141 | - ) { |
|
| 142 | - $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 143 | - } else { |
|
| 144 | - $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext, |
|
| 145 | - $echafauder)); |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 150 | - // et si il y a bien un contenu correspondant ou echafaudable |
|
| 151 | - // se rabbatre sur le dist.html du bloc concerne |
|
| 152 | - else { |
|
| 153 | - if ($dir = explode('/', $fond) |
|
| 154 | - and $dir = reset($dir) |
|
| 155 | - and $dir !== $z_contenu |
|
| 156 | - and in_array($dir, $z_blocs) |
|
| 157 | - ) { |
|
| 158 | - $type = substr($fond, strlen("$dir/")); |
|
| 159 | - if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 160 | - $type = $flux['args']['contexte'][$page]; |
|
| 161 | - } |
|
| 162 | - if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 163 | - $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 164 | - } |
|
| 165 | - if ($type == 'page' or $disponible[$type]) { |
|
| 166 | - $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - $squelette = $flux['data']; |
|
| 171 | - } |
|
| 172 | - // layout specifiques par type et compositions : |
|
| 173 | - // body-article.html |
|
| 174 | - // body-sommaire.html |
|
| 175 | - // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 176 | - // meme dossier que body.html |
|
| 177 | - if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 178 | - if (isset($flux['args']['contexte']['type-page']) |
|
| 179 | - and ( |
|
| 180 | - (isset($flux['args']['contexte']['composition']) |
|
| 181 | - and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 182 | - or |
|
| 183 | - file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 184 | - ) |
|
| 185 | - ) { |
|
| 186 | - $flux['data'] = $f; |
|
| 187 | - } |
|
| 188 | - } elseif ($fond == 'structure' |
|
| 189 | - and z_sanitize_var_zajax() |
|
| 190 | - and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 191 | - ) { |
|
| 192 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 193 | - } // chercher le fond correspondant a la composition |
|
| 194 | - elseif (isset($flux['args']['contexte']['composition']) |
|
| 195 | - and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 196 | - and $dir = substr($fond, $prefix_length) |
|
| 197 | - and $dir = explode('/', $dir) |
|
| 198 | - and $dir = reset($dir) |
|
| 199 | - and in_array($dir, $z_blocs) |
|
| 200 | - and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 201 | - ) { |
|
| 202 | - $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - return $flux; |
|
| 32 | + static $prefix_path = null; |
|
| 33 | + static $prefix_length; |
|
| 34 | + static $z_blocs; |
|
| 35 | + static $apl_constant; |
|
| 36 | + static $page; |
|
| 37 | + static $disponible = array(); |
|
| 38 | + static $echafauder; |
|
| 39 | + static $prepend = ""; |
|
| 40 | + |
|
| 41 | + if (!isset($prefix_path)) { |
|
| 42 | + $z_blocs = z_blocs(test_espace_prive()); |
|
| 43 | + if (test_espace_prive()) { |
|
| 44 | + $prefix_path = "prive/squelettes/"; |
|
| 45 | + $prefix_length = strlen($prefix_path); |
|
| 46 | + $apl_constant = '_ECRIRE_AJAX_PARALLEL_LOAD'; |
|
| 47 | + $page = 'exec'; |
|
| 48 | + $echafauder = charger_fonction('echafauder', 'prive', true); |
|
| 49 | + define('_ZCORE_EXCLURE_PATH', ''); |
|
| 50 | + } else { |
|
| 51 | + $prefix_path = ""; |
|
| 52 | + $prefix_length = 0; |
|
| 53 | + $apl_constant = '_Z_AJAX_PARALLEL_LOAD'; |
|
| 54 | + $page = _SPIP_PAGE; |
|
| 55 | + $echafauder = charger_fonction('echafauder', 'public', true); |
|
| 56 | + define('_ZCORE_EXCLURE_PATH', '\bprive|\bsquelettes-dist' . (defined('_DIR_PLUGIN_DIST') ? '|\b' . rtrim(_DIR_PLUGIN_DIST, |
|
| 57 | + '/') : '')); |
|
| 58 | + } |
|
| 59 | + $prepend = (defined('_Z_PREPEND_PATH') ? _Z_PREPEND_PATH : ""); |
|
| 60 | + } |
|
| 61 | + $z_contenu = reset($z_blocs); // contenu par defaut |
|
| 62 | + |
|
| 63 | + $fond = $flux['args']['fond']; |
|
| 64 | + |
|
| 65 | + if ($prepend or strncmp($fond, $prefix_path, $prefix_length) == 0) { |
|
| 66 | + $fond = substr($fond, $prefix_length); |
|
| 67 | + $squelette = $flux['data']; |
|
| 68 | + $ext = $flux['args']['ext']; |
|
| 69 | + // Ajax Parallel loading : ne pas calculer le bloc, mais renvoyer un js qui le loadera en ajax |
|
| 70 | + if (defined('_Z_AJAX_PARALLEL_LOAD_OK') |
|
| 71 | + and $dir = explode('/', $fond) |
|
| 72 | + and count($dir) == 2 // pas un sous repertoire |
|
| 73 | + and $dir = reset($dir) |
|
| 74 | + and in_array($dir, $z_blocs) // verifier deja qu'on est dans un bloc Z |
|
| 75 | + and defined($apl_constant) |
|
| 76 | + and in_array($dir, explode(',', constant($apl_constant))) // et dans un demande en APL |
|
| 77 | + and $pipe = z_trouver_bloc($prefix_path . $prepend, $dir, 'z_apl', $ext) // et qui contient le squelette APL |
|
| 78 | + ) { |
|
| 79 | + $flux['data'] = $pipe; |
|
| 80 | + |
|
| 81 | + return $flux; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + // surcharger aussi les squelettes venant de squelettes-dist/ |
|
| 85 | + if ($squelette and !z_fond_valide($squelette)) { |
|
| 86 | + $squelette = ""; |
|
| 87 | + $echafauder = ""; |
|
| 88 | + } |
|
| 89 | + if ($prepend) { |
|
| 90 | + $squelette = substr(find_in_path($prefix_path . $prepend . "$fond.$ext"), 0, -strlen(".$ext")); |
|
| 91 | + if ($squelette) { |
|
| 92 | + $flux['data'] = $squelette; |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + // gerer les squelettes non trouves |
|
| 97 | + // -> router vers les /dist.html |
|
| 98 | + // ou scaffolding ou page automatique les contenus |
|
| 99 | + if (!$squelette) { |
|
| 100 | + |
|
| 101 | + // si on est sur un ?page=XX non trouve |
|
| 102 | + if ((isset($flux['args']['contexte'][$page]) |
|
| 103 | + and $flux['args']['contexte'][$page] == $fond) |
|
| 104 | + or (isset($flux['args']['contexte']['type-page']) |
|
| 105 | + and $flux['args']['contexte']['type-page'] == $fond) |
|
| 106 | + or ($fond == 'sommaire' |
|
| 107 | + and (!isset($flux['args']['contexte'][$page]) or !$flux['args']['contexte'][$page])) |
|
| 108 | + ) { |
|
| 109 | + |
|
| 110 | + // si on est sur un ?page=XX non trouve |
|
| 111 | + // se brancher sur contenu/xx si il existe |
|
| 112 | + // ou si c'est un objet spip, associe a une table, utiliser le fond homonyme |
|
| 113 | + if (!isset($disponible[$fond])) { |
|
| 114 | + $disponible[$fond] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $fond, $ext, $echafauder); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + if ($disponible[$fond]) { |
|
| 118 | + $flux['data'] = substr(find_in_path($prefix_path . "page.$ext"), 0, -strlen(".$ext")); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // echafaudage : |
|
| 123 | + // si c'est un fond de contenu d'un objet en base |
|
| 124 | + // generer un fond automatique a la volee pour les webmestres |
|
| 125 | + elseif (strncmp($fond, "$z_contenu/", strlen($z_contenu) + 1) == 0) { |
|
| 126 | + $type = substr($fond, strlen($z_contenu) + 1); |
|
| 127 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 128 | + $type = $flux['args']['contexte'][$page]; |
|
| 129 | + } |
|
| 130 | + if (!isset($disponible[$type])) { |
|
| 131 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 132 | + } |
|
| 133 | + if (is_string($disponible[$type])) { |
|
| 134 | + $flux['data'] = $disponible[$type]; |
|
| 135 | + } elseif ($echafauder |
|
| 136 | + and include_spip('inc/autoriser') |
|
| 137 | + and isset($GLOBALS['visiteur_session']['statut']) // performance |
|
| 138 | + and autoriser('echafauder', $type) |
|
| 139 | + and $is = $disponible[$type] |
|
| 140 | + and is_array($is) |
|
| 141 | + ) { |
|
| 142 | + $flux['data'] = $echafauder($type, $is[0], $is[1], $is[2], $ext); |
|
| 143 | + } else { |
|
| 144 | + $flux['data'] = ($disponible['404'] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, '404', $ext, |
|
| 145 | + $echafauder)); |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + // sinon, si on demande un fond non trouve dans un des autres blocs |
|
| 150 | + // et si il y a bien un contenu correspondant ou echafaudable |
|
| 151 | + // se rabbatre sur le dist.html du bloc concerne |
|
| 152 | + else { |
|
| 153 | + if ($dir = explode('/', $fond) |
|
| 154 | + and $dir = reset($dir) |
|
| 155 | + and $dir !== $z_contenu |
|
| 156 | + and in_array($dir, $z_blocs) |
|
| 157 | + ) { |
|
| 158 | + $type = substr($fond, strlen("$dir/")); |
|
| 159 | + if (($type == 'page') and isset($flux['args']['contexte'][$page])) { |
|
| 160 | + $type = $flux['args']['contexte'][$page]; |
|
| 161 | + } |
|
| 162 | + if ($type !== 'page' and !isset($disponible[$type])) { |
|
| 163 | + $disponible[$type] = z_contenu_disponible($prefix_path . $prepend, $z_contenu, $type, $ext, $echafauder); |
|
| 164 | + } |
|
| 165 | + if ($type == 'page' or $disponible[$type]) { |
|
| 166 | + $flux['data'] = z_trouver_bloc($prefix_path . $prepend, $dir, 'dist', $ext); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + $squelette = $flux['data']; |
|
| 171 | + } |
|
| 172 | + // layout specifiques par type et compositions : |
|
| 173 | + // body-article.html |
|
| 174 | + // body-sommaire.html |
|
| 175 | + // pour des raisons de perfo, les declinaisons doivent etre dans le |
|
| 176 | + // meme dossier que body.html |
|
| 177 | + if ($fond == 'body' and substr($squelette, -strlen($fond)) == $fond) { |
|
| 178 | + if (isset($flux['args']['contexte']['type-page']) |
|
| 179 | + and ( |
|
| 180 | + (isset($flux['args']['contexte']['composition']) |
|
| 181 | + and file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page'] . "-" . $flux['args']['contexte']['composition']) . ".$ext")) |
|
| 182 | + or |
|
| 183 | + file_exists(($f = $squelette . "-" . $flux['args']['contexte']['type-page']) . ".$ext") |
|
| 184 | + ) |
|
| 185 | + ) { |
|
| 186 | + $flux['data'] = $f; |
|
| 187 | + } |
|
| 188 | + } elseif ($fond == 'structure' |
|
| 189 | + and z_sanitize_var_zajax() |
|
| 190 | + and $f = find_in_path($prefix_path . $prepend . 'ajax' . ".$ext") |
|
| 191 | + ) { |
|
| 192 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 193 | + } // chercher le fond correspondant a la composition |
|
| 194 | + elseif (isset($flux['args']['contexte']['composition']) |
|
| 195 | + and (basename($fond) == 'page' or ($squelette and substr($squelette, -strlen($fond)) == $fond)) |
|
| 196 | + and $dir = substr($fond, $prefix_length) |
|
| 197 | + and $dir = explode('/', $dir) |
|
| 198 | + and $dir = reset($dir) |
|
| 199 | + and in_array($dir, $z_blocs) |
|
| 200 | + and $f = find_in_path($prefix_path . $prepend . $fond . "-" . $flux['args']['contexte']['composition'] . ".$ext") |
|
| 201 | + ) { |
|
| 202 | + $flux['data'] = substr($f, 0, -strlen(".$ext")); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + return $flux; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function z_blocs($espace_prive = false) { |
| 216 | - if ($espace_prive) { |
|
| 217 | - return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array( |
|
| 218 | - 'contenu', |
|
| 219 | - 'navigation', |
|
| 220 | - 'extra', |
|
| 221 | - 'head', |
|
| 222 | - 'hierarchie', |
|
| 223 | - 'top' |
|
| 224 | - )); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu')); |
|
| 216 | + if ($espace_prive) { |
|
| 217 | + return (isset($GLOBALS['z_blocs_ecrire']) ? $GLOBALS['z_blocs_ecrire'] : array( |
|
| 218 | + 'contenu', |
|
| 219 | + 'navigation', |
|
| 220 | + 'extra', |
|
| 221 | + 'head', |
|
| 222 | + 'hierarchie', |
|
| 223 | + 'top' |
|
| 224 | + )); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return (isset($GLOBALS['z_blocs']) ? $GLOBALS['z_blocs'] : array('contenu')); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -239,11 +239,11 @@ discard block |
||
| 239 | 239 | * @return mixed |
| 240 | 240 | */ |
| 241 | 241 | function z_contenu_disponible($prefix_path, $z_contenu, $type, $ext, $echafauder = true) { |
| 242 | - if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 243 | - return $d; |
|
| 244 | - } |
|
| 242 | + if ($d = z_trouver_bloc($prefix_path, $z_contenu, $type, $ext)) { |
|
| 243 | + return $d; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - return $echafauder ? z_echafaudable($type) : false; |
|
| 246 | + return $echafauder ? z_echafaudable($type) : false; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -257,13 +257,13 @@ discard block |
||
| 257 | 257 | * `true` si on peut l'utiliser, `false` sinon. |
| 258 | 258 | **/ |
| 259 | 259 | function z_fond_valide($squelette) { |
| 260 | - if (!_ZCORE_EXCLURE_PATH |
|
| 261 | - or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 262 | - ) { |
|
| 263 | - return true; |
|
| 264 | - } |
|
| 260 | + if (!_ZCORE_EXCLURE_PATH |
|
| 261 | + or !preg_match(',(' . _ZCORE_EXCLURE_PATH . ')/,', $squelette) |
|
| 262 | + ) { |
|
| 263 | + return true; |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - return false; |
|
| 266 | + return false; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -281,14 +281,14 @@ discard block |
||
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | 283 | function z_trouver_bloc($prefix_path, $bloc, $fond, $ext) { |
| 284 | - if ( |
|
| 285 | - (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 286 | - or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 287 | - ) { |
|
| 288 | - return substr($f, 0, -strlen(".$ext")); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return ""; |
|
| 284 | + if ( |
|
| 285 | + (defined('_ZCORE_BLOC_PREFIX_SKEL') and $f = find_in_path("$prefix_path$bloc/$bloc.$fond.$ext") and z_fond_valide($f)) |
|
| 286 | + or ($f = find_in_path("$prefix_path$bloc/$fond.$ext") and z_fond_valide($f)) |
|
| 287 | + ) { |
|
| 288 | + return substr($f, 0, -strlen(".$ext")); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return ""; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -300,51 +300,51 @@ discard block |
||
| 300 | 300 | * @return bool |
| 301 | 301 | */ |
| 302 | 302 | function z_echafaudable($type) { |
| 303 | - static $pages = null; |
|
| 304 | - static $echafaudable = array(); |
|
| 305 | - if (isset($echafaudable[$type])) { |
|
| 306 | - return $echafaudable[$type]; |
|
| 307 | - } |
|
| 308 | - if (preg_match(',[^\w],', $type)) { |
|
| 309 | - return $echafaudable[$type] = false; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - if (test_espace_prive()) { |
|
| 313 | - if (!function_exists('trouver_objet_exec')) { |
|
| 314 | - include_spip('inc/pipelines_ecrire'); |
|
| 315 | - } |
|
| 316 | - if ($e = trouver_objet_exec($type)) { |
|
| 317 | - return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e); |
|
| 318 | - } else { |
|
| 319 | - // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 320 | - if (($t = objet_type($type, false)) !== $type |
|
| 321 | - and $e = trouver_objet_exec($t) |
|
| 322 | - ) { |
|
| 323 | - return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t); |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } else { |
|
| 327 | - if (is_null($pages)) { |
|
| 328 | - $pages = array(); |
|
| 329 | - $liste = lister_tables_objets_sql(); |
|
| 330 | - foreach ($liste as $t => $d) { |
|
| 331 | - if ($d['page']) { |
|
| 332 | - $pages[$d['page']] = array($d['table_objet'], $t); |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - if (!isset($pages[$type])) { |
|
| 337 | - return $echafaudable[$type] = false; |
|
| 338 | - } |
|
| 339 | - if (count($pages[$type]) == 2) { |
|
| 340 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | - $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - return $echafaudable[$type] = $pages[$type]; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - return $echafaudable[$type] = false; |
|
| 303 | + static $pages = null; |
|
| 304 | + static $echafaudable = array(); |
|
| 305 | + if (isset($echafaudable[$type])) { |
|
| 306 | + return $echafaudable[$type]; |
|
| 307 | + } |
|
| 308 | + if (preg_match(',[^\w],', $type)) { |
|
| 309 | + return $echafaudable[$type] = false; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + if (test_espace_prive()) { |
|
| 313 | + if (!function_exists('trouver_objet_exec')) { |
|
| 314 | + include_spip('inc/pipelines_ecrire'); |
|
| 315 | + } |
|
| 316 | + if ($e = trouver_objet_exec($type)) { |
|
| 317 | + return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $e); |
|
| 318 | + } else { |
|
| 319 | + // peut etre c'est un exec=types qui liste tous les objets "type" |
|
| 320 | + if (($t = objet_type($type, false)) !== $type |
|
| 321 | + and $e = trouver_objet_exec($t) |
|
| 322 | + ) { |
|
| 323 | + return $echafaudable[$type] = array($e['table'], $e['table_objet_sql'], $t); |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } else { |
|
| 327 | + if (is_null($pages)) { |
|
| 328 | + $pages = array(); |
|
| 329 | + $liste = lister_tables_objets_sql(); |
|
| 330 | + foreach ($liste as $t => $d) { |
|
| 331 | + if ($d['page']) { |
|
| 332 | + $pages[$d['page']] = array($d['table_objet'], $t); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + if (!isset($pages[$type])) { |
|
| 337 | + return $echafaudable[$type] = false; |
|
| 338 | + } |
|
| 339 | + if (count($pages[$type]) == 2) { |
|
| 340 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 341 | + $pages[$type][] = $trouver_table(reset($pages[$type])); |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + return $echafaudable[$type] = $pages[$type]; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + return $echafaudable[$type] = false; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
@@ -361,46 +361,46 @@ discard block |
||
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | function prive_echafauder_dist($exec, $table, $table_sql, $desc_exec, $ext) { |
| 364 | - $scaffold = ""; |
|
| 365 | - |
|
| 366 | - // page objet ou objet_edit |
|
| 367 | - if (is_array($desc_exec)) { |
|
| 368 | - $type = $desc_exec['type']; |
|
| 369 | - $primary = $desc_exec['id_table_objet']; |
|
| 370 | - |
|
| 371 | - if ($desc_exec['edition'] === false) { |
|
| 372 | - $fond = "objet"; |
|
| 373 | - } else { |
|
| 374 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 375 | - $desc = $trouver_table($table_sql); |
|
| 376 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 377 | - $fond = 'objet_edit'; |
|
| 378 | - } else { |
|
| 379 | - $fond = 'objet_edit.sans_rubrique'; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - $dir = z_blocs(test_espace_prive()); |
|
| 383 | - $dir = reset($dir); |
|
| 384 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>"; |
|
| 385 | - } // page objets |
|
| 386 | - elseif ($type = $desc_exec and strpos($type, "/") === false) { |
|
| 387 | - $dir = z_blocs(test_espace_prive()); |
|
| 388 | - $dir = reset($dir); |
|
| 389 | - $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />"; |
|
| 390 | - } |
|
| 391 | - // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 392 | - // et objet et tire de $table |
|
| 393 | - elseif ($fond = $desc_exec) { |
|
| 394 | - $dir = md5(dirname($fond)); |
|
| 395 | - $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />"; |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false); |
|
| 399 | - $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 400 | - $f = $base_dir . "$exec"; |
|
| 401 | - ecrire_fichier("$f.$ext", $scaffold); |
|
| 402 | - |
|
| 403 | - return $f; |
|
| 364 | + $scaffold = ""; |
|
| 365 | + |
|
| 366 | + // page objet ou objet_edit |
|
| 367 | + if (is_array($desc_exec)) { |
|
| 368 | + $type = $desc_exec['type']; |
|
| 369 | + $primary = $desc_exec['id_table_objet']; |
|
| 370 | + |
|
| 371 | + if ($desc_exec['edition'] === false) { |
|
| 372 | + $fond = "objet"; |
|
| 373 | + } else { |
|
| 374 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 375 | + $desc = $trouver_table($table_sql); |
|
| 376 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 377 | + $fond = 'objet_edit'; |
|
| 378 | + } else { |
|
| 379 | + $fond = 'objet_edit.sans_rubrique'; |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + $dir = z_blocs(test_espace_prive()); |
|
| 383 | + $dir = reset($dir); |
|
| 384 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/" . $fond . ",objet=" . $type . ",id_objet=#" . strtoupper($primary) . ",env}>"; |
|
| 385 | + } // page objets |
|
| 386 | + elseif ($type = $desc_exec and strpos($type, "/") === false) { |
|
| 387 | + $dir = z_blocs(test_espace_prive()); |
|
| 388 | + $dir = reset($dir); |
|
| 389 | + $scaffold = "<INCLURE{fond=prive/echafaudage/$dir/objets,objet=" . $type . ",env} />"; |
|
| 390 | + } |
|
| 391 | + // morceau d'objet : on fournit le fond de sibstitution dans $desc_exec |
|
| 392 | + // et objet et tire de $table |
|
| 393 | + elseif ($fond = $desc_exec) { |
|
| 394 | + $dir = md5(dirname($fond)); |
|
| 395 | + $scaffold = "<INCLURE{fond=$fond,objet=" . objet_type($table) . ",env} />"; |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + $base_dir = sous_repertoire(_DIR_CACHE, "scaffold", false); |
|
| 399 | + $base_dir = sous_repertoire($base_dir, $dir, false); |
|
| 400 | + $f = $base_dir . "$exec"; |
|
| 401 | + ecrire_fichier("$f.$ext", $scaffold); |
|
| 402 | + |
|
| 403 | + return $f; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -409,16 +409,16 @@ discard block |
||
| 409 | 409 | * @return bool|string |
| 410 | 410 | */ |
| 411 | 411 | function z_sanitize_var_zajax() { |
| 412 | - $z_ajax = _request('var_zajax'); |
|
| 413 | - if (!$z_ajax) { |
|
| 414 | - return false; |
|
| 415 | - } |
|
| 416 | - if (!$z_blocs = z_blocs(test_espace_prive()) |
|
| 417 | - or !in_array($z_ajax, $z_blocs) |
|
| 418 | - ) { |
|
| 419 | - set_request('var_zajax'); // enlever cette demande incongrue |
|
| 420 | - $z_ajax = false; |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - return $z_ajax; |
|
| 412 | + $z_ajax = _request('var_zajax'); |
|
| 413 | + if (!$z_ajax) { |
|
| 414 | + return false; |
|
| 415 | + } |
|
| 416 | + if (!$z_blocs = z_blocs(test_espace_prive()) |
|
| 417 | + or !in_array($z_ajax, $z_blocs) |
|
| 418 | + ) { |
|
| 419 | + set_request('var_zajax'); // enlever cette demande incongrue |
|
| 420 | + $z_ajax = false; |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + return $z_ajax; |
|
| 424 | 424 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * Code PHP compilé de la boucle |
| 34 | 34 | **/ |
| 35 | 35 | function boucle_DEFAUT_dist($id_boucle, &$boucles) { |
| 36 | - return calculer_boucle($id_boucle, $boucles); |
|
| 36 | + return calculer_boucle($id_boucle, $boucles); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Code PHP compilé de la boucle |
| 53 | 53 | **/ |
| 54 | 54 | function boucle_BOUCLE_dist($id_boucle, &$boucles) { |
| 55 | - return calculer_boucle($id_boucle, $boucles); |
|
| 55 | + return calculer_boucle($id_boucle, $boucles); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | |
@@ -82,30 +82,30 @@ discard block |
||
| 82 | 82 | * Code PHP compilé de la boucle |
| 83 | 83 | **/ |
| 84 | 84 | function boucle_HIERARCHIE_dist($id_boucle, &$boucles) { |
| 85 | - $boucle = &$boucles[$id_boucle]; |
|
| 86 | - $id_table = $boucle->id_table . ".id_rubrique"; |
|
| 85 | + $boucle = &$boucles[$id_boucle]; |
|
| 86 | + $id_table = $boucle->id_table . ".id_rubrique"; |
|
| 87 | 87 | |
| 88 | - // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 89 | - // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 90 | - // ou {id_article} qui positionne aussi le {tout} |
|
| 88 | + // Si la boucle mere est une boucle RUBRIQUES il faut ignorer la feuille |
|
| 89 | + // sauf en presence du critere {tout} (vu par phraser_html) |
|
| 90 | + // ou {id_article} qui positionne aussi le {tout} |
|
| 91 | 91 | |
| 92 | - $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 93 | - . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 94 | - . ")))\n\t\treturn '';\n\t" |
|
| 95 | - . "include_spip('inc/rubriques');\n\t" |
|
| 96 | - . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 97 | - . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
|
| 98 | - . ");\n\t" |
|
| 99 | - . 'if (!$hierarchie) return "";' . "\n\t"; |
|
| 92 | + $boucle->hierarchie = 'if (!($id_rubrique = intval(' |
|
| 93 | + . calculer_argument_precedent($boucle->id_boucle, 'id_rubrique', $boucles) |
|
| 94 | + . ")))\n\t\treturn '';\n\t" |
|
| 95 | + . "include_spip('inc/rubriques');\n\t" |
|
| 96 | + . '$hierarchie = calcul_hierarchie_in($id_rubrique,' |
|
| 97 | + . (isset($boucle->modificateur['tout']) ? 'true' : 'false') |
|
| 98 | + . ");\n\t" |
|
| 99 | + . 'if (!$hierarchie) return "";' . "\n\t"; |
|
| 100 | 100 | |
| 101 | - $boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 101 | + $boucle->where[] = array("'IN'", "'$id_table'", '"($hierarchie)"'); |
|
| 102 | 102 | |
| 103 | - $order = "FIELD($id_table, \$hierarchie)"; |
|
| 104 | - if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != " DESC") { |
|
| 105 | - $boucle->default_order[] = "\"$order\""; |
|
| 106 | - } else { |
|
| 107 | - $boucle->default_order[0] = "\"$order DESC\""; |
|
| 108 | - } |
|
| 103 | + $order = "FIELD($id_table, \$hierarchie)"; |
|
| 104 | + if (!isset($boucle->default_order[0]) or $boucle->default_order[0] != " DESC") { |
|
| 105 | + $boucle->default_order[] = "\"$order\""; |
|
| 106 | + } else { |
|
| 107 | + $boucle->default_order[0] = "\"$order DESC\""; |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - return calculer_boucle($id_boucle, $boucles); |
|
| 110 | + return calculer_boucle($id_boucle, $boucles); |
|
| 111 | 111 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/presentation'); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @return string Code HTML |
| 33 | 33 | **/ |
| 34 | 34 | function exec_puce_statut_dist() { |
| 35 | - exec_puce_statut_args(_request('id'), _request('type')); |
|
| 35 | + exec_puce_statut_args(_request('id'), _request('type')); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -52,25 +52,25 @@ discard block |
||
| 52 | 52 | * @return string Code HTML |
| 53 | 53 | **/ |
| 54 | 54 | function exec_puce_statut_args($id, $type) { |
| 55 | - $id = intval($id); |
|
| 56 | - if ($table_objet_sql = table_objet_sql($type) |
|
| 57 | - and $d = lister_tables_objets_sql($table_objet_sql) |
|
| 58 | - and isset($d['statut_textes_instituer']) |
|
| 59 | - and $d['statut_textes_instituer'] |
|
| 60 | - ) { |
|
| 61 | - $prim = id_table_objet($type); |
|
| 62 | - if (isset($d['field']['id_rubrique'])) { |
|
| 63 | - $select = "id_rubrique,statut"; |
|
| 64 | - } else { |
|
| 65 | - $select = "0 as id_rubrique,statut"; |
|
| 66 | - } |
|
| 67 | - $r = sql_fetsel($select, $table_objet_sql, "$prim=$id"); |
|
| 68 | - $statut = $r['statut']; |
|
| 69 | - $id_rubrique = $r['id_rubrique']; |
|
| 70 | - } else { |
|
| 71 | - $id_rubrique = $id; |
|
| 72 | - $statut = 'prop'; // arbitraire |
|
| 73 | - } |
|
| 74 | - $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 75 | - ajax_retour($puce_statut($id, $statut, $id_rubrique, $type, true)); |
|
| 55 | + $id = intval($id); |
|
| 56 | + if ($table_objet_sql = table_objet_sql($type) |
|
| 57 | + and $d = lister_tables_objets_sql($table_objet_sql) |
|
| 58 | + and isset($d['statut_textes_instituer']) |
|
| 59 | + and $d['statut_textes_instituer'] |
|
| 60 | + ) { |
|
| 61 | + $prim = id_table_objet($type); |
|
| 62 | + if (isset($d['field']['id_rubrique'])) { |
|
| 63 | + $select = "id_rubrique,statut"; |
|
| 64 | + } else { |
|
| 65 | + $select = "0 as id_rubrique,statut"; |
|
| 66 | + } |
|
| 67 | + $r = sql_fetsel($select, $table_objet_sql, "$prim=$id"); |
|
| 68 | + $statut = $r['statut']; |
|
| 69 | + $id_rubrique = $r['id_rubrique']; |
|
| 70 | + } else { |
|
| 71 | + $id_rubrique = $id; |
|
| 72 | + $statut = 'prop'; // arbitraire |
|
| 73 | + } |
|
| 74 | + $puce_statut = charger_fonction('puce_statut', 'inc'); |
|
| 75 | + ajax_retour($puce_statut($id, $statut, $id_rubrique, $type, true)); |
|
| 76 | 76 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/minipres'); |
@@ -42,28 +42,28 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | **/ |
| 44 | 44 | function exec_install_dist() { |
| 45 | - $etape = _request('etape'); |
|
| 46 | - $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 45 | + $etape = _request('etape'); |
|
| 46 | + $deja = (_FILE_CONNECT and analyse_fichier_connection(_FILE_CONNECT)); |
|
| 47 | 47 | |
| 48 | - // Si deja installe, on n'a plus le droit qu'a l'etape chmod |
|
| 49 | - // pour chgt post-install ou aux etapes supplementaires |
|
| 50 | - // de declaration de base externes. |
|
| 51 | - // Mais alors il faut authentifier car ecrire/index.php l'a omis |
|
| 48 | + // Si deja installe, on n'a plus le droit qu'a l'etape chmod |
|
| 49 | + // pour chgt post-install ou aux etapes supplementaires |
|
| 50 | + // de declaration de base externes. |
|
| 51 | + // Mais alors il faut authentifier car ecrire/index.php l'a omis |
|
| 52 | 52 | |
| 53 | - if ($deja and in_array($etape, array('chmod', 'sup1', 'sup2'))) { |
|
| 53 | + if ($deja and in_array($etape, array('chmod', 'sup1', 'sup2'))) { |
|
| 54 | 54 | |
| 55 | - $auth = charger_fonction('auth', 'inc'); |
|
| 56 | - if (!$auth()) { |
|
| 57 | - verifier_visiteur(); |
|
| 58 | - $deja = (!autoriser('configurer')); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - if ($deja) { |
|
| 62 | - // Rien a faire ici |
|
| 63 | - echo minipres(); |
|
| 64 | - } else { |
|
| 65 | - include_spip('base/create'); |
|
| 66 | - $fonc = charger_fonction("etape_$etape", 'install'); |
|
| 67 | - $fonc(); |
|
| 68 | - } |
|
| 55 | + $auth = charger_fonction('auth', 'inc'); |
|
| 56 | + if (!$auth()) { |
|
| 57 | + verifier_visiteur(); |
|
| 58 | + $deja = (!autoriser('configurer')); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + if ($deja) { |
|
| 62 | + // Rien a faire ici |
|
| 63 | + echo minipres(); |
|
| 64 | + } else { |
|
| 65 | + include_spip('base/create'); |
|
| 66 | + $fonc = charger_fonction("etape_$etape", 'install'); |
|
| 67 | + $fonc(); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -25,25 +25,25 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function exec_404_dist() { |
| 27 | 27 | |
| 28 | - $exec = _request('exec'); |
|
| 28 | + $exec = _request('exec'); |
|
| 29 | 29 | |
| 30 | - $titre = "exec_$exec"; |
|
| 31 | - $navigation = ''; |
|
| 32 | - $extra = ''; |
|
| 30 | + $titre = "exec_$exec"; |
|
| 31 | + $navigation = ''; |
|
| 32 | + $extra = ''; |
|
| 33 | 33 | |
| 34 | - include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 35 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 36 | - echo $commencer_page($titre); |
|
| 34 | + include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini |
|
| 35 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 36 | + echo $commencer_page($titre); |
|
| 37 | 37 | |
| 38 | - echo debut_gauche("404_$exec", true); |
|
| 39 | - echo pipeline('affiche_gauche', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => '')); |
|
| 38 | + echo debut_gauche("404_$exec", true); |
|
| 39 | + echo pipeline('affiche_gauche', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => '')); |
|
| 40 | 40 | |
| 41 | - echo creer_colonne_droite('404', true); |
|
| 42 | - echo pipeline('affiche_droite', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => '')); |
|
| 41 | + echo creer_colonne_droite('404', true); |
|
| 42 | + echo pipeline('affiche_droite', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => '')); |
|
| 43 | 43 | |
| 44 | - echo debut_droite('404', true); |
|
| 45 | - echo "<h1 class='grostitre'>" . _T('fichier_introuvable', array('fichier' => $exec)) . '</h1>'; |
|
| 46 | - echo pipeline('affiche_milieu', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => '')); |
|
| 44 | + echo debut_droite('404', true); |
|
| 45 | + echo "<h1 class='grostitre'>" . _T('fichier_introuvable', array('fichier' => $exec)) . '</h1>'; |
|
| 46 | + echo pipeline('affiche_milieu', array('args' => array('exec' => '404', 'exec_erreur' => $exec), 'data' => '')); |
|
| 47 | 47 | |
| 48 | - echo fin_gauche(), fin_page(); |
|
| 48 | + echo fin_gauche(), fin_page(); |
|
| 49 | 49 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | * @uses ajax_retour() |
| 28 | 28 | **/ |
| 29 | 29 | function exec_plonger_dist() { |
| 30 | - include_spip('inc/actions'); |
|
| 30 | + include_spip('inc/actions'); |
|
| 31 | 31 | |
| 32 | - $rac = preg_replace(',[^\w\,/#&;-]+,', ' ', _request('rac')); |
|
| 33 | - $id = intval(_request('id')); |
|
| 34 | - $exclus = intval(_request('exclus')); |
|
| 35 | - $col = intval(_request('col')); |
|
| 36 | - $do = _request('do'); |
|
| 37 | - if (preg_match('/^\w*$/', $do)) { |
|
| 38 | - if (!$do) { |
|
| 39 | - $do = 'aff'; |
|
| 40 | - } |
|
| 32 | + $rac = preg_replace(',[^\w\,/#&;-]+,', ' ', _request('rac')); |
|
| 33 | + $id = intval(_request('id')); |
|
| 34 | + $exclus = intval(_request('exclus')); |
|
| 35 | + $col = intval(_request('col')); |
|
| 36 | + $do = _request('do'); |
|
| 37 | + if (preg_match('/^\w*$/', $do)) { |
|
| 38 | + if (!$do) { |
|
| 39 | + $do = 'aff'; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $plonger = charger_fonction('plonger', 'inc'); |
|
| 43 | - $r = $plonger($id, spip_htmlentities($rac), array(), $col, $exclus, $do); |
|
| 44 | - } else { |
|
| 45 | - $r = ''; |
|
| 46 | - } |
|
| 42 | + $plonger = charger_fonction('plonger', 'inc'); |
|
| 43 | + $r = $plonger($id, spip_htmlentities($rac), array(), $col, $exclus, $do); |
|
| 44 | + } else { |
|
| 45 | + $r = ''; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - ajax_retour($r); |
|
| 48 | + ajax_retour($r); |
|
| 49 | 49 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | include_spip('inc/actions'); |
@@ -21,23 +21,23 @@ discard block |
||
| 21 | 21 | * @uses ajax_retour() |
| 22 | 22 | */ |
| 23 | 23 | function exec_info_plugin_dist() { |
| 24 | - if (!autoriser('configurer', '_plugins')) { |
|
| 25 | - include_spip('inc/minipres'); |
|
| 26 | - echo minipres(); |
|
| 27 | - } else { |
|
| 28 | - $plug = _DIR_RACINE . htmlspecialchars(_request('plugin')); |
|
| 29 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 30 | - $dir = ""; |
|
| 31 | - if (strncmp($plug, _DIR_PLUGINS, strlen(_DIR_PLUGINS)) == 0) { |
|
| 32 | - $dir = _DIR_PLUGINS; |
|
| 33 | - } elseif (strncmp($plug, _DIR_PLUGINS_DIST, strlen(_DIR_PLUGINS_DIST)) == 0) { |
|
| 34 | - $dir = _DIR_PLUGINS_DIST; |
|
| 35 | - } |
|
| 36 | - if ($dir) { |
|
| 37 | - $plug = substr($plug, strlen($dir)); |
|
| 38 | - } |
|
| 39 | - $info = $get_infos($plug, false, $dir); |
|
| 40 | - $afficher_plugin = charger_fonction("afficher_plugin", "plugins"); |
|
| 41 | - ajax_retour(affiche_bloc_plugin($plug, $info, $dir)); |
|
| 42 | - } |
|
| 24 | + if (!autoriser('configurer', '_plugins')) { |
|
| 25 | + include_spip('inc/minipres'); |
|
| 26 | + echo minipres(); |
|
| 27 | + } else { |
|
| 28 | + $plug = _DIR_RACINE . htmlspecialchars(_request('plugin')); |
|
| 29 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 30 | + $dir = ""; |
|
| 31 | + if (strncmp($plug, _DIR_PLUGINS, strlen(_DIR_PLUGINS)) == 0) { |
|
| 32 | + $dir = _DIR_PLUGINS; |
|
| 33 | + } elseif (strncmp($plug, _DIR_PLUGINS_DIST, strlen(_DIR_PLUGINS_DIST)) == 0) { |
|
| 34 | + $dir = _DIR_PLUGINS_DIST; |
|
| 35 | + } |
|
| 36 | + if ($dir) { |
|
| 37 | + $plug = substr($plug, strlen($dir)); |
|
| 38 | + } |
|
| 39 | + $info = $get_infos($plug, false, $dir); |
|
| 40 | + $afficher_plugin = charger_fonction("afficher_plugin", "plugins"); |
|
| 41 | + ajax_retour(affiche_bloc_plugin($plug, $info, $dir)); |
|
| 42 | + } |
|
| 43 | 43 | } |