@@ -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'); |
@@ -30,63 +30,63 @@ discard block |
||
| 30 | 30 | **/ |
| 31 | 31 | function exec_upgrade_dist() { |
| 32 | 32 | |
| 33 | - if (!_FILE_CONNECT) { |
|
| 34 | - redirige_url_ecrire("install"); |
|
| 35 | - } |
|
| 33 | + if (!_FILE_CONNECT) { |
|
| 34 | + redirige_url_ecrire("install"); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - // Si reinstallation necessaire, message ad hoc |
|
| 38 | - if (_request('reinstall') == 'oui') { |
|
| 39 | - include_spip('inc/minipres'); |
|
| 40 | - $r = minipres(_T('titre_page_upgrade'), |
|
| 41 | - "<p><b>" |
|
| 42 | - . _T('texte_nouvelle_version_spip_1') |
|
| 43 | - . "</b><p> " |
|
| 44 | - . _T('texte_nouvelle_version_spip_2', |
|
| 45 | - array('connect' => '<tt>' . _FILE_CONNECT . '</tt>')) |
|
| 46 | - . generer_form_ecrire('upgrade', "<input type='hidden' name='reinstall' value='non' />", '', |
|
| 47 | - _T('bouton_relancer_installation'))); |
|
| 48 | - echo $r; |
|
| 49 | - } elseif (_request('fin')) { |
|
| 50 | - include_spip('inc/plugin'); |
|
| 51 | - actualise_plugins_actifs(); |
|
| 52 | - include_spip('inc/headers'); |
|
| 53 | - $res = generer_url_ecrire('admin_plugin', 'var_mode=recalcul'); |
|
| 54 | - echo redirige_formulaire($res); |
|
| 55 | - } else { |
|
| 37 | + // Si reinstallation necessaire, message ad hoc |
|
| 38 | + if (_request('reinstall') == 'oui') { |
|
| 39 | + include_spip('inc/minipres'); |
|
| 40 | + $r = minipres(_T('titre_page_upgrade'), |
|
| 41 | + "<p><b>" |
|
| 42 | + . _T('texte_nouvelle_version_spip_1') |
|
| 43 | + . "</b><p> " |
|
| 44 | + . _T('texte_nouvelle_version_spip_2', |
|
| 45 | + array('connect' => '<tt>' . _FILE_CONNECT . '</tt>')) |
|
| 46 | + . generer_form_ecrire('upgrade', "<input type='hidden' name='reinstall' value='non' />", '', |
|
| 47 | + _T('bouton_relancer_installation'))); |
|
| 48 | + echo $r; |
|
| 49 | + } elseif (_request('fin')) { |
|
| 50 | + include_spip('inc/plugin'); |
|
| 51 | + actualise_plugins_actifs(); |
|
| 52 | + include_spip('inc/headers'); |
|
| 53 | + $res = generer_url_ecrire('admin_plugin', 'var_mode=recalcul'); |
|
| 54 | + echo redirige_formulaire($res); |
|
| 55 | + } else { |
|
| 56 | 56 | |
| 57 | - if (!isset($GLOBALS['meta']['version_installee'])) { |
|
| 58 | - $GLOBALS['meta']['version_installee'] = 0.0; |
|
| 59 | - } else { |
|
| 60 | - $GLOBALS['meta']['version_installee'] = |
|
| 61 | - (double)str_replace(',', '.', $GLOBALS['meta']['version_installee']); |
|
| 62 | - } |
|
| 63 | - # NB: str_replace car, sur club-internet, il semble que version_installe soit |
|
| 64 | - # enregistree au format '1,812' et non '1.812' |
|
| 57 | + if (!isset($GLOBALS['meta']['version_installee'])) { |
|
| 58 | + $GLOBALS['meta']['version_installee'] = 0.0; |
|
| 59 | + } else { |
|
| 60 | + $GLOBALS['meta']['version_installee'] = |
|
| 61 | + (double)str_replace(',', '.', $GLOBALS['meta']['version_installee']); |
|
| 62 | + } |
|
| 63 | + # NB: str_replace car, sur club-internet, il semble que version_installe soit |
|
| 64 | + # enregistree au format '1,812' et non '1.812' |
|
| 65 | 65 | |
| 66 | - // Erreur downgrade |
|
| 67 | - // (cas de double installation de fichiers SPIP sur une meme base) |
|
| 68 | - if ($GLOBALS['spip_version_base'] < $GLOBALS['meta']['version_installee']) { |
|
| 69 | - $commentaire = _T('info_mise_a_niveau_base_2'); |
|
| 70 | - } // Commentaire standard upgrade |
|
| 71 | - else { |
|
| 72 | - $commentaire = _T('texte_mise_a_niveau_base_1'); |
|
| 73 | - } |
|
| 66 | + // Erreur downgrade |
|
| 67 | + // (cas de double installation de fichiers SPIP sur une meme base) |
|
| 68 | + if ($GLOBALS['spip_version_base'] < $GLOBALS['meta']['version_installee']) { |
|
| 69 | + $commentaire = _T('info_mise_a_niveau_base_2'); |
|
| 70 | + } // Commentaire standard upgrade |
|
| 71 | + else { |
|
| 72 | + $commentaire = _T('texte_mise_a_niveau_base_1'); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - $commentaire .= "<br />[" . $GLOBALS['meta']['version_installee'] . "/" . $GLOBALS['spip_version_base'] . "]"; |
|
| 75 | + $commentaire .= "<br />[" . $GLOBALS['meta']['version_installee'] . "/" . $GLOBALS['spip_version_base'] . "]"; |
|
| 76 | 76 | |
| 77 | - $_POST['reinstall'] = 'non'; // pour copy_request dans admin |
|
| 78 | - include_spip('inc/headers'); |
|
| 79 | - $admin = charger_fonction('admin', 'inc'); |
|
| 80 | - $res = $admin('upgrade', _T('info_mise_a_niveau_base'), $commentaire); |
|
| 81 | - if ($res) { |
|
| 82 | - echo $res; |
|
| 83 | - } else { |
|
| 84 | - // effacer les alea pour forcer leur relecture |
|
| 85 | - // si jamais ils ont change pendant l'upgrade |
|
| 86 | - unset($GLOBALS['meta']['alea_ephemere']); |
|
| 87 | - unset($GLOBALS['meta']['alea_ephemere_ancien']); |
|
| 88 | - $res = redirige_action_auteur('purger', 'cache', 'upgrade', 'fin=oui', true); |
|
| 89 | - echo redirige_formulaire($res); |
|
| 90 | - } |
|
| 91 | - } |
|
| 77 | + $_POST['reinstall'] = 'non'; // pour copy_request dans admin |
|
| 78 | + include_spip('inc/headers'); |
|
| 79 | + $admin = charger_fonction('admin', 'inc'); |
|
| 80 | + $res = $admin('upgrade', _T('info_mise_a_niveau_base'), $commentaire); |
|
| 81 | + if ($res) { |
|
| 82 | + echo $res; |
|
| 83 | + } else { |
|
| 84 | + // effacer les alea pour forcer leur relecture |
|
| 85 | + // si jamais ils ont change pendant l'upgrade |
|
| 86 | + unset($GLOBALS['meta']['alea_ephemere']); |
|
| 87 | + unset($GLOBALS['meta']['alea_ephemere_ancien']); |
|
| 88 | + $res = redirige_action_auteur('purger', 'cache', 'upgrade', 'fin=oui', true); |
|
| 89 | + echo redirige_formulaire($res); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | . _T('texte_nouvelle_version_spip_1') |
| 43 | 43 | . "</b><p> " |
| 44 | 44 | . _T('texte_nouvelle_version_spip_2', |
| 45 | - array('connect' => '<tt>' . _FILE_CONNECT . '</tt>')) |
|
| 45 | + array('connect' => '<tt>'._FILE_CONNECT.'</tt>')) |
|
| 46 | 46 | . generer_form_ecrire('upgrade', "<input type='hidden' name='reinstall' value='non' />", '', |
| 47 | 47 | _T('bouton_relancer_installation'))); |
| 48 | 48 | echo $r; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $GLOBALS['meta']['version_installee'] = 0.0; |
| 59 | 59 | } else { |
| 60 | 60 | $GLOBALS['meta']['version_installee'] = |
| 61 | - (double)str_replace(',', '.', $GLOBALS['meta']['version_installee']); |
|
| 61 | + (double) str_replace(',', '.', $GLOBALS['meta']['version_installee']); |
|
| 62 | 62 | } |
| 63 | 63 | # NB: str_replace car, sur club-internet, il semble que version_installe soit |
| 64 | 64 | # enregistree au format '1,812' et non '1.812' |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $commentaire = _T('texte_mise_a_niveau_base_1'); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $commentaire .= "<br />[" . $GLOBALS['meta']['version_installee'] . "/" . $GLOBALS['spip_version_base'] . "]"; |
|
| 75 | + $commentaire .= "<br />[".$GLOBALS['meta']['version_installee']."/".$GLOBALS['spip_version_base']."]"; |
|
| 76 | 76 | |
| 77 | 77 | $_POST['reinstall'] = 'non'; // pour copy_request dans admin |
| 78 | 78 | include_spip('inc/headers'); |
@@ -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 | } |
@@ -46,8 +46,8 @@ |
||
| 46 | 46 | |
| 47 | 47 | echo debut_grand_cadre(true); |
| 48 | 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>"; |
|
| 49 | + echo "<p>"._T('info_procedure_maj_version')."</p>", |
|
| 50 | + "<p>"._T('info_administrateur_site_01')."</p>"; |
|
| 51 | 51 | echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire("upgrade", "reinstall=non")); |
| 52 | 52 | echo boite_fermer(); |
| 53 | 53 | // masquer les erreurs sql sur cette page car proviennent de la base pas a jour ! |
@@ -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 | } |
@@ -67,15 +67,15 @@ discard block |
||
| 67 | 67 | $where = preg_split(",\s+,", $type); |
| 68 | 68 | if ($where) { |
| 69 | 69 | foreach ($where as $k => $v) { |
| 70 | - $where[$k] = "'%" . substr(str_replace("%", "\%", sql_quote($v, '', 'string')), 1, -1) . "%'"; |
|
| 70 | + $where[$k] = "'%".substr(str_replace("%", "\%", sql_quote($v, '', 'string')), 1, -1)."%'"; |
|
| 71 | 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) . ")"); |
|
| 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 | 75 | |
| 76 | 76 | if ($exclus) { |
| 77 | 77 | include_spip('inc/rubriques'); |
| 78 | - $where_exclus = " AND " . sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT'); |
|
| 78 | + $where_exclus = " AND ".sql_in('id_rubrique', calcul_branche_in($exclus), 'NOT'); |
|
| 79 | 79 | } else { |
| 80 | 80 | $where_exclus = ''; |
| 81 | 81 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | if ($points) { |
| 105 | 105 | arsort($points); |
| 106 | - $style = " style='background-image: url(" . chemin_image('secteur-12.png') . ")'"; |
|
| 106 | + $style = " style='background-image: url(".chemin_image('secteur-12.png').")'"; |
|
| 107 | 107 | foreach ($rub as $k => $v) { |
| 108 | 108 | $rub[$k]['atts'] = ($v["id_parent"] ? $style : '') |
| 109 | 109 | . " class='petite-rubrique'"; |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | if (!$ids) { |
| 137 | 137 | return "<br /><br /><div style='padding: 5px; color: red;'><b>" |
| 138 | 138 | . spip_htmlentities($type) |
| 139 | - . "</b> : " . _T('avis_aucun_resultat') . "</div>"; |
|
| 139 | + . "</b> : "._T('avis_aucun_resultat')."</div>"; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $ret = ''; |
| 143 | 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 | 147 | $ondbClick = "$do(this.firstChild.firstChild.nodeValue,this.firstChild.title,'selection_rubrique', 'id_parent');"; |
| 148 | 148 | |
@@ -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(); |
@@ -26,7 +26,7 @@ |
||
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | $fond = _request('exec'); |
| 29 | -$GLOBALS['delais'] = 0;// pas de cache ! |
|
| 29 | +$GLOBALS['delais'] = 0; // pas de cache ! |
|
| 30 | 30 | // Securite |
| 31 | 31 | if (strstr($fond, '/')) { |
| 32 | 32 | if (!include_spip('inc/autoriser') |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | if ($quoi !== 'actifs') { |
| 140 | 140 | $lpf = liste_plugin_files(); |
| 141 | 141 | if ($lpf) { |
| 142 | - echo "<p>" . _T('texte_presente_plugin') . "</p>"; |
|
| 142 | + echo "<p>"._T('texte_presente_plugin')."</p>"; |
|
| 143 | 143 | } else { |
| 144 | 144 | if (!@is_dir(_DIR_PLUGINS)) { |
| 145 | - echo "<p>" . _T('plugin_info_automatique_ftp', array('rep' => joli_repertoire(_DIR_PLUGINS))) |
|
| 146 | - . " — " . _T('plugin_info_automatique_creer') . "</p>"; |
|
| 145 | + echo "<p>"._T('plugin_info_automatique_ftp', array('rep' => joli_repertoire(_DIR_PLUGINS))) |
|
| 146 | + . " — "._T('plugin_info_automatique_creer')."</p>"; |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | $lcpaffiche = $lpf; |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | if (defined('_DIR_PLUGINS_SUPPL')) { |
| 165 | 165 | $nb += count($lcpas); |
| 166 | 166 | } |
| 167 | - echo "<h3>" . sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 168 | - _T('plugins_actif_aucun')) . "</h3>"; |
|
| 167 | + echo "<h3>".sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 168 | + _T('plugins_actif_aucun'))."</h3>"; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | if (empty($format)) { |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | if ($corps) { |
| 184 | 184 | $corps .= "\n<div class='boutons' style='display:none;'>" |
| 185 | - . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 185 | + . "<input type='submit' class='submit save' value='"._T('bouton_enregistrer') |
|
| 186 | 186 | . "' />" |
| 187 | 187 | . "</div>"; |
| 188 | 188 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
| 256 | 256 | . "<p>" |
| 257 | 257 | . _T('plugin_info_plugins_dist_1', array('plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST))) |
| 258 | - . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 258 | + . '<br />'._T('plugin_info_plugins_dist_2') |
|
| 259 | 259 | . "</p>" |
| 260 | 260 | . $liste |
| 261 | 261 | . fin_cadre_trait_couleur(true) |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
| 279 | 279 | $res .= '<dl>'; |
| 280 | 280 | foreach ($libs as $lib => $rep) { |
| 281 | - $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 281 | + $res .= "<dt>$lib</dt><dd>".joli_repertoire($rep)."</dd>\n"; |
|
| 282 | 282 | } |
| 283 | 283 | $res .= '</dl>'; |
| 284 | 284 | $res .= fin_cadre_enfonce(true); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | function liste_librairies() { |
| 297 | 297 | $libs = array(); |
| 298 | 298 | foreach (array_reverse(creer_chemin()) as $d) { |
| 299 | - if (is_dir($dir = $d . 'lib/') |
|
| 299 | + if (is_dir($dir = $d.'lib/') |
|
| 300 | 300 | and $t = opendir($dir) |
| 301 | 301 | ) { |
| 302 | 302 | while (($f = readdir($t)) !== false) { |
@@ -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/config'); |
@@ -37,26 +37,26 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function exec_admin_plugin_dist($retour = '') { |
| 39 | 39 | |
| 40 | - if (!autoriser('configurer', '_plugins')) { |
|
| 41 | - include_spip('inc/minipres'); |
|
| 42 | - echo minipres(); |
|
| 43 | - } else { |
|
| 44 | - // on fait la verif du path avant tout, |
|
| 45 | - // et l'installation des qu'on est dans la colonne principale |
|
| 46 | - // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | - // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | - $new = actualise_plugins_actifs(); |
|
| 49 | - if ($new and _request('actualise') < 2) { |
|
| 50 | - include_spip('inc/headers'); |
|
| 51 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | - } |
|
| 55 | - redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | - } else { |
|
| 57 | - admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | - } |
|
| 59 | - } |
|
| 40 | + if (!autoriser('configurer', '_plugins')) { |
|
| 41 | + include_spip('inc/minipres'); |
|
| 42 | + echo minipres(); |
|
| 43 | + } else { |
|
| 44 | + // on fait la verif du path avant tout, |
|
| 45 | + // et l'installation des qu'on est dans la colonne principale |
|
| 46 | + // si jamais la liste des plugins actifs change, il faut faire un refresh du hit |
|
| 47 | + // pour etre sur que les bons fichiers seront charges lors de l'install |
|
| 48 | + $new = actualise_plugins_actifs(); |
|
| 49 | + if ($new and _request('actualise') < 2) { |
|
| 50 | + include_spip('inc/headers'); |
|
| 51 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 52 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 53 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 54 | + } |
|
| 55 | + redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&')); |
|
| 56 | + } else { |
|
| 57 | + admin_plug_args(_request('voir'), _request('erreur'), _request('format')); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -81,126 +81,126 @@ discard block |
||
| 81 | 81 | * Format d'affichage (liste ou arborescence) |
| 82 | 82 | **/ |
| 83 | 83 | function admin_plug_args($quoi, $erreur, $format) { |
| 84 | - if (!$quoi) { |
|
| 85 | - $quoi = 'actifs'; |
|
| 86 | - } |
|
| 87 | - // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 88 | - // format brut par plugin |
|
| 89 | - $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 90 | - // format resume mis en forme |
|
| 91 | - $erreur_activation = plugin_donne_erreurs(); |
|
| 92 | - $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 93 | - echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); |
|
| 94 | - |
|
| 95 | - echo debut_gauche('plugin', true); |
|
| 96 | - echo recuperer_fond('prive/squelettes/navigation/configurer', array('exec' => 'admin_plugin')); |
|
| 97 | - |
|
| 98 | - echo pipeline('affiche_gauche', |
|
| 99 | - array( |
|
| 100 | - 'args' => array('exec' => 'admin_plugin'), |
|
| 101 | - 'data' => afficher_librairies() |
|
| 102 | - ) |
|
| 103 | - ); |
|
| 104 | - |
|
| 105 | - echo debut_droite('plugin', true); |
|
| 106 | - echo gros_titre(_T('icone_admin_plugin'), '', false); |
|
| 107 | - |
|
| 108 | - // Barre d'onglets de premier niveau |
|
| 109 | - echo barre_onglets("plugins", "plugins_actifs"); |
|
| 110 | - // Barre d'onglets de second niveau |
|
| 111 | - $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 112 | - echo debut_onglet('onglets_simple second'); |
|
| 113 | - echo onglet(_T('plugins_tous_liste'), generer_url_ecrire("admin_plugin", "voir=tous"), 'admin_plugin', $onglet2); |
|
| 114 | - echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire("admin_plugin"), 'plugins_actifs', $onglet2); |
|
| 115 | - echo fin_onglet(); |
|
| 116 | - |
|
| 117 | - // message d'erreur au retour d'une operation |
|
| 118 | - if ($erreur) { |
|
| 119 | - echo "<div class='error'>$erreur</div>"; |
|
| 120 | - } |
|
| 121 | - if ($erreur_activation) { |
|
| 122 | - echo "<div class='error'>$erreur_activation</div>"; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 126 | - $actifs = unserialize($GLOBALS['meta']['plugin']); |
|
| 127 | - $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 128 | - |
|
| 129 | - // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 130 | - $actifs = liste_chemin_plugin($actifs, ''); |
|
| 131 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 132 | - $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL); |
|
| 133 | - } |
|
| 134 | - $lcpa = liste_chemin_plugin($lcpa); |
|
| 135 | - |
|
| 136 | - // on installe les plugins maintenant, |
|
| 137 | - // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 138 | - plugin_installes_meta(); |
|
| 139 | - |
|
| 140 | - echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 141 | - echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins'); |
|
| 142 | - |
|
| 143 | - if ($quoi !== 'actifs') { |
|
| 144 | - $lpf = liste_plugin_files(); |
|
| 145 | - if ($lpf) { |
|
| 146 | - echo "<p>" . _T('texte_presente_plugin') . "</p>"; |
|
| 147 | - } else { |
|
| 148 | - if (!@is_dir(_DIR_PLUGINS)) { |
|
| 149 | - echo "<p>" . _T('plugin_info_automatique_ftp', array('rep' => joli_repertoire(_DIR_PLUGINS))) |
|
| 150 | - . " — " . _T('plugin_info_automatique_creer') . "</p>"; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - $lcpaffiche = $lpf; |
|
| 154 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 155 | - $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - // la liste |
|
| 159 | - // $quoi=='actifs' |
|
| 160 | - $lcpaffiche = $lcpa; |
|
| 161 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 162 | - $lcpaffichesup = $lcpas; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if ($quoi == 'actifs' or $lpf) { |
|
| 167 | - $nb = count($lcpa); |
|
| 168 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 169 | - $nb += count($lcpas); |
|
| 170 | - } |
|
| 171 | - echo "<h3>" . sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 172 | - _T('plugins_actif_aucun')) . "</h3>"; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if (empty($format)) { |
|
| 176 | - $format = 'liste'; |
|
| 177 | - } elseif (!in_array($format, array('liste', 'repertoires'))) { |
|
| 178 | - $format = 'repertoires'; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $afficher = charger_fonction("afficher_$format", 'plugins'); |
|
| 182 | - $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs); |
|
| 183 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 184 | - $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - if ($corps) { |
|
| 188 | - $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 189 | - . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 190 | - . "' />" |
|
| 191 | - . "</div>"; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps); |
|
| 195 | - |
|
| 196 | - echo fin_cadre_trait_couleur(true); |
|
| 197 | - |
|
| 198 | - if ($quoi == 'actifs') { |
|
| 199 | - echo affiche_les_plugins_verrouilles($actifs); |
|
| 200 | - } |
|
| 201 | - echo "</div>"; |
|
| 202 | - |
|
| 203 | - echo http_script(" |
|
| 84 | + if (!$quoi) { |
|
| 85 | + $quoi = 'actifs'; |
|
| 86 | + } |
|
| 87 | + // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite |
|
| 88 | + // format brut par plugin |
|
| 89 | + $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false); |
|
| 90 | + // format resume mis en forme |
|
| 91 | + $erreur_activation = plugin_donne_erreurs(); |
|
| 92 | + $commencer_page = charger_fonction('commencer_page', 'inc'); |
|
| 93 | + echo $commencer_page(_T('icone_admin_plugin'), "configuration", "plugin"); |
|
| 94 | + |
|
| 95 | + echo debut_gauche('plugin', true); |
|
| 96 | + echo recuperer_fond('prive/squelettes/navigation/configurer', array('exec' => 'admin_plugin')); |
|
| 97 | + |
|
| 98 | + echo pipeline('affiche_gauche', |
|
| 99 | + array( |
|
| 100 | + 'args' => array('exec' => 'admin_plugin'), |
|
| 101 | + 'data' => afficher_librairies() |
|
| 102 | + ) |
|
| 103 | + ); |
|
| 104 | + |
|
| 105 | + echo debut_droite('plugin', true); |
|
| 106 | + echo gros_titre(_T('icone_admin_plugin'), '', false); |
|
| 107 | + |
|
| 108 | + // Barre d'onglets de premier niveau |
|
| 109 | + echo barre_onglets("plugins", "plugins_actifs"); |
|
| 110 | + // Barre d'onglets de second niveau |
|
| 111 | + $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin'; |
|
| 112 | + echo debut_onglet('onglets_simple second'); |
|
| 113 | + echo onglet(_T('plugins_tous_liste'), generer_url_ecrire("admin_plugin", "voir=tous"), 'admin_plugin', $onglet2); |
|
| 114 | + echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire("admin_plugin"), 'plugins_actifs', $onglet2); |
|
| 115 | + echo fin_onglet(); |
|
| 116 | + |
|
| 117 | + // message d'erreur au retour d'une operation |
|
| 118 | + if ($erreur) { |
|
| 119 | + echo "<div class='error'>$erreur</div>"; |
|
| 120 | + } |
|
| 121 | + if ($erreur_activation) { |
|
| 122 | + echo "<div class='error'>$erreur_activation</div>"; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs |
|
| 126 | + $actifs = unserialize($GLOBALS['meta']['plugin']); |
|
| 127 | + $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']); |
|
| 128 | + |
|
| 129 | + // Les affichages se basent sur le repertoire, pas sur le nom |
|
| 130 | + $actifs = liste_chemin_plugin($actifs, ''); |
|
| 131 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 132 | + $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL); |
|
| 133 | + } |
|
| 134 | + $lcpa = liste_chemin_plugin($lcpa); |
|
| 135 | + |
|
| 136 | + // on installe les plugins maintenant, |
|
| 137 | + // cela permet aux scripts d'install de faire des affichages (moches...) |
|
| 138 | + plugin_installes_meta(); |
|
| 139 | + |
|
| 140 | + echo "<div class='liste-plugins formulaire_spip'>"; |
|
| 141 | + echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins'); |
|
| 142 | + |
|
| 143 | + if ($quoi !== 'actifs') { |
|
| 144 | + $lpf = liste_plugin_files(); |
|
| 145 | + if ($lpf) { |
|
| 146 | + echo "<p>" . _T('texte_presente_plugin') . "</p>"; |
|
| 147 | + } else { |
|
| 148 | + if (!@is_dir(_DIR_PLUGINS)) { |
|
| 149 | + echo "<p>" . _T('plugin_info_automatique_ftp', array('rep' => joli_repertoire(_DIR_PLUGINS))) |
|
| 150 | + . " — " . _T('plugin_info_automatique_creer') . "</p>"; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + $lcpaffiche = $lpf; |
|
| 154 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 155 | + $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL); |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + // la liste |
|
| 159 | + // $quoi=='actifs' |
|
| 160 | + $lcpaffiche = $lcpa; |
|
| 161 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 162 | + $lcpaffichesup = $lcpas; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if ($quoi == 'actifs' or $lpf) { |
|
| 167 | + $nb = count($lcpa); |
|
| 168 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 169 | + $nb += count($lcpas); |
|
| 170 | + } |
|
| 171 | + echo "<h3>" . sinon(singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'), |
|
| 172 | + _T('plugins_actif_aucun')) . "</h3>"; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if (empty($format)) { |
|
| 176 | + $format = 'liste'; |
|
| 177 | + } elseif (!in_array($format, array('liste', 'repertoires'))) { |
|
| 178 | + $format = 'repertoires'; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $afficher = charger_fonction("afficher_$format", 'plugins'); |
|
| 182 | + $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs); |
|
| 183 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 184 | + $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + if ($corps) { |
|
| 188 | + $corps .= "\n<div class='boutons' style='display:none;'>" |
|
| 189 | + . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer') |
|
| 190 | + . "' />" |
|
| 191 | + . "</div>"; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps); |
|
| 195 | + |
|
| 196 | + echo fin_cadre_trait_couleur(true); |
|
| 197 | + |
|
| 198 | + if ($quoi == 'actifs') { |
|
| 199 | + echo affiche_les_plugins_verrouilles($actifs); |
|
| 200 | + } |
|
| 201 | + echo "</div>"; |
|
| 202 | + |
|
| 203 | + echo http_script(" |
|
| 204 | 204 | jQuery(function(){ |
| 205 | 205 | jQuery('.plugins li.item a[rel=info]').click(function(){ |
| 206 | 206 | var li = jQuery(this).parents('li').eq(0); |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | }); |
| 227 | 227 | "); |
| 228 | 228 | |
| 229 | - echo pipeline('affiche_milieu', |
|
| 230 | - array( |
|
| 231 | - 'args' => array('exec' => 'admin_plugin'), |
|
| 232 | - 'data' => '' |
|
| 233 | - ) |
|
| 234 | - ); |
|
| 229 | + echo pipeline('affiche_milieu', |
|
| 230 | + array( |
|
| 231 | + 'args' => array('exec' => 'admin_plugin'), |
|
| 232 | + 'data' => '' |
|
| 233 | + ) |
|
| 234 | + ); |
|
| 235 | 235 | |
| 236 | - echo fin_gauche(), fin_page(); |
|
| 236 | + echo fin_gauche(), fin_page(); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -247,23 +247,23 @@ discard block |
||
| 247 | 247 | * Code HTML |
| 248 | 248 | **/ |
| 249 | 249 | function affiche_les_plugins_verrouilles($actifs) { |
| 250 | - if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) { |
|
| 251 | - return ''; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - $afficher = charger_fonction("afficher_liste", 'plugins'); |
|
| 255 | - $liste = $afficher(self(), $liste, array(), $actifs, _DIR_PLUGINS_DIST); |
|
| 256 | - |
|
| 257 | - return |
|
| 258 | - "<div id='plugins_dist'>" |
|
| 259 | - . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 260 | - . "<p>" |
|
| 261 | - . _T('plugin_info_plugins_dist_1', array('plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST))) |
|
| 262 | - . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 263 | - . "</p>" |
|
| 264 | - . $liste |
|
| 265 | - . fin_cadre_trait_couleur(true) |
|
| 266 | - . "</div>\n"; |
|
| 250 | + if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) { |
|
| 251 | + return ''; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + $afficher = charger_fonction("afficher_liste", 'plugins'); |
|
| 255 | + $liste = $afficher(self(), $liste, array(), $actifs, _DIR_PLUGINS_DIST); |
|
| 256 | + |
|
| 257 | + return |
|
| 258 | + "<div id='plugins_dist'>" |
|
| 259 | + . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist') |
|
| 260 | + . "<p>" |
|
| 261 | + . _T('plugin_info_plugins_dist_1', array('plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST))) |
|
| 262 | + . '<br />' . _T('plugin_info_plugins_dist_2') |
|
| 263 | + . "</p>" |
|
| 264 | + . $liste |
|
| 265 | + . fin_cadre_trait_couleur(true) |
|
| 266 | + . "</div>\n"; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -275,19 +275,19 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | function afficher_librairies() { |
| 277 | 277 | |
| 278 | - if (!$libs = liste_librairies()) { |
|
| 279 | - return ''; |
|
| 280 | - } |
|
| 281 | - ksort($libs); |
|
| 282 | - $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 283 | - $res .= '<dl>'; |
|
| 284 | - foreach ($libs as $lib => $rep) { |
|
| 285 | - $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 286 | - } |
|
| 287 | - $res .= '</dl>'; |
|
| 288 | - $res .= fin_cadre_enfonce(true); |
|
| 289 | - |
|
| 290 | - return $res; |
|
| 278 | + if (!$libs = liste_librairies()) { |
|
| 279 | + return ''; |
|
| 280 | + } |
|
| 281 | + ksort($libs); |
|
| 282 | + $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees')); |
|
| 283 | + $res .= '<dl>'; |
|
| 284 | + foreach ($libs as $lib => $rep) { |
|
| 285 | + $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n"; |
|
| 286 | + } |
|
| 287 | + $res .= '</dl>'; |
|
| 288 | + $res .= fin_cadre_enfonce(true); |
|
| 289 | + |
|
| 290 | + return $res; |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | |
@@ -298,20 +298,20 @@ discard block |
||
| 298 | 298 | * Tableau (nom de la lib => repertoire , ...) |
| 299 | 299 | */ |
| 300 | 300 | function liste_librairies() { |
| 301 | - $libs = array(); |
|
| 302 | - foreach (array_reverse(creer_chemin()) as $d) { |
|
| 303 | - if (is_dir($dir = $d . 'lib/') |
|
| 304 | - and $t = opendir($dir) |
|
| 305 | - ) { |
|
| 306 | - while (($f = readdir($t)) !== false) { |
|
| 307 | - if ($f[0] != '.' |
|
| 308 | - and is_dir("$dir/$f") |
|
| 309 | - ) { |
|
| 310 | - $libs[$f] = $dir; |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - return $libs; |
|
| 301 | + $libs = array(); |
|
| 302 | + foreach (array_reverse(creer_chemin()) as $d) { |
|
| 303 | + if (is_dir($dir = $d . 'lib/') |
|
| 304 | + and $t = opendir($dir) |
|
| 305 | + ) { |
|
| 306 | + while (($f = readdir($t)) !== false) { |
|
| 307 | + if ($f[0] != '.' |
|
| 308 | + and is_dir("$dir/$f") |
|
| 309 | + ) { |
|
| 310 | + $libs[$f] = $dir; |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + return $libs; |
|
| 317 | 317 | } |
@@ -92,10 +92,12 @@ |
||
| 92 | 92 | $store = &$_GET; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - foreach ($c as $k => $v) // on ecrase pas si saisi a nouveau ! |
|
| 95 | + foreach ($c as $k => $v) { |
|
| 96 | + // on ecrase pas si saisi a nouveau ! |
|
| 96 | 97 | { |
| 97 | 98 | if (!isset($store[$k])) { |
| 98 | 99 | $_REQUEST[$k] = $store[$k] = $v; |
| 100 | + } |
|
| 99 | 101 | } // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
| 100 | 102 | elseif (is_array($store[$k]) |
| 101 | 103 | and is_array($v) |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $erreurs_etapes = array(); |
| 230 | 230 | $derniere_etape_ok = 0; |
| 231 | 231 | $e = 0; |
| 232 | - while ($e < max($etape, $etape_demandee -1) and $e < $etapes) { |
|
| 232 | + while ($e < max($etape, $etape_demandee - 1) and $e < $etapes) { |
|
| 233 | 233 | $e++; |
| 234 | 234 | $erreurs_etapes[$e] = array(); |
| 235 | 235 | if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | // si la derniere etape OK etait la derniere |
| 268 | 268 | // on renvoie le flux inchange et ca declenche traiter |
| 269 | 269 | if ($derniere_etape_ok == $etapes |
| 270 | - and (!$etape_demandee or $etape_demandee>=$etapes)) { |
|
| 270 | + and (!$etape_demandee or $etape_demandee >= $etapes)) { |
|
| 271 | 271 | return $erreurs; |
| 272 | 272 | } else { |
| 273 | 273 | $etape = $derniere_etape_ok + 1; |
@@ -309,9 +309,9 @@ discard block |
||
| 309 | 309 | and ($e = $flux['args']['contexte']['_etape']) > 1 |
| 310 | 310 | and $ext = $flux['args']['ext'] |
| 311 | 311 | and $f = $flux['data'] |
| 312 | - and file_exists($f . "_$e.$ext") |
|
| 312 | + and file_exists($f."_$e.$ext") |
|
| 313 | 313 | ) { |
| 314 | - $flux['data'] = $f . "_$e"; |
|
| 314 | + $flux['data'] = $f."_$e"; |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | return $flux; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | |
| 68 | 68 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 69 | - return; |
|
| 69 | + return; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -77,45 +77,45 @@ discard block |
||
| 77 | 77 | * @return array |
| 78 | 78 | */ |
| 79 | 79 | function cvtmulti_recuperer_post_precedents($form) { |
| 80 | - include_spip('inc/filtres'); |
|
| 81 | - if ($form |
|
| 82 | - and $c = _request('cvtm_prev_post') |
|
| 83 | - and $c = decoder_contexte_ajax($c, $form) |
|
| 84 | - ) { |
|
| 85 | - #var_dump($c); |
|
| 80 | + include_spip('inc/filtres'); |
|
| 81 | + if ($form |
|
| 82 | + and $c = _request('cvtm_prev_post') |
|
| 83 | + and $c = decoder_contexte_ajax($c, $form) |
|
| 84 | + ) { |
|
| 85 | + #var_dump($c); |
|
| 86 | 86 | |
| 87 | - # reinjecter dans la bonne variable pour permettre de retrouver |
|
| 88 | - # toutes les saisies dans un seul tableau |
|
| 89 | - if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 90 | - $store = &$_POST; |
|
| 91 | - } else { |
|
| 92 | - $store = &$_GET; |
|
| 93 | - } |
|
| 87 | + # reinjecter dans la bonne variable pour permettre de retrouver |
|
| 88 | + # toutes les saisies dans un seul tableau |
|
| 89 | + if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
|
| 90 | + $store = &$_POST; |
|
| 91 | + } else { |
|
| 92 | + $store = &$_GET; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - foreach ($c as $k => $v) // on ecrase pas si saisi a nouveau ! |
|
| 96 | - { |
|
| 97 | - if (!isset($store[$k])) { |
|
| 98 | - $_REQUEST[$k] = $store[$k] = $v; |
|
| 99 | - } // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
|
| 100 | - elseif (is_array($store[$k]) |
|
| 101 | - and is_array($v) |
|
| 102 | - and $z = array_keys($v) |
|
| 103 | - and !is_numeric(reset($z)) |
|
| 104 | - and $z = array_keys($store[$k]) |
|
| 105 | - and !is_numeric(reset($z)) |
|
| 106 | - ) { |
|
| 107 | - $_REQUEST[$k] = $store[$k] = array_merge($v, $store[$k]); |
|
| 108 | - } |
|
| 109 | - } |
|
| 95 | + foreach ($c as $k => $v) // on ecrase pas si saisi a nouveau ! |
|
| 96 | + { |
|
| 97 | + if (!isset($store[$k])) { |
|
| 98 | + $_REQUEST[$k] = $store[$k] = $v; |
|
| 99 | + } // mais si tableau des deux cotes, on merge avec priorite a la derniere saisie |
|
| 100 | + elseif (is_array($store[$k]) |
|
| 101 | + and is_array($v) |
|
| 102 | + and $z = array_keys($v) |
|
| 103 | + and !is_numeric(reset($z)) |
|
| 104 | + and $z = array_keys($store[$k]) |
|
| 105 | + and !is_numeric(reset($z)) |
|
| 106 | + ) { |
|
| 107 | + $_REQUEST[$k] = $store[$k] = array_merge($v, $store[$k]); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - // vider pour eviter un second appel a verifier_n |
|
| 112 | - // en cas de double implementation (unipotence) |
|
| 113 | - set_request('cvtm_prev_post'); |
|
| 111 | + // vider pour eviter un second appel a verifier_n |
|
| 112 | + // en cas de double implementation (unipotence) |
|
| 113 | + set_request('cvtm_prev_post'); |
|
| 114 | 114 | |
| 115 | - return array($c['_etape'], $c['_etapes']); |
|
| 116 | - } |
|
| 115 | + return array($c['_etape'], $c['_etapes']); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - return false; |
|
| 118 | + return false; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -128,28 +128,28 @@ discard block |
||
| 128 | 128 | * @return array |
| 129 | 129 | */ |
| 130 | 130 | function cvtmulti_sauver_post($form, $je_suis_poste, &$valeurs) { |
| 131 | - if (!isset($valeurs['_cvtm_prev_post'])) { |
|
| 132 | - $post = array('_etape' => $valeurs['_etape'], '_etapes' => $valeurs['_etapes']); |
|
| 133 | - foreach (array_keys($valeurs) as $champ) { |
|
| 134 | - if (substr($champ, 0, 1) !== '_') { |
|
| 135 | - if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { |
|
| 136 | - if (($v = _request($champ)) !== null) { |
|
| 137 | - $post[$champ] = $v; |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - include_spip('inc/filtres'); |
|
| 143 | - $c = encoder_contexte_ajax($post, $form); |
|
| 144 | - if (!isset($valeurs['_hidden'])) { |
|
| 145 | - $valeurs['_hidden'] = ''; |
|
| 146 | - } |
|
| 147 | - $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />"; |
|
| 148 | - // marquer comme fait, pour eviter double encodage (unipotence) |
|
| 149 | - $valeurs['_cvtm_prev_post'] = true; |
|
| 150 | - } |
|
| 131 | + if (!isset($valeurs['_cvtm_prev_post'])) { |
|
| 132 | + $post = array('_etape' => $valeurs['_etape'], '_etapes' => $valeurs['_etapes']); |
|
| 133 | + foreach (array_keys($valeurs) as $champ) { |
|
| 134 | + if (substr($champ, 0, 1) !== '_') { |
|
| 135 | + if ($je_suis_poste || (isset($valeurs['_forcer_request']) && $valeurs['_forcer_request'])) { |
|
| 136 | + if (($v = _request($champ)) !== null) { |
|
| 137 | + $post[$champ] = $v; |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + include_spip('inc/filtres'); |
|
| 143 | + $c = encoder_contexte_ajax($post, $form); |
|
| 144 | + if (!isset($valeurs['_hidden'])) { |
|
| 145 | + $valeurs['_hidden'] = ''; |
|
| 146 | + } |
|
| 147 | + $valeurs['_hidden'] .= "<input type='hidden' name='cvtm_prev_post' value='$c' />"; |
|
| 148 | + // marquer comme fait, pour eviter double encodage (unipotence) |
|
| 149 | + $valeurs['_cvtm_prev_post'] = true; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - return $valeurs; |
|
| 152 | + return $valeurs; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | * @return array |
| 163 | 163 | */ |
| 164 | 164 | function cvtmulti_formulaire_charger($flux) { |
| 165 | - if (is_array($flux['data']) |
|
| 166 | - and isset($flux['data']['_etapes']) |
|
| 167 | - ) { |
|
| 168 | - $flux['data'] = cvtmulti_formulaire_charger_etapes($flux['args'], $flux['data']); |
|
| 169 | - } |
|
| 165 | + if (is_array($flux['data']) |
|
| 166 | + and isset($flux['data']['_etapes']) |
|
| 167 | + ) { |
|
| 168 | + $flux['data'] = cvtmulti_formulaire_charger_etapes($flux['args'], $flux['data']); |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - return $flux; |
|
| 171 | + return $flux; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | /** |
@@ -178,19 +178,19 @@ discard block |
||
| 178 | 178 | * @return array |
| 179 | 179 | */ |
| 180 | 180 | function cvtmulti_formulaire_charger_etapes($args, $valeurs) { |
| 181 | - if (!isset($valeurs['_etape'])) { |
|
| 182 | - $form = $args['form']; |
|
| 183 | - $je_suis_poste = $args['je_suis_poste']; |
|
| 184 | - $nb_etapes = $valeurs['_etapes']; |
|
| 185 | - $etape = _request('_etape'); |
|
| 186 | - $etape = min(max($etape, 1), $nb_etapes); |
|
| 187 | - set_request('_etape', $etape); |
|
| 188 | - $valeurs['_etape'] = $etape; |
|
| 181 | + if (!isset($valeurs['_etape'])) { |
|
| 182 | + $form = $args['form']; |
|
| 183 | + $je_suis_poste = $args['je_suis_poste']; |
|
| 184 | + $nb_etapes = $valeurs['_etapes']; |
|
| 185 | + $etape = _request('_etape'); |
|
| 186 | + $etape = min(max($etape, 1), $nb_etapes); |
|
| 187 | + set_request('_etape', $etape); |
|
| 188 | + $valeurs['_etape'] = $etape; |
|
| 189 | 189 | |
| 190 | - // sauver les posts de cette etape pour les avoir a la prochaine etape |
|
| 191 | - $valeurs = cvtmulti_sauver_post($form, $je_suis_poste, $valeurs); |
|
| 192 | - } |
|
| 193 | - return $valeurs; |
|
| 190 | + // sauver les posts de cette etape pour les avoir a la prochaine etape |
|
| 191 | + $valeurs = cvtmulti_sauver_post($form, $je_suis_poste, $valeurs); |
|
| 192 | + } |
|
| 193 | + return $valeurs; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | * @return array |
| 203 | 203 | */ |
| 204 | 204 | function cvtmulti_formulaire_verifier($flux) { |
| 205 | - $flux['data'] = cvtmulti_formulaire_verifier_etapes($flux['args'], $flux['data']); |
|
| 206 | - return $flux; |
|
| 205 | + $flux['data'] = cvtmulti_formulaire_verifier_etapes($flux['args'], $flux['data']); |
|
| 206 | + return $flux; |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -214,84 +214,84 @@ discard block |
||
| 214 | 214 | * @return array |
| 215 | 215 | */ |
| 216 | 216 | function cvtmulti_formulaire_verifier_etapes($args, $erreurs) { |
| 217 | - #var_dump('Pipe verifier'); |
|
| 217 | + #var_dump('Pipe verifier'); |
|
| 218 | 218 | |
| 219 | - if ($form = $args['form'] |
|
| 220 | - and ($e = cvtmulti_recuperer_post_precedents($form)) !== false |
|
| 221 | - ) { |
|
| 222 | - // recuperer l'etape saisie et le nombre d'etapes total |
|
| 223 | - list($etape, $etapes) = $e; |
|
| 224 | - $etape_demandee = intval(_request('aller_a_etape')); // possibilite de poster un entier dans aller_a_etape |
|
| 219 | + if ($form = $args['form'] |
|
| 220 | + and ($e = cvtmulti_recuperer_post_precedents($form)) !== false |
|
| 221 | + ) { |
|
| 222 | + // recuperer l'etape saisie et le nombre d'etapes total |
|
| 223 | + list($etape, $etapes) = $e; |
|
| 224 | + $etape_demandee = intval(_request('aller_a_etape')); // possibilite de poster un entier dans aller_a_etape |
|
| 225 | 225 | |
| 226 | - $args['etape_saisie'] = $etape; |
|
| 227 | - $args['etapes'] = $etapes; |
|
| 228 | - // lancer les verifs pour chaque etape deja saisie de 1 a $etape |
|
| 229 | - $erreurs_etapes = array(); |
|
| 230 | - $derniere_etape_ok = 0; |
|
| 231 | - $e = 0; |
|
| 232 | - while ($e < max($etape, $etape_demandee -1) and $e < $etapes) { |
|
| 233 | - $e++; |
|
| 234 | - $erreurs_etapes[$e] = array(); |
|
| 235 | - if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) { |
|
| 236 | - $erreurs_etapes[$e] = call_user_func_array($verifier, $args['args']); |
|
| 237 | - } elseif ($verifier = charger_fonction("verifier_etape", "formulaires/$form/", true)) { |
|
| 238 | - $a = $args['args']; |
|
| 239 | - array_unshift($a, $e); |
|
| 240 | - $erreurs_etapes[$e] = call_user_func_array($verifier, $a); |
|
| 241 | - } |
|
| 242 | - // et on appelle un pipeline dedie aux etapes, plus easy |
|
| 243 | - $args['etape'] = $e; |
|
| 244 | - $args['etape_demandee'] = $etape_demandee; |
|
| 245 | - $erreurs_etapes[$e] = pipeline( |
|
| 246 | - 'formulaire_verifier_etape', |
|
| 247 | - array( |
|
| 248 | - 'args' => $args, |
|
| 249 | - 'data' => $erreurs_etapes[$e] |
|
| 250 | - ) |
|
| 251 | - ); |
|
| 226 | + $args['etape_saisie'] = $etape; |
|
| 227 | + $args['etapes'] = $etapes; |
|
| 228 | + // lancer les verifs pour chaque etape deja saisie de 1 a $etape |
|
| 229 | + $erreurs_etapes = array(); |
|
| 230 | + $derniere_etape_ok = 0; |
|
| 231 | + $e = 0; |
|
| 232 | + while ($e < max($etape, $etape_demandee -1) and $e < $etapes) { |
|
| 233 | + $e++; |
|
| 234 | + $erreurs_etapes[$e] = array(); |
|
| 235 | + if ($verifier = charger_fonction("verifier_$e", "formulaires/$form/", true)) { |
|
| 236 | + $erreurs_etapes[$e] = call_user_func_array($verifier, $args['args']); |
|
| 237 | + } elseif ($verifier = charger_fonction("verifier_etape", "formulaires/$form/", true)) { |
|
| 238 | + $a = $args['args']; |
|
| 239 | + array_unshift($a, $e); |
|
| 240 | + $erreurs_etapes[$e] = call_user_func_array($verifier, $a); |
|
| 241 | + } |
|
| 242 | + // et on appelle un pipeline dedie aux etapes, plus easy |
|
| 243 | + $args['etape'] = $e; |
|
| 244 | + $args['etape_demandee'] = $etape_demandee; |
|
| 245 | + $erreurs_etapes[$e] = pipeline( |
|
| 246 | + 'formulaire_verifier_etape', |
|
| 247 | + array( |
|
| 248 | + 'args' => $args, |
|
| 249 | + 'data' => $erreurs_etapes[$e] |
|
| 250 | + ) |
|
| 251 | + ); |
|
| 252 | 252 | |
| 253 | - if ($derniere_etape_ok == $e - 1 and !count($erreurs_etapes[$e])) { |
|
| 254 | - $derniere_etape_ok = $e; |
|
| 255 | - } |
|
| 256 | - // possibilite de poster dans _retour_etape_x ou aller_a_etape |
|
| 257 | - if (!is_null(_request("_retour_etape_$e"))) { |
|
| 258 | - $etape_demandee = $e; |
|
| 259 | - } |
|
| 260 | - // Il se peut que les verifications ait décidé de faire sauter des étapes |
|
| 261 | - if ($aller_a_etape = intval(_request('aller_a_etape'))) { |
|
| 262 | - $etape_demandee = $aller_a_etape; // possibilite de poster un entier dans aller_a_etape |
|
| 263 | - } |
|
| 264 | - } |
|
| 253 | + if ($derniere_etape_ok == $e - 1 and !count($erreurs_etapes[$e])) { |
|
| 254 | + $derniere_etape_ok = $e; |
|
| 255 | + } |
|
| 256 | + // possibilite de poster dans _retour_etape_x ou aller_a_etape |
|
| 257 | + if (!is_null(_request("_retour_etape_$e"))) { |
|
| 258 | + $etape_demandee = $e; |
|
| 259 | + } |
|
| 260 | + // Il se peut que les verifications ait décidé de faire sauter des étapes |
|
| 261 | + if ($aller_a_etape = intval(_request('aller_a_etape'))) { |
|
| 262 | + $etape_demandee = $aller_a_etape; // possibilite de poster un entier dans aller_a_etape |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | |
| 267 | - // si la derniere etape OK etait la derniere |
|
| 268 | - // on renvoie le flux inchange et ca declenche traiter |
|
| 269 | - if ($derniere_etape_ok == $etapes |
|
| 270 | - and (!$etape_demandee or $etape_demandee>=$etapes)) { |
|
| 271 | - return $erreurs; |
|
| 272 | - } else { |
|
| 273 | - $etape = $derniere_etape_ok + 1; |
|
| 274 | - if ($etape_demandee > 0 and $etape_demandee < $etape) { |
|
| 275 | - $etape = $etape_demandee; |
|
| 276 | - } |
|
| 277 | - $etape = min($etape, $etapes); |
|
| 278 | - #var_dump("prochaine etape $etape"); |
|
| 279 | - // retourner les erreurs de l'etape ciblee |
|
| 280 | - $erreurs = isset($erreurs_etapes[$etape]) ? $erreurs_etapes[$etape] : array(); |
|
| 281 | - // Ne pas se tromper dans le texte du message d'erreur : la clé '_etapes' n'est pas une erreur ! |
|
| 282 | - if ($erreurs) { |
|
| 283 | - if (!isset($erreurs['message_erreur'])) { |
|
| 284 | - $erreurs['message_erreur'] = singulier_ou_pluriel(count($erreurs), 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie'); |
|
| 285 | - } |
|
| 286 | - } else { |
|
| 287 | - $erreurs['message_erreur'] = ''; |
|
| 288 | - } |
|
| 289 | - $erreurs['_etapes'] = "etape suivante $etape"; |
|
| 290 | - set_request('_etape', $etape); |
|
| 291 | - } |
|
| 292 | - } |
|
| 267 | + // si la derniere etape OK etait la derniere |
|
| 268 | + // on renvoie le flux inchange et ca declenche traiter |
|
| 269 | + if ($derniere_etape_ok == $etapes |
|
| 270 | + and (!$etape_demandee or $etape_demandee>=$etapes)) { |
|
| 271 | + return $erreurs; |
|
| 272 | + } else { |
|
| 273 | + $etape = $derniere_etape_ok + 1; |
|
| 274 | + if ($etape_demandee > 0 and $etape_demandee < $etape) { |
|
| 275 | + $etape = $etape_demandee; |
|
| 276 | + } |
|
| 277 | + $etape = min($etape, $etapes); |
|
| 278 | + #var_dump("prochaine etape $etape"); |
|
| 279 | + // retourner les erreurs de l'etape ciblee |
|
| 280 | + $erreurs = isset($erreurs_etapes[$etape]) ? $erreurs_etapes[$etape] : array(); |
|
| 281 | + // Ne pas se tromper dans le texte du message d'erreur : la clé '_etapes' n'est pas une erreur ! |
|
| 282 | + if ($erreurs) { |
|
| 283 | + if (!isset($erreurs['message_erreur'])) { |
|
| 284 | + $erreurs['message_erreur'] = singulier_ou_pluriel(count($erreurs), 'avis_1_erreur_saisie', 'avis_nb_erreurs_saisie'); |
|
| 285 | + } |
|
| 286 | + } else { |
|
| 287 | + $erreurs['message_erreur'] = ''; |
|
| 288 | + } |
|
| 289 | + $erreurs['_etapes'] = "etape suivante $etape"; |
|
| 290 | + set_request('_etape', $etape); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - return $erreurs; |
|
| 294 | + return $erreurs; |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -303,16 +303,16 @@ discard block |
||
| 303 | 303 | * @return array |
| 304 | 304 | */ |
| 305 | 305 | function cvtmulti_styliser($flux) { |
| 306 | - if (strncmp($flux['args']['fond'], 'formulaires/', 12) == 0 |
|
| 307 | - and isset($flux['args']['contexte']['_etapes']) |
|
| 308 | - and isset($flux['args']['contexte']['_etape']) |
|
| 309 | - and ($e = $flux['args']['contexte']['_etape']) > 1 |
|
| 310 | - and $ext = $flux['args']['ext'] |
|
| 311 | - and $f = $flux['data'] |
|
| 312 | - and file_exists($f . "_$e.$ext") |
|
| 313 | - ) { |
|
| 314 | - $flux['data'] = $f . "_$e"; |
|
| 315 | - } |
|
| 306 | + if (strncmp($flux['args']['fond'], 'formulaires/', 12) == 0 |
|
| 307 | + and isset($flux['args']['contexte']['_etapes']) |
|
| 308 | + and isset($flux['args']['contexte']['_etape']) |
|
| 309 | + and ($e = $flux['args']['contexte']['_etape']) > 1 |
|
| 310 | + and $ext = $flux['args']['ext'] |
|
| 311 | + and $f = $flux['data'] |
|
| 312 | + and file_exists($f . "_$e.$ext") |
|
| 313 | + ) { |
|
| 314 | + $flux['data'] = $f . "_$e"; |
|
| 315 | + } |
|
| 316 | 316 | |
| 317 | - return $flux; |
|
| 317 | + return $flux; |
|
| 318 | 318 | } |
@@ -135,7 +135,7 @@ |
||
| 135 | 135 | while ( |
| 136 | 136 | $p !== false |
| 137 | 137 | and ($morceau = substr($txt, $d, $p - $d)) |
| 138 | - and (($nopen += preg_match_all("{<" . preg_quote($closing_tag) . "(\s*>|\s[^>]*[^/>]>)}is", $morceau, |
|
| 138 | + and (($nopen += preg_match_all("{<".preg_quote($closing_tag)."(\s*>|\s[^>]*[^/>]>)}is", $morceau, |
|
| 139 | 139 | $matches, PREG_SET_ORDER)) > $nclose) |
| 140 | 140 | ) { |
| 141 | 141 | $nclose++; |
@@ -154,9 +154,11 @@ |
||
| 154 | 154 | } |
| 155 | 155 | $content = substr($txt, 0, $p); |
| 156 | 156 | $txt = substr($txt, $p + $ncclos); |
| 157 | - if ($profondeur == 0 or strpos($content, "<") === false) // eviter une recursion si pas utile |
|
| 157 | + if ($profondeur == 0 or strpos($content, "<") === false) { |
|
| 158 | + // eviter une recursion si pas utile |
|
| 158 | 159 | { |
| 159 | 160 | $out[$tag][] = importer_charset($content, $charset); |
| 161 | + } |
|
| 160 | 162 | }//$content; |
| 161 | 163 | else { |
| 162 | 164 | $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | |
@@ -47,24 +47,24 @@ discard block |
||
| 47 | 47 | * - false si l'arbre xml ne peut être créé ou est vide |
| 48 | 48 | **/ |
| 49 | 49 | function spip_xml_load($fichier, $strict = true, $clean = true, $taille_max = 1048576, $datas = '', $profondeur = -1) { |
| 50 | - $contenu = ""; |
|
| 51 | - if (tester_url_absolue($fichier)) { |
|
| 52 | - include_spip('inc/distant'); |
|
| 53 | - $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | - $contenu = $contenu['page'] ?? ''; |
|
| 55 | - } else { |
|
| 56 | - lire_fichier($fichier, $contenu); |
|
| 57 | - } |
|
| 58 | - $arbre = array(); |
|
| 59 | - if ($contenu) { |
|
| 60 | - $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | - } |
|
| 50 | + $contenu = ""; |
|
| 51 | + if (tester_url_absolue($fichier)) { |
|
| 52 | + include_spip('inc/distant'); |
|
| 53 | + $contenu = recuperer_url($fichier, ['taille_max' => $taille_max, 'datas' => $datas]); |
|
| 54 | + $contenu = $contenu['page'] ?? ''; |
|
| 55 | + } else { |
|
| 56 | + lire_fichier($fichier, $contenu); |
|
| 57 | + } |
|
| 58 | + $arbre = array(); |
|
| 59 | + if ($contenu) { |
|
| 60 | + $arbre = spip_xml_parse($contenu, $strict, $clean, $profondeur); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return count($arbre) ? $arbre : false; |
|
| 63 | + return count($arbre) ? $arbre : false; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | if (!defined('_SPIP_XML_TAG_SPLIT')) { |
| 67 | - define('_SPIP_XML_TAG_SPLIT', "{<([^:>][^>]*?)>}sS"); |
|
| 67 | + define('_SPIP_XML_TAG_SPLIT', "{<([^:>][^>]*?)>}sS"); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -83,150 +83,150 @@ discard block |
||
| 83 | 83 | * - false si l'arbre xml ne peut être créé ou est vide |
| 84 | 84 | **/ |
| 85 | 85 | function spip_xml_parse(&$texte, $strict = true, $clean = true, $profondeur = -1) { |
| 86 | - $out = array(); |
|
| 87 | - // enlever les commentaires |
|
| 88 | - $charset = 'AUTO'; |
|
| 89 | - if ($clean === true) { |
|
| 90 | - if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | - $charset = $regs[2]; |
|
| 92 | - } |
|
| 93 | - $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | - $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | - include_spip('inc/charsets'); |
|
| 96 | - $clean = $charset; |
|
| 97 | - //$texte = importer_charset($texte,$charset); |
|
| 98 | - } |
|
| 99 | - if (is_string($clean)) { |
|
| 100 | - $charset = $clean; |
|
| 101 | - } |
|
| 102 | - $txt = $texte; |
|
| 86 | + $out = array(); |
|
| 87 | + // enlever les commentaires |
|
| 88 | + $charset = 'AUTO'; |
|
| 89 | + if ($clean === true) { |
|
| 90 | + if (preg_match(",<\?xml\s(.*?)encoding=['\"]?(.*?)['\"]?(\s(.*))?\?>,im", $texte, $regs)) { |
|
| 91 | + $charset = $regs[2]; |
|
| 92 | + } |
|
| 93 | + $texte = preg_replace(',<!--(.*?)-->,is', '', $texte); |
|
| 94 | + $texte = preg_replace(',<\?(.*?)\?>,is', '', $texte); |
|
| 95 | + include_spip('inc/charsets'); |
|
| 96 | + $clean = $charset; |
|
| 97 | + //$texte = importer_charset($texte,$charset); |
|
| 98 | + } |
|
| 99 | + if (is_string($clean)) { |
|
| 100 | + $charset = $clean; |
|
| 101 | + } |
|
| 102 | + $txt = $texte; |
|
| 103 | 103 | |
| 104 | - // tant qu'il y a des tags |
|
| 105 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | - while (count($chars) >= 2) { |
|
| 107 | - // tag ouvrant |
|
| 108 | - //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 104 | + // tant qu'il y a des tags |
|
| 105 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 106 | + while (count($chars) >= 2) { |
|
| 107 | + // tag ouvrant |
|
| 108 | + //$chars = preg_split("{<([^>]*?)>}s",$txt,2,PREG_SPLIT_DELIM_CAPTURE); |
|
| 109 | 109 | |
| 110 | - // $before doit etre vide ou des espaces uniquements! |
|
| 111 | - $before = trim($chars[0]); |
|
| 110 | + // $before doit etre vide ou des espaces uniquements! |
|
| 111 | + $before = trim($chars[0]); |
|
| 112 | 112 | |
| 113 | - if (strlen($before) > 0) { |
|
| 114 | - return importer_charset($texte, $charset); |
|
| 115 | - }//$texte; // before non vide, donc on est dans du texte |
|
| 113 | + if (strlen($before) > 0) { |
|
| 114 | + return importer_charset($texte, $charset); |
|
| 115 | + }//$texte; // before non vide, donc on est dans du texte |
|
| 116 | 116 | |
| 117 | - $tag = rtrim($chars[1]); |
|
| 118 | - $txt = $chars[2]; |
|
| 117 | + $tag = rtrim($chars[1]); |
|
| 118 | + $txt = $chars[2]; |
|
| 119 | 119 | |
| 120 | - if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | - return importer_charset($texte, $charset); |
|
| 122 | - }//$texte; |
|
| 123 | - if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | - $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | - $out[$tag][] = ""; |
|
| 126 | - } else { |
|
| 127 | - $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | - $closing_tag = reset($closing_tag); |
|
| 129 | - // tag fermant |
|
| 130 | - $ncclos = strlen("</$closing_tag>"); |
|
| 131 | - $p = strpos($txt, "</$closing_tag>"); |
|
| 132 | - if ($p !== false and (strpos($txt, "<") < $p)) { |
|
| 133 | - $nclose = 0; |
|
| 134 | - $nopen = 0; |
|
| 135 | - $d = 0; |
|
| 136 | - while ( |
|
| 137 | - $p !== false |
|
| 138 | - and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | - and (($nopen += preg_match_all("{<" . preg_quote($closing_tag) . "(\s*>|\s[^>]*[^/>]>)}is", $morceau, |
|
| 140 | - $matches, PREG_SET_ORDER)) > $nclose) |
|
| 141 | - ) { |
|
| 142 | - $nclose++; |
|
| 143 | - $d = $p + $ncclos; |
|
| 144 | - $p = strpos($txt, "</$closing_tag>", $d); |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - if ($p === false) { |
|
| 148 | - if ($strict) { |
|
| 149 | - $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 120 | + if (strncmp($tag, '![CDATA[', 8) == 0) { |
|
| 121 | + return importer_charset($texte, $charset); |
|
| 122 | + }//$texte; |
|
| 123 | + if (substr($tag, -1) == '/') { // self closing tag |
|
| 124 | + $tag = rtrim(substr($tag, 0, strlen($tag) - 1)); |
|
| 125 | + $out[$tag][] = ""; |
|
| 126 | + } else { |
|
| 127 | + $closing_tag = preg_split(",\s|\t|\n|\r,", trim($tag)); |
|
| 128 | + $closing_tag = reset($closing_tag); |
|
| 129 | + // tag fermant |
|
| 130 | + $ncclos = strlen("</$closing_tag>"); |
|
| 131 | + $p = strpos($txt, "</$closing_tag>"); |
|
| 132 | + if ($p !== false and (strpos($txt, "<") < $p)) { |
|
| 133 | + $nclose = 0; |
|
| 134 | + $nopen = 0; |
|
| 135 | + $d = 0; |
|
| 136 | + while ( |
|
| 137 | + $p !== false |
|
| 138 | + and ($morceau = substr($txt, $d, $p - $d)) |
|
| 139 | + and (($nopen += preg_match_all("{<" . preg_quote($closing_tag) . "(\s*>|\s[^>]*[^/>]>)}is", $morceau, |
|
| 140 | + $matches, PREG_SET_ORDER)) > $nclose) |
|
| 141 | + ) { |
|
| 142 | + $nclose++; |
|
| 143 | + $d = $p + $ncclos; |
|
| 144 | + $p = strpos($txt, "</$closing_tag>", $d); |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + if ($p === false) { |
|
| 148 | + if ($strict) { |
|
| 149 | + $out[$tag][] = "erreur : tag fermant $tag manquant::$txt"; |
|
| 150 | 150 | |
| 151 | - return $out; |
|
| 152 | - } else { |
|
| 153 | - return importer_charset($texte, $charset); |
|
| 154 | - }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 155 | - } |
|
| 156 | - $content = substr($txt, 0, $p); |
|
| 157 | - $txt = substr($txt, $p + $ncclos); |
|
| 158 | - if ($profondeur == 0 or strpos($content, "<") === false) // eviter une recursion si pas utile |
|
| 159 | - { |
|
| 160 | - $out[$tag][] = importer_charset($content, $charset); |
|
| 161 | - }//$content; |
|
| 162 | - else { |
|
| 163 | - $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 164 | - } |
|
| 165 | - } |
|
| 166 | - $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 167 | - } |
|
| 168 | - if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 169 | - return $out; |
|
| 170 | - } else { |
|
| 171 | - return importer_charset($texte, $charset); |
|
| 172 | - }//$texte; |
|
| 151 | + return $out; |
|
| 152 | + } else { |
|
| 153 | + return importer_charset($texte, $charset); |
|
| 154 | + }//$texte // un tag qui constitue du texte a reporter dans $before |
|
| 155 | + } |
|
| 156 | + $content = substr($txt, 0, $p); |
|
| 157 | + $txt = substr($txt, $p + $ncclos); |
|
| 158 | + if ($profondeur == 0 or strpos($content, "<") === false) // eviter une recursion si pas utile |
|
| 159 | + { |
|
| 160 | + $out[$tag][] = importer_charset($content, $charset); |
|
| 161 | + }//$content; |
|
| 162 | + else { |
|
| 163 | + $out[$tag][] = spip_xml_parse($content, $strict, $clean, $profondeur - 1); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | + $chars = preg_split(_SPIP_XML_TAG_SPLIT, $txt, 2, PREG_SPLIT_DELIM_CAPTURE); |
|
| 167 | + } |
|
| 168 | + if (count($out) && (strlen(trim($txt)) == 0)) { |
|
| 169 | + return $out; |
|
| 170 | + } else { |
|
| 171 | + return importer_charset($texte, $charset); |
|
| 172 | + }//$texte; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | // https://code.spip.net/@spip_xml_aplatit |
| 176 | 176 | function spip_xml_aplatit($arbre, $separateur = " ") { |
| 177 | - $s = ""; |
|
| 178 | - if (is_array($arbre)) { |
|
| 179 | - foreach ($arbre as $tag => $feuille) { |
|
| 180 | - if (is_array($feuille)) { |
|
| 181 | - if ($tag !== intval($tag)) { |
|
| 182 | - $f = spip_xml_aplatit($feuille, $separateur); |
|
| 183 | - if (strlen($f)) { |
|
| 184 | - $tagf = explode(" ", $tag); |
|
| 185 | - $tagf = $tagf[0]; |
|
| 186 | - $s .= "<$tag>$f</$tagf>"; |
|
| 187 | - } else { |
|
| 188 | - $s .= "<$tag />"; |
|
| 189 | - } |
|
| 190 | - } else { |
|
| 191 | - $s .= spip_xml_aplatit($feuille); |
|
| 192 | - } |
|
| 193 | - $s .= $separateur; |
|
| 194 | - } else { |
|
| 195 | - $s .= "$feuille$separateur"; |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - } |
|
| 177 | + $s = ""; |
|
| 178 | + if (is_array($arbre)) { |
|
| 179 | + foreach ($arbre as $tag => $feuille) { |
|
| 180 | + if (is_array($feuille)) { |
|
| 181 | + if ($tag !== intval($tag)) { |
|
| 182 | + $f = spip_xml_aplatit($feuille, $separateur); |
|
| 183 | + if (strlen($f)) { |
|
| 184 | + $tagf = explode(" ", $tag); |
|
| 185 | + $tagf = $tagf[0]; |
|
| 186 | + $s .= "<$tag>$f</$tagf>"; |
|
| 187 | + } else { |
|
| 188 | + $s .= "<$tag />"; |
|
| 189 | + } |
|
| 190 | + } else { |
|
| 191 | + $s .= spip_xml_aplatit($feuille); |
|
| 192 | + } |
|
| 193 | + $s .= $separateur; |
|
| 194 | + } else { |
|
| 195 | + $s .= "$feuille$separateur"; |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 200 | + return strlen($separateur) ? substr($s, 0, -strlen($separateur)) : $s; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // https://code.spip.net/@spip_xml_tagname |
| 204 | 204 | function spip_xml_tagname($tag) { |
| 205 | - if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 206 | - return $reg[1]; |
|
| 207 | - } |
|
| 205 | + if (preg_match(',^([a-z][\w:]*),i', $tag, $reg)) { |
|
| 206 | + return $reg[1]; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - return ""; |
|
| 209 | + return ""; |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | // https://code.spip.net/@spip_xml_decompose_tag |
| 213 | 213 | function spip_xml_decompose_tag($tag) { |
| 214 | - $tagname = spip_xml_tagname($tag); |
|
| 215 | - $liste = array(); |
|
| 216 | - $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 217 | - $p = strpos($tag, '='); |
|
| 218 | - while ($p !== false) { |
|
| 219 | - $attr = trim(substr($tag, 0, $p)); |
|
| 220 | - $tag = ltrim(substr($tag, $p + 1)); |
|
| 221 | - $quote = $tag[0]; |
|
| 222 | - $p = strpos($tag, $quote, 1); |
|
| 223 | - $cont = substr($tag, 1, $p - 1); |
|
| 224 | - $liste[$attr] = $cont; |
|
| 225 | - $tag = substr($tag, $p + 1); |
|
| 226 | - $p = strpos($tag, '='); |
|
| 227 | - } |
|
| 214 | + $tagname = spip_xml_tagname($tag); |
|
| 215 | + $liste = array(); |
|
| 216 | + $tag = ltrim(strpbrk($tag, " \n\t")); |
|
| 217 | + $p = strpos($tag, '='); |
|
| 218 | + while ($p !== false) { |
|
| 219 | + $attr = trim(substr($tag, 0, $p)); |
|
| 220 | + $tag = ltrim(substr($tag, $p + 1)); |
|
| 221 | + $quote = $tag[0]; |
|
| 222 | + $p = strpos($tag, $quote, 1); |
|
| 223 | + $cont = substr($tag, 1, $p - 1); |
|
| 224 | + $liste[$attr] = $cont; |
|
| 225 | + $tag = substr($tag, $p + 1); |
|
| 226 | + $p = strpos($tag, '='); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - return array($tagname, $liste); |
|
| 229 | + return array($tagname, $liste); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -249,21 +249,21 @@ discard block |
||
| 249 | 249 | * false si aucun élément ne valide l'expression régulière, true sinon. |
| 250 | 250 | **/ |
| 251 | 251 | function spip_xml_match_nodes($regexp, &$arbre, &$matches, $init = true) { |
| 252 | - if ($init) { |
|
| 253 | - $matches = array(); |
|
| 254 | - } |
|
| 255 | - if (is_array($arbre) && count($arbre)) { |
|
| 256 | - foreach (array_keys($arbre) as $tag) { |
|
| 257 | - if (preg_match($regexp, $tag)) { |
|
| 258 | - $matches[$tag] = &$arbre[$tag]; |
|
| 259 | - } |
|
| 260 | - if (is_array($arbre[$tag])) { |
|
| 261 | - foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 262 | - spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - } |
|
| 266 | - } |
|
| 252 | + if ($init) { |
|
| 253 | + $matches = array(); |
|
| 254 | + } |
|
| 255 | + if (is_array($arbre) && count($arbre)) { |
|
| 256 | + foreach (array_keys($arbre) as $tag) { |
|
| 257 | + if (preg_match($regexp, $tag)) { |
|
| 258 | + $matches[$tag] = &$arbre[$tag]; |
|
| 259 | + } |
|
| 260 | + if (is_array($arbre[$tag])) { |
|
| 261 | + foreach (array_keys($arbre[$tag]) as $occurences) { |
|
| 262 | + spip_xml_match_nodes($regexp, $arbre[$tag][$occurences], $matches, false); |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - return (count($matches)); |
|
| 268 | + return (count($matches)); |
|
| 269 | 269 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $_id = $e['id_table_objet']; |
| 51 | 51 | if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
| 52 | 52 | $table = $e['table_objet_sql']; |
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=".intval($id)); |
|
| 54 | 54 | if (isset($row['id_rubrique'])) { |
| 55 | 55 | $contexte['id_rubrique'] = $row['id_rubrique']; |
| 56 | 56 | if (isset($row['id_secteur'])) { |
@@ -111,8 +111,8 @@ discard block |
||
| 111 | 111 | $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
| 112 | 112 | + array( |
| 113 | 113 | $id => new Bouton( |
| 114 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 115 | - $infos['titre'], // titre |
|
| 114 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 115 | + $infos['titre'], // titre |
|
| 116 | 116 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 117 | 117 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 118 | 118 | ) |
@@ -128,8 +128,8 @@ discard block |
||
| 128 | 128 | $boutons_admin = array_slice($boutons_admin, 0, $position) |
| 129 | 129 | + array( |
| 130 | 130 | $id => new Bouton( |
| 131 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 132 | - $infos['titre'], // titre |
|
| 131 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 132 | + $infos['titre'], // titre |
|
| 133 | 133 | (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
| 134 | 134 | (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
| 135 | 135 | ) |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $libelles = $isfavoris = $favoris = array(); |
| 171 | 171 | foreach ($menu->sousmenu as $key => $item) { |
| 172 | 172 | $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
| 173 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 173 | + $isfavoris[$key] = (bool) $item->favori; |
|
| 174 | 174 | $favoris[$key] = $item->favori; |
| 175 | 175 | } |
| 176 | 176 | if ($avec_favoris) { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $url = str_replace('&', '&', $url); |
| 213 | 213 | while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
| 214 | 214 | if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
| 215 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 215 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($contexte['id_rubrique'])); |
|
| 216 | 216 | } |
| 217 | 217 | $val = _request($matches[2], $contexte); |
| 218 | 218 | $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
@@ -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/boutons'); |
@@ -37,33 +37,33 @@ discard block |
||
| 37 | 37 | * Contexte |
| 38 | 38 | **/ |
| 39 | 39 | function definir_barre_contexte($contexte = null) { |
| 40 | - if (is_null($contexte)) { |
|
| 41 | - $contexte = $_GET; |
|
| 42 | - } elseif (is_string($contexte)) { |
|
| 43 | - $contexte = unserialize($contexte); |
|
| 44 | - } |
|
| 45 | - if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | - if (!function_exists('trouver_objet_exec')) { |
|
| 47 | - include_spip('inc/pipelines_ecrire'); |
|
| 48 | - } |
|
| 49 | - if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | - $_id = $e['id_table_objet']; |
|
| 51 | - if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | - $table = $e['table_objet_sql']; |
|
| 53 | - $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | - if (isset($row['id_rubrique'])) { |
|
| 55 | - $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | - if (isset($row['id_secteur'])) { |
|
| 57 | - $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | - } |
|
| 59 | - } elseif (isset($row['id_groupe'])) { |
|
| 60 | - // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | - $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - return $contexte; |
|
| 40 | + if (is_null($contexte)) { |
|
| 41 | + $contexte = $_GET; |
|
| 42 | + } elseif (is_string($contexte)) { |
|
| 43 | + $contexte = unserialize($contexte); |
|
| 44 | + } |
|
| 45 | + if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) { |
|
| 46 | + if (!function_exists('trouver_objet_exec')) { |
|
| 47 | + include_spip('inc/pipelines_ecrire'); |
|
| 48 | + } |
|
| 49 | + if ($e = trouver_objet_exec($contexte['exec'])) { |
|
| 50 | + $_id = $e['id_table_objet']; |
|
| 51 | + if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) { |
|
| 52 | + $table = $e['table_objet_sql']; |
|
| 53 | + $row = sql_fetsel('*', $table, "$_id=" . intval($id)); |
|
| 54 | + if (isset($row['id_rubrique'])) { |
|
| 55 | + $contexte['id_rubrique'] = $row['id_rubrique']; |
|
| 56 | + if (isset($row['id_secteur'])) { |
|
| 57 | + $contexte['id_secteur'] = $row['id_secteur']; |
|
| 58 | + } |
|
| 59 | + } elseif (isset($row['id_groupe'])) { |
|
| 60 | + // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé |
|
| 61 | + $contexte['id_groupe'] = $row['id_groupe']; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + return $contexte; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -79,88 +79,88 @@ discard block |
||
| 79 | 79 | * @return array |
| 80 | 80 | */ |
| 81 | 81 | function definir_barre_boutons($contexte = array(), $icones = true, $autorise = true) { |
| 82 | - include_spip('inc/autoriser'); |
|
| 83 | - $boutons_admin = array(); |
|
| 82 | + include_spip('inc/autoriser'); |
|
| 83 | + $boutons_admin = array(); |
|
| 84 | 84 | |
| 85 | - // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | - $liste_boutons = array(); |
|
| 85 | + // les boutons du core, issus de ecrire/paquet.xml |
|
| 86 | + $liste_boutons = array(); |
|
| 87 | 87 | |
| 88 | - // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | - if (function_exists('boutons_plugins') |
|
| 90 | - and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 91 | - ) { |
|
| 92 | - $liste_boutons = &$liste_boutons_plugins; |
|
| 93 | - } |
|
| 88 | + // ajouter les boutons issus des plugin via paquet.xml |
|
| 89 | + if (function_exists('boutons_plugins') |
|
| 90 | + and is_array($liste_boutons_plugins = boutons_plugins()) |
|
| 91 | + ) { |
|
| 92 | + $liste_boutons = &$liste_boutons_plugins; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - foreach ($liste_boutons as $id => $infos) { |
|
| 96 | - $parent = ''; |
|
| 97 | - // les boutons principaux ne sont pas soumis a autorisation |
|
| 98 | - if (!isset($infos['parent']) |
|
| 99 | - or !($parent = $infos['parent']) |
|
| 100 | - or !$autorise |
|
| 101 | - or autoriser('menu', "_$id", 0, null, array('contexte' => $contexte)) |
|
| 102 | - ) { |
|
| 103 | - if ($parent |
|
| 104 | - and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 105 | - and isset($boutons_admin[$parent]) |
|
| 106 | - ) { |
|
| 107 | - if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 108 | - $boutons_admin[$parent]->sousmenu = array(); |
|
| 109 | - } |
|
| 110 | - $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 111 | - if ($position < 0) { |
|
| 112 | - $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 113 | - } |
|
| 114 | - $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 115 | - + array( |
|
| 116 | - $id => new Bouton( |
|
| 117 | - ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 118 | - $infos['titre'], // titre |
|
| 119 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 120 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 121 | - ) |
|
| 122 | - ) |
|
| 123 | - + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 124 | - } |
|
| 125 | - if (!$parent |
|
| 126 | - // provisoire, eviter les vieux boutons |
|
| 127 | - and (!in_array($id, array('forum', 'statistiques_visites'))) |
|
| 128 | - and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, array('contexte' => $contexte))) |
|
| 129 | - ) { |
|
| 130 | - $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 131 | - $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 132 | - + array( |
|
| 133 | - $id => new Bouton( |
|
| 134 | - ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 135 | - $infos['titre'], // titre |
|
| 136 | - (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 137 | - (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 138 | - ) |
|
| 139 | - ) |
|
| 140 | - + array_slice($boutons_admin, $position, 100); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 95 | + foreach ($liste_boutons as $id => $infos) { |
|
| 96 | + $parent = ''; |
|
| 97 | + // les boutons principaux ne sont pas soumis a autorisation |
|
| 98 | + if (!isset($infos['parent']) |
|
| 99 | + or !($parent = $infos['parent']) |
|
| 100 | + or !$autorise |
|
| 101 | + or autoriser('menu', "_$id", 0, null, array('contexte' => $contexte)) |
|
| 102 | + ) { |
|
| 103 | + if ($parent |
|
| 104 | + and $parent = preg_replace(',^bando_,', 'menu_', $parent) |
|
| 105 | + and isset($boutons_admin[$parent]) |
|
| 106 | + ) { |
|
| 107 | + if (!is_array($boutons_admin[$parent]->sousmenu)) { |
|
| 108 | + $boutons_admin[$parent]->sousmenu = array(); |
|
| 109 | + } |
|
| 110 | + $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu); |
|
| 111 | + if ($position < 0) { |
|
| 112 | + $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position; |
|
| 113 | + } |
|
| 114 | + $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position) |
|
| 115 | + + array( |
|
| 116 | + $id => new Bouton( |
|
| 117 | + ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '', // icone |
|
| 118 | + $infos['titre'], // titre |
|
| 119 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 120 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 121 | + ) |
|
| 122 | + ) |
|
| 123 | + + array_slice($boutons_admin[$parent]->sousmenu, $position, 100); |
|
| 124 | + } |
|
| 125 | + if (!$parent |
|
| 126 | + // provisoire, eviter les vieux boutons |
|
| 127 | + and (!in_array($id, array('forum', 'statistiques_visites'))) |
|
| 128 | + and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, array('contexte' => $contexte))) |
|
| 129 | + ) { |
|
| 130 | + $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin); |
|
| 131 | + $boutons_admin = array_slice($boutons_admin, 0, $position) |
|
| 132 | + + array( |
|
| 133 | + $id => new Bouton( |
|
| 134 | + ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '', // icone |
|
| 135 | + $infos['titre'], // titre |
|
| 136 | + (isset($infos['action']) and $infos['action']) ? $infos['action'] : null, |
|
| 137 | + (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null |
|
| 138 | + ) |
|
| 139 | + ) |
|
| 140 | + + array_slice($boutons_admin, $position, 100); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + $boutons_admin = pipeline('ajouter_menus', $boutons_admin); |
|
| 145 | 145 | |
| 146 | - // définir les favoris et positions d’origine |
|
| 147 | - if ($boutons_admin) { |
|
| 148 | - $menus_favoris = obtenir_menus_favoris(); |
|
| 149 | - $i = 1; |
|
| 150 | - foreach ($boutons_admin as $key => $menu) { |
|
| 151 | - $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 152 | - $menu->position = $i++; |
|
| 153 | - if ($menu->sousmenu) { |
|
| 154 | - $j = 1; |
|
| 155 | - foreach ($menu->sousmenu as $key => $bouton) { |
|
| 156 | - $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 157 | - $bouton->position = $j++; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - } |
|
| 146 | + // définir les favoris et positions d’origine |
|
| 147 | + if ($boutons_admin) { |
|
| 148 | + $menus_favoris = obtenir_menus_favoris(); |
|
| 149 | + $i = 1; |
|
| 150 | + foreach ($boutons_admin as $key => $menu) { |
|
| 151 | + $menu->favori = table_valeur($menus_favoris, $key, false); |
|
| 152 | + $menu->position = $i++; |
|
| 153 | + if ($menu->sousmenu) { |
|
| 154 | + $j = 1; |
|
| 155 | + foreach ($menu->sousmenu as $key => $bouton) { |
|
| 156 | + $bouton->favori = table_valeur($menus_favoris, $key, false); |
|
| 157 | + $bouton->position = $j++; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - return $boutons_admin; |
|
| 163 | + return $boutons_admin; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -172,22 +172,22 @@ discard block |
||
| 172 | 172 | * @return Bouton[] |
| 173 | 173 | */ |
| 174 | 174 | function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) { |
| 175 | - foreach ($menus as $menu) { |
|
| 176 | - if ($menu->sousmenu) { |
|
| 177 | - $libelles = $isfavoris = $favoris = array(); |
|
| 178 | - foreach ($menu->sousmenu as $key => $item) { |
|
| 179 | - $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 180 | - $isfavoris[$key] = (bool)$item->favori; |
|
| 181 | - $favoris[$key] = $item->favori; |
|
| 182 | - } |
|
| 183 | - if ($avec_favoris) { |
|
| 184 | - array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 185 | - } else { |
|
| 186 | - array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - return $menus; |
|
| 175 | + foreach ($menus as $menu) { |
|
| 176 | + if ($menu->sousmenu) { |
|
| 177 | + $libelles = $isfavoris = $favoris = array(); |
|
| 178 | + foreach ($menu->sousmenu as $key => $item) { |
|
| 179 | + $libelles[$key] = strtolower(translitteration(_T($item->libelle))); |
|
| 180 | + $isfavoris[$key] = (bool)$item->favori; |
|
| 181 | + $favoris[$key] = $item->favori; |
|
| 182 | + } |
|
| 183 | + if ($avec_favoris) { |
|
| 184 | + array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu); |
|
| 185 | + } else { |
|
| 186 | + array_multisort($libelles, SORT_ASC, $menu->sousmenu); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + return $menus; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @return Bouton[] |
| 199 | 199 | */ |
| 200 | 200 | function trier_boutons_enfants_par_favoris_alpha($menus) { |
| 201 | - return trier_boutons_enfants_par_alpha($menus, true); |
|
| 201 | + return trier_boutons_enfants_par_alpha($menus, true); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -211,23 +211,23 @@ discard block |
||
| 211 | 211 | * @return string |
| 212 | 212 | */ |
| 213 | 213 | function bandeau_creer_url($url, $args = '', $contexte = null) { |
| 214 | - if (!preg_match(',[\/\?],', $url)) { |
|
| 215 | - $url = generer_url_ecrire($url, $args, true); |
|
| 216 | - // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 217 | - // &truc=@machin@ |
|
| 218 | - // @machin@ etant remplace par _request('machin') |
|
| 219 | - $url = str_replace('&', '&', $url); |
|
| 220 | - while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 221 | - if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 222 | - $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 223 | - } |
|
| 224 | - $val = _request($matches[2], $contexte); |
|
| 225 | - $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 226 | - } |
|
| 227 | - $url = str_replace('&', '&', $url); |
|
| 228 | - } |
|
| 214 | + if (!preg_match(',[\/\?],', $url)) { |
|
| 215 | + $url = generer_url_ecrire($url, $args, true); |
|
| 216 | + // recuperer les parametres du contexte demande par l'url sous la forme |
|
| 217 | + // &truc=@machin@ |
|
| 218 | + // @machin@ etant remplace par _request('machin') |
|
| 219 | + $url = str_replace('&', '&', $url); |
|
| 220 | + while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) { |
|
| 221 | + if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) { |
|
| 222 | + $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique'])); |
|
| 223 | + } |
|
| 224 | + $val = _request($matches[2], $contexte); |
|
| 225 | + $url = parametre_url($url, $matches[1], $val ? $val : '', '&'); |
|
| 226 | + } |
|
| 227 | + $url = str_replace('&', '&', $url); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - return $url; |
|
| 230 | + return $url; |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * Code HTML du bandeau |
| 238 | 238 | */ |
| 239 | 239 | function inc_bandeau_dist() { |
| 240 | - return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 240 | + return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | |
@@ -246,13 +246,13 @@ discard block |
||
| 246 | 246 | * @return array |
| 247 | 247 | */ |
| 248 | 248 | function obtenir_menus_favoris() { |
| 249 | - if ( |
|
| 250 | - isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 251 | - and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 252 | - and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 253 | - ) { |
|
| 254 | - return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 255 | - } |
|
| 256 | - $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 257 | - return $definir_menus_favoris(); |
|
| 249 | + if ( |
|
| 250 | + isset($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 251 | + and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris']) |
|
| 252 | + and $GLOBALS['visiteur_session']['prefs']['menus_favoris'] |
|
| 253 | + ) { |
|
| 254 | + return $GLOBALS['visiteur_session']['prefs']['menus_favoris']; |
|
| 255 | + } |
|
| 256 | + $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc'); |
|
| 257 | + return $definir_menus_favoris(); |
|
| 258 | 258 | } |
| 259 | 259 | \ No newline at end of file |