@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | * @return array |
| 23 | 23 | */ |
| 24 | 24 | function inc_simplexml_to_array_dist($u, $utiliser_namespace = false) { |
| 25 | - // decoder la chaine en SimpleXML si pas deja fait |
|
| 26 | - if (is_string($u)) { |
|
| 27 | - $u = simplexml_load_string($u); |
|
| 28 | - } |
|
| 25 | + // decoder la chaine en SimpleXML si pas deja fait |
|
| 26 | + if (is_string($u)) { |
|
| 27 | + $u = simplexml_load_string($u); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - return ['root' => @xmlObjToArr($u, $utiliser_namespace)]; |
|
| 30 | + return ['root' => @xmlObjToArr($u, $utiliser_namespace)]; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -42,67 +42,67 @@ discard block |
||
| 42 | 42 | **/ |
| 43 | 43 | function xmlObjToArr($obj, $utiliser_namespace = false) { |
| 44 | 44 | |
| 45 | - $namespace = []; |
|
| 46 | - $tableau = []; |
|
| 45 | + $namespace = []; |
|
| 46 | + $tableau = []; |
|
| 47 | 47 | |
| 48 | - // Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc |
|
| 49 | - // de l'activer ou pas suivant le contenu supposé du XML |
|
| 50 | - if (is_object($obj)) { |
|
| 51 | - if (is_array($utiliser_namespace)) { |
|
| 52 | - $namespace = $utiliser_namespace; |
|
| 53 | - } else { |
|
| 54 | - if ($utiliser_namespace) { |
|
| 55 | - $namespace = $obj->getDocNamespaces(true); |
|
| 56 | - } |
|
| 57 | - $namespace[null] = null; |
|
| 58 | - } |
|
| 48 | + // Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc |
|
| 49 | + // de l'activer ou pas suivant le contenu supposé du XML |
|
| 50 | + if (is_object($obj)) { |
|
| 51 | + if (is_array($utiliser_namespace)) { |
|
| 52 | + $namespace = $utiliser_namespace; |
|
| 53 | + } else { |
|
| 54 | + if ($utiliser_namespace) { |
|
| 55 | + $namespace = $obj->getDocNamespaces(true); |
|
| 56 | + } |
|
| 57 | + $namespace[null] = null; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - $name = strtolower((string)$obj->getName()); |
|
| 61 | - $text = trim((string)$obj); |
|
| 62 | - if (strlen($text) <= 0) { |
|
| 63 | - $text = null; |
|
| 64 | - } |
|
| 60 | + $name = strtolower((string)$obj->getName()); |
|
| 61 | + $text = trim((string)$obj); |
|
| 62 | + if (strlen($text) <= 0) { |
|
| 63 | + $text = null; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - $children = []; |
|
| 67 | - $attributes = []; |
|
| 66 | + $children = []; |
|
| 67 | + $attributes = []; |
|
| 68 | 68 | |
| 69 | - // get info for all namespaces |
|
| 70 | - foreach (array_keys($namespace) as $ns) { |
|
| 71 | - // attributes |
|
| 72 | - $objAttributes = $obj->attributes($ns, true); |
|
| 73 | - foreach ($objAttributes as $attributeName => $attributeValue) { |
|
| 74 | - $attribName = strtolower(trim((string)$attributeName)); |
|
| 75 | - $attribVal = trim((string)$attributeValue); |
|
| 76 | - if (!empty($ns)) { |
|
| 77 | - $attribName = $ns . ':' . $attribName; |
|
| 78 | - } |
|
| 79 | - $attributes[$attribName] = $attribVal; |
|
| 80 | - } |
|
| 69 | + // get info for all namespaces |
|
| 70 | + foreach (array_keys($namespace) as $ns) { |
|
| 71 | + // attributes |
|
| 72 | + $objAttributes = $obj->attributes($ns, true); |
|
| 73 | + foreach ($objAttributes as $attributeName => $attributeValue) { |
|
| 74 | + $attribName = strtolower(trim((string)$attributeName)); |
|
| 75 | + $attribVal = trim((string)$attributeValue); |
|
| 76 | + if (!empty($ns)) { |
|
| 77 | + $attribName = $ns . ':' . $attribName; |
|
| 78 | + } |
|
| 79 | + $attributes[$attribName] = $attribVal; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // children |
|
| 83 | - $objChildren = $obj->children($ns, true); |
|
| 84 | - foreach ($objChildren as $childName => $child) { |
|
| 85 | - $childName = strtolower((string)$childName); |
|
| 86 | - if (!empty($ns)) { |
|
| 87 | - $childName = $ns . ':' . $childName; |
|
| 88 | - } |
|
| 89 | - $children[$childName][] = xmlObjToArr($child, $namespace); |
|
| 90 | - } |
|
| 91 | - } |
|
| 82 | + // children |
|
| 83 | + $objChildren = $obj->children($ns, true); |
|
| 84 | + foreach ($objChildren as $childName => $child) { |
|
| 85 | + $childName = strtolower((string)$childName); |
|
| 86 | + if (!empty($ns)) { |
|
| 87 | + $childName = $ns . ':' . $childName; |
|
| 88 | + } |
|
| 89 | + $children[$childName][] = xmlObjToArr($child, $namespace); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $tableau = [ |
|
| 94 | - 'name' => $name, |
|
| 95 | - ]; |
|
| 96 | - if ($text) { |
|
| 97 | - $tableau['text'] = $text; |
|
| 98 | - } |
|
| 99 | - if ($attributes) { |
|
| 100 | - $tableau['attributes'] = $attributes; |
|
| 101 | - } |
|
| 102 | - if ($children) { |
|
| 103 | - $tableau['children'] = $children; |
|
| 104 | - } |
|
| 105 | - } |
|
| 93 | + $tableau = [ |
|
| 94 | + 'name' => $name, |
|
| 95 | + ]; |
|
| 96 | + if ($text) { |
|
| 97 | + $tableau['text'] = $text; |
|
| 98 | + } |
|
| 99 | + if ($attributes) { |
|
| 100 | + $tableau['attributes'] = $attributes; |
|
| 101 | + } |
|
| 102 | + if ($children) { |
|
| 103 | + $tableau['children'] = $children; |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - return $tableau; |
|
| 107 | + return $tableau; |
|
| 108 | 108 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -28,51 +28,51 @@ discard block |
||
| 28 | 28 | * @return string Erreur éventuelle |
| 29 | 29 | */ |
| 30 | 30 | function inc_completer_traduction_dist($objet, $id_objet, $id_trad) { |
| 31 | - // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 32 | - // cf API editer_liens |
|
| 33 | - include_spip('action/editer_liens'); |
|
| 34 | - objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 35 | - $_id_table = id_table_objet($objet); |
|
| 31 | + // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 32 | + // cf API editer_liens |
|
| 33 | + include_spip('action/editer_liens'); |
|
| 34 | + objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 35 | + $_id_table = id_table_objet($objet); |
|
| 36 | 36 | |
| 37 | - // recuperer le logo |
|
| 38 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 39 | - include_spip('action/editer_logo'); |
|
| 40 | - foreach (['on', 'off'] as $etat) { |
|
| 41 | - $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 42 | - if ($logo && ($file = reset($logo))) { |
|
| 43 | - logo_modifier($objet, $id_objet, $etat, $file); |
|
| 44 | - } |
|
| 45 | - } |
|
| 37 | + // recuperer le logo |
|
| 38 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 39 | + include_spip('action/editer_logo'); |
|
| 40 | + foreach (['on', 'off'] as $etat) { |
|
| 41 | + $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 42 | + if ($logo && ($file = reset($logo))) { |
|
| 43 | + logo_modifier($objet, $id_objet, $etat, $file); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - // dupliquer certains champs |
|
| 48 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 49 | - $desc = $trouver_table(table_objet_sql($objet)); |
|
| 50 | - $champs = $set = []; |
|
| 47 | + // dupliquer certains champs |
|
| 48 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 49 | + $desc = $trouver_table(table_objet_sql($objet)); |
|
| 50 | + $champs = $set = []; |
|
| 51 | 51 | |
| 52 | - // un éventuel champ 'virtuel' (redirections) |
|
| 53 | - if (!empty($desc['field']['virtuel'])) { |
|
| 54 | - $champs[] = 'virtuel'; |
|
| 55 | - } |
|
| 52 | + // un éventuel champ 'virtuel' (redirections) |
|
| 53 | + if (!empty($desc['field']['virtuel'])) { |
|
| 54 | + $champs[] = 'virtuel'; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad); |
|
| 57 | + $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . (int) $id_trad); |
|
| 58 | 58 | |
| 59 | - foreach ($champs as $c) { |
|
| 60 | - $set[$c] = $data[$c]; |
|
| 61 | - } |
|
| 59 | + foreach ($champs as $c) { |
|
| 60 | + $set[$c] = $data[$c]; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /* |
|
| 63 | + /* |
|
| 64 | 64 | * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'. |
| 65 | 65 | * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction. |
| 66 | 66 | */ |
| 67 | - $err = objet_modifier_champs( |
|
| 68 | - $objet, |
|
| 69 | - $id_objet, |
|
| 70 | - [ |
|
| 71 | - 'data' => $data, |
|
| 72 | - 'action' => 'completer_traduction', |
|
| 73 | - ], |
|
| 74 | - $set |
|
| 75 | - ); |
|
| 67 | + $err = objet_modifier_champs( |
|
| 68 | + $objet, |
|
| 69 | + $id_objet, |
|
| 70 | + [ |
|
| 71 | + 'data' => $data, |
|
| 72 | + 'action' => 'completer_traduction', |
|
| 73 | + ], |
|
| 74 | + $set |
|
| 75 | + ); |
|
| 76 | 76 | |
| 77 | - return $err; |
|
| 77 | + return $err; |
|
| 78 | 78 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -42,25 +42,25 @@ discard block |
||
| 42 | 42 | * @return string Code HTML |
| 43 | 43 | **/ |
| 44 | 44 | function inc_commencer_page_dist( |
| 45 | - $titre = '', |
|
| 46 | - $rubrique = 'accueil', |
|
| 47 | - $sous_rubrique = 'accueil', |
|
| 48 | - $id_rubrique = '', |
|
| 49 | - $menu = true, |
|
| 50 | - $minipres = false, |
|
| 51 | - $alertes = true |
|
| 45 | + $titre = '', |
|
| 46 | + $rubrique = 'accueil', |
|
| 47 | + $sous_rubrique = 'accueil', |
|
| 48 | + $id_rubrique = '', |
|
| 49 | + $menu = true, |
|
| 50 | + $minipres = false, |
|
| 51 | + $alertes = true |
|
| 52 | 52 | ) { |
| 53 | 53 | |
| 54 | - include_spip('inc/headers'); |
|
| 54 | + include_spip('inc/headers'); |
|
| 55 | 55 | |
| 56 | - http_no_cache(); |
|
| 56 | + http_no_cache(); |
|
| 57 | 57 | |
| 58 | - return init_entete($titre, $id_rubrique, $minipres) |
|
| 59 | - . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu) |
|
| 60 | - . "<div id='page'>" |
|
| 61 | - . auteurs_recemment_connectes($GLOBALS['connect_id_auteur']) |
|
| 62 | - . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '') |
|
| 63 | - . '<div class="largeur">'; |
|
| 58 | + return init_entete($titre, $id_rubrique, $minipres) |
|
| 59 | + . init_body($rubrique, $sous_rubrique, $id_rubrique, $menu) |
|
| 60 | + . "<div id='page'>" |
|
| 61 | + . auteurs_recemment_connectes($GLOBALS['connect_id_auteur']) |
|
| 62 | + . ($alertes ? alertes_auteur($GLOBALS['connect_id_auteur']) : '') |
|
| 63 | + . '<div class="largeur">'; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -81,21 +81,21 @@ discard block |
||
| 81 | 81 | * Entête du fichier HTML avec le DOCTYPE |
| 82 | 82 | */ |
| 83 | 83 | function init_entete($titre = '', $dummy = 0, $minipres = false) { |
| 84 | - include_spip('inc/texte'); |
|
| 85 | - if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 86 | - $nom_site_spip = _T('info_mon_site_spip'); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $titre = '[' |
|
| 90 | - . $nom_site_spip |
|
| 91 | - . ']' |
|
| 92 | - . ($titre ? ' ' . textebrut(typo($titre)) : ''); |
|
| 93 | - |
|
| 94 | - return _DOCTYPE_ECRIRE |
|
| 95 | - . html_lang_attributes() |
|
| 96 | - . "<head>\n" |
|
| 97 | - . init_head($titre, $dummy, $minipres) |
|
| 98 | - . "</head>\n"; |
|
| 84 | + include_spip('inc/texte'); |
|
| 85 | + if (!$nom_site_spip = textebrut(typo($GLOBALS['meta']['nom_site']))) { |
|
| 86 | + $nom_site_spip = _T('info_mon_site_spip'); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $titre = '[' |
|
| 90 | + . $nom_site_spip |
|
| 91 | + . ']' |
|
| 92 | + . ($titre ? ' ' . textebrut(typo($titre)) : ''); |
|
| 93 | + |
|
| 94 | + return _DOCTYPE_ECRIRE |
|
| 95 | + . html_lang_attributes() |
|
| 96 | + . "<head>\n" |
|
| 97 | + . init_head($titre, $dummy, $minipres) |
|
| 98 | + . "</head>\n"; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | 111 | function init_head($titre = '', $dummy = 0, $minipres = false) { |
| 112 | - return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']); |
|
| 112 | + return recuperer_fond('prive/squelettes/head/dist', ['titre' => $titre, 'minipres' => $minipres ? ' ' : '']); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -131,20 +131,20 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | function init_body($rubrique = 'accueil', $sous_rubrique = 'accueil', $id_rubrique = '', $menu = true) { |
| 133 | 133 | |
| 134 | - $res = pipeline('body_prive', "<body class='" |
|
| 135 | - . init_body_class() . ' ' . _request('exec') . "'" |
|
| 136 | - . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '') |
|
| 137 | - . '>'); |
|
| 134 | + $res = pipeline('body_prive', "<body class='" |
|
| 135 | + . init_body_class() . ' ' . _request('exec') . "'" |
|
| 136 | + . ($GLOBALS['spip_lang_rtl'] ? " dir='rtl'" : '') |
|
| 137 | + . '>'); |
|
| 138 | 138 | |
| 139 | - if (!$menu) { |
|
| 140 | - return $res; |
|
| 141 | - } |
|
| 139 | + if (!$menu) { |
|
| 140 | + return $res; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | |
| 144 | - $bandeau = charger_fonction('bandeau', 'inc'); |
|
| 144 | + $bandeau = charger_fonction('bandeau', 'inc'); |
|
| 145 | 145 | |
| 146 | - return $res |
|
| 147 | - . $bandeau(); |
|
| 146 | + return $res |
|
| 147 | + . $bandeau(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -156,23 +156,23 @@ discard block |
||
| 156 | 156 | * @return string Classes CSS (séparées par des espaces) |
| 157 | 157 | */ |
| 158 | 158 | function init_body_class() { |
| 159 | - $display_modes = [ |
|
| 160 | - 0 => 'icones_img_texte' // défaut. |
|
| 161 | - /*init*/, |
|
| 162 | - 1 => 'icones_texte', |
|
| 163 | - 2 => 'icones_img_texte', |
|
| 164 | - 3 => 'icones_img' |
|
| 165 | - ]; |
|
| 159 | + $display_modes = [ |
|
| 160 | + 0 => 'icones_img_texte' // défaut. |
|
| 161 | + /*init*/, |
|
| 162 | + 1 => 'icones_texte', |
|
| 163 | + 2 => 'icones_img_texte', |
|
| 164 | + 3 => 'icones_img' |
|
| 165 | + ]; |
|
| 166 | 166 | |
| 167 | - $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 167 | + $prefs = $GLOBALS['visiteur_session']['prefs'] ?? []; |
|
| 168 | 168 | |
| 169 | - $display_mode = $display_modes[(int) ($prefs['display'] ?? 0)] ?? $display_modes[0]; |
|
| 170 | - $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones'; |
|
| 169 | + $display_mode = $display_modes[(int) ($prefs['display'] ?? 0)] ?? $display_modes[0]; |
|
| 170 | + $spip_display_navigation = isset($prefs['display_navigation']) ? spip_sanitize_classname($prefs['display_navigation']) : 'navigation_avec_icones'; |
|
| 171 | 171 | |
| 172 | - $couleur = (int) ($prefs['couleur'] ?? 2); |
|
| 172 | + $couleur = (int) ($prefs['couleur'] ?? 2); |
|
| 173 | 173 | |
| 174 | - $classes = "spip-theme-colors-$couleur $spip_display_navigation $display_mode"; |
|
| 175 | - return spip_sanitize_classname($classes); |
|
| 174 | + $classes = "spip-theme-colors-$couleur $spip_display_navigation $display_mode"; |
|
| 175 | + return spip_sanitize_classname($classes); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -183,5 +183,5 @@ discard block |
||
| 183 | 183 | * @return string |
| 184 | 184 | */ |
| 185 | 185 | function auteurs_recemment_connectes($id_auteur) { |
| 186 | - return recuperer_fond('prive/objets/liste/auteurs_enligne'); |
|
| 186 | + return recuperer_fond('prive/objets/liste/auteurs_enligne'); |
|
| 187 | 187 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Fichier |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -35,28 +35,28 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function spip_livrer_fichier($fichier, $content_type = 'application/octet-stream', $options = []) { |
| 37 | 37 | |
| 38 | - $defaut = [ |
|
| 39 | - 'attachment' => false, |
|
| 40 | - 'expires' => 3600, |
|
| 41 | - 'range' => null, |
|
| 42 | - ]; |
|
| 43 | - $options = array_merge($defaut, $options); |
|
| 44 | - if (is_numeric($options['expires']) && $options['expires'] > 0) { |
|
| 45 | - $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - if (is_null($options) && isset($_SERVER['HTTP_RANGE'])) { |
|
| 49 | - $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - spip_livrer_fichier_entetes($fichier, $content_type, ($options['attachment'] && !$options['range']) ? $options['attachment'] : false, $options['expires']); |
|
| 53 | - |
|
| 54 | - if (!is_null($options['range'])) { |
|
| 55 | - spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 56 | - } |
|
| 57 | - else { |
|
| 58 | - spip_livrer_fichier_entier($fichier); |
|
| 59 | - } |
|
| 38 | + $defaut = [ |
|
| 39 | + 'attachment' => false, |
|
| 40 | + 'expires' => 3600, |
|
| 41 | + 'range' => null, |
|
| 42 | + ]; |
|
| 43 | + $options = array_merge($defaut, $options); |
|
| 44 | + if (is_numeric($options['expires']) && $options['expires'] > 0) { |
|
| 45 | + $options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT'; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + if (is_null($options) && isset($_SERVER['HTTP_RANGE'])) { |
|
| 49 | + $options['range'] = $_SERVER['HTTP_RANGE']; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + spip_livrer_fichier_entetes($fichier, $content_type, ($options['attachment'] && !$options['range']) ? $options['attachment'] : false, $options['expires']); |
|
| 53 | + |
|
| 54 | + if (!is_null($options['range'])) { |
|
| 55 | + spip_livrer_fichier_partie($fichier, $options['range']); |
|
| 56 | + } |
|
| 57 | + else { |
|
| 58 | + spip_livrer_fichier_entier($fichier); |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -69,33 +69,33 @@ discard block |
||
| 69 | 69 | * @param int|string $expires |
| 70 | 70 | */ |
| 71 | 71 | function spip_livrer_fichier_entetes($fichier, $content_type = 'application/octet-stream', $attachment = false, $expires = 0) { |
| 72 | - // toujours envoyer un content type, meme vide ! |
|
| 73 | - header('Accept-Ranges: bytes'); |
|
| 74 | - header('Content-Type: ' . $content_type); |
|
| 75 | - |
|
| 76 | - if (($fs = stat($fichier)) && !empty($fs['size']) && !empty($fs['mtime'])) { |
|
| 77 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $fs['mtime']) . ' GMT'); |
|
| 78 | - header(sprintf('Etag: "%x-%x"', $fs['size'], str_pad($fs['mtime'], 16, '0'))); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($attachment) { |
|
| 82 | - $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 83 | - // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 84 | - header('Content-Type: application/octet-stream'); |
|
| 85 | - |
|
| 86 | - header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 87 | - header('Content-Transfer-Encoding: binary'); |
|
| 88 | - |
|
| 89 | - // fix for IE caching or PHP bug issue |
|
| 90 | - header('Expires: 0'); // set expiration time |
|
| 91 | - header('Pragma: public'); |
|
| 92 | - header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 93 | - } |
|
| 94 | - else { |
|
| 95 | - $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 96 | - header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 97 | - header('Expires: ' . $expires); // set expiration time |
|
| 98 | - } |
|
| 72 | + // toujours envoyer un content type, meme vide ! |
|
| 73 | + header('Accept-Ranges: bytes'); |
|
| 74 | + header('Content-Type: ' . $content_type); |
|
| 75 | + |
|
| 76 | + if (($fs = stat($fichier)) && !empty($fs['size']) && !empty($fs['mtime'])) { |
|
| 77 | + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $fs['mtime']) . ' GMT'); |
|
| 78 | + header(sprintf('Etag: "%x-%x"', $fs['size'], str_pad($fs['mtime'], 16, '0'))); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($attachment) { |
|
| 82 | + $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 83 | + // ce content-type est necessaire pour eviter des corruptions de zip dans ie6 |
|
| 84 | + header('Content-Type: application/octet-stream'); |
|
| 85 | + |
|
| 86 | + header("Content-Disposition: attachment; filename=\"$f\";"); |
|
| 87 | + header('Content-Transfer-Encoding: binary'); |
|
| 88 | + |
|
| 89 | + // fix for IE caching or PHP bug issue |
|
| 90 | + header('Expires: 0'); // set expiration time |
|
| 91 | + header('Pragma: public'); |
|
| 92 | + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
|
| 93 | + } |
|
| 94 | + else { |
|
| 95 | + $f = (is_string($attachment) ? $attachment : basename($fichier)); |
|
| 96 | + header("Content-Disposition: inline; filename=\"$f\";"); |
|
| 97 | + header('Expires: ' . $expires); // set expiration time |
|
| 98 | + } |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -103,20 +103,20 @@ discard block |
||
| 103 | 103 | * @param string $fichier |
| 104 | 104 | */ |
| 105 | 105 | function spip_livrer_fichier_entier($fichier) { |
| 106 | - if (!file_exists($fichier)) { |
|
| 107 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 108 | - } |
|
| 106 | + if (!file_exists($fichier)) { |
|
| 107 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - if (!is_readable($fichier)) { |
|
| 111 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 112 | - } |
|
| 110 | + if (!is_readable($fichier)) { |
|
| 111 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - if ($size = filesize($fichier)) { |
|
| 115 | - header(sprintf('Content-Length: %d', $size)); |
|
| 116 | - } |
|
| 114 | + if ($size = filesize($fichier)) { |
|
| 115 | + header(sprintf('Content-Length: %d', $size)); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - readfile($fichier); |
|
| 119 | - exit(); |
|
| 118 | + readfile($fichier); |
|
| 119 | + exit(); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
@@ -129,98 +129,98 @@ discard block |
||
| 129 | 129 | * @throws Exception |
| 130 | 130 | */ |
| 131 | 131 | function spip_livrer_fichier_partie($fichier, $range = null) { |
| 132 | - if (!file_exists($fichier)) { |
|
| 133 | - throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 134 | - } |
|
| 132 | + if (!file_exists($fichier)) { |
|
| 133 | + throw new \Exception(sprintf('File not found: %s', $fichier)); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - if (!is_readable($fichier)) { |
|
| 137 | - throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 138 | - } |
|
| 136 | + if (!is_readable($fichier)) { |
|
| 137 | + throw new \Exception(sprintf('File not readable: %s', $fichier)); |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | |
| 141 | - // Par defaut on envoie tout |
|
| 142 | - $byteOffset = 0; |
|
| 143 | - $byteLength = $fileSize = filesize($fichier); |
|
| 141 | + // Par defaut on envoie tout |
|
| 142 | + $byteOffset = 0; |
|
| 143 | + $byteLength = $fileSize = filesize($fichier); |
|
| 144 | 144 | |
| 145 | 145 | |
| 146 | - // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 147 | - if ($range && preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 148 | - ### Offset signifies where we should begin to read the file |
|
| 149 | - $byteOffset = (int)$match[1]; |
|
| 146 | + // Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451" |
|
| 147 | + if ($range && preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) { |
|
| 148 | + ### Offset signifies where we should begin to read the file |
|
| 149 | + $byteOffset = (int)$match[1]; |
|
| 150 | 150 | |
| 151 | 151 | |
| 152 | - ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 153 | - if (isset($match[2])) { |
|
| 154 | - $finishBytes = (int)$match[2]; |
|
| 155 | - $byteLength = $finishBytes + 1; |
|
| 156 | - } else { |
|
| 157 | - $finishBytes = $fileSize - 1; |
|
| 158 | - } |
|
| 152 | + ### Length is for how long we should read the file according to the browser, and can never go beyond the file size |
|
| 153 | + if (isset($match[2])) { |
|
| 154 | + $finishBytes = (int)$match[2]; |
|
| 155 | + $byteLength = $finishBytes + 1; |
|
| 156 | + } else { |
|
| 157 | + $finishBytes = $fileSize - 1; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 161 | - } |
|
| 162 | - else { |
|
| 163 | - // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 164 | - spip_livrer_fichier_entier($fichier); |
|
| 165 | - // redondant, mais facilite la comprehension du code |
|
| 166 | - exit(); |
|
| 167 | - } |
|
| 160 | + $cr_header = sprintf('Content-Range: bytes %d-%d/%d', $byteOffset, $finishBytes, $fileSize); |
|
| 161 | + } |
|
| 162 | + else { |
|
| 163 | + // si pas de range valide, on delegue a la methode d'envoi complet |
|
| 164 | + spip_livrer_fichier_entier($fichier); |
|
| 165 | + // redondant, mais facilite la comprehension du code |
|
| 166 | + exit(); |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - // Remove headers that might unnecessarily clutter up the output |
|
| 170 | - header_remove('Cache-Control'); |
|
| 171 | - header_remove('Pragma'); |
|
| 169 | + // Remove headers that might unnecessarily clutter up the output |
|
| 170 | + header_remove('Cache-Control'); |
|
| 171 | + header_remove('Pragma'); |
|
| 172 | 172 | |
| 173 | - // partial content |
|
| 174 | - header('HTTP/1.1 206 Partial content'); |
|
| 175 | - header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 173 | + // partial content |
|
| 174 | + header('HTTP/1.1 206 Partial content'); |
|
| 175 | + header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | - $byteRange = $byteLength - $byteOffset; |
|
| 178 | + $byteRange = $byteLength - $byteOffset; |
|
| 179 | 179 | |
| 180 | - header(sprintf('Content-Length: %d', $byteRange)); |
|
| 180 | + header(sprintf('Content-Length: %d', $byteRange)); |
|
| 181 | 181 | |
| 182 | - // Variable containing the buffer |
|
| 183 | - $buffer = ''; |
|
| 184 | - // Just a reasonable buffer size |
|
| 185 | - $bufferSize = 512 * 16; |
|
| 186 | - // Contains how much is left to read of the byteRange |
|
| 187 | - $bytePool = $byteRange; |
|
| 182 | + // Variable containing the buffer |
|
| 183 | + $buffer = ''; |
|
| 184 | + // Just a reasonable buffer size |
|
| 185 | + $bufferSize = 512 * 16; |
|
| 186 | + // Contains how much is left to read of the byteRange |
|
| 187 | + $bytePool = $byteRange; |
|
| 188 | 188 | |
| 189 | - if (!$handle = fopen($fichier, 'r')) { |
|
| 190 | - throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 191 | - } |
|
| 189 | + if (!$handle = fopen($fichier, 'r')) { |
|
| 190 | + throw new \Exception(sprintf('Could not get handle for file %s', $fichier)); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 194 | - throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 195 | - } |
|
| 193 | + if (fseek($handle, $byteOffset, SEEK_SET) == -1) { |
|
| 194 | + throw new \Exception(sprintf('Could not seek to byte offset %d', $byteOffset)); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | 197 | |
| 198 | - while ($bytePool > 0) { |
|
| 199 | - // How many bytes we request on this iteration |
|
| 200 | - $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 198 | + while ($bytePool > 0) { |
|
| 199 | + // How many bytes we request on this iteration |
|
| 200 | + $chunkSizeRequested = min($bufferSize, $bytePool); |
|
| 201 | 201 | |
| 202 | - // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 203 | - $buffer = fread($handle, $chunkSizeRequested); |
|
| 202 | + // Try readin $chunkSizeRequested bytes from $handle and put data in $buffer |
|
| 203 | + $buffer = fread($handle, $chunkSizeRequested); |
|
| 204 | 204 | |
| 205 | - // Store how many bytes were actually read |
|
| 206 | - $chunkSizeActual = strlen($buffer); |
|
| 205 | + // Store how many bytes were actually read |
|
| 206 | + $chunkSizeActual = strlen($buffer); |
|
| 207 | 207 | |
| 208 | - // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 209 | - if ($chunkSizeActual == 0) { |
|
| 210 | - // For production servers this should go in your php error log, since it will break the output |
|
| 211 | - trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 212 | - break; |
|
| 213 | - } |
|
| 208 | + // If we didn't get any bytes that means something unexpected has happened since $bytePool should be zero already |
|
| 209 | + if ($chunkSizeActual == 0) { |
|
| 210 | + // For production servers this should go in your php error log, since it will break the output |
|
| 211 | + trigger_error('Chunksize became 0', E_USER_WARNING); |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 216 | - $bytePool -= $chunkSizeActual; |
|
| 215 | + // Decrease byte pool with amount of bytes that were read during this iteration |
|
| 216 | + $bytePool -= $chunkSizeActual; |
|
| 217 | 217 | |
| 218 | - // Write the buffer to output |
|
| 219 | - print $buffer; |
|
| 218 | + // Write the buffer to output |
|
| 219 | + print $buffer; |
|
| 220 | 220 | |
| 221 | - // Try to output the data to the client immediately |
|
| 222 | - flush(); |
|
| 223 | - } |
|
| 221 | + // Try to output the data to the client immediately |
|
| 222 | + flush(); |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - exit(); |
|
| 225 | + exit(); |
|
| 226 | 226 | } |
@@ -15,22 +15,22 @@ |
||
| 15 | 15 | * Présentation des pages simplifiées pour installer SPIP |
| 16 | 16 | **/ |
| 17 | 17 | class Installation extends Admin { |
| 18 | - public const TYPE = 'installation'; |
|
| 18 | + public const TYPE = 'installation'; |
|
| 19 | 19 | |
| 20 | - protected function setOptions(array $options) { |
|
| 21 | - $options['titre'] ??= ''; |
|
| 22 | - if (!$options['titre'] || $options['titre'] === 'AUTO') { |
|
| 23 | - $options['titre'] = _T('info_installation_systeme_publication'); |
|
| 24 | - } |
|
| 25 | - $options = parent::setOptions($options); |
|
| 26 | - $options['couleur_fond'] = '#a1124d'; |
|
| 27 | - $options['css_files'][] = find_in_theme('installation.css'); |
|
| 28 | - $options['footer'] = ''; |
|
| 29 | - return $options; |
|
| 30 | - } |
|
| 20 | + protected function setOptions(array $options) { |
|
| 21 | + $options['titre'] ??= ''; |
|
| 22 | + if (!$options['titre'] || $options['titre'] === 'AUTO') { |
|
| 23 | + $options['titre'] = _T('info_installation_systeme_publication'); |
|
| 24 | + } |
|
| 25 | + $options = parent::setOptions($options); |
|
| 26 | + $options['couleur_fond'] = '#a1124d'; |
|
| 27 | + $options['css_files'][] = find_in_theme('installation.css'); |
|
| 28 | + $options['footer'] = ''; |
|
| 29 | + return $options; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function page($corps = '', $options = []) { |
|
| 33 | - $options['titre'] ??= 'AUTO'; |
|
| 34 | - return parent::page($corps, $options); |
|
| 35 | - } |
|
| 32 | + public function page($corps = '', $options = []) { |
|
| 33 | + $options['titre'] ??= 'AUTO'; |
|
| 34 | + return parent::page($corps, $options); |
|
| 35 | + } |
|
| 36 | 36 | } |
@@ -8,112 +8,112 @@ |
||
| 8 | 8 | **/ |
| 9 | 9 | class Sqlite |
| 10 | 10 | { |
| 11 | - /** @var Requeteur[] Liste des instances de requêteurs créés */ |
|
| 12 | - public static $requeteurs = []; |
|
| 13 | - /** @var bool[] Pour chaque connexion, flag pour savoir si une transaction est en cours */ |
|
| 14 | - public static $transaction_en_cours = []; |
|
| 11 | + /** @var Requeteur[] Liste des instances de requêteurs créés */ |
|
| 12 | + public static $requeteurs = []; |
|
| 13 | + /** @var bool[] Pour chaque connexion, flag pour savoir si une transaction est en cours */ |
|
| 14 | + public static $transaction_en_cours = []; |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Retourne une unique instance du requêteur |
|
| 19 | - * |
|
| 20 | - * Retourne une instance unique du requêteur pour une connexion SQLite |
|
| 21 | - * donnée |
|
| 22 | - * |
|
| 23 | - * @param string $serveur |
|
| 24 | - * Nom du connecteur |
|
| 25 | - * @return Requeteur |
|
| 26 | - * Instance unique du requêteur |
|
| 27 | - **/ |
|
| 28 | - public static function requeteur($serveur) { |
|
| 29 | - if (!isset(static::$requeteurs[$serveur])) { |
|
| 30 | - static::$requeteurs[$serveur] = new Requeteur($serveur); |
|
| 31 | - } |
|
| 17 | + /** |
|
| 18 | + * Retourne une unique instance du requêteur |
|
| 19 | + * |
|
| 20 | + * Retourne une instance unique du requêteur pour une connexion SQLite |
|
| 21 | + * donnée |
|
| 22 | + * |
|
| 23 | + * @param string $serveur |
|
| 24 | + * Nom du connecteur |
|
| 25 | + * @return Requeteur |
|
| 26 | + * Instance unique du requêteur |
|
| 27 | + **/ |
|
| 28 | + public static function requeteur($serveur) { |
|
| 29 | + if (!isset(static::$requeteurs[$serveur])) { |
|
| 30 | + static::$requeteurs[$serveur] = new Requeteur($serveur); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - return static::$requeteurs[$serveur]; |
|
| 34 | - } |
|
| 33 | + return static::$requeteurs[$serveur]; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Prépare le texte d'une requête avant son exécution |
|
| 38 | - * |
|
| 39 | - * Adapte la requête au format plus ou moins MySQL par un format |
|
| 40 | - * compris de SQLite. |
|
| 41 | - * |
|
| 42 | - * Change les préfixes de tables SPIP par ceux véritables |
|
| 43 | - * |
|
| 44 | - * @param string $query Requête à préparer |
|
| 45 | - * @param string $serveur Nom de la connexion |
|
| 46 | - * @return string Requête préparée |
|
| 47 | - */ |
|
| 48 | - public static function traduire_requete($query, $serveur) { |
|
| 49 | - $requeteur = static::requeteur($serveur); |
|
| 50 | - $traducteur = new Traducteur($query, $requeteur->prefixe, $requeteur->sqlite_version); |
|
| 36 | + /** |
|
| 37 | + * Prépare le texte d'une requête avant son exécution |
|
| 38 | + * |
|
| 39 | + * Adapte la requête au format plus ou moins MySQL par un format |
|
| 40 | + * compris de SQLite. |
|
| 41 | + * |
|
| 42 | + * Change les préfixes de tables SPIP par ceux véritables |
|
| 43 | + * |
|
| 44 | + * @param string $query Requête à préparer |
|
| 45 | + * @param string $serveur Nom de la connexion |
|
| 46 | + * @return string Requête préparée |
|
| 47 | + */ |
|
| 48 | + public static function traduire_requete($query, $serveur) { |
|
| 49 | + $requeteur = static::requeteur($serveur); |
|
| 50 | + $traducteur = new Traducteur($query, $requeteur->prefixe, $requeteur->sqlite_version); |
|
| 51 | 51 | |
| 52 | - return $traducteur->traduire_requete(); |
|
| 53 | - } |
|
| 52 | + return $traducteur->traduire_requete(); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Démarre une transaction |
|
| 57 | - * |
|
| 58 | - * @param string $serveur Nom de la connexion |
|
| 59 | - **/ |
|
| 60 | - public static function demarrer_transaction($serveur) { |
|
| 61 | - Sqlite::executer_requete('BEGIN TRANSACTION', $serveur); |
|
| 62 | - Sqlite::$transaction_en_cours[$serveur] = true; |
|
| 63 | - } |
|
| 55 | + /** |
|
| 56 | + * Démarre une transaction |
|
| 57 | + * |
|
| 58 | + * @param string $serveur Nom de la connexion |
|
| 59 | + **/ |
|
| 60 | + public static function demarrer_transaction($serveur) { |
|
| 61 | + Sqlite::executer_requete('BEGIN TRANSACTION', $serveur); |
|
| 62 | + Sqlite::$transaction_en_cours[$serveur] = true; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Exécute la requête donnée |
|
| 67 | - * |
|
| 68 | - * @param string $query Requête |
|
| 69 | - * @param string $serveur Nom de la connexion |
|
| 70 | - * @param null|bool $tracer Demander des statistiques (temps) ? |
|
| 71 | - **/ |
|
| 72 | - public static function executer_requete($query, $serveur, $tracer = null) { |
|
| 73 | - $requeteur = Sqlite::requeteur($serveur); |
|
| 65 | + /** |
|
| 66 | + * Exécute la requête donnée |
|
| 67 | + * |
|
| 68 | + * @param string $query Requête |
|
| 69 | + * @param string $serveur Nom de la connexion |
|
| 70 | + * @param null|bool $tracer Demander des statistiques (temps) ? |
|
| 71 | + **/ |
|
| 72 | + public static function executer_requete($query, $serveur, $tracer = null) { |
|
| 73 | + $requeteur = Sqlite::requeteur($serveur); |
|
| 74 | 74 | |
| 75 | - return $requeteur->executer_requete($query, $tracer); |
|
| 76 | - } |
|
| 75 | + return $requeteur->executer_requete($query, $tracer); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Obtient l'identifiant de la dernière ligne insérée ou modifiée |
|
| 80 | - * |
|
| 81 | - * @param string $serveur Nom de la connexion |
|
| 82 | - * return int Identifiant |
|
| 83 | - **/ |
|
| 84 | - public static function last_insert_id($serveur) { |
|
| 85 | - $requeteur = Sqlite::requeteur($serveur); |
|
| 78 | + /** |
|
| 79 | + * Obtient l'identifiant de la dernière ligne insérée ou modifiée |
|
| 80 | + * |
|
| 81 | + * @param string $serveur Nom de la connexion |
|
| 82 | + * return int Identifiant |
|
| 83 | + **/ |
|
| 84 | + public static function last_insert_id($serveur) { |
|
| 85 | + $requeteur = Sqlite::requeteur($serveur); |
|
| 86 | 86 | |
| 87 | - return $requeteur->last_insert_id(); |
|
| 88 | - } |
|
| 87 | + return $requeteur->last_insert_id(); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Annule une transaction |
|
| 92 | - * |
|
| 93 | - * @param string $serveur Nom de la connexion |
|
| 94 | - **/ |
|
| 95 | - public static function annuler_transaction($serveur) { |
|
| 96 | - Sqlite::executer_requete('ROLLBACK', $serveur); |
|
| 97 | - Sqlite::$transaction_en_cours[$serveur] = false; |
|
| 98 | - } |
|
| 90 | + /** |
|
| 91 | + * Annule une transaction |
|
| 92 | + * |
|
| 93 | + * @param string $serveur Nom de la connexion |
|
| 94 | + **/ |
|
| 95 | + public static function annuler_transaction($serveur) { |
|
| 96 | + Sqlite::executer_requete('ROLLBACK', $serveur); |
|
| 97 | + Sqlite::$transaction_en_cours[$serveur] = false; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Termine une transaction |
|
| 102 | - * |
|
| 103 | - * @param string $serveur Nom de la connexion |
|
| 104 | - **/ |
|
| 105 | - public static function finir_transaction($serveur) { |
|
| 106 | - // si pas de transaction en cours, ne rien faire et le dire |
|
| 107 | - if ( |
|
| 108 | - !isset(Sqlite::$transaction_en_cours[$serveur]) |
|
| 109 | - || Sqlite::$transaction_en_cours[$serveur] == false |
|
| 110 | - ) { |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 113 | - // sinon fermer la transaction et retourner true |
|
| 114 | - Sqlite::executer_requete('COMMIT', $serveur); |
|
| 115 | - Sqlite::$transaction_en_cours[$serveur] = false; |
|
| 100 | + /** |
|
| 101 | + * Termine une transaction |
|
| 102 | + * |
|
| 103 | + * @param string $serveur Nom de la connexion |
|
| 104 | + **/ |
|
| 105 | + public static function finir_transaction($serveur) { |
|
| 106 | + // si pas de transaction en cours, ne rien faire et le dire |
|
| 107 | + if ( |
|
| 108 | + !isset(Sqlite::$transaction_en_cours[$serveur]) |
|
| 109 | + || Sqlite::$transaction_en_cours[$serveur] == false |
|
| 110 | + ) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + // sinon fermer la transaction et retourner true |
|
| 114 | + Sqlite::executer_requete('COMMIT', $serveur); |
|
| 115 | + Sqlite::$transaction_en_cours[$serveur] = false; |
|
| 116 | 116 | |
| 117 | - return true; |
|
| 118 | - } |
|
| 117 | + return true; |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -6,10 +6,10 @@ |
||
| 6 | 6 | * Pouvoir retrouver le PDO utilisé pour générer un résultat de requête. |
| 7 | 7 | */ |
| 8 | 8 | final class PDOStatement extends \PDOStatement { |
| 9 | - private function __construct(private \PDO &$PDO) { |
|
| 10 | - } |
|
| 9 | + private function __construct(private \PDO &$PDO) { |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public function getPDO(): \PDO { |
|
| 13 | - return $this->PDO; |
|
| 14 | - } |
|
| 12 | + public function getPDO(): \PDO { |
|
| 13 | + return $this->PDO; |
|
| 14 | + } |
|
| 15 | 15 | } |
@@ -7,85 +7,85 @@ |
||
| 7 | 7 | **/ |
| 8 | 8 | class Idiome |
| 9 | 9 | { |
| 10 | - /** Type de noeud */ |
|
| 11 | - public string $type = 'idiome'; |
|
| 12 | - |
|
| 13 | - /** Clé de traduction demandée. Exemple 'item_oui' */ |
|
| 14 | - public string $nom_champ = ''; |
|
| 15 | - |
|
| 16 | - /** Module de langue où chercher la clé de traduction. Exemple 'medias' */ |
|
| 17 | - public string $module = ''; |
|
| 18 | - |
|
| 19 | - /** Arguments à passer à la chaîne */ |
|
| 20 | - public array $arg = []; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * Filtres à appliquer au résultat |
|
| 24 | - * |
|
| 25 | - * |
|
| 26 | - * * FIXME: type unique. |
|
| 27 | - * @var false|array |
|
| 28 | - * - false: erreur de syntaxe |
|
| 29 | - */ |
|
| 30 | - public $param = []; |
|
| 31 | - |
|
| 32 | - /** Source des filtres (compatibilité) (?) */ |
|
| 33 | - public array $fonctions = []; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Inutilisé, propriété générique de l'AST |
|
| 37 | - * |
|
| 38 | - * @var string|array |
|
| 39 | - */ |
|
| 40 | - public $avant = ''; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Inutilisé, propriété générique de l'AST |
|
| 44 | - * |
|
| 45 | - * @var string|array |
|
| 46 | - */ |
|
| 47 | - public $apres = ''; |
|
| 48 | - |
|
| 49 | - /** Identifiant de la boucle */ |
|
| 50 | - public string $id_boucle = ''; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * AST du squelette, liste de toutes les boucles |
|
| 54 | - * |
|
| 55 | - * @var Boucle[] |
|
| 56 | - */ |
|
| 57 | - public array $boucles; |
|
| 58 | - |
|
| 59 | - /** Alias de table d'application de la requête ou nom complet de la table SQL */ |
|
| 60 | - public ?string $type_requete = null; |
|
| 61 | - |
|
| 62 | - /** Résultat de la compilation: toujours une expression PHP */ |
|
| 63 | - public string $code = ''; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Interdire les scripts |
|
| 67 | - * |
|
| 68 | - * @see interdire_scripts() |
|
| 69 | - */ |
|
| 70 | - public bool $interdire_scripts = false; |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Description du squelette |
|
| 74 | - * |
|
| 75 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 76 | - * |
|
| 77 | - * Peut contenir les index : |
|
| 78 | - * - nom : Nom du fichier de cache |
|
| 79 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 80 | - * - sourcefile : Chemin du squelette |
|
| 81 | - * - squelette : Code du squelette |
|
| 82 | - * - id_mere : Identifiant de la boucle parente |
|
| 83 | - * - documents : Pour embed et img dans les textes |
|
| 84 | - * - session : Pour un cache sessionné par auteur |
|
| 85 | - * - niv : Niveau de tabulation |
|
| 86 | - */ |
|
| 87 | - public array $descr = []; |
|
| 88 | - |
|
| 89 | - /** Numéro de ligne dans le code source du squelette */ |
|
| 90 | - public int $ligne = 0; |
|
| 10 | + /** Type de noeud */ |
|
| 11 | + public string $type = 'idiome'; |
|
| 12 | + |
|
| 13 | + /** Clé de traduction demandée. Exemple 'item_oui' */ |
|
| 14 | + public string $nom_champ = ''; |
|
| 15 | + |
|
| 16 | + /** Module de langue où chercher la clé de traduction. Exemple 'medias' */ |
|
| 17 | + public string $module = ''; |
|
| 18 | + |
|
| 19 | + /** Arguments à passer à la chaîne */ |
|
| 20 | + public array $arg = []; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * Filtres à appliquer au résultat |
|
| 24 | + * |
|
| 25 | + * |
|
| 26 | + * * FIXME: type unique. |
|
| 27 | + * @var false|array |
|
| 28 | + * - false: erreur de syntaxe |
|
| 29 | + */ |
|
| 30 | + public $param = []; |
|
| 31 | + |
|
| 32 | + /** Source des filtres (compatibilité) (?) */ |
|
| 33 | + public array $fonctions = []; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Inutilisé, propriété générique de l'AST |
|
| 37 | + * |
|
| 38 | + * @var string|array |
|
| 39 | + */ |
|
| 40 | + public $avant = ''; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Inutilisé, propriété générique de l'AST |
|
| 44 | + * |
|
| 45 | + * @var string|array |
|
| 46 | + */ |
|
| 47 | + public $apres = ''; |
|
| 48 | + |
|
| 49 | + /** Identifiant de la boucle */ |
|
| 50 | + public string $id_boucle = ''; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * AST du squelette, liste de toutes les boucles |
|
| 54 | + * |
|
| 55 | + * @var Boucle[] |
|
| 56 | + */ |
|
| 57 | + public array $boucles; |
|
| 58 | + |
|
| 59 | + /** Alias de table d'application de la requête ou nom complet de la table SQL */ |
|
| 60 | + public ?string $type_requete = null; |
|
| 61 | + |
|
| 62 | + /** Résultat de la compilation: toujours une expression PHP */ |
|
| 63 | + public string $code = ''; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Interdire les scripts |
|
| 67 | + * |
|
| 68 | + * @see interdire_scripts() |
|
| 69 | + */ |
|
| 70 | + public bool $interdire_scripts = false; |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Description du squelette |
|
| 74 | + * |
|
| 75 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 76 | + * |
|
| 77 | + * Peut contenir les index : |
|
| 78 | + * - nom : Nom du fichier de cache |
|
| 79 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 80 | + * - sourcefile : Chemin du squelette |
|
| 81 | + * - squelette : Code du squelette |
|
| 82 | + * - id_mere : Identifiant de la boucle parente |
|
| 83 | + * - documents : Pour embed et img dans les textes |
|
| 84 | + * - session : Pour un cache sessionné par auteur |
|
| 85 | + * - niv : Niveau de tabulation |
|
| 86 | + */ |
|
| 87 | + public array $descr = []; |
|
| 88 | + |
|
| 89 | + /** Numéro de ligne dans le code source du squelette */ |
|
| 90 | + public int $ligne = 0; |
|
| 91 | 91 | } |
@@ -7,104 +7,104 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Champ |
| 9 | 9 | { |
| 10 | - /** Type de noeud */ |
|
| 11 | - public string $type = 'champ'; |
|
| 12 | - |
|
| 13 | - /** Nom du champ demandé. Exemple 'ID_ARTICLE' */ |
|
| 14 | - public ?string $nom_champ = null; |
|
| 15 | - |
|
| 16 | - /** Identifiant de la boucle parente si explicité */ |
|
| 17 | - public ?string $nom_boucle = ''; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Partie optionnelle avant |
|
| 21 | - * |
|
| 22 | - * @var null|string|array |
|
| 23 | - */ |
|
| 24 | - public $avant; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Partie optionnelle après |
|
| 28 | - * |
|
| 29 | - * @var null|string|array |
|
| 30 | - */ |
|
| 31 | - public $apres; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Étoiles : annuler des automatismes |
|
| 35 | - * |
|
| 36 | - * - '*' annule les filtres automatiques |
|
| 37 | - * - '**' annule en plus les protections de scripts |
|
| 38 | - * |
|
| 39 | - * FIXME: type unique. |
|
| 40 | - */ |
|
| 41 | - public ?string $etoile = ''; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Arguments et filtres explicites sur la balise |
|
| 45 | - * |
|
| 46 | - * - $param[0] contient les arguments de la balise |
|
| 47 | - * - $param[1..n] contient les filtres à appliquer à la balise |
|
| 48 | - * |
|
| 49 | - * FIXME: type unique. |
|
| 50 | - * @var false|array |
|
| 51 | - * - false: erreur de syntaxe |
|
| 52 | - */ |
|
| 53 | - public $param = []; |
|
| 54 | - |
|
| 55 | - /** Source des filtres (compatibilité) (?) */ |
|
| 56 | - public array $fonctions = []; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Identifiant de la boucle |
|
| 60 | - * |
|
| 61 | - * @var string |
|
| 62 | - */ |
|
| 63 | - public $id_boucle = ''; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * AST du squelette, liste de toutes les boucles |
|
| 67 | - * |
|
| 68 | - * @var Boucle[] |
|
| 69 | - */ |
|
| 70 | - public array $boucles; |
|
| 71 | - |
|
| 72 | - /** Alias de table d'application de la requête ou nom complet de la table SQL */ |
|
| 73 | - public ?string $type_requete = null; |
|
| 74 | - |
|
| 75 | - /** Résultat de la compilation: toujours une expression PHP */ |
|
| 76 | - public string $code = ''; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Interdire les scripts |
|
| 80 | - * |
|
| 81 | - * false si on est sûr de cette balise |
|
| 82 | - * |
|
| 83 | - * @see interdire_scripts() |
|
| 84 | - */ |
|
| 85 | - public bool $interdire_scripts = true; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Description du squelette |
|
| 89 | - * |
|
| 90 | - * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 91 | - * |
|
| 92 | - * Peut contenir les index : |
|
| 93 | - * |
|
| 94 | - * - nom : Nom du fichier de cache |
|
| 95 | - * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 96 | - * - sourcefile : Chemin du squelette |
|
| 97 | - * - squelette : Code du squelette |
|
| 98 | - * - id_mere : Identifiant de la boucle parente |
|
| 99 | - * - documents : Pour embed et img dans les textes |
|
| 100 | - * - session : Pour un cache sessionné par auteur |
|
| 101 | - * - niv : Niveau de tabulation |
|
| 102 | - */ |
|
| 103 | - public array $descr = []; |
|
| 104 | - |
|
| 105 | - /** Numéro de ligne dans le code source du squelette*/ |
|
| 106 | - public int $ligne = 0; |
|
| 107 | - |
|
| 108 | - /** Drapeau pour reperer les balises calculées par une fonction explicite */ |
|
| 109 | - public bool $balise_calculee = false; |
|
| 10 | + /** Type de noeud */ |
|
| 11 | + public string $type = 'champ'; |
|
| 12 | + |
|
| 13 | + /** Nom du champ demandé. Exemple 'ID_ARTICLE' */ |
|
| 14 | + public ?string $nom_champ = null; |
|
| 15 | + |
|
| 16 | + /** Identifiant de la boucle parente si explicité */ |
|
| 17 | + public ?string $nom_boucle = ''; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Partie optionnelle avant |
|
| 21 | + * |
|
| 22 | + * @var null|string|array |
|
| 23 | + */ |
|
| 24 | + public $avant; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Partie optionnelle après |
|
| 28 | + * |
|
| 29 | + * @var null|string|array |
|
| 30 | + */ |
|
| 31 | + public $apres; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Étoiles : annuler des automatismes |
|
| 35 | + * |
|
| 36 | + * - '*' annule les filtres automatiques |
|
| 37 | + * - '**' annule en plus les protections de scripts |
|
| 38 | + * |
|
| 39 | + * FIXME: type unique. |
|
| 40 | + */ |
|
| 41 | + public ?string $etoile = ''; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Arguments et filtres explicites sur la balise |
|
| 45 | + * |
|
| 46 | + * - $param[0] contient les arguments de la balise |
|
| 47 | + * - $param[1..n] contient les filtres à appliquer à la balise |
|
| 48 | + * |
|
| 49 | + * FIXME: type unique. |
|
| 50 | + * @var false|array |
|
| 51 | + * - false: erreur de syntaxe |
|
| 52 | + */ |
|
| 53 | + public $param = []; |
|
| 54 | + |
|
| 55 | + /** Source des filtres (compatibilité) (?) */ |
|
| 56 | + public array $fonctions = []; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Identifiant de la boucle |
|
| 60 | + * |
|
| 61 | + * @var string |
|
| 62 | + */ |
|
| 63 | + public $id_boucle = ''; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * AST du squelette, liste de toutes les boucles |
|
| 67 | + * |
|
| 68 | + * @var Boucle[] |
|
| 69 | + */ |
|
| 70 | + public array $boucles; |
|
| 71 | + |
|
| 72 | + /** Alias de table d'application de la requête ou nom complet de la table SQL */ |
|
| 73 | + public ?string $type_requete = null; |
|
| 74 | + |
|
| 75 | + /** Résultat de la compilation: toujours une expression PHP */ |
|
| 76 | + public string $code = ''; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Interdire les scripts |
|
| 80 | + * |
|
| 81 | + * false si on est sûr de cette balise |
|
| 82 | + * |
|
| 83 | + * @see interdire_scripts() |
|
| 84 | + */ |
|
| 85 | + public bool $interdire_scripts = true; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Description du squelette |
|
| 89 | + * |
|
| 90 | + * Sert pour la gestion d'erreur et la production de code dependant du contexte |
|
| 91 | + * |
|
| 92 | + * Peut contenir les index : |
|
| 93 | + * |
|
| 94 | + * - nom : Nom du fichier de cache |
|
| 95 | + * - gram : Nom de la grammaire du squelette (détermine le phraseur à utiliser) |
|
| 96 | + * - sourcefile : Chemin du squelette |
|
| 97 | + * - squelette : Code du squelette |
|
| 98 | + * - id_mere : Identifiant de la boucle parente |
|
| 99 | + * - documents : Pour embed et img dans les textes |
|
| 100 | + * - session : Pour un cache sessionné par auteur |
|
| 101 | + * - niv : Niveau de tabulation |
|
| 102 | + */ |
|
| 103 | + public array $descr = []; |
|
| 104 | + |
|
| 105 | + /** Numéro de ligne dans le code source du squelette*/ |
|
| 106 | + public int $ligne = 0; |
|
| 107 | + |
|
| 108 | + /** Drapeau pour reperer les balises calculées par une fonction explicite */ |
|
| 109 | + public bool $balise_calculee = false; |
|
| 110 | 110 | } |