@@ -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'); |
@@ -46,33 +46,33 @@ discard block |
||
| 46 | 46 | * Environnement du formulaire |
| 47 | 47 | **/ |
| 48 | 48 | function formulaires_editer_article_charger_dist( |
| 49 | - $id_article = 'new', |
|
| 50 | - $id_rubrique = 0, |
|
| 51 | - $retour = '', |
|
| 52 | - $lier_trad = 0, |
|
| 53 | - $config_fonc = 'articles_edit_config', |
|
| 54 | - $row = array(), |
|
| 55 | - $hidden = '' |
|
| 49 | + $id_article = 'new', |
|
| 50 | + $id_rubrique = 0, |
|
| 51 | + $retour = '', |
|
| 52 | + $lier_trad = 0, |
|
| 53 | + $config_fonc = 'articles_edit_config', |
|
| 54 | + $row = array(), |
|
| 55 | + $hidden = '' |
|
| 56 | 56 | ) { |
| 57 | - $valeurs = formulaires_editer_objet_charger( |
|
| 58 | - 'article', |
|
| 59 | - $id_article, |
|
| 60 | - $id_rubrique, |
|
| 61 | - $lier_trad, |
|
| 62 | - $retour, |
|
| 63 | - $config_fonc, |
|
| 64 | - $row, |
|
| 65 | - $hidden |
|
| 66 | - ); |
|
| 67 | - |
|
| 68 | - if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) { |
|
| 69 | - $valeurs['editable'] = ''; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - // il faut enlever l'id_rubrique car la saisie se fait sur id_parent |
|
| 73 | - // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale |
|
| 74 | - // et sera perdue si elle est supposee saisie |
|
| 75 | - return $valeurs; |
|
| 57 | + $valeurs = formulaires_editer_objet_charger( |
|
| 58 | + 'article', |
|
| 59 | + $id_article, |
|
| 60 | + $id_rubrique, |
|
| 61 | + $lier_trad, |
|
| 62 | + $retour, |
|
| 63 | + $config_fonc, |
|
| 64 | + $row, |
|
| 65 | + $hidden |
|
| 66 | + ); |
|
| 67 | + |
|
| 68 | + if (intval($id_article) and !autoriser('modifier', 'article', intval($id_article))) { |
|
| 69 | + $valeurs['editable'] = ''; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + // il faut enlever l'id_rubrique car la saisie se fait sur id_parent |
|
| 73 | + // et id_rubrique peut etre passe dans l'url comme rubrique parent initiale |
|
| 74 | + // et sera perdue si elle est supposee saisie |
|
| 75 | + return $valeurs; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -97,15 +97,15 @@ discard block |
||
| 97 | 97 | * Hash du formulaire |
| 98 | 98 | */ |
| 99 | 99 | function formulaires_editer_article_identifier_dist( |
| 100 | - $id_article = 'new', |
|
| 101 | - $id_rubrique = 0, |
|
| 102 | - $retour = '', |
|
| 103 | - $lier_trad = 0, |
|
| 104 | - $config_fonc = 'articles_edit_config', |
|
| 105 | - $row = array(), |
|
| 106 | - $hidden = '' |
|
| 100 | + $id_article = 'new', |
|
| 101 | + $id_rubrique = 0, |
|
| 102 | + $retour = '', |
|
| 103 | + $lier_trad = 0, |
|
| 104 | + $config_fonc = 'articles_edit_config', |
|
| 105 | + $row = array(), |
|
| 106 | + $hidden = '' |
|
| 107 | 107 | ) { |
| 108 | - return serialize(array(intval($id_article), $lier_trad)); |
|
| 108 | + return serialize(array(intval($id_article), $lier_trad)); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -117,15 +117,15 @@ discard block |
||
| 117 | 117 | * Configuration pour le formulaire |
| 118 | 118 | */ |
| 119 | 119 | function articles_edit_config($row) { |
| 120 | - global $spip_lang; |
|
| 120 | + global $spip_lang; |
|
| 121 | 121 | |
| 122 | - $config = $GLOBALS['meta']; |
|
| 123 | - $config['lignes'] = 8; |
|
| 124 | - $config['langue'] = $spip_lang; |
|
| 122 | + $config = $GLOBALS['meta']; |
|
| 123 | + $config['lignes'] = 8; |
|
| 124 | + $config['langue'] = $spip_lang; |
|
| 125 | 125 | |
| 126 | - $config['restreint'] = ($row['statut'] == 'publie'); |
|
| 126 | + $config['restreint'] = ($row['statut'] == 'publie'); |
|
| 127 | 127 | |
| 128 | - return $config; |
|
| 128 | + return $config; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -151,29 +151,29 @@ discard block |
||
| 151 | 151 | * Erreurs du formulaire |
| 152 | 152 | **/ |
| 153 | 153 | function formulaires_editer_article_verifier_dist( |
| 154 | - $id_article = 'new', |
|
| 155 | - $id_rubrique = 0, |
|
| 156 | - $retour = '', |
|
| 157 | - $lier_trad = 0, |
|
| 158 | - $config_fonc = 'articles_edit_config', |
|
| 159 | - $row = array(), |
|
| 160 | - $hidden = '' |
|
| 154 | + $id_article = 'new', |
|
| 155 | + $id_rubrique = 0, |
|
| 156 | + $retour = '', |
|
| 157 | + $lier_trad = 0, |
|
| 158 | + $config_fonc = 'articles_edit_config', |
|
| 159 | + $row = array(), |
|
| 160 | + $hidden = '' |
|
| 161 | 161 | ) { |
| 162 | - // auto-renseigner le titre si il n'existe pas |
|
| 163 | - titre_automatique('titre', array('descriptif', 'chapo', 'texte')); |
|
| 164 | - // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide |
|
| 165 | - $erreurs = formulaires_editer_objet_verifier('article', $id_article, array('id_parent')); |
|
| 166 | - // si on utilise le formulaire dans le public |
|
| 167 | - if (!function_exists('autoriser')) { |
|
| 168 | - include_spip('inc/autoriser'); |
|
| 169 | - } |
|
| 170 | - if (!isset($erreurs['id_parent']) |
|
| 171 | - and !autoriser('creerarticledans', 'rubrique', _request('id_parent')) |
|
| 172 | - ) { |
|
| 173 | - $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise'); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - return $erreurs; |
|
| 162 | + // auto-renseigner le titre si il n'existe pas |
|
| 163 | + titre_automatique('titre', array('descriptif', 'chapo', 'texte')); |
|
| 164 | + // on ne demande pas le titre obligatoire : il sera rempli a la volee dans editer_article si vide |
|
| 165 | + $erreurs = formulaires_editer_objet_verifier('article', $id_article, array('id_parent')); |
|
| 166 | + // si on utilise le formulaire dans le public |
|
| 167 | + if (!function_exists('autoriser')) { |
|
| 168 | + include_spip('inc/autoriser'); |
|
| 169 | + } |
|
| 170 | + if (!isset($erreurs['id_parent']) |
|
| 171 | + and !autoriser('creerarticledans', 'rubrique', _request('id_parent')) |
|
| 172 | + ) { |
|
| 173 | + $erreurs['id_parent'] = _T('info_creerdansrubrique_non_autorise'); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + return $erreurs; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -199,29 +199,29 @@ discard block |
||
| 199 | 199 | * Retours des traitements |
| 200 | 200 | **/ |
| 201 | 201 | function formulaires_editer_article_traiter_dist( |
| 202 | - $id_article = 'new', |
|
| 203 | - $id_rubrique = 0, |
|
| 204 | - $retour = '', |
|
| 205 | - $lier_trad = 0, |
|
| 206 | - $config_fonc = 'articles_edit_config', |
|
| 207 | - $row = array(), |
|
| 208 | - $hidden = '' |
|
| 202 | + $id_article = 'new', |
|
| 203 | + $id_rubrique = 0, |
|
| 204 | + $retour = '', |
|
| 205 | + $lier_trad = 0, |
|
| 206 | + $config_fonc = 'articles_edit_config', |
|
| 207 | + $row = array(), |
|
| 208 | + $hidden = '' |
|
| 209 | 209 | ) { |
| 210 | - // ici on ignore changer_lang qui est poste en cas de trad, |
|
| 211 | - // car l'heuristique du choix de la langue est pris en charge par article_inserer |
|
| 212 | - // en fonction de la config du site et de la rubrique choisie |
|
| 213 | - if (!$lier_trad) { |
|
| 214 | - set_request('changer_lang'); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - return formulaires_editer_objet_traiter( |
|
| 218 | - 'article', |
|
| 219 | - $id_article, |
|
| 220 | - $id_rubrique, |
|
| 221 | - $lier_trad, |
|
| 222 | - $retour, |
|
| 223 | - $config_fonc, |
|
| 224 | - $row, |
|
| 225 | - $hidden |
|
| 226 | - ); |
|
| 210 | + // ici on ignore changer_lang qui est poste en cas de trad, |
|
| 211 | + // car l'heuristique du choix de la langue est pris en charge par article_inserer |
|
| 212 | + // en fonction de la config du site et de la rubrique choisie |
|
| 213 | + if (!$lier_trad) { |
|
| 214 | + set_request('changer_lang'); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + return formulaires_editer_objet_traiter( |
|
| 218 | + 'article', |
|
| 219 | + $id_article, |
|
| 220 | + $id_rubrique, |
|
| 221 | + $lier_trad, |
|
| 222 | + $retour, |
|
| 223 | + $config_fonc, |
|
| 224 | + $row, |
|
| 225 | + $hidden |
|
| 226 | + ); |
|
| 227 | 227 | } |
@@ -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 = array(), |
|
| 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 = array(), |
|
| 69 | + $hidden = '' |
|
| 70 | 70 | ) { |
| 71 | 71 | |
| 72 | - $res = array(); |
|
| 73 | - // eviter la redirection forcee par l'action... |
|
| 74 | - set_request('redirect'); |
|
| 75 | - if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | - list($id, $err) = $action_editer($id); |
|
| 77 | - } else { |
|
| 78 | - $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | - list($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 ? $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 = array(); |
|
| 73 | + // eviter la redirection forcee par l'action... |
|
| 74 | + set_request('redirect'); |
|
| 75 | + if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | + list($id, $err) = $action_editer($id); |
|
| 77 | + } else { |
|
| 78 | + $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | + list($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 ? $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 = array()) { |
| 135 | - $erreurs = array(); |
|
| 136 | - if (intval($id)) { |
|
| 137 | - $conflits = controler_contenu($type, $id); |
|
| 138 | - if ($conflits and count($conflits)) { |
|
| 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 = array(); |
|
| 136 | + if (intval($id)) { |
|
| 137 | + $conflits = controler_contenu($type, $id); |
|
| 138 | + if ($conflits and count($conflits)) { |
|
| 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 | /** |
@@ -198,133 +198,133 @@ discard block |
||
| 198 | 198 | * Environnement du formulaire. |
| 199 | 199 | **/ |
| 200 | 200 | function formulaires_editer_objet_charger( |
| 201 | - $type, |
|
| 202 | - $id = 'new', |
|
| 203 | - $id_parent = 0, |
|
| 204 | - $lier_trad = 0, |
|
| 205 | - $retour = '', |
|
| 206 | - $config_fonc = 'articles_edit_config', |
|
| 207 | - $row = array(), |
|
| 208 | - $hidden = '' |
|
| 201 | + $type, |
|
| 202 | + $id = 'new', |
|
| 203 | + $id_parent = 0, |
|
| 204 | + $lier_trad = 0, |
|
| 205 | + $retour = '', |
|
| 206 | + $config_fonc = 'articles_edit_config', |
|
| 207 | + $row = array(), |
|
| 208 | + $hidden = '' |
|
| 209 | 209 | ) { |
| 210 | 210 | |
| 211 | - $table_objet = table_objet($type); |
|
| 212 | - $table_objet_sql = table_objet_sql($type); |
|
| 213 | - $id_table_objet = id_table_objet($type); |
|
| 214 | - |
|
| 215 | - // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 216 | - if ($config_fonc |
|
| 217 | - and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 218 | - and $config_fonc !== $table_objet . '_edit_config') { |
|
| 219 | - if ($args = test_formulaire_inclus_par_modele() |
|
| 220 | - and in_array($config_fonc, $args)) { |
|
| 221 | - $config_fonc = ''; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - $new = !is_numeric($id); |
|
| 226 | - $lang_default = ''; |
|
| 227 | - // Appel direct dans un squelette |
|
| 228 | - if (!$row) { |
|
| 229 | - if (!$new or $lier_trad) { |
|
| 230 | - if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 231 | - $row = $select($id, $id_parent, $lier_trad); |
|
| 232 | - // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 233 | - $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 234 | - } else { |
|
| 235 | - $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 236 | - } |
|
| 237 | - if (!$new) { |
|
| 238 | - $md5 = controles_md5($row); |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - if (!$row) { |
|
| 242 | - $row = array(); |
|
| 243 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 244 | - if ($desc = $trouver_table($table_objet)) { |
|
| 245 | - foreach ($desc['field'] as $k => $v) { |
|
| 246 | - $row[$k] = ''; |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 253 | - // (et donc: pas de lien de traduction) |
|
| 254 | - $id = ($new or $lier_trad) |
|
| 255 | - ? 'oui' |
|
| 256 | - : $row[$id_table_objet]; |
|
| 257 | - $row[$id_table_objet] = $id; |
|
| 258 | - |
|
| 259 | - $contexte = $row; |
|
| 260 | - if (strlen($id_parent) && is_numeric($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 261 | - if (!isset($contexte['id_parent'])) { |
|
| 262 | - unset($contexte['id_rubrique']); |
|
| 263 | - } |
|
| 264 | - $contexte['id_parent'] = $id_parent; |
|
| 265 | - } elseif (!isset($contexte['id_parent'])) { |
|
| 266 | - // id_rubrique dans id_parent si possible |
|
| 267 | - if (isset($contexte['id_rubrique'])) { |
|
| 268 | - $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 269 | - unset($contexte['id_rubrique']); |
|
| 270 | - } else { |
|
| 271 | - $contexte['id_parent'] = ''; |
|
| 272 | - } |
|
| 273 | - if (!$contexte['id_parent'] |
|
| 274 | - and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 275 | - ) { |
|
| 276 | - $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - $config = array(); |
|
| 281 | - if ($config_fonc) { |
|
| 282 | - $contexte['config'] = $config = $config_fonc($contexte); |
|
| 283 | - if (!$lang_default) { |
|
| 284 | - $lang_default = $config['langue']; |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - $config = $config + array( |
|
| 288 | - 'lignes' => 0, |
|
| 289 | - 'langue' => '', |
|
| 290 | - ); |
|
| 291 | - |
|
| 292 | - $att_text = " class='textarea' " |
|
| 293 | - . " rows='" |
|
| 294 | - . ($config['lignes'] + 15) |
|
| 295 | - . "' cols='40'"; |
|
| 296 | - if (isset($contexte['texte'])) { |
|
| 297 | - list($contexte['texte'], $contexte['_texte_trop_long']) = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - // on veut conserver la langue de l'interface ; |
|
| 301 | - // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 302 | - // voudrait l'exploiter |
|
| 303 | - if (isset($contexte['lang'])) { |
|
| 304 | - $contexte['langue'] = $contexte['lang']; |
|
| 305 | - unset($contexte['lang']); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 309 | - (!$lier_trad ? '' : |
|
| 310 | - ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 311 | - $lier_trad . |
|
| 312 | - "' />" . |
|
| 313 | - "\n<input type='hidden' name='changer_lang' value='" . |
|
| 314 | - $lang_default . |
|
| 315 | - "' />")) |
|
| 316 | - . $hidden |
|
| 317 | - . (isset($md5) ? $md5 : ''); |
|
| 318 | - |
|
| 319 | - // preciser que le formulaire doit passer dans un pipeline |
|
| 320 | - $contexte['_pipeline'] = array('editer_contenu_objet', array('type' => $type, 'id' => $id)); |
|
| 321 | - |
|
| 322 | - // preciser que le formulaire doit etre securise auteur/action |
|
| 323 | - // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 324 | - // on le garde pour compat |
|
| 325 | - $contexte['_action'] = array("editer_$type", $id); |
|
| 326 | - |
|
| 327 | - return $contexte; |
|
| 211 | + $table_objet = table_objet($type); |
|
| 212 | + $table_objet_sql = table_objet_sql($type); |
|
| 213 | + $id_table_objet = id_table_objet($type); |
|
| 214 | + |
|
| 215 | + // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 216 | + if ($config_fonc |
|
| 217 | + and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 218 | + and $config_fonc !== $table_objet . '_edit_config') { |
|
| 219 | + if ($args = test_formulaire_inclus_par_modele() |
|
| 220 | + and in_array($config_fonc, $args)) { |
|
| 221 | + $config_fonc = ''; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + $new = !is_numeric($id); |
|
| 226 | + $lang_default = ''; |
|
| 227 | + // Appel direct dans un squelette |
|
| 228 | + if (!$row) { |
|
| 229 | + if (!$new or $lier_trad) { |
|
| 230 | + if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 231 | + $row = $select($id, $id_parent, $lier_trad); |
|
| 232 | + // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 233 | + $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 234 | + } else { |
|
| 235 | + $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 236 | + } |
|
| 237 | + if (!$new) { |
|
| 238 | + $md5 = controles_md5($row); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + if (!$row) { |
|
| 242 | + $row = array(); |
|
| 243 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 244 | + if ($desc = $trouver_table($table_objet)) { |
|
| 245 | + foreach ($desc['field'] as $k => $v) { |
|
| 246 | + $row[$k] = ''; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 253 | + // (et donc: pas de lien de traduction) |
|
| 254 | + $id = ($new or $lier_trad) |
|
| 255 | + ? 'oui' |
|
| 256 | + : $row[$id_table_objet]; |
|
| 257 | + $row[$id_table_objet] = $id; |
|
| 258 | + |
|
| 259 | + $contexte = $row; |
|
| 260 | + if (strlen($id_parent) && is_numeric($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 261 | + if (!isset($contexte['id_parent'])) { |
|
| 262 | + unset($contexte['id_rubrique']); |
|
| 263 | + } |
|
| 264 | + $contexte['id_parent'] = $id_parent; |
|
| 265 | + } elseif (!isset($contexte['id_parent'])) { |
|
| 266 | + // id_rubrique dans id_parent si possible |
|
| 267 | + if (isset($contexte['id_rubrique'])) { |
|
| 268 | + $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 269 | + unset($contexte['id_rubrique']); |
|
| 270 | + } else { |
|
| 271 | + $contexte['id_parent'] = ''; |
|
| 272 | + } |
|
| 273 | + if (!$contexte['id_parent'] |
|
| 274 | + and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 275 | + ) { |
|
| 276 | + $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + $config = array(); |
|
| 281 | + if ($config_fonc) { |
|
| 282 | + $contexte['config'] = $config = $config_fonc($contexte); |
|
| 283 | + if (!$lang_default) { |
|
| 284 | + $lang_default = $config['langue']; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + $config = $config + array( |
|
| 288 | + 'lignes' => 0, |
|
| 289 | + 'langue' => '', |
|
| 290 | + ); |
|
| 291 | + |
|
| 292 | + $att_text = " class='textarea' " |
|
| 293 | + . " rows='" |
|
| 294 | + . ($config['lignes'] + 15) |
|
| 295 | + . "' cols='40'"; |
|
| 296 | + if (isset($contexte['texte'])) { |
|
| 297 | + list($contexte['texte'], $contexte['_texte_trop_long']) = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + // on veut conserver la langue de l'interface ; |
|
| 301 | + // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 302 | + // voudrait l'exploiter |
|
| 303 | + if (isset($contexte['lang'])) { |
|
| 304 | + $contexte['langue'] = $contexte['lang']; |
|
| 305 | + unset($contexte['lang']); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 309 | + (!$lier_trad ? '' : |
|
| 310 | + ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 311 | + $lier_trad . |
|
| 312 | + "' />" . |
|
| 313 | + "\n<input type='hidden' name='changer_lang' value='" . |
|
| 314 | + $lang_default . |
|
| 315 | + "' />")) |
|
| 316 | + . $hidden |
|
| 317 | + . (isset($md5) ? $md5 : ''); |
|
| 318 | + |
|
| 319 | + // preciser que le formulaire doit passer dans un pipeline |
|
| 320 | + $contexte['_pipeline'] = array('editer_contenu_objet', array('type' => $type, 'id' => $id)); |
|
| 321 | + |
|
| 322 | + // preciser que le formulaire doit etre securise auteur/action |
|
| 323 | + // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 324 | + // on le garde pour compat |
|
| 325 | + $contexte['_action'] = array("editer_$type", $id); |
|
| 326 | + |
|
| 327 | + return $contexte; |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | /** |
@@ -335,29 +335,29 @@ discard block |
||
| 335 | 335 | * @return array |
| 336 | 336 | */ |
| 337 | 337 | function coupe_trop_long($texte) { |
| 338 | - $aider = charger_fonction('aider', 'inc'); |
|
| 339 | - if (strlen($texte) > 28 * 1024) { |
|
| 340 | - $texte = str_replace("\r\n", "\n", $texte); |
|
| 341 | - $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 342 | - if ($pos > 0 and $pos < 32 * 1024) { |
|
| 343 | - $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 344 | - $suite = substr($texte, $pos + 2); |
|
| 345 | - } else { |
|
| 346 | - $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 347 | - if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 348 | - $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 349 | - $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 350 | - } else { |
|
| 351 | - $decalage = 1; |
|
| 352 | - } |
|
| 353 | - $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 354 | - $suite = substr($texte, $pos + $decalage); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - return (array($debut, $suite)); |
|
| 358 | - } else { |
|
| 359 | - return (array($texte, '')); |
|
| 360 | - } |
|
| 338 | + $aider = charger_fonction('aider', 'inc'); |
|
| 339 | + if (strlen($texte) > 28 * 1024) { |
|
| 340 | + $texte = str_replace("\r\n", "\n", $texte); |
|
| 341 | + $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 342 | + if ($pos > 0 and $pos < 32 * 1024) { |
|
| 343 | + $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 344 | + $suite = substr($texte, $pos + 2); |
|
| 345 | + } else { |
|
| 346 | + $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 347 | + if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 348 | + $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 349 | + $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 350 | + } else { |
|
| 351 | + $decalage = 1; |
|
| 352 | + } |
|
| 353 | + $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 354 | + $suite = substr($texte, $pos + $decalage); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + return (array($debut, $suite)); |
|
| 358 | + } else { |
|
| 359 | + return (array($texte, '')); |
|
| 360 | + } |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -368,24 +368,24 @@ discard block |
||
| 368 | 368 | * @return array |
| 369 | 369 | */ |
| 370 | 370 | function editer_texte_recolle($texte, $att_text) { |
| 371 | - if ((strlen($texte) < 29 * 1024) |
|
| 372 | - or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 373 | - ) { |
|
| 374 | - return array($texte, ''); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - include_spip('inc/barre'); |
|
| 378 | - $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 379 | - $nombre = 0; |
|
| 380 | - |
|
| 381 | - while (strlen($texte) > 29 * 1024) { |
|
| 382 | - $nombre++; |
|
| 383 | - list($texte1, $texte) = coupe_trop_long($texte); |
|
| 384 | - $textes_supplement .= '<br />' . |
|
| 385 | - "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - return array($texte, $textes_supplement); |
|
| 371 | + if ((strlen($texte) < 29 * 1024) |
|
| 372 | + or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 373 | + ) { |
|
| 374 | + return array($texte, ''); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + include_spip('inc/barre'); |
|
| 378 | + $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 379 | + $nombre = 0; |
|
| 380 | + |
|
| 381 | + while (strlen($texte) > 29 * 1024) { |
|
| 382 | + $nombre++; |
|
| 383 | + list($texte1, $texte) = coupe_trop_long($texte); |
|
| 384 | + $textes_supplement .= '<br />' . |
|
| 385 | + "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + return array($texte, $textes_supplement); |
|
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | /** |
@@ -396,17 +396,17 @@ discard block |
||
| 396 | 396 | * @param int $longueur |
| 397 | 397 | */ |
| 398 | 398 | function titre_automatique($champ_titre, $champs_contenu, $longueur = null) { |
| 399 | - if (!_request($champ_titre)) { |
|
| 400 | - $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 401 | - if (!is_null($longueur)) { |
|
| 402 | - $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 403 | - } else { |
|
| 404 | - $t = $titrer_contenu($champs_contenu); |
|
| 405 | - } |
|
| 406 | - if ($t) { |
|
| 407 | - set_request($champ_titre, $t); |
|
| 408 | - } |
|
| 409 | - } |
|
| 399 | + if (!_request($champ_titre)) { |
|
| 400 | + $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 401 | + if (!is_null($longueur)) { |
|
| 402 | + $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 403 | + } else { |
|
| 404 | + $t = $titrer_contenu($champs_contenu); |
|
| 405 | + } |
|
| 406 | + if ($t) { |
|
| 407 | + set_request($champ_titre, $t); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | /** |
@@ -426,20 +426,20 @@ discard block |
||
| 426 | 426 | * @return string |
| 427 | 427 | */ |
| 428 | 428 | function inc_titrer_contenu_dist($champs_contenu, $c = null, $longueur = 50) { |
| 429 | - // trouver un champ texte non vide |
|
| 430 | - $t = ''; |
|
| 431 | - foreach ($champs_contenu as $champ) { |
|
| 432 | - if ($t = _request($champ, $c)) { |
|
| 433 | - break; |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - if ($t) { |
|
| 438 | - include_spip('inc/texte_mini'); |
|
| 439 | - $t = couper($t, $longueur, '...'); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return $t; |
|
| 429 | + // trouver un champ texte non vide |
|
| 430 | + $t = ''; |
|
| 431 | + foreach ($champs_contenu as $champ) { |
|
| 432 | + if ($t = _request($champ, $c)) { |
|
| 433 | + break; |
|
| 434 | + } |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + if ($t) { |
|
| 438 | + include_spip('inc/texte_mini'); |
|
| 439 | + $t = couper($t, $longueur, '...'); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return $t; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -462,30 +462,30 @@ discard block |
||
| 462 | 462 | * - array sinon couples ('$prefixe$colonne => md5) |
| 463 | 463 | **/ |
| 464 | 464 | function controles_md5($data, $prefixe = 'ctr_', $format = 'html') { |
| 465 | - if (!is_array($data)) { |
|
| 466 | - return false; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - $ctr = array(); |
|
| 470 | - foreach ($data as $key => $val) { |
|
| 471 | - $m = md5($val); |
|
| 472 | - $k = $prefixe . $key; |
|
| 473 | - |
|
| 474 | - switch ($format) { |
|
| 475 | - case 'html': |
|
| 476 | - $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 477 | - break; |
|
| 478 | - default: |
|
| 479 | - $ctr[$k] = $m; |
|
| 480 | - break; |
|
| 481 | - } |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - if ($format == 'html') { |
|
| 485 | - return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 486 | - } else { |
|
| 487 | - return $ctr; |
|
| 488 | - } |
|
| 465 | + if (!is_array($data)) { |
|
| 466 | + return false; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + $ctr = array(); |
|
| 470 | + foreach ($data as $key => $val) { |
|
| 471 | + $m = md5($val); |
|
| 472 | + $k = $prefixe . $key; |
|
| 473 | + |
|
| 474 | + switch ($format) { |
|
| 475 | + case 'html': |
|
| 476 | + $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 477 | + break; |
|
| 478 | + default: |
|
| 479 | + $ctr[$k] = $m; |
|
| 480 | + break; |
|
| 481 | + } |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + if ($format == 'html') { |
|
| 485 | + return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 486 | + } else { |
|
| 487 | + return $ctr; |
|
| 488 | + } |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -524,79 +524,79 @@ discard block |
||
| 524 | 524 | * - post : le contenu posté |
| 525 | 525 | **/ |
| 526 | 526 | function controler_contenu($type, $id, $options = array(), $c = false, $serveur = '') { |
| 527 | - include_spip('inc/filtres'); |
|
| 528 | - |
|
| 529 | - $table_objet = table_objet($type); |
|
| 530 | - $spip_table_objet = table_objet_sql($type); |
|
| 531 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 532 | - $desc = $trouver_table($table_objet, $serveur); |
|
| 533 | - |
|
| 534 | - // Appels incomplets (sans $c) |
|
| 535 | - if (!is_array($c)) { |
|
| 536 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 537 | - if (_request($champ)) { |
|
| 538 | - $c[$champ] = _request($champ); |
|
| 539 | - } |
|
| 540 | - } |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - // Securite : certaines variables ne sont jamais acceptees ici |
|
| 544 | - // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 545 | - // il faut passer par instituer_XX() |
|
| 546 | - // TODO: faut-il passer ces variables interdites |
|
| 547 | - // dans un fichier de description separe ? |
|
| 548 | - unset($c['statut']); |
|
| 549 | - unset($c['id_parent']); |
|
| 550 | - unset($c['id_rubrique']); |
|
| 551 | - unset($c['id_secteur']); |
|
| 552 | - |
|
| 553 | - // Gerer les champs non vides |
|
| 554 | - if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 555 | - foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 556 | - if ($c[$champ] === '') { |
|
| 557 | - $c[$champ] = $sinon; |
|
| 558 | - } |
|
| 559 | - } |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - // N'accepter que les champs qui existent |
|
| 563 | - // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 564 | - $champs = array(); |
|
| 565 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 566 | - if (isset($c[$champ])) { |
|
| 567 | - $champs[$champ] = $c[$champ]; |
|
| 568 | - } |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - // Nettoyer les valeurs |
|
| 572 | - $champs = array_map('corriger_caracteres', $champs); |
|
| 573 | - |
|
| 574 | - // Envoyer aux plugins |
|
| 575 | - $champs = pipeline( |
|
| 576 | - 'pre_edition', |
|
| 577 | - array( |
|
| 578 | - 'args' => array( |
|
| 579 | - 'table' => $spip_table_objet, // compatibilite |
|
| 580 | - 'table_objet' => $table_objet, |
|
| 581 | - 'spip_table_objet' => $spip_table_objet, |
|
| 582 | - 'type' => $type, |
|
| 583 | - 'id_objet' => $id, |
|
| 584 | - 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ? |
|
| 585 | - 'action' => 'controler', |
|
| 586 | - 'serveur' => $serveur, |
|
| 587 | - ), |
|
| 588 | - 'data' => $champs |
|
| 589 | - ) |
|
| 590 | - ); |
|
| 591 | - |
|
| 592 | - if (!$champs) { |
|
| 593 | - return false; |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 597 | - $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, isset($options['prefix']) ? $options['prefix'] : 'ctr_'); |
|
| 598 | - |
|
| 599 | - return $conflits; |
|
| 527 | + include_spip('inc/filtres'); |
|
| 528 | + |
|
| 529 | + $table_objet = table_objet($type); |
|
| 530 | + $spip_table_objet = table_objet_sql($type); |
|
| 531 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 532 | + $desc = $trouver_table($table_objet, $serveur); |
|
| 533 | + |
|
| 534 | + // Appels incomplets (sans $c) |
|
| 535 | + if (!is_array($c)) { |
|
| 536 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 537 | + if (_request($champ)) { |
|
| 538 | + $c[$champ] = _request($champ); |
|
| 539 | + } |
|
| 540 | + } |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + // Securite : certaines variables ne sont jamais acceptees ici |
|
| 544 | + // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 545 | + // il faut passer par instituer_XX() |
|
| 546 | + // TODO: faut-il passer ces variables interdites |
|
| 547 | + // dans un fichier de description separe ? |
|
| 548 | + unset($c['statut']); |
|
| 549 | + unset($c['id_parent']); |
|
| 550 | + unset($c['id_rubrique']); |
|
| 551 | + unset($c['id_secteur']); |
|
| 552 | + |
|
| 553 | + // Gerer les champs non vides |
|
| 554 | + if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 555 | + foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 556 | + if ($c[$champ] === '') { |
|
| 557 | + $c[$champ] = $sinon; |
|
| 558 | + } |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + // N'accepter que les champs qui existent |
|
| 563 | + // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 564 | + $champs = array(); |
|
| 565 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 566 | + if (isset($c[$champ])) { |
|
| 567 | + $champs[$champ] = $c[$champ]; |
|
| 568 | + } |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + // Nettoyer les valeurs |
|
| 572 | + $champs = array_map('corriger_caracteres', $champs); |
|
| 573 | + |
|
| 574 | + // Envoyer aux plugins |
|
| 575 | + $champs = pipeline( |
|
| 576 | + 'pre_edition', |
|
| 577 | + array( |
|
| 578 | + 'args' => array( |
|
| 579 | + 'table' => $spip_table_objet, // compatibilite |
|
| 580 | + 'table_objet' => $table_objet, |
|
| 581 | + 'spip_table_objet' => $spip_table_objet, |
|
| 582 | + 'type' => $type, |
|
| 583 | + 'id_objet' => $id, |
|
| 584 | + 'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ? |
|
| 585 | + 'action' => 'controler', |
|
| 586 | + 'serveur' => $serveur, |
|
| 587 | + ), |
|
| 588 | + 'data' => $champs |
|
| 589 | + ) |
|
| 590 | + ); |
|
| 591 | + |
|
| 592 | + if (!$champs) { |
|
| 593 | + return false; |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 597 | + $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, isset($options['prefix']) ? $options['prefix'] : 'ctr_'); |
|
| 598 | + |
|
| 599 | + return $conflits; |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
@@ -626,63 +626,63 @@ discard block |
||
| 626 | 626 | * - post : le contenu posté |
| 627 | 627 | **/ |
| 628 | 628 | function controler_md5(&$champs, $ctr, $type, $id, $serveur, $prefix = 'ctr_') { |
| 629 | - $spip_table_objet = table_objet_sql($type); |
|
| 630 | - $id_table_objet = id_table_objet($type); |
|
| 631 | - |
|
| 632 | - // Controle des MD5 envoyes |
|
| 633 | - // On elimine les donnees non modifiees par le formulaire (mais |
|
| 634 | - // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 635 | - foreach ($champs as $key => $val) { |
|
| 636 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 637 | - if (is_scalar($val) and $m == md5($val)) { |
|
| 638 | - unset($champs[$key]); |
|
| 639 | - } |
|
| 640 | - } |
|
| 641 | - } |
|
| 642 | - if (!$champs) { |
|
| 643 | - return; |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - // On veut savoir si notre modif va avoir un impact |
|
| 647 | - // par rapport aux donnees contenues dans la base |
|
| 648 | - // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 649 | - $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 650 | - $intact = true; |
|
| 651 | - foreach ($champs as $ch => $val) { |
|
| 652 | - $intact &= ($s[$ch] == $val); |
|
| 653 | - } |
|
| 654 | - if ($intact) { |
|
| 655 | - return; |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - // Detection de conflits : |
|
| 659 | - // On verifie si notre modif ne provient pas d'un formulaire |
|
| 660 | - // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 661 | - // on compare a ce qui est dans la base, et on bloque en cas |
|
| 662 | - // de conflit. |
|
| 663 | - $ctrh = $ctrq = $conflits = array(); |
|
| 664 | - foreach (array_keys($champs) as $key) { |
|
| 665 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 666 | - $ctrh[$key] = $m; |
|
| 667 | - $ctrq[] = $key; |
|
| 668 | - } |
|
| 669 | - } |
|
| 670 | - if ($ctrq) { |
|
| 671 | - $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 672 | - foreach ($ctrh as $key => $m) { |
|
| 673 | - if ($m != md5($ctrq[$key]) |
|
| 674 | - and $champs[$key] !== $ctrq[$key] |
|
| 675 | - ) { |
|
| 676 | - $conflits[$key] = array( |
|
| 677 | - 'base' => $ctrq[$key], |
|
| 678 | - 'post' => $champs[$key] |
|
| 679 | - ); |
|
| 680 | - unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 681 | - } |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - |
|
| 685 | - return $conflits; |
|
| 629 | + $spip_table_objet = table_objet_sql($type); |
|
| 630 | + $id_table_objet = id_table_objet($type); |
|
| 631 | + |
|
| 632 | + // Controle des MD5 envoyes |
|
| 633 | + // On elimine les donnees non modifiees par le formulaire (mais |
|
| 634 | + // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 635 | + foreach ($champs as $key => $val) { |
|
| 636 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 637 | + if (is_scalar($val) and $m == md5($val)) { |
|
| 638 | + unset($champs[$key]); |
|
| 639 | + } |
|
| 640 | + } |
|
| 641 | + } |
|
| 642 | + if (!$champs) { |
|
| 643 | + return; |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + // On veut savoir si notre modif va avoir un impact |
|
| 647 | + // par rapport aux donnees contenues dans la base |
|
| 648 | + // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 649 | + $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 650 | + $intact = true; |
|
| 651 | + foreach ($champs as $ch => $val) { |
|
| 652 | + $intact &= ($s[$ch] == $val); |
|
| 653 | + } |
|
| 654 | + if ($intact) { |
|
| 655 | + return; |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + // Detection de conflits : |
|
| 659 | + // On verifie si notre modif ne provient pas d'un formulaire |
|
| 660 | + // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 661 | + // on compare a ce qui est dans la base, et on bloque en cas |
|
| 662 | + // de conflit. |
|
| 663 | + $ctrh = $ctrq = $conflits = array(); |
|
| 664 | + foreach (array_keys($champs) as $key) { |
|
| 665 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 666 | + $ctrh[$key] = $m; |
|
| 667 | + $ctrq[] = $key; |
|
| 668 | + } |
|
| 669 | + } |
|
| 670 | + if ($ctrq) { |
|
| 671 | + $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 672 | + foreach ($ctrh as $key => $m) { |
|
| 673 | + if ($m != md5($ctrq[$key]) |
|
| 674 | + and $champs[$key] !== $ctrq[$key] |
|
| 675 | + ) { |
|
| 676 | + $conflits[$key] = array( |
|
| 677 | + 'base' => $ctrq[$key], |
|
| 678 | + 'post' => $champs[$key] |
|
| 679 | + ); |
|
| 680 | + unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + |
|
| 685 | + return $conflits; |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | /** |
@@ -694,11 +694,11 @@ discard block |
||
| 694 | 694 | * @return string |
| 695 | 695 | */ |
| 696 | 696 | function display_conflit_champ($x) { |
| 697 | - if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 698 | - return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 699 | - } else { |
|
| 700 | - return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 701 | - } |
|
| 697 | + if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 698 | + return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 699 | + } else { |
|
| 700 | + return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 701 | + } |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | /** |
@@ -716,57 +716,57 @@ discard block |
||
| 716 | 716 | * @return string |
| 717 | 717 | */ |
| 718 | 718 | function signaler_conflits_edition($conflits, $redirect = '') { |
| 719 | - include_spip('inc/minipres'); |
|
| 720 | - include_spip('inc/revisions'); |
|
| 721 | - include_spip('afficher_diff/champ'); |
|
| 722 | - include_spip('inc/suivi_versions'); |
|
| 723 | - include_spip('inc/diff'); |
|
| 724 | - $diffs = array(); |
|
| 725 | - foreach ($conflits as $champ => $a) { |
|
| 726 | - // probleme de stockage ou conflit d'edition ? |
|
| 727 | - $base = isset($a['save']) ? $a['save'] : $a['base']; |
|
| 728 | - |
|
| 729 | - $diff = new Diff(new DiffTexte); |
|
| 730 | - $n = preparer_diff($a['post']); |
|
| 731 | - $o = preparer_diff($base); |
|
| 732 | - $d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o)))); |
|
| 733 | - |
|
| 734 | - $titre = isset($a['save']) ? _L( |
|
| 735 | - 'Echec lors de l\'enregistrement du champ @champ@', |
|
| 736 | - array('champ' => $champ) |
|
| 737 | - ) : $champ; |
|
| 738 | - |
|
| 739 | - $diffs[] = "<h2>$titre</h2>\n" |
|
| 740 | - . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 741 | - . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 742 | - . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 743 | - . display_conflit_champ($a['post']) |
|
| 744 | - . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 745 | - . display_conflit_champ($base); |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - if ($redirect) { |
|
| 749 | - $id = uniqid(rand()); |
|
| 750 | - $redirect = "<form action='$redirect' method='get' |
|
| 719 | + include_spip('inc/minipres'); |
|
| 720 | + include_spip('inc/revisions'); |
|
| 721 | + include_spip('afficher_diff/champ'); |
|
| 722 | + include_spip('inc/suivi_versions'); |
|
| 723 | + include_spip('inc/diff'); |
|
| 724 | + $diffs = array(); |
|
| 725 | + foreach ($conflits as $champ => $a) { |
|
| 726 | + // probleme de stockage ou conflit d'edition ? |
|
| 727 | + $base = isset($a['save']) ? $a['save'] : $a['base']; |
|
| 728 | + |
|
| 729 | + $diff = new Diff(new DiffTexte); |
|
| 730 | + $n = preparer_diff($a['post']); |
|
| 731 | + $o = preparer_diff($base); |
|
| 732 | + $d = propre_diff(afficher_para_modifies(afficher_diff($diff->comparer($n, $o)))); |
|
| 733 | + |
|
| 734 | + $titre = isset($a['save']) ? _L( |
|
| 735 | + 'Echec lors de l\'enregistrement du champ @champ@', |
|
| 736 | + array('champ' => $champ) |
|
| 737 | + ) : $champ; |
|
| 738 | + |
|
| 739 | + $diffs[] = "<h2>$titre</h2>\n" |
|
| 740 | + . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 741 | + . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 742 | + . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 743 | + . display_conflit_champ($a['post']) |
|
| 744 | + . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 745 | + . display_conflit_champ($base); |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + if ($redirect) { |
|
| 749 | + $id = uniqid(rand()); |
|
| 750 | + $redirect = "<form action='$redirect' method='get' |
|
| 751 | 751 | id='$id' |
| 752 | 752 | style='float:" . $GLOBALS['spip_lang_right'] . "; margin-top:2em;'>\n" |
| 753 | - . form_hidden($redirect) |
|
| 754 | - . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 753 | + . form_hidden($redirect) |
|
| 754 | + . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 755 | 755 | </form>\n"; |
| 756 | 756 | |
| 757 | - // pour les documents, on est probablement en ajax : il faut ajaxer |
|
| 758 | - if (_AJAX) { |
|
| 759 | - $redirect .= '<script type="text/javascript">' |
|
| 760 | - . 'setTimeout(function(){$("#' . $id . '") |
|
| 757 | + // pour les documents, on est probablement en ajax : il faut ajaxer |
|
| 758 | + if (_AJAX) { |
|
| 759 | + $redirect .= '<script type="text/javascript">' |
|
| 760 | + . 'setTimeout(function(){$("#' . $id . '") |
|
| 761 | 761 | .ajaxForm({target:$("#' . $id . '").parent()}); |
| 762 | 762 | }, 200);' |
| 763 | - . "</script>\n"; |
|
| 764 | - } |
|
| 765 | - } |
|
| 763 | + . "</script>\n"; |
|
| 764 | + } |
|
| 765 | + } |
|
| 766 | 766 | |
| 767 | - echo minipres( |
|
| 768 | - _T('titre_conflit_edition'), |
|
| 769 | - '<style> |
|
| 767 | + echo minipres( |
|
| 768 | + _T('titre_conflit_edition'), |
|
| 769 | + '<style> |
|
| 770 | 770 | .diff-para-deplace { background: #e8e8ff; } |
| 771 | 771 | .diff-para-ajoute { background: #d0ffc0; color: #000; } |
| 772 | 772 | .diff-para-supprime { background: #ffd0c0; color: #904040; text-decoration: line-through; } |
@@ -777,12 +777,12 @@ discard block |
||
| 777 | 777 | .diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; } |
| 778 | 778 | .diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; } |
| 779 | 779 | </style>' |
| 780 | - . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 781 | - . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 782 | - . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 783 | - . join("\n", $diffs) |
|
| 784 | - . "</div>\n" |
|
| 785 | - |
|
| 786 | - . $redirect |
|
| 787 | - ); |
|
| 780 | + . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 781 | + . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 782 | + . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 783 | + . join("\n", $diffs) |
|
| 784 | + . "</div>\n" |
|
| 785 | + |
|
| 786 | + . $redirect |
|
| 787 | + ); |
|
| 788 | 788 | } |
@@ -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 | } |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | // on accepte pas une fonction de config inconnue si elle vient d'un modele |
| 216 | 216 | if ($config_fonc |
| 217 | 217 | and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
| 218 | - and $config_fonc !== $table_objet . '_edit_config') { |
|
| 218 | + and $config_fonc !== $table_objet.'_edit_config') { |
|
| 219 | 219 | if ($args = test_formulaire_inclus_par_modele() |
| 220 | 220 | and in_array($config_fonc, $args)) { |
| 221 | 221 | $config_fonc = ''; |
@@ -227,12 +227,12 @@ discard block |
||
| 227 | 227 | // Appel direct dans un squelette |
| 228 | 228 | if (!$row) { |
| 229 | 229 | if (!$new or $lier_trad) { |
| 230 | - if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 230 | + if ($select = charger_fonction('precharger_'.$type, 'inc', true)) { |
|
| 231 | 231 | $row = $select($id, $id_parent, $lier_trad); |
| 232 | 232 | // si on a une fonction precharger, elle pu faire un reglage de langue |
| 233 | 233 | $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
| 234 | 234 | } else { |
| 235 | - $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 235 | + $row = sql_fetsel('*', $table_objet_sql, $id_table_objet.'='.intval($id)); |
|
| 236 | 236 | } |
| 237 | 237 | if (!$new) { |
| 238 | 238 | $md5 = controles_md5($row); |
@@ -305,13 +305,12 @@ discard block |
||
| 305 | 305 | unset($contexte['lang']); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 309 | - (!$lier_trad ? '' : |
|
| 310 | - ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 311 | - $lier_trad . |
|
| 312 | - "' />" . |
|
| 313 | - "\n<input type='hidden' name='changer_lang' value='" . |
|
| 314 | - $lang_default . |
|
| 308 | + $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n". |
|
| 309 | + (!$lier_trad ? '' : ("\n<input type='hidden' name='lier_trad' value='". |
|
| 310 | + $lier_trad. |
|
| 311 | + "' />". |
|
| 312 | + "\n<input type='hidden' name='changer_lang' value='". |
|
| 313 | + $lang_default. |
|
| 315 | 314 | "' />")) |
| 316 | 315 | . $hidden |
| 317 | 316 | . (isset($md5) ? $md5 : ''); |
@@ -338,14 +337,14 @@ discard block |
||
| 338 | 337 | $aider = charger_fonction('aider', 'inc'); |
| 339 | 338 | if (strlen($texte) > 28 * 1024) { |
| 340 | 339 | $texte = str_replace("\r\n", "\n", $texte); |
| 341 | - $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 340 | + $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 342 | 341 | if ($pos > 0 and $pos < 32 * 1024) { |
| 343 | - $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 342 | + $debut = substr($texte, 0, $pos)."\n\n<!--SPIP-->\n"; |
|
| 344 | 343 | $suite = substr($texte, $pos + 2); |
| 345 | 344 | } else { |
| 346 | - $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 345 | + $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 347 | 346 | if (!($pos > 0 and $pos < 32 * 1024)) { |
| 348 | - $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 347 | + $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 349 | 348 | $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
| 350 | 349 | } else { |
| 351 | 350 | $decalage = 1; |
@@ -375,13 +374,13 @@ discard block |
||
| 375 | 374 | } |
| 376 | 375 | |
| 377 | 376 | include_spip('inc/barre'); |
| 378 | - $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 377 | + $textes_supplement = "<br /><span style='color: red'>"._T('info_texte_long')."</span>\n"; |
|
| 379 | 378 | $nombre = 0; |
| 380 | 379 | |
| 381 | 380 | while (strlen($texte) > 29 * 1024) { |
| 382 | 381 | $nombre++; |
| 383 | 382 | list($texte1, $texte) = coupe_trop_long($texte); |
| 384 | - $textes_supplement .= '<br />' . |
|
| 383 | + $textes_supplement .= '<br />'. |
|
| 385 | 384 | "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
| 386 | 385 | } |
| 387 | 386 | |
@@ -469,7 +468,7 @@ discard block |
||
| 469 | 468 | $ctr = array(); |
| 470 | 469 | foreach ($data as $key => $val) { |
| 471 | 470 | $m = md5($val); |
| 472 | - $k = $prefixe . $key; |
|
| 471 | + $k = $prefixe.$key; |
|
| 473 | 472 | |
| 474 | 473 | switch ($format) { |
| 475 | 474 | case 'html': |
@@ -482,7 +481,7 @@ discard block |
||
| 482 | 481 | } |
| 483 | 482 | |
| 484 | 483 | if ($format == 'html') { |
| 485 | - return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 484 | + return "\n\n<!-- controles md5 -->\n".join("\n", $ctr)."\n\n"; |
|
| 486 | 485 | } else { |
| 487 | 486 | return $ctr; |
| 488 | 487 | } |
@@ -633,7 +632,7 @@ discard block |
||
| 633 | 632 | // On elimine les donnees non modifiees par le formulaire (mais |
| 634 | 633 | // potentiellement modifiees entre temps par un autre utilisateur) |
| 635 | 634 | foreach ($champs as $key => $val) { |
| 636 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 635 | + if (isset($ctr[$prefix.$key]) and $m = $ctr[$prefix.$key]) { |
|
| 637 | 636 | if (is_scalar($val) and $m == md5($val)) { |
| 638 | 637 | unset($champs[$key]); |
| 639 | 638 | } |
@@ -662,7 +661,7 @@ discard block |
||
| 662 | 661 | // de conflit. |
| 663 | 662 | $ctrh = $ctrq = $conflits = array(); |
| 664 | 663 | foreach (array_keys($champs) as $key) { |
| 665 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 664 | + if (isset($ctr[$prefix.$key]) and $m = $ctr[$prefix.$key]) { |
|
| 666 | 665 | $ctrh[$key] = $m; |
| 667 | 666 | $ctrq[] = $key; |
| 668 | 667 | } |
@@ -695,9 +694,9 @@ discard block |
||
| 695 | 694 | */ |
| 696 | 695 | function display_conflit_champ($x) { |
| 697 | 696 | if (strstr($x, "\n") or strlen($x) > 80) { |
| 698 | - return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 697 | + return "<textarea style='width:99%; height:10em;'>".entites_html($x)."</textarea>\n"; |
|
| 699 | 698 | } else { |
| 700 | - return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 699 | + return "<input type='text' size='40' style='width:99%' value=\"".entites_html($x)."\" />\n"; |
|
| 701 | 700 | } |
| 702 | 701 | } |
| 703 | 702 | |
@@ -737,11 +736,11 @@ discard block |
||
| 737 | 736 | ) : $champ; |
| 738 | 737 | |
| 739 | 738 | $diffs[] = "<h2>$titre</h2>\n" |
| 740 | - . '<h3>' . _T('info_conflit_edition_differences') . "</h3>\n" |
|
| 741 | - . "<div style='max-height:8em; overflow: auto; width:99%;'>" . $d . "</div>\n" |
|
| 742 | - . '<h4>' . _T('info_conflit_edition_votre_version') . '</h4>' |
|
| 739 | + . '<h3>'._T('info_conflit_edition_differences')."</h3>\n" |
|
| 740 | + . "<div style='max-height:8em; overflow: auto; width:99%;'>".$d."</div>\n" |
|
| 741 | + . '<h4>'._T('info_conflit_edition_votre_version').'</h4>' |
|
| 743 | 742 | . display_conflit_champ($a['post']) |
| 744 | - . '<h4>' . _T('info_conflit_edition_version_enregistree') . '</h4>' |
|
| 743 | + . '<h4>'._T('info_conflit_edition_version_enregistree').'</h4>' |
|
| 745 | 744 | . display_conflit_champ($base); |
| 746 | 745 | } |
| 747 | 746 | |
@@ -749,16 +748,16 @@ discard block |
||
| 749 | 748 | $id = uniqid(rand()); |
| 750 | 749 | $redirect = "<form action='$redirect' method='get' |
| 751 | 750 | id='$id' |
| 752 | - style='float:" . $GLOBALS['spip_lang_right'] . "; margin-top:2em;'>\n" |
|
| 751 | + style='float:".$GLOBALS['spip_lang_right']."; margin-top:2em;'>\n" |
|
| 753 | 752 | . form_hidden($redirect) |
| 754 | - . "<input type='submit' value='" . _T('icone_retour') . "' /> |
|
| 753 | + . "<input type='submit' value='"._T('icone_retour')."' /> |
|
| 755 | 754 | </form>\n"; |
| 756 | 755 | |
| 757 | 756 | // pour les documents, on est probablement en ajax : il faut ajaxer |
| 758 | 757 | if (_AJAX) { |
| 759 | 758 | $redirect .= '<script type="text/javascript">' |
| 760 | - . 'setTimeout(function(){$("#' . $id . '") |
|
| 761 | - .ajaxForm({target:$("#' . $id . '").parent()}); |
|
| 759 | + . 'setTimeout(function(){$("#'.$id.'") |
|
| 760 | + .ajaxForm({target:$("#' . $id.'").parent()}); |
|
| 762 | 761 | }, 200);' |
| 763 | 762 | . "</script>\n"; |
| 764 | 763 | } |
@@ -777,9 +776,9 @@ discard block |
||
| 777 | 776 | .diff-para-deplace .diff-supprime { background: #ffb8b8; border: 1px solid #808080; } |
| 778 | 777 | .diff-para-deplace .diff-deplace { background: #b8b8ff; border: 1px solid #808080; } |
| 779 | 778 | </style>' |
| 780 | - . '<p>' . _T('info_conflit_edition_avis_non_sauvegarde') . '</p>' |
|
| 781 | - . '<p>' . _T('texte_conflit_edition_correction') . '</p>' |
|
| 782 | - . "<div style='text-align:" . $GLOBALS['spip_lang_left'] . ";'>" |
|
| 779 | + . '<p>'._T('info_conflit_edition_avis_non_sauvegarde').'</p>' |
|
| 780 | + . '<p>'._T('texte_conflit_edition_correction').'</p>' |
|
| 781 | + . "<div style='text-align:".$GLOBALS['spip_lang_left'].";'>" |
|
| 783 | 782 | . join("\n", $diffs) |
| 784 | 783 | . "</div>\n" |
| 785 | 784 | |
@@ -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/autoriser'); // necessaire si appel de l'espace public |
@@ -45,69 +45,69 @@ discard block |
||
| 45 | 45 | **/ |
| 46 | 46 | function precharger_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $champ_titre = 'titre') { |
| 47 | 47 | |
| 48 | - $table = table_objet_sql($type); |
|
| 49 | - $_id_objet = id_table_objet($table); |
|
| 50 | - |
|
| 51 | - // si l'objet existe deja, on retourne simplement ses valeurs |
|
| 52 | - if (is_numeric($id_objet)) { |
|
| 53 | - return sql_fetsel("*", $table, "$_id_objet=".intval($id_objet)); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - // ici, on demande une creation. |
|
| 57 | - // on prerempli certains elements : les champs si traduction, |
|
| 58 | - // les id_rubrique et id_secteur si l'objet a ces champs |
|
| 59 | - $desc = lister_tables_objets_sql($table); |
|
| 60 | - # il faudrait calculer $champ_titre ici |
|
| 61 | - $is_rubrique = isset($desc['field']['id_rubrique']); |
|
| 62 | - $is_secteur = isset($desc['field']['id_secteur']); |
|
| 63 | - |
|
| 64 | - // si demande de traduction |
|
| 65 | - // on recupere les valeurs de la traduction |
|
| 66 | - if ($lier_trad) { |
|
| 67 | - if ($select = charger_fonction("precharger_traduction_" . $type, 'inc', true)) { |
|
| 68 | - $row = $select($id_objet, $id_rubrique, $lier_trad); |
|
| 69 | - } else { |
|
| 70 | - $row = precharger_traduction_objet($type, $id_objet, $id_rubrique, $lier_trad, $champ_titre); |
|
| 71 | - } |
|
| 72 | - } else { |
|
| 73 | - $row[$champ_titre] = ''; |
|
| 74 | - if ($is_rubrique) { |
|
| 75 | - $row['id_rubrique'] = $id_rubrique; |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - // calcul de la rubrique |
|
| 80 | - # note : comment faire pour des traductions sur l'objet rubriques ? |
|
| 81 | - if ($is_rubrique) { |
|
| 82 | - // appel du script a la racine, faut choisir |
|
| 83 | - // admin restreint ==> sa premiere rubrique |
|
| 84 | - // autre ==> la derniere rubrique cree |
|
| 85 | - if (!$row['id_rubrique']) { |
|
| 86 | - if ($GLOBALS['connect_id_rubrique']) { |
|
| 87 | - $row['id_rubrique'] = $id_rubrique = current($GLOBALS['connect_id_rubrique']); |
|
| 88 | - } else { |
|
| 89 | - $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", 1); |
|
| 90 | - $row['id_rubrique'] = $id_rubrique = $row_rub['id_rubrique']; |
|
| 91 | - } |
|
| 92 | - if (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique'])) { |
|
| 93 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 94 | - $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 95 | - while (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique']) && $row_rub = sql_fetch($res)) { |
|
| 96 | - $row['id_rubrique'] = $row_rub['id_rubrique']; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // recuperer le secteur, pour affecter les bons champs extras |
|
| 103 | - if ($id_rubrique and $is_secteur) { |
|
| 104 | - if (!$row['id_secteur']) { |
|
| 105 | - $row_rub = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=" . sql_quote($id_rubrique)); |
|
| 106 | - $row['id_secteur'] = $row_rub; |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return $row; |
|
| 48 | + $table = table_objet_sql($type); |
|
| 49 | + $_id_objet = id_table_objet($table); |
|
| 50 | + |
|
| 51 | + // si l'objet existe deja, on retourne simplement ses valeurs |
|
| 52 | + if (is_numeric($id_objet)) { |
|
| 53 | + return sql_fetsel("*", $table, "$_id_objet=".intval($id_objet)); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + // ici, on demande une creation. |
|
| 57 | + // on prerempli certains elements : les champs si traduction, |
|
| 58 | + // les id_rubrique et id_secteur si l'objet a ces champs |
|
| 59 | + $desc = lister_tables_objets_sql($table); |
|
| 60 | + # il faudrait calculer $champ_titre ici |
|
| 61 | + $is_rubrique = isset($desc['field']['id_rubrique']); |
|
| 62 | + $is_secteur = isset($desc['field']['id_secteur']); |
|
| 63 | + |
|
| 64 | + // si demande de traduction |
|
| 65 | + // on recupere les valeurs de la traduction |
|
| 66 | + if ($lier_trad) { |
|
| 67 | + if ($select = charger_fonction("precharger_traduction_" . $type, 'inc', true)) { |
|
| 68 | + $row = $select($id_objet, $id_rubrique, $lier_trad); |
|
| 69 | + } else { |
|
| 70 | + $row = precharger_traduction_objet($type, $id_objet, $id_rubrique, $lier_trad, $champ_titre); |
|
| 71 | + } |
|
| 72 | + } else { |
|
| 73 | + $row[$champ_titre] = ''; |
|
| 74 | + if ($is_rubrique) { |
|
| 75 | + $row['id_rubrique'] = $id_rubrique; |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + // calcul de la rubrique |
|
| 80 | + # note : comment faire pour des traductions sur l'objet rubriques ? |
|
| 81 | + if ($is_rubrique) { |
|
| 82 | + // appel du script a la racine, faut choisir |
|
| 83 | + // admin restreint ==> sa premiere rubrique |
|
| 84 | + // autre ==> la derniere rubrique cree |
|
| 85 | + if (!$row['id_rubrique']) { |
|
| 86 | + if ($GLOBALS['connect_id_rubrique']) { |
|
| 87 | + $row['id_rubrique'] = $id_rubrique = current($GLOBALS['connect_id_rubrique']); |
|
| 88 | + } else { |
|
| 89 | + $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", "", "", "id_rubrique DESC", 1); |
|
| 90 | + $row['id_rubrique'] = $id_rubrique = $row_rub['id_rubrique']; |
|
| 91 | + } |
|
| 92 | + if (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique'])) { |
|
| 93 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 94 | + $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 95 | + while (!autoriser('creerarticledans', 'rubrique', $row['id_rubrique']) && $row_rub = sql_fetch($res)) { |
|
| 96 | + $row['id_rubrique'] = $row_rub['id_rubrique']; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // recuperer le secteur, pour affecter les bons champs extras |
|
| 103 | + if ($id_rubrique and $is_secteur) { |
|
| 104 | + if (!$row['id_secteur']) { |
|
| 105 | + $row_rub = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=" . sql_quote($id_rubrique)); |
|
| 106 | + $row['id_secteur'] = $row_rub; |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return $row; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
@@ -129,76 +129,76 @@ discard block |
||
| 129 | 129 | * Couples clés / valeurs des champs du formulaire à charger |
| 130 | 130 | **/ |
| 131 | 131 | function precharger_traduction_objet($type, $id_objet, $id_rubrique = 0, $lier_trad = 0, $champ_titre = 'titre') { |
| 132 | - $table = table_objet_sql($type); |
|
| 133 | - $_id_objet = id_table_objet($table); |
|
| 134 | - |
|
| 135 | - // Recuperer les donnees de l'objet original |
|
| 136 | - $row = sql_fetsel("*", $table, "$_id_objet=".intval($lier_trad)); |
|
| 137 | - if ($row) { |
|
| 138 | - include_spip('inc/filtres'); |
|
| 139 | - $row[$champ_titre] = filtrer_entites(objet_T($type, 'info_nouvelle_traduction')) . ' ' . $row[$champ_titre]; |
|
| 140 | - } else { |
|
| 141 | - $row = array(); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - // on met l'objet dans une rubrique si l'objet le peut |
|
| 145 | - $desc = lister_tables_objets_sql($table); |
|
| 146 | - $is_rubrique = isset($desc['field']['id_rubrique']); |
|
| 147 | - |
|
| 148 | - if ($is_rubrique) { |
|
| 149 | - $langues_dispo = explode(',', $GLOBALS['meta']['langues_multilingue']); |
|
| 150 | - // si le redacteur utilise une autre langue que celle de la source, on suppose que c'est pour traduire dans sa langue |
|
| 151 | - if (in_array($GLOBALS['spip_lang'], $langues_dispo) and $GLOBALS['spip_lang'] !== $row['lang']) { |
|
| 152 | - $row['lang'] = $GLOBALS['spip_lang']; |
|
| 153 | - } |
|
| 154 | - // sinon si il y a seulement 2 langues dispos, on bascule sur l'"autre" |
|
| 155 | - elseif (count($langues_dispo) == 2) { |
|
| 156 | - $autre_langue = array_diff($langues_dispo, [$row['lang']]); |
|
| 157 | - if (count($autre_langue) == 1) { |
|
| 158 | - $row['lang'] = reset($autre_langue); |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - else { |
|
| 162 | - $row['lang'] = 'en'; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - if ($id_rubrique) { |
|
| 166 | - $row['id_rubrique'] = $id_rubrique; |
|
| 167 | - |
|
| 168 | - return $row; |
|
| 169 | - } |
|
| 170 | - $id_rubrique = $row['id_rubrique']; |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - // Regler la langue, si possible, sur celle du redacteur |
|
| 174 | - // Cela implique souvent de choisir une rubrique ou un secteur |
|
| 175 | - if (in_array($GLOBALS['spip_lang'], $langues_dispo)) { |
|
| 176 | - |
|
| 177 | - // Si le menu de langues est autorise sur l'objet, |
|
| 178 | - // on peut changer la langue quelle que soit la rubrique |
|
| 179 | - // donc on reste dans la meme rubrique |
|
| 180 | - if (in_array($table, explode(',', $GLOBALS['meta']['multi_objets']))) { |
|
| 181 | - $row['id_rubrique'] = $row['id_rubrique']; # explicite :-) |
|
| 182 | - |
|
| 183 | - // Sinon, chercher la rubrique la plus adaptee pour |
|
| 184 | - // accueillir l'objet dans la langue du traducteur |
|
| 185 | - } elseif ($is_rubrique and $GLOBALS['meta']['multi_rubriques'] == 'oui') { |
|
| 186 | - if ($GLOBALS['meta']['multi_secteurs'] == 'oui') { |
|
| 187 | - $id_parent = 0; |
|
| 188 | - } else { |
|
| 189 | - // on cherche une rubrique soeur dans la bonne langue |
|
| 190 | - $row_rub = sql_fetsel("id_parent", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 191 | - $id_parent = $row_rub['id_parent']; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", |
|
| 195 | - "lang='" . $GLOBALS['spip_lang'] . "' AND id_parent=".intval($id_parent)); |
|
| 196 | - if ($row_rub) { |
|
| 197 | - $row['id_rubrique'] = $row_rub['id_rubrique']; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - return $row; |
|
| 132 | + $table = table_objet_sql($type); |
|
| 133 | + $_id_objet = id_table_objet($table); |
|
| 134 | + |
|
| 135 | + // Recuperer les donnees de l'objet original |
|
| 136 | + $row = sql_fetsel("*", $table, "$_id_objet=".intval($lier_trad)); |
|
| 137 | + if ($row) { |
|
| 138 | + include_spip('inc/filtres'); |
|
| 139 | + $row[$champ_titre] = filtrer_entites(objet_T($type, 'info_nouvelle_traduction')) . ' ' . $row[$champ_titre]; |
|
| 140 | + } else { |
|
| 141 | + $row = array(); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + // on met l'objet dans une rubrique si l'objet le peut |
|
| 145 | + $desc = lister_tables_objets_sql($table); |
|
| 146 | + $is_rubrique = isset($desc['field']['id_rubrique']); |
|
| 147 | + |
|
| 148 | + if ($is_rubrique) { |
|
| 149 | + $langues_dispo = explode(',', $GLOBALS['meta']['langues_multilingue']); |
|
| 150 | + // si le redacteur utilise une autre langue que celle de la source, on suppose que c'est pour traduire dans sa langue |
|
| 151 | + if (in_array($GLOBALS['spip_lang'], $langues_dispo) and $GLOBALS['spip_lang'] !== $row['lang']) { |
|
| 152 | + $row['lang'] = $GLOBALS['spip_lang']; |
|
| 153 | + } |
|
| 154 | + // sinon si il y a seulement 2 langues dispos, on bascule sur l'"autre" |
|
| 155 | + elseif (count($langues_dispo) == 2) { |
|
| 156 | + $autre_langue = array_diff($langues_dispo, [$row['lang']]); |
|
| 157 | + if (count($autre_langue) == 1) { |
|
| 158 | + $row['lang'] = reset($autre_langue); |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + else { |
|
| 162 | + $row['lang'] = 'en'; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + if ($id_rubrique) { |
|
| 166 | + $row['id_rubrique'] = $id_rubrique; |
|
| 167 | + |
|
| 168 | + return $row; |
|
| 169 | + } |
|
| 170 | + $id_rubrique = $row['id_rubrique']; |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + // Regler la langue, si possible, sur celle du redacteur |
|
| 174 | + // Cela implique souvent de choisir une rubrique ou un secteur |
|
| 175 | + if (in_array($GLOBALS['spip_lang'], $langues_dispo)) { |
|
| 176 | + |
|
| 177 | + // Si le menu de langues est autorise sur l'objet, |
|
| 178 | + // on peut changer la langue quelle que soit la rubrique |
|
| 179 | + // donc on reste dans la meme rubrique |
|
| 180 | + if (in_array($table, explode(',', $GLOBALS['meta']['multi_objets']))) { |
|
| 181 | + $row['id_rubrique'] = $row['id_rubrique']; # explicite :-) |
|
| 182 | + |
|
| 183 | + // Sinon, chercher la rubrique la plus adaptee pour |
|
| 184 | + // accueillir l'objet dans la langue du traducteur |
|
| 185 | + } elseif ($is_rubrique and $GLOBALS['meta']['multi_rubriques'] == 'oui') { |
|
| 186 | + if ($GLOBALS['meta']['multi_secteurs'] == 'oui') { |
|
| 187 | + $id_parent = 0; |
|
| 188 | + } else { |
|
| 189 | + // on cherche une rubrique soeur dans la bonne langue |
|
| 190 | + $row_rub = sql_fetsel("id_parent", "spip_rubriques", "id_rubrique=".intval($id_rubrique)); |
|
| 191 | + $id_parent = $row_rub['id_parent']; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + $row_rub = sql_fetsel("id_rubrique", "spip_rubriques", |
|
| 195 | + "lang='" . $GLOBALS['spip_lang'] . "' AND id_parent=".intval($id_parent)); |
|
| 196 | + if ($row_rub) { |
|
| 197 | + $row['id_rubrique'] = $row_rub['id_rubrique']; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + return $row; |
|
| 204 | 204 | } |
@@ -157,8 +157,7 @@ |
||
| 157 | 157 | if (count($autre_langue) == 1) { |
| 158 | 158 | $row['lang'] = reset($autre_langue); |
| 159 | 159 | } |
| 160 | - } |
|
| 161 | - else { |
|
| 160 | + } else { |
|
| 162 | 161 | $row['lang'] = 'en'; |
| 163 | 162 | } |
| 164 | 163 | |