@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 24 | - return; |
|
| 24 | + return; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
@@ -29,29 +29,29 @@ discard block |
||
| 29 | 29 | * Demander à mettre à jour la base de données |
| 30 | 30 | */ |
| 31 | 31 | function exec_demande_mise_a_jour_dist() { |
| 32 | - // on fait la verif du path avant tout, |
|
| 33 | - // et l'installation des qu'on est dans la colonne principale |
|
| 34 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 35 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 36 | - include_spip('inc/plugin'); |
|
| 37 | - if (actualise_plugins_actifs()) { |
|
| 38 | - include_spip('inc/headers'); |
|
| 39 | - redirige_par_entete(self()); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - include_spip('inc/presentation'); |
|
| 43 | - include_spip('inc/filtres_boites'); |
|
| 44 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 45 | - echo $commencer_page('', '', '', '', true, false, false); |
|
| 46 | - |
|
| 47 | - echo debut_grand_cadre(true); |
|
| 48 | - echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
|
| 49 | - echo "<p>" . _T('info_procedure_maj_version') . "</p>", |
|
| 50 | - "<p>" . _T('info_administrateur_site_01') . "</p>"; |
|
| 51 | - echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire("upgrade", "reinstall=non")); |
|
| 52 | - echo boite_fermer(); |
|
| 53 | - // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 54 | - echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 55 | - echo fin_grand_cadre(true); |
|
| 56 | - echo fin_page(); |
|
| 32 | + // on fait la verif du path avant tout, |
|
| 33 | + // et l'installation des qu'on est dans la colonne principale |
|
| 34 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 35 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 36 | + include_spip('inc/plugin'); |
|
| 37 | + if (actualise_plugins_actifs()) { |
|
| 38 | + include_spip('inc/headers'); |
|
| 39 | + redirige_par_entete(self()); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + include_spip('inc/presentation'); |
|
| 43 | + include_spip('inc/filtres_boites'); |
|
| 44 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 45 | + echo $commencer_page('', '', '', '', true, false, false); |
|
| 46 | + |
|
| 47 | + echo debut_grand_cadre(true); |
|
| 48 | + echo boite_ouvrir(_T('info_message_technique'), 'notice'); |
|
| 49 | + echo "<p>" . _T('info_procedure_maj_version') . "</p>", |
|
| 50 | + "<p>" . _T('info_administrateur_site_01') . "</p>"; |
|
| 51 | + echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire("upgrade", "reinstall=non")); |
|
| 52 | + echo boite_fermer(); |
|
| 53 | + // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
|
| 54 | + echo '<style type="text/css">#debug-nav {display: none;}</style>'; |
|
| 55 | + echo fin_grand_cadre(true); |
|
| 56 | + echo fin_page(); |
|
| 57 | 57 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | include_spip('inc/actions'); |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | * @uses ajax_retour() |
| 32 | 32 | **/ |
| 33 | 33 | function exec_rechercher_dist() { |
| 34 | - $id = intval(_request('id')); |
|
| 35 | - $exclus = intval(_request('exclus')); |
|
| 36 | - $rac = spip_htmlentities(_request('rac')); |
|
| 37 | - $type = _request('type'); |
|
| 38 | - $do = _request('do'); |
|
| 39 | - if (preg_match('/^\w*$/', $do)) { |
|
| 40 | - $r = exec_rechercher_args($id, $type, $exclus, $rac, $do); |
|
| 41 | - } else { |
|
| 42 | - $r = ''; |
|
| 43 | - } |
|
| 44 | - ajax_retour($r); |
|
| 34 | + $id = intval(_request('id')); |
|
| 35 | + $exclus = intval(_request('exclus')); |
|
| 36 | + $rac = spip_htmlentities(_request('rac')); |
|
| 37 | + $type = _request('type'); |
|
| 38 | + $do = _request('do'); |
|
| 39 | + if (preg_match('/^\w*$/', $do)) { |
|
| 40 | + $r = exec_rechercher_args($id, $type, $exclus, $rac, $do); |
|
| 41 | + } else { |
|
| 42 | + $r = ''; |
|
| 43 | + } |
|
| 44 | + ajax_retour($r); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -58,59 +58,59 @@ discard block |
||
| 58 | 58 | * @return string |
| 59 | 59 | **/ |
| 60 | 60 | function exec_rechercher_args($id, $type, $exclus, $rac, $do) { |
| 61 | - if (!$do) { |
|
| 62 | - $do = 'aff'; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $points = $rub = array(); |
|
| 66 | - |
|
| 67 | - $where = preg_split(",\s+,", $type); |
|
| 68 | - if ($where) { |
|
| 69 | - foreach ($where as $k => $v) { |
|
| 70 | - $where[$k] = "'%" . substr(str_replace("%", "\%", sql_quote($v, '', 'string')), 1, -1) . "%'"; |
|
| 71 | - } |
|
| 72 | - $where_titre = ("(titre LIKE " . join(" AND titre LIKE ", $where) . ")"); |
|
| 73 | - $where_desc = ("(descriptif LIKE " . join(" AND descriptif LIKE ", $where) . ")"); |
|
| 74 | - $where_id = ("(id_rubrique = " . intval($type) . ")"); |
|
| 75 | - |
|
| 76 | - if ($exclus) { |
|
| 77 | - include_spip('inc/rubriques'); |
|
| 78 | - $where_exclus = " AND " . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT'); |
|
| 79 | - } else { |
|
| 80 | - $where_exclus = ''; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - foreach (array( |
|
| 84 | - 3 => $where_titre, |
|
| 85 | - 2 => $where_desc, |
|
| 86 | - 1 => $where_id, |
|
| 87 | - ) as $point => $recherche) { |
|
| 88 | - $res = sql_select("id_rubrique, id_parent, titre", "spip_rubriques", "$recherche$where_exclus"); |
|
| 89 | - while ($row = sql_fetch($res)) { |
|
| 90 | - $id_rubrique = $row["id_rubrique"]; |
|
| 91 | - if (!isset($rub[$id_rubrique])) { |
|
| 92 | - $rub[$id_rubrique] = array(); |
|
| 93 | - } |
|
| 94 | - $rub[$id_rubrique]["titre"] = typo($row["titre"]); |
|
| 95 | - $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; |
|
| 96 | - if (!isset($points[$id_rubrique])) { |
|
| 97 | - $points[$id_rubrique] = 0; |
|
| 98 | - } |
|
| 99 | - $points[$id_rubrique] = $points[$id_rubrique] + $point; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - if ($points) { |
|
| 105 | - arsort($points); |
|
| 106 | - $style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'"; |
|
| 107 | - foreach ($rub as $k => $v) { |
|
| 108 | - $rub[$k]['atts'] = ($v["id_parent"] ? $style : '') |
|
| 109 | - . " class='petite-rubrique'"; |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - return (proposer_item($points, $rub, $rac, $type, $do)); |
|
| 61 | + if (!$do) { |
|
| 62 | + $do = 'aff'; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $points = $rub = array(); |
|
| 66 | + |
|
| 67 | + $where = preg_split(",\s+,", $type); |
|
| 68 | + if ($where) { |
|
| 69 | + foreach ($where as $k => $v) { |
|
| 70 | + $where[$k] = "'%" . substr(str_replace("%", "\%", sql_quote($v, '', 'string')), 1, -1) . "%'"; |
|
| 71 | + } |
|
| 72 | + $where_titre = ("(titre LIKE " . join(" AND titre LIKE ", $where) . ")"); |
|
| 73 | + $where_desc = ("(descriptif LIKE " . join(" AND descriptif LIKE ", $where) . ")"); |
|
| 74 | + $where_id = ("(id_rubrique = " . intval($type) . ")"); |
|
| 75 | + |
|
| 76 | + if ($exclus) { |
|
| 77 | + include_spip('inc/rubriques'); |
|
| 78 | + $where_exclus = " AND " . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT'); |
|
| 79 | + } else { |
|
| 80 | + $where_exclus = ''; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + foreach (array( |
|
| 84 | + 3 => $where_titre, |
|
| 85 | + 2 => $where_desc, |
|
| 86 | + 1 => $where_id, |
|
| 87 | + ) as $point => $recherche) { |
|
| 88 | + $res = sql_select("id_rubrique, id_parent, titre", "spip_rubriques", "$recherche$where_exclus"); |
|
| 89 | + while ($row = sql_fetch($res)) { |
|
| 90 | + $id_rubrique = $row["id_rubrique"]; |
|
| 91 | + if (!isset($rub[$id_rubrique])) { |
|
| 92 | + $rub[$id_rubrique] = array(); |
|
| 93 | + } |
|
| 94 | + $rub[$id_rubrique]["titre"] = typo($row["titre"]); |
|
| 95 | + $rub[$id_rubrique]["id_parent"] = $row["id_parent"]; |
|
| 96 | + if (!isset($points[$id_rubrique])) { |
|
| 97 | + $points[$id_rubrique] = 0; |
|
| 98 | + } |
|
| 99 | + $points[$id_rubrique] = $points[$id_rubrique] + $point; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + if ($points) { |
|
| 105 | + arsort($points); |
|
| 106 | + $style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'"; |
|
| 107 | + foreach ($rub as $k => $v) { |
|
| 108 | + $rub[$k]['atts'] = ($v["id_parent"] ? $style : '') |
|
| 109 | + . " class='petite-rubrique'"; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + return (proposer_item($points, $rub, $rac, $type, $do)); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | |
@@ -133,35 +133,35 @@ discard block |
||
| 133 | 133 | **/ |
| 134 | 134 | function proposer_item($ids, $titles, $rac, $type, $do) { |
| 135 | 135 | |
| 136 | - if (!$ids) { |
|
| 137 | - return "<br /><br /><div style='padding: 5px; color: red;'><b>" |
|
| 138 | - . spip_htmlentities($type) |
|
| 139 | - . "</b> : " . _T('avis_aucun_resultat') . "</div>"; |
|
| 140 | - } |
|
| 136 | + if (!$ids) { |
|
| 137 | + return "<br /><br /><div style='padding: 5px; color: red;'><b>" |
|
| 138 | + . spip_htmlentities($type) |
|
| 139 | + . "</b> : " . _T('avis_aucun_resultat') . "</div>"; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - $ret = ''; |
|
| 143 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id="); |
|
| 142 | + $ret = ''; |
|
| 143 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$rac&id="); |
|
| 144 | 144 | |
| 145 | - $onClick = "aff_selection(this.firstChild.title,'$rac" . "_selection','$info', event)"; |
|
| 145 | + $onClick = "aff_selection(this.firstChild.title,'$rac" . "_selection','$info', event)"; |
|
| 146 | 146 | |
| 147 | - $ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');"; |
|
| 147 | + $ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');"; |
|
| 148 | 148 | |
| 149 | - foreach ($ids as $id => $bof) { |
|
| 149 | + foreach ($ids as $id => $bof) { |
|
| 150 | 150 | |
| 151 | - $titre = strtr(str_replace("'", "’", str_replace('"', """, textebrut($titles[$id]["titre"]))), "\n\r", |
|
| 152 | - " "); |
|
| 151 | + $titre = strtr(str_replace("'", "’", str_replace('"', """, textebrut($titles[$id]["titre"]))), "\n\r", |
|
| 152 | + " "); |
|
| 153 | 153 | |
| 154 | - $ret .= "<div class='highlight off'\nonclick=\"changerhighlight(this); " |
|
| 155 | - . $onClick |
|
| 156 | - . "\"\nondblclick=\"" |
|
| 157 | - . $ondbClick |
|
| 158 | - . $onClick |
|
| 159 | - . " \"><div" |
|
| 160 | - . $titles[$id]["atts"] |
|
| 161 | - . " title='$id'> " |
|
| 162 | - . $titre |
|
| 163 | - . "</div></div>"; |
|
| 164 | - } |
|
| 154 | + $ret .= "<div class='highlight off'\nonclick=\"changerhighlight(this); " |
|
| 155 | + . $onClick |
|
| 156 | + . "\"\nondblclick=\"" |
|
| 157 | + . $ondbClick |
|
| 158 | + . $onClick |
|
| 159 | + . " \"><div" |
|
| 160 | + . $titles[$id]["atts"] |
|
| 161 | + . " title='$id'> " |
|
| 162 | + . $titre |
|
| 163 | + . "</div></div>"; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - return $ret; |
|
| 166 | + return $ret; |
|
| 167 | 167 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | 25 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 26 | - return; |
|
| 26 | + return; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
@@ -31,24 +31,24 @@ discard block |
||
| 31 | 31 | * Réparer la base de données |
| 32 | 32 | */ |
| 33 | 33 | function exec_base_repair_dist() { |
| 34 | - $ok = false; |
|
| 35 | - if (!spip_connect()) { |
|
| 36 | - $message = _T('titre_probleme_technique'); |
|
| 37 | - } else { |
|
| 38 | - $version_sql = sql_version(); |
|
| 39 | - if (!$version_sql) { |
|
| 40 | - $message = _T('avis_erreur_connexion_mysql'); |
|
| 41 | - } else { |
|
| 42 | - $message = _T('texte_requetes_echouent'); |
|
| 43 | - $ok = true; |
|
| 44 | - } |
|
| 45 | - $action = _T('texte_tenter_reparation'); |
|
| 46 | - } |
|
| 47 | - if ($ok) { |
|
| 48 | - $admin = charger_fonction('admin', 'inc'); |
|
| 49 | - echo $admin('repair', $action, $message, true); |
|
| 50 | - } else { |
|
| 51 | - include_spip('inc/minipres'); |
|
| 52 | - echo minipres(_T('titre_reparation'), "<p>$message</p>"); |
|
| 53 | - } |
|
| 34 | + $ok = false; |
|
| 35 | + if (!spip_connect()) { |
|
| 36 | + $message = _T('titre_probleme_technique'); |
|
| 37 | + } else { |
|
| 38 | + $version_sql = sql_version(); |
|
| 39 | + if (!$version_sql) { |
|
| 40 | + $message = _T('avis_erreur_connexion_mysql'); |
|
| 41 | + } else { |
|
| 42 | + $message = _T('texte_requetes_echouent'); |
|
| 43 | + $ok = true; |
|
| 44 | + } |
|
| 45 | + $action = _T('texte_tenter_reparation'); |
|
| 46 | + } |
|
| 47 | + if ($ok) { |
|
| 48 | + $admin = charger_fonction('admin', 'inc'); |
|
| 49 | + echo $admin('repair', $action, $message, true); |
|
| 50 | + } else { |
|
| 51 | + include_spip('inc/minipres'); |
|
| 52 | + echo minipres(_T('titre_reparation'), "<p>$message</p>"); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 24 | - return; |
|
| 24 | + return; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | $GLOBALS['delais'] = 0;// pas de cache ! |
| 30 | 30 | // Securite |
| 31 | 31 | if (strstr($fond, '/')) { |
| 32 | - if (!include_spip('inc/autoriser') |
|
| 33 | - or !autoriser('webmestre') |
|
| 34 | - ) { |
|
| 35 | - include_spip('inc/minipres'); |
|
| 36 | - echo minipres(); |
|
| 37 | - exit; |
|
| 38 | - } |
|
| 32 | + if (!include_spip('inc/autoriser') |
|
| 33 | + or !autoriser('webmestre') |
|
| 34 | + ) { |
|
| 35 | + include_spip('inc/minipres'); |
|
| 36 | + echo minipres(); |
|
| 37 | + exit; |
|
| 38 | + } |
|
| 39 | 39 | } else { |
| 40 | - $fond = "prive/squelettes/$fond"; |
|
| 40 | + $fond = "prive/squelettes/$fond"; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // quelques inclusions et ini prealables |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | * @todo supprimer cette fonction vide ? |
| 50 | 50 | **/ |
| 51 | 51 | function shutdown_error() { |
| 52 | - // si on arrive ici avec un tampon non ferme : erreur fatale |
|
| 53 | - /* if (ob_get_level()){ |
|
| 52 | + // si on arrive ici avec un tampon non ferme : erreur fatale |
|
| 53 | + /* if (ob_get_level()){ |
|
| 54 | 54 | // envoyer tous les tampons |
| 55 | 55 | while (ob_get_level()) |
| 56 | 56 | ob_end_flush(); |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | * @param array $opt |
| 25 | 25 | */ |
| 26 | 26 | function inc_journal_dist($phrase, $opt = array()) { |
| 27 | - if (!strlen($phrase)) { |
|
| 28 | - return; |
|
| 29 | - } |
|
| 30 | - if ($opt) { |
|
| 31 | - $phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt)); |
|
| 32 | - } |
|
| 33 | - spip_log($phrase, 'journal'); |
|
| 27 | + if (!strlen($phrase)) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 30 | + if ($opt) { |
|
| 31 | + $phrase .= ' :: ' . str_replace("\n", ' ', join(', ', $opt)); |
|
| 32 | + } |
|
| 33 | + spip_log($phrase, 'journal'); |
|
| 34 | 34 | } |
@@ -20,21 +20,21 @@ |
||
| 20 | 20 | * Retourne la liste des menus favoris par défaut ainsi que leur rang |
| 21 | 21 | */ |
| 22 | 22 | function inc_definir_menus_favoris_dist() { |
| 23 | - $liste = array( |
|
| 23 | + $liste = array( |
|
| 24 | 24 | |
| 25 | - // Menu Édition, |
|
| 26 | - 'auteurs' => 1, |
|
| 27 | - 'rubriques' => 2, |
|
| 28 | - 'articles' => 3, |
|
| 25 | + // Menu Édition, |
|
| 26 | + 'auteurs' => 1, |
|
| 27 | + 'rubriques' => 2, |
|
| 28 | + 'articles' => 3, |
|
| 29 | 29 | |
| 30 | - // Menu Maintenance |
|
| 31 | - 'admin_vider' => 1, |
|
| 30 | + // Menu Maintenance |
|
| 31 | + 'admin_vider' => 1, |
|
| 32 | 32 | |
| 33 | - // Menu Configurations |
|
| 34 | - 'configurer_identite' => 1, |
|
| 35 | - 'admin_plugin' => 2, |
|
| 33 | + // Menu Configurations |
|
| 34 | + 'configurer_identite' => 1, |
|
| 35 | + 'admin_plugin' => 2, |
|
| 36 | 36 | |
| 37 | - ); |
|
| 37 | + ); |
|
| 38 | 38 | |
| 39 | - return $liste; |
|
| 39 | + return $liste; |
|
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @package SPIP\Core\Drapeaux\Edition |
| 31 | 31 | **/ |
| 32 | 32 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 33 | - return; |
|
| 33 | + return; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -45,46 +45,46 @@ discard block |
||
| 45 | 45 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 46 | 46 | **/ |
| 47 | 47 | function lire_tableau_edition() { |
| 48 | - $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | - if (!$edition) { |
|
| 50 | - return array(); |
|
| 51 | - } |
|
| 52 | - $changed = false; |
|
| 48 | + $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | + if (!$edition) { |
|
| 50 | + return array(); |
|
| 51 | + } |
|
| 52 | + $changed = false; |
|
| 53 | 53 | |
| 54 | - $bon_pour_le_service = time() - 3600; |
|
| 55 | - // parcourir le tableau et virer les vieux |
|
| 56 | - foreach ($edition as $objet => $data) { |
|
| 57 | - if (!is_array($data)) { |
|
| 58 | - unset($edition[$objet]); |
|
| 59 | - } // vieille version |
|
| 60 | - else { |
|
| 61 | - foreach ($data as $id => $tab) { |
|
| 62 | - if (!is_array($tab)) { |
|
| 63 | - unset($edition[$objet][$tab]); |
|
| 64 | - } // vieille version |
|
| 65 | - else { |
|
| 66 | - foreach ($tab as $n => $duo) { |
|
| 67 | - if (current($duo) < $bon_pour_le_service) { |
|
| 68 | - unset($edition[$objet][$id][$n]); |
|
| 69 | - $changed = true; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - if (!$edition[$objet][$id]) { |
|
| 74 | - unset($edition[$objet][$id]); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - if (!$edition[$objet]) { |
|
| 79 | - unset($edition[$objet]); |
|
| 80 | - } |
|
| 81 | - } |
|
| 54 | + $bon_pour_le_service = time() - 3600; |
|
| 55 | + // parcourir le tableau et virer les vieux |
|
| 56 | + foreach ($edition as $objet => $data) { |
|
| 57 | + if (!is_array($data)) { |
|
| 58 | + unset($edition[$objet]); |
|
| 59 | + } // vieille version |
|
| 60 | + else { |
|
| 61 | + foreach ($data as $id => $tab) { |
|
| 62 | + if (!is_array($tab)) { |
|
| 63 | + unset($edition[$objet][$tab]); |
|
| 64 | + } // vieille version |
|
| 65 | + else { |
|
| 66 | + foreach ($tab as $n => $duo) { |
|
| 67 | + if (current($duo) < $bon_pour_le_service) { |
|
| 68 | + unset($edition[$objet][$id][$n]); |
|
| 69 | + $changed = true; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + if (!$edition[$objet][$id]) { |
|
| 74 | + unset($edition[$objet][$id]); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + if (!$edition[$objet]) { |
|
| 79 | + unset($edition[$objet]); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if ($changed) { |
|
| 84 | - ecrire_tableau_edition($edition); |
|
| 85 | - } |
|
| 83 | + if ($changed) { |
|
| 84 | + ecrire_tableau_edition($edition); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return $edition; |
|
| 87 | + return $edition; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 98 | 98 | **/ |
| 99 | 99 | function ecrire_tableau_edition($edition) { |
| 100 | - ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 100 | + ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | * Type d'objet édité |
| 118 | 118 | */ |
| 119 | 119 | function signale_edition($id, $auteur, $type = 'article') { |
| 120 | - include_spip('base/objets'); |
|
| 121 | - include_spip('inc/filtres'); |
|
| 122 | - if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | - return; |
|
| 124 | - } |
|
| 120 | + include_spip('base/objets'); |
|
| 121 | + include_spip('inc/filtres'); |
|
| 122 | + if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $edition = lire_tableau_edition(); |
|
| 127 | - if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | - $nom = $auteur['nom']; |
|
| 129 | - } else { |
|
| 130 | - $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | - } |
|
| 126 | + $edition = lire_tableau_edition(); |
|
| 127 | + if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | + $nom = $auteur['nom']; |
|
| 129 | + } else { |
|
| 130 | + $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | - $edition[$type][$id] = array(); |
|
| 135 | - } |
|
| 136 | - $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | - ecrire_tableau_edition($edition); |
|
| 133 | + if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | + $edition[$type][$id] = array(); |
|
| 135 | + } |
|
| 136 | + $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | + ecrire_tableau_edition($edition); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function qui_edite($id, $type = 'article') { |
| 153 | 153 | |
| 154 | - $edition = lire_tableau_edition(); |
|
| 154 | + $edition = lire_tableau_edition(); |
|
| 155 | 155 | |
| 156 | - return empty($edition[$type][$id]) ? array() : $edition[$type][$id]; |
|
| 156 | + return empty($edition[$type][$id]) ? array() : $edition[$type][$id]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,22 +167,22 @@ discard block |
||
| 167 | 167 | * Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]` |
| 168 | 168 | */ |
| 169 | 169 | function mention_qui_edite($id, $type = 'article') { |
| 170 | - $modif = qui_edite($id, $type); |
|
| 171 | - unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 170 | + $modif = qui_edite($id, $type); |
|
| 171 | + unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 172 | 172 | |
| 173 | - if ($modif) { |
|
| 174 | - $quand = 0; |
|
| 175 | - foreach ($modif as $duo) { |
|
| 176 | - $auteurs[] = typo(key($duo)); |
|
| 177 | - $quand = max($quand, current($duo)); |
|
| 178 | - } |
|
| 173 | + if ($modif) { |
|
| 174 | + $quand = 0; |
|
| 175 | + foreach ($modif as $duo) { |
|
| 176 | + $auteurs[] = typo(key($duo)); |
|
| 177 | + $quand = max($quand, current($duo)); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | - return array( |
|
| 182 | - 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | - 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | - ); |
|
| 185 | - } |
|
| 180 | + // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | + return array( |
|
| 182 | + 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | + 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | + ); |
|
| 185 | + } |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -196,24 +196,24 @@ discard block |
||
| 196 | 196 | * Liste de tableaux `['objet' => x, 'id_objet' => n]` |
| 197 | 197 | */ |
| 198 | 198 | function liste_drapeau_edition($id_auteur) { |
| 199 | - $edition = lire_tableau_edition(); |
|
| 200 | - $objets_ouverts = array(); |
|
| 199 | + $edition = lire_tableau_edition(); |
|
| 200 | + $objets_ouverts = array(); |
|
| 201 | 201 | |
| 202 | - foreach ($edition as $objet => $data) { |
|
| 203 | - foreach ($data as $id => $auteurs) { |
|
| 204 | - if (isset($auteurs[$id_auteur]) |
|
| 205 | - and is_array($auteurs[$id_auteur]) // precaution |
|
| 206 | - and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 207 | - ) { |
|
| 208 | - $objets_ouverts[] = array( |
|
| 209 | - 'objet' => $objet, |
|
| 210 | - 'id_objet' => $id, |
|
| 211 | - ); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - } |
|
| 202 | + foreach ($edition as $objet => $data) { |
|
| 203 | + foreach ($data as $id => $auteurs) { |
|
| 204 | + if (isset($auteurs[$id_auteur]) |
|
| 205 | + and is_array($auteurs[$id_auteur]) // precaution |
|
| 206 | + and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 207 | + ) { |
|
| 208 | + $objets_ouverts[] = array( |
|
| 209 | + 'objet' => $objet, |
|
| 210 | + 'id_objet' => $id, |
|
| 211 | + ); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - return $objets_ouverts; |
|
| 216 | + return $objets_ouverts; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | /** |
@@ -226,15 +226,15 @@ discard block |
||
| 226 | 226 | * @return void |
| 227 | 227 | */ |
| 228 | 228 | function debloquer_tous($id_auteur) { |
| 229 | - $edition = lire_tableau_edition(); |
|
| 230 | - foreach ($edition as $objet => $data) { |
|
| 231 | - foreach ($data as $id => $auteurs) { |
|
| 232 | - if (isset($auteurs[$id_auteur])) { |
|
| 233 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 234 | - ecrire_tableau_edition($edition); |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - } |
|
| 229 | + $edition = lire_tableau_edition(); |
|
| 230 | + foreach ($edition as $objet => $data) { |
|
| 231 | + foreach ($data as $id => $auteurs) { |
|
| 232 | + if (isset($auteurs[$id_auteur])) { |
|
| 233 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 234 | + ecrire_tableau_edition($edition); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -252,18 +252,18 @@ discard block |
||
| 252 | 252 | * @return void |
| 253 | 253 | */ |
| 254 | 254 | function debloquer_edition($id_auteur, $id_objet, $type = 'article') { |
| 255 | - $edition = lire_tableau_edition(); |
|
| 255 | + $edition = lire_tableau_edition(); |
|
| 256 | 256 | |
| 257 | - foreach ($edition as $objet => $data) { |
|
| 258 | - if ($objet == $type) { |
|
| 259 | - foreach ($data as $id => $auteurs) { |
|
| 260 | - if ($id == $id_objet |
|
| 261 | - and isset($auteurs[$id_auteur]) |
|
| 262 | - ) { |
|
| 263 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 264 | - ecrire_tableau_edition($edition); |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - } |
|
| 257 | + foreach ($edition as $objet => $data) { |
|
| 258 | + if ($objet == $type) { |
|
| 259 | + foreach ($data as $id => $auteurs) { |
|
| 260 | + if ($id == $id_objet |
|
| 261 | + and isset($auteurs[$id_auteur]) |
|
| 262 | + ) { |
|
| 263 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 264 | + ecrire_tableau_edition($edition); |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -25,51 +25,51 @@ discard block |
||
| 25 | 25 | * privée ou dans un de ses sous menus |
| 26 | 26 | */ |
| 27 | 27 | class Bouton { |
| 28 | - /** @var string L'icone à mettre dans le bouton */ |
|
| 29 | - public $icone; |
|
| 30 | - |
|
| 31 | - /** @var string Le nom de l'entrée d'i18n associé */ |
|
| 32 | - public $libelle; |
|
| 33 | - |
|
| 34 | - /** @var null|string L'URL de la page (null => ?exec=nom) */ |
|
| 35 | - public $url = null; |
|
| 36 | - |
|
| 37 | - /** @var null|string|array Arguments supplementaires de l'URL */ |
|
| 38 | - public $urlArg = null; |
|
| 39 | - |
|
| 40 | - /** @var null|string URL du javascript */ |
|
| 41 | - public $url2 = null; |
|
| 42 | - |
|
| 43 | - /** @var null|string Pour ouvrir dans une fenetre a part */ |
|
| 44 | - public $target = null; |
|
| 45 | - |
|
| 46 | - /** @var null|mixed Sous-barre de boutons / onglets */ |
|
| 47 | - public $sousmenu = null; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Définit un bouton |
|
| 51 | - * |
|
| 52 | - * @param string $icone |
|
| 53 | - * L'icone à mettre dans le bouton |
|
| 54 | - * @param string $libelle |
|
| 55 | - * Le nom de l'entrée i18n associé |
|
| 56 | - * @param null|string $url |
|
| 57 | - * L'URL de la page |
|
| 58 | - * @param null|string|array $urlArg |
|
| 59 | - * Arguments supplémentaires de l'URL |
|
| 60 | - * @param null|string $url2 |
|
| 61 | - * URL du javascript |
|
| 62 | - * @param null|mixed $target |
|
| 63 | - * Pour ouvrir une fenêtre à part |
|
| 64 | - */ |
|
| 65 | - public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) { |
|
| 66 | - $this->icone = $icone; |
|
| 67 | - $this->libelle = $libelle; |
|
| 68 | - $this->url = $url; |
|
| 69 | - $this->urlArg = $urlArg; |
|
| 70 | - $this->url2 = $url2; |
|
| 71 | - $this->target = $target; |
|
| 72 | - } |
|
| 28 | + /** @var string L'icone à mettre dans le bouton */ |
|
| 29 | + public $icone; |
|
| 30 | + |
|
| 31 | + /** @var string Le nom de l'entrée d'i18n associé */ |
|
| 32 | + public $libelle; |
|
| 33 | + |
|
| 34 | + /** @var null|string L'URL de la page (null => ?exec=nom) */ |
|
| 35 | + public $url = null; |
|
| 36 | + |
|
| 37 | + /** @var null|string|array Arguments supplementaires de l'URL */ |
|
| 38 | + public $urlArg = null; |
|
| 39 | + |
|
| 40 | + /** @var null|string URL du javascript */ |
|
| 41 | + public $url2 = null; |
|
| 42 | + |
|
| 43 | + /** @var null|string Pour ouvrir dans une fenetre a part */ |
|
| 44 | + public $target = null; |
|
| 45 | + |
|
| 46 | + /** @var null|mixed Sous-barre de boutons / onglets */ |
|
| 47 | + public $sousmenu = null; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Définit un bouton |
|
| 51 | + * |
|
| 52 | + * @param string $icone |
|
| 53 | + * L'icone à mettre dans le bouton |
|
| 54 | + * @param string $libelle |
|
| 55 | + * Le nom de l'entrée i18n associé |
|
| 56 | + * @param null|string $url |
|
| 57 | + * L'URL de la page |
|
| 58 | + * @param null|string|array $urlArg |
|
| 59 | + * Arguments supplémentaires de l'URL |
|
| 60 | + * @param null|string $url2 |
|
| 61 | + * URL du javascript |
|
| 62 | + * @param null|mixed $target |
|
| 63 | + * Pour ouvrir une fenêtre à part |
|
| 64 | + */ |
|
| 65 | + public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) { |
|
| 66 | + $this->icone = $icone; |
|
| 67 | + $this->libelle = $libelle; |
|
| 68 | + $this->url = $url; |
|
| 69 | + $this->urlArg = $urlArg; |
|
| 70 | + $this->url2 = $url2; |
|
| 71 | + $this->target = $target; |
|
| 72 | + } |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -86,32 +86,32 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function definir_barre_onglets($script) { |
| 88 | 88 | |
| 89 | - $onglets = array(); |
|
| 90 | - $liste_onglets = array(); |
|
| 91 | - |
|
| 92 | - // ajouter les onglets issus des plugin via paquet.xml |
|
| 93 | - if (function_exists('onglets_plugins')) { |
|
| 94 | - $liste_onglets = onglets_plugins(); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - foreach ($liste_onglets as $id => $infos) { |
|
| 99 | - if (($parent = $infos['parent']) |
|
| 100 | - && $parent == $script |
|
| 101 | - && autoriser('onglet', "_$id") |
|
| 102 | - ) { |
|
| 103 | - $onglets[$id] = new Bouton( |
|
| 104 | - isset($infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 105 | - $infos['titre'], // titre |
|
| 106 | - (isset($infos['action']) and $infos['action']) |
|
| 107 | - ? generer_url_ecrire($infos['action'], |
|
| 108 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : '') |
|
| 109 | - : null |
|
| 110 | - ); |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return pipeline('ajouter_onglets', array('data' => $onglets, 'args' => $script)); |
|
| 89 | + $onglets = array(); |
|
| 90 | + $liste_onglets = array(); |
|
| 91 | + |
|
| 92 | + // ajouter les onglets issus des plugin via paquet.xml |
|
| 93 | + if (function_exists('onglets_plugins')) { |
|
| 94 | + $liste_onglets = onglets_plugins(); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + foreach ($liste_onglets as $id => $infos) { |
|
| 99 | + if (($parent = $infos['parent']) |
|
| 100 | + && $parent == $script |
|
| 101 | + && autoriser('onglet', "_$id") |
|
| 102 | + ) { |
|
| 103 | + $onglets[$id] = new Bouton( |
|
| 104 | + isset($infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 105 | + $infos['titre'], // titre |
|
| 106 | + (isset($infos['action']) and $infos['action']) |
|
| 107 | + ? generer_url_ecrire($infos['action'], |
|
| 108 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : '') |
|
| 109 | + : null |
|
| 110 | + ); |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return pipeline('ajouter_onglets', array('data' => $onglets, 'args' => $script)); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | 132 | function barre_onglets($rubrique, $ongletCourant, $class = "barre_onglet") { |
| 133 | - include_spip('inc/presentation'); |
|
| 133 | + include_spip('inc/presentation'); |
|
| 134 | 134 | |
| 135 | - $res = ''; |
|
| 135 | + $res = ''; |
|
| 136 | 136 | |
| 137 | - foreach (definir_barre_onglets($rubrique) as $exec => $onglet) { |
|
| 138 | - $url = $onglet->url ? $onglet->url : generer_url_ecrire($exec); |
|
| 139 | - $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone); |
|
| 140 | - } |
|
| 137 | + foreach (definir_barre_onglets($rubrique) as $exec => $onglet) { |
|
| 138 | + $url = $onglet->url ? $onglet->url : generer_url_ecrire($exec); |
|
| 139 | + $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - return !$res ? '' : (debut_onglet($class) . $res . fin_onglet()); |
|
| 142 | + return !$res ? '' : (debut_onglet($class) . $res . fin_onglet()); |
|
| 143 | 143 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | include_spip('inc/config'); |
@@ -32,31 +32,31 @@ discard block |
||
| 32 | 32 | * @return array |
| 33 | 33 | */ |
| 34 | 34 | function cvtconf_formulaire_charger($flux) { |
| 35 | - if ( |
|
| 36 | - $form = $flux['args']['form'] |
|
| 37 | - and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 38 | - ) { |
|
| 39 | - // Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé |
|
| 40 | - include_spip('inc/autoriser'); |
|
| 41 | - if (!autoriser('configurer', '_' . substr($form, 11))) { |
|
| 42 | - return false; |
|
| 43 | - } |
|
| 35 | + if ( |
|
| 36 | + $form = $flux['args']['form'] |
|
| 37 | + and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 38 | + ) { |
|
| 39 | + // Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé |
|
| 40 | + include_spip('inc/autoriser'); |
|
| 41 | + if (!autoriser('configurer', '_' . substr($form, 11))) { |
|
| 42 | + return false; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // S'il n'y a pas de fonction charger(), on génère un contexte automatiquement |
|
| 46 | - if (!charger_fonction("charger", "formulaires/$form/", true)) { |
|
| 47 | - $flux['data'] = cvtconf_formulaires_configurer_recense($form); |
|
| 48 | - $flux['data']['editable'] = true; |
|
| 49 | - if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 50 | - if (!_AJAX) { |
|
| 51 | - var_dump($flux['data']); |
|
| 52 | - } |
|
| 53 | - // reinjecter pour la trace au traitement |
|
| 54 | - $flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />"; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 45 | + // S'il n'y a pas de fonction charger(), on génère un contexte automatiquement |
|
| 46 | + if (!charger_fonction("charger", "formulaires/$form/", true)) { |
|
| 47 | + $flux['data'] = cvtconf_formulaires_configurer_recense($form); |
|
| 48 | + $flux['data']['editable'] = true; |
|
| 49 | + if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 50 | + if (!_AJAX) { |
|
| 51 | + var_dump($flux['data']); |
|
| 52 | + } |
|
| 53 | + // reinjecter pour la trace au traitement |
|
| 54 | + $flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />"; |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - return $flux; |
|
| 59 | + return $flux; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | * @return array |
| 67 | 67 | */ |
| 68 | 68 | function cvtconf_formulaire_traiter($flux) { |
| 69 | - if ($form = $flux['args']['form'] |
|
| 70 | - and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 71 | - and !charger_fonction("traiter", "formulaires/$form/", true) // sans fonction traiter() |
|
| 72 | - ) { |
|
| 73 | - $trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']); |
|
| 74 | - $flux['data'] = array('message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true); |
|
| 75 | - } |
|
| 69 | + if ($form = $flux['args']['form'] |
|
| 70 | + and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX |
|
| 71 | + and !charger_fonction("traiter", "formulaires/$form/", true) // sans fonction traiter() |
|
| 72 | + ) { |
|
| 73 | + $trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']); |
|
| 74 | + $flux['data'] = array('message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - return $flux; |
|
| 77 | + return $flux; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -90,32 +90,32 @@ discard block |
||
| 90 | 90 | * @return string |
| 91 | 91 | */ |
| 92 | 92 | function cvtconf_formulaires_configurer_enregistre($form, $args) { |
| 93 | - $valeurs = array(); |
|
| 94 | - // charger les valeurs |
|
| 95 | - // ce qui permet de prendre en charge une fonction charger() existante |
|
| 96 | - // qui prend alors la main sur l'auto detection |
|
| 97 | - if ($charger_valeurs = charger_fonction("charger", "formulaires/$form/", true)) { |
|
| 98 | - $valeurs = call_user_func_array($charger_valeurs, $args); |
|
| 99 | - } |
|
| 100 | - $valeurs = pipeline( |
|
| 101 | - 'formulaire_charger', |
|
| 102 | - array( |
|
| 103 | - 'args' => array('form' => $form, 'args' => $args, 'je_suis_poste' => false), |
|
| 104 | - 'data' => $valeurs |
|
| 105 | - ) |
|
| 106 | - ); |
|
| 107 | - // ne pas stocker editable ! |
|
| 108 | - unset($valeurs['editable']); |
|
| 93 | + $valeurs = array(); |
|
| 94 | + // charger les valeurs |
|
| 95 | + // ce qui permet de prendre en charge une fonction charger() existante |
|
| 96 | + // qui prend alors la main sur l'auto detection |
|
| 97 | + if ($charger_valeurs = charger_fonction("charger", "formulaires/$form/", true)) { |
|
| 98 | + $valeurs = call_user_func_array($charger_valeurs, $args); |
|
| 99 | + } |
|
| 100 | + $valeurs = pipeline( |
|
| 101 | + 'formulaire_charger', |
|
| 102 | + array( |
|
| 103 | + 'args' => array('form' => $form, 'args' => $args, 'je_suis_poste' => false), |
|
| 104 | + 'data' => $valeurs |
|
| 105 | + ) |
|
| 106 | + ); |
|
| 107 | + // ne pas stocker editable ! |
|
| 108 | + unset($valeurs['editable']); |
|
| 109 | 109 | |
| 110 | - // recuperer les valeurs postees |
|
| 111 | - $store = array(); |
|
| 112 | - foreach ($valeurs as $k => $v) { |
|
| 113 | - if (substr($k, 0, 1) !== '_') { |
|
| 114 | - $store[$k] = _request($k); |
|
| 115 | - } |
|
| 116 | - } |
|
| 110 | + // recuperer les valeurs postees |
|
| 111 | + $store = array(); |
|
| 112 | + foreach ($valeurs as $k => $v) { |
|
| 113 | + if (substr($k, 0, 1) !== '_') { |
|
| 114 | + $store[$k] = _request($k); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - return cvtconf_configurer_stocker($form, $valeurs, $store); |
|
| 118 | + return cvtconf_configurer_stocker($form, $valeurs, $store); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -131,31 +131,31 @@ discard block |
||
| 131 | 131 | * @return array |
| 132 | 132 | */ |
| 133 | 133 | function cvtconf_definir_configurer_conteneur($form, $valeurs) { |
| 134 | - // stocker en base |
|
| 135 | - // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 136 | - $casier = substr($form, 11); |
|
| 137 | - $table = 'meta'; |
|
| 138 | - $prefixe = ''; |
|
| 139 | - $stockage = ''; |
|
| 134 | + // stocker en base |
|
| 135 | + // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 136 | + $casier = substr($form, 11); |
|
| 137 | + $table = 'meta'; |
|
| 138 | + $prefixe = ''; |
|
| 139 | + $stockage = ''; |
|
| 140 | 140 | |
| 141 | - if (isset($valeurs['_meta_casier'])) { |
|
| 142 | - $casier = $valeurs['_meta_casier']; |
|
| 143 | - } |
|
| 144 | - if (isset($valeurs['_meta_prefixe'])) { |
|
| 145 | - $prefixe = $valeurs['_meta_prefixe']; |
|
| 146 | - } |
|
| 147 | - if (isset($valeurs['_meta_stockage'])) { |
|
| 148 | - $stockage = $valeurs['_meta_stockage'] . '::'; |
|
| 149 | - } |
|
| 141 | + if (isset($valeurs['_meta_casier'])) { |
|
| 142 | + $casier = $valeurs['_meta_casier']; |
|
| 143 | + } |
|
| 144 | + if (isset($valeurs['_meta_prefixe'])) { |
|
| 145 | + $prefixe = $valeurs['_meta_prefixe']; |
|
| 146 | + } |
|
| 147 | + if (isset($valeurs['_meta_stockage'])) { |
|
| 148 | + $stockage = $valeurs['_meta_stockage'] . '::'; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - // si on indique juste une table, il faut vider les autres proprietes |
|
| 152 | - // car par defaut on utilise ni casier ni prefixe dans ce cas |
|
| 153 | - if (isset($valeurs['_meta_table'])) { |
|
| 154 | - $table = $valeurs['_meta_table']; |
|
| 155 | - $casier = (isset($valeurs['_meta_casier']) ? $valeurs['_meta_casier'] : ''); |
|
| 156 | - } |
|
| 151 | + // si on indique juste une table, il faut vider les autres proprietes |
|
| 152 | + // car par defaut on utilise ni casier ni prefixe dans ce cas |
|
| 153 | + if (isset($valeurs['_meta_table'])) { |
|
| 154 | + $table = $valeurs['_meta_table']; |
|
| 155 | + $casier = (isset($valeurs['_meta_casier']) ? $valeurs['_meta_casier'] : ''); |
|
| 156 | + } |
|
| 157 | 157 | |
| 158 | - return array($table, $casier, $prefixe, $stockage); |
|
| 158 | + return array($table, $casier, $prefixe, $stockage); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -166,45 +166,45 @@ discard block |
||
| 166 | 166 | * @return array |
| 167 | 167 | */ |
| 168 | 168 | function cvtconf_formulaires_configurer_recense($form) { |
| 169 | - $valeurs = array('editable' => ' '); |
|
| 169 | + $valeurs = array('editable' => ' '); |
|
| 170 | 170 | |
| 171 | - // sinon cas analyse du squelette |
|
| 172 | - if ($f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/') |
|
| 173 | - and lire_fichier($f, $contenu) |
|
| 174 | - ) { |
|
| 171 | + // sinon cas analyse du squelette |
|
| 172 | + if ($f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/') |
|
| 173 | + and lire_fichier($f, $contenu) |
|
| 174 | + ) { |
|
| 175 | 175 | |
| 176 | - for ($i = 0; $i < 2; $i++) { |
|
| 177 | - // a la seconde iteration, evaluer le fond avec les valeurs deja trouvees |
|
| 178 | - // permet de trouver aussi les name="#GET{truc}" |
|
| 179 | - if ($i == 1) { |
|
| 180 | - $contenu = recuperer_fond("formulaires/$form", $valeurs); |
|
| 181 | - } |
|
| 176 | + for ($i = 0; $i < 2; $i++) { |
|
| 177 | + // a la seconde iteration, evaluer le fond avec les valeurs deja trouvees |
|
| 178 | + // permet de trouver aussi les name="#GET{truc}" |
|
| 179 | + if ($i == 1) { |
|
| 180 | + $contenu = recuperer_fond("formulaires/$form", $valeurs); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - $balises = array_merge(extraire_balises($contenu, 'input'), |
|
| 184 | - extraire_balises($contenu, 'textarea'), |
|
| 185 | - extraire_balises($contenu, 'select')); |
|
| 183 | + $balises = array_merge(extraire_balises($contenu, 'input'), |
|
| 184 | + extraire_balises($contenu, 'textarea'), |
|
| 185 | + extraire_balises($contenu, 'select')); |
|
| 186 | 186 | |
| 187 | - foreach ($balises as $b) { |
|
| 188 | - if ($n = extraire_attribut($b, 'name') |
|
| 189 | - and preg_match(",^([\w\-]+)(\[\w*\])?$,", $n, $r) |
|
| 190 | - and !in_array($n, array('formulaire_action', 'formulaire_action_args')) |
|
| 191 | - and extraire_attribut($b, 'type') !== 'submit' |
|
| 192 | - ) { |
|
| 193 | - $valeurs[$r[1]] = ''; |
|
| 194 | - // recuperer les valeurs _meta_xx qui peuvent etre fournies |
|
| 195 | - // en input hidden dans le squelette |
|
| 196 | - if (strncmp($r[1], '_meta_', 6) == 0) { |
|
| 197 | - $valeurs[$r[1]] = extraire_attribut($b, 'value'); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 187 | + foreach ($balises as $b) { |
|
| 188 | + if ($n = extraire_attribut($b, 'name') |
|
| 189 | + and preg_match(",^([\w\-]+)(\[\w*\])?$,", $n, $r) |
|
| 190 | + and !in_array($n, array('formulaire_action', 'formulaire_action_args')) |
|
| 191 | + and extraire_attribut($b, 'type') !== 'submit' |
|
| 192 | + ) { |
|
| 193 | + $valeurs[$r[1]] = ''; |
|
| 194 | + // recuperer les valeurs _meta_xx qui peuvent etre fournies |
|
| 195 | + // en input hidden dans le squelette |
|
| 196 | + if (strncmp($r[1], '_meta_', 6) == 0) { |
|
| 197 | + $valeurs[$r[1]] = extraire_attribut($b, 'value'); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | |
| 205 | - cvtconf_configurer_lire_meta($form, $valeurs); |
|
| 205 | + cvtconf_configurer_lire_meta($form, $valeurs); |
|
| 206 | 206 | |
| 207 | - return $valeurs; |
|
| 207 | + return $valeurs; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -216,26 +216,26 @@ discard block |
||
| 216 | 216 | * @return string |
| 217 | 217 | */ |
| 218 | 218 | function cvtconf_configurer_stocker($form, $valeurs, $store) { |
| 219 | - $trace = ''; |
|
| 220 | - list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 221 | - // stocker en base |
|
| 222 | - // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 223 | - if (!isset($GLOBALS[$table])) { |
|
| 224 | - lire_metas($table); |
|
| 225 | - } |
|
| 219 | + $trace = ''; |
|
| 220 | + list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 221 | + // stocker en base |
|
| 222 | + // par defaut, dans un casier serialize dans spip_meta (idem CFG) |
|
| 223 | + if (!isset($GLOBALS[$table])) { |
|
| 224 | + lire_metas($table); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 228 | - $table = ($table) ? "/$table/" : ""; |
|
| 229 | - $casier = ($casier) ? rtrim($casier, '/') . '/' : ""; // slash final, sinon rien |
|
| 227 | + $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 228 | + $table = ($table) ? "/$table/" : ""; |
|
| 229 | + $casier = ($casier) ? rtrim($casier, '/') . '/' : ""; // slash final, sinon rien |
|
| 230 | 230 | |
| 231 | - foreach ($store as $k => $v) { |
|
| 232 | - ecrire_config("$stockage$table$prefixe$casier$k", $v); |
|
| 233 | - if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 234 | - $trace .= "<br />table $table : " . $prefixe . $k . " = $v;"; |
|
| 235 | - } |
|
| 236 | - } |
|
| 231 | + foreach ($store as $k => $v) { |
|
| 232 | + ecrire_config("$stockage$table$prefixe$casier$k", $v); |
|
| 233 | + if (_request('var_mode') == 'configurer' and autoriser('webmestre')) { |
|
| 234 | + $trace .= "<br />table $table : " . $prefixe . $k . " = $v;"; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - return $trace; |
|
| 238 | + return $trace; |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -245,21 +245,21 @@ discard block |
||
| 245 | 245 | * @param array $valeurs |
| 246 | 246 | */ |
| 247 | 247 | function cvtconf_configurer_lire_meta($form, &$valeurs) { |
| 248 | - list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 248 | + list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs); |
|
| 249 | 249 | |
| 250 | - $table = ($table) ? "/$table/" : ""; |
|
| 251 | - $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 252 | - if ($casier) { |
|
| 253 | - $meta = lire_config("$stockage$table$prefixe$casier"); |
|
| 254 | - $prefixe = ''; |
|
| 255 | - } else { |
|
| 256 | - $table = rtrim($table, '/'); |
|
| 257 | - $meta = lire_config("$stockage$table"); |
|
| 258 | - } |
|
| 250 | + $table = ($table) ? "/$table/" : ""; |
|
| 251 | + $prefixe = ($prefixe ? $prefixe . '_' : ''); |
|
| 252 | + if ($casier) { |
|
| 253 | + $meta = lire_config("$stockage$table$prefixe$casier"); |
|
| 254 | + $prefixe = ''; |
|
| 255 | + } else { |
|
| 256 | + $table = rtrim($table, '/'); |
|
| 257 | + $meta = lire_config("$stockage$table"); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - foreach ($valeurs as $k => $v) { |
|
| 261 | - if (substr($k, 0, 1) !== '_') { |
|
| 262 | - $valeurs[$k] = (isset($meta[$prefixe . $k]) ? $meta[$prefixe . $k] : null); |
|
| 263 | - } |
|
| 264 | - } |
|
| 260 | + foreach ($valeurs as $k => $v) { |
|
| 261 | + if (substr($k, 0, 1) !== '_') { |
|
| 262 | + $valeurs[$k] = (isset($meta[$prefixe . $k]) ? $meta[$prefixe . $k] : null); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | 265 | } |