@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -21,65 +21,65 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // https://code.spip.net/@install_etape_fin_dist |
| 23 | 23 | function install_etape_fin_dist() { |
| 24 | - ecrire_acces(); |
|
| 24 | + ecrire_acces(); |
|
| 25 | 25 | |
| 26 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | - if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | - if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - } |
|
| 26 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 27 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 28 | + if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | + if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 30 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | - spip_log("renomme $f"); |
|
| 38 | - if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | - if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - } |
|
| 35 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 36 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 37 | + spip_log("renomme $f"); |
|
| 38 | + if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | + if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 40 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // creer le repertoire cache, qui sert partout ! |
|
| 46 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | - } |
|
| 45 | + // creer le repertoire cache, qui sert partout ! |
|
| 46 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 47 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 48 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 49 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - // Verifier la securite des htaccess |
|
| 53 | - // Si elle ne fonctionne pas, prevenir |
|
| 54 | - $msg = install_verifier_htaccess(); |
|
| 55 | - if ($msg) { |
|
| 56 | - $cible = _T('public:accueil_site'); |
|
| 57 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | - echo minipres('AUTO', $msg . $cible); |
|
| 59 | - // ok, deboucher dans l'espace prive |
|
| 60 | - } else { |
|
| 61 | - redirige_url_ecrire('accueil'); |
|
| 62 | - } |
|
| 52 | + // Verifier la securite des htaccess |
|
| 53 | + // Si elle ne fonctionne pas, prevenir |
|
| 54 | + $msg = install_verifier_htaccess(); |
|
| 55 | + if ($msg) { |
|
| 56 | + $cible = _T('public:accueil_site'); |
|
| 57 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 58 | + echo minipres('AUTO', $msg . $cible); |
|
| 59 | + // ok, deboucher dans l'espace prive |
|
| 60 | + } else { |
|
| 61 | + redirige_url_ecrire('accueil'); |
|
| 62 | + } |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | function install_verifier_htaccess() { |
| 66 | - if ( |
|
| 67 | - verifier_htaccess(_DIR_TMP, true) |
|
| 68 | - and verifier_htaccess(_DIR_CONNECT, true) |
|
| 69 | - ) { |
|
| 70 | - return ''; |
|
| 71 | - } |
|
| 66 | + if ( |
|
| 67 | + verifier_htaccess(_DIR_TMP, true) |
|
| 68 | + and verifier_htaccess(_DIR_CONNECT, true) |
|
| 69 | + ) { |
|
| 70 | + return ''; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - $titre = _T('htaccess_inoperant'); |
|
| 73 | + $titre = _T('htaccess_inoperant'); |
|
| 74 | 74 | |
| 75 | - $averti = _T( |
|
| 76 | - 'htaccess_a_simuler', |
|
| 77 | - [ |
|
| 78 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 79 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 80 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 81 | - ] |
|
| 82 | - ); |
|
| 75 | + $averti = _T( |
|
| 76 | + 'htaccess_a_simuler', |
|
| 77 | + [ |
|
| 78 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 79 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 80 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 81 | + ] |
|
| 82 | + ); |
|
| 83 | 83 | |
| 84 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 84 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 85 | 85 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/headers'); |
@@ -19,62 +19,62 @@ discard block |
||
| 19 | 19 | // https://code.spip.net/@install_etape_4_dist |
| 20 | 20 | function install_etape_4_dist() { |
| 21 | 21 | |
| 22 | - // creer le repertoire cache, qui sert partout ! |
|
| 23 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 24 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 25 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | - } |
|
| 22 | + // creer le repertoire cache, qui sert partout ! |
|
| 23 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 24 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 25 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | - echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 29 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 30 | + echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 31 | 31 | |
| 32 | - echo "<div class='success'><b>" |
|
| 33 | - . _T('info_derniere_etape') |
|
| 34 | - . '</b><p>' |
|
| 35 | - . _T('info_utilisation_spip') |
|
| 36 | - . '</p></div>'; |
|
| 32 | + echo "<div class='success'><b>" |
|
| 33 | + . _T('info_derniere_etape') |
|
| 34 | + . '</b><p>' |
|
| 35 | + . _T('info_utilisation_spip') |
|
| 36 | + . '</p></div>'; |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - echo '<p>' |
|
| 40 | - . _T( |
|
| 41 | - 'plugin_info_plugins_dist_1', |
|
| 42 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 43 | - ) |
|
| 44 | - . '</p>'; |
|
| 39 | + echo '<p>' |
|
| 40 | + . _T( |
|
| 41 | + 'plugin_info_plugins_dist_1', |
|
| 42 | + ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 43 | + ) |
|
| 44 | + . '</p>'; |
|
| 45 | 45 | |
| 46 | - // installer les extensions |
|
| 47 | - include_spip('inc/plugin'); |
|
| 48 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 49 | - echo $afficher( |
|
| 50 | - self(), |
|
| 51 | - liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 52 | - [], |
|
| 53 | - [], |
|
| 54 | - _DIR_PLUGINS_DIST, |
|
| 55 | - 'afficher_nom_plugin' |
|
| 56 | - ); |
|
| 46 | + // installer les extensions |
|
| 47 | + include_spip('inc/plugin'); |
|
| 48 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 49 | + echo $afficher( |
|
| 50 | + self(), |
|
| 51 | + liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 52 | + [], |
|
| 53 | + [], |
|
| 54 | + _DIR_PLUGINS_DIST, |
|
| 55 | + 'afficher_nom_plugin' |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | - // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 59 | - // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 60 | - // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 61 | - // et procede alors a l'installation |
|
| 62 | - if ( |
|
| 63 | - !isset($GLOBALS['meta']['version_installee']) |
|
| 64 | - or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 65 | - ) { |
|
| 66 | - plugin_installes_meta(); |
|
| 67 | - } |
|
| 58 | + // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 59 | + // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 60 | + // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 61 | + // et procede alors a l'installation |
|
| 62 | + if ( |
|
| 63 | + !isset($GLOBALS['meta']['version_installee']) |
|
| 64 | + or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 65 | + ) { |
|
| 66 | + plugin_installes_meta(); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - // mettre a jour si necessaire l'adresse du site |
|
| 70 | - // securite si on arrive plus a se loger |
|
| 71 | - include_spip('inc/config'); |
|
| 72 | - appliquer_adresse_site(''); |
|
| 69 | + // mettre a jour si necessaire l'adresse du site |
|
| 70 | + // securite si on arrive plus a se loger |
|
| 71 | + include_spip('inc/config'); |
|
| 72 | + appliquer_adresse_site(''); |
|
| 73 | 73 | |
| 74 | - // aller a la derniere etape qui clos l'install et redirige |
|
| 75 | - $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 76 | - . bouton_suivant(_T('login_espace_prive')); |
|
| 74 | + // aller a la derniere etape qui clos l'install et redirige |
|
| 75 | + $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 76 | + . bouton_suivant(_T('login_espace_prive')); |
|
| 77 | 77 | |
| 78 | - echo generer_form_ecrire('install', $suite); |
|
| 79 | - echo install_fin_html(); |
|
| 78 | + echo generer_form_ecrire('install', $suite); |
|
| 79 | + echo install_fin_html(); |
|
| 80 | 80 | } |
@@ -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 | /** |
@@ -35,18 +35,18 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | function genie_maintenance_dist($t) { |
| 37 | 37 | |
| 38 | - // (re)mettre .htaccess avec deny from all |
|
| 39 | - // dans les deux repertoires dits inaccessibles par http |
|
| 40 | - include_spip('inc/acces'); |
|
| 41 | - verifier_htaccess(_DIR_ETC); |
|
| 42 | - verifier_htaccess(_DIR_TMP); |
|
| 38 | + // (re)mettre .htaccess avec deny from all |
|
| 39 | + // dans les deux repertoires dits inaccessibles par http |
|
| 40 | + include_spip('inc/acces'); |
|
| 41 | + verifier_htaccess(_DIR_ETC); |
|
| 42 | + verifier_htaccess(_DIR_TMP); |
|
| 43 | 43 | |
| 44 | - // Verifier qu'aucune table n'est crashee |
|
| 45 | - if (!_request('reinstall')) { |
|
| 46 | - verifier_crash_tables(); |
|
| 47 | - } |
|
| 44 | + // Verifier qu'aucune table n'est crashee |
|
| 45 | + if (!_request('reinstall')) { |
|
| 46 | + verifier_crash_tables(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return 1; |
|
| 49 | + return 1; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
@@ -63,33 +63,33 @@ discard block |
||
| 63 | 63 | * des tables qui ont crashé. |
| 64 | 64 | */ |
| 65 | 65 | function verifier_crash_tables() { |
| 66 | - if (spip_connect()) { |
|
| 67 | - include_spip('base/serial'); |
|
| 68 | - include_spip('base/auxiliaires'); |
|
| 69 | - $crash = []; |
|
| 70 | - foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | - foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | - if ( |
|
| 73 | - !sql_select('*', $table, '', '', '', 1) |
|
| 74 | - and !defined('spip_interdire_cache') |
|
| 75 | - ) { # cas "LOST CONNECTION" |
|
| 76 | - $crash[] = $table; |
|
| 77 | - } |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - #$crash[] = 'test'; |
|
| 81 | - if ($crash) { |
|
| 82 | - ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | - spip_log('crash des tables', 'err'); |
|
| 84 | - spip_log($crash, 'err'); |
|
| 85 | - } else { |
|
| 86 | - effacer_meta('message_crash_tables'); |
|
| 87 | - } |
|
| 66 | + if (spip_connect()) { |
|
| 67 | + include_spip('base/serial'); |
|
| 68 | + include_spip('base/auxiliaires'); |
|
| 69 | + $crash = []; |
|
| 70 | + foreach (['tables_principales', 'tables_auxiliaires'] as $com) { |
|
| 71 | + foreach ($GLOBALS[$com] as $table => $desc) { |
|
| 72 | + if ( |
|
| 73 | + !sql_select('*', $table, '', '', '', 1) |
|
| 74 | + and !defined('spip_interdire_cache') |
|
| 75 | + ) { # cas "LOST CONNECTION" |
|
| 76 | + $crash[] = $table; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + #$crash[] = 'test'; |
|
| 81 | + if ($crash) { |
|
| 82 | + ecrire_meta('message_crash_tables', serialize($crash)); |
|
| 83 | + spip_log('crash des tables', 'err'); |
|
| 84 | + spip_log($crash, 'err'); |
|
| 85 | + } else { |
|
| 86 | + effacer_meta('message_crash_tables'); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - return $crash; |
|
| 90 | - } |
|
| 89 | + return $crash; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return false; |
|
| 92 | + return false; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | 107 | function message_crash_tables() { |
| 108 | - if ($crash = verifier_crash_tables()) { |
|
| 109 | - return |
|
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 112 | - . generer_form_ecrire( |
|
| 113 | - 'base_repair', |
|
| 114 | - _T('texte_crash_base'), |
|
| 115 | - '', |
|
| 116 | - _T('bouton_tenter_recuperation') |
|
| 117 | - ); |
|
| 118 | - } |
|
| 108 | + if ($crash = verifier_crash_tables()) { |
|
| 109 | + return |
|
| 110 | + '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | + . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 112 | + . generer_form_ecrire( |
|
| 113 | + 'base_repair', |
|
| 114 | + _T('texte_crash_base'), |
|
| 115 | + '', |
|
| 116 | + _T('bouton_tenter_recuperation') |
|
| 117 | + ); |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @package SPIP\Core\Drapeaux\Edition |
| 31 | 31 | **/ |
| 32 | 32 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 33 | - return; |
|
| 33 | + return; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
@@ -45,46 +45,46 @@ discard block |
||
| 45 | 45 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 46 | 46 | **/ |
| 47 | 47 | function lire_tableau_edition() { |
| 48 | - $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | - if (!$edition) { |
|
| 50 | - return []; |
|
| 51 | - } |
|
| 52 | - $changed = false; |
|
| 48 | + $edition = @unserialize($GLOBALS['meta']['drapeau_edition']); |
|
| 49 | + if (!$edition) { |
|
| 50 | + return []; |
|
| 51 | + } |
|
| 52 | + $changed = false; |
|
| 53 | 53 | |
| 54 | - $bon_pour_le_service = time() - 3600; |
|
| 55 | - // parcourir le tableau et virer les vieux |
|
| 56 | - foreach ($edition as $objet => $data) { |
|
| 57 | - if (!is_array($data)) { |
|
| 58 | - unset($edition[$objet]); |
|
| 59 | - } // vieille version |
|
| 60 | - else { |
|
| 61 | - foreach ($data as $id => $tab) { |
|
| 62 | - if (!is_array($tab)) { |
|
| 63 | - unset($edition[$objet][$tab]); |
|
| 64 | - } // vieille version |
|
| 65 | - else { |
|
| 66 | - foreach ($tab as $n => $duo) { |
|
| 67 | - if (current($duo) < $bon_pour_le_service) { |
|
| 68 | - unset($edition[$objet][$id][$n]); |
|
| 69 | - $changed = true; |
|
| 70 | - } |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - if (!$edition[$objet][$id]) { |
|
| 74 | - unset($edition[$objet][$id]); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - if (!$edition[$objet]) { |
|
| 79 | - unset($edition[$objet]); |
|
| 80 | - } |
|
| 81 | - } |
|
| 54 | + $bon_pour_le_service = time() - 3600; |
|
| 55 | + // parcourir le tableau et virer les vieux |
|
| 56 | + foreach ($edition as $objet => $data) { |
|
| 57 | + if (!is_array($data)) { |
|
| 58 | + unset($edition[$objet]); |
|
| 59 | + } // vieille version |
|
| 60 | + else { |
|
| 61 | + foreach ($data as $id => $tab) { |
|
| 62 | + if (!is_array($tab)) { |
|
| 63 | + unset($edition[$objet][$tab]); |
|
| 64 | + } // vieille version |
|
| 65 | + else { |
|
| 66 | + foreach ($tab as $n => $duo) { |
|
| 67 | + if (current($duo) < $bon_pour_le_service) { |
|
| 68 | + unset($edition[$objet][$id][$n]); |
|
| 69 | + $changed = true; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + if (!$edition[$objet][$id]) { |
|
| 74 | + unset($edition[$objet][$id]); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + if (!$edition[$objet]) { |
|
| 79 | + unset($edition[$objet]); |
|
| 80 | + } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if ($changed) { |
|
| 84 | - ecrire_tableau_edition($edition); |
|
| 85 | - } |
|
| 83 | + if ($changed) { |
|
| 84 | + ecrire_tableau_edition($edition); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return $edition; |
|
| 87 | + return $edition; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()` |
| 98 | 98 | **/ |
| 99 | 99 | function ecrire_tableau_edition($edition) { |
| 100 | - ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 100 | + ecrire_meta('drapeau_edition', serialize($edition)); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -117,24 +117,24 @@ discard block |
||
| 117 | 117 | * Type d'objet édité |
| 118 | 118 | */ |
| 119 | 119 | function signale_edition($id, $auteur, $type = 'article') { |
| 120 | - include_spip('base/objets'); |
|
| 121 | - include_spip('inc/filtres'); |
|
| 122 | - if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | - return; |
|
| 124 | - } |
|
| 120 | + include_spip('base/objets'); |
|
| 121 | + include_spip('inc/filtres'); |
|
| 122 | + if (objet_info($type, 'editable') !== 'oui') { |
|
| 123 | + return; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - $edition = lire_tableau_edition(); |
|
| 127 | - if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | - $nom = $auteur['nom']; |
|
| 129 | - } else { |
|
| 130 | - $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | - } |
|
| 126 | + $edition = lire_tableau_edition(); |
|
| 127 | + if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) { |
|
| 128 | + $nom = $auteur['nom']; |
|
| 129 | + } else { |
|
| 130 | + $nom = $id_a = $GLOBALS['ip']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | - $edition[$type][$id] = []; |
|
| 135 | - } |
|
| 136 | - $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | - ecrire_tableau_edition($edition); |
|
| 133 | + if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) { |
|
| 134 | + $edition[$type][$id] = []; |
|
| 135 | + } |
|
| 136 | + $edition[$type][$id][$id_a][$nom] = time(); |
|
| 137 | + ecrire_tableau_edition($edition); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | function qui_edite($id, $type = 'article') { |
| 153 | 153 | |
| 154 | - $edition = lire_tableau_edition(); |
|
| 154 | + $edition = lire_tableau_edition(); |
|
| 155 | 155 | |
| 156 | - return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 156 | + return empty($edition[$type][$id]) ? [] : $edition[$type][$id]; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -167,22 +167,22 @@ discard block |
||
| 167 | 167 | * Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]` |
| 168 | 168 | */ |
| 169 | 169 | function mention_qui_edite($id, $type = 'article') { |
| 170 | - $modif = qui_edite($id, $type); |
|
| 171 | - unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 170 | + $modif = qui_edite($id, $type); |
|
| 171 | + unset($modif[$GLOBALS['visiteur_session']['id_auteur']]); |
|
| 172 | 172 | |
| 173 | - if ($modif) { |
|
| 174 | - $quand = 0; |
|
| 175 | - foreach ($modif as $duo) { |
|
| 176 | - $auteurs[] = typo(key($duo)); |
|
| 177 | - $quand = max($quand, current($duo)); |
|
| 178 | - } |
|
| 173 | + if ($modif) { |
|
| 174 | + $quand = 0; |
|
| 175 | + foreach ($modif as $duo) { |
|
| 176 | + $auteurs[] = typo(key($duo)); |
|
| 177 | + $quand = max($quand, current($duo)); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | - return [ |
|
| 182 | - 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | - 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | - ]; |
|
| 185 | - } |
|
| 180 | + // format lie a la chaine de langue 'avis_article_modifie' |
|
| 181 | + return [ |
|
| 182 | + 'nom_auteur_modif' => join(' | ', $auteurs), |
|
| 183 | + 'date_diff' => ceil((time() - $quand) / 60) |
|
| 184 | + ]; |
|
| 185 | + } |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -196,25 +196,25 @@ discard block |
||
| 196 | 196 | * Liste de tableaux `['objet' => x, 'id_objet' => n]` |
| 197 | 197 | */ |
| 198 | 198 | function liste_drapeau_edition($id_auteur) { |
| 199 | - $edition = lire_tableau_edition(); |
|
| 200 | - $objets_ouverts = []; |
|
| 199 | + $edition = lire_tableau_edition(); |
|
| 200 | + $objets_ouverts = []; |
|
| 201 | 201 | |
| 202 | - foreach ($edition as $objet => $data) { |
|
| 203 | - foreach ($data as $id => $auteurs) { |
|
| 204 | - if ( |
|
| 205 | - isset($auteurs[$id_auteur]) |
|
| 206 | - and is_array($auteurs[$id_auteur]) // precaution |
|
| 207 | - and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 208 | - ) { |
|
| 209 | - $objets_ouverts[] = [ |
|
| 210 | - 'objet' => $objet, |
|
| 211 | - 'id_objet' => $id, |
|
| 212 | - ]; |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - } |
|
| 202 | + foreach ($edition as $objet => $data) { |
|
| 203 | + foreach ($data as $id => $auteurs) { |
|
| 204 | + if ( |
|
| 205 | + isset($auteurs[$id_auteur]) |
|
| 206 | + and is_array($auteurs[$id_auteur]) // precaution |
|
| 207 | + and (array_pop($auteurs[$id_auteur]) > time() - 3600) |
|
| 208 | + ) { |
|
| 209 | + $objets_ouverts[] = [ |
|
| 210 | + 'objet' => $objet, |
|
| 211 | + 'id_objet' => $id, |
|
| 212 | + ]; |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return $objets_ouverts; |
|
| 217 | + return $objets_ouverts; |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -227,15 +227,15 @@ discard block |
||
| 227 | 227 | * @return void |
| 228 | 228 | */ |
| 229 | 229 | function debloquer_tous($id_auteur) { |
| 230 | - $edition = lire_tableau_edition(); |
|
| 231 | - foreach ($edition as $objet => $data) { |
|
| 232 | - foreach ($data as $id => $auteurs) { |
|
| 233 | - if (isset($auteurs[$id_auteur])) { |
|
| 234 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 235 | - ecrire_tableau_edition($edition); |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - } |
|
| 230 | + $edition = lire_tableau_edition(); |
|
| 231 | + foreach ($edition as $objet => $data) { |
|
| 232 | + foreach ($data as $id => $auteurs) { |
|
| 233 | + if (isset($auteurs[$id_auteur])) { |
|
| 234 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 235 | + ecrire_tableau_edition($edition); |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | /** |
@@ -253,19 +253,19 @@ discard block |
||
| 253 | 253 | * @return void |
| 254 | 254 | */ |
| 255 | 255 | function debloquer_edition($id_auteur, $id_objet, $type = 'article') { |
| 256 | - $edition = lire_tableau_edition(); |
|
| 256 | + $edition = lire_tableau_edition(); |
|
| 257 | 257 | |
| 258 | - foreach ($edition as $objet => $data) { |
|
| 259 | - if ($objet == $type) { |
|
| 260 | - foreach ($data as $id => $auteurs) { |
|
| 261 | - if ( |
|
| 262 | - $id == $id_objet |
|
| 263 | - and isset($auteurs[$id_auteur]) |
|
| 264 | - ) { |
|
| 265 | - unset($edition[$objet][$id][$id_auteur]); |
|
| 266 | - ecrire_tableau_edition($edition); |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - } |
|
| 270 | - } |
|
| 258 | + foreach ($edition as $objet => $data) { |
|
| 259 | + if ($objet == $type) { |
|
| 260 | + foreach ($data as $id => $auteurs) { |
|
| 261 | + if ( |
|
| 262 | + $id == $id_objet |
|
| 263 | + and isset($auteurs[$id_auteur]) |
|
| 264 | + ) { |
|
| 265 | + unset($edition[$objet][$id][$id_auteur]); |
|
| 266 | + ecrire_tableau_edition($edition); |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | + } |
|
| 271 | 271 | } |
@@ -20,21 +20,21 @@ |
||
| 20 | 20 | * Retourne la liste des menus favoris par défaut ainsi que leur rang |
| 21 | 21 | */ |
| 22 | 22 | function inc_definir_menus_favoris_dist() { |
| 23 | - $liste = [ |
|
| 23 | + $liste = [ |
|
| 24 | 24 | |
| 25 | - // Menu Édition, |
|
| 26 | - 'auteurs' => 1, |
|
| 27 | - 'rubriques' => 2, |
|
| 28 | - 'articles' => 3, |
|
| 25 | + // Menu Édition, |
|
| 26 | + 'auteurs' => 1, |
|
| 27 | + 'rubriques' => 2, |
|
| 28 | + 'articles' => 3, |
|
| 29 | 29 | |
| 30 | - // Menu Maintenance |
|
| 31 | - 'admin_vider' => 1, |
|
| 30 | + // Menu Maintenance |
|
| 31 | + 'admin_vider' => 1, |
|
| 32 | 32 | |
| 33 | - // Menu Configurations |
|
| 34 | - 'configurer_identite' => 1, |
|
| 35 | - 'admin_plugin' => 2, |
|
| 33 | + // Menu Configurations |
|
| 34 | + 'configurer_identite' => 1, |
|
| 35 | + 'admin_plugin' => 2, |
|
| 36 | 36 | |
| 37 | - ]; |
|
| 37 | + ]; |
|
| 38 | 38 | |
| 39 | - return $liste; |
|
| 39 | + return $liste; |
|
| 40 | 40 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | /** |
@@ -26,41 +26,41 @@ discard block |
||
| 26 | 26 | * @return string Code HTML du cadre dépliable |
| 27 | 27 | **/ |
| 28 | 28 | function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') { |
| 29 | - $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 30 | - |
|
| 31 | - return |
|
| 32 | - debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 33 | - . debut_block_depliable($deplie, $ids) |
|
| 34 | - . "<div class='cadre_padding'>\n" |
|
| 35 | - . $contenu |
|
| 36 | - . "</div>\n" |
|
| 37 | - . fin_block() |
|
| 38 | - . fin_cadre(); |
|
| 29 | + $bouton = bouton_block_depliable($titre, $deplie, $ids); |
|
| 30 | + |
|
| 31 | + return |
|
| 32 | + debut_cadre($style_cadre, $icone, '', $bouton, '', '', false) |
|
| 33 | + . debut_block_depliable($deplie, $ids) |
|
| 34 | + . "<div class='cadre_padding'>\n" |
|
| 35 | + . $contenu |
|
| 36 | + . "</div>\n" |
|
| 37 | + . fin_block() |
|
| 38 | + . fin_cadre(); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // https://code.spip.net/@block_parfois_visible |
| 42 | 42 | function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) { |
| 43 | - return "\n" |
|
| 44 | - . bouton_block_depliable($invite, $visible, $nom) |
|
| 45 | - . debut_block_depliable($visible, $nom) |
|
| 46 | - . $masque |
|
| 47 | - . fin_block(); |
|
| 43 | + return "\n" |
|
| 44 | + . bouton_block_depliable($invite, $visible, $nom) |
|
| 45 | + . debut_block_depliable($visible, $nom) |
|
| 46 | + . $masque |
|
| 47 | + . fin_block(); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // https://code.spip.net/@debut_block_depliable |
| 51 | 51 | function debut_block_depliable($deplie, $id = '') { |
| 52 | - $class = ' blocdeplie'; |
|
| 53 | - // si on n'accepte pas js, ne pas fermer |
|
| 54 | - if (!$deplie) { |
|
| 55 | - $class = ' blocreplie'; |
|
| 56 | - } |
|
| 52 | + $class = ' blocdeplie'; |
|
| 53 | + // si on n'accepte pas js, ne pas fermer |
|
| 54 | + if (!$deplie) { |
|
| 55 | + $class = ' blocreplie'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>"; |
|
| 58 | + return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>"; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // https://code.spip.net/@fin_block |
| 62 | 62 | function fin_block() { |
| 63 | - return "<div class='nettoyeur'></div>\n</div>"; |
|
| 63 | + return "<div class='nettoyeur'></div>\n</div>"; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // $texte : texte du bouton |
@@ -68,32 +68,32 @@ discard block |
||
| 68 | 68 | // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit) |
| 69 | 69 | // https://code.spip.net/@bouton_block_depliable |
| 70 | 70 | function bouton_block_depliable($texte, $deplie, $ids = '') { |
| 71 | - $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 72 | - |
|
| 73 | - $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie'); |
|
| 74 | - if (strlen($ids)) { |
|
| 75 | - $cible = explode(',', $ids); |
|
| 76 | - $cible = '#' . implode(',#', $cible); |
|
| 77 | - } else { |
|
| 78 | - $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - $b = (strpos($texte, '<h') === false ? 'h3' : 'div'); |
|
| 82 | - |
|
| 83 | - return "<$b " |
|
| 84 | - . ($bouton_id ? "id='$bouton_id' " : '') |
|
| 85 | - . "class='titrem$class'" |
|
| 86 | - . (($deplie === -1) |
|
| 87 | - ? '' |
|
| 88 | - : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 89 | - ) |
|
| 90 | - . '>' |
|
| 91 | - // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 92 | - . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 93 | - . "$texte</$b>" |
|
| 94 | - . http_script(($deplie === 'incertain') |
|
| 95 | - ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 96 | - : ''); |
|
| 71 | + $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8); |
|
| 72 | + |
|
| 73 | + $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie'); |
|
| 74 | + if (strlen($ids)) { |
|
| 75 | + $cible = explode(',', $ids); |
|
| 76 | + $cible = '#' . implode(',#', $cible); |
|
| 77 | + } else { |
|
| 78 | + $cible = "#$bouton_id + div.bloc_depliable"; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + $b = (strpos($texte, '<h') === false ? 'h3' : 'div'); |
|
| 82 | + |
|
| 83 | + return "<$b " |
|
| 84 | + . ($bouton_id ? "id='$bouton_id' " : '') |
|
| 85 | + . "class='titrem$class'" |
|
| 86 | + . (($deplie === -1) |
|
| 87 | + ? '' |
|
| 88 | + : " onmouseover=\"jQuery(this).depliant('$cible');\"" |
|
| 89 | + ) |
|
| 90 | + . '>' |
|
| 91 | + // une ancre pour rendre accessible au clavier le depliage du sous bloc |
|
| 92 | + . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>" |
|
| 93 | + . "$texte</$b>" |
|
| 94 | + . http_script(($deplie === 'incertain') |
|
| 95 | + ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});" |
|
| 96 | + : ''); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // |
@@ -102,66 +102,66 @@ discard block |
||
| 102 | 102 | // https://code.spip.net/@verif_butineur |
| 103 | 103 | function verif_butineur() { |
| 104 | 104 | |
| 105 | - preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 106 | - $GLOBALS['browser_name'] = $match[1]; |
|
| 107 | - $GLOBALS['browser_version'] = $match[2]; |
|
| 108 | - $GLOBALS['browser_description'] = $match[3]; |
|
| 109 | - $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 110 | - $GLOBALS['browser_barre'] = ''; |
|
| 111 | - |
|
| 112 | - if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) { |
|
| 113 | - $GLOBALS['browser_name'] = 'Opera'; |
|
| 114 | - $GLOBALS['browser_version'] = $match[2]; |
|
| 115 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 116 | - } else { |
|
| 117 | - if (preg_match(',opera,i', $GLOBALS['browser_description'])) { |
|
| 118 | - preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match); |
|
| 119 | - $GLOBALS['browser_name'] = 'Opera'; |
|
| 120 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 121 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 122 | - } else { |
|
| 123 | - if (preg_match(',msie,i', $GLOBALS['browser_description'])) { |
|
| 124 | - preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match); |
|
| 125 | - $GLOBALS['browser_name'] = 'MSIE'; |
|
| 126 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 127 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5); |
|
| 128 | - } else { |
|
| 129 | - if ( |
|
| 130 | - preg_match(',KHTML,i', $GLOBALS['browser_description']) && |
|
| 131 | - preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match) |
|
| 132 | - ) { |
|
| 133 | - $GLOBALS['browser_name'] = 'Safari'; |
|
| 134 | - $GLOBALS['browser_version'] = $match[1]; |
|
| 135 | - $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0); |
|
| 136 | - } else { |
|
| 137 | - if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) { |
|
| 138 | - // Numero de version pour Mozilla "authentique" |
|
| 139 | - if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) { |
|
| 140 | - $GLOBALS['browser_rev'] = doubleval($match[1]); |
|
| 141 | - } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 142 | - else { |
|
| 143 | - if ( |
|
| 144 | - strpos($GLOBALS['browser_description'], 'Gecko') and !strpos( |
|
| 145 | - $GLOBALS['browser_description'], |
|
| 146 | - 'KHTML' |
|
| 147 | - ) |
|
| 148 | - ) { |
|
| 149 | - $GLOBALS['browser_rev'] = 1.4; |
|
| 150 | - } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 151 | - else { |
|
| 152 | - $GLOBALS['browser_rev'] = 1.0; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3; |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - if (!$GLOBALS['browser_name']) { |
|
| 163 | - $GLOBALS['browser_name'] = 'Mozilla'; |
|
| 164 | - } |
|
| 105 | + preg_match(',^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,', $_SERVER['HTTP_USER_AGENT'], $match); |
|
| 106 | + $GLOBALS['browser_name'] = $match[1]; |
|
| 107 | + $GLOBALS['browser_version'] = $match[2]; |
|
| 108 | + $GLOBALS['browser_description'] = $match[3]; |
|
| 109 | + $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur |
|
| 110 | + $GLOBALS['browser_barre'] = ''; |
|
| 111 | + |
|
| 112 | + if (!preg_match(',opera,i', $GLOBALS['browser_description']) && preg_match(',opera,i', $GLOBALS['browser_name'])) { |
|
| 113 | + $GLOBALS['browser_name'] = 'Opera'; |
|
| 114 | + $GLOBALS['browser_version'] = $match[2]; |
|
| 115 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 116 | + } else { |
|
| 117 | + if (preg_match(',opera,i', $GLOBALS['browser_description'])) { |
|
| 118 | + preg_match(',Opera ([^\ ]*),i', $GLOBALS['browser_description'], $match); |
|
| 119 | + $GLOBALS['browser_name'] = 'Opera'; |
|
| 120 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 121 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5); |
|
| 122 | + } else { |
|
| 123 | + if (preg_match(',msie,i', $GLOBALS['browser_description'])) { |
|
| 124 | + preg_match(',MSIE ([^;]*),i', $GLOBALS['browser_description'], $match); |
|
| 125 | + $GLOBALS['browser_name'] = 'MSIE'; |
|
| 126 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 127 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5); |
|
| 128 | + } else { |
|
| 129 | + if ( |
|
| 130 | + preg_match(',KHTML,i', $GLOBALS['browser_description']) && |
|
| 131 | + preg_match(',Safari/([^;]*),', $GLOBALS['browser_description'], $match) |
|
| 132 | + ) { |
|
| 133 | + $GLOBALS['browser_name'] = 'Safari'; |
|
| 134 | + $GLOBALS['browser_version'] = $match[1]; |
|
| 135 | + $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0); |
|
| 136 | + } else { |
|
| 137 | + if (preg_match(',mozilla,i', $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) { |
|
| 138 | + // Numero de version pour Mozilla "authentique" |
|
| 139 | + if (preg_match(',rv:([0-9]+\.[0-9]+),', $GLOBALS['browser_description'], $match)) { |
|
| 140 | + $GLOBALS['browser_rev'] = doubleval($match[1]); |
|
| 141 | + } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.) |
|
| 142 | + else { |
|
| 143 | + if ( |
|
| 144 | + strpos($GLOBALS['browser_description'], 'Gecko') and !strpos( |
|
| 145 | + $GLOBALS['browser_description'], |
|
| 146 | + 'KHTML' |
|
| 147 | + ) |
|
| 148 | + ) { |
|
| 149 | + $GLOBALS['browser_rev'] = 1.4; |
|
| 150 | + } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.) |
|
| 151 | + else { |
|
| 152 | + $GLOBALS['browser_rev'] = 1.0; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3; |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + if (!$GLOBALS['browser_name']) { |
|
| 163 | + $GLOBALS['browser_name'] = 'Mozilla'; |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | verif_butineur(); |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Pipelines |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | if (test_espace_prive()) { |
| 22 | - include_spip('inc/pipelines_ecrire'); |
|
| 22 | + include_spip('inc/pipelines_ecrire'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -45,29 +45,29 @@ discard block |
||
| 45 | 45 | * @return string Contenu qui sera inséré dans le head HTML |
| 46 | 46 | **/ |
| 47 | 47 | function f_jQuery($texte) { |
| 48 | - $x = ''; |
|
| 49 | - $jquery_plugins = pipeline( |
|
| 50 | - 'jquery_plugins', |
|
| 51 | - [ |
|
| 52 | - 'javascript/jquery.js', |
|
| 53 | - 'javascript/jquery.form.js', |
|
| 54 | - 'javascript/jquery.autosave.js', |
|
| 55 | - 'javascript/jquery.placeholder-label.js', |
|
| 56 | - 'javascript/ajaxCallback.js', |
|
| 57 | - 'javascript/js.cookie.js', |
|
| 58 | - 'javascript/jquery.cookie.js' |
|
| 59 | - ] |
|
| 60 | - ); |
|
| 61 | - foreach (array_unique($jquery_plugins) as $script) { |
|
| 62 | - if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 63 | - $script = timestamp($script); |
|
| 64 | - $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 65 | - } |
|
| 66 | - } |
|
| 48 | + $x = ''; |
|
| 49 | + $jquery_plugins = pipeline( |
|
| 50 | + 'jquery_plugins', |
|
| 51 | + [ |
|
| 52 | + 'javascript/jquery.js', |
|
| 53 | + 'javascript/jquery.form.js', |
|
| 54 | + 'javascript/jquery.autosave.js', |
|
| 55 | + 'javascript/jquery.placeholder-label.js', |
|
| 56 | + 'javascript/ajaxCallback.js', |
|
| 57 | + 'javascript/js.cookie.js', |
|
| 58 | + 'javascript/jquery.cookie.js' |
|
| 59 | + ] |
|
| 60 | + ); |
|
| 61 | + foreach (array_unique($jquery_plugins) as $script) { |
|
| 62 | + if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 63 | + $script = timestamp($script); |
|
| 64 | + $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $texte = $x . $texte; |
|
| 68 | + $texte = $x . $texte; |
|
| 69 | 69 | |
| 70 | - return $texte; |
|
| 70 | + return $texte; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | |
@@ -86,28 +86,28 @@ discard block |
||
| 86 | 86 | * @return string Contenu de la page envoyée au navigateur |
| 87 | 87 | **/ |
| 88 | 88 | function f_surligne($texte) { |
| 89 | - if (!$GLOBALS['html']) { |
|
| 90 | - return $texte; |
|
| 91 | - } |
|
| 92 | - $rech = _request('var_recherche'); |
|
| 93 | - if ( |
|
| 94 | - !$rech |
|
| 95 | - and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 96 | - or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 97 | - or !isset($_SERVER['HTTP_REFERER'])) |
|
| 98 | - ) { |
|
| 99 | - return $texte; |
|
| 100 | - } |
|
| 101 | - include_spip('inc/surligne'); |
|
| 89 | + if (!$GLOBALS['html']) { |
|
| 90 | + return $texte; |
|
| 91 | + } |
|
| 92 | + $rech = _request('var_recherche'); |
|
| 93 | + if ( |
|
| 94 | + !$rech |
|
| 95 | + and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 96 | + or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 97 | + or !isset($_SERVER['HTTP_REFERER'])) |
|
| 98 | + ) { |
|
| 99 | + return $texte; |
|
| 100 | + } |
|
| 101 | + include_spip('inc/surligne'); |
|
| 102 | 102 | |
| 103 | - if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 104 | - $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 105 | - } |
|
| 106 | - if ($rech) { |
|
| 107 | - $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 108 | - } |
|
| 103 | + if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 104 | + $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 105 | + } |
|
| 106 | + if ($rech) { |
|
| 107 | + $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - return surligner_mots($texte, $rech); |
|
| 110 | + return surligner_mots($texte, $rech); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -124,33 +124,33 @@ discard block |
||
| 124 | 124 | * @return string Contenu de la page envoyée au navigateur |
| 125 | 125 | **/ |
| 126 | 126 | function f_tidy($texte) { |
| 127 | - /** |
|
| 128 | - * Indentation à faire ? |
|
| 129 | - * |
|
| 130 | - * - true : actif. |
|
| 131 | - * - false par défaut. |
|
| 132 | - */ |
|
| 127 | + /** |
|
| 128 | + * Indentation à faire ? |
|
| 129 | + * |
|
| 130 | + * - true : actif. |
|
| 131 | + * - false par défaut. |
|
| 132 | + */ |
|
| 133 | 133 | |
| 134 | - if ( |
|
| 135 | - $GLOBALS['xhtml'] # tidy demande |
|
| 136 | - and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 137 | - and strlen($texte) |
|
| 138 | - and !headers_sent() |
|
| 139 | - ) { |
|
| 140 | - # Compatibilite ascendante |
|
| 141 | - if (!is_string($GLOBALS['xhtml'])) { |
|
| 142 | - $GLOBALS['xhtml'] = 'tidy'; |
|
| 143 | - } |
|
| 134 | + if ( |
|
| 135 | + $GLOBALS['xhtml'] # tidy demande |
|
| 136 | + and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 137 | + and strlen($texte) |
|
| 138 | + and !headers_sent() |
|
| 139 | + ) { |
|
| 140 | + # Compatibilite ascendante |
|
| 141 | + if (!is_string($GLOBALS['xhtml'])) { |
|
| 142 | + $GLOBALS['xhtml'] = 'tidy'; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 146 | - spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 147 | - $f = charger_fonction('sax', 'xml'); |
|
| 148 | - } |
|
| 145 | + if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 146 | + spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 147 | + $f = charger_fonction('sax', 'xml'); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - return $f($texte); |
|
| 151 | - } |
|
| 150 | + return $f($texte); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - return $texte; |
|
| 153 | + return $texte; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -169,21 +169,21 @@ discard block |
||
| 169 | 169 | * @return string Contenu de la page envoyée au navigateur |
| 170 | 170 | **/ |
| 171 | 171 | function f_insert_head($texte) { |
| 172 | - if (!$GLOBALS['html']) { |
|
| 173 | - return $texte; |
|
| 174 | - } |
|
| 175 | - include_spip('public/admin'); // pour strripos |
|
| 172 | + if (!$GLOBALS['html']) { |
|
| 173 | + return $texte; |
|
| 174 | + } |
|
| 175 | + include_spip('public/admin'); // pour strripos |
|
| 176 | 176 | |
| 177 | - ($pos = stripos($texte, '</head>')) |
|
| 178 | - || ($pos = stripos($texte, '<body>')) |
|
| 179 | - || ($pos = 0); |
|
| 177 | + ($pos = stripos($texte, '</head>')) |
|
| 178 | + || ($pos = stripos($texte, '<body>')) |
|
| 179 | + || ($pos = 0); |
|
| 180 | 180 | |
| 181 | - if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 182 | - $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 183 | - $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 184 | - } |
|
| 181 | + if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 182 | + $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 183 | + $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - return $texte; |
|
| 186 | + return $texte; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | |
@@ -199,34 +199,34 @@ discard block |
||
| 199 | 199 | * @return string Contenu de la page envoyée au navigateur |
| 200 | 200 | **/ |
| 201 | 201 | function f_admin($texte) { |
| 202 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 203 | - include_spip('inc/filtres'); // pour http_img_pack |
|
| 204 | - $x = "<div class='spip-previsu' " |
|
| 205 | - . http_style_background('preview-32.png', '', 32) |
|
| 206 | - . '>' |
|
| 207 | - . _T('previsualisation') |
|
| 208 | - . '</div>'; |
|
| 209 | - if (!$pos = stripos($texte, '</body>')) { |
|
| 210 | - $pos = strlen($texte); |
|
| 211 | - } |
|
| 212 | - $texte = substr_replace($texte, $x, $pos, 0); |
|
| 213 | - // pas de preview en fenetre enfant |
|
| 214 | - $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>"; |
|
| 215 | - if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 216 | - $pos = -1; |
|
| 217 | - } |
|
| 218 | - $texte = substr_replace($texte, $x, $pos + 1, 0); |
|
| 219 | - } |
|
| 202 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 203 | + include_spip('inc/filtres'); // pour http_img_pack |
|
| 204 | + $x = "<div class='spip-previsu' " |
|
| 205 | + . http_style_background('preview-32.png', '', 32) |
|
| 206 | + . '>' |
|
| 207 | + . _T('previsualisation') |
|
| 208 | + . '</div>'; |
|
| 209 | + if (!$pos = stripos($texte, '</body>')) { |
|
| 210 | + $pos = strlen($texte); |
|
| 211 | + } |
|
| 212 | + $texte = substr_replace($texte, $x, $pos, 0); |
|
| 213 | + // pas de preview en fenetre enfant |
|
| 214 | + $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>"; |
|
| 215 | + if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 216 | + $pos = -1; |
|
| 217 | + } |
|
| 218 | + $texte = substr_replace($texte, $x, $pos + 1, 0); |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 222 | - include_spip('public/admin'); |
|
| 223 | - $texte = affiche_boutons_admin($texte); |
|
| 224 | - } |
|
| 225 | - if (_request('var_mode') == 'noajax') { |
|
| 226 | - $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 227 | - } |
|
| 221 | + if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 222 | + include_spip('public/admin'); |
|
| 223 | + $texte = affiche_boutons_admin($texte); |
|
| 224 | + } |
|
| 225 | + if (_request('var_mode') == 'noajax') { |
|
| 226 | + $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - return $texte; |
|
| 229 | + return $texte; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -244,11 +244,11 @@ discard block |
||
| 244 | 244 | * @return array $flux Description et contenu de l'inclusion |
| 245 | 245 | **/ |
| 246 | 246 | function f_recuperer_fond($flux) { |
| 247 | - if (!test_espace_prive()) { |
|
| 248 | - return $flux; |
|
| 249 | - } |
|
| 247 | + if (!test_espace_prive()) { |
|
| 248 | + return $flux; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - return f_afficher_blocs_ecrire($flux); |
|
| 251 | + return f_afficher_blocs_ecrire($flux); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -262,30 +262,30 @@ discard block |
||
| 262 | 262 | * @return string Contenu de la page envoyée au navigateur |
| 263 | 263 | */ |
| 264 | 264 | function f_queue($texte) { |
| 265 | - // eviter une inclusion si rien a faire |
|
| 266 | - if ( |
|
| 267 | - _request('action') == 'cron' |
|
| 268 | - or queue_sleep_time_to_next_job() > 0 |
|
| 269 | - or defined('_DEBUG_BLOCK_QUEUE') |
|
| 270 | - ) { |
|
| 271 | - return $texte; |
|
| 272 | - } |
|
| 265 | + // eviter une inclusion si rien a faire |
|
| 266 | + if ( |
|
| 267 | + _request('action') == 'cron' |
|
| 268 | + or queue_sleep_time_to_next_job() > 0 |
|
| 269 | + or defined('_DEBUG_BLOCK_QUEUE') |
|
| 270 | + ) { |
|
| 271 | + return $texte; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - include_spip('inc/queue'); |
|
| 275 | - $code = queue_affichage_cron(); |
|
| 274 | + include_spip('inc/queue'); |
|
| 275 | + $code = queue_affichage_cron(); |
|
| 276 | 276 | |
| 277 | - // si rien a afficher |
|
| 278 | - // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 279 | - if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 280 | - return $texte; |
|
| 281 | - } |
|
| 277 | + // si rien a afficher |
|
| 278 | + // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 279 | + if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 280 | + return $texte; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 284 | - if (($p = strpos($texte, '</body>')) !== false) { |
|
| 285 | - $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 286 | - } else { |
|
| 287 | - $texte .= $code; |
|
| 288 | - } |
|
| 283 | + // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 284 | + if (($p = strpos($texte, '</body>')) !== false) { |
|
| 285 | + $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 286 | + } else { |
|
| 287 | + $texte .= $code; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - return $texte; |
|
| 290 | + return $texte; |
|
| 291 | 291 | } |
@@ -11,71 +11,71 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/boutons'); |
| 18 | 18 | include_spip('base/objets'); |
| 19 | 19 | |
| 20 | 20 | function inc_icone_renommer_dist($fond, $fonction) { |
| 21 | - $size = 24; |
|
| 22 | - if ( |
|
| 23 | - preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match) |
|
| 24 | - and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1])) |
|
| 25 | - ) { |
|
| 26 | - if (isset($match[1]) and $match[1]) { |
|
| 27 | - $size = $match[1]; |
|
| 28 | - } |
|
| 29 | - $type = substr($fond, 0, -strlen($match[0])); |
|
| 30 | - if (!isset($match[2]) or !$match[2]) { |
|
| 31 | - $fond .= '.png'; |
|
| 32 | - } |
|
| 33 | - } else { |
|
| 34 | - $type = $fond; |
|
| 35 | - $fond .= '.png'; |
|
| 36 | - } |
|
| 21 | + $size = 24; |
|
| 22 | + if ( |
|
| 23 | + preg_match('/(?:-([0-9]{1,3}))?([.](gif|png|svg))?$/i', $fond, $match) |
|
| 24 | + and ((isset($match[0]) and $match[0]) or (isset($match[1]) and $match[1])) |
|
| 25 | + ) { |
|
| 26 | + if (isset($match[1]) and $match[1]) { |
|
| 27 | + $size = $match[1]; |
|
| 28 | + } |
|
| 29 | + $type = substr($fond, 0, -strlen($match[0])); |
|
| 30 | + if (!isset($match[2]) or !$match[2]) { |
|
| 31 | + $fond .= '.png'; |
|
| 32 | + } |
|
| 33 | + } else { |
|
| 34 | + $type = $fond; |
|
| 35 | + $fond .= '.png'; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $rtl = false; |
|
| 39 | - if (preg_match(',[-_]rtl$,i', $type, $match)) { |
|
| 40 | - $rtl = true; |
|
| 41 | - $type = substr($type, 0, -strlen($match[0])); |
|
| 42 | - } |
|
| 38 | + $rtl = false; |
|
| 39 | + if (preg_match(',[-_]rtl$,i', $type, $match)) { |
|
| 40 | + $rtl = true; |
|
| 41 | + $type = substr($type, 0, -strlen($match[0])); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - // objet_type garde invariant tout ce qui ne commence par par id_, spip_ |
|
| 45 | - // et ne finit pas par un s, sauf si c'est une exception declaree |
|
| 46 | - $type = objet_type($type, false); |
|
| 44 | + // objet_type garde invariant tout ce qui ne commence par par id_, spip_ |
|
| 45 | + // et ne finit pas par un s, sauf si c'est une exception declaree |
|
| 46 | + $type = objet_type($type, false); |
|
| 47 | 47 | |
| 48 | - $dir = 'images/'; |
|
| 49 | - $f = "$type-$size.png"; |
|
| 50 | - if ($icone = find_in_theme($dir . $f)) { |
|
| 51 | - $dir = dirname($icone); |
|
| 52 | - $fond = $icone; |
|
| 48 | + $dir = 'images/'; |
|
| 49 | + $f = "$type-$size.png"; |
|
| 50 | + if ($icone = find_in_theme($dir . $f)) { |
|
| 51 | + $dir = dirname($icone); |
|
| 52 | + $fond = $icone; |
|
| 53 | 53 | |
| 54 | - if ( |
|
| 55 | - $rtl |
|
| 56 | - and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)) |
|
| 57 | - and file_exists($fr) |
|
| 58 | - ) { |
|
| 59 | - $fond = $fr; |
|
| 60 | - } |
|
| 54 | + if ( |
|
| 55 | + $rtl |
|
| 56 | + and $fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename($icone)) |
|
| 57 | + and file_exists($fr) |
|
| 58 | + ) { |
|
| 59 | + $fond = $fr; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $action = $fonction; |
|
| 63 | - if ($action == 'supprimer.gif') { |
|
| 64 | - $action = 'del'; |
|
| 65 | - } elseif ($action == 'creer.gif') { |
|
| 66 | - $action = 'new'; |
|
| 67 | - } elseif ($action == 'edit.gif') { |
|
| 68 | - $action = 'edit'; |
|
| 69 | - } |
|
| 62 | + $action = $fonction; |
|
| 63 | + if ($action == 'supprimer.gif') { |
|
| 64 | + $action = 'del'; |
|
| 65 | + } elseif ($action == 'creer.gif') { |
|
| 66 | + $action = 'new'; |
|
| 67 | + } elseif ($action == 'edit.gif') { |
|
| 68 | + $action = 'edit'; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - $fonction = ''; |
|
| 72 | - if (in_array($action, ['add','del', 'new', 'edit', 'config'])) { |
|
| 73 | - $fonction = $action; |
|
| 74 | - } |
|
| 71 | + $fonction = ''; |
|
| 72 | + if (in_array($action, ['add','del', 'new', 'edit', 'config'])) { |
|
| 73 | + $fonction = $action; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - // c'est bon ! |
|
| 77 | - return [$fond, $fonction]; |
|
| 78 | - } |
|
| 76 | + // c'est bon ! |
|
| 77 | + return [$fond, $fonction]; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - return [$fond, $fonction]; |
|
| 80 | + return [$fond, $fonction]; |
|
| 81 | 81 | } |
@@ -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/charsets'); |
@@ -32,13 +32,13 @@ discard block |
||
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | 34 | function exporter_csv_champ($champ) { |
| 35 | - #$champ = str_replace("\r", "\n", $champ); |
|
| 36 | - #$champ = preg_replace(",[\n]+,ms", "\n", $champ); |
|
| 37 | - #$champ = str_replace("\n", ", ", $champ); |
|
| 38 | - $champ = preg_replace(',[\s]+,ms', ' ', $champ); |
|
| 39 | - $champ = str_replace('"', '""', $champ); |
|
| 35 | + #$champ = str_replace("\r", "\n", $champ); |
|
| 36 | + #$champ = preg_replace(",[\n]+,ms", "\n", $champ); |
|
| 37 | + #$champ = str_replace("\n", ", ", $champ); |
|
| 38 | + $champ = preg_replace(',[\s]+,ms', ' ', $champ); |
|
| 39 | + $champ = str_replace('"', '""', $champ); |
|
| 40 | 40 | |
| 41 | - return '"' . $champ . '"'; |
|
| 41 | + return '"' . $champ . '"'; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | * @return string |
| 56 | 56 | */ |
| 57 | 57 | function exporter_csv_ligne_numerotee($nb, $ligne, $delim = ',', $importer_charset = null, $callback = null) { |
| 58 | - if ($callback) { |
|
| 59 | - $ligne = call_user_func($callback, $nb, $ligne, $delim, $importer_charset); |
|
| 60 | - } |
|
| 61 | - $output = join($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n"; |
|
| 62 | - if ($importer_charset) { |
|
| 63 | - $output = str_replace('’', '\'', $output); |
|
| 64 | - $output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset); |
|
| 65 | - } |
|
| 66 | - return $output; |
|
| 58 | + if ($callback) { |
|
| 59 | + $ligne = call_user_func($callback, $nb, $ligne, $delim, $importer_charset); |
|
| 60 | + } |
|
| 61 | + $output = join($delim, array_map('exporter_csv_champ', $ligne)) . "\r\n"; |
|
| 62 | + if ($importer_charset) { |
|
| 63 | + $output = str_replace('’', '\'', $output); |
|
| 64 | + $output = unicode2charset(html2unicode(charset2unicode($output)), $importer_charset); |
|
| 65 | + } |
|
| 66 | + return $output; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | 77 | function exporter_csv_ligne($ligne, $delim = ',', $importer_charset = null) { |
| 78 | - return exporter_csv_ligne_numerotee(null, $ligne, $delim, $importer_charset); |
|
| 78 | + return exporter_csv_ligne_numerotee(null, $ligne, $delim, $importer_charset); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
@@ -101,101 +101,101 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | function inc_exporter_csv_dist($titre, $resource, $options = []) { |
| 103 | 103 | |
| 104 | - // support ancienne syntaxe |
|
| 105 | - // inc_exporter_csv_dist($titre, $resource, $delim = ', ', $entetes = null, $envoyer = true) |
|
| 106 | - if (is_string($options)) { |
|
| 107 | - $args = func_get_args(); |
|
| 108 | - $options = []; |
|
| 109 | - foreach ([2 => 'delim', 3 => 'entetes', 4 => 'envoyer'] as $k => $option) { |
|
| 110 | - if (!empty($args[$k])) { |
|
| 111 | - $options[$option] = $args[$k]; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - $default_options = [ |
|
| 117 | - 'delim' => ', ', |
|
| 118 | - 'entetes' => null, |
|
| 119 | - 'envoyer' => true, |
|
| 120 | - 'charset' => null, |
|
| 121 | - 'callback' => null, |
|
| 122 | - ]; |
|
| 123 | - $options = array_merge($default_options, $options); |
|
| 124 | - |
|
| 125 | - $filename = preg_replace(',[^-_\w]+,', '_', translitteration(textebrut(typo($titre)))); |
|
| 126 | - |
|
| 127 | - if ($options['delim'] == 'TAB') { |
|
| 128 | - $options['delim'] = "\t"; |
|
| 129 | - } |
|
| 130 | - if (!in_array($options['delim'], [',', ';', "\t"])) { |
|
| 131 | - $options['delim'] = ','; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $charset = $GLOBALS['meta']['charset']; |
|
| 135 | - $importer_charset = null; |
|
| 136 | - if ($options['delim'] == ',') { |
|
| 137 | - $extension = 'csv'; |
|
| 138 | - } else { |
|
| 139 | - $extension = 'xls'; |
|
| 140 | - # Excel n'accepte pas l'utf-8 ni les entites html... on transcode tout ce qu'on peut |
|
| 141 | - $charset = 'iso-8859-1'; |
|
| 142 | - } |
|
| 143 | - // mais si une option charset est explicite, elle a la priorite |
|
| 144 | - if (!empty($options['charset'])) { |
|
| 145 | - $charset = $options['charset']; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - $importer_charset = (($charset === $GLOBALS['meta']['charset']) ? null : $charset); |
|
| 149 | - |
|
| 150 | - $filename = "$filename.$extension"; |
|
| 151 | - |
|
| 152 | - $output = ''; |
|
| 153 | - $nb = 0; |
|
| 154 | - if (!empty($options['entetes']) and is_array($options['entetes'])) { |
|
| 155 | - $output = exporter_csv_ligne_numerotee($nb, $options['entetes'], $options['delim'], $importer_charset, $options['callback']); |
|
| 156 | - } |
|
| 157 | - // les donnees commencent toujours a la ligne 1, qu'il y ait ou non des entetes |
|
| 158 | - $nb++; |
|
| 159 | - |
|
| 160 | - if ($options['envoyer']) { |
|
| 161 | - $disposition = ($options['envoyer'] === 'attachment' ? 'attachment' : 'inline'); |
|
| 162 | - header("Content-Type: text/comma-separated-values; charset=$charset"); |
|
| 163 | - header("Content-Disposition: $disposition; filename=$filename"); |
|
| 164 | - |
|
| 165 | - // Vider tous les tampons |
|
| 166 | - $level = @ob_get_level(); |
|
| 167 | - while ($level--) { |
|
| 168 | - @ob_end_flush(); |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - // si envoyer=='attachment' on passe par un fichier temporaire |
|
| 173 | - // sinon on ecrit directement sur stdout |
|
| 174 | - if ($options['envoyer'] and $options['envoyer'] !== 'attachment') { |
|
| 175 | - $fichier = 'php://output'; |
|
| 176 | - } |
|
| 177 | - else { |
|
| 178 | - $fichier = sous_repertoire(_DIR_CACHE, 'export') . $filename; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - $fp = fopen($fichier, 'w'); |
|
| 182 | - $length = fwrite($fp, $output); |
|
| 183 | - |
|
| 184 | - while ($row = is_array($resource) ? array_shift($resource) : sql_fetch($resource)) { |
|
| 185 | - $output = exporter_csv_ligne_numerotee($nb, $row, $options['delim'], $importer_charset, $options['callback']); |
|
| 186 | - $length += fwrite($fp, $output); |
|
| 187 | - $nb++; |
|
| 188 | - } |
|
| 189 | - fclose($fp); |
|
| 190 | - |
|
| 191 | - if ($options['envoyer']) { |
|
| 192 | - if ($options['envoyer'] === 'attachment') { |
|
| 193 | - header("Content-Length: $length"); |
|
| 194 | - readfile($fichier); |
|
| 195 | - } |
|
| 196 | - // si on a envoye inline, c'est deja tout bon |
|
| 197 | - exit; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - return $fichier; |
|
| 104 | + // support ancienne syntaxe |
|
| 105 | + // inc_exporter_csv_dist($titre, $resource, $delim = ', ', $entetes = null, $envoyer = true) |
|
| 106 | + if (is_string($options)) { |
|
| 107 | + $args = func_get_args(); |
|
| 108 | + $options = []; |
|
| 109 | + foreach ([2 => 'delim', 3 => 'entetes', 4 => 'envoyer'] as $k => $option) { |
|
| 110 | + if (!empty($args[$k])) { |
|
| 111 | + $options[$option] = $args[$k]; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + $default_options = [ |
|
| 117 | + 'delim' => ', ', |
|
| 118 | + 'entetes' => null, |
|
| 119 | + 'envoyer' => true, |
|
| 120 | + 'charset' => null, |
|
| 121 | + 'callback' => null, |
|
| 122 | + ]; |
|
| 123 | + $options = array_merge($default_options, $options); |
|
| 124 | + |
|
| 125 | + $filename = preg_replace(',[^-_\w]+,', '_', translitteration(textebrut(typo($titre)))); |
|
| 126 | + |
|
| 127 | + if ($options['delim'] == 'TAB') { |
|
| 128 | + $options['delim'] = "\t"; |
|
| 129 | + } |
|
| 130 | + if (!in_array($options['delim'], [',', ';', "\t"])) { |
|
| 131 | + $options['delim'] = ','; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $charset = $GLOBALS['meta']['charset']; |
|
| 135 | + $importer_charset = null; |
|
| 136 | + if ($options['delim'] == ',') { |
|
| 137 | + $extension = 'csv'; |
|
| 138 | + } else { |
|
| 139 | + $extension = 'xls'; |
|
| 140 | + # Excel n'accepte pas l'utf-8 ni les entites html... on transcode tout ce qu'on peut |
|
| 141 | + $charset = 'iso-8859-1'; |
|
| 142 | + } |
|
| 143 | + // mais si une option charset est explicite, elle a la priorite |
|
| 144 | + if (!empty($options['charset'])) { |
|
| 145 | + $charset = $options['charset']; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + $importer_charset = (($charset === $GLOBALS['meta']['charset']) ? null : $charset); |
|
| 149 | + |
|
| 150 | + $filename = "$filename.$extension"; |
|
| 151 | + |
|
| 152 | + $output = ''; |
|
| 153 | + $nb = 0; |
|
| 154 | + if (!empty($options['entetes']) and is_array($options['entetes'])) { |
|
| 155 | + $output = exporter_csv_ligne_numerotee($nb, $options['entetes'], $options['delim'], $importer_charset, $options['callback']); |
|
| 156 | + } |
|
| 157 | + // les donnees commencent toujours a la ligne 1, qu'il y ait ou non des entetes |
|
| 158 | + $nb++; |
|
| 159 | + |
|
| 160 | + if ($options['envoyer']) { |
|
| 161 | + $disposition = ($options['envoyer'] === 'attachment' ? 'attachment' : 'inline'); |
|
| 162 | + header("Content-Type: text/comma-separated-values; charset=$charset"); |
|
| 163 | + header("Content-Disposition: $disposition; filename=$filename"); |
|
| 164 | + |
|
| 165 | + // Vider tous les tampons |
|
| 166 | + $level = @ob_get_level(); |
|
| 167 | + while ($level--) { |
|
| 168 | + @ob_end_flush(); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + // si envoyer=='attachment' on passe par un fichier temporaire |
|
| 173 | + // sinon on ecrit directement sur stdout |
|
| 174 | + if ($options['envoyer'] and $options['envoyer'] !== 'attachment') { |
|
| 175 | + $fichier = 'php://output'; |
|
| 176 | + } |
|
| 177 | + else { |
|
| 178 | + $fichier = sous_repertoire(_DIR_CACHE, 'export') . $filename; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + $fp = fopen($fichier, 'w'); |
|
| 182 | + $length = fwrite($fp, $output); |
|
| 183 | + |
|
| 184 | + while ($row = is_array($resource) ? array_shift($resource) : sql_fetch($resource)) { |
|
| 185 | + $output = exporter_csv_ligne_numerotee($nb, $row, $options['delim'], $importer_charset, $options['callback']); |
|
| 186 | + $length += fwrite($fp, $output); |
|
| 187 | + $nb++; |
|
| 188 | + } |
|
| 189 | + fclose($fp); |
|
| 190 | + |
|
| 191 | + if ($options['envoyer']) { |
|
| 192 | + if ($options['envoyer'] === 'attachment') { |
|
| 193 | + header("Content-Length: $length"); |
|
| 194 | + readfile($fichier); |
|
| 195 | + } |
|
| 196 | + // si on a envoye inline, c'est deja tout bon |
|
| 197 | + exit; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + return $fichier; |
|
| 201 | 201 | } |