@@ -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/actions'); |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * - ou tableau d'information sur le squelette. |
| 37 | 37 | */ |
| 38 | 38 | function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) { |
| 39 | - // compat avec anciens appels |
|
| 40 | - $objet = objet_type($objet); |
|
| 39 | + // compat avec anciens appels |
|
| 40 | + $objet = objet_type($objet); |
|
| 41 | 41 | |
| 42 | - return recuperer_fond( |
|
| 43 | - 'prive/objets/editer/logo', |
|
| 44 | - ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | - ); |
|
| 42 | + return recuperer_fond( |
|
| 43 | + 'prive/objets/editer/logo', |
|
| 44 | + ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | + ); |
|
| 46 | 46 | } |
@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | if (!defined('_AUTO_SELECTION_RUBRIQUE')) { |
| 17 | - define('_AUTO_SELECTION_RUBRIQUE', false); |
|
| 17 | + define('_AUTO_SELECTION_RUBRIQUE', false); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | |
@@ -28,39 +28,39 @@ discard block |
||
| 28 | 28 | * @return string |
| 29 | 29 | */ |
| 30 | 30 | function inc_preselectionner_parent_nouvel_objet_dist($objet, $row) { |
| 31 | - if (!_AUTO_SELECTION_RUBRIQUE) { |
|
| 32 | - return ''; |
|
| 33 | - } |
|
| 31 | + if (!_AUTO_SELECTION_RUBRIQUE) { |
|
| 32 | + return ''; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - if (!isset($row['id_rubrique'])) { |
|
| 36 | - return ''; |
|
| 37 | - } |
|
| 35 | + if (!isset($row['id_rubrique'])) { |
|
| 36 | + return ''; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - $id_rubrique = ''; |
|
| 40 | - if ($GLOBALS['connect_id_rubrique']) { |
|
| 41 | - // si admin restreint : sa rubrique |
|
| 42 | - $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 43 | - } elseif ( |
|
| 44 | - is_int(_AUTO_SELECTION_RUBRIQUE) |
|
| 45 | - and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 46 | - ) { |
|
| 47 | - $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
|
| 48 | - } else { |
|
| 49 | - // sinon la derniere rubrique cree |
|
| 50 | - $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1'); |
|
| 51 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 52 | - } |
|
| 53 | - // si le choix ne convient pas, on cherche dans un secteur |
|
| 54 | - if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 55 | - $id_rubrique = ''; |
|
| 56 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 57 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 58 | - while (!$id_rubrique and $row_rub = sql_fetch($res)) { |
|
| 59 | - if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 60 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } |
|
| 39 | + $id_rubrique = ''; |
|
| 40 | + if ($GLOBALS['connect_id_rubrique']) { |
|
| 41 | + // si admin restreint : sa rubrique |
|
| 42 | + $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
|
| 43 | + } elseif ( |
|
| 44 | + is_int(_AUTO_SELECTION_RUBRIQUE) |
|
| 45 | + and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 46 | + ) { |
|
| 47 | + $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
|
| 48 | + } else { |
|
| 49 | + // sinon la derniere rubrique cree |
|
| 50 | + $row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1'); |
|
| 51 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 52 | + } |
|
| 53 | + // si le choix ne convient pas, on cherche dans un secteur |
|
| 54 | + if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 55 | + $id_rubrique = ''; |
|
| 56 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 57 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 58 | + while (!$id_rubrique and $row_rub = sql_fetch($res)) { |
|
| 59 | + if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 60 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - return $id_rubrique; |
|
| 65 | + return $id_rubrique; |
|
| 66 | 66 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $id_rubrique = $GLOBALS['connect_id_rubrique'][0]; |
| 43 | 43 | } elseif ( |
| 44 | 44 | is_int(_AUTO_SELECTION_RUBRIQUE) |
| 45 | - and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 45 | + and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique='.intval(_AUTO_SELECTION_RUBRIQUE)) |
|
| 46 | 46 | ) { |
| 47 | 47 | $id_rubrique = _AUTO_SELECTION_RUBRIQUE; |
| 48 | 48 | } else { |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | $id_rubrique = $row_rub['id_rubrique']; |
| 52 | 52 | } |
| 53 | 53 | // si le choix ne convient pas, on cherche dans un secteur |
| 54 | - if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) { |
|
| 54 | + if (!autoriser('creer'.$objet.'dans', 'rubrique', $id_rubrique)) { |
|
| 55 | 55 | $id_rubrique = ''; |
| 56 | 56 | // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
| 57 | 57 | $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
| 58 | 58 | while (!$id_rubrique and $row_rub = sql_fetch($res)) { |
| 59 | - if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 59 | + if (autoriser('creer'.$objet.'dans', 'rubrique', $row_rub['id_rubrique'])) { |
|
| 60 | 60 | $id_rubrique = $row_rub['id_rubrique']; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -137,7 +137,7 @@ |
||
| 137 | 137 | $p !== false |
| 138 | 138 | and ($morceau = substr($txt, $d, $p - $d)) |
| 139 | 139 | and (($nopen += preg_match_all( |
| 140 | - '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 140 | + '{<'.preg_quote($closing_tag).'(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | 141 | $morceau, |
| 142 | 142 | $matches, |
| 143 | 143 | PREG_SET_ORDER |
@@ -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 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | * - false si l'arbre xml ne peut être créé ou est vide |
| 48 | 48 | **/ |
| 49 | 49 | function spip_xml_load($fichier, $strict = true, $clean = true, $taille_max = 1_048_576, $datas = '', $profondeur = -1) { |
| 50 | - $contenu = ''; |
|
| 51 | - if (tester_url_absolue($fichier)) { |
|
| 52 | - include_spip('inc/distant'); |
|
| 53 | - $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | - $contenu = $contenu['page'] ?? ''; |
|
| 55 | - } else { |
|
| 56 | - lire_fichier($fichier, $contenu); |
|
| 57 | - } |
|
| 58 | - $arbre = []; |
|
| 59 | - if ($contenu) { |
|
| 60 | - $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | - } |
|
| 50 | + $contenu = ''; |
|
| 51 | + if (tester_url_absolue($fichier)) { |
|
| 52 | + include_spip('inc/distant'); |
|
| 53 | + $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | + $contenu = $contenu['page'] ?? ''; |
|
| 55 | + } else { |
|
| 56 | + lire_fichier($fichier, $contenu); |
|
| 57 | + } |
|
| 58 | + $arbre = []; |
|
| 59 | + if ($contenu) { |
|
| 60 | + $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return count($arbre) ? $arbre : false; |
|
| 63 | + return count($arbre) ? $arbre : false; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!defined('_SPIP_XML_TAG_SPLIT')) { |
| 67 | - define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS'); |
|
| 67 | + define('_SPIP_XML_TAG_SPLIT', '{<([^:>][^>]*?)>}sS'); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -83,150 +83,150 @@ discard block |
||
| 83 | 83 | * - false si l'arbre xml ne peut être créé ou est vide |
| 84 | 84 | **/ |
| 85 | 85 | function spip_xml_parse(&$texte, $strict = true, $clean = true, $profondeur = -1) { |
| 86 | - $out = []; |
|
| 87 | - // enlever les commentaires |
|
| 88 | - $charset = 'AUTO'; |
|
| 89 | - if ($clean === true) { |
|
| 90 | - if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | - $charset = $regs[2]; |
|
| 92 | - } |
|
| 93 | - $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | - $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | - include_spip('inc/charsets'); |
|
| 96 | - $clean = $charset; |
|
| 97 | - //$texte = importer_charset($texte,$charset); |
|
| 98 | - } |
|
| 99 | - if (is_string($clean)) { |
|
| 100 | - $charset = $clean; |
|
| 101 | - } |
|
| 102 | - $txt = $texte; |
|
| 86 | + $out = []; |
|
| 87 | + // enlever les commentaires |
|
| 88 | + $charset = 'AUTO'; |
|
| 89 | + if ($clean === true) { |
|
| 90 | + if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | + $charset = $regs[2]; |
|
| 92 | + } |
|
| 93 | + $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | + $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | + include_spip('inc/charsets'); |
|
| 96 | + $clean = $charset; |
|
| 97 | + //$texte = importer_charset($texte,$charset); |
|
| 98 | + } |
|
| 99 | + if (is_string($clean)) { |
|
| 100 | + $charset = $clean; |
|
| 101 | + } |
|
| 102 | + $txt = $texte; |
|
| 103 | 103 | |
| 104 | - // tant qu'il y a des tags |
|
| 105 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | - while ((is_countable($chars) ? count($chars) : 0) >= 2) { |
|
| 107 | - // tag ouvrant |
|
| 108 | - //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 104 | + // tant qu'il y a des tags |
|
| 105 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | + while ((is_countable($chars) ? count($chars) : 0) >= 2) { |
|
| 107 | + // tag ouvrant |
|
| 108 | + //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 109 | 109 | |
| 110 | - // $before doit etre vide ou des espaces uniquements! |
|
| 111 | - $before = trim($chars[0]); |
|
| 110 | + // $before doit etre vide ou des espaces uniquements! |
|
| 111 | + $before = trim($chars[0]); |
|
| 112 | 112 | |
| 113 | - if (strlen($before) > 0) { |
|
| 114 | - return importer_charset($texte, $charset); |
|
| 115 | - }//$texte; // before non vide, donc on est dans du texte |
|
| 113 | + if (strlen($before) > 0) { |
|
| 114 | + return importer_charset($texte, $charset); |
|
| 115 | + }//$texte; // before non vide, donc on est dans du texte |
|
| 116 | 116 | |
| 117 | - $tag = rtrim($chars[1]); |
|
| 118 | - $txt = $chars[2]; |
|
| 117 | + $tag = rtrim($chars[1]); |
|
| 118 | + $txt = $chars[2]; |
|
| 119 | 119 | |
| 120 | - if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | - return importer_charset($texte, $charset); |
|
| 122 | - }//$texte; |
|
| 123 | - if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | - $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | - $out[$tag][] = ''; |
|
| 126 | - } else { |
|
| 127 | - $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | - $closing_tag = reset($closing_tag); |
|
| 129 | - // tag fermant |
|
| 130 | - $ncclos = strlen("</$closing_tag>"); |
|
| 131 | - $p = strpos($txt, (string) "</$closing_tag>"); |
|
| 132 | - if ($p !== false and (strpos($txt, '<') < $p)) { |
|
| 133 | - $nclose = 0; |
|
| 134 | - $nopen = 0; |
|
| 135 | - $d = 0; |
|
| 136 | - while ( |
|
| 137 | - $p !== false |
|
| 138 | - and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | - and (($nopen += preg_match_all( |
|
| 140 | - '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | - $morceau, |
|
| 142 | - $matches, |
|
| 143 | - PREG_SET_ORDER |
|
| 144 | - )) > $nclose) |
|
| 145 | - ) { |
|
| 146 | - $nclose++; |
|
| 147 | - $d = $p + $ncclos; |
|
| 148 | - $p = strpos($txt, (string) "</$closing_tag>", $d); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - if ($p === false) { |
|
| 152 | - if ($strict) { |
|
| 153 | - $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 120 | + if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | + return importer_charset($texte, $charset); |
|
| 122 | + }//$texte; |
|
| 123 | + if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | + $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | + $out[$tag][] = ''; |
|
| 126 | + } else { |
|
| 127 | + $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | + $closing_tag = reset($closing_tag); |
|
| 129 | + // tag fermant |
|
| 130 | + $ncclos = strlen("</$closing_tag>"); |
|
| 131 | + $p = strpos($txt, (string) "</$closing_tag>"); |
|
| 132 | + if ($p !== false and (strpos($txt, '<') < $p)) { |
|
| 133 | + $nclose = 0; |
|
| 134 | + $nopen = 0; |
|
| 135 | + $d = 0; |
|
| 136 | + while ( |
|
| 137 | + $p !== false |
|
| 138 | + and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | + and (($nopen += preg_match_all( |
|
| 140 | + '{<' . preg_quote($closing_tag) . '(\s*>|\s[^>]*[^/>]>)}is', |
|
| 141 | + $morceau, |
|
| 142 | + $matches, |
|
| 143 | + PREG_SET_ORDER |
|
| 144 | + )) > $nclose) |
|
| 145 | + ) { |
|
| 146 | + $nclose++; |
|
| 147 | + $d = $p + $ncclos; |
|
| 148 | + $p = strpos($txt, (string) "</$closing_tag>", $d); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + if ($p === false) { |
|
| 152 | + if ($strict) { |
|
| 153 | + $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 154 | 154 | |
| 155 | - return $out; |
|
| 156 | - } else { |
|
| 157 | - return importer_charset($texte, $charset); |
|
| 158 | - }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 159 | - } |
|
| 160 | - $content = substr($txt, 0, $p); |
|
| 161 | - $txt = substr($txt, $p + $ncclos); |
|
| 162 | - if ($profondeur == 0 or strpos($content, '<') === false) { // eviter une recursion si pas utile |
|
| 163 | - $out[$tag][] = importer_charset($content, $charset); |
|
| 164 | - }//$content; |
|
| 165 | - else { |
|
| 166 | - $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 167 | - } |
|
| 168 | - } |
|
| 169 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 170 | - } |
|
| 171 | - if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 172 | - return $out; |
|
| 173 | - } else { |
|
| 174 | - return importer_charset($texte, $charset); |
|
| 175 | - }//$texte; |
|
| 155 | + return $out; |
|
| 156 | + } else { |
|
| 157 | + return importer_charset($texte, $charset); |
|
| 158 | + }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 159 | + } |
|
| 160 | + $content = substr($txt, 0, $p); |
|
| 161 | + $txt = substr($txt, $p + $ncclos); |
|
| 162 | + if ($profondeur == 0 or strpos($content, '<') === false) { // eviter une recursion si pas utile |
|
| 163 | + $out[$tag][] = importer_charset($content, $charset); |
|
| 164 | + }//$content; |
|
| 165 | + else { |
|
| 166 | + $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 170 | + } |
|
| 171 | + if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 172 | + return $out; |
|
| 173 | + } else { |
|
| 174 | + return importer_charset($texte, $charset); |
|
| 175 | + }//$texte; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | function spip_xml_aplatit($arbre, $separateur = ' ') { |
| 179 | - $s = ''; |
|
| 180 | - if (is_array($arbre)) { |
|
| 181 | - foreach ($arbre as $tag => $feuille) { |
|
| 182 | - if (is_array($feuille)) { |
|
| 183 | - if ($tag !== intval($tag)) { |
|
| 184 | - $f = spip_xml_aplatit($feuille, $separateur); |
|
| 185 | - if (strlen($f)) { |
|
| 186 | - $tagf = explode(' ', $tag); |
|
| 187 | - $tagf = $tagf[0]; |
|
| 188 | - $s .= "<$tag>$f</$tagf>"; |
|
| 189 | - } else { |
|
| 190 | - $s .= "<$tag />"; |
|
| 191 | - } |
|
| 192 | - } else { |
|
| 193 | - $s .= spip_xml_aplatit($feuille); |
|
| 194 | - } |
|
| 195 | - $s .= $separateur; |
|
| 196 | - } else { |
|
| 197 | - $s .= "$feuille$separateur"; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 179 | + $s = ''; |
|
| 180 | + if (is_array($arbre)) { |
|
| 181 | + foreach ($arbre as $tag => $feuille) { |
|
| 182 | + if (is_array($feuille)) { |
|
| 183 | + if ($tag !== intval($tag)) { |
|
| 184 | + $f = spip_xml_aplatit($feuille, $separateur); |
|
| 185 | + if (strlen($f)) { |
|
| 186 | + $tagf = explode(' ', $tag); |
|
| 187 | + $tagf = $tagf[0]; |
|
| 188 | + $s .= "<$tag>$f</$tagf>"; |
|
| 189 | + } else { |
|
| 190 | + $s .= "<$tag />"; |
|
| 191 | + } |
|
| 192 | + } else { |
|
| 193 | + $s .= spip_xml_aplatit($feuille); |
|
| 194 | + } |
|
| 195 | + $s .= $separateur; |
|
| 196 | + } else { |
|
| 197 | + $s .= "$feuille$separateur"; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 202 | + return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | function spip_xml_tagname($tag) { |
| 206 | - if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 207 | - return $reg[1]; |
|
| 208 | - } |
|
| 206 | + if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 207 | + return $reg[1]; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - return ''; |
|
| 210 | + return ''; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | function spip_xml_decompose_tag($tag) { |
| 214 | - $tagname = spip_xml_tagname($tag); |
|
| 215 | - $liste = []; |
|
| 216 | - $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 217 | - $p = strpos($tag, '='); |
|
| 218 | - while ($p !== false) { |
|
| 219 | - $attr = trim(substr($tag, 0, $p)); |
|
| 220 | - $tag = ltrim(substr($tag, $p + 1)); |
|
| 221 | - $quote = $tag[0]; |
|
| 222 | - $p = strpos($tag, $quote, 1); |
|
| 223 | - $cont = substr($tag, 1, $p - 1); |
|
| 224 | - $liste[$attr] = $cont; |
|
| 225 | - $tag = substr($tag, $p + 1); |
|
| 226 | - $p = strpos($tag, '='); |
|
| 227 | - } |
|
| 214 | + $tagname = spip_xml_tagname($tag); |
|
| 215 | + $liste = []; |
|
| 216 | + $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 217 | + $p = strpos($tag, '='); |
|
| 218 | + while ($p !== false) { |
|
| 219 | + $attr = trim(substr($tag, 0, $p)); |
|
| 220 | + $tag = ltrim(substr($tag, $p + 1)); |
|
| 221 | + $quote = $tag[0]; |
|
| 222 | + $p = strpos($tag, $quote, 1); |
|
| 223 | + $cont = substr($tag, 1, $p - 1); |
|
| 224 | + $liste[$attr] = $cont; |
|
| 225 | + $tag = substr($tag, $p + 1); |
|
| 226 | + $p = strpos($tag, '='); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - return [$tagname, $liste]; |
|
| 229 | + return [$tagname, $liste]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -249,21 +249,21 @@ discard block |
||
| 249 | 249 | * false si aucun élément ne valide l'expression régulière, true sinon. |
| 250 | 250 | **/ |
| 251 | 251 | function spip_xml_match_nodes($regexp, &$arbre, &$matches, $init = true) { |
| 252 | - if ($init) { |
|
| 253 | - $matches = []; |
|
| 254 | - } |
|
| 255 | - if (is_array($arbre) && count($arbre)) { |
|
| 256 | - foreach (array_keys($arbre) as $tag) { |
|
| 257 | - if (preg_match($regexp, $tag)) { |
|
| 258 | - $matches[$tag] = &$arbre[$tag]; |
|
| 259 | - } |
|
| 260 | - if (is_array($arbre[$tag])) { |
|
| 261 | - foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 262 | - spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - } |
|
| 252 | + if ($init) { |
|
| 253 | + $matches = []; |
|
| 254 | + } |
|
| 255 | + if (is_array($arbre) && count($arbre)) { |
|
| 256 | + foreach (array_keys($arbre) as $tag) { |
|
| 257 | + if (preg_match($regexp, $tag)) { |
|
| 258 | + $matches[$tag] = &$arbre[$tag]; |
|
| 259 | + } |
|
| 260 | + if (is_array($arbre[$tag])) { |
|
| 261 | + foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 262 | + spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - return (is_countable($matches) ? count($matches) : 0); |
|
| 268 | + return (is_countable($matches) ? count($matches) : 0); |
|
| 269 | 269 | } |
@@ -335,8 +335,7 @@ |
||
| 335 | 335 | if (!autoriser('modifier', $type, intval($id))) { |
| 336 | 336 | $valeurs['editable'] = ''; |
| 337 | 337 | } |
| 338 | - } |
|
| 339 | - else { |
|
| 338 | + } else { |
|
| 340 | 339 | if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
| 341 | 340 | $valeurs['editable'] = ''; |
| 342 | 341 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $res['message_ok'] = _T('info_modification_enregistree'); |
| 101 | 101 | if ($retour) { |
| 102 | 102 | if (strncmp($retour, 'javascript:', 11) == 0) { |
| 103 | - $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 103 | + $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/'.substr($retour, 11).'/*]]>*/</script>'; |
|
| 104 | 104 | $res['editable'] = true; |
| 105 | 105 | } else { |
| 106 | 106 | $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | if (!isset($erreurs[$champ])) { |
| 141 | 141 | $erreurs[$champ] = ''; |
| 142 | 142 | } |
| 143 | - $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 143 | + $erreurs[$champ] .= _T('alerte_modif_info_concourante')."<br /><textarea readonly='readonly' class='forml'>".entites_html($conflit['base']).'</textarea>'; |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | if ( |
| 219 | 219 | $config_fonc |
| 220 | 220 | and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
| 221 | - and $config_fonc !== $table_objet . '_edit_config' |
|
| 221 | + and $config_fonc !== $table_objet.'_edit_config' |
|
| 222 | 222 | ) { |
| 223 | 223 | if ( |
| 224 | 224 | $args = test_formulaire_inclus_par_modele() |
@@ -233,12 +233,12 @@ discard block |
||
| 233 | 233 | // Appel direct dans un squelette |
| 234 | 234 | if (!$row) { |
| 235 | 235 | if (!$new or $lier_trad) { |
| 236 | - if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 236 | + if ($select = charger_fonction('precharger_'.$type, 'inc', true)) { |
|
| 237 | 237 | $row = $select($id, $id_parent, $lier_trad); |
| 238 | 238 | // si on a une fonction precharger, elle pu faire un reglage de langue |
| 239 | 239 | $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
| 240 | 240 | } else { |
| 241 | - $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 241 | + $row = sql_fetsel('*', $table_objet_sql, $id_table_objet.'='.intval($id)); |
|
| 242 | 242 | } |
| 243 | 243 | if (!$new) { |
| 244 | 244 | $md5 = controles_md5($row ?? []); |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | if ($config_fonc) { |
| 289 | 289 | $contexte['config'] = $config = $config_fonc($contexte); |
| 290 | 290 | if (!$lang_default) { |
| 291 | - $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 291 | + $lang_default = $config['langue'] ?? session_get('lang'); |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | $config = $config + [ |
@@ -312,13 +312,12 @@ discard block |
||
| 312 | 312 | unset($contexte['lang']); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 316 | - (!$lier_trad ? '' : |
|
| 317 | - ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 318 | - $lier_trad . |
|
| 319 | - "' />" . |
|
| 320 | - "\n<input type='hidden' name='changer_lang' value='" . |
|
| 321 | - $lang_default . |
|
| 315 | + $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n". |
|
| 316 | + (!$lier_trad ? '' : ("\n<input type='hidden' name='lier_trad' value='". |
|
| 317 | + $lier_trad. |
|
| 318 | + "' />". |
|
| 319 | + "\n<input type='hidden' name='changer_lang' value='". |
|
| 320 | + $lang_default. |
|
| 322 | 321 | "' />")) |
| 323 | 322 | . $hidden |
| 324 | 323 | . ($md5 ?? ''); |
@@ -358,14 +357,14 @@ discard block |
||
| 358 | 357 | $aider = charger_fonction('aider', 'inc'); |
| 359 | 358 | if (strlen($texte) > 28 * 1024) { |
| 360 | 359 | $texte = str_replace("\r\n", "\n", $texte); |
| 361 | - $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 360 | + $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 362 | 361 | if ($pos > 0 and $pos < 32 * 1024) { |
| 363 | - $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 362 | + $debut = substr($texte, 0, $pos)."\n\n<!--SPIP-->\n"; |
|
| 364 | 363 | $suite = substr($texte, $pos + 2); |
| 365 | 364 | } else { |
| 366 | - $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 365 | + $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 367 | 366 | if (!($pos > 0 and $pos < 32 * 1024)) { |
| 368 | - $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 367 | + $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 369 | 368 | $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
| 370 | 369 | } else { |
| 371 | 370 | $decalage = 1; |
@@ -396,13 +395,13 @@ discard block |
||
| 396 | 395 | } |
| 397 | 396 | |
| 398 | 397 | include_spip('inc/barre'); |
| 399 | - $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 398 | + $textes_supplement = "<br /><span style='color: red'>"._T('info_texte_long')."</span>\n"; |
|
| 400 | 399 | $nombre = 0; |
| 401 | 400 | |
| 402 | 401 | while (strlen($texte) > 29 * 1024) { |
| 403 | 402 | $nombre++; |
| 404 | 403 | [$texte1, $texte] = coupe_trop_long($texte); |
| 405 | - $textes_supplement .= '<br />' . |
|
| 404 | + $textes_supplement .= '<br />'. |
|
| 406 | 405 | "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
| 407 | 406 | } |
| 408 | 407 | |
@@ -485,7 +484,7 @@ discard block |
||
| 485 | 484 | $ctr = []; |
| 486 | 485 | foreach ($data as $key => $val) { |
| 487 | 486 | $m = md5($val ?? ''); |
| 488 | - $k = $prefixe . $key; |
|
| 487 | + $k = $prefixe.$key; |
|
| 489 | 488 | |
| 490 | 489 | switch ($format) { |
| 491 | 490 | case 'html': |
@@ -498,7 +497,7 @@ discard block |
||
| 498 | 497 | } |
| 499 | 498 | |
| 500 | 499 | if ($format === 'html') { |
| 501 | - return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 500 | + return "\n\n<!-- controles md5 -->\n".join("\n", $ctr)."\n\n"; |
|
| 502 | 501 | } else { |
| 503 | 502 | return $ctr; |
| 504 | 503 | } |
@@ -650,7 +649,7 @@ discard block |
||
| 650 | 649 | // On elimine les donnees non modifiees par le formulaire (mais |
| 651 | 650 | // potentiellement modifiees entre temps par un autre utilisateur) |
| 652 | 651 | foreach ($champs as $key => $val) { |
| 653 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 652 | + if (isset($ctr[$prefix.$key]) and $m = $ctr[$prefix.$key]) { |
|
| 654 | 653 | if (is_scalar($val) and $m == md5($val)) { |
| 655 | 654 | unset($champs[$key]); |
| 656 | 655 | } |
@@ -679,7 +678,7 @@ discard block |
||
| 679 | 678 | // de conflit. |
| 680 | 679 | $ctrh = $ctrq = $conflits = []; |
| 681 | 680 | foreach (array_keys($champs) as $key) { |
| 682 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 681 | + if (isset($ctr[$prefix.$key]) and $m = $ctr[$prefix.$key]) { |
|
| 683 | 682 | $ctrh[$key] = $m; |
| 684 | 683 | $ctrq[] = $key; |
| 685 | 684 | } |
@@ -713,9 +712,9 @@ discard block |
||
| 713 | 712 | */ |
| 714 | 713 | function display_conflit_champ($x) { |
| 715 | 714 | if (strstr($x, "\n") or strlen($x) > 80) { |
| 716 | - return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 715 | + return "<textarea style='width:99%; height:10em;'>".entites_html($x)."</textarea>\n"; |
|
| 717 | 716 | } else { |
| 718 | - return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 717 | + return "<input type='text' size='40' style='width:99%' value=\"".entites_html($x)."\" />\n"; |
|
| 719 | 718 | } |
| 720 | 719 | } |
| 721 | 720 | |
@@ -755,11 +754,11 @@ discard block |
||
| 755 | 754 | ) : $champ; |
| 756 | 755 | |
| 757 | 756 | $diffs[] = "<h2>$titre</h2>\n" |
| 758 | - . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 759 | - . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 760 | - . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 757 | + . '<h3>'._T('info_conflit_edition_differences')."</h3>\n" |
|
| 758 | + . "<div style='max-height:8em; overflow: auto; width:99%;'>".$d."</div>\n" |
|
| 759 | + . '<h4>'._T('info_conflit_edition_votre_version').'</h4>' |
|
| 761 | 760 | . display_conflit_champ($a['post']) |
| 762 | - . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 761 | + . '<h4>'._T('info_conflit_edition_version_enregistree').'</h4>' |
|
| 763 | 762 | . display_conflit_champ($base); |
| 764 | 763 | } |
| 765 | 764 | |
@@ -767,16 +766,16 @@ discard block |
||
| 767 | 766 | $id = uniqid(random_int(0, mt_getrandmax())); |
| 768 | 767 | $redirect = "<form action='$redirect' method='get' |
| 769 | 768 | id='$id' |
| 770 | - style='float:" . $GLOBALS['spip_lang_right'] . "; margin-top:2em;'>\n" |
|
| 769 | + style='float:".$GLOBALS['spip_lang_right']."; margin-top:2em;'>\n" |
|
| 771 | 770 | . form_hidden($redirect) |
| 772 | - . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 771 | + . "<input type='submit' value='"._T('icone_retour')."' /> |
|
| 773 | 772 | </form>\n"; |
| 774 | 773 | |
| 775 | 774 | // pour les documents, on est probablement en ajax : il faut ajaxer |
| 776 | 775 | if (_AJAX) { |
| 777 | 776 | $redirect .= '<script type="text/javascript">' |
| 778 | - . 'setTimeout(function(){$("#' . $id . '") |
|
| 779 | - .ajaxForm({target:$("#' . $id . '").parent()}); |
|
| 777 | + . 'setTimeout(function(){$("#'.$id.'") |
|
| 778 | + .ajaxForm({target:$("#' . $id.'").parent()}); |
|
| 780 | 779 | }, 200);' |
| 781 | 780 | . "</script>\n"; |
| 782 | 781 | } |
@@ -795,9 +794,9 @@ discard block |
||
| 795 | 794 | .diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; } |
| 796 | 795 | .diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; } |
| 797 | 796 | </style>' |
| 798 | - . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 799 | - . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 800 | - . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 797 | + . '<p>'._T('info_conflit_edition_avis_non_sauvegarde').'</p>' |
|
| 798 | + . '<p>'._T('texte_conflit_edition_correction').'</p>' |
|
| 799 | + . "<div style='text-align:".$GLOBALS['spip_lang_left'].";'>" |
|
| 801 | 800 | . join("\n", $diffs) |
| 802 | 801 | . "</div>\n" |
| 803 | 802 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | include_spip('base/abstract_sql'); |
| 23 | 23 | |
@@ -59,56 +59,56 @@ discard block |
||
| 59 | 59 | * Retour des traitements. |
| 60 | 60 | **/ |
| 61 | 61 | function formulaires_editer_objet_traiter( |
| 62 | - $type, |
|
| 63 | - $id = 'new', |
|
| 64 | - $id_parent = 0, |
|
| 65 | - $lier_trad = 0, |
|
| 66 | - $retour = '', |
|
| 67 | - $config_fonc = 'articles_edit_config', |
|
| 68 | - $row = [], |
|
| 69 | - $hidden = '' |
|
| 62 | + $type, |
|
| 63 | + $id = 'new', |
|
| 64 | + $id_parent = 0, |
|
| 65 | + $lier_trad = 0, |
|
| 66 | + $retour = '', |
|
| 67 | + $config_fonc = 'articles_edit_config', |
|
| 68 | + $row = [], |
|
| 69 | + $hidden = '' |
|
| 70 | 70 | ) { |
| 71 | 71 | |
| 72 | - $res = []; |
|
| 73 | - // eviter la redirection forcee par l'action... |
|
| 74 | - set_request('redirect'); |
|
| 75 | - if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | - [$id, $err] = $action_editer($id); |
|
| 77 | - } else { |
|
| 78 | - $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | - [$id, $err] = $action_editer($id, $type); |
|
| 80 | - } |
|
| 81 | - $id_table_objet = id_table_objet($type); |
|
| 82 | - $res[$id_table_objet] = $id; |
|
| 83 | - if ($err or !$id) { |
|
| 84 | - $res['message_erreur'] = ($err ?: _T('erreur')); |
|
| 85 | - } else { |
|
| 86 | - // Un lien de trad a prendre en compte |
|
| 87 | - if ($lier_trad) { |
|
| 88 | - // referencer la traduction |
|
| 89 | - $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 90 | - $referencer_traduction($type, $id, $lier_trad); |
|
| 91 | - // actions de recopie de champs / liens sur le nouvel objet créé |
|
| 92 | - $completer_traduction = charger_fonction('completer_traduction', 'inc'); |
|
| 93 | - $err = $completer_traduction($type, $id, $lier_trad); |
|
| 94 | - if ($err) { |
|
| 95 | - $res['message_erreur'] = $err; |
|
| 96 | - return $res; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $res['message_ok'] = _T('info_modification_enregistree'); |
|
| 101 | - if ($retour) { |
|
| 102 | - if (strncmp($retour, 'javascript:', 11) == 0) { |
|
| 103 | - $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 104 | - $res['editable'] = true; |
|
| 105 | - } else { |
|
| 106 | - $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return $res; |
|
| 72 | + $res = []; |
|
| 73 | + // eviter la redirection forcee par l'action... |
|
| 74 | + set_request('redirect'); |
|
| 75 | + if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | + [$id, $err] = $action_editer($id); |
|
| 77 | + } else { |
|
| 78 | + $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | + [$id, $err] = $action_editer($id, $type); |
|
| 80 | + } |
|
| 81 | + $id_table_objet = id_table_objet($type); |
|
| 82 | + $res[$id_table_objet] = $id; |
|
| 83 | + if ($err or !$id) { |
|
| 84 | + $res['message_erreur'] = ($err ?: _T('erreur')); |
|
| 85 | + } else { |
|
| 86 | + // Un lien de trad a prendre en compte |
|
| 87 | + if ($lier_trad) { |
|
| 88 | + // referencer la traduction |
|
| 89 | + $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 90 | + $referencer_traduction($type, $id, $lier_trad); |
|
| 91 | + // actions de recopie de champs / liens sur le nouvel objet créé |
|
| 92 | + $completer_traduction = charger_fonction('completer_traduction', 'inc'); |
|
| 93 | + $err = $completer_traduction($type, $id, $lier_trad); |
|
| 94 | + if ($err) { |
|
| 95 | + $res['message_erreur'] = $err; |
|
| 96 | + return $res; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $res['message_ok'] = _T('info_modification_enregistree'); |
|
| 101 | + if ($retour) { |
|
| 102 | + if (strncmp($retour, 'javascript:', 11) == 0) { |
|
| 103 | + $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 104 | + $res['editable'] = true; |
|
| 105 | + } else { |
|
| 106 | + $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + return $res; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -132,29 +132,29 @@ discard block |
||
| 132 | 132 | * Tableau des erreurs |
| 133 | 133 | **/ |
| 134 | 134 | function formulaires_editer_objet_verifier($type, $id = 'new', $oblis = []) { |
| 135 | - $erreurs = []; |
|
| 136 | - if (intval($id)) { |
|
| 137 | - $conflits = controler_contenu($type, $id); |
|
| 138 | - if ($conflits and is_countable($conflits) ? count($conflits) : 0) { |
|
| 139 | - foreach ($conflits as $champ => $conflit) { |
|
| 140 | - if (!isset($erreurs[$champ])) { |
|
| 141 | - $erreurs[$champ] = ''; |
|
| 142 | - } |
|
| 143 | - $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - foreach ($oblis as $obli) { |
|
| 148 | - $value = _request($obli); |
|
| 149 | - if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) { |
|
| 150 | - if (!isset($erreurs[$obli])) { |
|
| 151 | - $erreurs[$obli] = ''; |
|
| 152 | - } |
|
| 153 | - $erreurs[$obli] .= _T('info_obligatoire'); |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return $erreurs; |
|
| 135 | + $erreurs = []; |
|
| 136 | + if (intval($id)) { |
|
| 137 | + $conflits = controler_contenu($type, $id); |
|
| 138 | + if ($conflits and is_countable($conflits) ? count($conflits) : 0) { |
|
| 139 | + foreach ($conflits as $champ => $conflit) { |
|
| 140 | + if (!isset($erreurs[$champ])) { |
|
| 141 | + $erreurs[$champ] = ''; |
|
| 142 | + } |
|
| 143 | + $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + foreach ($oblis as $obli) { |
|
| 148 | + $value = _request($obli); |
|
| 149 | + if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) { |
|
| 150 | + if (!isset($erreurs[$obli])) { |
|
| 151 | + $erreurs[$obli] = ''; |
|
| 152 | + } |
|
| 153 | + $erreurs[$obli] .= _T('info_obligatoire'); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return $erreurs; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -199,155 +199,155 @@ discard block |
||
| 199 | 199 | * Environnement du formulaire. |
| 200 | 200 | **/ |
| 201 | 201 | function formulaires_editer_objet_charger( |
| 202 | - $type, |
|
| 203 | - $id = 'new', |
|
| 204 | - $id_parent = 0, |
|
| 205 | - $lier_trad = 0, |
|
| 206 | - $retour = '', |
|
| 207 | - $config_fonc = 'articles_edit_config', |
|
| 208 | - $row = [], |
|
| 209 | - $hidden = '' |
|
| 202 | + $type, |
|
| 203 | + $id = 'new', |
|
| 204 | + $id_parent = 0, |
|
| 205 | + $lier_trad = 0, |
|
| 206 | + $retour = '', |
|
| 207 | + $config_fonc = 'articles_edit_config', |
|
| 208 | + $row = [], |
|
| 209 | + $hidden = '' |
|
| 210 | 210 | ) { |
| 211 | 211 | |
| 212 | - $valeurs = []; |
|
| 213 | - $table_objet = table_objet($type); |
|
| 214 | - $table_objet_sql = table_objet_sql($type); |
|
| 215 | - $id_table_objet = id_table_objet($type); |
|
| 216 | - if (!is_array($row)) { |
|
| 217 | - $row = []; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 221 | - if ( |
|
| 222 | - $config_fonc |
|
| 223 | - and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 224 | - and $config_fonc !== $table_objet . '_edit_config' |
|
| 225 | - ) { |
|
| 226 | - if ( |
|
| 227 | - $args = test_formulaire_inclus_par_modele() |
|
| 228 | - and in_array($config_fonc, $args) |
|
| 229 | - ) { |
|
| 230 | - $config_fonc = ''; |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - $new = !is_numeric($id); |
|
| 235 | - $lang_default = ''; |
|
| 236 | - // Appel direct dans un squelette |
|
| 237 | - if (!$row) { |
|
| 238 | - if (!$new or $lier_trad) { |
|
| 239 | - if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 240 | - $row = $select($id, $id_parent, $lier_trad); |
|
| 241 | - // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 242 | - $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 243 | - } else { |
|
| 244 | - $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 245 | - } |
|
| 246 | - if (!$new) { |
|
| 247 | - $md5 = controles_md5($row ?? []); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - if (!$row) { |
|
| 251 | - $row = []; |
|
| 252 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 253 | - if ($desc = $trouver_table($table_objet)) { |
|
| 254 | - foreach ($desc['field'] as $k => $v) { |
|
| 255 | - $row[$k] = ''; |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 262 | - // (et donc: pas de lien de traduction) |
|
| 263 | - $id = ($new or $lier_trad) |
|
| 264 | - ? 'oui' |
|
| 265 | - : $row[$id_table_objet]; |
|
| 266 | - $row[$id_table_objet] = $id; |
|
| 267 | - |
|
| 268 | - $contexte = $row; |
|
| 269 | - if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 270 | - if (!isset($contexte['id_parent'])) { |
|
| 271 | - unset($contexte['id_rubrique']); |
|
| 272 | - } |
|
| 273 | - $contexte['id_parent'] = $id_parent; |
|
| 274 | - } elseif (!isset($contexte['id_parent'])) { |
|
| 275 | - // id_rubrique dans id_parent si possible |
|
| 276 | - if (isset($contexte['id_rubrique'])) { |
|
| 277 | - $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 278 | - unset($contexte['id_rubrique']); |
|
| 279 | - } else { |
|
| 280 | - $contexte['id_parent'] = ''; |
|
| 281 | - } |
|
| 282 | - if ( |
|
| 283 | - !$contexte['id_parent'] |
|
| 284 | - and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 285 | - ) { |
|
| 286 | - $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - $config = []; |
|
| 291 | - if ($config_fonc) { |
|
| 292 | - $contexte['config'] = $config = $config_fonc($contexte); |
|
| 293 | - if (!$lang_default) { |
|
| 294 | - $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - $config = $config + [ |
|
| 298 | - 'lignes' => 0, |
|
| 299 | - 'langue' => '', |
|
| 300 | - ]; |
|
| 301 | - |
|
| 302 | - $att_text = " class='textarea' " |
|
| 303 | - . " rows='" |
|
| 304 | - . ($config['lignes'] + 15) |
|
| 305 | - . "' cols='40'"; |
|
| 306 | - if (isset($contexte['texte'])) { |
|
| 307 | - [$contexte['texte'], $contexte['_texte_trop_long']] = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - // on veut conserver la langue de l'interface ; |
|
| 311 | - // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 312 | - // voudrait l'exploiter |
|
| 313 | - if (isset($contexte['lang'])) { |
|
| 314 | - $contexte['langue'] = $contexte['lang']; |
|
| 315 | - unset($contexte['lang']); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 319 | - (!$lier_trad ? '' : |
|
| 320 | - ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 321 | - $lier_trad . |
|
| 322 | - "' />" . |
|
| 323 | - "\n<input type='hidden' name='changer_lang' value='" . |
|
| 324 | - $lang_default . |
|
| 325 | - "' />")) |
|
| 326 | - . $hidden |
|
| 327 | - . ($md5 ?? ''); |
|
| 328 | - |
|
| 329 | - // preciser que le formulaire doit passer dans un pipeline |
|
| 330 | - $contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]]; |
|
| 331 | - |
|
| 332 | - // preciser que le formulaire doit etre securise auteur/action |
|
| 333 | - // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 334 | - // on le garde pour compat |
|
| 335 | - $contexte['_action'] = ["editer_$type", $id]; |
|
| 336 | - |
|
| 337 | - // et in fine placer l'autorisation |
|
| 338 | - include_spip('inc/autoriser'); |
|
| 339 | - if (intval($id)) { |
|
| 340 | - if (!autoriser('modifier', $type, intval($id))) { |
|
| 341 | - $valeurs['editable'] = ''; |
|
| 342 | - } |
|
| 343 | - } |
|
| 344 | - else { |
|
| 345 | - if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
|
| 346 | - $valeurs['editable'] = ''; |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - return $contexte; |
|
| 212 | + $valeurs = []; |
|
| 213 | + $table_objet = table_objet($type); |
|
| 214 | + $table_objet_sql = table_objet_sql($type); |
|
| 215 | + $id_table_objet = id_table_objet($type); |
|
| 216 | + if (!is_array($row)) { |
|
| 217 | + $row = []; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 221 | + if ( |
|
| 222 | + $config_fonc |
|
| 223 | + and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 224 | + and $config_fonc !== $table_objet . '_edit_config' |
|
| 225 | + ) { |
|
| 226 | + if ( |
|
| 227 | + $args = test_formulaire_inclus_par_modele() |
|
| 228 | + and in_array($config_fonc, $args) |
|
| 229 | + ) { |
|
| 230 | + $config_fonc = ''; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + $new = !is_numeric($id); |
|
| 235 | + $lang_default = ''; |
|
| 236 | + // Appel direct dans un squelette |
|
| 237 | + if (!$row) { |
|
| 238 | + if (!$new or $lier_trad) { |
|
| 239 | + if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 240 | + $row = $select($id, $id_parent, $lier_trad); |
|
| 241 | + // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 242 | + $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 243 | + } else { |
|
| 244 | + $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 245 | + } |
|
| 246 | + if (!$new) { |
|
| 247 | + $md5 = controles_md5($row ?? []); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + if (!$row) { |
|
| 251 | + $row = []; |
|
| 252 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 253 | + if ($desc = $trouver_table($table_objet)) { |
|
| 254 | + foreach ($desc['field'] as $k => $v) { |
|
| 255 | + $row[$k] = ''; |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 262 | + // (et donc: pas de lien de traduction) |
|
| 263 | + $id = ($new or $lier_trad) |
|
| 264 | + ? 'oui' |
|
| 265 | + : $row[$id_table_objet]; |
|
| 266 | + $row[$id_table_objet] = $id; |
|
| 267 | + |
|
| 268 | + $contexte = $row; |
|
| 269 | + if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 270 | + if (!isset($contexte['id_parent'])) { |
|
| 271 | + unset($contexte['id_rubrique']); |
|
| 272 | + } |
|
| 273 | + $contexte['id_parent'] = $id_parent; |
|
| 274 | + } elseif (!isset($contexte['id_parent'])) { |
|
| 275 | + // id_rubrique dans id_parent si possible |
|
| 276 | + if (isset($contexte['id_rubrique'])) { |
|
| 277 | + $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 278 | + unset($contexte['id_rubrique']); |
|
| 279 | + } else { |
|
| 280 | + $contexte['id_parent'] = ''; |
|
| 281 | + } |
|
| 282 | + if ( |
|
| 283 | + !$contexte['id_parent'] |
|
| 284 | + and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 285 | + ) { |
|
| 286 | + $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + $config = []; |
|
| 291 | + if ($config_fonc) { |
|
| 292 | + $contexte['config'] = $config = $config_fonc($contexte); |
|
| 293 | + if (!$lang_default) { |
|
| 294 | + $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + $config = $config + [ |
|
| 298 | + 'lignes' => 0, |
|
| 299 | + 'langue' => '', |
|
| 300 | + ]; |
|
| 301 | + |
|
| 302 | + $att_text = " class='textarea' " |
|
| 303 | + . " rows='" |
|
| 304 | + . ($config['lignes'] + 15) |
|
| 305 | + . "' cols='40'"; |
|
| 306 | + if (isset($contexte['texte'])) { |
|
| 307 | + [$contexte['texte'], $contexte['_texte_trop_long']] = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + // on veut conserver la langue de l'interface ; |
|
| 311 | + // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 312 | + // voudrait l'exploiter |
|
| 313 | + if (isset($contexte['lang'])) { |
|
| 314 | + $contexte['langue'] = $contexte['lang']; |
|
| 315 | + unset($contexte['lang']); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 319 | + (!$lier_trad ? '' : |
|
| 320 | + ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 321 | + $lier_trad . |
|
| 322 | + "' />" . |
|
| 323 | + "\n<input type='hidden' name='changer_lang' value='" . |
|
| 324 | + $lang_default . |
|
| 325 | + "' />")) |
|
| 326 | + . $hidden |
|
| 327 | + . ($md5 ?? ''); |
|
| 328 | + |
|
| 329 | + // preciser que le formulaire doit passer dans un pipeline |
|
| 330 | + $contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]]; |
|
| 331 | + |
|
| 332 | + // preciser que le formulaire doit etre securise auteur/action |
|
| 333 | + // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 334 | + // on le garde pour compat |
|
| 335 | + $contexte['_action'] = ["editer_$type", $id]; |
|
| 336 | + |
|
| 337 | + // et in fine placer l'autorisation |
|
| 338 | + include_spip('inc/autoriser'); |
|
| 339 | + if (intval($id)) { |
|
| 340 | + if (!autoriser('modifier', $type, intval($id))) { |
|
| 341 | + $valeurs['editable'] = ''; |
|
| 342 | + } |
|
| 343 | + } |
|
| 344 | + else { |
|
| 345 | + if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
|
| 346 | + $valeurs['editable'] = ''; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + return $contexte; |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | /** |
@@ -358,29 +358,29 @@ discard block |
||
| 358 | 358 | * @return array |
| 359 | 359 | */ |
| 360 | 360 | function coupe_trop_long($texte) { |
| 361 | - $aider = charger_fonction('aider', 'inc'); |
|
| 362 | - if (strlen($texte) > 28 * 1024) { |
|
| 363 | - $texte = str_replace("\r\n", "\n", $texte); |
|
| 364 | - $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 365 | - if ($pos > 0 and $pos < 32 * 1024) { |
|
| 366 | - $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 367 | - $suite = substr($texte, $pos + 2); |
|
| 368 | - } else { |
|
| 369 | - $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 370 | - if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 371 | - $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 372 | - $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 373 | - } else { |
|
| 374 | - $decalage = 1; |
|
| 375 | - } |
|
| 376 | - $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 377 | - $suite = substr($texte, $pos + $decalage); |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - return ([$debut, $suite]); |
|
| 381 | - } else { |
|
| 382 | - return ([$texte, '']); |
|
| 383 | - } |
|
| 361 | + $aider = charger_fonction('aider', 'inc'); |
|
| 362 | + if (strlen($texte) > 28 * 1024) { |
|
| 363 | + $texte = str_replace("\r\n", "\n", $texte); |
|
| 364 | + $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 365 | + if ($pos > 0 and $pos < 32 * 1024) { |
|
| 366 | + $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 367 | + $suite = substr($texte, $pos + 2); |
|
| 368 | + } else { |
|
| 369 | + $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 370 | + if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 371 | + $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 372 | + $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 373 | + } else { |
|
| 374 | + $decalage = 1; |
|
| 375 | + } |
|
| 376 | + $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 377 | + $suite = substr($texte, $pos + $decalage); |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + return ([$debut, $suite]); |
|
| 381 | + } else { |
|
| 382 | + return ([$texte, '']); |
|
| 383 | + } |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -391,25 +391,25 @@ discard block |
||
| 391 | 391 | * @return array |
| 392 | 392 | */ |
| 393 | 393 | function editer_texte_recolle($texte, $att_text) { |
| 394 | - if ( |
|
| 395 | - (strlen($texte) < 29 * 1024) |
|
| 396 | - or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 397 | - ) { |
|
| 398 | - return [$texte, '']; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - include_spip('inc/barre'); |
|
| 402 | - $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 403 | - $nombre = 0; |
|
| 404 | - |
|
| 405 | - while (strlen($texte) > 29 * 1024) { |
|
| 406 | - $nombre++; |
|
| 407 | - [$texte1, $texte] = coupe_trop_long($texte); |
|
| 408 | - $textes_supplement .= '<br />' . |
|
| 409 | - "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - return [$texte, $textes_supplement]; |
|
| 394 | + if ( |
|
| 395 | + (strlen($texte) < 29 * 1024) |
|
| 396 | + or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 397 | + ) { |
|
| 398 | + return [$texte, '']; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + include_spip('inc/barre'); |
|
| 402 | + $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 403 | + $nombre = 0; |
|
| 404 | + |
|
| 405 | + while (strlen($texte) > 29 * 1024) { |
|
| 406 | + $nombre++; |
|
| 407 | + [$texte1, $texte] = coupe_trop_long($texte); |
|
| 408 | + $textes_supplement .= '<br />' . |
|
| 409 | + "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + return [$texte, $textes_supplement]; |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -420,17 +420,17 @@ discard block |
||
| 420 | 420 | * @param int $longueur |
| 421 | 421 | */ |
| 422 | 422 | function titre_automatique($champ_titre, $champs_contenu, $longueur = null) { |
| 423 | - if (!_request($champ_titre)) { |
|
| 424 | - $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 425 | - if (!is_null($longueur)) { |
|
| 426 | - $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 427 | - } else { |
|
| 428 | - $t = $titrer_contenu($champs_contenu); |
|
| 429 | - } |
|
| 430 | - if ($t) { |
|
| 431 | - set_request($champ_titre, $t); |
|
| 432 | - } |
|
| 433 | - } |
|
| 423 | + if (!_request($champ_titre)) { |
|
| 424 | + $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 425 | + if (!is_null($longueur)) { |
|
| 426 | + $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 427 | + } else { |
|
| 428 | + $t = $titrer_contenu($champs_contenu); |
|
| 429 | + } |
|
| 430 | + if ($t) { |
|
| 431 | + set_request($champ_titre, $t); |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -450,20 +450,20 @@ discard block |
||
| 450 | 450 | * @return string |
| 451 | 451 | */ |
| 452 | 452 | function inc_titrer_contenu_dist($champs_contenu, $c = null, $longueur = 50) { |
| 453 | - // trouver un champ texte non vide |
|
| 454 | - $t = ''; |
|
| 455 | - foreach ($champs_contenu as $champ) { |
|
| 456 | - if ($t = _request($champ, $c)) { |
|
| 457 | - break; |
|
| 458 | - } |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - if ($t) { |
|
| 462 | - include_spip('inc/texte_mini'); |
|
| 463 | - $t = couper($t, $longueur, '...'); |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - return $t; |
|
| 453 | + // trouver un champ texte non vide |
|
| 454 | + $t = ''; |
|
| 455 | + foreach ($champs_contenu as $champ) { |
|
| 456 | + if ($t = _request($champ, $c)) { |
|
| 457 | + break; |
|
| 458 | + } |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + if ($t) { |
|
| 462 | + include_spip('inc/texte_mini'); |
|
| 463 | + $t = couper($t, $longueur, '...'); |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + return $t; |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -485,26 +485,26 @@ discard block |
||
| 485 | 485 | * - array sinon couples ('$prefixe$colonne => md5) |
| 486 | 486 | **/ |
| 487 | 487 | function controles_md5(array $data, string $prefixe = 'ctr_', string $format = 'html') { |
| 488 | - $ctr = []; |
|
| 489 | - foreach ($data as $key => $val) { |
|
| 490 | - $m = md5($val ?? ''); |
|
| 491 | - $k = $prefixe . $key; |
|
| 492 | - |
|
| 493 | - switch ($format) { |
|
| 494 | - case 'html': |
|
| 495 | - $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 496 | - break; |
|
| 497 | - default: |
|
| 498 | - $ctr[$k] = $m; |
|
| 499 | - break; |
|
| 500 | - } |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - if ($format === 'html') { |
|
| 504 | - return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 505 | - } else { |
|
| 506 | - return $ctr; |
|
| 507 | - } |
|
| 488 | + $ctr = []; |
|
| 489 | + foreach ($data as $key => $val) { |
|
| 490 | + $m = md5($val ?? ''); |
|
| 491 | + $k = $prefixe . $key; |
|
| 492 | + |
|
| 493 | + switch ($format) { |
|
| 494 | + case 'html': |
|
| 495 | + $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 496 | + break; |
|
| 497 | + default: |
|
| 498 | + $ctr[$k] = $m; |
|
| 499 | + break; |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + if ($format === 'html') { |
|
| 504 | + return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 505 | + } else { |
|
| 506 | + return $ctr; |
|
| 507 | + } |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | /** |
@@ -543,80 +543,80 @@ discard block |
||
| 543 | 543 | * - post : le contenu posté |
| 544 | 544 | **/ |
| 545 | 545 | function controler_contenu($type, $id, $options = [], $c = false, $serveur = '') { |
| 546 | - include_spip('inc/filtres'); |
|
| 547 | - |
|
| 548 | - $table_objet = table_objet($type); |
|
| 549 | - $spip_table_objet = table_objet_sql($type); |
|
| 550 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 551 | - $desc = $trouver_table($table_objet, $serveur); |
|
| 552 | - |
|
| 553 | - // Appels incomplets (sans $c) |
|
| 554 | - if (!is_array($c)) { |
|
| 555 | - $c = []; |
|
| 556 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 557 | - if (_request($champ)) { |
|
| 558 | - $c[$champ] = _request($champ); |
|
| 559 | - } |
|
| 560 | - } |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - // Securite : certaines variables ne sont jamais acceptees ici |
|
| 564 | - // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 565 | - // il faut passer par instituer_XX() |
|
| 566 | - // TODO: faut-il passer ces variables interdites |
|
| 567 | - // dans un fichier de description separe ? |
|
| 568 | - unset($c['statut']); |
|
| 569 | - unset($c['id_parent']); |
|
| 570 | - unset($c['id_rubrique']); |
|
| 571 | - unset($c['id_secteur']); |
|
| 572 | - |
|
| 573 | - // Gerer les champs non vides |
|
| 574 | - if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 575 | - foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 576 | - if ($c[$champ] === '') { |
|
| 577 | - $c[$champ] = $sinon; |
|
| 578 | - } |
|
| 579 | - } |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - // N'accepter que les champs qui existent |
|
| 583 | - // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 584 | - $champs = []; |
|
| 585 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 586 | - if (isset($c[$champ])) { |
|
| 587 | - $champs[$champ] = $c[$champ]; |
|
| 588 | - } |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - // Nettoyer les valeurs |
|
| 592 | - $champs = array_map('corriger_caracteres', $champs); |
|
| 593 | - |
|
| 594 | - // Envoyer aux plugins |
|
| 595 | - $champs = pipeline( |
|
| 596 | - 'pre_edition', |
|
| 597 | - [ |
|
| 598 | - 'args' => [ |
|
| 599 | - 'table' => $spip_table_objet, // compatibilite |
|
| 600 | - 'table_objet' => $table_objet, |
|
| 601 | - 'spip_table_objet' => $spip_table_objet, |
|
| 602 | - 'type' => $type, |
|
| 603 | - 'id_objet' => $id, |
|
| 604 | - 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 605 | - 'action' => 'controler', |
|
| 606 | - 'serveur' => $serveur, |
|
| 607 | - ], |
|
| 608 | - 'data' => $champs |
|
| 609 | - ] |
|
| 610 | - ); |
|
| 611 | - |
|
| 612 | - if (!$champs) { |
|
| 613 | - return false; |
|
| 614 | - } |
|
| 615 | - |
|
| 616 | - // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 617 | - $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_'); |
|
| 618 | - |
|
| 619 | - return $conflits; |
|
| 546 | + include_spip('inc/filtres'); |
|
| 547 | + |
|
| 548 | + $table_objet = table_objet($type); |
|
| 549 | + $spip_table_objet = table_objet_sql($type); |
|
| 550 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 551 | + $desc = $trouver_table($table_objet, $serveur); |
|
| 552 | + |
|
| 553 | + // Appels incomplets (sans $c) |
|
| 554 | + if (!is_array($c)) { |
|
| 555 | + $c = []; |
|
| 556 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 557 | + if (_request($champ)) { |
|
| 558 | + $c[$champ] = _request($champ); |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + // Securite : certaines variables ne sont jamais acceptees ici |
|
| 564 | + // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 565 | + // il faut passer par instituer_XX() |
|
| 566 | + // TODO: faut-il passer ces variables interdites |
|
| 567 | + // dans un fichier de description separe ? |
|
| 568 | + unset($c['statut']); |
|
| 569 | + unset($c['id_parent']); |
|
| 570 | + unset($c['id_rubrique']); |
|
| 571 | + unset($c['id_secteur']); |
|
| 572 | + |
|
| 573 | + // Gerer les champs non vides |
|
| 574 | + if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 575 | + foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 576 | + if ($c[$champ] === '') { |
|
| 577 | + $c[$champ] = $sinon; |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | + |
|
| 582 | + // N'accepter que les champs qui existent |
|
| 583 | + // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 584 | + $champs = []; |
|
| 585 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 586 | + if (isset($c[$champ])) { |
|
| 587 | + $champs[$champ] = $c[$champ]; |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + // Nettoyer les valeurs |
|
| 592 | + $champs = array_map('corriger_caracteres', $champs); |
|
| 593 | + |
|
| 594 | + // Envoyer aux plugins |
|
| 595 | + $champs = pipeline( |
|
| 596 | + 'pre_edition', |
|
| 597 | + [ |
|
| 598 | + 'args' => [ |
|
| 599 | + 'table' => $spip_table_objet, // compatibilite |
|
| 600 | + 'table_objet' => $table_objet, |
|
| 601 | + 'spip_table_objet' => $spip_table_objet, |
|
| 602 | + 'type' => $type, |
|
| 603 | + 'id_objet' => $id, |
|
| 604 | + 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 605 | + 'action' => 'controler', |
|
| 606 | + 'serveur' => $serveur, |
|
| 607 | + ], |
|
| 608 | + 'data' => $champs |
|
| 609 | + ] |
|
| 610 | + ); |
|
| 611 | + |
|
| 612 | + if (!$champs) { |
|
| 613 | + return false; |
|
| 614 | + } |
|
| 615 | + |
|
| 616 | + // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 617 | + $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_'); |
|
| 618 | + |
|
| 619 | + return $conflits; |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | |
@@ -646,64 +646,64 @@ discard block |
||
| 646 | 646 | * - post : le contenu posté |
| 647 | 647 | **/ |
| 648 | 648 | function controler_md5(&$champs, $ctr, $type, $id, $serveur, $prefix = 'ctr_') { |
| 649 | - $spip_table_objet = table_objet_sql($type); |
|
| 650 | - $id_table_objet = id_table_objet($type); |
|
| 651 | - |
|
| 652 | - // Controle des MD5 envoyes |
|
| 653 | - // On elimine les donnees non modifiees par le formulaire (mais |
|
| 654 | - // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 655 | - foreach ($champs as $key => $val) { |
|
| 656 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 657 | - if (is_scalar($val) and $m == md5($val)) { |
|
| 658 | - unset($champs[$key]); |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - if (!$champs) { |
|
| 663 | - return; |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - // On veut savoir si notre modif va avoir un impact |
|
| 667 | - // par rapport aux donnees contenues dans la base |
|
| 668 | - // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 669 | - $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 670 | - $intact = true; |
|
| 671 | - foreach ($champs as $ch => $val) { |
|
| 672 | - $intact &= ($s[$ch] == $val); |
|
| 673 | - } |
|
| 674 | - if ($intact) { |
|
| 675 | - return; |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - // Detection de conflits : |
|
| 679 | - // On verifie si notre modif ne provient pas d'un formulaire |
|
| 680 | - // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 681 | - // on compare a ce qui est dans la base, et on bloque en cas |
|
| 682 | - // de conflit. |
|
| 683 | - $ctrh = $ctrq = $conflits = []; |
|
| 684 | - foreach (array_keys($champs) as $key) { |
|
| 685 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 686 | - $ctrh[$key] = $m; |
|
| 687 | - $ctrq[] = $key; |
|
| 688 | - } |
|
| 689 | - } |
|
| 690 | - if ($ctrq) { |
|
| 691 | - $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 692 | - foreach ($ctrh as $key => $m) { |
|
| 693 | - if ( |
|
| 694 | - $m != md5($ctrq[$key]) |
|
| 695 | - and $champs[$key] !== $ctrq[$key] |
|
| 696 | - ) { |
|
| 697 | - $conflits[$key] = [ |
|
| 698 | - 'base' => $ctrq[$key], |
|
| 699 | - 'post' => $champs[$key] |
|
| 700 | - ]; |
|
| 701 | - unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 702 | - } |
|
| 703 | - } |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - return $conflits; |
|
| 649 | + $spip_table_objet = table_objet_sql($type); |
|
| 650 | + $id_table_objet = id_table_objet($type); |
|
| 651 | + |
|
| 652 | + // Controle des MD5 envoyes |
|
| 653 | + // On elimine les donnees non modifiees par le formulaire (mais |
|
| 654 | + // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 655 | + foreach ($champs as $key => $val) { |
|
| 656 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 657 | + if (is_scalar($val) and $m == md5($val)) { |
|
| 658 | + unset($champs[$key]); |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + if (!$champs) { |
|
| 663 | + return; |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + // On veut savoir si notre modif va avoir un impact |
|
| 667 | + // par rapport aux donnees contenues dans la base |
|
| 668 | + // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 669 | + $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 670 | + $intact = true; |
|
| 671 | + foreach ($champs as $ch => $val) { |
|
| 672 | + $intact &= ($s[$ch] == $val); |
|
| 673 | + } |
|
| 674 | + if ($intact) { |
|
| 675 | + return; |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + // Detection de conflits : |
|
| 679 | + // On verifie si notre modif ne provient pas d'un formulaire |
|
| 680 | + // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 681 | + // on compare a ce qui est dans la base, et on bloque en cas |
|
| 682 | + // de conflit. |
|
| 683 | + $ctrh = $ctrq = $conflits = []; |
|
| 684 | + foreach (array_keys($champs) as $key) { |
|
| 685 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 686 | + $ctrh[$key] = $m; |
|
| 687 | + $ctrq[] = $key; |
|
| 688 | + } |
|
| 689 | + } |
|
| 690 | + if ($ctrq) { |
|
| 691 | + $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 692 | + foreach ($ctrh as $key => $m) { |
|
| 693 | + if ( |
|
| 694 | + $m != md5($ctrq[$key]) |
|
| 695 | + and $champs[$key] !== $ctrq[$key] |
|
| 696 | + ) { |
|
| 697 | + $conflits[$key] = [ |
|
| 698 | + 'base' => $ctrq[$key], |
|
| 699 | + 'post' => $champs[$key] |
|
| 700 | + ]; |
|
| 701 | + unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + return $conflits; |
|
| 707 | 707 | } |
| 708 | 708 | |
| 709 | 709 | /** |
@@ -715,11 +715,11 @@ discard block |
||
| 715 | 715 | * @return string |
| 716 | 716 | */ |
| 717 | 717 | function display_conflit_champ($x) { |
| 718 | - if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 719 | - return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 720 | - } else { |
|
| 721 | - return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 722 | - } |
|
| 718 | + if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 719 | + return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 720 | + } else { |
|
| 721 | + return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 722 | + } |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /** |
@@ -737,57 +737,57 @@ discard block |
||
| 737 | 737 | * @return string |
| 738 | 738 | */ |
| 739 | 739 | function signaler_conflits_edition($conflits, $redirect = '') { |
| 740 | - include_spip('inc/minipres'); |
|
| 741 | - include_spip('inc/revisions'); |
|
| 742 | - include_spip('afficher_diff/champ'); |
|
| 743 | - include_spip('inc/suivi_versions'); |
|
| 744 | - include_spip('inc/diff'); |
|
| 745 | - $diffs = []; |
|
| 746 | - foreach ($conflits as $champ => $a) { |
|
| 747 | - // probleme de stockage ou conflit d'edition ? |
|
| 748 | - $base = $a['save'] ?? $a['base']; |
|
| 749 | - |
|
| 750 | - $diff = new Diff(new DiffTexte()); |
|
| 751 | - $n = preparer_diff($a['post']); |
|
| 752 | - $o = preparer_diff($base); |
|
| 753 | - $d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o)))); |
|
| 754 | - |
|
| 755 | - $titre = isset($a['save']) ? _L( |
|
| 756 | - 'Echec lors de l\'enregistrement du champ @champ@', |
|
| 757 | - ['champ' => $champ] |
|
| 758 | - ) : $champ; |
|
| 759 | - |
|
| 760 | - $diffs[] = "<h2>$titre</h2>\n" |
|
| 761 | - . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 762 | - . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 763 | - . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 764 | - . display_conflit_champ($a['post']) |
|
| 765 | - . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 766 | - . display_conflit_champ($base); |
|
| 767 | - } |
|
| 768 | - |
|
| 769 | - if ($redirect) { |
|
| 770 | - $id = uniqid(random_int(0, mt_getrandmax())); |
|
| 771 | - $redirect = "<form action='$redirect' method='get' |
|
| 740 | + include_spip('inc/minipres'); |
|
| 741 | + include_spip('inc/revisions'); |
|
| 742 | + include_spip('afficher_diff/champ'); |
|
| 743 | + include_spip('inc/suivi_versions'); |
|
| 744 | + include_spip('inc/diff'); |
|
| 745 | + $diffs = []; |
|
| 746 | + foreach ($conflits as $champ => $a) { |
|
| 747 | + // probleme de stockage ou conflit d'edition ? |
|
| 748 | + $base = $a['save'] ?? $a['base']; |
|
| 749 | + |
|
| 750 | + $diff = new Diff(new DiffTexte()); |
|
| 751 | + $n = preparer_diff($a['post']); |
|
| 752 | + $o = preparer_diff($base); |
|
| 753 | + $d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o)))); |
|
| 754 | + |
|
| 755 | + $titre = isset($a['save']) ? _L( |
|
| 756 | + 'Echec lors de l\'enregistrement du champ @champ@', |
|
| 757 | + ['champ' => $champ] |
|
| 758 | + ) : $champ; |
|
| 759 | + |
|
| 760 | + $diffs[] = "<h2>$titre</h2>\n" |
|
| 761 | + . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 762 | + . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 763 | + . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 764 | + . display_conflit_champ($a['post']) |
|
| 765 | + . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 766 | + . display_conflit_champ($base); |
|
| 767 | + } |
|
| 768 | + |
|
| 769 | + if ($redirect) { |
|
| 770 | + $id = uniqid(random_int(0, mt_getrandmax())); |
|
| 771 | + $redirect = "<form action='$redirect' method='get' |
|
| 772 | 772 | id='$id' |
| 773 | 773 | style='float:" . $GLOBALS['spip_lang_right'] . "; margin-top:2em;'>\n" |
| 774 | - . form_hidden($redirect) |
|
| 775 | - . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 774 | + . form_hidden($redirect) |
|
| 775 | + . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 776 | 776 | </form>\n"; |
| 777 | 777 | |
| 778 | - // pour les documents, on est probablement en ajax : il faut ajaxer |
|
| 779 | - if (_AJAX) { |
|
| 780 | - $redirect .= '<script type="text/javascript">' |
|
| 781 | - . 'setTimeout(function(){$("#' . $id . '") |
|
| 778 | + // pour les documents, on est probablement en ajax : il faut ajaxer |
|
| 779 | + if (_AJAX) { |
|
| 780 | + $redirect .= '<script type="text/javascript">' |
|
| 781 | + . 'setTimeout(function(){$("#' . $id . '") |
|
| 782 | 782 | .ajaxForm({target:$("#' . $id . '").parent()}); |
| 783 | 783 | }, 200);' |
| 784 | - . "</script>\n"; |
|
| 785 | - } |
|
| 786 | - } |
|
| 784 | + . "</script>\n"; |
|
| 785 | + } |
|
| 786 | + } |
|
| 787 | 787 | |
| 788 | - echo minipres( |
|
| 789 | - _T('titre_conflit_edition'), |
|
| 790 | - '<style> |
|
| 788 | + echo minipres( |
|
| 789 | + _T('titre_conflit_edition'), |
|
| 790 | + '<style> |
|
| 791 | 791 | .diff-para-deplace { background: #e8e8ff; } |
| 792 | 792 | .diff-para-ajoute { background: #d0ffc0; color: #000; } |
| 793 | 793 | .diff-para-supprime { background: #ffd0c0; color: #904040; text-decoration: line-through; } |
@@ -798,12 +798,12 @@ discard block |
||
| 798 | 798 | .diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; } |
| 799 | 799 | .diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; } |
| 800 | 800 | </style>' |
| 801 | - . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 802 | - . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 803 | - . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 804 | - . join("\n", $diffs) |
|
| 805 | - . "</div>\n" |
|
| 806 | - |
|
| 807 | - . $redirect |
|
| 808 | - ); |
|
| 801 | + . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 802 | + . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 803 | + . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 804 | + . join("\n", $diffs) |
|
| 805 | + . "</div>\n" |
|
| 806 | + |
|
| 807 | + . $redirect |
|
| 808 | + ); |
|
| 809 | 809 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | static $dirs = []; |
| 42 | 42 | $liste = []; |
| 43 | 43 | foreach (creer_chemin() as $dir) { |
| 44 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 44 | + if (!isset($dirs[$a = $dir.$dirname])) { |
|
| 45 | 45 | $dirs[$a] = (is_dir($a) || !$a); |
| 46 | 46 | } |
| 47 | 47 | if ($dirs[$a]) { |
@@ -67,21 +67,21 @@ discard block |
||
| 67 | 67 | **/ |
| 68 | 68 | function chercher_module_lang($module, $lang = '') { |
| 69 | 69 | if ($lang) { |
| 70 | - $lang = '_' . $lang; |
|
| 70 | + $lang = '_'.$lang; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
| 74 | 74 | if ( |
| 75 | 75 | $f = ($module == 'local' |
| 76 | - ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | - : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 76 | + ? find_in_path($module.$lang.'.php', 'lang/') |
|
| 77 | + : find_langs_in_path($module.$lang.'.php', 'lang/')) |
|
| 78 | 78 | ) { |
| 79 | 79 | return is_array($f) ? $f : [$f]; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // 2) directement dans le chemin (old style, uniquement pour local) |
| 83 | 83 | return (($module == 'local') or strpos($module, '/')) |
| 84 | - ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 84 | + ? (($f = find_in_path($module.$lang.'.php')) ? [$f] : false) |
|
| 85 | 85 | : false; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | **/ |
| 106 | 106 | function charger_langue($lang, $module = 'spip') { |
| 107 | 107 | static $langs = []; |
| 108 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 108 | + $var = 'i18n_'.$module.'_'.$lang; |
|
| 109 | 109 | if (!isset($langs[$lang])) { |
| 110 | 110 | $langs[$lang] = []; |
| 111 | 111 | if ($lang) { |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | foreach ($langs[$lang] as $l) { |
| 122 | 122 | if ($fichiers_lang = chercher_module_lang($module, $l)) { |
| 123 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 123 | + $GLOBALS['idx_lang'] = 'i18n_'.$module.'_'.$l; |
|
| 124 | 124 | include(array_shift($fichiers_lang)); |
| 125 | 125 | surcharger_langue($fichiers_lang); |
| 126 | 126 | if ($l !== $lang) { |
| 127 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 127 | + $GLOBALS[$var] = &$GLOBALS['i18n_'.$module.'_'.$l]; |
|
| 128 | 128 | } |
| 129 | - $GLOBALS['lang_' . $var] = $l; |
|
| 129 | + $GLOBALS['lang_'.$var] = $l; |
|
| 130 | 130 | #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
| 131 | 131 | break; |
| 132 | 132 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | foreach ($fichiers as $fichier) { |
| 165 | 165 | if (!isset($surcharges[$fichier])) { |
| 166 | 166 | $idx_lang_normal = $GLOBALS['idx_lang']; |
| 167 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 167 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'].'@temporaire'; |
|
| 168 | 168 | include($fichier); |
| 169 | 169 | $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
| 170 | 170 | unset($GLOBALS[$GLOBALS['idx_lang']]); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | if (is_array($surcharges[$fichier])) { |
| 174 | 174 | $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
| 175 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 175 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array) $GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | 176 | $surcharges[$fichier] |
| 177 | 177 | ); |
| 178 | 178 | } |
@@ -250,27 +250,27 @@ discard block |
||
| 250 | 250 | } else { |
| 251 | 251 | $modules = ['spip', 'ecrire']; |
| 252 | 252 | $code = $ori; |
| 253 | - $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 253 | + $ori_complet = implode('|', $modules).':'.$ori; |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | $desc = new SPIP_Traductions_Description(); |
| 257 | 257 | |
| 258 | 258 | // parcourir tous les modules jusqu'a ce qu'on trouve |
| 259 | 259 | foreach ($modules as $module) { |
| 260 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 260 | + $var = 'i18n_'.$module.'_'.$lang; |
|
| 261 | 261 | |
| 262 | 262 | if (empty($GLOBALS[$var])) { |
| 263 | 263 | charger_langue($lang, $module); |
| 264 | 264 | // surcharges persos -- on cherche |
| 265 | 265 | // (lang/)local_xx.php et/ou (lang/)local.php ... |
| 266 | - if (!isset($local['local_' . $lang])) { |
|
| 266 | + if (!isset($local['local_'.$lang])) { |
|
| 267 | 267 | // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
| 268 | 268 | $GLOBALS['idx_lang'] = $var; |
| 269 | 269 | // ... (lang/)local_xx.php |
| 270 | - $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 270 | + $local['local_'.$lang] = chercher_module_lang('local', $lang); |
|
| 271 | 271 | } |
| 272 | - if ($local['local_' . $lang]) { |
|
| 273 | - surcharger_langue($local['local_' . $lang]); |
|
| 272 | + if ($local['local_'.$lang]) { |
|
| 273 | + surcharger_langue($local['local_'.$lang]); |
|
| 274 | 274 | } |
| 275 | 275 | // ... puis (lang/)local.php |
| 276 | 276 | if (!isset($local['local'])) { |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | if (isset($GLOBALS[$var][$code])) { |
| 285 | 285 | $desc->code = $code; |
| 286 | 286 | $desc->module = $module; |
| 287 | - $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 287 | + $desc->langue = $GLOBALS['lang_'.$var]; |
|
| 288 | 288 | $desc->texte = $GLOBALS[$var][$code]; |
| 289 | 289 | break; |
| 290 | 290 | } |
@@ -339,13 +339,13 @@ discard block |
||
| 339 | 339 | if (!$desc->mode and $desc->texte) { |
| 340 | 340 | // ne pas modifier 2 fois l'affichage |
| 341 | 341 | $desc->mode = 'traduction'; |
| 342 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 342 | + $classe = 'debug-traduction'.($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 343 | 343 | $desc->texte = '<span ' |
| 344 | - . 'lang=' . $desc->langue |
|
| 345 | - . ' class=' . $classe |
|
| 346 | - . ' data-module=' . $desc->module |
|
| 347 | - . ' data-code=' . $desc->code |
|
| 348 | - . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 344 | + . 'lang='.$desc->langue |
|
| 345 | + . ' class='.$classe |
|
| 346 | + . ' data-module='.$desc->module |
|
| 347 | + . ' data-code='.$desc->code |
|
| 348 | + . ' title='.$modules.'('.$desc->langue.')>' |
|
| 349 | 349 | . $desc->texte |
| 350 | 350 | . '</span>'; |
| 351 | 351 | $desc->texte = str_replace( |
@@ -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 | /** |
@@ -38,20 +38,20 @@ discard block |
||
| 38 | 38 | * Liste des fichiers de langue trouvés, dans l'ordre des chemins |
| 39 | 39 | */ |
| 40 | 40 | function find_langs_in_path($file, $dirname = 'lang') { |
| 41 | - static $dirs = []; |
|
| 42 | - $liste = []; |
|
| 43 | - foreach (creer_chemin() as $dir) { |
|
| 44 | - if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 45 | - $dirs[$a] = (is_dir($a) || !$a); |
|
| 46 | - } |
|
| 47 | - if ($dirs[$a]) { |
|
| 48 | - if (is_readable($a .= $file)) { |
|
| 49 | - $liste[] = $a; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 41 | + static $dirs = []; |
|
| 42 | + $liste = []; |
|
| 43 | + foreach (creer_chemin() as $dir) { |
|
| 44 | + if (!isset($dirs[$a = $dir . $dirname])) { |
|
| 45 | + $dirs[$a] = (is_dir($a) || !$a); |
|
| 46 | + } |
|
| 47 | + if ($dirs[$a]) { |
|
| 48 | + if (is_readable($a .= $file)) { |
|
| 49 | + $liste[] = $a; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return array_reverse($liste); |
|
| 54 | + return array_reverse($liste); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -66,23 +66,23 @@ discard block |
||
| 66 | 66 | * Liste des fichiers touvés pour ce module et cette langue. |
| 67 | 67 | **/ |
| 68 | 68 | function chercher_module_lang($module, $lang = '') { |
| 69 | - if ($lang) { |
|
| 70 | - $lang = '_' . $lang; |
|
| 71 | - } |
|
| 69 | + if ($lang) { |
|
| 70 | + $lang = '_' . $lang; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
|
| 74 | - if ( |
|
| 75 | - $f = ($module == 'local' |
|
| 76 | - ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | - : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 78 | - ) { |
|
| 79 | - return is_array($f) ? $f : [$f]; |
|
| 80 | - } |
|
| 73 | + // 1) dans un repertoire nomme lang/ se trouvant sur le chemin |
|
| 74 | + if ( |
|
| 75 | + $f = ($module == 'local' |
|
| 76 | + ? find_in_path($module . $lang . '.php', 'lang/') |
|
| 77 | + : find_langs_in_path($module . $lang . '.php', 'lang/')) |
|
| 78 | + ) { |
|
| 79 | + return is_array($f) ? $f : [$f]; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - // 2) directement dans le chemin (old style, uniquement pour local) |
|
| 83 | - return (($module == 'local') or strpos($module, '/')) |
|
| 84 | - ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 85 | - : false; |
|
| 82 | + // 2) directement dans le chemin (old style, uniquement pour local) |
|
| 83 | + return (($module == 'local') or strpos($module, '/')) |
|
| 84 | + ? (($f = find_in_path($module . $lang . '.php')) ? [$f] : false) |
|
| 85 | + : false; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | /** |
@@ -104,33 +104,33 @@ discard block |
||
| 104 | 104 | * @return string Langue du module chargé, sinon chaîne vide. |
| 105 | 105 | **/ |
| 106 | 106 | function charger_langue($lang, $module = 'spip') { |
| 107 | - static $langs = []; |
|
| 108 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 109 | - if (!isset($langs[$lang])) { |
|
| 110 | - $langs[$lang] = []; |
|
| 111 | - if ($lang) { |
|
| 112 | - $langs[$lang][] = $lang; |
|
| 113 | - if (strpos($lang, '_') !== false) { |
|
| 114 | - $l = explode('_', $lang); |
|
| 115 | - $langs[$lang][] = reset($l); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - $langs[$lang][] = $GLOBALS['meta']['langue_site']; |
|
| 119 | - $langs[$lang][] = _LANGUE_PAR_DEFAUT; |
|
| 120 | - } |
|
| 121 | - foreach ($langs[$lang] as $l) { |
|
| 122 | - if ($fichiers_lang = chercher_module_lang($module, $l)) { |
|
| 123 | - $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 124 | - include(array_shift($fichiers_lang)); |
|
| 125 | - surcharger_langue($fichiers_lang); |
|
| 126 | - if ($l !== $lang) { |
|
| 127 | - $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 128 | - } |
|
| 129 | - $GLOBALS['lang_' . $var] = $l; |
|
| 130 | - #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
|
| 131 | - break; |
|
| 132 | - } |
|
| 133 | - } |
|
| 107 | + static $langs = []; |
|
| 108 | + $var = 'i18n_' . $module . '_' . $lang; |
|
| 109 | + if (!isset($langs[$lang])) { |
|
| 110 | + $langs[$lang] = []; |
|
| 111 | + if ($lang) { |
|
| 112 | + $langs[$lang][] = $lang; |
|
| 113 | + if (strpos($lang, '_') !== false) { |
|
| 114 | + $l = explode('_', $lang); |
|
| 115 | + $langs[$lang][] = reset($l); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + $langs[$lang][] = $GLOBALS['meta']['langue_site']; |
|
| 119 | + $langs[$lang][] = _LANGUE_PAR_DEFAUT; |
|
| 120 | + } |
|
| 121 | + foreach ($langs[$lang] as $l) { |
|
| 122 | + if ($fichiers_lang = chercher_module_lang($module, $l)) { |
|
| 123 | + $GLOBALS['idx_lang'] = 'i18n_' . $module . '_' . $l; |
|
| 124 | + include(array_shift($fichiers_lang)); |
|
| 125 | + surcharger_langue($fichiers_lang); |
|
| 126 | + if ($l !== $lang) { |
|
| 127 | + $GLOBALS[$var] = &$GLOBALS['i18n_' . $module . '_' . $l]; |
|
| 128 | + } |
|
| 129 | + $GLOBALS['lang_' . $var] = $l; |
|
| 130 | + #spip_log("module de langue : ${module}_$l.php", 'traduire'); |
|
| 131 | + break; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -150,50 +150,50 @@ discard block |
||
| 150 | 150 | * Liste des chemins de fichiers de langue à surcharger. |
| 151 | 151 | **/ |
| 152 | 152 | function surcharger_langue($fichiers) { |
| 153 | - static $surcharges = []; |
|
| 154 | - if (!isset($GLOBALS['idx_lang'])) { |
|
| 155 | - return; |
|
| 156 | - } |
|
| 153 | + static $surcharges = []; |
|
| 154 | + if (!isset($GLOBALS['idx_lang'])) { |
|
| 155 | + return; |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - if (!is_array($fichiers)) { |
|
| 159 | - $fichiers = [$fichiers]; |
|
| 160 | - } |
|
| 161 | - if (!count($fichiers)) { |
|
| 162 | - return; |
|
| 163 | - } |
|
| 164 | - foreach ($fichiers as $fichier) { |
|
| 165 | - if (!isset($surcharges[$fichier])) { |
|
| 166 | - $idx_lang_normal = $GLOBALS['idx_lang']; |
|
| 167 | - $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 168 | - include($fichier); |
|
| 169 | - $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
|
| 170 | - unset($GLOBALS[$GLOBALS['idx_lang']]); |
|
| 171 | - $GLOBALS['idx_lang'] = $idx_lang_normal; |
|
| 172 | - } |
|
| 173 | - if (is_array($surcharges[$fichier])) { |
|
| 174 | - $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
|
| 175 | - (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | - $surcharges[$fichier] |
|
| 177 | - ); |
|
| 178 | - } |
|
| 179 | - } |
|
| 158 | + if (!is_array($fichiers)) { |
|
| 159 | + $fichiers = [$fichiers]; |
|
| 160 | + } |
|
| 161 | + if (!count($fichiers)) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 164 | + foreach ($fichiers as $fichier) { |
|
| 165 | + if (!isset($surcharges[$fichier])) { |
|
| 166 | + $idx_lang_normal = $GLOBALS['idx_lang']; |
|
| 167 | + $GLOBALS['idx_lang'] = $GLOBALS['idx_lang'] . '@temporaire'; |
|
| 168 | + include($fichier); |
|
| 169 | + $surcharges[$fichier] = $GLOBALS[$GLOBALS['idx_lang']]; |
|
| 170 | + unset($GLOBALS[$GLOBALS['idx_lang']]); |
|
| 171 | + $GLOBALS['idx_lang'] = $idx_lang_normal; |
|
| 172 | + } |
|
| 173 | + if (is_array($surcharges[$fichier])) { |
|
| 174 | + $GLOBALS[$GLOBALS['idx_lang']] = array_merge( |
|
| 175 | + (isset($GLOBALS[$GLOBALS['idx_lang']]) ? (array)$GLOBALS[$GLOBALS['idx_lang']] : []), |
|
| 176 | + $surcharges[$fichier] |
|
| 177 | + ); |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | |
| 184 | 184 | class SPIP_Traductions_Description { |
| 185 | - /** @var string code de langue (hors module) */ |
|
| 186 | - public $code; |
|
| 187 | - /** @var string nom du module de langue */ |
|
| 188 | - public $module; |
|
| 189 | - /** @var string langue de la traduction */ |
|
| 190 | - public $langue; |
|
| 191 | - /** @var string traduction */ |
|
| 192 | - public $texte; |
|
| 193 | - /** @var string var mode particulier appliqué ? */ |
|
| 194 | - public $mode; |
|
| 195 | - /** @var bool Corrections des textes appliqué ? */ |
|
| 196 | - public $corrections = false; |
|
| 185 | + /** @var string code de langue (hors module) */ |
|
| 186 | + public $code; |
|
| 187 | + /** @var string nom du module de langue */ |
|
| 188 | + public $module; |
|
| 189 | + /** @var string langue de la traduction */ |
|
| 190 | + public $langue; |
|
| 191 | + /** @var string traduction */ |
|
| 192 | + public $texte; |
|
| 193 | + /** @var string var mode particulier appliqué ? */ |
|
| 194 | + public $mode; |
|
| 195 | + /** @var bool Corrections des textes appliqué ? */ |
|
| 196 | + public $corrections = false; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | |
@@ -235,99 +235,99 @@ discard block |
||
| 235 | 235 | * - SPIP_Traductions_Description : traduction et description (texte, module, langue) |
| 236 | 236 | **/ |
| 237 | 237 | function inc_traduire_dist($ori, $lang, $raw = false) { |
| 238 | - static $deja_vu = []; |
|
| 239 | - static $local = []; |
|
| 238 | + static $deja_vu = []; |
|
| 239 | + static $local = []; |
|
| 240 | 240 | |
| 241 | - if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { |
|
| 242 | - return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte; |
|
| 243 | - } |
|
| 241 | + if (isset($deja_vu[$lang][$ori]) and (_request('var_mode') != 'traduction')) { |
|
| 242 | + return $raw ? $deja_vu[$lang][$ori] : $deja_vu[$lang][$ori]->texte; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES |
|
| 246 | - if (strpos($ori, ':')) { |
|
| 247 | - [$modules, $code] = explode(':', $ori, 2); |
|
| 248 | - $modules = explode('|', $modules); |
|
| 249 | - $ori_complet = $ori; |
|
| 250 | - } else { |
|
| 251 | - $modules = ['spip', 'ecrire']; |
|
| 252 | - $code = $ori; |
|
| 253 | - $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 254 | - } |
|
| 245 | + // modules demandes explicitement <xxx|yyy|zzz:code> cf MODULES_IDIOMES |
|
| 246 | + if (strpos($ori, ':')) { |
|
| 247 | + [$modules, $code] = explode(':', $ori, 2); |
|
| 248 | + $modules = explode('|', $modules); |
|
| 249 | + $ori_complet = $ori; |
|
| 250 | + } else { |
|
| 251 | + $modules = ['spip', 'ecrire']; |
|
| 252 | + $code = $ori; |
|
| 253 | + $ori_complet = implode('|', $modules) . ':' . $ori; |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - $desc = new SPIP_Traductions_Description(); |
|
| 256 | + $desc = new SPIP_Traductions_Description(); |
|
| 257 | 257 | |
| 258 | - // parcourir tous les modules jusqu'a ce qu'on trouve |
|
| 259 | - foreach ($modules as $module) { |
|
| 260 | - $var = 'i18n_' . $module . '_' . $lang; |
|
| 258 | + // parcourir tous les modules jusqu'a ce qu'on trouve |
|
| 259 | + foreach ($modules as $module) { |
|
| 260 | + $var = 'i18n_' . $module . '_' . $lang; |
|
| 261 | 261 | |
| 262 | - if (empty($GLOBALS[$var])) { |
|
| 263 | - charger_langue($lang, $module); |
|
| 264 | - // surcharges persos -- on cherche |
|
| 265 | - // (lang/)local_xx.php et/ou (lang/)local.php ... |
|
| 266 | - if (!isset($local['local_' . $lang])) { |
|
| 267 | - // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
|
| 268 | - $GLOBALS['idx_lang'] = $var; |
|
| 269 | - // ... (lang/)local_xx.php |
|
| 270 | - $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 271 | - } |
|
| 272 | - if ($local['local_' . $lang]) { |
|
| 273 | - surcharger_langue($local['local_' . $lang]); |
|
| 274 | - } |
|
| 275 | - // ... puis (lang/)local.php |
|
| 276 | - if (!isset($local['local'])) { |
|
| 277 | - $local['local'] = chercher_module_lang('local'); |
|
| 278 | - } |
|
| 279 | - if ($local['local']) { |
|
| 280 | - surcharger_langue($local['local']); |
|
| 281 | - } |
|
| 282 | - } |
|
| 262 | + if (empty($GLOBALS[$var])) { |
|
| 263 | + charger_langue($lang, $module); |
|
| 264 | + // surcharges persos -- on cherche |
|
| 265 | + // (lang/)local_xx.php et/ou (lang/)local.php ... |
|
| 266 | + if (!isset($local['local_' . $lang])) { |
|
| 267 | + // redéfinir la langue en cours pour les surcharges (chercher_langue a pu le changer) |
|
| 268 | + $GLOBALS['idx_lang'] = $var; |
|
| 269 | + // ... (lang/)local_xx.php |
|
| 270 | + $local['local_' . $lang] = chercher_module_lang('local', $lang); |
|
| 271 | + } |
|
| 272 | + if ($local['local_' . $lang]) { |
|
| 273 | + surcharger_langue($local['local_' . $lang]); |
|
| 274 | + } |
|
| 275 | + // ... puis (lang/)local.php |
|
| 276 | + if (!isset($local['local'])) { |
|
| 277 | + $local['local'] = chercher_module_lang('local'); |
|
| 278 | + } |
|
| 279 | + if ($local['local']) { |
|
| 280 | + surcharger_langue($local['local']); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - if (isset($GLOBALS[$var][$code])) { |
|
| 285 | - $desc->code = $code; |
|
| 286 | - $desc->module = $module; |
|
| 287 | - $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 288 | - $desc->texte = $GLOBALS[$var][$code]; |
|
| 289 | - break; |
|
| 290 | - } |
|
| 291 | - } |
|
| 284 | + if (isset($GLOBALS[$var][$code])) { |
|
| 285 | + $desc->code = $code; |
|
| 286 | + $desc->module = $module; |
|
| 287 | + $desc->langue = $GLOBALS['lang_' . $var]; |
|
| 288 | + $desc->texte = $GLOBALS[$var][$code]; |
|
| 289 | + break; |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - if (!$desc->corrections) { |
|
| 294 | - $desc->corrections = true; |
|
| 295 | - // Retour aux sources si la chaine est absente dans la langue cible ; |
|
| 296 | - // on essaie d'abord la langue du site, puis a defaut la langue fr |
|
| 297 | - if ( |
|
| 298 | - ($desc->texte === null || !strlen($desc->texte)) |
|
| 299 | - and $lang !== _LANGUE_PAR_DEFAUT |
|
| 300 | - ) { |
|
| 301 | - if ($lang !== $GLOBALS['meta']['langue_site']) { |
|
| 302 | - $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true); |
|
| 303 | - } else { |
|
| 304 | - $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true); |
|
| 305 | - } |
|
| 306 | - } |
|
| 293 | + if (!$desc->corrections) { |
|
| 294 | + $desc->corrections = true; |
|
| 295 | + // Retour aux sources si la chaine est absente dans la langue cible ; |
|
| 296 | + // on essaie d'abord la langue du site, puis a defaut la langue fr |
|
| 297 | + if ( |
|
| 298 | + ($desc->texte === null || !strlen($desc->texte)) |
|
| 299 | + and $lang !== _LANGUE_PAR_DEFAUT |
|
| 300 | + ) { |
|
| 301 | + if ($lang !== $GLOBALS['meta']['langue_site']) { |
|
| 302 | + $desc = inc_traduire_dist($ori, $GLOBALS['meta']['langue_site'], true); |
|
| 303 | + } else { |
|
| 304 | + $desc = inc_traduire_dist($ori, _LANGUE_PAR_DEFAUT, true); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - // Supprimer la mention <NEW> ou <MODIF> |
|
| 309 | - if ($desc->texte && substr($desc->texte, 0, 1) === '<') { |
|
| 310 | - $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte); |
|
| 311 | - } |
|
| 308 | + // Supprimer la mention <NEW> ou <MODIF> |
|
| 309 | + if ($desc->texte && substr($desc->texte, 0, 1) === '<') { |
|
| 310 | + $desc->texte = str_replace(['<NEW>', '<MODIF>'], [], $desc->texte); |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - // Si on n'est pas en utf-8, la chaine peut l'etre... |
|
| 314 | - // le cas echeant on la convertit en entites html &#xxx; |
|
| 315 | - if ( |
|
| 316 | - (!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8') |
|
| 317 | - and preg_match(',[\x7f-\xff],S', $desc->texte) |
|
| 318 | - ) { |
|
| 319 | - include_spip('inc/charsets'); |
|
| 320 | - $desc->texte = charset2unicode($desc->texte, 'utf-8'); |
|
| 321 | - } |
|
| 322 | - } |
|
| 313 | + // Si on n'est pas en utf-8, la chaine peut l'etre... |
|
| 314 | + // le cas echeant on la convertit en entites html &#xxx; |
|
| 315 | + if ( |
|
| 316 | + (!isset($GLOBALS['meta']['charset']) or $GLOBALS['meta']['charset'] !== 'utf-8') |
|
| 317 | + and preg_match(',[\x7f-\xff],S', $desc->texte) |
|
| 318 | + ) { |
|
| 319 | + include_spip('inc/charsets'); |
|
| 320 | + $desc->texte = charset2unicode($desc->texte, 'utf-8'); |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - if (_request('var_mode') == 'traduction') { |
|
| 325 | - $desc = definir_details_traduction($desc, $ori_complet); |
|
| 326 | - } else { |
|
| 327 | - $deja_vu[$lang][$ori] = $desc; |
|
| 328 | - } |
|
| 324 | + if (_request('var_mode') == 'traduction') { |
|
| 325 | + $desc = definir_details_traduction($desc, $ori_complet); |
|
| 326 | + } else { |
|
| 327 | + $deja_vu[$lang][$ori] = $desc; |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - return $raw ? $desc : $desc->texte; |
|
| 330 | + return $raw ? $desc : $desc->texte; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -339,23 +339,23 @@ discard block |
||
| 339 | 339 | * @return SPIP_Traductions_Description |
| 340 | 340 | */ |
| 341 | 341 | function definir_details_traduction($desc, $modules) { |
| 342 | - if (!$desc->mode and $desc->texte) { |
|
| 343 | - // ne pas modifier 2 fois l'affichage |
|
| 344 | - $desc->mode = 'traduction'; |
|
| 345 | - $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 346 | - $desc->texte = '<span ' |
|
| 347 | - . 'lang=' . $desc->langue |
|
| 348 | - . ' class=' . $classe |
|
| 349 | - . ' data-module=' . $desc->module |
|
| 350 | - . ' data-code=' . $desc->code |
|
| 351 | - . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 352 | - . $desc->texte |
|
| 353 | - . '</span>'; |
|
| 354 | - $desc->texte = str_replace( |
|
| 355 | - ["$desc->module:", "$desc->module|"], |
|
| 356 | - ["*$desc->module*:", "*$desc->module*|"], |
|
| 357 | - $desc->texte |
|
| 358 | - ); |
|
| 359 | - } |
|
| 360 | - return $desc; |
|
| 342 | + if (!$desc->mode and $desc->texte) { |
|
| 343 | + // ne pas modifier 2 fois l'affichage |
|
| 344 | + $desc->mode = 'traduction'; |
|
| 345 | + $classe = 'debug-traduction' . ($desc->module == 'ecrire' ? '-prive' : ''); |
|
| 346 | + $desc->texte = '<span ' |
|
| 347 | + . 'lang=' . $desc->langue |
|
| 348 | + . ' class=' . $classe |
|
| 349 | + . ' data-module=' . $desc->module |
|
| 350 | + . ' data-code=' . $desc->code |
|
| 351 | + . ' title=' . $modules . '(' . $desc->langue . ')>' |
|
| 352 | + . $desc->texte |
|
| 353 | + . '</span>'; |
|
| 354 | + $desc->texte = str_replace( |
|
| 355 | + ["$desc->module:", "$desc->module|"], |
|
| 356 | + ["*$desc->module*:", "*$desc->module*|"], |
|
| 357 | + $desc->texte |
|
| 358 | + ); |
|
| 359 | + } |
|
| 360 | + return $desc; |
|
| 361 | 361 | } |
@@ -18,206 +18,206 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $GLOBALS['codes_langues'] = [ |
| 25 | - 'aa' => 'Afar', |
|
| 26 | - 'ab' => 'Abkhazian', |
|
| 27 | - 'af' => 'Afrikaans', |
|
| 28 | - 'am' => 'Amharic', |
|
| 29 | - 'an' => 'Aragonés', |
|
| 30 | - 'ar' => 'عربي', |
|
| 31 | - 'as' => 'Assamese', |
|
| 32 | - 'ast' => 'asturianu', |
|
| 33 | - 'ay' => 'Aymara', |
|
| 34 | - 'az' => 'Azərbaycan dili', |
|
| 35 | - 'ba' => 'Bashkir', |
|
| 36 | - 'be' => 'Беларуская', |
|
| 37 | - 'ber_tam' => 'Tamazigh', |
|
| 38 | - 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | - 'bg' => 'български', |
|
| 40 | - 'bh' => 'Bihari', |
|
| 41 | - 'bi' => 'Bislama', |
|
| 42 | - 'bm' => 'Bambara', |
|
| 43 | - 'bn' => 'Bengali; Bangla', |
|
| 44 | - 'bo' => 'Tibetan', |
|
| 45 | - 'br' => 'brezhoneg', |
|
| 46 | - 'bs' => 'bosanski', |
|
| 47 | - 'ca' => 'català', |
|
| 48 | - 'co' => 'corsu', |
|
| 49 | - 'cpf' => 'Kréol réyoné', |
|
| 50 | - 'cpf_dom' => 'Kreyòl', |
|
| 51 | - 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | - 'cs' => 'čeština', |
|
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | - 'da' => 'dansk', |
|
| 55 | - 'de' => 'Deutsch', |
|
| 56 | - 'dz' => 'Bhutani', |
|
| 57 | - 'el' => 'ελληνικά', |
|
| 58 | - 'en' => 'English', |
|
| 59 | - 'en_hx' => 'H4ck3R', |
|
| 60 | - 'en_sm' => 'Smurf', |
|
| 61 | - 'eo' => 'Esperanto', |
|
| 62 | - 'es' => 'Español', |
|
| 63 | - 'es_co' => 'Colombiano', |
|
| 64 | - 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | - 'et' => 'eesti', |
|
| 66 | - 'eu' => 'euskara', |
|
| 67 | - 'fa' => 'فارسى', |
|
| 68 | - 'ff' => 'Fulah', // peul |
|
| 69 | - 'fi' => 'suomi', |
|
| 70 | - 'fj' => 'Fiji', |
|
| 71 | - 'fo' => 'føroyskt', |
|
| 72 | - 'fon' => 'fongbè', |
|
| 73 | - 'fr' => 'français', |
|
| 74 | - 'fr_fem' => 'français féminin', |
|
| 75 | - 'fr_sc' => 'schtroumpf', |
|
| 76 | - 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | - 'fr_lsf' => 'langue des signes française', |
|
| 78 | - 'fr_spl' => 'français simplifié', |
|
| 79 | - 'fr_tu' => 'français copain', |
|
| 80 | - 'fy' => 'Frisian', |
|
| 81 | - 'ga' => 'Irish', |
|
| 82 | - 'gd' => 'Scots Gaelic', |
|
| 83 | - 'gl' => 'galego', |
|
| 84 | - 'gn' => 'Guarani', |
|
| 85 | - 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | - 'gu' => 'Gujarati', |
|
| 87 | - 'ha' => 'Hausa', |
|
| 88 | - 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | - 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | - 'haz' => 'هزاره گی', |
|
| 91 | - 'he' => 'עברית', |
|
| 92 | - 'hi' => 'हिंदी', |
|
| 93 | - 'hr' => 'hrvatski', |
|
| 94 | - 'hu' => 'magyar', |
|
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 96 | - 'ia' => 'Interlingua', |
|
| 97 | - 'id' => 'Indonesia', |
|
| 98 | - 'ie' => 'Interlingue', |
|
| 99 | - 'ik' => 'Inupiak', |
|
| 100 | - 'is' => 'íslenska', |
|
| 101 | - 'it' => 'italiano', |
|
| 102 | - 'it_fem' => 'italiana', |
|
| 103 | - 'iu' => 'Inuktitut', |
|
| 104 | - 'ja' => '日本語', |
|
| 105 | - 'jv' => 'Javanese', |
|
| 106 | - 'ka' => 'ქართული', |
|
| 107 | - 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | - 'kl' => 'kalaallisut', |
|
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | - 'kn' => 'Kannada', |
|
| 111 | - 'ko' => '한국어', |
|
| 112 | - 'kok' => 'कोंकणी', |
|
| 113 | - 'ks' => 'Kashmiri', |
|
| 114 | - 'ku' => 'کوردی', |
|
| 115 | - 'ky' => 'Kirghiz', |
|
| 116 | - 'la' => 'lingua latina', |
|
| 117 | - 'lb' => 'Lëtzebuergesch', |
|
| 118 | - 'ln' => 'Lingala', |
|
| 119 | - 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | - 'lt' => 'lietuvių', |
|
| 121 | - 'lu' => 'luba-katanga', |
|
| 122 | - 'lv' => 'latviešu', |
|
| 123 | - 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | - 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | - 'mg' => 'Malagasy', |
|
| 126 | - 'mi' => 'Maori', |
|
| 127 | - 'mk' => 'македонски јазик', |
|
| 128 | - 'ml' => 'Malayalam', |
|
| 129 | - 'mn' => 'Монгол хэл', |
|
| 130 | - 'mo' => 'Moldavian', |
|
| 131 | - 'mos' => 'Moré', |
|
| 132 | - 'mr' => 'मराठी', |
|
| 133 | - 'ms' => 'Bahasa Malaysia', |
|
| 134 | - 'mt' => 'Maltese', |
|
| 135 | - 'my' => 'Burmese', |
|
| 136 | - 'na' => 'Nauru', |
|
| 137 | - 'nap' => 'napulitano', |
|
| 138 | - 'ne' => 'Nepali', |
|
| 139 | - 'nqo' => "N'ko", // www.manden.org |
|
| 140 | - 'nl' => 'Nederlands', |
|
| 141 | - 'no' => 'norsk', |
|
| 142 | - 'nb' => 'norsk bokmål', |
|
| 143 | - 'nn' => 'norsk nynorsk', |
|
| 144 | - 'oc' => 'òc', |
|
| 145 | - 'oc_lnc' => 'òc lengadocian', |
|
| 146 | - 'oc_ni' => 'òc niçard', |
|
| 147 | - 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | - 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | - 'oc_prv' => 'òc provençau', |
|
| 150 | - 'oc_gsc' => 'òc gascon', |
|
| 151 | - 'oc_lms' => 'òc lemosin', |
|
| 152 | - 'oc_auv' => 'òc auvernhat', |
|
| 153 | - 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | - 'om' => '(Afan) Oromo', |
|
| 155 | - 'or' => 'Oriya', |
|
| 156 | - 'pa' => 'Punjabi', |
|
| 157 | - 'pbb' => 'Nasa Yuwe', |
|
| 158 | - 'pl' => 'polski', |
|
| 159 | - 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | - 'ps' => 'پښتو', |
|
| 161 | - 'pt' => 'Português', |
|
| 162 | - 'pt_br' => 'Português do Brasil', |
|
| 163 | - 'qu' => 'Quechua', |
|
| 164 | - 'rm' => 'Rhaeto-Romance', |
|
| 165 | - 'rn' => 'Kirundi', |
|
| 166 | - 'ro' => 'română', |
|
| 167 | - 'roa' => "ch'ti", |
|
| 168 | - 'ru' => 'русский', |
|
| 169 | - 'rw' => 'Kinyarwanda', |
|
| 170 | - 'sa' => 'संस्कृत', |
|
| 171 | - 'sc' => 'sardu', |
|
| 172 | - 'scn' => 'sicilianu', |
|
| 173 | - 'sd' => 'Sindhi', |
|
| 174 | - 'sg' => 'Sangho', |
|
| 175 | - 'sh' => 'srpskohrvastski', |
|
| 176 | - 'sh_latn' => 'srpskohrvastski', |
|
| 177 | - 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | - 'si' => 'Sinhalese', |
|
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | - 'sm' => 'Samoan', |
|
| 182 | - 'sn' => 'Shona', |
|
| 183 | - 'so' => 'Somali', |
|
| 184 | - 'sq' => 'shqip', |
|
| 185 | - 'sr' => 'српски', |
|
| 186 | - 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | - 'sro' => 'sardu campidanésu', |
|
| 188 | - 'ss' => 'Siswati', |
|
| 189 | - 'st' => 'Sesotho', |
|
| 190 | - 'su' => 'Sundanese', |
|
| 191 | - 'sv' => 'svenska', |
|
| 192 | - 'sw' => 'Kiswahili', |
|
| 193 | - 'ta' => 'தமிழ்', // Tamil |
|
| 194 | - 'te' => 'Telugu', |
|
| 195 | - 'tg' => 'Tajik', |
|
| 196 | - 'th' => 'ไทย', |
|
| 197 | - 'ti' => 'Tigrinya', |
|
| 198 | - 'tk' => 'Turkmen', |
|
| 199 | - 'tl' => 'Tagalog', |
|
| 200 | - 'tn' => 'Setswana', |
|
| 201 | - 'to' => 'Tonga', |
|
| 202 | - 'tr' => 'Türkçe', |
|
| 203 | - 'ts' => 'Tsonga', |
|
| 204 | - 'tt' => 'Татар', |
|
| 205 | - 'tw' => 'Twi', |
|
| 206 | - 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | - 'ug' => 'Uighur', |
|
| 208 | - 'uk' => 'українська', |
|
| 209 | - 'ur' => 'ٱردو', |
|
| 210 | - 'uz' => "O'zbekcha", |
|
| 211 | - 'vi' => 'Tiếng Việt', |
|
| 212 | - 'vo' => 'Volapuk', |
|
| 213 | - 'wa' => 'walon', |
|
| 214 | - 'wo' => 'Wolof', |
|
| 215 | - 'xh' => 'Xhosa', |
|
| 216 | - 'yi' => 'Yiddish', |
|
| 217 | - 'yo' => 'Yoruba', |
|
| 218 | - 'za' => 'Zhuang', |
|
| 219 | - 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | - 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | - 'zu' => 'Zulu' |
|
| 25 | + 'aa' => 'Afar', |
|
| 26 | + 'ab' => 'Abkhazian', |
|
| 27 | + 'af' => 'Afrikaans', |
|
| 28 | + 'am' => 'Amharic', |
|
| 29 | + 'an' => 'Aragonés', |
|
| 30 | + 'ar' => 'عربي', |
|
| 31 | + 'as' => 'Assamese', |
|
| 32 | + 'ast' => 'asturianu', |
|
| 33 | + 'ay' => 'Aymara', |
|
| 34 | + 'az' => 'Azərbaycan dili', |
|
| 35 | + 'ba' => 'Bashkir', |
|
| 36 | + 'be' => 'Беларуская', |
|
| 37 | + 'ber_tam' => 'Tamazigh', |
|
| 38 | + 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | + 'bg' => 'български', |
|
| 40 | + 'bh' => 'Bihari', |
|
| 41 | + 'bi' => 'Bislama', |
|
| 42 | + 'bm' => 'Bambara', |
|
| 43 | + 'bn' => 'Bengali; Bangla', |
|
| 44 | + 'bo' => 'Tibetan', |
|
| 45 | + 'br' => 'brezhoneg', |
|
| 46 | + 'bs' => 'bosanski', |
|
| 47 | + 'ca' => 'català', |
|
| 48 | + 'co' => 'corsu', |
|
| 49 | + 'cpf' => 'Kréol réyoné', |
|
| 50 | + 'cpf_dom' => 'Kreyòl', |
|
| 51 | + 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | + 'cs' => 'čeština', |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | + 'da' => 'dansk', |
|
| 55 | + 'de' => 'Deutsch', |
|
| 56 | + 'dz' => 'Bhutani', |
|
| 57 | + 'el' => 'ελληνικά', |
|
| 58 | + 'en' => 'English', |
|
| 59 | + 'en_hx' => 'H4ck3R', |
|
| 60 | + 'en_sm' => 'Smurf', |
|
| 61 | + 'eo' => 'Esperanto', |
|
| 62 | + 'es' => 'Español', |
|
| 63 | + 'es_co' => 'Colombiano', |
|
| 64 | + 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | + 'et' => 'eesti', |
|
| 66 | + 'eu' => 'euskara', |
|
| 67 | + 'fa' => 'فارسى', |
|
| 68 | + 'ff' => 'Fulah', // peul |
|
| 69 | + 'fi' => 'suomi', |
|
| 70 | + 'fj' => 'Fiji', |
|
| 71 | + 'fo' => 'føroyskt', |
|
| 72 | + 'fon' => 'fongbè', |
|
| 73 | + 'fr' => 'français', |
|
| 74 | + 'fr_fem' => 'français féminin', |
|
| 75 | + 'fr_sc' => 'schtroumpf', |
|
| 76 | + 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | + 'fr_lsf' => 'langue des signes française', |
|
| 78 | + 'fr_spl' => 'français simplifié', |
|
| 79 | + 'fr_tu' => 'français copain', |
|
| 80 | + 'fy' => 'Frisian', |
|
| 81 | + 'ga' => 'Irish', |
|
| 82 | + 'gd' => 'Scots Gaelic', |
|
| 83 | + 'gl' => 'galego', |
|
| 84 | + 'gn' => 'Guarani', |
|
| 85 | + 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | + 'gu' => 'Gujarati', |
|
| 87 | + 'ha' => 'Hausa', |
|
| 88 | + 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | + 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | + 'haz' => 'هزاره گی', |
|
| 91 | + 'he' => 'עברית', |
|
| 92 | + 'hi' => 'हिंदी', |
|
| 93 | + 'hr' => 'hrvatski', |
|
| 94 | + 'hu' => 'magyar', |
|
| 95 | + 'hy' => 'Հայերեն',// Arménien |
|
| 96 | + 'ia' => 'Interlingua', |
|
| 97 | + 'id' => 'Indonesia', |
|
| 98 | + 'ie' => 'Interlingue', |
|
| 99 | + 'ik' => 'Inupiak', |
|
| 100 | + 'is' => 'íslenska', |
|
| 101 | + 'it' => 'italiano', |
|
| 102 | + 'it_fem' => 'italiana', |
|
| 103 | + 'iu' => 'Inuktitut', |
|
| 104 | + 'ja' => '日本語', |
|
| 105 | + 'jv' => 'Javanese', |
|
| 106 | + 'ka' => 'ქართული', |
|
| 107 | + 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | + 'kl' => 'kalaallisut', |
|
| 109 | + 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | + 'kn' => 'Kannada', |
|
| 111 | + 'ko' => '한국어', |
|
| 112 | + 'kok' => 'कोंकणी', |
|
| 113 | + 'ks' => 'Kashmiri', |
|
| 114 | + 'ku' => 'کوردی', |
|
| 115 | + 'ky' => 'Kirghiz', |
|
| 116 | + 'la' => 'lingua latina', |
|
| 117 | + 'lb' => 'Lëtzebuergesch', |
|
| 118 | + 'ln' => 'Lingala', |
|
| 119 | + 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | + 'lt' => 'lietuvių', |
|
| 121 | + 'lu' => 'luba-katanga', |
|
| 122 | + 'lv' => 'latviešu', |
|
| 123 | + 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | + 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | + 'mg' => 'Malagasy', |
|
| 126 | + 'mi' => 'Maori', |
|
| 127 | + 'mk' => 'македонски јазик', |
|
| 128 | + 'ml' => 'Malayalam', |
|
| 129 | + 'mn' => 'Монгол хэл', |
|
| 130 | + 'mo' => 'Moldavian', |
|
| 131 | + 'mos' => 'Moré', |
|
| 132 | + 'mr' => 'मराठी', |
|
| 133 | + 'ms' => 'Bahasa Malaysia', |
|
| 134 | + 'mt' => 'Maltese', |
|
| 135 | + 'my' => 'Burmese', |
|
| 136 | + 'na' => 'Nauru', |
|
| 137 | + 'nap' => 'napulitano', |
|
| 138 | + 'ne' => 'Nepali', |
|
| 139 | + 'nqo' => "N'ko", // www.manden.org |
|
| 140 | + 'nl' => 'Nederlands', |
|
| 141 | + 'no' => 'norsk', |
|
| 142 | + 'nb' => 'norsk bokmål', |
|
| 143 | + 'nn' => 'norsk nynorsk', |
|
| 144 | + 'oc' => 'òc', |
|
| 145 | + 'oc_lnc' => 'òc lengadocian', |
|
| 146 | + 'oc_ni' => 'òc niçard', |
|
| 147 | + 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | + 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | + 'oc_prv' => 'òc provençau', |
|
| 150 | + 'oc_gsc' => 'òc gascon', |
|
| 151 | + 'oc_lms' => 'òc lemosin', |
|
| 152 | + 'oc_auv' => 'òc auvernhat', |
|
| 153 | + 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | + 'om' => '(Afan) Oromo', |
|
| 155 | + 'or' => 'Oriya', |
|
| 156 | + 'pa' => 'Punjabi', |
|
| 157 | + 'pbb' => 'Nasa Yuwe', |
|
| 158 | + 'pl' => 'polski', |
|
| 159 | + 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | + 'ps' => 'پښتو', |
|
| 161 | + 'pt' => 'Português', |
|
| 162 | + 'pt_br' => 'Português do Brasil', |
|
| 163 | + 'qu' => 'Quechua', |
|
| 164 | + 'rm' => 'Rhaeto-Romance', |
|
| 165 | + 'rn' => 'Kirundi', |
|
| 166 | + 'ro' => 'română', |
|
| 167 | + 'roa' => "ch'ti", |
|
| 168 | + 'ru' => 'русский', |
|
| 169 | + 'rw' => 'Kinyarwanda', |
|
| 170 | + 'sa' => 'संस्कृत', |
|
| 171 | + 'sc' => 'sardu', |
|
| 172 | + 'scn' => 'sicilianu', |
|
| 173 | + 'sd' => 'Sindhi', |
|
| 174 | + 'sg' => 'Sangho', |
|
| 175 | + 'sh' => 'srpskohrvastski', |
|
| 176 | + 'sh_latn' => 'srpskohrvastski', |
|
| 177 | + 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | + 'si' => 'Sinhalese', |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | + 'sm' => 'Samoan', |
|
| 182 | + 'sn' => 'Shona', |
|
| 183 | + 'so' => 'Somali', |
|
| 184 | + 'sq' => 'shqip', |
|
| 185 | + 'sr' => 'српски', |
|
| 186 | + 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | + 'sro' => 'sardu campidanésu', |
|
| 188 | + 'ss' => 'Siswati', |
|
| 189 | + 'st' => 'Sesotho', |
|
| 190 | + 'su' => 'Sundanese', |
|
| 191 | + 'sv' => 'svenska', |
|
| 192 | + 'sw' => 'Kiswahili', |
|
| 193 | + 'ta' => 'தமிழ்', // Tamil |
|
| 194 | + 'te' => 'Telugu', |
|
| 195 | + 'tg' => 'Tajik', |
|
| 196 | + 'th' => 'ไทย', |
|
| 197 | + 'ti' => 'Tigrinya', |
|
| 198 | + 'tk' => 'Turkmen', |
|
| 199 | + 'tl' => 'Tagalog', |
|
| 200 | + 'tn' => 'Setswana', |
|
| 201 | + 'to' => 'Tonga', |
|
| 202 | + 'tr' => 'Türkçe', |
|
| 203 | + 'ts' => 'Tsonga', |
|
| 204 | + 'tt' => 'Татар', |
|
| 205 | + 'tw' => 'Twi', |
|
| 206 | + 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | + 'ug' => 'Uighur', |
|
| 208 | + 'uk' => 'українська', |
|
| 209 | + 'ur' => 'ٱردو', |
|
| 210 | + 'uz' => "O'zbekcha", |
|
| 211 | + 'vi' => 'Tiếng Việt', |
|
| 212 | + 'vo' => 'Volapuk', |
|
| 213 | + 'wa' => 'walon', |
|
| 214 | + 'wo' => 'Wolof', |
|
| 215 | + 'xh' => 'Xhosa', |
|
| 216 | + 'yi' => 'Yiddish', |
|
| 217 | + 'yo' => 'Yoruba', |
|
| 218 | + 'za' => 'Zhuang', |
|
| 219 | + 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | + 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | + 'zu' => 'Zulu' |
|
| 222 | 222 | |
| 223 | 223 | ]; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'cpf_dom' => 'Kreyòl', |
| 51 | 51 | 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
| 52 | 52 | 'cs' => 'čeština', |
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | 54 | 'da' => 'dansk', |
| 55 | 55 | 'de' => 'Deutsch', |
| 56 | 56 | 'dz' => 'Bhutani', |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | 'hi' => 'हिंदी', |
| 93 | 93 | 'hr' => 'hrvatski', |
| 94 | 94 | 'hu' => 'magyar', |
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 95 | + 'hy' => 'Հայերեն', // Arménien |
|
| 96 | 96 | 'ia' => 'Interlingua', |
| 97 | 97 | 'id' => 'Indonesia', |
| 98 | 98 | 'ie' => 'Interlingue', |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'ka' => 'ქართული', |
| 107 | 107 | 'kk' => 'қазақ тілі', // Kazakh |
| 108 | 108 | 'kl' => 'kalaallisut', |
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 109 | + 'km' => 'ភាសាខ្មែរ', // Khmer |
|
| 110 | 110 | 'kn' => 'Kannada', |
| 111 | 111 | 'ko' => '한국어', |
| 112 | 112 | 'kok' => 'कोंकणी', |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | 'sh_latn' => 'srpskohrvastski', |
| 177 | 177 | 'sh_cyrl' => 'Српскохрватски', |
| 178 | 178 | 'si' => 'Sinhalese', |
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | 181 | 'sm' => 'Samoan', |
| 182 | 182 | 'sn' => 'Shona', |
| 183 | 183 | 'so' => 'Somali', |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | if (strncmp($url, 'configurer_', 11) == 0) { |
| 336 | 336 | $deja[$url] = $b; |
| 337 | 337 | } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
| 338 | - $deja['configurer_' . $match[1]] = $b; |
|
| 338 | + $deja['configurer_'.$match[1]] = $b; |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } |
@@ -348,10 +348,10 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | // trouver toutes les pages configurer_xxx de l'espace prive |
| 350 | 350 | // et construire un tableau des entrees qui ne sont pas dans $deja |
| 351 | - $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 351 | + $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]'._EXTENSION_SQUELETTES.'$'); |
|
| 352 | 352 | |
| 353 | 353 | foreach ($pages as $page) { |
| 354 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 354 | + $configurer = basename($page, '.'._EXTENSION_SQUELETTES); |
|
| 355 | 355 | if (!isset($exclure[$configurer])) { |
| 356 | 356 | $liste[$configurer] = [ |
| 357 | 357 | 'parent' => 'bando_configuration', |
@@ -371,9 +371,9 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | // trouver tous les formulaires/configurer_ |
| 373 | 373 | // et construire un tableau des entrees |
| 374 | - $pages = find_all_in_path('formulaires/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 374 | + $pages = find_all_in_path('formulaires/', 'configurer_.*[.]'._EXTENSION_SQUELETTES.'$'); |
|
| 375 | 375 | foreach ($pages as $page) { |
| 376 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 376 | + $configurer = basename($page, '.'._EXTENSION_SQUELETTES); |
|
| 377 | 377 | if ( |
| 378 | 378 | !isset($forms[$configurer]) |
| 379 | 379 | and !isset($liste[$configurer]) |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | $liste[$configurer] = [ |
| 383 | 383 | 'parent' => 'bando_configuration', |
| 384 | 384 | 'url' => 'configurer', |
| 385 | - 'args' => 'cfg=' . substr($configurer, 11), |
|
| 385 | + 'args' => 'cfg='.substr($configurer, 11), |
|
| 386 | 386 | 'titre' => _T("configurer:{$configurer}_titre"), |
| 387 | 387 | 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
| 388 | 388 | ]; |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | |
| 415 | 415 | // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
| 416 | 416 | // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
| 417 | - $config = basename(substr($file, 0, -strlen('.' . _EXTENSION_SQUELETTES))); |
|
| 418 | - spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 417 | + $config = basename(substr($file, 0, -strlen('.'._EXTENSION_SQUELETTES))); |
|
| 418 | + spip_log('Calcul de '."prive/squelettes/contenu/$config"); |
|
| 419 | 419 | $fond = recuperer_fond("prive/squelettes/contenu/$config", ['exec' => $config]); |
| 420 | 420 | |
| 421 | 421 | // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
@@ -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 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function inc_config_dist() { |
| 31 | - actualise_metas(liste_metas()); |
|
| 31 | + actualise_metas(liste_metas()); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -45,34 +45,34 @@ discard block |
||
| 45 | 45 | * Liste (table, casier, sous_casier) |
| 46 | 46 | */ |
| 47 | 47 | function expliquer_config($cfg) { |
| 48 | - // par defaut, sur la table des meta |
|
| 49 | - $table = 'meta'; |
|
| 50 | - $casier = null; |
|
| 51 | - $sous_casier = []; |
|
| 52 | - $cfg = explode('/', $cfg); |
|
| 53 | - |
|
| 54 | - // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | - if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | - array_shift($cfg); |
|
| 57 | - $table = array_shift($cfg); |
|
| 58 | - if (!isset($GLOBALS[$table])) { |
|
| 59 | - lire_metas($table); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | - if (count($cfg)) { |
|
| 65 | - // pas sur un appel vide '' |
|
| 66 | - if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | - $casier = $c; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - if (count($cfg)) { |
|
| 72 | - $sous_casier = $cfg; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - return [$table, $casier, $sous_casier]; |
|
| 48 | + // par defaut, sur la table des meta |
|
| 49 | + $table = 'meta'; |
|
| 50 | + $casier = null; |
|
| 51 | + $sous_casier = []; |
|
| 52 | + $cfg = explode('/', $cfg); |
|
| 53 | + |
|
| 54 | + // si le premier argument est vide, c'est une syntaxe /table/ ou un appel vide '' |
|
| 55 | + if (!reset($cfg) and count($cfg) > 1) { |
|
| 56 | + array_shift($cfg); |
|
| 57 | + $table = array_shift($cfg); |
|
| 58 | + if (!isset($GLOBALS[$table])) { |
|
| 59 | + lire_metas($table); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 64 | + if (count($cfg)) { |
|
| 65 | + // pas sur un appel vide '' |
|
| 66 | + if ('' !== ($c = array_shift($cfg))) { |
|
| 67 | + $casier = $c; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + if (count($cfg)) { |
|
| 72 | + $sous_casier = $cfg; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + return [$table, $casier, $sous_casier]; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -100,65 +100,65 @@ discard block |
||
| 100 | 100 | * Contenu de la configuration obtenue |
| 101 | 101 | */ |
| 102 | 102 | function lire_config($cfg = '', $def = null, $unserialize = true) { |
| 103 | - // lire le stockage sous la forme /table/valeur |
|
| 104 | - // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | - // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | - |
|
| 107 | - // traiter en priorite le cas simple et frequent |
|
| 108 | - // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | - if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | - $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | - ((!$unserialize |
|
| 112 | - // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | - or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | - // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | - or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | - or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | - : $def; |
|
| 118 | - |
|
| 119 | - return $r; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - // Brancher sur methodes externes si besoin |
|
| 123 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | - $methode = substr($cfg, 0, $p); |
|
| 125 | - $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | - |
|
| 127 | - return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 131 | - |
|
| 132 | - if (!isset($GLOBALS[$table])) { |
|
| 133 | - return $def; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - $r = $GLOBALS[$table]; |
|
| 137 | - |
|
| 138 | - // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | - if (!$casier) { |
|
| 140 | - return $unserialize ? $r : serialize($r); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // casier principal : |
|
| 144 | - // le deserializer si demande |
|
| 145 | - // ou si on a besoin |
|
| 146 | - // d'un sous casier |
|
| 147 | - $r = $r[$casier] ?? null; |
|
| 148 | - if (($unserialize or is_countable($sous_casier) ? count($sous_casier) : 0) and $r and is_string($r)) { |
|
| 149 | - $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - // aller chercher le sous_casier |
|
| 153 | - while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | - $r = $r[$casier] ?? null; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (is_null($r)) { |
|
| 158 | - return $def; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return $r; |
|
| 103 | + // lire le stockage sous la forme /table/valeur |
|
| 104 | + // ou valeur qui est en fait implicitement /meta/valeur |
|
| 105 | + // ou casier/valeur qui est en fait implicitement /meta/casier/valeur |
|
| 106 | + |
|
| 107 | + // traiter en priorite le cas simple et frequent |
|
| 108 | + // de lecture direct $GLOBALS['meta']['truc'], si $cfg ne contient ni / ni : |
|
| 109 | + if ($cfg and strpbrk($cfg, '/:') === false) { |
|
| 110 | + $r = isset($GLOBALS['meta'][$cfg]) ? |
|
| 111 | + ((!$unserialize |
|
| 112 | + // ne pas essayer de deserialiser autre chose qu'une chaine |
|
| 113 | + or !is_string($GLOBALS['meta'][$cfg]) |
|
| 114 | + // ne pas essayer de deserialiser si ce n'est visiblement pas une chaine serializee |
|
| 115 | + or strpos($GLOBALS['meta'][$cfg], ':') === false |
|
| 116 | + or ($t = @unserialize($GLOBALS['meta'][$cfg])) === false) ? $GLOBALS['meta'][$cfg] : $t) |
|
| 117 | + : $def; |
|
| 118 | + |
|
| 119 | + return $r; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + // Brancher sur methodes externes si besoin |
|
| 123 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 124 | + $methode = substr($cfg, 0, $p); |
|
| 125 | + $lire_config = charger_fonction($methode, 'lire_config'); |
|
| 126 | + |
|
| 127 | + return $lire_config(substr($cfg, $p + 2), $def, $unserialize); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 131 | + |
|
| 132 | + if (!isset($GLOBALS[$table])) { |
|
| 133 | + return $def; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + $r = $GLOBALS[$table]; |
|
| 137 | + |
|
| 138 | + // si on a demande #CONFIG{/meta,'',0} |
|
| 139 | + if (!$casier) { |
|
| 140 | + return $unserialize ? $r : serialize($r); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // casier principal : |
|
| 144 | + // le deserializer si demande |
|
| 145 | + // ou si on a besoin |
|
| 146 | + // d'un sous casier |
|
| 147 | + $r = $r[$casier] ?? null; |
|
| 148 | + if (($unserialize or is_countable($sous_casier) ? count($sous_casier) : 0) and $r and is_string($r)) { |
|
| 149 | + $r = (($t = @unserialize($r)) === false ? $r : $t); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + // aller chercher le sous_casier |
|
| 153 | + while (!is_null($r) and $casier = array_shift($sous_casier)) { |
|
| 154 | + $r = $r[$casier] ?? null; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (is_null($r)) { |
|
| 158 | + return $def; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return $r; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @return mixed |
| 173 | 173 | */ |
| 174 | 174 | function lire_config_metapack_dist($cfg = '', $def = null, $unserialize = true) { |
| 175 | - return lire_config($cfg, $def, $unserialize); |
|
| 175 | + return lire_config($cfg, $def, $unserialize); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -184,106 +184,106 @@ discard block |
||
| 184 | 184 | * @return bool |
| 185 | 185 | */ |
| 186 | 186 | function ecrire_config($cfg, $store) { |
| 187 | - // Brancher sur methodes externes si besoin |
|
| 188 | - if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | - $methode = substr($cfg, 0, $p); |
|
| 190 | - $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | - |
|
| 192 | - return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 196 | - // il faut au moins un casier pour ecrire |
|
| 197 | - if (!$casier) { |
|
| 198 | - return false; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - // trouvons ou creons le pointeur sur le casier |
|
| 202 | - $st = $GLOBALS[$table][$casier] ?? null; |
|
| 203 | - if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | - if ($st === null) { |
|
| 205 | - // ne rien creer si c'est une demande d'effacement |
|
| 206 | - if ($store === null) { |
|
| 207 | - return false; |
|
| 208 | - } |
|
| 209 | - $st = []; |
|
| 210 | - } else { |
|
| 211 | - $st = unserialize($st); |
|
| 212 | - if ($st === false) { |
|
| 213 | - // ne rien creer si c'est une demande d'effacement |
|
| 214 | - if ($store === null) { |
|
| 215 | - return false; |
|
| 216 | - } |
|
| 217 | - $st = []; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - // si on a affaire a un sous caiser |
|
| 223 | - // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 224 | - if ($c = $sous_casier) { |
|
| 225 | - $sc = &$st; |
|
| 226 | - $pointeurs = []; |
|
| 227 | - while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) { |
|
| 228 | - // creer l'entree si elle n'existe pas |
|
| 229 | - if (!isset($sc[$cc])) { |
|
| 230 | - // si on essaye d'effacer une config qui n'existe pas |
|
| 231 | - // ne rien creer mais sortir |
|
| 232 | - if (is_null($store)) { |
|
| 233 | - return false; |
|
| 234 | - } |
|
| 235 | - $sc[$cc] = []; |
|
| 236 | - } |
|
| 237 | - $pointeurs[$cc] = &$sc; |
|
| 238 | - $sc = &$sc[$cc]; |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - // si c'est une demande d'effacement |
|
| 242 | - if (is_null($store)) { |
|
| 243 | - $c = $sous_casier; |
|
| 244 | - $sous = array_pop($c); |
|
| 245 | - // effacer, et remonter pour effacer les parents vides |
|
| 246 | - do { |
|
| 247 | - unset($pointeurs[$sous][$sous]); |
|
| 248 | - } while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 249 | - |
|
| 250 | - // si on a vide tous les sous casiers, |
|
| 251 | - // et que le casier est vide |
|
| 252 | - // vider aussi la meta |
|
| 253 | - if (!$sous and !(is_countable($st) ? count($st) : 0)) { |
|
| 254 | - $st = null; |
|
| 255 | - } |
|
| 256 | - } // dans tous les autres cas, on ecrase |
|
| 257 | - else { |
|
| 258 | - $sc = $store; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // Maintenant que $st est modifiee |
|
| 262 | - // reprenons la comme valeur a stocker dans le casier principal |
|
| 263 | - $store = $st; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - if (is_null($store)) { |
|
| 267 | - if (is_null($st) and !$sous_casier) { |
|
| 268 | - return false; |
|
| 269 | - } // la config n'existait deja pas ! |
|
| 270 | - effacer_meta($casier, $table); |
|
| 271 | - supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 272 | - } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 273 | - else { |
|
| 274 | - if (!isset($GLOBALS[$table])) { |
|
| 275 | - installer_table_meta($table); |
|
| 276 | - } |
|
| 277 | - // si ce n'est pas une chaine |
|
| 278 | - // il faut serializer |
|
| 279 | - if (!is_string($store)) { |
|
| 280 | - $store = serialize($store); |
|
| 281 | - } |
|
| 282 | - ecrire_meta($casier, $store, null, $table); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - // verifier que lire_config($cfg)==$store ? |
|
| 286 | - return true; |
|
| 187 | + // Brancher sur methodes externes si besoin |
|
| 188 | + if ($cfg and $p = strpos($cfg, '::')) { |
|
| 189 | + $methode = substr($cfg, 0, $p); |
|
| 190 | + $ecrire_config = charger_fonction($methode, 'ecrire_config'); |
|
| 191 | + |
|
| 192 | + return $ecrire_config(substr($cfg, $p + 2), $store); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + [$table, $casier, $sous_casier] = expliquer_config($cfg); |
|
| 196 | + // il faut au moins un casier pour ecrire |
|
| 197 | + if (!$casier) { |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + // trouvons ou creons le pointeur sur le casier |
|
| 202 | + $st = $GLOBALS[$table][$casier] ?? null; |
|
| 203 | + if (!is_array($st) and ($sous_casier or is_array($store))) { |
|
| 204 | + if ($st === null) { |
|
| 205 | + // ne rien creer si c'est une demande d'effacement |
|
| 206 | + if ($store === null) { |
|
| 207 | + return false; |
|
| 208 | + } |
|
| 209 | + $st = []; |
|
| 210 | + } else { |
|
| 211 | + $st = unserialize($st); |
|
| 212 | + if ($st === false) { |
|
| 213 | + // ne rien creer si c'est une demande d'effacement |
|
| 214 | + if ($store === null) { |
|
| 215 | + return false; |
|
| 216 | + } |
|
| 217 | + $st = []; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + // si on a affaire a un sous caiser |
|
| 223 | + // il faut ecrire au bon endroit sans perdre les autres sous casier freres |
|
| 224 | + if ($c = $sous_casier) { |
|
| 225 | + $sc = &$st; |
|
| 226 | + $pointeurs = []; |
|
| 227 | + while (is_countable($c) ? count($c) : 0 and $cc = array_shift($c)) { |
|
| 228 | + // creer l'entree si elle n'existe pas |
|
| 229 | + if (!isset($sc[$cc])) { |
|
| 230 | + // si on essaye d'effacer une config qui n'existe pas |
|
| 231 | + // ne rien creer mais sortir |
|
| 232 | + if (is_null($store)) { |
|
| 233 | + return false; |
|
| 234 | + } |
|
| 235 | + $sc[$cc] = []; |
|
| 236 | + } |
|
| 237 | + $pointeurs[$cc] = &$sc; |
|
| 238 | + $sc = &$sc[$cc]; |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + // si c'est une demande d'effacement |
|
| 242 | + if (is_null($store)) { |
|
| 243 | + $c = $sous_casier; |
|
| 244 | + $sous = array_pop($c); |
|
| 245 | + // effacer, et remonter pour effacer les parents vides |
|
| 246 | + do { |
|
| 247 | + unset($pointeurs[$sous][$sous]); |
|
| 248 | + } while ($sous = array_pop($c) and !(is_countable($pointeurs[$sous][$sous]) ? count($pointeurs[$sous][$sous]) : 0)); |
|
| 249 | + |
|
| 250 | + // si on a vide tous les sous casiers, |
|
| 251 | + // et que le casier est vide |
|
| 252 | + // vider aussi la meta |
|
| 253 | + if (!$sous and !(is_countable($st) ? count($st) : 0)) { |
|
| 254 | + $st = null; |
|
| 255 | + } |
|
| 256 | + } // dans tous les autres cas, on ecrase |
|
| 257 | + else { |
|
| 258 | + $sc = $store; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // Maintenant que $st est modifiee |
|
| 262 | + // reprenons la comme valeur a stocker dans le casier principal |
|
| 263 | + $store = $st; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + if (is_null($store)) { |
|
| 267 | + if (is_null($st) and !$sous_casier) { |
|
| 268 | + return false; |
|
| 269 | + } // la config n'existait deja pas ! |
|
| 270 | + effacer_meta($casier, $table); |
|
| 271 | + supprimer_table_meta($table); // supprimons la table (si elle est bien vide) |
|
| 272 | + } // les meta ne peuvent etre que des chaines : il faut serializer le reste |
|
| 273 | + else { |
|
| 274 | + if (!isset($GLOBALS[$table])) { |
|
| 275 | + installer_table_meta($table); |
|
| 276 | + } |
|
| 277 | + // si ce n'est pas une chaine |
|
| 278 | + // il faut serializer |
|
| 279 | + if (!is_string($store)) { |
|
| 280 | + $store = serialize($store); |
|
| 281 | + } |
|
| 282 | + ecrire_meta($casier, $store, null, $table); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + // verifier que lire_config($cfg)==$store ? |
|
| 286 | + return true; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | |
@@ -297,14 +297,14 @@ discard block |
||
| 297 | 297 | * @return bool |
| 298 | 298 | */ |
| 299 | 299 | function ecrire_config_metapack_dist($cfg, $store) { |
| 300 | - // cas particulier en metapack:: |
|
| 301 | - // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 302 | - // intacte en sortie ... |
|
| 303 | - if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 304 | - $store = serialize($store); |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return ecrire_config($cfg, $store); |
|
| 300 | + // cas particulier en metapack:: |
|
| 301 | + // si on ecrit une chaine deja serializee, il faut la reserializer pour la rendre |
|
| 302 | + // intacte en sortie ... |
|
| 303 | + if (is_string($store) and strpos($store, ':') and unserialize($store)) { |
|
| 304 | + $store = serialize($store); |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + return ecrire_config($cfg, $store); |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | 310 | /** |
@@ -314,9 +314,9 @@ discard block |
||
| 314 | 314 | * @return bool |
| 315 | 315 | */ |
| 316 | 316 | function effacer_config($cfg) { |
| 317 | - ecrire_config($cfg, null); |
|
| 317 | + ecrire_config($cfg, null); |
|
| 318 | 318 | |
| 319 | - return true; |
|
| 319 | + return true; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -333,71 +333,71 @@ discard block |
||
| 333 | 333 | * @return array |
| 334 | 334 | */ |
| 335 | 335 | function lister_configurer($exclure = []) { |
| 336 | - return []; |
|
| 337 | - |
|
| 338 | - // lister les pages de config deja dans les menus |
|
| 339 | - $deja = []; |
|
| 340 | - foreach ($exclure as $id => $b) { |
|
| 341 | - $url = ($b['url'] ?: $id); |
|
| 342 | - if (!$b['url'] or !isset($exclure[$url])) { |
|
| 343 | - if (strncmp($url, 'configurer_', 11) == 0) { |
|
| 344 | - $deja[$url] = $b; |
|
| 345 | - } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
|
| 346 | - $deja['configurer_' . $match[1]] = $b; |
|
| 347 | - } |
|
| 348 | - } |
|
| 349 | - } |
|
| 350 | - $exclure = $exclure + $deja; |
|
| 351 | - |
|
| 352 | - $icone_defaut = 'images/configuration-16.png'; |
|
| 353 | - $liste = []; |
|
| 354 | - $skels = []; |
|
| 355 | - $forms = []; |
|
| 356 | - |
|
| 357 | - // trouver toutes les pages configurer_xxx de l'espace prive |
|
| 358 | - // et construire un tableau des entrees qui ne sont pas dans $deja |
|
| 359 | - $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 360 | - |
|
| 361 | - foreach ($pages as $page) { |
|
| 362 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 363 | - if (!isset($exclure[$configurer])) { |
|
| 364 | - $liste[$configurer] = [ |
|
| 365 | - 'parent' => 'bando_configuration', |
|
| 366 | - 'url' => $configurer, |
|
| 367 | - 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 368 | - 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 369 | - ]; |
|
| 370 | - } |
|
| 371 | - $skels[$configurer] = $page; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - // analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus |
|
| 375 | - foreach ($skels as $file) { |
|
| 376 | - $forms = array_merge($forms, lister_formulaires_configurer($file)); |
|
| 377 | - } |
|
| 378 | - $forms = array_flip($forms); |
|
| 379 | - |
|
| 380 | - // trouver tous les formulaires/configurer_ |
|
| 381 | - // et construire un tableau des entrees |
|
| 382 | - $pages = find_all_in_path('formulaires/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 383 | - foreach ($pages as $page) { |
|
| 384 | - $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 385 | - if ( |
|
| 386 | - !isset($forms[$configurer]) |
|
| 387 | - and !isset($liste[$configurer]) |
|
| 388 | - and !isset($exclure[$configurer]) |
|
| 389 | - ) { |
|
| 390 | - $liste[$configurer] = [ |
|
| 391 | - 'parent' => 'bando_configuration', |
|
| 392 | - 'url' => 'configurer', |
|
| 393 | - 'args' => 'cfg=' . substr($configurer, 11), |
|
| 394 | - 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 395 | - 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 396 | - ]; |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - return $liste; |
|
| 336 | + return []; |
|
| 337 | + |
|
| 338 | + // lister les pages de config deja dans les menus |
|
| 339 | + $deja = []; |
|
| 340 | + foreach ($exclure as $id => $b) { |
|
| 341 | + $url = ($b['url'] ?: $id); |
|
| 342 | + if (!$b['url'] or !isset($exclure[$url])) { |
|
| 343 | + if (strncmp($url, 'configurer_', 11) == 0) { |
|
| 344 | + $deja[$url] = $b; |
|
| 345 | + } elseif ($b['url'] == 'configurer' and preg_match(',cfg=([a-z0-9_]+),i', $b['args'], $match)) { |
|
| 346 | + $deja['configurer_' . $match[1]] = $b; |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | + $exclure = $exclure + $deja; |
|
| 351 | + |
|
| 352 | + $icone_defaut = 'images/configuration-16.png'; |
|
| 353 | + $liste = []; |
|
| 354 | + $skels = []; |
|
| 355 | + $forms = []; |
|
| 356 | + |
|
| 357 | + // trouver toutes les pages configurer_xxx de l'espace prive |
|
| 358 | + // et construire un tableau des entrees qui ne sont pas dans $deja |
|
| 359 | + $pages = find_all_in_path('prive/squelettes/contenu/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 360 | + |
|
| 361 | + foreach ($pages as $page) { |
|
| 362 | + $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 363 | + if (!isset($exclure[$configurer])) { |
|
| 364 | + $liste[$configurer] = [ |
|
| 365 | + 'parent' => 'bando_configuration', |
|
| 366 | + 'url' => $configurer, |
|
| 367 | + 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 368 | + 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 369 | + ]; |
|
| 370 | + } |
|
| 371 | + $skels[$configurer] = $page; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + // analyser la liste des $skels pour voir les #FORMULAIRE_CONFIGURER_ inclus |
|
| 375 | + foreach ($skels as $file) { |
|
| 376 | + $forms = array_merge($forms, lister_formulaires_configurer($file)); |
|
| 377 | + } |
|
| 378 | + $forms = array_flip($forms); |
|
| 379 | + |
|
| 380 | + // trouver tous les formulaires/configurer_ |
|
| 381 | + // et construire un tableau des entrees |
|
| 382 | + $pages = find_all_in_path('formulaires/', 'configurer_.*[.]' . _EXTENSION_SQUELETTES . '$'); |
|
| 383 | + foreach ($pages as $page) { |
|
| 384 | + $configurer = basename($page, '.' . _EXTENSION_SQUELETTES); |
|
| 385 | + if ( |
|
| 386 | + !isset($forms[$configurer]) |
|
| 387 | + and !isset($liste[$configurer]) |
|
| 388 | + and !isset($exclure[$configurer]) |
|
| 389 | + ) { |
|
| 390 | + $liste[$configurer] = [ |
|
| 391 | + 'parent' => 'bando_configuration', |
|
| 392 | + 'url' => 'configurer', |
|
| 393 | + 'args' => 'cfg=' . substr($configurer, 11), |
|
| 394 | + 'titre' => _T("configurer:{$configurer}_titre"), |
|
| 395 | + 'icone' => find_in_theme($i = "images/{$configurer}-16.png") ? $i : $icone_defaut, |
|
| 396 | + ]; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + return $liste; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
@@ -411,35 +411,35 @@ discard block |
||
| 411 | 411 | * Liste des formulaires trouvés |
| 412 | 412 | **/ |
| 413 | 413 | function lister_formulaires_configurer($file) { |
| 414 | - $forms = []; |
|
| 415 | - |
|
| 416 | - lire_fichier($file, $skel); |
|
| 417 | - if (preg_match_all(',#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),', $skel, $matches, PREG_SET_ORDER)) { |
|
| 418 | - $matches = array_map('end', $matches); |
|
| 419 | - $matches = array_map('strtolower', $matches); |
|
| 420 | - $forms = array_merge($forms, $matches); |
|
| 421 | - } |
|
| 422 | - |
|
| 423 | - // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
|
| 424 | - // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
|
| 425 | - $config = basename(substr($file, 0, -strlen('.' . _EXTENSION_SQUELETTES))); |
|
| 426 | - spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 427 | - $fond = recuperer_fond("prive/squelettes/contenu/$config", ['exec' => $config]); |
|
| 428 | - |
|
| 429 | - // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
|
| 430 | - // et donc que l'on puisse les referencer aussi ! |
|
| 431 | - $fond = pipeline('affiche_milieu', ['args' => ['exec' => $config], 'data' => $fond]); |
|
| 432 | - |
|
| 433 | - // recuperer les noms des formulaires presents. |
|
| 434 | - if (is_array($inputs = extraire_balises($fond, 'input'))) { |
|
| 435 | - foreach ($inputs as $i) { |
|
| 436 | - if (extraire_attribut($i, 'name') == 'formulaire_action') { |
|
| 437 | - $forms[] = ($c = extraire_attribut($i, 'value')); |
|
| 438 | - } |
|
| 439 | - } |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return $forms; |
|
| 414 | + $forms = []; |
|
| 415 | + |
|
| 416 | + lire_fichier($file, $skel); |
|
| 417 | + if (preg_match_all(',#FORMULAIRE_(CONFIGURER_[A-Z0-9_]*),', $skel, $matches, PREG_SET_ORDER)) { |
|
| 418 | + $matches = array_map('end', $matches); |
|
| 419 | + $matches = array_map('strtolower', $matches); |
|
| 420 | + $forms = array_merge($forms, $matches); |
|
| 421 | + } |
|
| 422 | + |
|
| 423 | + // evaluer le fond en lui passant un exec coherent pour que les pipelines le reconnaissent |
|
| 424 | + // et reperer les formulaires CVT configurer_xx insereres par les plugins via pipeline |
|
| 425 | + $config = basename(substr($file, 0, -strlen('.' . _EXTENSION_SQUELETTES))); |
|
| 426 | + spip_log('Calcul de ' . "prive/squelettes/contenu/$config"); |
|
| 427 | + $fond = recuperer_fond("prive/squelettes/contenu/$config", ['exec' => $config]); |
|
| 428 | + |
|
| 429 | + // passer dans le pipeline affiche_milieu pour que les plugins puissent ajouter leur formulaires... |
|
| 430 | + // et donc que l'on puisse les referencer aussi ! |
|
| 431 | + $fond = pipeline('affiche_milieu', ['args' => ['exec' => $config], 'data' => $fond]); |
|
| 432 | + |
|
| 433 | + // recuperer les noms des formulaires presents. |
|
| 434 | + if (is_array($inputs = extraire_balises($fond, 'input'))) { |
|
| 435 | + foreach ($inputs as $i) { |
|
| 436 | + if (extraire_attribut($i, 'name') == 'formulaire_action') { |
|
| 437 | + $forms[] = ($c = extraire_attribut($i, 'value')); |
|
| 438 | + } |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return $forms; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | |
@@ -457,58 +457,58 @@ discard block |
||
| 457 | 457 | * Couples nom de la `meta` => valeur par défaut |
| 458 | 458 | */ |
| 459 | 459 | function liste_metas() { |
| 460 | - return pipeline('configurer_liste_metas', [ |
|
| 461 | - 'nom_site' => _T('info_mon_site_spip'), |
|
| 462 | - 'slogan_site' => '', |
|
| 463 | - 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 464 | - 'descriptif_site' => '', |
|
| 465 | - 'activer_logos' => 'oui', |
|
| 466 | - 'activer_logos_survol' => 'non', |
|
| 467 | - 'articles_surtitre' => 'non', |
|
| 468 | - 'articles_soustitre' => 'non', |
|
| 469 | - 'articles_descriptif' => 'non', |
|
| 470 | - 'articles_chapeau' => 'non', |
|
| 471 | - 'articles_texte' => 'oui', |
|
| 472 | - 'articles_ps' => 'non', |
|
| 473 | - 'articles_redac' => 'non', |
|
| 474 | - 'post_dates' => 'non', |
|
| 475 | - 'articles_urlref' => 'non', |
|
| 476 | - 'articles_redirection' => 'non', |
|
| 477 | - 'creer_preview' => 'non', |
|
| 478 | - 'taille_preview' => 150, |
|
| 479 | - 'articles_modif' => 'non', |
|
| 480 | - |
|
| 481 | - 'rubriques_descriptif' => 'non', |
|
| 482 | - 'rubriques_texte' => 'oui', |
|
| 483 | - |
|
| 484 | - 'accepter_inscriptions' => 'non', |
|
| 485 | - 'accepter_visiteurs' => 'non', |
|
| 486 | - 'prevenir_auteurs' => 'non', |
|
| 487 | - 'suivi_edito' => 'non', |
|
| 488 | - 'adresse_suivi' => '', |
|
| 489 | - 'adresse_suivi_inscription' => '', |
|
| 490 | - 'adresse_neuf' => '', |
|
| 491 | - 'jours_neuf' => '', |
|
| 492 | - 'quoi_de_neuf' => 'non', |
|
| 493 | - 'preview' => ',0minirezo,1comite,', |
|
| 494 | - |
|
| 495 | - 'syndication_integrale' => 'oui', |
|
| 496 | - 'charset' => _DEFAULT_CHARSET, |
|
| 497 | - 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 498 | - |
|
| 499 | - 'multi_rubriques' => 'non', |
|
| 500 | - 'multi_secteurs' => 'non', |
|
| 501 | - 'gerer_trad' => 'non', |
|
| 502 | - 'langues_multilingue' => '', |
|
| 503 | - |
|
| 504 | - 'version_html_max' => 'html4', |
|
| 505 | - |
|
| 506 | - 'type_urls' => 'page', |
|
| 507 | - |
|
| 508 | - 'email_envoi' => '', |
|
| 509 | - 'email_webmaster' => '', |
|
| 510 | - 'auto_compress_http' => 'non', |
|
| 511 | - ]); |
|
| 460 | + return pipeline('configurer_liste_metas', [ |
|
| 461 | + 'nom_site' => _T('info_mon_site_spip'), |
|
| 462 | + 'slogan_site' => '', |
|
| 463 | + 'adresse_site' => preg_replace(',/$,', '', url_de_base()), |
|
| 464 | + 'descriptif_site' => '', |
|
| 465 | + 'activer_logos' => 'oui', |
|
| 466 | + 'activer_logos_survol' => 'non', |
|
| 467 | + 'articles_surtitre' => 'non', |
|
| 468 | + 'articles_soustitre' => 'non', |
|
| 469 | + 'articles_descriptif' => 'non', |
|
| 470 | + 'articles_chapeau' => 'non', |
|
| 471 | + 'articles_texte' => 'oui', |
|
| 472 | + 'articles_ps' => 'non', |
|
| 473 | + 'articles_redac' => 'non', |
|
| 474 | + 'post_dates' => 'non', |
|
| 475 | + 'articles_urlref' => 'non', |
|
| 476 | + 'articles_redirection' => 'non', |
|
| 477 | + 'creer_preview' => 'non', |
|
| 478 | + 'taille_preview' => 150, |
|
| 479 | + 'articles_modif' => 'non', |
|
| 480 | + |
|
| 481 | + 'rubriques_descriptif' => 'non', |
|
| 482 | + 'rubriques_texte' => 'oui', |
|
| 483 | + |
|
| 484 | + 'accepter_inscriptions' => 'non', |
|
| 485 | + 'accepter_visiteurs' => 'non', |
|
| 486 | + 'prevenir_auteurs' => 'non', |
|
| 487 | + 'suivi_edito' => 'non', |
|
| 488 | + 'adresse_suivi' => '', |
|
| 489 | + 'adresse_suivi_inscription' => '', |
|
| 490 | + 'adresse_neuf' => '', |
|
| 491 | + 'jours_neuf' => '', |
|
| 492 | + 'quoi_de_neuf' => 'non', |
|
| 493 | + 'preview' => ',0minirezo,1comite,', |
|
| 494 | + |
|
| 495 | + 'syndication_integrale' => 'oui', |
|
| 496 | + 'charset' => _DEFAULT_CHARSET, |
|
| 497 | + 'dir_img' => substr(_DIR_IMG, strlen(_DIR_RACINE)), |
|
| 498 | + |
|
| 499 | + 'multi_rubriques' => 'non', |
|
| 500 | + 'multi_secteurs' => 'non', |
|
| 501 | + 'gerer_trad' => 'non', |
|
| 502 | + 'langues_multilingue' => '', |
|
| 503 | + |
|
| 504 | + 'version_html_max' => 'html4', |
|
| 505 | + |
|
| 506 | + 'type_urls' => 'page', |
|
| 507 | + |
|
| 508 | + 'email_envoi' => '', |
|
| 509 | + 'email_webmaster' => '', |
|
| 510 | + 'auto_compress_http' => 'non', |
|
| 511 | + ]); |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
@@ -519,43 +519,43 @@ discard block |
||
| 519 | 519 | * @return void |
| 520 | 520 | */ |
| 521 | 521 | function actualise_metas($liste_meta) { |
| 522 | - $meta_serveur = |
|
| 523 | - [ |
|
| 524 | - 'version_installee', |
|
| 525 | - 'adresse_site', |
|
| 526 | - 'alea_ephemere_ancien', |
|
| 527 | - 'alea_ephemere', |
|
| 528 | - 'alea_ephemere_date', |
|
| 529 | - 'langue_site', |
|
| 530 | - 'langues_proposees', |
|
| 531 | - 'date_calcul_rubriques', |
|
| 532 | - 'derniere_modif', |
|
| 533 | - 'optimiser_table', |
|
| 534 | - 'drapeau_edition', |
|
| 535 | - 'creer_preview', |
|
| 536 | - 'taille_preview', |
|
| 537 | - 'creer_htpasswd', |
|
| 538 | - 'creer_htaccess', |
|
| 539 | - 'gd_formats_read', |
|
| 540 | - 'gd_formats', |
|
| 541 | - 'netpbm_formats', |
|
| 542 | - 'formats_graphiques', |
|
| 543 | - 'image_process', |
|
| 544 | - 'plugin_header', |
|
| 545 | - 'plugin' |
|
| 546 | - ]; |
|
| 547 | - // verifier le impt=non |
|
| 548 | - sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 549 | - |
|
| 550 | - foreach ($liste_meta as $nom => $valeur) { |
|
| 551 | - if (empty($GLOBALS['meta'][$nom])) { |
|
| 552 | - ecrire_meta($nom, $valeur); |
|
| 553 | - } |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - include_spip('inc/rubriques'); |
|
| 557 | - $langues = calculer_langues_utilisees(); |
|
| 558 | - ecrire_meta('langues_utilisees', $langues); |
|
| 522 | + $meta_serveur = |
|
| 523 | + [ |
|
| 524 | + 'version_installee', |
|
| 525 | + 'adresse_site', |
|
| 526 | + 'alea_ephemere_ancien', |
|
| 527 | + 'alea_ephemere', |
|
| 528 | + 'alea_ephemere_date', |
|
| 529 | + 'langue_site', |
|
| 530 | + 'langues_proposees', |
|
| 531 | + 'date_calcul_rubriques', |
|
| 532 | + 'derniere_modif', |
|
| 533 | + 'optimiser_table', |
|
| 534 | + 'drapeau_edition', |
|
| 535 | + 'creer_preview', |
|
| 536 | + 'taille_preview', |
|
| 537 | + 'creer_htpasswd', |
|
| 538 | + 'creer_htaccess', |
|
| 539 | + 'gd_formats_read', |
|
| 540 | + 'gd_formats', |
|
| 541 | + 'netpbm_formats', |
|
| 542 | + 'formats_graphiques', |
|
| 543 | + 'image_process', |
|
| 544 | + 'plugin_header', |
|
| 545 | + 'plugin' |
|
| 546 | + ]; |
|
| 547 | + // verifier le impt=non |
|
| 548 | + sql_updateq('spip_meta', ['impt' => 'non'], sql_in('nom', $meta_serveur)); |
|
| 549 | + |
|
| 550 | + foreach ($liste_meta as $nom => $valeur) { |
|
| 551 | + if (empty($GLOBALS['meta'][$nom])) { |
|
| 552 | + ecrire_meta($nom, $valeur); |
|
| 553 | + } |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + include_spip('inc/rubriques'); |
|
| 557 | + $langues = calculer_langues_utilisees(); |
|
| 558 | + ecrire_meta('langues_utilisees', $langues); |
|
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | |
@@ -577,18 +577,18 @@ discard block |
||
| 577 | 577 | */ |
| 578 | 578 | function appliquer_modifs_config($purger_skel = false) { |
| 579 | 579 | |
| 580 | - foreach (liste_metas() as $i => $v) { |
|
| 581 | - if (($x = _request($i)) !== null) { |
|
| 582 | - ecrire_meta($i, $x); |
|
| 583 | - } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 584 | - ecrire_meta($i, $v); |
|
| 585 | - } |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - if ($purger_skel) { |
|
| 589 | - include_spip('inc/invalideur'); |
|
| 590 | - purger_repertoire(_DIR_SKELS); |
|
| 591 | - } |
|
| 580 | + foreach (liste_metas() as $i => $v) { |
|
| 581 | + if (($x = _request($i)) !== null) { |
|
| 582 | + ecrire_meta($i, $x); |
|
| 583 | + } elseif (!isset($GLOBALS['meta'][$i])) { |
|
| 584 | + ecrire_meta($i, $v); |
|
| 585 | + } |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + if ($purger_skel) { |
|
| 589 | + include_spip('inc/invalideur'); |
|
| 590 | + purger_repertoire(_DIR_SKELS); |
|
| 591 | + } |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -599,21 +599,21 @@ discard block |
||
| 599 | 599 | * @return string |
| 600 | 600 | */ |
| 601 | 601 | function appliquer_adresse_site($adresse_site) { |
| 602 | - if ($adresse_site !== null) { |
|
| 603 | - if (!strlen($adresse_site)) { |
|
| 604 | - $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 605 | - $adresse_site = url_de_base(); |
|
| 606 | - } |
|
| 607 | - $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 602 | + if ($adresse_site !== null) { |
|
| 603 | + if (!strlen($adresse_site)) { |
|
| 604 | + $GLOBALS['profondeur_url'] = _DIR_RESTREINT ? 0 : 1; |
|
| 605 | + $adresse_site = url_de_base(); |
|
| 606 | + } |
|
| 607 | + $adresse_site = preg_replace(',/?\s*$,', '', $adresse_site); |
|
| 608 | 608 | |
| 609 | - if (!tester_url_absolue($adresse_site)) { |
|
| 610 | - $adresse_site = "http://$adresse_site"; |
|
| 611 | - } |
|
| 609 | + if (!tester_url_absolue($adresse_site)) { |
|
| 610 | + $adresse_site = "http://$adresse_site"; |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - $adresse_site = entites_html($adresse_site); |
|
| 613 | + $adresse_site = entites_html($adresse_site); |
|
| 614 | 614 | |
| 615 | - ecrire_meta('adresse_site', $adresse_site); |
|
| 616 | - } |
|
| 615 | + ecrire_meta('adresse_site', $adresse_site); |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | - return $adresse_site; |
|
| 618 | + return $adresse_site; |
|
| 619 | 619 | } |
@@ -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/filtres'); |
@@ -46,56 +46,56 @@ discard block |
||
| 46 | 46 | **/ |
| 47 | 47 | function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') { |
| 48 | 48 | |
| 49 | - if ($recur) { |
|
| 50 | - $recur = mini_hier($sel); |
|
| 51 | - } else { |
|
| 52 | - $sel = 0; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if ($aff_racine) { |
|
| 56 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | - $idom3 = $idom . '_selection'; |
|
| 58 | - |
|
| 59 | - $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 60 | - |
|
| 61 | - $ondbClick = strtr( |
|
| 62 | - str_replace( |
|
| 63 | - "'", |
|
| 64 | - '’', |
|
| 65 | - str_replace( |
|
| 66 | - '"', |
|
| 67 | - '"', |
|
| 68 | - textebrut(_T('info_racine_site')) |
|
| 69 | - ) |
|
| 70 | - ), |
|
| 71 | - "\n\r", |
|
| 72 | - ' ' |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - $js_func = $do . '_selection_titre'; |
|
| 76 | - $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 77 | - |
|
| 78 | - $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 79 | - . "<a href='#'" |
|
| 80 | - . 'onclick="' |
|
| 81 | - . $onClick |
|
| 82 | - . "\"\nondbclick=\"" |
|
| 83 | - . $ondbClick |
|
| 84 | - . $onClick |
|
| 85 | - . '">' |
|
| 86 | - . _T('info_racine_site') |
|
| 87 | - . '</a></div>'; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 91 | - |
|
| 92 | - $plonger = charger_fonction('plonger', 'inc'); |
|
| 93 | - $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 94 | - |
|
| 95 | - // url completee par la fonction JS onkeypress_rechercher |
|
| 96 | - $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 97 | - |
|
| 98 | - return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 49 | + if ($recur) { |
|
| 50 | + $recur = mini_hier($sel); |
|
| 51 | + } else { |
|
| 52 | + $sel = 0; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if ($aff_racine) { |
|
| 56 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | + $idom3 = $idom . '_selection'; |
|
| 58 | + |
|
| 59 | + $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 60 | + |
|
| 61 | + $ondbClick = strtr( |
|
| 62 | + str_replace( |
|
| 63 | + "'", |
|
| 64 | + '’', |
|
| 65 | + str_replace( |
|
| 66 | + '"', |
|
| 67 | + '"', |
|
| 68 | + textebrut(_T('info_racine_site')) |
|
| 69 | + ) |
|
| 70 | + ), |
|
| 71 | + "\n\r", |
|
| 72 | + ' ' |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + $js_func = $do . '_selection_titre'; |
|
| 76 | + $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 77 | + |
|
| 78 | + $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 79 | + . "<a href='#'" |
|
| 80 | + . 'onclick="' |
|
| 81 | + . $onClick |
|
| 82 | + . "\"\nondbclick=\"" |
|
| 83 | + . $ondbClick |
|
| 84 | + . $onClick |
|
| 85 | + . '">' |
|
| 86 | + . _T('info_racine_site') |
|
| 87 | + . '</a></div>'; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 91 | + |
|
| 92 | + $plonger = charger_fonction('plonger', 'inc'); |
|
| 93 | + $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 94 | + |
|
| 95 | + // url completee par la fonction JS onkeypress_rechercher |
|
| 96 | + $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 97 | + |
|
| 98 | + return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -113,58 +113,58 @@ discard block |
||
| 113 | 113 | **/ |
| 114 | 114 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 115 | 115 | |
| 116 | - $idom1 = $idom . '_champ_recherche'; |
|
| 117 | - $idom2 = $idom . '_principal'; |
|
| 118 | - $idom3 = $idom . '_selection'; |
|
| 119 | - $idom4 = $idom . '_col_1'; |
|
| 120 | - $idom5 = 'img_' . $idom4; |
|
| 121 | - $idom6 = $idom . '_fonc'; |
|
| 122 | - |
|
| 123 | - return "<div id='$idom'>" |
|
| 124 | - . "<a id='$idom6' style='visibility: hidden;'" |
|
| 125 | - . ($url_init ? "\nhref='$url_init'" : '') |
|
| 126 | - . '></a>' |
|
| 127 | - . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 128 | - . http_img_pack( |
|
| 129 | - 'loader.svg', |
|
| 130 | - '', |
|
| 131 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 132 | - ) |
|
| 133 | - . '' |
|
| 134 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 135 | - // eliminer Return car il provoque la soumission (balise unique) |
|
| 136 | - // et eliminer Tab pour la navigation au clavier |
|
| 137 | - // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 138 | - // resultats retournes par la recherche |
|
| 139 | - . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 140 | - // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 141 | - . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 142 | - // la destination de la recherche |
|
| 143 | - . "'$idom4'" |
|
| 116 | + $idom1 = $idom . '_champ_recherche'; |
|
| 117 | + $idom2 = $idom . '_principal'; |
|
| 118 | + $idom3 = $idom . '_selection'; |
|
| 119 | + $idom4 = $idom . '_col_1'; |
|
| 120 | + $idom5 = 'img_' . $idom4; |
|
| 121 | + $idom6 = $idom . '_fonc'; |
|
| 122 | + |
|
| 123 | + return "<div id='$idom'>" |
|
| 124 | + . "<a id='$idom6' style='visibility: hidden;'" |
|
| 125 | + . ($url_init ? "\nhref='$url_init'" : '') |
|
| 126 | + . '></a>' |
|
| 127 | + . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 128 | + . http_img_pack( |
|
| 129 | + 'loader.svg', |
|
| 130 | + '', |
|
| 131 | + "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 132 | + ) |
|
| 133 | + . '' |
|
| 134 | + . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 135 | + // eliminer Return car il provoque la soumission (balise unique) |
|
| 136 | + // et eliminer Tab pour la navigation au clavier |
|
| 137 | + // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 138 | + // resultats retournes par la recherche |
|
| 139 | + . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 140 | + // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 141 | + . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 142 | + // la destination de la recherche |
|
| 143 | + . "'$idom4'" |
|
| 144 | 144 | # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id" |
| 145 | - . ",'" |
|
| 146 | - // l'url effectuant la recherche |
|
| 147 | - . $url |
|
| 148 | - . "'," |
|
| 149 | - // le noeud contenant un gif anime |
|
| 150 | - // . "'idom5'" |
|
| 151 | - . 'this.parentNode.previousSibling.firstChild' |
|
| 152 | - . ",'" |
|
| 153 | - // la valeur de l'attribut Name a remplir |
|
| 154 | - . $name |
|
| 155 | - . "','" |
|
| 156 | - // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 157 | - . $idom6 |
|
| 158 | - . "')\"" |
|
| 159 | - . ' />' |
|
| 160 | - . "\n</div>" |
|
| 161 | - . ($racine ? "<div>$racine</div>" : '') |
|
| 162 | - . "<div id='" |
|
| 163 | - . $idom2 |
|
| 164 | - . "'><div id='$idom4'" |
|
| 165 | - . " class=''>" |
|
| 166 | - . $liste |
|
| 167 | - . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 145 | + . ",'" |
|
| 146 | + // l'url effectuant la recherche |
|
| 147 | + . $url |
|
| 148 | + . "'," |
|
| 149 | + // le noeud contenant un gif anime |
|
| 150 | + // . "'idom5'" |
|
| 151 | + . 'this.parentNode.previousSibling.firstChild' |
|
| 152 | + . ",'" |
|
| 153 | + // la valeur de l'attribut Name a remplir |
|
| 154 | + . $name |
|
| 155 | + . "','" |
|
| 156 | + // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 157 | + . $idom6 |
|
| 158 | + . "')\"" |
|
| 159 | + . ' />' |
|
| 160 | + . "\n</div>" |
|
| 161 | + . ($racine ? "<div>$racine</div>" : '') |
|
| 162 | + . "<div id='" |
|
| 163 | + . $idom2 |
|
| 164 | + . "'><div id='$idom4'" |
|
| 165 | + . " class=''>" |
|
| 166 | + . $liste |
|
| 167 | + . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | **/ |
| 177 | 177 | function mini_hier($id_rubrique) { |
| 178 | 178 | |
| 179 | - $liste = $id_rubrique; |
|
| 180 | - $id_rubrique = intval($id_rubrique); |
|
| 181 | - while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | - $liste = $id_rubrique . ",$liste"; |
|
| 183 | - } |
|
| 179 | + $liste = $id_rubrique; |
|
| 180 | + $id_rubrique = intval($id_rubrique); |
|
| 181 | + while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | + $liste = $id_rubrique . ",$liste"; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return explode(',', "0,$liste"); |
|
| 185 | + return explode(',', "0,$liste"); |
|
| 186 | 186 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | if ($aff_racine) { |
| 56 | 56 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
| 57 | - $idom3 = $idom . '_selection'; |
|
| 57 | + $idom3 = $idom.'_selection'; |
|
| 58 | 58 | |
| 59 | 59 | $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
| 60 | 60 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ' ' |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - $js_func = $do . '_selection_titre'; |
|
| 75 | + $js_func = $do.'_selection_titre'; |
|
| 76 | 76 | $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
| 77 | 77 | |
| 78 | 78 | $aff_racine = "<div class='petit-item petite-racine item'>" |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | **/ |
| 114 | 114 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 115 | 115 | |
| 116 | - $idom1 = $idom . '_champ_recherche'; |
|
| 117 | - $idom2 = $idom . '_principal'; |
|
| 118 | - $idom3 = $idom . '_selection'; |
|
| 119 | - $idom4 = $idom . '_col_1'; |
|
| 120 | - $idom5 = 'img_' . $idom4; |
|
| 121 | - $idom6 = $idom . '_fonc'; |
|
| 116 | + $idom1 = $idom.'_champ_recherche'; |
|
| 117 | + $idom2 = $idom.'_principal'; |
|
| 118 | + $idom3 = $idom.'_selection'; |
|
| 119 | + $idom4 = $idom.'_col_1'; |
|
| 120 | + $idom5 = 'img_'.$idom4; |
|
| 121 | + $idom6 = $idom.'_fonc'; |
|
| 122 | 122 | |
| 123 | 123 | return "<div id='$idom'>" |
| 124 | 124 | . "<a id='$idom6' style='visibility: hidden;'" |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | . http_img_pack( |
| 129 | 129 | 'loader.svg', |
| 130 | 130 | '', |
| 131 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 131 | + "class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'" |
|
| 132 | 132 | ) |
| 133 | 133 | . '' |
| 134 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 134 | + . "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='text' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'" |
|
| 135 | 135 | // eliminer Return car il provoque la soumission (balise unique) |
| 136 | 136 | // et eliminer Tab pour la navigation au clavier |
| 137 | 137 | // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $liste = $id_rubrique; |
| 180 | 180 | $id_rubrique = intval($id_rubrique); |
| 181 | - while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | - $liste = $id_rubrique . ",$liste"; |
|
| 181 | + while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = '.$id_rubrique)) { |
|
| 182 | + $liste = $id_rubrique.",$liste"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return explode(',', "0,$liste"); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Notifications |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function inc_notifications_dist($quoi, $id = 0, $options = []) { |
| 35 | 35 | |
| 36 | - // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | - // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | - pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 36 | + // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | + // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | + pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 39 | 39 | |
| 40 | - if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | - spip_log("$notification($quoi,$id" |
|
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 43 | - . ')', 'notifications'); |
|
| 44 | - $notification($quoi, $id, $options); |
|
| 45 | - } |
|
| 40 | + if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | + spip_log("$notification($quoi,$id" |
|
| 42 | + . ($options ? ',' . serialize($options) : '') |
|
| 43 | + . ')', 'notifications'); |
|
| 44 | + $notification($quoi, $id, $options); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | * @param array $exclure |
| 57 | 57 | */ |
| 58 | 58 | function notifications_nettoyer_emails(&$emails, $exclure = []) { |
| 59 | - // filtrer et unifier |
|
| 60 | - $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | - if ($exclure and count($exclure)) { |
|
| 62 | - // nettoyer les exclusions d'abord |
|
| 63 | - notifications_nettoyer_emails($exclure); |
|
| 64 | - // faire un diff |
|
| 65 | - $emails = array_diff($emails, $exclure); |
|
| 66 | - } |
|
| 59 | + // filtrer et unifier |
|
| 60 | + $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | + if ($exclure and count($exclure)) { |
|
| 62 | + // nettoyer les exclusions d'abord |
|
| 63 | + notifications_nettoyer_emails($exclure); |
|
| 64 | + // faire un diff |
|
| 65 | + $emails = array_diff($emails, $exclure); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -78,90 +78,90 @@ discard block |
||
| 78 | 78 | * @param string $headers |
| 79 | 79 | */ |
| 80 | 80 | function notifications_envoyer_mails($emails, $texte, $sujet = '', $from = '', $headers = '') { |
| 81 | - // rien a faire si pas de texte ! |
|
| 82 | - if (!strlen($texte)) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | - if (!is_array($emails)) { |
|
| 88 | - $emails = explode(',', $emails); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - notifications_nettoyer_emails($emails); |
|
| 92 | - |
|
| 93 | - // tester si le mail est deja en html |
|
| 94 | - if ( |
|
| 95 | - strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | - and $ttrim = trim($texte) |
|
| 97 | - and substr($ttrim, 0, 1) == '<' |
|
| 98 | - and substr($ttrim, -1, 1) == '>' |
|
| 99 | - and stripos($ttrim, '</html>') !== false |
|
| 100 | - ) { |
|
| 101 | - if (!strlen($sujet)) { |
|
| 102 | - // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | - if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | - $sujet = $m[1]; |
|
| 105 | - } else { |
|
| 106 | - // fallback, on prend le body si on le trouve |
|
| 107 | - if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | - $ttrim = $m[1]; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // et on extrait la premiere ligne de vrai texte... |
|
| 112 | - // nettoyer le html et les retours chariots |
|
| 113 | - $ttrim = textebrut($ttrim); |
|
| 114 | - $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | - $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | - // decouper |
|
| 117 | - $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | - // extraire la premiere ligne de texte brut |
|
| 119 | - $sujet = array_shift($ttrim); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // si besoin on ajoute le content-type dans les headers |
|
| 124 | - if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | - $headers .= "Content-Type: text/html\n"; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | - // du mail qui est donc du texte |
|
| 131 | - if (!strlen($sujet)) { |
|
| 132 | - // nettoyer un peu les retours chariots |
|
| 133 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | - $texte = str_replace("\r", "\n", $texte); |
|
| 135 | - // decouper |
|
| 136 | - $texte = explode("\n", trim($texte)); |
|
| 137 | - // extraire la premiere ligne |
|
| 138 | - $sujet = array_shift($texte); |
|
| 139 | - $texte = trim(implode("\n", $texte)); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | - foreach ($emails as $email) { |
|
| 144 | - // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | - // (url de suivi des notifications par exemple) |
|
| 146 | - $envoi = pipeline( |
|
| 147 | - 'notifications_envoyer_mails', |
|
| 148 | - [ |
|
| 149 | - 'email' => $email, |
|
| 150 | - 'sujet' => $sujet, |
|
| 151 | - 'texte' => $texte, |
|
| 152 | - 'from' => $from, |
|
| 153 | - 'headers' => $headers, |
|
| 154 | - ] |
|
| 155 | - ); |
|
| 156 | - $email = $envoi['email']; |
|
| 157 | - |
|
| 158 | - job_queue_add( |
|
| 159 | - 'envoyer_mail', |
|
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 161 | - [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | - 'inc/' |
|
| 163 | - ); |
|
| 164 | - } |
|
| 81 | + // rien a faire si pas de texte ! |
|
| 82 | + if (!strlen($texte)) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | + if (!is_array($emails)) { |
|
| 88 | + $emails = explode(',', $emails); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + notifications_nettoyer_emails($emails); |
|
| 92 | + |
|
| 93 | + // tester si le mail est deja en html |
|
| 94 | + if ( |
|
| 95 | + strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | + and $ttrim = trim($texte) |
|
| 97 | + and substr($ttrim, 0, 1) == '<' |
|
| 98 | + and substr($ttrim, -1, 1) == '>' |
|
| 99 | + and stripos($ttrim, '</html>') !== false |
|
| 100 | + ) { |
|
| 101 | + if (!strlen($sujet)) { |
|
| 102 | + // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | + if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | + $sujet = $m[1]; |
|
| 105 | + } else { |
|
| 106 | + // fallback, on prend le body si on le trouve |
|
| 107 | + if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | + $ttrim = $m[1]; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // et on extrait la premiere ligne de vrai texte... |
|
| 112 | + // nettoyer le html et les retours chariots |
|
| 113 | + $ttrim = textebrut($ttrim); |
|
| 114 | + $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | + $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | + // decouper |
|
| 117 | + $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | + // extraire la premiere ligne de texte brut |
|
| 119 | + $sujet = array_shift($ttrim); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // si besoin on ajoute le content-type dans les headers |
|
| 124 | + if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | + $headers .= "Content-Type: text/html\n"; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | + // du mail qui est donc du texte |
|
| 131 | + if (!strlen($sujet)) { |
|
| 132 | + // nettoyer un peu les retours chariots |
|
| 133 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | + $texte = str_replace("\r", "\n", $texte); |
|
| 135 | + // decouper |
|
| 136 | + $texte = explode("\n", trim($texte)); |
|
| 137 | + // extraire la premiere ligne |
|
| 138 | + $sujet = array_shift($texte); |
|
| 139 | + $texte = trim(implode("\n", $texte)); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | + foreach ($emails as $email) { |
|
| 144 | + // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | + // (url de suivi des notifications par exemple) |
|
| 146 | + $envoi = pipeline( |
|
| 147 | + 'notifications_envoyer_mails', |
|
| 148 | + [ |
|
| 149 | + 'email' => $email, |
|
| 150 | + 'sujet' => $sujet, |
|
| 151 | + 'texte' => $texte, |
|
| 152 | + 'from' => $from, |
|
| 153 | + 'headers' => $headers, |
|
| 154 | + ] |
|
| 155 | + ); |
|
| 156 | + $email = $envoi['email']; |
|
| 157 | + |
|
| 158 | + job_queue_add( |
|
| 159 | + 'envoyer_mail', |
|
| 160 | + ">$email : " . $envoi['sujet'], |
|
| 161 | + [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | + 'inc/' |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | * @return string |
| 178 | 178 | */ |
| 179 | 179 | function email_notification_objet($id_objet, $type_objet, $modele) { |
| 180 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | - $id_type = id_table_objet($type_objet); |
|
| 180 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | + $id_type = id_table_objet($type_objet); |
|
| 182 | 182 | |
| 183 | - return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 183 | + return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | 197 | function email_notification_article($id_article, $modele) { |
| 198 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 198 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 199 | 199 | |
| 200 | - return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 200 | + return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 201 | 201 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | if ($notification = charger_fonction($quoi, 'notifications', true)) { |
| 41 | 41 | spip_log("$notification($quoi,$id" |
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 42 | + . ($options ? ','.serialize($options) : '') |
|
| 43 | 43 | . ')', 'notifications'); |
| 44 | 44 | $notification($quoi, $id, $options); |
| 45 | 45 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | job_queue_add( |
| 159 | 159 | 'envoyer_mail', |
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 160 | + ">$email : ".$envoi['sujet'], |
|
| 161 | 161 | [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
| 162 | 162 | 'inc/' |
| 163 | 163 | ); |