@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | // creer le repertoire cache, qui sert partout ! |
| 46 | 46 | // deja fait en etape 4 en principe, on garde au cas ou |
| 47 | 47 | if (!@file_exists(_DIR_CACHE)) { |
| 48 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 48 | + $rep = preg_replace(','._DIR_TMP.',', '', _DIR_CACHE); |
|
| 49 | 49 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | if ($msg) { |
| 56 | 56 | $cible = _T('public:accueil_site'); |
| 57 | 57 | $cible = generer_form_ecrire('accueil', '', '', $cible); |
| 58 | - echo minipres('AUTO', $msg . $cible); |
|
| 58 | + echo minipres('AUTO', $msg.$cible); |
|
| 59 | 59 | // ok, deboucher dans l'espace prive |
| 60 | 60 | } else { |
| 61 | 61 | redirige_url_ecrire('accueil'); |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | $averti = _T( |
| 76 | 76 | 'htaccess_a_simuler', |
| 77 | 77 | [ |
| 78 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 78 | + 'htaccess' => '<tt>'._ACCESS_FILE_NAME.'</tt>', |
|
| 79 | 79 | 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
| 80 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 80 | + 'document_root' => '<tt>'.$_SERVER['DOCUMENT_ROOT'].'</tt>' |
|
| 81 | 81 | ] |
| 82 | 82 | ); |
| 83 | 83 | |
@@ -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'); |
@@ -20,65 +20,65 @@ discard block |
||
| 20 | 20 | // Mise en place des fichiers de configuration si ce n'est fait |
| 21 | 21 | |
| 22 | 22 | function install_etape_fin_dist() { |
| 23 | - ecrire_acces(); |
|
| 23 | + ecrire_acces(); |
|
| 24 | 24 | |
| 25 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 26 | - if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 27 | - if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | - if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 30 | - } |
|
| 31 | - } |
|
| 32 | - } |
|
| 25 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CHMOD_TMP); |
|
| 26 | + if (file_exists(_FILE_CHMOD_TMP)) { |
|
| 27 | + if (!@rename(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | + if (@copy(_FILE_CHMOD_TMP, $f)) { |
|
| 29 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 35 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 36 | - spip_log("renomme $f"); |
|
| 37 | - if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 38 | - if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - } |
|
| 34 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', _FILE_CONNECT_TMP); |
|
| 35 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 36 | + spip_log("renomme $f"); |
|
| 37 | + if (!@rename(_FILE_CONNECT_TMP, $f)) { |
|
| 38 | + if (@copy(_FILE_CONNECT_TMP, $f)) { |
|
| 39 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - // creer le repertoire cache, qui sert partout ! |
|
| 45 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 46 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 47 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 48 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 49 | - } |
|
| 44 | + // creer le repertoire cache, qui sert partout ! |
|
| 45 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 46 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 47 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 48 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - // Verifier la securite des htaccess |
|
| 52 | - // Si elle ne fonctionne pas, prevenir |
|
| 53 | - $msg = install_verifier_htaccess(); |
|
| 54 | - if ($msg) { |
|
| 55 | - $cible = _T('public:accueil_site'); |
|
| 56 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 57 | - echo minipres('AUTO', $msg . $cible); |
|
| 58 | - // ok, deboucher dans l'espace prive |
|
| 59 | - } else { |
|
| 60 | - redirige_url_ecrire('accueil'); |
|
| 61 | - } |
|
| 51 | + // Verifier la securite des htaccess |
|
| 52 | + // Si elle ne fonctionne pas, prevenir |
|
| 53 | + $msg = install_verifier_htaccess(); |
|
| 54 | + if ($msg) { |
|
| 55 | + $cible = _T('public:accueil_site'); |
|
| 56 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 57 | + echo minipres('AUTO', $msg . $cible); |
|
| 58 | + // ok, deboucher dans l'espace prive |
|
| 59 | + } else { |
|
| 60 | + redirige_url_ecrire('accueil'); |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | function install_verifier_htaccess() { |
| 65 | - if ( |
|
| 66 | - verifier_htaccess(_DIR_TMP, true) |
|
| 67 | - and verifier_htaccess(_DIR_CONNECT, true) |
|
| 68 | - ) { |
|
| 69 | - return ''; |
|
| 70 | - } |
|
| 65 | + if ( |
|
| 66 | + verifier_htaccess(_DIR_TMP, true) |
|
| 67 | + and verifier_htaccess(_DIR_CONNECT, true) |
|
| 68 | + ) { |
|
| 69 | + return ''; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $titre = _T('htaccess_inoperant'); |
|
| 72 | + $titre = _T('htaccess_inoperant'); |
|
| 73 | 73 | |
| 74 | - $averti = _T( |
|
| 75 | - 'htaccess_a_simuler', |
|
| 76 | - [ |
|
| 77 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 78 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 79 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 80 | - ] |
|
| 81 | - ); |
|
| 74 | + $averti = _T( |
|
| 75 | + 'htaccess_a_simuler', |
|
| 76 | + [ |
|
| 77 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 78 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 79 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 80 | + ] |
|
| 81 | + ); |
|
| 82 | 82 | |
| 83 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 83 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 84 | 84 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // creer le repertoire cache, qui sert partout ! |
| 23 | 23 | if (!@file_exists(_DIR_CACHE)) { |
| 24 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 24 | + $rep = preg_replace(','._DIR_TMP.',', '', _DIR_CACHE); |
|
| 25 | 25 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | echo '<p>' |
| 40 | 40 | . _T( |
| 41 | 41 | 'plugin_info_plugins_dist_1', |
| 42 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | + ['plugins_dist' => '<tt>'.joli_repertoire(_DIR_PLUGINS_DIST).'</tt>'] |
|
| 43 | 43 | ) |
| 44 | 44 | . '</p>'; |
| 45 | 45 | |
@@ -11,69 +11,69 @@ |
||
| 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'); |
| 18 | 18 | |
| 19 | 19 | function install_etape_4_dist() { |
| 20 | 20 | |
| 21 | - // creer le repertoire cache, qui sert partout ! |
|
| 22 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 23 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 24 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 25 | - } |
|
| 21 | + // creer le repertoire cache, qui sert partout ! |
|
| 22 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 23 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', _DIR_CACHE); |
|
| 24 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 29 | - echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 28 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 29 | + echo info_progression_etape(4, 'etape_', 'install/'); |
|
| 30 | 30 | |
| 31 | - echo "<div class='success'><b>" |
|
| 32 | - . _T('info_derniere_etape') |
|
| 33 | - . '</b><p>' |
|
| 34 | - . _T('info_utilisation_spip') |
|
| 35 | - . '</p></div>'; |
|
| 31 | + echo "<div class='success'><b>" |
|
| 32 | + . _T('info_derniere_etape') |
|
| 33 | + . '</b><p>' |
|
| 34 | + . _T('info_utilisation_spip') |
|
| 35 | + . '</p></div>'; |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - echo '<p>' |
|
| 39 | - . _T( |
|
| 40 | - 'plugin_info_plugins_dist_1', |
|
| 41 | - ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | - ) |
|
| 43 | - . '</p>'; |
|
| 38 | + echo '<p>' |
|
| 39 | + . _T( |
|
| 40 | + 'plugin_info_plugins_dist_1', |
|
| 41 | + ['plugins_dist' => '<tt>' . joli_repertoire(_DIR_PLUGINS_DIST) . '</tt>'] |
|
| 42 | + ) |
|
| 43 | + . '</p>'; |
|
| 44 | 44 | |
| 45 | - // installer les extensions |
|
| 46 | - include_spip('inc/plugin'); |
|
| 47 | - $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 48 | - echo $afficher( |
|
| 49 | - self(), |
|
| 50 | - liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 51 | - [], |
|
| 52 | - [], |
|
| 53 | - _DIR_PLUGINS_DIST, |
|
| 54 | - 'afficher_nom_plugin' |
|
| 55 | - ); |
|
| 45 | + // installer les extensions |
|
| 46 | + include_spip('inc/plugin'); |
|
| 47 | + $afficher = charger_fonction('afficher_liste', 'plugins'); |
|
| 48 | + echo $afficher( |
|
| 49 | + self(), |
|
| 50 | + liste_plugin_files(_DIR_PLUGINS_DIST), |
|
| 51 | + [], |
|
| 52 | + [], |
|
| 53 | + _DIR_PLUGINS_DIST, |
|
| 54 | + 'afficher_nom_plugin' |
|
| 55 | + ); |
|
| 56 | 56 | |
| 57 | - // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 58 | - // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 59 | - // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 60 | - // et procede alors a l'installation |
|
| 61 | - if ( |
|
| 62 | - !isset($GLOBALS['meta']['version_installee']) |
|
| 63 | - or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 64 | - ) { |
|
| 65 | - plugin_installes_meta(); |
|
| 66 | - } |
|
| 57 | + // si la base de SPIP est up, on peut installer les plugins, sinon on passe cette etape |
|
| 58 | + // car les plugins supposent que la base de SPIP est dans son etat normal (mise a jour) |
|
| 59 | + // au premier passage dans l'espace prive on aura une demande d'upgrade qui se poursuit sur la page plugin |
|
| 60 | + // et procede alors a l'installation |
|
| 61 | + if ( |
|
| 62 | + !isset($GLOBALS['meta']['version_installee']) |
|
| 63 | + or ($GLOBALS['spip_version_base'] == (str_replace(',', '.', $GLOBALS['meta']['version_installee']))) |
|
| 64 | + ) { |
|
| 65 | + plugin_installes_meta(); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - // mettre a jour si necessaire l'adresse du site |
|
| 69 | - // securite si on arrive plus a se loger |
|
| 70 | - include_spip('inc/config'); |
|
| 71 | - appliquer_adresse_site(''); |
|
| 68 | + // mettre a jour si necessaire l'adresse du site |
|
| 69 | + // securite si on arrive plus a se loger |
|
| 70 | + include_spip('inc/config'); |
|
| 71 | + appliquer_adresse_site(''); |
|
| 72 | 72 | |
| 73 | - // aller a la derniere etape qui clos l'install et redirige |
|
| 74 | - $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 75 | - . bouton_suivant(_T('login_espace_prive')); |
|
| 73 | + // aller a la derniere etape qui clos l'install et redirige |
|
| 74 | + $suite = "\n<input type='hidden' name='etape' value='fin' />" |
|
| 75 | + . bouton_suivant(_T('login_espace_prive')); |
|
| 76 | 76 | |
| 77 | - echo generer_form_ecrire('install', $suite); |
|
| 78 | - echo install_fin_html(); |
|
| 77 | + echo generer_form_ecrire('install', $suite); |
|
| 78 | + echo install_fin_html(); |
|
| 79 | 79 | } |
@@ -52,29 +52,28 @@ discard block |
||
| 52 | 52 | $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
| 53 | 53 | . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
| 54 | 54 | . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
| 55 | - . (($tls_ldap != 'oui') ? '' : |
|
| 56 | - "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 55 | + . (($tls_ldap != 'oui') ? '' : "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 57 | 56 | . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
| 58 | 57 | |
| 59 | 58 | $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
| 60 | 59 | $res = ''; |
| 61 | 60 | foreach ($champs as $champ => $v) { |
| 62 | - $nom = 'ldap_' . $champ; |
|
| 61 | + $nom = 'ldap_'.$champ; |
|
| 63 | 62 | $val = trim(_request($nom)); |
| 64 | 63 | if (preg_match('/^\w*$/', $val)) { |
| 65 | 64 | if ($val) { |
| 66 | 65 | $val = _q($val); |
| 67 | 66 | } |
| 68 | 67 | } else { |
| 69 | - $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 68 | + $val = 'array('._q(preg_split('/\W+/', $val)).')'; |
|
| 70 | 69 | }; |
| 71 | 70 | if ($val) { |
| 72 | - $res .= "'$champ' => " . $val . ','; |
|
| 71 | + $res .= "'$champ' => ".$val.','; |
|
| 73 | 72 | } |
| 74 | 73 | } |
| 75 | 74 | $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
| 76 | 75 | |
| 77 | - install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 76 | + install_fichier_connexion(_DIR_CONNECT._FILE_LDAP, $conn); |
|
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | function etape_ldap5_suite() { |
@@ -87,7 +86,7 @@ discard block |
||
| 87 | 86 | ); |
| 88 | 87 | |
| 89 | 88 | echo generer_form_ecrire('install', ( |
| 90 | - "<input type='hidden' name='etape' value='3' />" . |
|
| 89 | + "<input type='hidden' name='etape' value='3' />". |
|
| 91 | 90 | "<input type='hidden' name='ldap_present' value='true' />" |
| 92 | 91 | . bouton_suivant())); |
| 93 | 92 | |
@@ -11,84 +11,84 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/headers'); |
| 17 | 17 | include_spip('auth/ldap'); |
| 18 | 18 | |
| 19 | 19 | function install_etape_ldap5_dist() { |
| 20 | - etape_ldap5_save(); |
|
| 21 | - etape_ldap5_suite(); |
|
| 20 | + etape_ldap5_save(); |
|
| 21 | + etape_ldap5_suite(); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | function etape_ldap5_save() { |
| 25 | - $conn = null; |
|
| 26 | - if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 27 | - redirige_url_ecrire('install'); |
|
| 28 | - } |
|
| 25 | + $conn = null; |
|
| 26 | + if (!@file_exists(_FILE_CONNECT_TMP)) { |
|
| 27 | + redirige_url_ecrire('install'); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 30 | + ecrire_meta('ldap_statut_import', _request('statut_ldap')); |
|
| 31 | 31 | |
| 32 | - lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 32 | + lire_fichier(_FILE_CONNECT_TMP, $conn); |
|
| 33 | 33 | |
| 34 | - if ($p = strpos($conn, "'');")) { |
|
| 35 | - ecrire_fichier( |
|
| 36 | - _FILE_CONNECT_TMP, |
|
| 37 | - substr($conn, 0, $p + 1) |
|
| 38 | - . _FILE_LDAP |
|
| 39 | - . substr($conn, $p + 1) |
|
| 40 | - ); |
|
| 41 | - } |
|
| 34 | + if ($p = strpos($conn, "'');")) { |
|
| 35 | + ecrire_fichier( |
|
| 36 | + _FILE_CONNECT_TMP, |
|
| 37 | + substr($conn, 0, $p + 1) |
|
| 38 | + . _FILE_LDAP |
|
| 39 | + . substr($conn, $p + 1) |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\"); |
|
| 44 | - $login_ldap = addcslashes(_request('login_ldap'), "'\\"); |
|
| 45 | - $pass_ldap = addcslashes(_request('pass_ldap'), "'\\"); |
|
| 46 | - $port_ldap = addcslashes(_request('port_ldap'), "'\\"); |
|
| 47 | - $tls_ldap = addcslashes(_request('tls_ldap'), "'\\"); |
|
| 48 | - $protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\"); |
|
| 49 | - $base_ldap = addcslashes(_request('base_ldap'), "'\\"); |
|
| 50 | - $base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\"); |
|
| 43 | + $adresse_ldap = addcslashes(_request('adresse_ldap'), "'\\"); |
|
| 44 | + $login_ldap = addcslashes(_request('login_ldap'), "'\\"); |
|
| 45 | + $pass_ldap = addcslashes(_request('pass_ldap'), "'\\"); |
|
| 46 | + $port_ldap = addcslashes(_request('port_ldap'), "'\\"); |
|
| 47 | + $tls_ldap = addcslashes(_request('tls_ldap'), "'\\"); |
|
| 48 | + $protocole_ldap = addcslashes(_request('protocole_ldap'), "'\\"); |
|
| 49 | + $base_ldap = addcslashes(_request('base_ldap'), "'\\"); |
|
| 50 | + $base_ldap_text = addcslashes(_request('base_ldap_text'), "'\\"); |
|
| 51 | 51 | |
| 52 | - $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 53 | - . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 54 | - . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
|
| 55 | - . (($tls_ldap != 'oui') ? '' : |
|
| 56 | - "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 57 | - . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 52 | + $conn = "\$GLOBALS['ldap_base'] = '$base_ldap';\n" |
|
| 53 | + . "\$GLOBALS['ldap_link'] = @ldap_connect('$adresse_ldap','$port_ldap');\n" |
|
| 54 | + . "@ldap_set_option(\$GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'$protocole_ldap');\n" |
|
| 55 | + . (($tls_ldap != 'oui') ? '' : |
|
| 56 | + "@ldap_start_tls(\$GLOBALS['ldap_link']);\n") |
|
| 57 | + . "@ldap_bind(\$GLOBALS['ldap_link'],'$login_ldap','$pass_ldap');\n"; |
|
| 58 | 58 | |
| 59 | - $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 60 | - $res = ''; |
|
| 61 | - foreach ($champs as $champ => $v) { |
|
| 62 | - $nom = 'ldap_' . $champ; |
|
| 63 | - $val = trim(_request($nom)); |
|
| 64 | - if (preg_match('/^\w*$/', $val)) { |
|
| 65 | - if ($val) { |
|
| 66 | - $val = _q($val); |
|
| 67 | - } |
|
| 68 | - } else { |
|
| 69 | - $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 70 | - }; |
|
| 71 | - if ($val) { |
|
| 72 | - $res .= "'$champ' => " . $val . ','; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 59 | + $champs = is_array($GLOBALS['ldap_attributes']) ? $GLOBALS['ldap_attributes'] : []; |
|
| 60 | + $res = ''; |
|
| 61 | + foreach ($champs as $champ => $v) { |
|
| 62 | + $nom = 'ldap_' . $champ; |
|
| 63 | + $val = trim(_request($nom)); |
|
| 64 | + if (preg_match('/^\w*$/', $val)) { |
|
| 65 | + if ($val) { |
|
| 66 | + $val = _q($val); |
|
| 67 | + } |
|
| 68 | + } else { |
|
| 69 | + $val = 'array(' . _q(preg_split('/\W+/', $val)) . ')'; |
|
| 70 | + }; |
|
| 71 | + if ($val) { |
|
| 72 | + $res .= "'$champ' => " . $val . ','; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + $conn .= "\$GLOBALS['ldap_champs'] = array($res);\n"; |
|
| 76 | 76 | |
| 77 | - install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 77 | + install_fichier_connexion(_DIR_CONNECT . _FILE_LDAP, $conn); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | function etape_ldap5_suite() { |
| 81 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 81 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 82 | 82 | |
| 83 | - echo info_etape( |
|
| 84 | - _T('info_ldap_ok'), |
|
| 85 | - info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 86 | - ); |
|
| 83 | + echo info_etape( |
|
| 84 | + _T('info_ldap_ok'), |
|
| 85 | + info_progression_etape(5, 'etape_ldap', 'install/') |
|
| 86 | + ); |
|
| 87 | 87 | |
| 88 | - echo generer_form_ecrire('install', ( |
|
| 89 | - "<input type='hidden' name='etape' value='3' />" . |
|
| 90 | - "<input type='hidden' name='ldap_present' value='true' />" |
|
| 91 | - . bouton_suivant())); |
|
| 88 | + echo generer_form_ecrire('install', ( |
|
| 89 | + "<input type='hidden' name='etape' value='3' />" . |
|
| 90 | + "<input type='hidden' name='ldap_present' value='true' />" |
|
| 91 | + . bouton_suivant())); |
|
| 92 | 92 | |
| 93 | - echo install_fin_html(); |
|
| 93 | + echo install_fin_html(); |
|
| 94 | 94 | } |
@@ -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 | } |
@@ -107,8 +107,8 @@ |
||
| 107 | 107 | function message_crash_tables() { |
| 108 | 108 | if ($crash = verifier_crash_tables()) { |
| 109 | 109 | return |
| 110 | - '<strong>' . _T('texte_recuperer_base') . '</strong><br />' |
|
| 111 | - . ' <tt>' . join(', ', $crash) . '</tt><br />' |
|
| 110 | + '<strong>'._T('texte_recuperer_base').'</strong><br />' |
|
| 111 | + . ' <tt>'.join(', ', $crash).'</tt><br />' |
|
| 112 | 112 | . generer_form_ecrire( |
| 113 | 113 | 'base_repair', |
| 114 | 114 | _T('texte_crash_base'), |
@@ -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 | } |
@@ -561,11 +561,9 @@ discard block |
||
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
| 564 | - } |
|
| 565 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 564 | + } elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 566 | 565 | $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
| 567 | - } |
|
| 568 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 566 | + } elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 569 | 567 | $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
| 570 | 568 | } |
| 571 | 569 | } else { |
@@ -954,8 +952,7 @@ discard block |
||
| 954 | 952 | if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
| 955 | 953 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 954 | } |
| 957 | - } |
|
| 958 | - else { |
|
| 955 | + } else { |
|
| 959 | 956 | foreach ($info['chemin'] as $chemin) { |
| 960 | 957 | if ( |
| 961 | 958 | !isset($chemin['version']) or plugin_version_compatible( |
@@ -1425,8 +1422,7 @@ discard block |
||
| 1425 | 1422 | echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
| 1426 | 1423 | $trace, |
| 1427 | 1424 | "\n"; |
| 1428 | - } |
|
| 1429 | - else { |
|
| 1425 | + } else { |
|
| 1430 | 1426 | include_spip('inc/filtres_boites'); |
| 1431 | 1427 | echo "<div class='install-plugins svp_retour'>" |
| 1432 | 1428 | . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
@@ -1463,8 +1459,7 @@ discard block |
||
| 1463 | 1459 | if (file_exists($nom)) { |
| 1464 | 1460 | if (substr($nom, -4) == '.php') { |
| 1465 | 1461 | $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
| 1466 | - } |
|
| 1467 | - else { |
|
| 1462 | + } else { |
|
| 1468 | 1463 | $fichier_tmp = $nom . '.tmp'; |
| 1469 | 1464 | } |
| 1470 | 1465 | file_put_contents($fichier_tmp, $contenu); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS.'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | if ($dir) { |
| 374 | 374 | $dir .= '/'; |
| 375 | 375 | } |
| 376 | - $dir .= 'procure:' . $procure['nom']; |
|
| 376 | + $dir .= 'procure:'.$procure['nom']; |
|
| 377 | 377 | |
| 378 | 378 | $procure['etat'] = '?'; |
| 379 | 379 | $procure['dir_type'] = $resume['dir_type']; |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | $plug = $resume['dir']; |
| 558 | 558 | $k = $infos[$dir_type][$plug]; |
| 559 | 559 | |
| 560 | - $plug = constant($dir_type) . $plug; |
|
| 560 | + $plug = constant($dir_type).$plug; |
|
| 561 | 561 | if (!isset($msg[$p])) { |
| 562 | 562 | if (isset($resume['erreur']) and $resume['erreur']) { |
| 563 | 563 | $msg[$p] = [$resume['erreur']]; |
@@ -600,10 +600,10 @@ discard block |
||
| 600 | 600 | $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
| 601 | 601 | } elseif (!$raw) { |
| 602 | 602 | foreach ($list as $plug => $msg) { |
| 603 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 603 | + $list[$plug] = '<li>'._T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 604 | + . '<ul><li>'.implode('</li><li>', $msg).'</li></ul></li>'; |
|
| 605 | 605 | } |
| 606 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 606 | + $list = '<ul>'.join("\n", $list).'</ul>'; |
|
| 607 | 607 | } |
| 608 | 608 | if ($raz) { |
| 609 | 609 | effacer_meta('plugin_erreur_activation'); |
@@ -717,13 +717,13 @@ discard block |
||
| 717 | 717 | if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
| 718 | 718 | return _T("plugin_${balise}_${type}", [ |
| 719 | 719 | 'plugin' => $nom, |
| 720 | - 'version' => ' ≥ ' . $minimum |
|
| 720 | + 'version' => ' ≥ '.$minimum |
|
| 721 | 721 | ]); |
| 722 | 722 | } |
| 723 | 723 | if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
| 724 | 724 | return _T("plugin_${balise}_${type}", [ |
| 725 | 725 | 'plugin' => $nom, |
| 726 | - 'version' => ' > ' . $minimum |
|
| 726 | + 'version' => ' > '.$minimum |
|
| 727 | 727 | ]); |
| 728 | 728 | } |
| 729 | 729 | } |
@@ -732,13 +732,13 @@ discard block |
||
| 732 | 732 | if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
| 733 | 733 | return _T("plugin_${balise}_${type}", [ |
| 734 | 734 | 'plugin' => $nom, |
| 735 | - 'version' => ' ≤ ' . $maximum |
|
| 735 | + 'version' => ' ≤ '.$maximum |
|
| 736 | 736 | ]); |
| 737 | 737 | } |
| 738 | 738 | if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
| 739 | 739 | return _T("plugin_${balise}_plugin", [ |
| 740 | 740 | 'plugin' => $nom, |
| 741 | - 'version' => ' < ' . $maximum |
|
| 741 | + 'version' => ' < '.$maximum |
|
| 742 | 742 | ]); |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | include_spip('inc/charger_plugin'); |
| 758 | 758 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 759 | 759 | }*/ |
| 760 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 760 | + return _T('plugin_necessite_lib', ['lib' => $lib])." <a href='$url'>$url</a>"; |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | |
@@ -857,7 +857,7 @@ discard block |
||
| 857 | 857 | foreach ($plugin_valides as $p => $resume) { |
| 858 | 858 | // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
| 859 | 859 | if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
| 860 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 860 | + $header[] = $p.($resume['version'] ? '('.$resume['version'].')' : ''); |
|
| 861 | 861 | } |
| 862 | 862 | if ($resume['dir']) { |
| 863 | 863 | foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
@@ -882,11 +882,11 @@ discard block |
||
| 882 | 882 | $header = strtolower(implode(',', $header)); |
| 883 | 883 | if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
| 884 | 884 | ecrire_fichier( |
| 885 | - _DIR_VAR . 'config.txt', |
|
| 886 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 885 | + _DIR_VAR.'config.txt', |
|
| 886 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP').' '.$GLOBALS['spip_version_affichee'].' @ www.spip.net + '.$header |
|
| 887 | 887 | ); |
| 888 | 888 | } else { |
| 889 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 889 | + @unlink(_DIR_VAR.'config.txt'); |
|
| 890 | 890 | } |
| 891 | 891 | // generer charger_plugins_chemin.php |
| 892 | 892 | plugins_precompile_chemin($plugin_valides, $ordre); |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | // definir le plugin, donc le path avant l'include du fichier options |
| 941 | 941 | // permet de faire des include_spip pour attraper un inc_ du plugin |
| 942 | 942 | |
| 943 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 943 | + $dir = $dir_type.".'".$plug."/'"; |
|
| 944 | 944 | |
| 945 | 945 | $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
| 946 | 946 | if ( |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | if (!$info['chemin']) { |
| 952 | 952 | $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
| 953 | 953 | $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
| 954 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 954 | + if (is_dir(constant($dir_type).$plug.'/squelettes/')) { |
|
| 955 | 955 | $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
| 956 | 956 | } |
| 957 | 957 | } |
@@ -972,13 +972,13 @@ discard block |
||
| 972 | 972 | $dir = ''; |
| 973 | 973 | } |
| 974 | 974 | if (strlen($dir)) { |
| 975 | - $dir = rtrim($dir, '/') . '/'; |
|
| 975 | + $dir = rtrim($dir, '/').'/'; |
|
| 976 | 976 | } |
| 977 | 977 | if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
| 978 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 978 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 979 | 979 | } |
| 980 | 980 | if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
| 981 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 981 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix".(strlen($dir) ? ".'$dir'" : ''); |
|
| 982 | 982 | } |
| 983 | 983 | } |
| 984 | 984 | } |
@@ -987,11 +987,11 @@ discard block |
||
| 987 | 987 | } |
| 988 | 988 | } |
| 989 | 989 | if (count($chemins['public']) or count($chemins['prive'])) { |
| 990 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 990 | + $contenu .= 'if (_DIR_RESTREINT) _chemin(['.implode( |
|
| 991 | 991 | ',', |
| 992 | 992 | array_reverse($chemins['public']) |
| 993 | - ) . "]);\n" |
|
| 994 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 993 | + )."]);\n" |
|
| 994 | + . 'else _chemin(['.implode(',', array_reverse($chemins['prive']))."]);\n"; |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | and strpos($dir, ':') === false // exclure le cas des procure: |
| 1041 | 1041 | and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
| 1042 | 1042 | ) { |
| 1043 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1043 | + if (is_readable("$dir$plug/".($file = $info['prefix'].'_'.$charge.'.php'))) { |
|
| 1044 | 1044 | $info[$charge] = [$file]; |
| 1045 | 1045 | } |
| 1046 | 1046 | } |
@@ -1057,7 +1057,7 @@ discard block |
||
| 1057 | 1057 | ) { |
| 1058 | 1058 | unset($info[$charge][$k]); |
| 1059 | 1059 | } else { |
| 1060 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1060 | + $_file = $root_dir_type.".'$plug/$file'"; |
|
| 1061 | 1061 | $contenu[$charge] .= "include_once_check($_file);\n"; |
| 1062 | 1062 | } |
| 1063 | 1063 | } |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | } |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1070 | + $contenu['options'] = "define('_PLUGINS_HASH','".md5($sign)."');\n".$contenu['options']; |
|
| 1071 | 1071 | $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
| 1072 | 1072 | . plugin_ongletbouton('onglets_plugins', $onglets); |
| 1073 | 1073 | |
@@ -1102,12 +1102,12 @@ discard block |
||
| 1102 | 1102 | define("_UPDATED_$nom", $val); |
| 1103 | 1103 | define("_UPDATED_md5_$nom", $md5); |
| 1104 | 1104 | } |
| 1105 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1105 | + $val = "unserialize('".str_replace("'", "\'", $val)."')"; |
|
| 1106 | 1106 | |
| 1107 | 1107 | return |
| 1108 | 1108 | "if (!function_exists('$nom')) {\n" |
| 1109 | 1109 | . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
| 1110 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1110 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'".$md5."';}\n" |
|
| 1111 | 1111 | . "}\n"; |
| 1112 | 1112 | } |
| 1113 | 1113 | |
@@ -1130,7 +1130,7 @@ discard block |
||
| 1130 | 1130 | if (@is_readable(_CACHE_PLUGINS_OPT)) { |
| 1131 | 1131 | include_once(_CACHE_PLUGINS_OPT); |
| 1132 | 1132 | } else { |
| 1133 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1133 | + spip_log('pipelines desactives: impossible de produire '._CACHE_PLUGINS_OPT); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | 1136 | |
@@ -1167,7 +1167,7 @@ discard block |
||
| 1167 | 1167 | $dir_type = $plugin_valides[$p]['dir_type']; |
| 1168 | 1168 | $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
| 1169 | 1169 | $plug = $plugin_valides[$p]['dir']; |
| 1170 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1170 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'].'_'); |
|
| 1171 | 1171 | if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
| 1172 | 1172 | foreach ($info['pipeline'] as $pipe) { |
| 1173 | 1173 | $nom = $pipe['nom']; |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | } |
| 1202 | 1202 | if (isset($pipe['inclure'])) { |
| 1203 | 1203 | $GLOBALS['spip_matrice']["$prefix$action"] = |
| 1204 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1204 | + "$root_dir_type:$plug/".$pipe['inclure']; |
|
| 1205 | 1205 | } |
| 1206 | 1206 | } |
| 1207 | 1207 | } |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | $prepend_code['taches_generales_cron'] = ''; |
| 1212 | 1212 | } |
| 1213 | 1213 | foreach ($info['genie'] as $genie) { |
| 1214 | - $nom = $prefix . $genie['nom']; |
|
| 1214 | + $nom = $prefix.$genie['nom']; |
|
| 1215 | 1215 | $periode = max(60, intval($genie['periode'])); |
| 1216 | 1216 | if (charger_fonction($nom, 'genie', true)) { |
| 1217 | 1217 | $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
@@ -1229,13 +1229,13 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | foreach ($info['style'] as $style) { |
| 1231 | 1231 | if (isset($style['path']) and $style['path']) { |
| 1232 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1232 | + $code = "if (\$f=timestamp(direction_css(find_in_path('".addslashes($style['path'])."')))) "; |
|
| 1233 | 1233 | } else { |
| 1234 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1234 | + $code = "if (\$f='".addslashes($style['url'])."') "; |
|
| 1235 | 1235 | } |
| 1236 | 1236 | $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
| 1237 | 1237 | if (isset($style['media']) and strlen($style['media'])) { |
| 1238 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1238 | + $code .= ' media="'.addslashes($style['media']).'"'; |
|
| 1239 | 1239 | } |
| 1240 | 1240 | $code .= "/>';\n"; |
| 1241 | 1241 | if ($style['type'] != 'prive') { |
@@ -1255,9 +1255,9 @@ discard block |
||
| 1255 | 1255 | if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
| 1256 | 1256 | foreach ($info['script'] as $script) { |
| 1257 | 1257 | if (isset($script['path']) and $script['path']) { |
| 1258 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1258 | + $code = "if (\$f=timestamp(find_in_path('".addslashes($script['path'])."'))) "; |
|
| 1259 | 1259 | } else { |
| 1260 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1260 | + $code = "if (\$f='".addslashes($script['url'])."') "; |
|
| 1261 | 1261 | } |
| 1262 | 1262 | $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
| 1263 | 1263 | if ($script['type'] != 'prive') { |
@@ -1320,10 +1320,10 @@ discard block |
||
| 1320 | 1320 | unset($GLOBALS['spip_pipeline']['all']); |
| 1321 | 1321 | $all_pipes = trim(array_shift($a)); |
| 1322 | 1322 | if ($all_pipes) { |
| 1323 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1323 | + $all_pipes = '|'.ltrim($all_pipes, '|'); |
|
| 1324 | 1324 | } |
| 1325 | 1325 | if (count($a)) { |
| 1326 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1326 | + $all_pipes_end = '||'.array_shift($a); |
|
| 1327 | 1327 | } |
| 1328 | 1328 | } |
| 1329 | 1329 | $content = ''; |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | // Eclater le pipeline en filtres et appliquer chaque filtre |
| 1341 | 1341 | foreach ($pipe as $fonc) { |
| 1342 | 1342 | $fonc = trim($fonc); |
| 1343 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1343 | + $s_call .= '$val = minipipe(\''.$fonc.'\', $val);'."\n"; |
|
| 1344 | 1344 | if (isset($GLOBALS['spip_matrice'][$fonc])) { |
| 1345 | 1345 | $file = $GLOBALS['spip_matrice'][$fonc]; |
| 1346 | 1346 | $file = "'$file'"; |
@@ -1351,7 +1351,7 @@ discard block |
||
| 1351 | 1351 | if (defined($root_dir)) { |
| 1352 | 1352 | $dir = $root_dir; |
| 1353 | 1353 | } |
| 1354 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1354 | + $file = str_replace($regs[0], "'.".$dir.".'", $file); |
|
| 1355 | 1355 | $file = str_replace("''.", '', $file); |
| 1356 | 1356 | $file = str_replace(constant($dir), '', $file); |
| 1357 | 1357 | } |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | $content .= "// Pipeline $action \n" |
| 1365 | 1365 | . "function execute_pipeline_$action(&\$val){\n" |
| 1366 | 1366 | . $s_inc |
| 1367 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1367 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action])."\n" : '') |
|
| 1368 | 1368 | . $s_call |
| 1369 | 1369 | . "return \$val;\n}\n"; |
| 1370 | 1370 | } |
@@ -1420,9 +1420,9 @@ discard block |
||
| 1420 | 1420 | $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
| 1421 | 1421 | if (_IS_CLI) { |
| 1422 | 1422 | include_spip('inc/filtres'); |
| 1423 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1424 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1425 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1423 | + $trace = ltrim(textebrut($trace)."\n".$result); |
|
| 1424 | + $trace = ' '.str_replace("\n", "\n ", $trace); |
|
| 1425 | + echo "\n".($ok ? 'OK ' : '/!\ ').textebrut($titre)."\n", |
|
| 1426 | 1426 | $trace, |
| 1427 | 1427 | "\n"; |
| 1428 | 1428 | } |
@@ -1457,15 +1457,15 @@ discard block |
||
| 1457 | 1457 | $GLOBALS['fichier_php_compile_recent'] = 0; |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1460 | + $contenu = '<'.'?php'."\n".$comment."\nif (defined('_ECRIRE_INC_VERSION')) {\n".$contenu."}\n?".'>'; |
|
| 1461 | 1461 | // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
| 1462 | 1462 | // si pas de modif on ne touche pas au fichier initial |
| 1463 | 1463 | if (file_exists($nom)) { |
| 1464 | 1464 | if (substr($nom, -4) == '.php') { |
| 1465 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1465 | + $fichier_tmp = substr($nom, 0, -4).'.tmp.php'; |
|
| 1466 | 1466 | } |
| 1467 | 1467 | else { |
| 1468 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1468 | + $fichier_tmp = $nom.'.tmp'; |
|
| 1469 | 1469 | } |
| 1470 | 1470 | file_put_contents($fichier_tmp, $contenu); |
| 1471 | 1471 | if (md5_file($nom) == md5_file($fichier_tmp)) { |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** l'adresse du repertoire de telechargement et de decompactage des plugins */ |
| 24 | 24 | if (!defined('_DIR_PLUGINS_AUTO')) { |
| 25 | - define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 25 | + define('_DIR_PLUGINS_AUTO', _DIR_PLUGINS . 'auto/'); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | #include_spip('inc/texte'); // ????? Appelle public/parametrer trop tot avant la reconstruction du chemin des plugins. |
@@ -47,27 +47,27 @@ discard block |
||
| 47 | 47 | * @return array |
| 48 | 48 | **/ |
| 49 | 49 | function liste_plugin_files($dir_plugins = null) { |
| 50 | - static $plugin_files = []; |
|
| 51 | - if (is_null($dir_plugins)) { |
|
| 52 | - $dir_plugins = _DIR_PLUGINS; |
|
| 53 | - } |
|
| 54 | - if ( |
|
| 55 | - !isset($plugin_files[$dir_plugins]) |
|
| 56 | - or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | - ) { |
|
| 58 | - $plugin_files[$dir_plugins] = []; |
|
| 59 | - foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | - $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - sort($plugin_files[$dir_plugins]); |
|
| 64 | - // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | - // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | - $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return $plugin_files[$dir_plugins]; |
|
| 50 | + static $plugin_files = []; |
|
| 51 | + if (is_null($dir_plugins)) { |
|
| 52 | + $dir_plugins = _DIR_PLUGINS; |
|
| 53 | + } |
|
| 54 | + if ( |
|
| 55 | + !isset($plugin_files[$dir_plugins]) |
|
| 56 | + or (is_countable($plugin_files[$dir_plugins]) ? count($plugin_files[$dir_plugins]) : 0) == 0 |
|
| 57 | + ) { |
|
| 58 | + $plugin_files[$dir_plugins] = []; |
|
| 59 | + foreach (fast_find_plugin_dirs($dir_plugins) as $plugin) { |
|
| 60 | + $plugin_files[$dir_plugins][] = substr($plugin, strlen($dir_plugins)); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + sort($plugin_files[$dir_plugins]); |
|
| 64 | + // et on lit le XML de tous les plugins pour le mettre en cache |
|
| 65 | + // et en profiter pour nettoyer ceux qui n'existent plus du cache |
|
| 66 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 67 | + $get_infos($plugin_files[$dir_plugins], false, $dir_plugins, true); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return $plugin_files[$dir_plugins]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -83,45 +83,45 @@ discard block |
||
| 83 | 83 | * Liste complète des répeertoires |
| 84 | 84 | **/ |
| 85 | 85 | function fast_find_plugin_dirs($dir, $max_prof = 100) { |
| 86 | - $fichiers = []; |
|
| 87 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | - if ($dir == '') { |
|
| 91 | - $dir = '.'; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - if (!is_dir($dir)) { |
|
| 95 | - return $fichiers; |
|
| 96 | - } |
|
| 97 | - if (is_plugin_dir($dir, '')) { |
|
| 98 | - $fichiers[] = $dir; |
|
| 99 | - |
|
| 100 | - return $fichiers; |
|
| 101 | - } |
|
| 102 | - if ($max_prof <= 0) { |
|
| 103 | - return $fichiers; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $subdirs = []; |
|
| 107 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | - while (($f = readdir($d)) !== false) { |
|
| 109 | - if ( |
|
| 110 | - $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | - and $f != 'CVS' |
|
| 112 | - and is_dir($f = "$dir/$f") |
|
| 113 | - ) { |
|
| 114 | - $subdirs[] = $f; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - closedir($d); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - foreach ($subdirs as $d) { |
|
| 121 | - $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return $fichiers; |
|
| 86 | + $fichiers = []; |
|
| 87 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 88 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 89 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 90 | + if ($dir == '') { |
|
| 91 | + $dir = '.'; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + if (!is_dir($dir)) { |
|
| 95 | + return $fichiers; |
|
| 96 | + } |
|
| 97 | + if (is_plugin_dir($dir, '')) { |
|
| 98 | + $fichiers[] = $dir; |
|
| 99 | + |
|
| 100 | + return $fichiers; |
|
| 101 | + } |
|
| 102 | + if ($max_prof <= 0) { |
|
| 103 | + return $fichiers; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $subdirs = []; |
|
| 107 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 108 | + while (($f = readdir($d)) !== false) { |
|
| 109 | + if ( |
|
| 110 | + $f[0] != '.' # ignorer . .. .svn etc |
|
| 111 | + and $f != 'CVS' |
|
| 112 | + and is_dir($f = "$dir/$f") |
|
| 113 | + ) { |
|
| 114 | + $subdirs[] = $f; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + closedir($d); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + foreach ($subdirs as $d) { |
|
| 121 | + $fichiers = array_merge($fichiers, fast_find_plugin_dirs("$d/", $max_prof - 1)); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return $fichiers; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -142,27 +142,27 @@ discard block |
||
| 142 | 142 | **/ |
| 143 | 143 | function is_plugin_dir($dir, $dir_plugins = null) { |
| 144 | 144 | |
| 145 | - if (is_array($dir)) { |
|
| 146 | - foreach ($dir as $k => $d) { |
|
| 147 | - if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | - unset($dir[$k]); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $dir; |
|
| 153 | - } |
|
| 154 | - if (is_null($dir_plugins)) { |
|
| 155 | - $dir_plugins = _DIR_PLUGINS; |
|
| 156 | - } |
|
| 157 | - $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | - |
|
| 159 | - foreach ($search as $s) { |
|
| 160 | - if (file_exists($s)) { |
|
| 161 | - return $dir; |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - return ''; |
|
| 145 | + if (is_array($dir)) { |
|
| 146 | + foreach ($dir as $k => $d) { |
|
| 147 | + if (!is_plugin_dir($d, $dir_plugins)) { |
|
| 148 | + unset($dir[$k]); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $dir; |
|
| 153 | + } |
|
| 154 | + if (is_null($dir_plugins)) { |
|
| 155 | + $dir_plugins = _DIR_PLUGINS; |
|
| 156 | + } |
|
| 157 | + $search = ["$dir_plugins$dir/paquet.xml"]; |
|
| 158 | + |
|
| 159 | + foreach ($search as $s) { |
|
| 160 | + if (file_exists($s)) { |
|
| 161 | + return $dir; |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + return ''; |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** Regexp d'extraction des informations d'un intervalle de compatibilité */ |
@@ -189,51 +189,51 @@ discard block |
||
| 189 | 189 | **/ |
| 190 | 190 | function plugin_version_compatible($intervalle, $version, $avec_quoi = '') { |
| 191 | 191 | |
| 192 | - if (!strlen($intervalle)) { |
|
| 193 | - return true; |
|
| 194 | - } |
|
| 195 | - if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | - // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | - $minimum = $regs[1]; |
|
| 201 | - $maximum = $regs[2]; |
|
| 202 | - |
|
| 203 | - // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | - // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | - // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | - // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | - // entre plugins) |
|
| 208 | - if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | - if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | - return true; |
|
| 211 | - } |
|
| 212 | - // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | - // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $minimum_inc = $intervalle[0] == '['; |
|
| 217 | - $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | - |
|
| 219 | - if (strlen($minimum)) { |
|
| 220 | - if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | - return false; |
|
| 222 | - } |
|
| 223 | - if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | - return false; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - if (strlen($maximum)) { |
|
| 228 | - if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | - return false; |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - return true; |
|
| 192 | + if (!strlen($intervalle)) { |
|
| 193 | + return true; |
|
| 194 | + } |
|
| 195 | + if (!preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + // Extraction des bornes et traitement de * pour la borne sup : |
|
| 199 | + // -- on autorise uniquement les ecritures 3.0.*, 3.* |
|
| 200 | + $minimum = $regs[1]; |
|
| 201 | + $maximum = $regs[2]; |
|
| 202 | + |
|
| 203 | + // si une version SPIP de compatibilité a été définie (dans |
|
| 204 | + // mes_options.php, sous la forme : define('_DEV_VERSION_SPIP_COMPAT', '3.1.0'); |
|
| 205 | + // on l'utilise (phase de dev, de test...) mais *que* en cas de comparaison |
|
| 206 | + // avec la version de SPIP (ne nuit donc pas aux tests de necessite |
|
| 207 | + // entre plugins) |
|
| 208 | + if (defined('_DEV_VERSION_SPIP_COMPAT') and $avec_quoi == 'spip' and $version !== _DEV_VERSION_SPIP_COMPAT) { |
|
| 209 | + if (plugin_version_compatible($intervalle, _DEV_VERSION_SPIP_COMPAT, $avec_quoi)) { |
|
| 210 | + return true; |
|
| 211 | + } |
|
| 212 | + // si pas de compatibilite avec _DEV_VERSION_SPIP_COMPAT, on essaye quand meme avec la vrai version |
|
| 213 | + // cas du plugin qui n'est compatible qu'avec cette nouvelle version |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $minimum_inc = $intervalle[0] == '['; |
|
| 217 | + $maximum_inc = substr($intervalle, -1) == ']'; |
|
| 218 | + |
|
| 219 | + if (strlen($minimum)) { |
|
| 220 | + if ($minimum_inc and spip_version_compare($version, $minimum, '<')) { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 223 | + if (!$minimum_inc and spip_version_compare($version, $minimum, '<=')) { |
|
| 224 | + return false; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + if (strlen($maximum)) { |
|
| 228 | + if ($maximum_inc and spip_version_compare($version, $maximum, '>')) { |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + if (!$maximum_inc and spip_version_compare($version, $maximum, '>=')) { |
|
| 232 | + return false; |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + return true; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -250,62 +250,62 @@ discard block |
||
| 250 | 250 | * @return array |
| 251 | 251 | */ |
| 252 | 252 | function liste_plugin_valides($liste_plug, $force = false) { |
| 253 | - $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | - $infos = [ |
|
| 256 | - // lister les extensions qui sont automatiquement actives |
|
| 257 | - '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | - '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | - ]; |
|
| 260 | - |
|
| 261 | - // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | - // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | - $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | - $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | - $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | - $liste_non_classee = [ |
|
| 267 | - 'SPIP' => [ |
|
| 268 | - 'nom' => 'SPIP', |
|
| 269 | - 'etat' => 'stable', |
|
| 270 | - 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | - 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | - 'dir' => '', |
|
| 273 | - ] |
|
| 274 | - ]; |
|
| 275 | - |
|
| 276 | - $invalides = []; |
|
| 277 | - foreach ($liste_ext as $plug) { |
|
| 278 | - if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | - plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | - } |
|
| 281 | - } |
|
| 282 | - foreach ($liste_plug as $plug) { |
|
| 283 | - if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | - if (is_array($r)) { |
|
| 286 | - $invalides = array_merge($invalides, $r); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | - $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | - foreach ($liste_plug as $plug) { |
|
| 294 | - if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | - $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | - if (is_array($r)) { |
|
| 297 | - $invalides = array_merge($invalides, $r); |
|
| 298 | - } |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | - |
|
| 305 | - // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | - $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | - |
|
| 308 | - return [$infos, $liste_non_classee, $invalides]; |
|
| 253 | + $liste_ext = liste_plugin_files(_DIR_PLUGINS_DIST); |
|
| 254 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 255 | + $infos = [ |
|
| 256 | + // lister les extensions qui sont automatiquement actives |
|
| 257 | + '_DIR_PLUGINS_DIST' => $get_infos($liste_ext, $force, _DIR_PLUGINS_DIST), |
|
| 258 | + '_DIR_PLUGINS' => $get_infos($liste_plug, $force, _DIR_PLUGINS) |
|
| 259 | + ]; |
|
| 260 | + |
|
| 261 | + // creer une premiere liste non ordonnee mais qui ne retient |
|
| 262 | + // que les plugins valides, et dans leur derniere version en cas de doublon |
|
| 263 | + $infos['_DIR_RESTREINT'][''] = $get_infos('./', $force, _DIR_RESTREINT); |
|
| 264 | + $infos['_DIR_RESTREINT']['SPIP']['version'] = $GLOBALS['spip_version_branche']; |
|
| 265 | + $infos['_DIR_RESTREINT']['SPIP']['chemin'] = []; |
|
| 266 | + $liste_non_classee = [ |
|
| 267 | + 'SPIP' => [ |
|
| 268 | + 'nom' => 'SPIP', |
|
| 269 | + 'etat' => 'stable', |
|
| 270 | + 'version' => $GLOBALS['spip_version_branche'], |
|
| 271 | + 'dir_type' => '_DIR_RESTREINT', |
|
| 272 | + 'dir' => '', |
|
| 273 | + ] |
|
| 274 | + ]; |
|
| 275 | + |
|
| 276 | + $invalides = []; |
|
| 277 | + foreach ($liste_ext as $plug) { |
|
| 278 | + if (isset($infos['_DIR_PLUGINS_DIST'][$plug])) { |
|
| 279 | + plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_DIST'); |
|
| 280 | + } |
|
| 281 | + } |
|
| 282 | + foreach ($liste_plug as $plug) { |
|
| 283 | + if (isset($infos['_DIR_PLUGINS'][$plug])) { |
|
| 284 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS'); |
|
| 285 | + if (is_array($r)) { |
|
| 286 | + $invalides = array_merge($invalides, $r); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + if (defined('_DIR_PLUGINS_SUPPL') and _DIR_PLUGINS_SUPPL) { |
|
| 292 | + $infos['_DIR_PLUGINS_SUPPL'] = $get_infos($liste_plug, false, _DIR_PLUGINS_SUPPL); |
|
| 293 | + foreach ($liste_plug as $plug) { |
|
| 294 | + if (isset($infos['_DIR_PLUGINS_SUPPL'][$plug])) { |
|
| 295 | + $r = plugin_valide_resume($liste_non_classee, $plug, $infos, '_DIR_PLUGINS_SUPPL'); |
|
| 296 | + if (is_array($r)) { |
|
| 297 | + $invalides = array_merge($invalides, $r); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + plugin_fixer_procure($liste_non_classee, $infos); |
|
| 304 | + |
|
| 305 | + // les plugins qui sont dans $liste_non_classee ne sont pas invalides (on a trouve un autre version valide) |
|
| 306 | + $invalides = array_diff_key($invalides, $liste_non_classee); |
|
| 307 | + |
|
| 308 | + return [$infos, $liste_non_classee, $invalides]; |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | /** |
@@ -325,38 +325,38 @@ discard block |
||
| 325 | 325 | * array description short si on ne le retient pas (pour memorisation dans une table des erreurs) |
| 326 | 326 | */ |
| 327 | 327 | function plugin_valide_resume(&$liste, $plug, $infos, $dir_type) { |
| 328 | - $i = $infos[$dir_type][$plug]; |
|
| 329 | - // minimum syndical pour afficher si le xml avait des erreurs éventuelles |
|
| 330 | - $short_desc = [ |
|
| 331 | - 'dir' => $plug, |
|
| 332 | - 'dir_type' => $dir_type |
|
| 333 | - ]; |
|
| 334 | - if (empty($i['prefix'])) { |
|
| 335 | - // erreur xml ? mais sans connaissance du prefix, on retourne le chemin… |
|
| 336 | - $short_desc['erreur'] = $i['erreur'] ?? ['?']; |
|
| 337 | - return [$plug => $short_desc]; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - $p = strtoupper($i['prefix']); |
|
| 341 | - $short_desc['nom'] = $i['nom']; |
|
| 342 | - $short_desc['etat'] = $i['etat']; |
|
| 343 | - $short_desc['version'] = $i['version']; |
|
| 344 | - |
|
| 345 | - if (isset($i['erreur']) and $i['erreur']) { |
|
| 346 | - $short_desc['erreur'] = $i['erreur']; |
|
| 347 | - return [$p => $short_desc]; |
|
| 348 | - } |
|
| 349 | - if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 350 | - return [$p => $short_desc]; |
|
| 351 | - } |
|
| 352 | - if ( |
|
| 353 | - !isset($liste[$p]) |
|
| 354 | - or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 355 | - ) { |
|
| 356 | - $liste[$p] = $short_desc; |
|
| 357 | - } |
|
| 358 | - // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 359 | - return $p; |
|
| 328 | + $i = $infos[$dir_type][$plug]; |
|
| 329 | + // minimum syndical pour afficher si le xml avait des erreurs éventuelles |
|
| 330 | + $short_desc = [ |
|
| 331 | + 'dir' => $plug, |
|
| 332 | + 'dir_type' => $dir_type |
|
| 333 | + ]; |
|
| 334 | + if (empty($i['prefix'])) { |
|
| 335 | + // erreur xml ? mais sans connaissance du prefix, on retourne le chemin… |
|
| 336 | + $short_desc['erreur'] = $i['erreur'] ?? ['?']; |
|
| 337 | + return [$plug => $short_desc]; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + $p = strtoupper($i['prefix']); |
|
| 341 | + $short_desc['nom'] = $i['nom']; |
|
| 342 | + $short_desc['etat'] = $i['etat']; |
|
| 343 | + $short_desc['version'] = $i['version']; |
|
| 344 | + |
|
| 345 | + if (isset($i['erreur']) and $i['erreur']) { |
|
| 346 | + $short_desc['erreur'] = $i['erreur']; |
|
| 347 | + return [$p => $short_desc]; |
|
| 348 | + } |
|
| 349 | + if (!plugin_version_compatible($i['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 350 | + return [$p => $short_desc]; |
|
| 351 | + } |
|
| 352 | + if ( |
|
| 353 | + !isset($liste[$p]) |
|
| 354 | + or spip_version_compare($i['version'], $liste[$p]['version'], '>') |
|
| 355 | + ) { |
|
| 356 | + $liste[$p] = $short_desc; |
|
| 357 | + } |
|
| 358 | + // ok le plugin etait deja dans la liste ou on a choisi une version plus recente |
|
| 359 | + return $p; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -372,47 +372,47 @@ discard block |
||
| 372 | 372 | * @param array $infos |
| 373 | 373 | */ |
| 374 | 374 | function plugin_fixer_procure(&$liste, &$infos) { |
| 375 | - foreach ($liste as $p => $resume) { |
|
| 376 | - $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 377 | - if (isset($i['procure']) and $i['procure']) { |
|
| 378 | - foreach ($i['procure'] as $procure) { |
|
| 379 | - $p = strtoupper($procure['nom']); |
|
| 380 | - $dir = $resume['dir']; |
|
| 381 | - if ($dir) { |
|
| 382 | - $dir .= '/'; |
|
| 383 | - } |
|
| 384 | - $dir .= 'procure:' . $procure['nom']; |
|
| 385 | - |
|
| 386 | - $procure['etat'] = '?'; |
|
| 387 | - $procure['dir_type'] = $resume['dir_type']; |
|
| 388 | - $procure['dir'] = $dir; |
|
| 389 | - |
|
| 390 | - // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 391 | - // on ajoute cette version a la liste |
|
| 392 | - if ( |
|
| 393 | - !isset($liste[$p]) |
|
| 394 | - or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 395 | - ) { |
|
| 396 | - $liste[$p] = $procure; |
|
| 397 | - |
|
| 398 | - // on fournit une information minimale pour ne pas perturber la compilation |
|
| 399 | - $infos[$resume['dir_type']][$dir] = [ |
|
| 400 | - 'prefix' => $procure['nom'], |
|
| 401 | - 'nom' => $procure['nom'], |
|
| 402 | - 'etat' => $procure['etat'], |
|
| 403 | - 'version' => $procure['version'], |
|
| 404 | - 'chemin' => [], |
|
| 405 | - 'necessite' => [], |
|
| 406 | - 'utilise' => [], |
|
| 407 | - 'lib' => [], |
|
| 408 | - 'menu' => [], |
|
| 409 | - 'onglet' => [], |
|
| 410 | - 'procure' => [], |
|
| 411 | - ]; |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - } |
|
| 375 | + foreach ($liste as $p => $resume) { |
|
| 376 | + $i = $infos[$resume['dir_type']][$resume['dir']]; |
|
| 377 | + if (isset($i['procure']) and $i['procure']) { |
|
| 378 | + foreach ($i['procure'] as $procure) { |
|
| 379 | + $p = strtoupper($procure['nom']); |
|
| 380 | + $dir = $resume['dir']; |
|
| 381 | + if ($dir) { |
|
| 382 | + $dir .= '/'; |
|
| 383 | + } |
|
| 384 | + $dir .= 'procure:' . $procure['nom']; |
|
| 385 | + |
|
| 386 | + $procure['etat'] = '?'; |
|
| 387 | + $procure['dir_type'] = $resume['dir_type']; |
|
| 388 | + $procure['dir'] = $dir; |
|
| 389 | + |
|
| 390 | + // si ce plugin n'est pas deja procure, ou dans une version plus ancienne |
|
| 391 | + // on ajoute cette version a la liste |
|
| 392 | + if ( |
|
| 393 | + !isset($liste[$p]) |
|
| 394 | + or spip_version_compare($procure['version'], $liste[$p]['version'], '>') |
|
| 395 | + ) { |
|
| 396 | + $liste[$p] = $procure; |
|
| 397 | + |
|
| 398 | + // on fournit une information minimale pour ne pas perturber la compilation |
|
| 399 | + $infos[$resume['dir_type']][$dir] = [ |
|
| 400 | + 'prefix' => $procure['nom'], |
|
| 401 | + 'nom' => $procure['nom'], |
|
| 402 | + 'etat' => $procure['etat'], |
|
| 403 | + 'version' => $procure['version'], |
|
| 404 | + 'chemin' => [], |
|
| 405 | + 'necessite' => [], |
|
| 406 | + 'utilise' => [], |
|
| 407 | + 'lib' => [], |
|
| 408 | + 'menu' => [], |
|
| 409 | + 'onglet' => [], |
|
| 410 | + 'procure' => [], |
|
| 411 | + ]; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -426,20 +426,20 @@ discard block |
||
| 426 | 426 | * @return array |
| 427 | 427 | */ |
| 428 | 428 | function liste_chemin_plugin($liste, $dir_plugins = _DIR_PLUGINS) { |
| 429 | - foreach ($liste as $prefix => $infos) { |
|
| 430 | - if ( |
|
| 431 | - !$dir_plugins |
|
| 432 | - or ( |
|
| 433 | - defined($infos['dir_type']) |
|
| 434 | - and constant($infos['dir_type']) == $dir_plugins) |
|
| 435 | - ) { |
|
| 436 | - $liste[$prefix] = $infos['dir']; |
|
| 437 | - } else { |
|
| 438 | - unset($liste[$prefix]); |
|
| 439 | - } |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - return $liste; |
|
| 429 | + foreach ($liste as $prefix => $infos) { |
|
| 430 | + if ( |
|
| 431 | + !$dir_plugins |
|
| 432 | + or ( |
|
| 433 | + defined($infos['dir_type']) |
|
| 434 | + and constant($infos['dir_type']) == $dir_plugins) |
|
| 435 | + ) { |
|
| 436 | + $liste[$prefix] = $infos['dir']; |
|
| 437 | + } else { |
|
| 438 | + unset($liste[$prefix]); |
|
| 439 | + } |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + return $liste; |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -454,9 +454,9 @@ discard block |
||
| 454 | 454 | * @return array |
| 455 | 455 | */ |
| 456 | 456 | function liste_chemin_plugin_actifs($dir_plugins = _DIR_PLUGINS) { |
| 457 | - include_spip('plugins/installer'); |
|
| 457 | + include_spip('plugins/installer'); |
|
| 458 | 458 | |
| 459 | - return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 459 | + return liste_chemin_plugin(liste_plugin_actifs(), $dir_plugins); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | /** |
@@ -487,54 +487,54 @@ discard block |
||
| 487 | 487 | * qui n'ont pas satisfait leurs dépendances |
| 488 | 488 | **/ |
| 489 | 489 | function plugin_trier($infos, $liste_non_classee) { |
| 490 | - $toute_la_liste = $liste_non_classee; |
|
| 491 | - $liste = $ordre = []; |
|
| 492 | - $count = 0; |
|
| 493 | - |
|
| 494 | - while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 495 | - #echo "tour::";var_dump($liste_non_classee); |
|
| 496 | - $count = $c; |
|
| 497 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 498 | - $plug = $resume['dir']; |
|
| 499 | - $dir_type = $resume['dir_type']; |
|
| 500 | - $info1 = $infos[$dir_type][$plug]; |
|
| 501 | - // si des plugins sont necessaires, |
|
| 502 | - // on ne peut inserer qu'apres eux |
|
| 503 | - foreach ($info1['necessite'] as $need) { |
|
| 504 | - $nom = strtoupper($need['nom']); |
|
| 505 | - $compat = $need['compatibilite'] ?? ''; |
|
| 506 | - if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 507 | - $info1 = false; |
|
| 508 | - break; |
|
| 509 | - } |
|
| 510 | - } |
|
| 511 | - if (!$info1) { |
|
| 512 | - continue; |
|
| 513 | - } |
|
| 514 | - // idem si des plugins sont utiles, |
|
| 515 | - // sauf si ils sont de toute facon absents de la liste |
|
| 516 | - foreach ($info1['utilise'] as $need) { |
|
| 517 | - $nom = strtoupper($need['nom']); |
|
| 518 | - $compat = $need['compatibilite'] ?? ''; |
|
| 519 | - if (isset($toute_la_liste[$nom])) { |
|
| 520 | - if ( |
|
| 521 | - !isset($liste[$nom]) or |
|
| 522 | - !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 523 | - ) { |
|
| 524 | - $info1 = false; |
|
| 525 | - break; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - if ($info1) { |
|
| 530 | - $ordre[$p] = $info1; |
|
| 531 | - $liste[$p] = $liste_non_classee[$p]; |
|
| 532 | - unset($liste_non_classee[$p]); |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - return [$liste, $ordre, $liste_non_classee]; |
|
| 490 | + $toute_la_liste = $liste_non_classee; |
|
| 491 | + $liste = $ordre = []; |
|
| 492 | + $count = 0; |
|
| 493 | + |
|
| 494 | + while ($c = count($liste_non_classee) and $c != $count) { // tant qu'il reste des plugins a classer, et qu'on ne stagne pas |
|
| 495 | + #echo "tour::";var_dump($liste_non_classee); |
|
| 496 | + $count = $c; |
|
| 497 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 498 | + $plug = $resume['dir']; |
|
| 499 | + $dir_type = $resume['dir_type']; |
|
| 500 | + $info1 = $infos[$dir_type][$plug]; |
|
| 501 | + // si des plugins sont necessaires, |
|
| 502 | + // on ne peut inserer qu'apres eux |
|
| 503 | + foreach ($info1['necessite'] as $need) { |
|
| 504 | + $nom = strtoupper($need['nom']); |
|
| 505 | + $compat = $need['compatibilite'] ?? ''; |
|
| 506 | + if (!isset($liste[$nom]) or !plugin_version_compatible($compat, $liste[$nom]['version'])) { |
|
| 507 | + $info1 = false; |
|
| 508 | + break; |
|
| 509 | + } |
|
| 510 | + } |
|
| 511 | + if (!$info1) { |
|
| 512 | + continue; |
|
| 513 | + } |
|
| 514 | + // idem si des plugins sont utiles, |
|
| 515 | + // sauf si ils sont de toute facon absents de la liste |
|
| 516 | + foreach ($info1['utilise'] as $need) { |
|
| 517 | + $nom = strtoupper($need['nom']); |
|
| 518 | + $compat = $need['compatibilite'] ?? ''; |
|
| 519 | + if (isset($toute_la_liste[$nom])) { |
|
| 520 | + if ( |
|
| 521 | + !isset($liste[$nom]) or |
|
| 522 | + !plugin_version_compatible($compat, $liste[$nom]['version']) |
|
| 523 | + ) { |
|
| 524 | + $info1 = false; |
|
| 525 | + break; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | + if ($info1) { |
|
| 530 | + $ordre[$p] = $info1; |
|
| 531 | + $liste[$p] = $liste_non_classee[$p]; |
|
| 532 | + unset($liste_non_classee[$p]); |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + return [$liste, $ordre, $liste_non_classee]; |
|
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | /** |
@@ -551,40 +551,40 @@ discard block |
||
| 551 | 551 | * Répertoire (plugins, plugins-dist, ...) => Couples (prefixes => infos completes) des plugins qu'ils contiennent |
| 552 | 552 | **/ |
| 553 | 553 | function plugins_erreurs($liste_non_classee, $liste, $infos, $msg = []) { |
| 554 | - static $erreurs = []; |
|
| 555 | - |
|
| 556 | - if (!is_array($liste)) { |
|
| 557 | - $liste = []; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 561 | - $liste = array_diff_key($liste, $liste_non_classee); |
|
| 562 | - |
|
| 563 | - foreach ($liste_non_classee as $p => $resume) { |
|
| 564 | - $dir_type = $resume['dir_type']; |
|
| 565 | - $plug = $resume['dir']; |
|
| 566 | - $k = $infos[$dir_type][$plug]; |
|
| 567 | - |
|
| 568 | - $plug = constant($dir_type) . $plug; |
|
| 569 | - if (!isset($msg[$p])) { |
|
| 570 | - if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 571 | - $msg[$p] = [$resume['erreur']]; |
|
| 572 | - } |
|
| 573 | - elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 574 | - $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 575 | - } |
|
| 576 | - elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 577 | - $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 578 | - } |
|
| 579 | - } else { |
|
| 580 | - foreach ($msg[$p] as $c => $l) { |
|
| 581 | - $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - $erreurs[$plug] = $msg[$p]; |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 554 | + static $erreurs = []; |
|
| 555 | + |
|
| 556 | + if (!is_array($liste)) { |
|
| 557 | + $liste = []; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + // les plugins en erreur ne sont pas actifs ; ils ne doivent pas être dans la liste |
|
| 561 | + $liste = array_diff_key($liste, $liste_non_classee); |
|
| 562 | + |
|
| 563 | + foreach ($liste_non_classee as $p => $resume) { |
|
| 564 | + $dir_type = $resume['dir_type']; |
|
| 565 | + $plug = $resume['dir']; |
|
| 566 | + $k = $infos[$dir_type][$plug]; |
|
| 567 | + |
|
| 568 | + $plug = constant($dir_type) . $plug; |
|
| 569 | + if (!isset($msg[$p])) { |
|
| 570 | + if (isset($resume['erreur']) and $resume['erreur']) { |
|
| 571 | + $msg[$p] = [$resume['erreur']]; |
|
| 572 | + } |
|
| 573 | + elseif (!plugin_version_compatible($k['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 574 | + $msg[$p] = [plugin_message_incompatibilite($k['compatibilite'], $GLOBALS['spip_version_branche'], 'SPIP', 'necessite')]; |
|
| 575 | + } |
|
| 576 | + elseif (!$msg[$p] = plugin_necessite($k['necessite'], $liste, 'necessite')) { |
|
| 577 | + $msg[$p] = plugin_necessite($k['utilise'], $liste, 'utilise'); |
|
| 578 | + } |
|
| 579 | + } else { |
|
| 580 | + foreach ($msg[$p] as $c => $l) { |
|
| 581 | + $msg[$p][$c] = plugin_controler_lib($l['nom'], $l['lien']); |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + $erreurs[$plug] = $msg[$p]; |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + ecrire_meta('plugin_erreur_activation', serialize($erreurs)); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -599,25 +599,25 @@ discard block |
||
| 599 | 599 | * - Liste des erreurs ou code HTML des erreurs |
| 600 | 600 | **/ |
| 601 | 601 | function plugin_donne_erreurs($raw = false, $raz = true) { |
| 602 | - if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 603 | - return $raw ? [] : ''; |
|
| 604 | - } |
|
| 605 | - $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 606 | - // Compat ancienne version |
|
| 607 | - if (!$list) { |
|
| 608 | - $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 609 | - } elseif (!$raw) { |
|
| 610 | - foreach ($list as $plug => $msg) { |
|
| 611 | - $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | - . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 613 | - } |
|
| 614 | - $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 615 | - } |
|
| 616 | - if ($raz) { |
|
| 617 | - effacer_meta('plugin_erreur_activation'); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - return $list; |
|
| 602 | + if (!isset($GLOBALS['meta']['plugin_erreur_activation'])) { |
|
| 603 | + return $raw ? [] : ''; |
|
| 604 | + } |
|
| 605 | + $list = @unserialize($GLOBALS['meta']['plugin_erreur_activation']); |
|
| 606 | + // Compat ancienne version |
|
| 607 | + if (!$list) { |
|
| 608 | + $list = $raw ? [] : $GLOBALS['meta']['plugin_erreur_activation']; |
|
| 609 | + } elseif (!$raw) { |
|
| 610 | + foreach ($list as $plug => $msg) { |
|
| 611 | + $list[$plug] = '<li>' . _T('plugin_impossible_activer', ['plugin' => $plug]) |
|
| 612 | + . '<ul><li>' . implode('</li><li>', $msg) . '</li></ul></li>'; |
|
| 613 | + } |
|
| 614 | + $list = '<ul>' . join("\n", $list) . '</ul>'; |
|
| 615 | + } |
|
| 616 | + if ($raz) { |
|
| 617 | + effacer_meta('plugin_erreur_activation'); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + return $list; |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -637,21 +637,21 @@ discard block |
||
| 637 | 637 | * |
| 638 | 638 | **/ |
| 639 | 639 | function plugin_necessite($n, $liste, $balise = 'necessite') { |
| 640 | - $msg = []; |
|
| 641 | - foreach ($n as $need) { |
|
| 642 | - $id = strtoupper($need['nom']); |
|
| 643 | - $r = plugin_controler_necessite( |
|
| 644 | - $liste, |
|
| 645 | - $id, |
|
| 646 | - $need['compatibilite'] ?? '', |
|
| 647 | - $balise |
|
| 648 | - ); |
|
| 649 | - if ($r) { |
|
| 650 | - $msg[] = $r; |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - return $msg; |
|
| 640 | + $msg = []; |
|
| 641 | + foreach ($n as $need) { |
|
| 642 | + $id = strtoupper($need['nom']); |
|
| 643 | + $r = plugin_controler_necessite( |
|
| 644 | + $liste, |
|
| 645 | + $id, |
|
| 646 | + $need['compatibilite'] ?? '', |
|
| 647 | + $balise |
|
| 648 | + ); |
|
| 649 | + if ($r) { |
|
| 650 | + $msg[] = $r; |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + return $msg; |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | /** |
@@ -673,19 +673,19 @@ discard block |
||
| 673 | 673 | * Message d'erreur lorsque la dépendance est absente. |
| 674 | 674 | **/ |
| 675 | 675 | function plugin_controler_necessite($liste, $nom, $intervalle, $balise) { |
| 676 | - if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 677 | - return ''; |
|
| 678 | - } |
|
| 679 | - // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 680 | - if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 681 | - return ''; |
|
| 682 | - } |
|
| 683 | - return plugin_message_incompatibilite( |
|
| 684 | - $intervalle, |
|
| 685 | - (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 686 | - $nom, |
|
| 687 | - $balise |
|
| 688 | - ); |
|
| 676 | + if (isset($liste[$nom]) and plugin_version_compatible($intervalle, $liste[$nom]['version'])) { |
|
| 677 | + return ''; |
|
| 678 | + } |
|
| 679 | + // Si l'on a un <utilise="plugin non actif" />, ne pas renvoyer d'erreur |
|
| 680 | + if ($balise === 'utilise' and !isset($liste[$nom])) { |
|
| 681 | + return ''; |
|
| 682 | + } |
|
| 683 | + return plugin_message_incompatibilite( |
|
| 684 | + $intervalle, |
|
| 685 | + (isset($liste[$nom]) ? $liste[$nom]['version'] : ''), |
|
| 686 | + $nom, |
|
| 687 | + $balise |
|
| 688 | + ); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -702,70 +702,70 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | function plugin_message_incompatibilite($intervalle, $version, $nom, $balise) { |
| 704 | 704 | |
| 705 | - // prendre en compte les erreurs de dépendances à PHP |
|
| 706 | - // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 707 | - $type = 'plugin'; |
|
| 708 | - if ($nom === 'SPIP') { |
|
| 709 | - $type = 'spip'; |
|
| 710 | - } elseif ($nom === 'PHP') { |
|
| 711 | - $type = 'php'; |
|
| 712 | - } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 713 | - $type = 'extension_php'; |
|
| 714 | - [, $nom] = explode(':', $nom, 2); |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 718 | - $minimum = $regs[1]; |
|
| 719 | - $maximum = $regs[2]; |
|
| 720 | - |
|
| 721 | - $minimum_inclus = $intervalle[0] == '['; |
|
| 722 | - $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 723 | - |
|
| 724 | - if (strlen($minimum)) { |
|
| 725 | - if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 726 | - return _T("plugin_${balise}_${type}", [ |
|
| 727 | - 'plugin' => $nom, |
|
| 728 | - 'version' => ' ≥ ' . $minimum |
|
| 729 | - ]); |
|
| 730 | - } |
|
| 731 | - if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 732 | - return _T("plugin_${balise}_${type}", [ |
|
| 733 | - 'plugin' => $nom, |
|
| 734 | - 'version' => ' > ' . $minimum |
|
| 735 | - ]); |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - |
|
| 739 | - if (strlen($maximum)) { |
|
| 740 | - if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 741 | - return _T("plugin_${balise}_${type}", [ |
|
| 742 | - 'plugin' => $nom, |
|
| 743 | - 'version' => ' ≤ ' . $maximum |
|
| 744 | - ]); |
|
| 745 | - } |
|
| 746 | - if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 747 | - return _T("plugin_${balise}_plugin", [ |
|
| 748 | - 'plugin' => $nom, |
|
| 749 | - 'version' => ' < ' . $maximum |
|
| 750 | - ]); |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - // note : il ne peut pas y avoir d'erreur sur |
|
| 756 | - // - un 'utilise' sans version. |
|
| 757 | - // - un 'php' sans version. |
|
| 758 | - return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]); |
|
| 705 | + // prendre en compte les erreurs de dépendances à PHP |
|
| 706 | + // ou à une extension PHP avec des messages d'erreurs dédiés. |
|
| 707 | + $type = 'plugin'; |
|
| 708 | + if ($nom === 'SPIP') { |
|
| 709 | + $type = 'spip'; |
|
| 710 | + } elseif ($nom === 'PHP') { |
|
| 711 | + $type = 'php'; |
|
| 712 | + } elseif (strncmp($nom, 'PHP:', 4) === 0) { |
|
| 713 | + $type = 'extension_php'; |
|
| 714 | + [, $nom] = explode(':', $nom, 2); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + if (preg_match(_EXTRAIRE_INTERVALLE, $intervalle, $regs)) { |
|
| 718 | + $minimum = $regs[1]; |
|
| 719 | + $maximum = $regs[2]; |
|
| 720 | + |
|
| 721 | + $minimum_inclus = $intervalle[0] == '['; |
|
| 722 | + $maximum_inclus = substr($intervalle, -1) == ']'; |
|
| 723 | + |
|
| 724 | + if (strlen($minimum)) { |
|
| 725 | + if ($minimum_inclus and spip_version_compare($version, $minimum, '<')) { |
|
| 726 | + return _T("plugin_${balise}_${type}", [ |
|
| 727 | + 'plugin' => $nom, |
|
| 728 | + 'version' => ' ≥ ' . $minimum |
|
| 729 | + ]); |
|
| 730 | + } |
|
| 731 | + if (!$minimum_inclus and spip_version_compare($version, $minimum, '<=')) { |
|
| 732 | + return _T("plugin_${balise}_${type}", [ |
|
| 733 | + 'plugin' => $nom, |
|
| 734 | + 'version' => ' > ' . $minimum |
|
| 735 | + ]); |
|
| 736 | + } |
|
| 737 | + } |
|
| 738 | + |
|
| 739 | + if (strlen($maximum)) { |
|
| 740 | + if ($maximum_inclus and spip_version_compare($version, $maximum, '>')) { |
|
| 741 | + return _T("plugin_${balise}_${type}", [ |
|
| 742 | + 'plugin' => $nom, |
|
| 743 | + 'version' => ' ≤ ' . $maximum |
|
| 744 | + ]); |
|
| 745 | + } |
|
| 746 | + if (!$maximum_inclus and spip_version_compare($version, $maximum, '>=')) { |
|
| 747 | + return _T("plugin_${balise}_plugin", [ |
|
| 748 | + 'plugin' => $nom, |
|
| 749 | + 'version' => ' < ' . $maximum |
|
| 750 | + ]); |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + // note : il ne peut pas y avoir d'erreur sur |
|
| 756 | + // - un 'utilise' sans version. |
|
| 757 | + // - un 'php' sans version. |
|
| 758 | + return _T("plugin_necessite_${type}_sans_version", ['plugin' => $nom]); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | |
| 762 | 762 | function plugin_controler_lib($lib, $url) { |
| 763 | - /* Feature sortie du core, voir STP |
|
| 763 | + /* Feature sortie du core, voir STP |
|
| 764 | 764 | * if ($url) { |
| 765 | 765 | include_spip('inc/charger_plugin'); |
| 766 | 766 | $url = '<br />' . bouton_telechargement_plugin($url, 'lib'); |
| 767 | 767 | }*/ |
| 768 | - return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 768 | + return _T('plugin_necessite_lib', ['lib' => $lib]) . " <a href='$url'>$url</a>"; |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * true si il y a eu des modifications sur la liste des plugins actifs, false sinon |
| 781 | 781 | **/ |
| 782 | 782 | function actualise_plugins_actifs($pipe_recherche = false) { |
| 783 | - return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 783 | + return ecrire_plugin_actifs('', $pipe_recherche, 'force'); |
|
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | |
@@ -807,116 +807,116 @@ discard block |
||
| 807 | 807 | **/ |
| 808 | 808 | function ecrire_plugin_actifs($plugin, $pipe_recherche = false, $operation = 'raz') { |
| 809 | 809 | |
| 810 | - // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 811 | - $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 812 | - |
|
| 813 | - // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 814 | - if (!$cache and !spip_connect()) { |
|
| 815 | - return false; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - if ($operation != 'raz') { |
|
| 819 | - $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 820 | - $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 821 | - if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 822 | - $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 823 | - $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 824 | - $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 825 | - } |
|
| 826 | - // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 827 | - // on les reinjecte ici |
|
| 828 | - if ( |
|
| 829 | - isset($GLOBALS['meta']['plugin_attente']) |
|
| 830 | - and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 831 | - ) { |
|
| 832 | - $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - if ($operation == 'ajoute') { |
|
| 836 | - $plugin = array_merge($plugin_valides, $plugin); |
|
| 837 | - } elseif ($operation == 'enleve') { |
|
| 838 | - $plugin = array_diff($plugin_valides, $plugin); |
|
| 839 | - } else { |
|
| 840 | - $plugin = $plugin_valides; |
|
| 841 | - } |
|
| 842 | - } |
|
| 843 | - $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 844 | - |
|
| 845 | - // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 846 | - if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 847 | - $plugin = $ajouter_dependances($plugin); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - // recharger le xml des plugins a activer |
|
| 851 | - // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 852 | - // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 853 | - // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 854 | - // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 855 | - [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 856 | - // trouver l'ordre d'activation |
|
| 857 | - [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 858 | - if ($invalides or $reste) { |
|
| 859 | - plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - // Ignorer les plugins necessitant une lib absente |
|
| 863 | - // et preparer la meta d'entete Http |
|
| 864 | - $err = $msg = $header = []; |
|
| 865 | - foreach ($plugin_valides as $p => $resume) { |
|
| 866 | - // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 867 | - if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 868 | - $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 869 | - } |
|
| 870 | - if ($resume['dir']) { |
|
| 871 | - foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 872 | - if (!find_in_path($l['nom'], 'lib/')) { |
|
| 873 | - $err[$p] = $resume; |
|
| 874 | - $msg[$p][] = $l; |
|
| 875 | - unset($plugin_valides[$p]); |
|
| 876 | - } |
|
| 877 | - } |
|
| 878 | - } |
|
| 879 | - } |
|
| 880 | - if ($err) { |
|
| 881 | - plugins_erreurs($err, '', $infos, $msg); |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 885 | - effacer_meta('message_crash_plugins'); |
|
| 886 | - } |
|
| 887 | - ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 888 | - $liste = array_diff_key($liste, $plugin_valides); |
|
| 889 | - ecrire_meta('plugin_attente', serialize($liste)); |
|
| 890 | - $header = strtolower(implode(',', $header)); |
|
| 891 | - if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 892 | - ecrire_fichier( |
|
| 893 | - _DIR_VAR . 'config.txt', |
|
| 894 | - (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 895 | - ); |
|
| 896 | - } else { |
|
| 897 | - @unlink(_DIR_VAR . 'config.txt'); |
|
| 898 | - } |
|
| 899 | - // generer charger_plugins_chemin.php |
|
| 900 | - plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 901 | - // generer les fichiers |
|
| 902 | - // - charger_plugins_options.php |
|
| 903 | - // - charger_plugins_fonctions.php |
|
| 904 | - plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 905 | - // charger les chemins des plugins et les fichiers d'options |
|
| 906 | - // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 907 | - plugins_amorcer_plugins_actifs(); |
|
| 908 | - // mise a jour de la matrice des pipelines |
|
| 909 | - $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 910 | - // generer le fichier _CACHE_PIPELINE |
|
| 911 | - pipeline_precompile($prepend_code); |
|
| 912 | - |
|
| 913 | - if (spip_connect()) { |
|
| 914 | - // lancer et initialiser les nouveaux crons ! |
|
| 915 | - include_spip('inc/genie'); |
|
| 916 | - genie_queue_watch_dist(); |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 810 | + // creer le repertoire cache/ si necessaire ! (installation notamment) |
|
| 811 | + $cache = sous_repertoire(_DIR_CACHE, '', false, true); |
|
| 812 | + |
|
| 813 | + // Si on n'a ni cache accessible, ni connexion SQL, on ne peut pas faire grand chose encore. |
|
| 814 | + if (!$cache and !spip_connect()) { |
|
| 815 | + return false; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + if ($operation != 'raz') { |
|
| 819 | + $plugin_valides = liste_chemin_plugin_actifs(); |
|
| 820 | + $plugin_valides = is_plugin_dir($plugin_valides); |
|
| 821 | + if (defined('_DIR_PLUGINS_SUPPL') && _DIR_PLUGINS_SUPPL) { |
|
| 822 | + $plugin_valides_supp = liste_chemin_plugin_actifs(_DIR_PLUGINS_SUPPL); |
|
| 823 | + $plugin_valides_supp = is_plugin_dir($plugin_valides_supp, _DIR_PLUGINS_SUPPL); |
|
| 824 | + $plugin_valides = array_merge($plugin_valides, $plugin_valides_supp); |
|
| 825 | + } |
|
| 826 | + // si des plugins sont en attentes (coches mais impossible a activer) |
|
| 827 | + // on les reinjecte ici |
|
| 828 | + if ( |
|
| 829 | + isset($GLOBALS['meta']['plugin_attente']) |
|
| 830 | + and $a = unserialize($GLOBALS['meta']['plugin_attente']) |
|
| 831 | + ) { |
|
| 832 | + $plugin_valides = $plugin_valides + liste_chemin_plugin($a); |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + if ($operation == 'ajoute') { |
|
| 836 | + $plugin = array_merge($plugin_valides, $plugin); |
|
| 837 | + } elseif ($operation == 'enleve') { |
|
| 838 | + $plugin = array_diff($plugin_valides, $plugin); |
|
| 839 | + } else { |
|
| 840 | + $plugin = $plugin_valides; |
|
| 841 | + } |
|
| 842 | + } |
|
| 843 | + $actifs_avant = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 844 | + |
|
| 845 | + // si une fonction de gestion de dependances existe, l'appeler ici |
|
| 846 | + if ($ajouter_dependances = charger_fonction('ajouter_dependances', 'plugins', true)) { |
|
| 847 | + $plugin = $ajouter_dependances($plugin); |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + // recharger le xml des plugins a activer |
|
| 851 | + // on force le reload ici, meme si le fichier xml n'a pas change |
|
| 852 | + // pour ne pas rater l'ajout ou la suppression d'un fichier fonctions/options/administrations |
|
| 853 | + // pourra etre evite quand on ne supportera plus les plugin.xml |
|
| 854 | + // en deplacant la detection de ces fichiers dans la compilation ci dessous |
|
| 855 | + [$infos, $liste, $invalides] = liste_plugin_valides($plugin, true); |
|
| 856 | + // trouver l'ordre d'activation |
|
| 857 | + [$plugin_valides, $ordre, $reste] = plugin_trier($infos, $liste); |
|
| 858 | + if ($invalides or $reste) { |
|
| 859 | + plugins_erreurs(array_merge($invalides, $reste), $liste, $infos); |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + // Ignorer les plugins necessitant une lib absente |
|
| 863 | + // et preparer la meta d'entete Http |
|
| 864 | + $err = $msg = $header = []; |
|
| 865 | + foreach ($plugin_valides as $p => $resume) { |
|
| 866 | + // Les headers ne doivent pas indiquer les versions des extensions PHP, ni la version PHP |
|
| 867 | + if (0 !== strpos($p, 'PHP:') and $p !== 'PHP') { |
|
| 868 | + $header[] = $p . ($resume['version'] ? '(' . $resume['version'] . ')' : ''); |
|
| 869 | + } |
|
| 870 | + if ($resume['dir']) { |
|
| 871 | + foreach ($infos[$resume['dir_type']][$resume['dir']]['lib'] as $l) { |
|
| 872 | + if (!find_in_path($l['nom'], 'lib/')) { |
|
| 873 | + $err[$p] = $resume; |
|
| 874 | + $msg[$p][] = $l; |
|
| 875 | + unset($plugin_valides[$p]); |
|
| 876 | + } |
|
| 877 | + } |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | + if ($err) { |
|
| 881 | + plugins_erreurs($err, '', $infos, $msg); |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + if (isset($GLOBALS['meta']['message_crash_plugins'])) { |
|
| 885 | + effacer_meta('message_crash_plugins'); |
|
| 886 | + } |
|
| 887 | + ecrire_meta('plugin', serialize($plugin_valides)); |
|
| 888 | + $liste = array_diff_key($liste, $plugin_valides); |
|
| 889 | + ecrire_meta('plugin_attente', serialize($liste)); |
|
| 890 | + $header = strtolower(implode(',', $header)); |
|
| 891 | + if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) { |
|
| 892 | + ecrire_fichier( |
|
| 893 | + _DIR_VAR . 'config.txt', |
|
| 894 | + (defined('_HEADER_COMPOSED_BY') ? _HEADER_COMPOSED_BY : 'Composed-By: SPIP') . ' ' . $GLOBALS['spip_version_affichee'] . ' @ www.spip.net + ' . $header |
|
| 895 | + ); |
|
| 896 | + } else { |
|
| 897 | + @unlink(_DIR_VAR . 'config.txt'); |
|
| 898 | + } |
|
| 899 | + // generer charger_plugins_chemin.php |
|
| 900 | + plugins_precompile_chemin($plugin_valides, $ordre); |
|
| 901 | + // generer les fichiers |
|
| 902 | + // - charger_plugins_options.php |
|
| 903 | + // - charger_plugins_fonctions.php |
|
| 904 | + plugins_precompile_xxxtions($plugin_valides, $ordre); |
|
| 905 | + // charger les chemins des plugins et les fichiers d'options |
|
| 906 | + // (qui peuvent déclarer / utiliser des pipelines, ajouter d'autres chemins) |
|
| 907 | + plugins_amorcer_plugins_actifs(); |
|
| 908 | + // mise a jour de la matrice des pipelines |
|
| 909 | + $prepend_code = pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche); |
|
| 910 | + // generer le fichier _CACHE_PIPELINE |
|
| 911 | + pipeline_precompile($prepend_code); |
|
| 912 | + |
|
| 913 | + if (spip_connect()) { |
|
| 914 | + // lancer et initialiser les nouveaux crons ! |
|
| 915 | + include_spip('inc/genie'); |
|
| 916 | + genie_queue_watch_dist(); |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + return ($GLOBALS['meta']['plugin'] != $actifs_avant); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -935,74 +935,74 @@ discard block |
||
| 935 | 935 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 936 | 936 | **/ |
| 937 | 937 | function plugins_precompile_chemin($plugin_valides, $ordre) { |
| 938 | - $chemins = [ |
|
| 939 | - 'public' => [], |
|
| 940 | - 'prive' => [] |
|
| 941 | - ]; |
|
| 942 | - $contenu = ''; |
|
| 943 | - foreach ($ordre as $p => $info) { |
|
| 944 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 945 | - if (isset($plugin_valides[$p])) { |
|
| 946 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 947 | - $plug = $plugin_valides[$p]['dir']; |
|
| 948 | - // definir le plugin, donc le path avant l'include du fichier options |
|
| 949 | - // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 950 | - |
|
| 951 | - $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 952 | - |
|
| 953 | - $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 954 | - if ( |
|
| 955 | - $prefix !== 'SPIP' |
|
| 956 | - and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 957 | - ) { |
|
| 958 | - $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 959 | - if (!$info['chemin']) { |
|
| 960 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 961 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 962 | - if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 963 | - $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 964 | - } |
|
| 965 | - } |
|
| 966 | - else { |
|
| 967 | - foreach ($info['chemin'] as $chemin) { |
|
| 968 | - if ( |
|
| 969 | - !isset($chemin['version']) or plugin_version_compatible( |
|
| 970 | - $chemin['version'], |
|
| 971 | - $GLOBALS['spip_version_branche'], |
|
| 972 | - 'spip' |
|
| 973 | - ) |
|
| 974 | - ) { |
|
| 975 | - $dir = $chemin['path']; |
|
| 976 | - if (strlen($dir) and $dir[0] == '/') { |
|
| 977 | - $dir = substr($dir, 1); |
|
| 978 | - } |
|
| 979 | - if (strlen($dir) and $dir == './') { |
|
| 980 | - $dir = ''; |
|
| 981 | - } |
|
| 982 | - if (strlen($dir)) { |
|
| 983 | - $dir = rtrim($dir, '/') . '/'; |
|
| 984 | - } |
|
| 985 | - if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 986 | - $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | - } |
|
| 988 | - if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 989 | - $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | - } |
|
| 991 | - } |
|
| 992 | - } |
|
| 993 | - } |
|
| 994 | - } |
|
| 995 | - } |
|
| 996 | - } |
|
| 997 | - if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 998 | - $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 999 | - ',', |
|
| 1000 | - array_reverse($chemins['public']) |
|
| 1001 | - ) . "]);\n" |
|
| 1002 | - . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1003 | - } |
|
| 1004 | - |
|
| 1005 | - ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 938 | + $chemins = [ |
|
| 939 | + 'public' => [], |
|
| 940 | + 'prive' => [] |
|
| 941 | + ]; |
|
| 942 | + $contenu = ''; |
|
| 943 | + foreach ($ordre as $p => $info) { |
|
| 944 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 945 | + if (isset($plugin_valides[$p])) { |
|
| 946 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 947 | + $plug = $plugin_valides[$p]['dir']; |
|
| 948 | + // definir le plugin, donc le path avant l'include du fichier options |
|
| 949 | + // permet de faire des include_spip pour attraper un inc_ du plugin |
|
| 950 | + |
|
| 951 | + $dir = $dir_type . ".'" . $plug . "/'"; |
|
| 952 | + |
|
| 953 | + $prefix = strtoupper(preg_replace(',\W,', '_', $info['prefix'])); |
|
| 954 | + if ( |
|
| 955 | + $prefix !== 'SPIP' |
|
| 956 | + and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 957 | + ) { |
|
| 958 | + $contenu .= "define('_DIR_PLUGIN_$prefix',$dir);\n"; |
|
| 959 | + if (!$info['chemin']) { |
|
| 960 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix"; |
|
| 961 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix"; |
|
| 962 | + if (is_dir(constant($dir_type) . $plug . '/squelettes/')) { |
|
| 963 | + $chemins['public'][] = "_DIR_PLUGIN_{$prefix}.'squelettes/'"; |
|
| 964 | + } |
|
| 965 | + } |
|
| 966 | + else { |
|
| 967 | + foreach ($info['chemin'] as $chemin) { |
|
| 968 | + if ( |
|
| 969 | + !isset($chemin['version']) or plugin_version_compatible( |
|
| 970 | + $chemin['version'], |
|
| 971 | + $GLOBALS['spip_version_branche'], |
|
| 972 | + 'spip' |
|
| 973 | + ) |
|
| 974 | + ) { |
|
| 975 | + $dir = $chemin['path']; |
|
| 976 | + if (strlen($dir) and $dir[0] == '/') { |
|
| 977 | + $dir = substr($dir, 1); |
|
| 978 | + } |
|
| 979 | + if (strlen($dir) and $dir == './') { |
|
| 980 | + $dir = ''; |
|
| 981 | + } |
|
| 982 | + if (strlen($dir)) { |
|
| 983 | + $dir = rtrim($dir, '/') . '/'; |
|
| 984 | + } |
|
| 985 | + if (!isset($chemin['type']) or $chemin['type'] == 'public') { |
|
| 986 | + $chemins['public'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 987 | + } |
|
| 988 | + if (!isset($chemin['type']) or $chemin['type'] == 'prive') { |
|
| 989 | + $chemins['prive'][] = "_DIR_PLUGIN_$prefix" . (strlen($dir) ? ".'$dir'" : ''); |
|
| 990 | + } |
|
| 991 | + } |
|
| 992 | + } |
|
| 993 | + } |
|
| 994 | + } |
|
| 995 | + } |
|
| 996 | + } |
|
| 997 | + if (count($chemins['public']) or count($chemins['prive'])) { |
|
| 998 | + $contenu .= 'if (_DIR_RESTREINT) _chemin([' . implode( |
|
| 999 | + ',', |
|
| 1000 | + array_reverse($chemins['public']) |
|
| 1001 | + ) . "]);\n" |
|
| 1002 | + . 'else _chemin([' . implode(',', array_reverse($chemins['prive'])) . "]);\n"; |
|
| 1003 | + } |
|
| 1004 | + |
|
| 1005 | + ecrire_fichier_php(_CACHE_PLUGINS_PATH, $contenu); |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /** |
@@ -1020,67 +1020,67 @@ discard block |
||
| 1020 | 1020 | * Couples (prefixe => infos complètes) des plugins qui seront actifs, dans l'ordre de leurs dépendances |
| 1021 | 1021 | **/ |
| 1022 | 1022 | function plugins_precompile_xxxtions($plugin_valides, $ordre) { |
| 1023 | - $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1024 | - $boutons = []; |
|
| 1025 | - $onglets = []; |
|
| 1026 | - $sign = ''; |
|
| 1027 | - |
|
| 1028 | - foreach ($ordre as $p => $info) { |
|
| 1029 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1030 | - if (isset($plugin_valides[$p])) { |
|
| 1031 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1032 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1033 | - $dir = constant($dir_type); |
|
| 1034 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1035 | - if ($info['menu']) { |
|
| 1036 | - $boutons = array_merge($boutons, $info['menu']); |
|
| 1037 | - } |
|
| 1038 | - if ($info['onglet']) { |
|
| 1039 | - $onglets = array_merge($onglets, $info['onglet']); |
|
| 1040 | - } |
|
| 1041 | - foreach ($contenu as $charge => $v) { |
|
| 1042 | - // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1043 | - // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1044 | - // donc ni sa relecture, ni sa detection |
|
| 1045 | - if ( |
|
| 1046 | - !isset($info[$charge]) |
|
| 1047 | - and $dir // exclure le cas du plugin "SPIP" |
|
| 1048 | - and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 1049 | - and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1050 | - ) { |
|
| 1051 | - if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1052 | - $info[$charge] = [$file]; |
|
| 1053 | - } |
|
| 1054 | - } |
|
| 1055 | - if (isset($info[$charge])) { |
|
| 1056 | - $files = $info[$charge]; |
|
| 1057 | - foreach ($files as $k => $file) { |
|
| 1058 | - // on genere un if file_exists devant chaque include |
|
| 1059 | - // pour pouvoir garder le meme niveau d'erreur general |
|
| 1060 | - $file = trim($file); |
|
| 1061 | - if ( |
|
| 1062 | - !is_readable("$dir$plug/$file") |
|
| 1063 | - // uniquement pour les paquet.xml |
|
| 1064 | - and file_exists("$dir$plug/paquet.xml") |
|
| 1065 | - ) { |
|
| 1066 | - unset($info[$charge][$k]); |
|
| 1067 | - } else { |
|
| 1068 | - $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1069 | - $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1070 | - } |
|
| 1071 | - } |
|
| 1072 | - } |
|
| 1073 | - } |
|
| 1074 | - $sign .= md5(serialize($info)); |
|
| 1075 | - } |
|
| 1076 | - } |
|
| 1077 | - |
|
| 1078 | - $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1079 | - $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1080 | - . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1081 | - |
|
| 1082 | - ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1083 | - ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1023 | + $contenu = ['options' => '', 'fonctions' => '']; |
|
| 1024 | + $boutons = []; |
|
| 1025 | + $onglets = []; |
|
| 1026 | + $sign = ''; |
|
| 1027 | + |
|
| 1028 | + foreach ($ordre as $p => $info) { |
|
| 1029 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1030 | + if (isset($plugin_valides[$p])) { |
|
| 1031 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1032 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1033 | + $dir = constant($dir_type); |
|
| 1034 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1035 | + if ($info['menu']) { |
|
| 1036 | + $boutons = array_merge($boutons, $info['menu']); |
|
| 1037 | + } |
|
| 1038 | + if ($info['onglet']) { |
|
| 1039 | + $onglets = array_merge($onglets, $info['onglet']); |
|
| 1040 | + } |
|
| 1041 | + foreach ($contenu as $charge => $v) { |
|
| 1042 | + // si pas declare/detecte a la lecture du paquet.xml, |
|
| 1043 | + // detecer a nouveau ici puisque son ajout ne provoque pas une modif du paquet.xml |
|
| 1044 | + // donc ni sa relecture, ni sa detection |
|
| 1045 | + if ( |
|
| 1046 | + !isset($info[$charge]) |
|
| 1047 | + and $dir // exclure le cas du plugin "SPIP" |
|
| 1048 | + and strpos($dir, ':') === false // exclure le cas des procure: |
|
| 1049 | + and file_exists("$dir$plug/paquet.xml") // uniquement pour les paquet.xml |
|
| 1050 | + ) { |
|
| 1051 | + if (is_readable("$dir$plug/" . ($file = $info['prefix'] . '_' . $charge . '.php'))) { |
|
| 1052 | + $info[$charge] = [$file]; |
|
| 1053 | + } |
|
| 1054 | + } |
|
| 1055 | + if (isset($info[$charge])) { |
|
| 1056 | + $files = $info[$charge]; |
|
| 1057 | + foreach ($files as $k => $file) { |
|
| 1058 | + // on genere un if file_exists devant chaque include |
|
| 1059 | + // pour pouvoir garder le meme niveau d'erreur general |
|
| 1060 | + $file = trim($file); |
|
| 1061 | + if ( |
|
| 1062 | + !is_readable("$dir$plug/$file") |
|
| 1063 | + // uniquement pour les paquet.xml |
|
| 1064 | + and file_exists("$dir$plug/paquet.xml") |
|
| 1065 | + ) { |
|
| 1066 | + unset($info[$charge][$k]); |
|
| 1067 | + } else { |
|
| 1068 | + $_file = $root_dir_type . ".'$plug/$file'"; |
|
| 1069 | + $contenu[$charge] .= "include_once_check($_file);\n"; |
|
| 1070 | + } |
|
| 1071 | + } |
|
| 1072 | + } |
|
| 1073 | + } |
|
| 1074 | + $sign .= md5(serialize($info)); |
|
| 1075 | + } |
|
| 1076 | + } |
|
| 1077 | + |
|
| 1078 | + $contenu['options'] = "define('_PLUGINS_HASH','" . md5($sign) . "');\n" . $contenu['options']; |
|
| 1079 | + $contenu['fonctions'] .= plugin_ongletbouton('boutons_plugins', $boutons) |
|
| 1080 | + . plugin_ongletbouton('onglets_plugins', $onglets); |
|
| 1081 | + |
|
| 1082 | + ecrire_fichier_php(_CACHE_PLUGINS_OPT, $contenu['options']); |
|
| 1083 | + ecrire_fichier_php(_CACHE_PLUGINS_FCT, $contenu['fonctions']); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
@@ -1099,24 +1099,24 @@ discard block |
||
| 1099 | 1099 | * @return string Code php |
| 1100 | 1100 | */ |
| 1101 | 1101 | function plugin_ongletbouton($nom, $val) { |
| 1102 | - if (!$val) { |
|
| 1103 | - $val = []; |
|
| 1104 | - } |
|
| 1105 | - |
|
| 1106 | - $val = serialize($val); |
|
| 1107 | - $md5 = md5($val); |
|
| 1108 | - |
|
| 1109 | - if (!defined("_UPDATED_$nom")) { |
|
| 1110 | - define("_UPDATED_$nom", $val); |
|
| 1111 | - define("_UPDATED_md5_$nom", $md5); |
|
| 1112 | - } |
|
| 1113 | - $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1114 | - |
|
| 1115 | - return |
|
| 1116 | - "if (!function_exists('$nom')) {\n" |
|
| 1117 | - . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1118 | - . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1119 | - . "}\n"; |
|
| 1102 | + if (!$val) { |
|
| 1103 | + $val = []; |
|
| 1104 | + } |
|
| 1105 | + |
|
| 1106 | + $val = serialize($val); |
|
| 1107 | + $md5 = md5($val); |
|
| 1108 | + |
|
| 1109 | + if (!defined("_UPDATED_$nom")) { |
|
| 1110 | + define("_UPDATED_$nom", $val); |
|
| 1111 | + define("_UPDATED_md5_$nom", $md5); |
|
| 1112 | + } |
|
| 1113 | + $val = "unserialize('" . str_replace("'", "\'", $val) . "')"; |
|
| 1114 | + |
|
| 1115 | + return |
|
| 1116 | + "if (!function_exists('$nom')) {\n" |
|
| 1117 | + . "function $nom(){return defined('_UPDATED_$nom')?unserialize(_UPDATED_$nom):$val;}\n" |
|
| 1118 | + . "function md5_$nom(){return defined('_UPDATED_md5_$nom')?_UPDATED_md5_$nom:'" . $md5 . "';}\n" |
|
| 1119 | + . "}\n"; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | /** |
@@ -1131,15 +1131,15 @@ discard block |
||
| 1131 | 1131 | **/ |
| 1132 | 1132 | function plugins_amorcer_plugins_actifs() { |
| 1133 | 1133 | |
| 1134 | - if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1135 | - include_once(_CACHE_PLUGINS_PATH); |
|
| 1136 | - } |
|
| 1134 | + if (@is_readable(_CACHE_PLUGINS_PATH)) { |
|
| 1135 | + include_once(_CACHE_PLUGINS_PATH); |
|
| 1136 | + } |
|
| 1137 | 1137 | |
| 1138 | - if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1139 | - include_once(_CACHE_PLUGINS_OPT); |
|
| 1140 | - } else { |
|
| 1141 | - spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1142 | - } |
|
| 1138 | + if (@is_readable(_CACHE_PLUGINS_OPT)) { |
|
| 1139 | + include_once(_CACHE_PLUGINS_OPT); |
|
| 1140 | + } else { |
|
| 1141 | + spip_log('pipelines desactives: impossible de produire ' . _CACHE_PLUGINS_OPT); |
|
| 1142 | + } |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | /** |
@@ -1162,140 +1162,140 @@ discard block |
||
| 1162 | 1162 | * Couples (nom du pipeline => Code PHP à insérer au début du pipeline) |
| 1163 | 1163 | **/ |
| 1164 | 1164 | function pipeline_matrice_precompile($plugin_valides, $ordre, $pipe_recherche) { |
| 1165 | - static $liste_pipe_manquants = []; |
|
| 1166 | - if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1167 | - $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - $prepend_code = []; |
|
| 1171 | - |
|
| 1172 | - foreach ($ordre as $p => $info) { |
|
| 1173 | - // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1174 | - if (isset($plugin_valides[$p])) { |
|
| 1175 | - $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1176 | - $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1177 | - $plug = $plugin_valides[$p]['dir']; |
|
| 1178 | - $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1179 | - if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1180 | - foreach ($info['pipeline'] as $pipe) { |
|
| 1181 | - $nom = $pipe['nom']; |
|
| 1182 | - if (isset($pipe['action'])) { |
|
| 1183 | - $action = $pipe['action']; |
|
| 1184 | - } else { |
|
| 1185 | - $action = $nom; |
|
| 1186 | - } |
|
| 1187 | - $nomlower = strtolower($nom); |
|
| 1188 | - if ( |
|
| 1189 | - $nomlower != $nom |
|
| 1190 | - and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1191 | - and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1192 | - ) { |
|
| 1193 | - $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1194 | - unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1195 | - } |
|
| 1196 | - $nom = $nomlower; |
|
| 1197 | - // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1198 | - if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1199 | - $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1200 | - } |
|
| 1201 | - if ($action) { |
|
| 1202 | - if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1203 | - $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1204 | - ',(\|\||$),', |
|
| 1205 | - "|$prefix$action\\1", |
|
| 1206 | - $GLOBALS['spip_pipeline'][$nom], |
|
| 1207 | - 1 |
|
| 1208 | - ); |
|
| 1209 | - } |
|
| 1210 | - if (isset($pipe['inclure'])) { |
|
| 1211 | - $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1212 | - "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1213 | - } |
|
| 1214 | - } |
|
| 1215 | - } |
|
| 1216 | - } |
|
| 1217 | - if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1218 | - if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1219 | - $prepend_code['taches_generales_cron'] = ''; |
|
| 1220 | - } |
|
| 1221 | - foreach ($info['genie'] as $genie) { |
|
| 1222 | - $nom = $prefix . $genie['nom']; |
|
| 1223 | - $periode = max(60, intval($genie['periode'])); |
|
| 1224 | - if (charger_fonction($nom, 'genie', true)) { |
|
| 1225 | - $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1226 | - } else { |
|
| 1227 | - spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1228 | - } |
|
| 1229 | - } |
|
| 1230 | - } |
|
| 1231 | - if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1232 | - if (!isset($prepend_code['insert_head_css'])) { |
|
| 1233 | - $prepend_code['insert_head_css'] = ''; |
|
| 1234 | - } |
|
| 1235 | - if (!isset($prepend_code['header_prive_css'])) { |
|
| 1236 | - $prepend_code['header_prive_css'] = ''; |
|
| 1237 | - } |
|
| 1238 | - foreach ($info['style'] as $style) { |
|
| 1239 | - if (isset($style['path']) and $style['path']) { |
|
| 1240 | - $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1241 | - } else { |
|
| 1242 | - $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1243 | - } |
|
| 1244 | - $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1245 | - if (isset($style['media']) and strlen($style['media'])) { |
|
| 1246 | - $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1247 | - } |
|
| 1248 | - $code .= "/>';\n"; |
|
| 1249 | - if ($style['type'] != 'prive') { |
|
| 1250 | - $prepend_code['insert_head_css'] .= $code; |
|
| 1251 | - } |
|
| 1252 | - if ($style['type'] != 'public') { |
|
| 1253 | - $prepend_code['header_prive_css'] .= $code; |
|
| 1254 | - } |
|
| 1255 | - } |
|
| 1256 | - } |
|
| 1257 | - if (!isset($prepend_code['insert_head'])) { |
|
| 1258 | - $prepend_code['insert_head'] = ''; |
|
| 1259 | - } |
|
| 1260 | - if (!isset($prepend_code['header_prive'])) { |
|
| 1261 | - $prepend_code['header_prive'] = ''; |
|
| 1262 | - } |
|
| 1263 | - if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1264 | - foreach ($info['script'] as $script) { |
|
| 1265 | - if (isset($script['path']) and $script['path']) { |
|
| 1266 | - $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1267 | - } else { |
|
| 1268 | - $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1269 | - } |
|
| 1270 | - $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1271 | - if ($script['type'] != 'prive') { |
|
| 1272 | - $prepend_code['insert_head'] .= $code; |
|
| 1273 | - } |
|
| 1274 | - if ($script['type'] != 'public') { |
|
| 1275 | - $prepend_code['header_prive'] .= $code; |
|
| 1276 | - } |
|
| 1277 | - } |
|
| 1278 | - } |
|
| 1279 | - } |
|
| 1280 | - } |
|
| 1281 | - |
|
| 1282 | - $prepend_code['insert_head'] = |
|
| 1283 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1284 | - . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1285 | - . $prepend_code['insert_head']; |
|
| 1286 | - $prepend_code['header_prive'] = |
|
| 1287 | - "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1288 | - . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1289 | - . $prepend_code['header_prive']; |
|
| 1290 | - |
|
| 1291 | - // on ajoute les pipe qui ont ete recenses manquants |
|
| 1292 | - foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1293 | - if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1294 | - $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1295 | - } |
|
| 1296 | - } |
|
| 1297 | - |
|
| 1298 | - return $prepend_code; |
|
| 1165 | + static $liste_pipe_manquants = []; |
|
| 1166 | + if (($pipe_recherche) && (!in_array($pipe_recherche, $liste_pipe_manquants))) { |
|
| 1167 | + $liste_pipe_manquants[] = $pipe_recherche; |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + $prepend_code = []; |
|
| 1171 | + |
|
| 1172 | + foreach ($ordre as $p => $info) { |
|
| 1173 | + // $ordre peur contenir des plugins en attente et non valides pour ce hit |
|
| 1174 | + if (isset($plugin_valides[$p])) { |
|
| 1175 | + $dir_type = $plugin_valides[$p]['dir_type']; |
|
| 1176 | + $root_dir_type = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 1177 | + $plug = $plugin_valides[$p]['dir']; |
|
| 1178 | + $prefix = (($info['prefix'] == 'spip') ? '' : $info['prefix'] . '_'); |
|
| 1179 | + if (isset($info['pipeline']) and is_array($info['pipeline'])) { |
|
| 1180 | + foreach ($info['pipeline'] as $pipe) { |
|
| 1181 | + $nom = $pipe['nom']; |
|
| 1182 | + if (isset($pipe['action'])) { |
|
| 1183 | + $action = $pipe['action']; |
|
| 1184 | + } else { |
|
| 1185 | + $action = $nom; |
|
| 1186 | + } |
|
| 1187 | + $nomlower = strtolower($nom); |
|
| 1188 | + if ( |
|
| 1189 | + $nomlower != $nom |
|
| 1190 | + and isset($GLOBALS['spip_pipeline'][$nom]) |
|
| 1191 | + and !isset($GLOBALS['spip_pipeline'][$nomlower]) |
|
| 1192 | + ) { |
|
| 1193 | + $GLOBALS['spip_pipeline'][$nomlower] = $GLOBALS['spip_pipeline'][$nom]; |
|
| 1194 | + unset($GLOBALS['spip_pipeline'][$nom]); |
|
| 1195 | + } |
|
| 1196 | + $nom = $nomlower; |
|
| 1197 | + // une action vide est une declaration qui ne doit pas etre compilee ! |
|
| 1198 | + if (!isset($GLOBALS['spip_pipeline'][$nom])) { // creer le pipeline eventuel |
|
| 1199 | + $GLOBALS['spip_pipeline'][$nom] = ''; |
|
| 1200 | + } |
|
| 1201 | + if ($action) { |
|
| 1202 | + if (strpos($GLOBALS['spip_pipeline'][$nom], (string) "|$prefix$action") === false) { |
|
| 1203 | + $GLOBALS['spip_pipeline'][$nom] = preg_replace( |
|
| 1204 | + ',(\|\||$),', |
|
| 1205 | + "|$prefix$action\\1", |
|
| 1206 | + $GLOBALS['spip_pipeline'][$nom], |
|
| 1207 | + 1 |
|
| 1208 | + ); |
|
| 1209 | + } |
|
| 1210 | + if (isset($pipe['inclure'])) { |
|
| 1211 | + $GLOBALS['spip_matrice']["$prefix$action"] = |
|
| 1212 | + "$root_dir_type:$plug/" . $pipe['inclure']; |
|
| 1213 | + } |
|
| 1214 | + } |
|
| 1215 | + } |
|
| 1216 | + } |
|
| 1217 | + if (isset($info['genie']) and is_countable($info['genie']) ? count($info['genie']) : 0) { |
|
| 1218 | + if (!isset($prepend_code['taches_generales_cron'])) { |
|
| 1219 | + $prepend_code['taches_generales_cron'] = ''; |
|
| 1220 | + } |
|
| 1221 | + foreach ($info['genie'] as $genie) { |
|
| 1222 | + $nom = $prefix . $genie['nom']; |
|
| 1223 | + $periode = max(60, intval($genie['periode'])); |
|
| 1224 | + if (charger_fonction($nom, 'genie', true)) { |
|
| 1225 | + $prepend_code['taches_generales_cron'] .= "\$val['$nom'] = $periode;\n"; |
|
| 1226 | + } else { |
|
| 1227 | + spip_log("Fonction genie_$nom introuvable", _LOG_ERREUR); |
|
| 1228 | + } |
|
| 1229 | + } |
|
| 1230 | + } |
|
| 1231 | + if (isset($info['style']) and is_countable($info['style']) ? count($info['style']) : 0) { |
|
| 1232 | + if (!isset($prepend_code['insert_head_css'])) { |
|
| 1233 | + $prepend_code['insert_head_css'] = ''; |
|
| 1234 | + } |
|
| 1235 | + if (!isset($prepend_code['header_prive_css'])) { |
|
| 1236 | + $prepend_code['header_prive_css'] = ''; |
|
| 1237 | + } |
|
| 1238 | + foreach ($info['style'] as $style) { |
|
| 1239 | + if (isset($style['path']) and $style['path']) { |
|
| 1240 | + $code = "if (\$f=timestamp(direction_css(find_in_path('" . addslashes($style['path']) . "')))) "; |
|
| 1241 | + } else { |
|
| 1242 | + $code = "if (\$f='" . addslashes($style['url']) . "') "; |
|
| 1243 | + } |
|
| 1244 | + $code .= "\$val .= '<link rel=\"stylesheet\" href=\"'.\$f.'\" type=\"text/css\""; |
|
| 1245 | + if (isset($style['media']) and strlen($style['media'])) { |
|
| 1246 | + $code .= ' media="' . addslashes($style['media']) . '"'; |
|
| 1247 | + } |
|
| 1248 | + $code .= "/>';\n"; |
|
| 1249 | + if ($style['type'] != 'prive') { |
|
| 1250 | + $prepend_code['insert_head_css'] .= $code; |
|
| 1251 | + } |
|
| 1252 | + if ($style['type'] != 'public') { |
|
| 1253 | + $prepend_code['header_prive_css'] .= $code; |
|
| 1254 | + } |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1257 | + if (!isset($prepend_code['insert_head'])) { |
|
| 1258 | + $prepend_code['insert_head'] = ''; |
|
| 1259 | + } |
|
| 1260 | + if (!isset($prepend_code['header_prive'])) { |
|
| 1261 | + $prepend_code['header_prive'] = ''; |
|
| 1262 | + } |
|
| 1263 | + if (isset($info['script']) and is_countable($info['script']) ? count($info['script']) : 0) { |
|
| 1264 | + foreach ($info['script'] as $script) { |
|
| 1265 | + if (isset($script['path']) and $script['path']) { |
|
| 1266 | + $code = "if (\$f=timestamp(find_in_path('" . addslashes($script['path']) . "'))) "; |
|
| 1267 | + } else { |
|
| 1268 | + $code = "if (\$f='" . addslashes($script['url']) . "') "; |
|
| 1269 | + } |
|
| 1270 | + $code .= "\$val .= '<script src=\"'.\$f.'\" type=\"text/javascript\"></script>';\n"; |
|
| 1271 | + if ($script['type'] != 'prive') { |
|
| 1272 | + $prepend_code['insert_head'] .= $code; |
|
| 1273 | + } |
|
| 1274 | + if ($script['type'] != 'public') { |
|
| 1275 | + $prepend_code['header_prive'] .= $code; |
|
| 1276 | + } |
|
| 1277 | + } |
|
| 1278 | + } |
|
| 1279 | + } |
|
| 1280 | + } |
|
| 1281 | + |
|
| 1282 | + $prepend_code['insert_head'] = |
|
| 1283 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines.php');\n" |
|
| 1284 | + . "\$val = minipipe('f_jQuery', \$val);\n" |
|
| 1285 | + . $prepend_code['insert_head']; |
|
| 1286 | + $prepend_code['header_prive'] = |
|
| 1287 | + "include_once_check(_DIR_RESTREINT . 'inc/pipelines_ecrire.php');\n" |
|
| 1288 | + . "\$val = minipipe('f_jQuery_prive', \$val);\n" |
|
| 1289 | + . $prepend_code['header_prive']; |
|
| 1290 | + |
|
| 1291 | + // on ajoute les pipe qui ont ete recenses manquants |
|
| 1292 | + foreach ($liste_pipe_manquants as $add_pipe) { |
|
| 1293 | + if (!isset($GLOBALS['spip_pipeline'][$add_pipe])) { |
|
| 1294 | + $GLOBALS['spip_pipeline'][$add_pipe] = ''; |
|
| 1295 | + } |
|
| 1296 | + } |
|
| 1297 | + |
|
| 1298 | + return $prepend_code; |
|
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | /** |
@@ -1322,62 +1322,62 @@ discard block |
||
| 1322 | 1322 | **/ |
| 1323 | 1323 | function pipeline_precompile($prepend_code = []) { |
| 1324 | 1324 | |
| 1325 | - $all_pipes = $all_pipes_end = ''; |
|
| 1326 | - if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1327 | - $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1328 | - unset($GLOBALS['spip_pipeline']['all']); |
|
| 1329 | - $all_pipes = trim(array_shift($a)); |
|
| 1330 | - if ($all_pipes) { |
|
| 1331 | - $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1332 | - } |
|
| 1333 | - if (count($a)) { |
|
| 1334 | - $all_pipes_end = '||' . array_shift($a); |
|
| 1335 | - } |
|
| 1336 | - } |
|
| 1337 | - $content = ''; |
|
| 1338 | - foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1339 | - $s_inc = ''; |
|
| 1340 | - $s_call = ''; |
|
| 1341 | - if ($all_pipes) { |
|
| 1342 | - $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1343 | - } |
|
| 1344 | - if ($all_pipes_end) { |
|
| 1345 | - $pipeline .= $all_pipes_end; |
|
| 1346 | - } |
|
| 1347 | - $pipe = array_filter(explode('|', $pipeline)); |
|
| 1348 | - // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1349 | - foreach ($pipe as $fonc) { |
|
| 1350 | - $fonc = trim($fonc); |
|
| 1351 | - $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1352 | - if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1353 | - $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1354 | - $file = "'$file'"; |
|
| 1355 | - // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1356 | - if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1357 | - $dir = $regs[1]; |
|
| 1358 | - $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1359 | - if (defined($root_dir)) { |
|
| 1360 | - $dir = $root_dir; |
|
| 1361 | - } |
|
| 1362 | - $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1363 | - $file = str_replace("''.", '', $file); |
|
| 1364 | - $file = str_replace(constant($dir), '', $file); |
|
| 1365 | - } |
|
| 1366 | - $s_inc .= "include_once_check($file);\n"; |
|
| 1367 | - } |
|
| 1368 | - } |
|
| 1369 | - if (strlen($s_inc)) { |
|
| 1370 | - $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1371 | - } |
|
| 1372 | - $content .= "// Pipeline $action \n" |
|
| 1373 | - . "function execute_pipeline_$action(&\$val){\n" |
|
| 1374 | - . $s_inc |
|
| 1375 | - . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1376 | - . $s_call |
|
| 1377 | - . "return \$val;\n}\n"; |
|
| 1378 | - } |
|
| 1379 | - ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1380 | - clear_path_cache(); |
|
| 1325 | + $all_pipes = $all_pipes_end = ''; |
|
| 1326 | + if (!empty($GLOBALS['spip_pipeline']['all'])) { |
|
| 1327 | + $a = explode('||', $GLOBALS['spip_pipeline']['all'], 2); |
|
| 1328 | + unset($GLOBALS['spip_pipeline']['all']); |
|
| 1329 | + $all_pipes = trim(array_shift($a)); |
|
| 1330 | + if ($all_pipes) { |
|
| 1331 | + $all_pipes = '|' . ltrim($all_pipes, '|'); |
|
| 1332 | + } |
|
| 1333 | + if (count($a)) { |
|
| 1334 | + $all_pipes_end = '||' . array_shift($a); |
|
| 1335 | + } |
|
| 1336 | + } |
|
| 1337 | + $content = ''; |
|
| 1338 | + foreach ($GLOBALS['spip_pipeline'] as $action => $pipeline) { |
|
| 1339 | + $s_inc = ''; |
|
| 1340 | + $s_call = ''; |
|
| 1341 | + if ($all_pipes) { |
|
| 1342 | + $pipeline = preg_replace(',(\|\||$),', "$all_pipes\\1", $pipeline, 1); |
|
| 1343 | + } |
|
| 1344 | + if ($all_pipes_end) { |
|
| 1345 | + $pipeline .= $all_pipes_end; |
|
| 1346 | + } |
|
| 1347 | + $pipe = array_filter(explode('|', $pipeline)); |
|
| 1348 | + // Eclater le pipeline en filtres et appliquer chaque filtre |
|
| 1349 | + foreach ($pipe as $fonc) { |
|
| 1350 | + $fonc = trim($fonc); |
|
| 1351 | + $s_call .= '$val = minipipe(\'' . $fonc . '\', $val);' . "\n"; |
|
| 1352 | + if (isset($GLOBALS['spip_matrice'][$fonc])) { |
|
| 1353 | + $file = $GLOBALS['spip_matrice'][$fonc]; |
|
| 1354 | + $file = "'$file'"; |
|
| 1355 | + // si un _DIR_XXX: est dans la chaine, on extrait la constante |
|
| 1356 | + if (preg_match(',(_(DIR|ROOT)_[A-Z_]+):,Ums', $file, $regs)) { |
|
| 1357 | + $dir = $regs[1]; |
|
| 1358 | + $root_dir = str_replace('_DIR_', '_ROOT_', $dir); |
|
| 1359 | + if (defined($root_dir)) { |
|
| 1360 | + $dir = $root_dir; |
|
| 1361 | + } |
|
| 1362 | + $file = str_replace($regs[0], "'." . $dir . ".'", $file); |
|
| 1363 | + $file = str_replace("''.", '', $file); |
|
| 1364 | + $file = str_replace(constant($dir), '', $file); |
|
| 1365 | + } |
|
| 1366 | + $s_inc .= "include_once_check($file);\n"; |
|
| 1367 | + } |
|
| 1368 | + } |
|
| 1369 | + if (strlen($s_inc)) { |
|
| 1370 | + $s_inc = "static \$inc=null;\nif (!\$inc){\n$s_inc\$inc=true;\n}\n"; |
|
| 1371 | + } |
|
| 1372 | + $content .= "// Pipeline $action \n" |
|
| 1373 | + . "function execute_pipeline_$action(&\$val){\n" |
|
| 1374 | + . $s_inc |
|
| 1375 | + . ((isset($prepend_code[$action]) and strlen($prepend_code[$action])) ? trim($prepend_code[$action]) . "\n" : '') |
|
| 1376 | + . $s_call |
|
| 1377 | + . "return \$val;\n}\n"; |
|
| 1378 | + } |
|
| 1379 | + ecrire_fichier_php(_CACHE_PIPELINES, $content); |
|
| 1380 | + clear_path_cache(); |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | |
@@ -1390,12 +1390,12 @@ discard block |
||
| 1390 | 1390 | * true si le plugin est actif, false sinon |
| 1391 | 1391 | **/ |
| 1392 | 1392 | function plugin_est_installe($plug_path) { |
| 1393 | - $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1394 | - if (!$plugin_installes) { |
|
| 1395 | - return false; |
|
| 1396 | - } |
|
| 1393 | + $plugin_installes = isset($GLOBALS['meta']['plugin_installes']) ? unserialize($GLOBALS['meta']['plugin_installes']) : []; |
|
| 1394 | + if (!$plugin_installes) { |
|
| 1395 | + return false; |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | - return in_array($plug_path, $plugin_installes); |
|
| 1398 | + return in_array($plug_path, $plugin_installes); |
|
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | |
@@ -1408,46 +1408,46 @@ discard block |
||
| 1408 | 1408 | * @uses plugins_installer_dist() |
| 1409 | 1409 | **/ |
| 1410 | 1410 | function plugin_installes_meta() { |
| 1411 | - if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1412 | - // attendre eventuellement l'invalidation du cache opcode |
|
| 1413 | - spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1414 | - } |
|
| 1415 | - |
|
| 1416 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1417 | - $meta_plug_installes = []; |
|
| 1418 | - foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1419 | - if ($plug = $resume['dir']) { |
|
| 1420 | - $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1421 | - if ($infos) { |
|
| 1422 | - if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1423 | - $meta_plug_installes[] = $plug; |
|
| 1424 | - } |
|
| 1425 | - if (is_array($infos)) { |
|
| 1426 | - [$ok, $trace] = $infos['install_test']; |
|
| 1427 | - $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1428 | - $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1429 | - if (_IS_CLI) { |
|
| 1430 | - include_spip('inc/filtres'); |
|
| 1431 | - $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | - $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | - echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1434 | - $trace, |
|
| 1435 | - "\n"; |
|
| 1436 | - } |
|
| 1437 | - else { |
|
| 1438 | - include_spip('inc/filtres_boites'); |
|
| 1439 | - echo "<div class='install-plugins svp_retour'>" |
|
| 1440 | - . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1441 | - . $trace |
|
| 1442 | - . "<div class='result'>$result</div>" |
|
| 1443 | - . boite_fermer() |
|
| 1444 | - . '</div>'; |
|
| 1445 | - } |
|
| 1446 | - } |
|
| 1447 | - } |
|
| 1448 | - } |
|
| 1449 | - } |
|
| 1450 | - ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1411 | + if (isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1412 | + // attendre eventuellement l'invalidation du cache opcode |
|
| 1413 | + spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']); |
|
| 1414 | + } |
|
| 1415 | + |
|
| 1416 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 1417 | + $meta_plug_installes = []; |
|
| 1418 | + foreach (unserialize($GLOBALS['meta']['plugin']) as $prefix => $resume) { |
|
| 1419 | + if ($plug = $resume['dir']) { |
|
| 1420 | + $infos = $installer_plugins($plug, 'install', $resume['dir_type']); |
|
| 1421 | + if ($infos) { |
|
| 1422 | + if (!is_array($infos) or $infos['install_test'][0]) { |
|
| 1423 | + $meta_plug_installes[] = $plug; |
|
| 1424 | + } |
|
| 1425 | + if (is_array($infos)) { |
|
| 1426 | + [$ok, $trace] = $infos['install_test']; |
|
| 1427 | + $titre = _T('plugin_titre_installation', ['plugin' => typo($infos['nom'])]); |
|
| 1428 | + $result = ($ok ? ((isset($infos['upgrade']) && $infos['upgrade']) ? _T('plugin_info_upgrade_ok') : _T('plugin_info_install_ok')) : _T('avis_operation_echec')); |
|
| 1429 | + if (_IS_CLI) { |
|
| 1430 | + include_spip('inc/filtres'); |
|
| 1431 | + $trace = ltrim(textebrut($trace) . "\n" . $result); |
|
| 1432 | + $trace = ' ' . str_replace("\n", "\n ", $trace); |
|
| 1433 | + echo "\n" . ($ok ? 'OK ' : '/!\ ') . textebrut($titre) . "\n", |
|
| 1434 | + $trace, |
|
| 1435 | + "\n"; |
|
| 1436 | + } |
|
| 1437 | + else { |
|
| 1438 | + include_spip('inc/filtres_boites'); |
|
| 1439 | + echo "<div class='install-plugins svp_retour'>" |
|
| 1440 | + . boite_ouvrir($titre, ($ok ? 'success' : 'error')) |
|
| 1441 | + . $trace |
|
| 1442 | + . "<div class='result'>$result</div>" |
|
| 1443 | + . boite_fermer() |
|
| 1444 | + . '</div>'; |
|
| 1445 | + } |
|
| 1446 | + } |
|
| 1447 | + } |
|
| 1448 | + } |
|
| 1449 | + } |
|
| 1450 | + ecrire_meta('plugin_installes', serialize($meta_plug_installes), 'non'); |
|
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | /** |
@@ -1461,29 +1461,29 @@ discard block |
||
| 1461 | 1461 | * Commentaire : code écrit en tout début de fichier, après la balise PHP ouvrante |
| 1462 | 1462 | **/ |
| 1463 | 1463 | function ecrire_fichier_php($nom, $contenu, $comment = '') { |
| 1464 | - if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1465 | - $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1466 | - } |
|
| 1467 | - |
|
| 1468 | - $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1469 | - // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1470 | - // si pas de modif on ne touche pas au fichier initial |
|
| 1471 | - if (file_exists($nom)) { |
|
| 1472 | - if (substr($nom, -4) == '.php') { |
|
| 1473 | - $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1474 | - } |
|
| 1475 | - else { |
|
| 1476 | - $fichier_tmp = $nom . '.tmp'; |
|
| 1477 | - } |
|
| 1478 | - file_put_contents($fichier_tmp, $contenu); |
|
| 1479 | - if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1480 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1481 | - @unlink($fichier_tmp); |
|
| 1482 | - return; |
|
| 1483 | - } |
|
| 1484 | - @unlink($fichier_tmp); |
|
| 1485 | - } |
|
| 1486 | - ecrire_fichier($nom, $contenu); |
|
| 1487 | - $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1488 | - spip_clear_opcode_cache(realpath($nom)); |
|
| 1464 | + if (!isset($GLOBALS['fichier_php_compile_recent'])) { |
|
| 1465 | + $GLOBALS['fichier_php_compile_recent'] = 0; |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + $contenu = '<' . '?php' . "\n" . $comment . "\nif (defined('_ECRIRE_INC_VERSION')) {\n" . $contenu . "}\n?" . '>'; |
|
| 1469 | + // si un fichier existe deja on verifie que son contenu change avant de l'ecraser |
|
| 1470 | + // si pas de modif on ne touche pas au fichier initial |
|
| 1471 | + if (file_exists($nom)) { |
|
| 1472 | + if (substr($nom, -4) == '.php') { |
|
| 1473 | + $fichier_tmp = substr($nom, 0, -4) . '.tmp.php'; |
|
| 1474 | + } |
|
| 1475 | + else { |
|
| 1476 | + $fichier_tmp = $nom . '.tmp'; |
|
| 1477 | + } |
|
| 1478 | + file_put_contents($fichier_tmp, $contenu); |
|
| 1479 | + if (md5_file($nom) == md5_file($fichier_tmp)) { |
|
| 1480 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1481 | + @unlink($fichier_tmp); |
|
| 1482 | + return; |
|
| 1483 | + } |
|
| 1484 | + @unlink($fichier_tmp); |
|
| 1485 | + } |
|
| 1486 | + ecrire_fichier($nom, $contenu); |
|
| 1487 | + $GLOBALS['fichier_php_compile_recent'] = max($GLOBALS['fichier_php_compile_recent'], filemtime($nom)); |
|
| 1488 | + spip_clear_opcode_cache(realpath($nom)); |
|
| 1489 | 1489 | } |
@@ -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 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | function extraire_date($texte) { |
| 39 | 39 | // format = 2001-08 |
| 40 | 40 | if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
| 41 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 41 | + return $regs[1].'-'.sprintf('%02d', $regs[2]).'-01'; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 70 | 70 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 71 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 71 | + $date = $regs[1].'-00-00'.$regs[3]; |
|
| 72 | 72 | } else { |
| 73 | 73 | if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
| 74 | 74 | $regs = array_pad($regs, 4, null); // eviter notice php |
| 75 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 75 | + $date = preg_replace('@/@', '-', $regs[1]).'-00'.$regs[3]; |
|
| 76 | 76 | } else { |
| 77 | 77 | $date = date('Y-m-d H:i:s', strtotime($date)); |
| 78 | 78 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | 99 | if ( |
| 100 | 100 | !$verif_format_date |
| 101 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 101 | + or (in_array(strlen($letexte), [10, 19]) and |
|
| 102 | 102 | preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
| 103 | 103 | ) { |
| 104 | 104 | if (strncmp('0000-00-00', $letexte, 10) == 0) { |
@@ -381,17 +381,17 @@ discard block |
||
| 381 | 381 | if ($decal > 3600 * 24 * 30) { |
| 382 | 382 | $mois = floor($decal / (3600 * 24 * 30)); |
| 383 | 383 | if ($mois < 2) { |
| 384 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 384 | + $delai = "$mois "._T('date_un_mois'); |
|
| 385 | 385 | } else { |
| 386 | - $delai = "$mois " . _T('date_mois'); |
|
| 386 | + $delai = "$mois "._T('date_mois'); |
|
| 387 | 387 | } |
| 388 | 388 | } else { |
| 389 | 389 | if ($decal > 3600 * 24 * 7) { |
| 390 | 390 | $semaines = floor($decal / (3600 * 24 * 7)); |
| 391 | 391 | if ($semaines < 2) { |
| 392 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 392 | + $delai = "$semaines "._T('date_une_semaine'); |
|
| 393 | 393 | } else { |
| 394 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 394 | + $delai = "$semaines "._T('date_semaines'); |
|
| 395 | 395 | } |
| 396 | 396 | } else { |
| 397 | 397 | if ($decal > 3600 * 24) { |
@@ -399,30 +399,30 @@ discard block |
||
| 399 | 399 | if ($jours < 2) { |
| 400 | 400 | return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
| 401 | 401 | } else { |
| 402 | - $delai = "$jours " . _T('date_jours'); |
|
| 402 | + $delai = "$jours "._T('date_jours'); |
|
| 403 | 403 | } |
| 404 | 404 | } else { |
| 405 | 405 | if ($decal >= 3600) { |
| 406 | 406 | $heures = floor($decal / 3600); |
| 407 | 407 | if ($heures < 2) { |
| 408 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 408 | + $delai = "$heures "._T('date_une_heure'); |
|
| 409 | 409 | } else { |
| 410 | - $delai = "$heures " . _T('date_heures'); |
|
| 410 | + $delai = "$heures "._T('date_heures'); |
|
| 411 | 411 | } |
| 412 | 412 | } else { |
| 413 | 413 | if ($decal >= 60) { |
| 414 | 414 | $minutes = floor($decal / 60); |
| 415 | 415 | if ($minutes < 2) { |
| 416 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 416 | + $delai = "$minutes "._T('date_une_minute'); |
|
| 417 | 417 | } else { |
| 418 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 418 | + $delai = "$minutes "._T('date_minutes'); |
|
| 419 | 419 | } |
| 420 | 420 | } else { |
| 421 | 421 | $secondes = ceil($decal); |
| 422 | 422 | if ($secondes < 2) { |
| 423 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 423 | + $delai = "$secondes "._T('date_une_seconde'); |
|
| 424 | 424 | } else { |
| 425 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 425 | + $delai = "$secondes "._T('date_secondes'); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | $njour = 0; |
| 518 | 518 | } else { |
| 519 | 519 | $njour = intval($jour); |
| 520 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 520 | + if ($jourth = _T('date_jnum'.$jour)) { |
|
| 521 | 521 | $jour = $jourth; |
| 522 | 522 | } |
| 523 | 523 | } |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | $mois = intval($mois); |
| 526 | 526 | if ($mois > 0 and $mois < 13) { |
| 527 | 527 | /* Traiter le cas "abbr" pour les noms de mois */ |
| 528 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 529 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 528 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_'.$options['param'] : ''); |
|
| 529 | + $nommois = _T('date_mois_'.$mois.$param); |
|
| 530 | 530 | if ($jour) { |
| 531 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 531 | + $jourmois = _T('date_de_mois_'.$mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 532 | 532 | } else { |
| 533 | 533 | $jourmois = $nommois; |
| 534 | 534 | } |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | if ($annee < 0) { |
| 541 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 541 | + $annee = -$annee.' '._T('date_avant_jc'); |
|
| 542 | 542 | $avjc = true; |
| 543 | 543 | } else { |
| 544 | 544 | $avjc = false; |
@@ -564,11 +564,11 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | } |
| 566 | 566 | if ($vue == 'saison') { |
| 567 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 567 | + return $saison ? _T('date_saison_'.$saison) : ''; |
|
| 568 | 568 | } else { |
| 569 | 569 | return $saison ? trim(_T( |
| 570 | 570 | 'date_fmt_saison_annee', |
| 571 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 571 | + ['saison' => _T('date_saison_'.$saison), 'annee' => $annee] |
|
| 572 | 572 | )) : ''; |
| 573 | 573 | } |
| 574 | 574 | |
@@ -645,9 +645,9 @@ discard block |
||
| 645 | 645 | } |
| 646 | 646 | $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
| 647 | 647 | $nom = 1 + date('w', $nom); |
| 648 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 648 | + $param = ((isset($options['param']) and $options['param']) ? '_'.$options['param'] : ''); |
|
| 649 | 649 | |
| 650 | - return _T('date_jour_' . $nom . $param); |
|
| 650 | + return _T('date_jour_'.$nom.$param); |
|
| 651 | 651 | |
| 652 | 652 | case 'mois_annee': |
| 653 | 653 | if ($avjc) { |
@@ -1042,8 +1042,8 @@ discard block |
||
| 1042 | 1042 | |
| 1043 | 1043 | $dtstart = $dtend = $dtabbr = ''; |
| 1044 | 1044 | if (strpos($forme, 'hcal') !== false) { |
| 1045 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1046 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1045 | + $dtstart = "<abbr class='dtstart' title='".date_iso($date_debut)."'>"; |
|
| 1046 | + $dtend = "<abbr class='dtend' title='".date_iso($date_fin)."'>"; |
|
| 1047 | 1047 | $dtabbr = '</abbr>'; |
| 1048 | 1048 | } |
| 1049 | 1049 | |
@@ -1091,7 +1091,7 @@ discard block |
||
| 1091 | 1091 | } |
| 1092 | 1092 | } else { |
| 1093 | 1093 | if ($dtabbr && $dtstart) { |
| 1094 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1094 | + $s = $dtstart.spip_ucfirst($s).$dtabbr; |
|
| 1095 | 1095 | } else { |
| 1096 | 1096 | $s = spip_ucfirst($s); |
| 1097 | 1097 | } |
@@ -1114,8 +1114,8 @@ discard block |
||
| 1114 | 1114 | $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
| 1115 | 1115 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1116 | 1116 | } |
| 1117 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1118 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1117 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1118 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1119 | 1119 | |
| 1120 | 1120 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1121 | 1121 | } else { |
@@ -1132,8 +1132,8 @@ discard block |
||
| 1132 | 1132 | $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1136 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1135 | + $date_debut = $dtstart.$date_debut.$dtabbr; |
|
| 1136 | + $date_fin = $dtend.$date_fin.$dtabbr; |
|
| 1137 | 1137 | $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
| 1138 | 1138 | } |
| 1139 | 1139 | } |
@@ -1237,7 +1237,7 @@ discard block |
||
| 1237 | 1237 | $d = date('Y-m-d'); |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1240 | + return substr($d, 0, 4).substr($d, 5, 2).substr($d, 8, 2); |
|
| 1241 | 1241 | } |
| 1242 | 1242 | |
| 1243 | 1243 | /** |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | $d = date('Y-m-d'); |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1260 | + return substr($d, 0, 4).substr($d, 5, 2); |
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | /** |
@@ -212,8 +212,7 @@ |
||
| 212 | 212 | function heures_minutes($numdate, $forme = '') { |
| 213 | 213 | if ($forme != 'abbr') { |
| 214 | 214 | return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
| 215 | - } |
|
| 216 | - else { |
|
| 215 | + } else { |
|
| 217 | 216 | return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
| 218 | 217 | } |
| 219 | 218 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | * Date au format SQL tel que `2008-04-01` |
| 37 | 37 | **/ |
| 38 | 38 | function extraire_date($texte) { |
| 39 | - // format = 2001-08 |
|
| 40 | - if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 41 | - return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | - } |
|
| 39 | + // format = 2001-08 |
|
| 40 | + if (preg_match(',([1-2][0-9]{3})[^0-9]*(1[0-2]|0?[1-9]),', $texte, $regs)) { |
|
| 41 | + return $regs[1] . '-' . sprintf('%02d', $regs[2]) . '-01'; |
|
| 42 | + } |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -61,29 +61,29 @@ discard block |
||
| 61 | 61 | * - une chaîne vide si la date est considérée nulle |
| 62 | 62 | **/ |
| 63 | 63 | function normaliser_date($date, $forcer_jour = false) { |
| 64 | - $date = vider_date($date); |
|
| 65 | - if ($date) { |
|
| 66 | - if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 67 | - $date = date('Y-m-d H:i:s', $date); |
|
| 68 | - } |
|
| 69 | - if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 70 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | - $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 72 | - } else { |
|
| 73 | - if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 74 | - $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | - $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 76 | - } else { |
|
| 77 | - $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if ($forcer_jour) { |
|
| 82 | - $date = str_replace('-00', '-01', $date); |
|
| 83 | - } |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - return $date; |
|
| 64 | + $date = vider_date($date); |
|
| 65 | + if ($date) { |
|
| 66 | + if (preg_match('/^[0-9]{8,10}$/', $date)) { |
|
| 67 | + $date = date('Y-m-d H:i:s', $date); |
|
| 68 | + } |
|
| 69 | + if (preg_match('#^([12][0-9]{3})([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 70 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 71 | + $date = $regs[1] . '-00-00' . $regs[3]; |
|
| 72 | + } else { |
|
| 73 | + if (preg_match('#^([12][0-9]{3}[-/][01]?[0-9])([-/]00)?( [-0-9:]+)?$#', $date, $regs)) { |
|
| 74 | + $regs = array_pad($regs, 4, null); // eviter notice php |
|
| 75 | + $date = preg_replace('@/@', '-', $regs[1]) . '-00' . $regs[3]; |
|
| 76 | + } else { |
|
| 77 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if ($forcer_jour) { |
|
| 82 | + $date = str_replace('-00', '-01', $date); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + return $date; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -96,22 +96,22 @@ discard block |
||
| 96 | 96 | * - Une chaine vide |
| 97 | 97 | **/ |
| 98 | 98 | function vider_date($letexte, $verif_format_date = false) { |
| 99 | - if ( |
|
| 100 | - !$verif_format_date |
|
| 101 | - or (in_array(strlen($letexte), [10,19]) and |
|
| 102 | - preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 103 | - ) { |
|
| 104 | - if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 105 | - return ''; |
|
| 106 | - } |
|
| 107 | - if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 108 | - return ''; |
|
| 109 | - } |
|
| 110 | - if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 111 | - return ''; |
|
| 112 | - } // eviter le bug GMT-1 |
|
| 113 | - } |
|
| 114 | - return $letexte; |
|
| 99 | + if ( |
|
| 100 | + !$verif_format_date |
|
| 101 | + or (in_array(strlen($letexte), [10,19]) and |
|
| 102 | + preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}(\s[0-9]{2}:[0-9]{2}:[0-9]{2})?$/', $letexte)) |
|
| 103 | + ) { |
|
| 104 | + if (strncmp('0000-00-00', $letexte, 10) == 0) { |
|
| 105 | + return ''; |
|
| 106 | + } |
|
| 107 | + if (strncmp('0001-01-01', $letexte, 10) == 0) { |
|
| 108 | + return ''; |
|
| 109 | + } |
|
| 110 | + if (strncmp('1970-01-01', $letexte, 10) == 0) { |
|
| 111 | + return ''; |
|
| 112 | + } // eviter le bug GMT-1 |
|
| 113 | + } |
|
| 114 | + return $letexte; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | **/ |
| 128 | 128 | function recup_heure($date) { |
| 129 | 129 | |
| 130 | - static $d = [0, 0, 0]; |
|
| 131 | - if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 132 | - return $d; |
|
| 133 | - } |
|
| 130 | + static $d = [0, 0, 0]; |
|
| 131 | + if (!preg_match('#([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $date, $r)) { |
|
| 132 | + return $d; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - array_shift($r); |
|
| 135 | + array_shift($r); |
|
| 136 | 136 | |
| 137 | - return $r; |
|
| 137 | + return $r; |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | /** |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | * @return int heures, sinon 0 |
| 149 | 149 | **/ |
| 150 | 150 | function heures($numdate) { |
| 151 | - $heures = null; |
|
| 152 | - $date_array = recup_heure($numdate); |
|
| 153 | - if ($date_array) { |
|
| 154 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 155 | - } |
|
| 151 | + $heures = null; |
|
| 152 | + $date_array = recup_heure($numdate); |
|
| 153 | + if ($date_array) { |
|
| 154 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - return $heures; |
|
| 157 | + return $heures; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | * @return int minutes, sinon 0 |
| 169 | 169 | **/ |
| 170 | 170 | function minutes($numdate) { |
| 171 | - $minutes = null; |
|
| 172 | - $date_array = recup_heure($numdate); |
|
| 173 | - if ($date_array) { |
|
| 174 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 175 | - } |
|
| 171 | + $minutes = null; |
|
| 172 | + $date_array = recup_heure($numdate); |
|
| 173 | + if ($date_array) { |
|
| 174 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | - return $minutes; |
|
| 177 | + return $minutes; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -188,13 +188,13 @@ discard block |
||
| 188 | 188 | * @return int secondes, sinon 0 |
| 189 | 189 | **/ |
| 190 | 190 | function secondes($numdate) { |
| 191 | - $secondes = null; |
|
| 192 | - $date_array = recup_heure($numdate); |
|
| 193 | - if ($date_array) { |
|
| 194 | - [$heures, $minutes, $secondes] = $date_array; |
|
| 195 | - } |
|
| 191 | + $secondes = null; |
|
| 192 | + $date_array = recup_heure($numdate); |
|
| 193 | + if ($date_array) { |
|
| 194 | + [$heures, $minutes, $secondes] = $date_array; |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - return $secondes; |
|
| 197 | + return $secondes; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -213,12 +213,12 @@ discard block |
||
| 213 | 213 | * @return string L'heure formatée dans la langue en cours. |
| 214 | 214 | **/ |
| 215 | 215 | function heures_minutes($numdate, $forme = '') { |
| 216 | - if ($forme != 'abbr') { |
|
| 217 | - return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 218 | - } |
|
| 219 | - else { |
|
| 220 | - return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 221 | - } |
|
| 216 | + if ($forme != 'abbr') { |
|
| 217 | + return _T('date_fmt_heures_minutes', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 218 | + } |
|
| 219 | + else { |
|
| 220 | + return _T('date_fmt_heures_minutes_court', ['h' => heures($numdate), 'm' => minutes($numdate)]); |
|
| 221 | + } |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -243,56 +243,56 @@ discard block |
||
| 243 | 243 | * @return array [année, mois, jour, heures, minutes, secondes] |
| 244 | 244 | **/ |
| 245 | 245 | function recup_date($numdate, $forcer_jour = true) { |
| 246 | - if (!$numdate) { |
|
| 247 | - return ''; |
|
| 248 | - } |
|
| 249 | - $heures = $minutes = $secondes = 0; |
|
| 250 | - if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 251 | - $jour = $regs[1]; |
|
| 252 | - $mois = $regs[2]; |
|
| 253 | - $annee = $regs[3]; |
|
| 254 | - if ($annee < 90) { |
|
| 255 | - $annee = 2000 + $annee; |
|
| 256 | - } elseif ($annee < 100) { |
|
| 257 | - $annee = 1900 + $annee; |
|
| 258 | - } |
|
| 259 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 260 | - } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 261 | - $annee = $regs[1]; |
|
| 262 | - $mois = $regs[2]; |
|
| 263 | - $jour = $regs[3]; |
|
| 264 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 265 | - } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 266 | - $annee = $regs[1]; |
|
| 267 | - $mois = $regs[2]; |
|
| 268 | - $jour = ''; |
|
| 269 | - [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 270 | - } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 271 | - $annee = $regs[1]; |
|
| 272 | - $mois = $regs[2]; |
|
| 273 | - $jour = $regs[3]; |
|
| 274 | - $heures = $regs[4]; |
|
| 275 | - $minutes = $regs[5]; |
|
| 276 | - $secondes = $regs[6]; |
|
| 277 | - } else { |
|
| 278 | - $annee = $mois = $jour = ''; |
|
| 279 | - } |
|
| 280 | - if ($annee > 4000) { |
|
| 281 | - $annee -= 9000; |
|
| 282 | - } |
|
| 283 | - if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 284 | - $jour = substr($jour, 1); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - if ($forcer_jour and $jour == '0') { |
|
| 288 | - $jour = '1'; |
|
| 289 | - } |
|
| 290 | - if ($forcer_jour and $mois == '0') { |
|
| 291 | - $mois = '1'; |
|
| 292 | - } |
|
| 293 | - if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 294 | - return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 295 | - } |
|
| 246 | + if (!$numdate) { |
|
| 247 | + return ''; |
|
| 248 | + } |
|
| 249 | + $heures = $minutes = $secondes = 0; |
|
| 250 | + if (preg_match('#([0-9]{1,2})/([0-9]{1,2})/([0-9]{4}|[0-9]{1,2})#', $numdate, $regs)) { |
|
| 251 | + $jour = $regs[1]; |
|
| 252 | + $mois = $regs[2]; |
|
| 253 | + $annee = $regs[3]; |
|
| 254 | + if ($annee < 90) { |
|
| 255 | + $annee = 2000 + $annee; |
|
| 256 | + } elseif ($annee < 100) { |
|
| 257 | + $annee = 1900 + $annee; |
|
| 258 | + } |
|
| 259 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 260 | + } elseif (preg_match('#([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})#', $numdate, $regs)) { |
|
| 261 | + $annee = $regs[1]; |
|
| 262 | + $mois = $regs[2]; |
|
| 263 | + $jour = $regs[3]; |
|
| 264 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 265 | + } elseif (preg_match('#([0-9]{4})-([0-9]{2})#', $numdate, $regs)) { |
|
| 266 | + $annee = $regs[1]; |
|
| 267 | + $mois = $regs[2]; |
|
| 268 | + $jour = ''; |
|
| 269 | + [$heures, $minutes, $secondes] = recup_heure($numdate); |
|
| 270 | + } elseif (preg_match('#^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $numdate, $regs)) { |
|
| 271 | + $annee = $regs[1]; |
|
| 272 | + $mois = $regs[2]; |
|
| 273 | + $jour = $regs[3]; |
|
| 274 | + $heures = $regs[4]; |
|
| 275 | + $minutes = $regs[5]; |
|
| 276 | + $secondes = $regs[6]; |
|
| 277 | + } else { |
|
| 278 | + $annee = $mois = $jour = ''; |
|
| 279 | + } |
|
| 280 | + if ($annee > 4000) { |
|
| 281 | + $annee -= 9000; |
|
| 282 | + } |
|
| 283 | + if (strlen($jour) and substr($jour, 0, 1) == '0') { |
|
| 284 | + $jour = substr($jour, 1); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + if ($forcer_jour and $jour == '0') { |
|
| 288 | + $jour = '1'; |
|
| 289 | + } |
|
| 290 | + if ($forcer_jour and $mois == '0') { |
|
| 291 | + $mois = '1'; |
|
| 292 | + } |
|
| 293 | + if ($annee or $mois or $jour or $heures or $minutes or $secondes) { |
|
| 294 | + return [$annee, $mois, $jour, $heures, $minutes, $secondes]; |
|
| 295 | + } |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | /** |
@@ -319,10 +319,10 @@ discard block |
||
| 319 | 319 | * La date relative ou complète |
| 320 | 320 | **/ |
| 321 | 321 | function date_interface($date, $decalage_maxi = 43200 /* 12*3600 */) { |
| 322 | - return sinon( |
|
| 323 | - date_relative($date, $decalage_maxi), |
|
| 324 | - affdate_heure($date) |
|
| 325 | - ); |
|
| 322 | + return sinon( |
|
| 323 | + date_relative($date, $decalage_maxi), |
|
| 324 | + affdate_heure($date) |
|
| 325 | + ); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | /** |
@@ -355,85 +355,85 @@ discard block |
||
| 355 | 355 | **/ |
| 356 | 356 | function date_relative($date, $decalage_maxi = 0, $ref_date = null) { |
| 357 | 357 | |
| 358 | - if (is_null($ref_date)) { |
|
| 359 | - $ref_time = time(); |
|
| 360 | - } else { |
|
| 361 | - $ref_time = strtotime($ref_date); |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - if (!$date) { |
|
| 365 | - return; |
|
| 366 | - } |
|
| 367 | - $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 368 | - |
|
| 369 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 370 | - return ''; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - if ($decal < 0) { |
|
| 374 | - $il_y_a = 'date_dans'; |
|
| 375 | - $decal = -1 * $decal; |
|
| 376 | - } else { |
|
| 377 | - $il_y_a = 'date_il_y_a'; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - if ($decal > 3600 * 24 * 30 * 6) { |
|
| 381 | - return affdate_court($date); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - if ($decal > 3600 * 24 * 30) { |
|
| 385 | - $mois = floor($decal / (3600 * 24 * 30)); |
|
| 386 | - if ($mois < 2) { |
|
| 387 | - $delai = "$mois " . _T('date_un_mois'); |
|
| 388 | - } else { |
|
| 389 | - $delai = "$mois " . _T('date_mois'); |
|
| 390 | - } |
|
| 391 | - } else { |
|
| 392 | - if ($decal > 3600 * 24 * 7) { |
|
| 393 | - $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 394 | - if ($semaines < 2) { |
|
| 395 | - $delai = "$semaines " . _T('date_une_semaine'); |
|
| 396 | - } else { |
|
| 397 | - $delai = "$semaines " . _T('date_semaines'); |
|
| 398 | - } |
|
| 399 | - } else { |
|
| 400 | - if ($decal > 3600 * 24) { |
|
| 401 | - $jours = floor($decal / (3600 * 24)); |
|
| 402 | - if ($jours < 2) { |
|
| 403 | - return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 404 | - } else { |
|
| 405 | - $delai = "$jours " . _T('date_jours'); |
|
| 406 | - } |
|
| 407 | - } else { |
|
| 408 | - if ($decal >= 3600) { |
|
| 409 | - $heures = floor($decal / 3600); |
|
| 410 | - if ($heures < 2) { |
|
| 411 | - $delai = "$heures " . _T('date_une_heure'); |
|
| 412 | - } else { |
|
| 413 | - $delai = "$heures " . _T('date_heures'); |
|
| 414 | - } |
|
| 415 | - } else { |
|
| 416 | - if ($decal >= 60) { |
|
| 417 | - $minutes = floor($decal / 60); |
|
| 418 | - if ($minutes < 2) { |
|
| 419 | - $delai = "$minutes " . _T('date_une_minute'); |
|
| 420 | - } else { |
|
| 421 | - $delai = "$minutes " . _T('date_minutes'); |
|
| 422 | - } |
|
| 423 | - } else { |
|
| 424 | - $secondes = ceil($decal); |
|
| 425 | - if ($secondes < 2) { |
|
| 426 | - $delai = "$secondes " . _T('date_une_seconde'); |
|
| 427 | - } else { |
|
| 428 | - $delai = "$secondes " . _T('date_secondes'); |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - return _T($il_y_a, ['delai' => $delai]); |
|
| 358 | + if (is_null($ref_date)) { |
|
| 359 | + $ref_time = time(); |
|
| 360 | + } else { |
|
| 361 | + $ref_time = strtotime($ref_date); |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + if (!$date) { |
|
| 365 | + return; |
|
| 366 | + } |
|
| 367 | + $decal = date('U', $ref_time) - date('U', strtotime($date)); |
|
| 368 | + |
|
| 369 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 370 | + return ''; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + if ($decal < 0) { |
|
| 374 | + $il_y_a = 'date_dans'; |
|
| 375 | + $decal = -1 * $decal; |
|
| 376 | + } else { |
|
| 377 | + $il_y_a = 'date_il_y_a'; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + if ($decal > 3600 * 24 * 30 * 6) { |
|
| 381 | + return affdate_court($date); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + if ($decal > 3600 * 24 * 30) { |
|
| 385 | + $mois = floor($decal / (3600 * 24 * 30)); |
|
| 386 | + if ($mois < 2) { |
|
| 387 | + $delai = "$mois " . _T('date_un_mois'); |
|
| 388 | + } else { |
|
| 389 | + $delai = "$mois " . _T('date_mois'); |
|
| 390 | + } |
|
| 391 | + } else { |
|
| 392 | + if ($decal > 3600 * 24 * 7) { |
|
| 393 | + $semaines = floor($decal / (3600 * 24 * 7)); |
|
| 394 | + if ($semaines < 2) { |
|
| 395 | + $delai = "$semaines " . _T('date_une_semaine'); |
|
| 396 | + } else { |
|
| 397 | + $delai = "$semaines " . _T('date_semaines'); |
|
| 398 | + } |
|
| 399 | + } else { |
|
| 400 | + if ($decal > 3600 * 24) { |
|
| 401 | + $jours = floor($decal / (3600 * 24)); |
|
| 402 | + if ($jours < 2) { |
|
| 403 | + return $il_y_a == 'date_dans' ? _T('date_demain') : _T('date_hier'); |
|
| 404 | + } else { |
|
| 405 | + $delai = "$jours " . _T('date_jours'); |
|
| 406 | + } |
|
| 407 | + } else { |
|
| 408 | + if ($decal >= 3600) { |
|
| 409 | + $heures = floor($decal / 3600); |
|
| 410 | + if ($heures < 2) { |
|
| 411 | + $delai = "$heures " . _T('date_une_heure'); |
|
| 412 | + } else { |
|
| 413 | + $delai = "$heures " . _T('date_heures'); |
|
| 414 | + } |
|
| 415 | + } else { |
|
| 416 | + if ($decal >= 60) { |
|
| 417 | + $minutes = floor($decal / 60); |
|
| 418 | + if ($minutes < 2) { |
|
| 419 | + $delai = "$minutes " . _T('date_une_minute'); |
|
| 420 | + } else { |
|
| 421 | + $delai = "$minutes " . _T('date_minutes'); |
|
| 422 | + } |
|
| 423 | + } else { |
|
| 424 | + $secondes = ceil($decal); |
|
| 425 | + if ($secondes < 2) { |
|
| 426 | + $delai = "$secondes " . _T('date_une_seconde'); |
|
| 427 | + } else { |
|
| 428 | + $delai = "$secondes " . _T('date_secondes'); |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + return _T($il_y_a, ['delai' => $delai]); |
|
| 437 | 437 | } |
| 438 | 438 | |
| 439 | 439 | |
@@ -459,32 +459,32 @@ discard block |
||
| 459 | 459 | **/ |
| 460 | 460 | function date_relativecourt($date, $decalage_maxi = 0) { |
| 461 | 461 | |
| 462 | - if (!$date) { |
|
| 463 | - return; |
|
| 464 | - } |
|
| 465 | - $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 466 | - |
|
| 467 | - if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 468 | - return ''; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - if ($decal < -24 * 3600) { |
|
| 472 | - $retour = date_relative($date, $decalage_maxi); |
|
| 473 | - } elseif ($decal < 0) { |
|
| 474 | - $retour = _T('date_demain'); |
|
| 475 | - } else { |
|
| 476 | - if ($decal < (3600 * 24)) { |
|
| 477 | - $retour = _T('date_aujourdhui'); |
|
| 478 | - } else { |
|
| 479 | - if ($decal < (3600 * 24 * 2)) { |
|
| 480 | - $retour = _T('date_hier'); |
|
| 481 | - } else { |
|
| 482 | - $retour = date_relative($date, $decalage_maxi); |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - return $retour; |
|
| 462 | + if (!$date) { |
|
| 463 | + return; |
|
| 464 | + } |
|
| 465 | + $decal = date('U', strtotime(date('Y-m-d')) - strtotime(date('Y-m-d', strtotime($date)))); |
|
| 466 | + |
|
| 467 | + if ($decalage_maxi and ($decal > $decalage_maxi or $decal < 0)) { |
|
| 468 | + return ''; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + if ($decal < -24 * 3600) { |
|
| 472 | + $retour = date_relative($date, $decalage_maxi); |
|
| 473 | + } elseif ($decal < 0) { |
|
| 474 | + $retour = _T('date_demain'); |
|
| 475 | + } else { |
|
| 476 | + if ($decal < (3600 * 24)) { |
|
| 477 | + $retour = _T('date_aujourdhui'); |
|
| 478 | + } else { |
|
| 479 | + if ($decal < (3600 * 24 * 2)) { |
|
| 480 | + $retour = _T('date_hier'); |
|
| 481 | + } else { |
|
| 482 | + $retour = date_relative($date, $decalage_maxi); |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + return $retour; |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -503,174 +503,174 @@ discard block |
||
| 503 | 503 | * @return mixed|string |
| 504 | 504 | */ |
| 505 | 505 | function affdate_base($numdate, $vue, $options = []) { |
| 506 | - if (is_string($options)) { |
|
| 507 | - $options = ['param' => $options]; |
|
| 508 | - } |
|
| 509 | - $date_array = recup_date($numdate, false); |
|
| 510 | - if (!$date_array) { |
|
| 511 | - return; |
|
| 512 | - } |
|
| 513 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 514 | - |
|
| 515 | - // 1er, 21st, etc. |
|
| 516 | - $journum = $jour; |
|
| 517 | - |
|
| 518 | - if ($jour == 0) { |
|
| 519 | - $jour = ''; |
|
| 520 | - $njour = 0; |
|
| 521 | - } else { |
|
| 522 | - $njour = intval($jour); |
|
| 523 | - if ($jourth = _T('date_jnum' . $jour)) { |
|
| 524 | - $jour = $jourth; |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - $mois = intval($mois); |
|
| 529 | - if ($mois > 0 and $mois < 13) { |
|
| 530 | - /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 531 | - $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 532 | - $nommois = _T('date_mois_' . $mois . $param); |
|
| 533 | - if ($jour) { |
|
| 534 | - $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 535 | - } else { |
|
| 536 | - $jourmois = $nommois; |
|
| 537 | - } |
|
| 538 | - } else { |
|
| 539 | - $nommois = ''; |
|
| 540 | - $jourmois = ''; |
|
| 541 | - } |
|
| 542 | - |
|
| 543 | - if ($annee < 0) { |
|
| 544 | - $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 545 | - $avjc = true; |
|
| 546 | - } else { |
|
| 547 | - $avjc = false; |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - switch ($vue) { |
|
| 551 | - case 'saison': |
|
| 552 | - case 'saison_annee': |
|
| 553 | - $saison = ''; |
|
| 554 | - if ($mois > 0) { |
|
| 555 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 556 | - if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 557 | - $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 558 | - } |
|
| 559 | - if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 560 | - $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 561 | - } |
|
| 562 | - if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 563 | - $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 564 | - } |
|
| 565 | - if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 566 | - $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 567 | - } |
|
| 568 | - } |
|
| 569 | - if ($vue == 'saison') { |
|
| 570 | - return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 571 | - } else { |
|
| 572 | - return $saison ? trim(_T( |
|
| 573 | - 'date_fmt_saison_annee', |
|
| 574 | - ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 575 | - )) : ''; |
|
| 576 | - } |
|
| 577 | - |
|
| 578 | - case 'court': |
|
| 579 | - if ($avjc) { |
|
| 580 | - return $annee; |
|
| 581 | - } |
|
| 582 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 583 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 584 | - return $annee; |
|
| 585 | - } |
|
| 586 | - if ($annee != $a) { |
|
| 587 | - return _T( |
|
| 588 | - 'date_fmt_mois_annee', |
|
| 589 | - ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 590 | - ); |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - return _T( |
|
| 594 | - 'date_fmt_jour_mois', |
|
| 595 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 596 | - ); |
|
| 597 | - |
|
| 598 | - case 'jourcourt': |
|
| 599 | - if ($avjc) { |
|
| 600 | - return $annee; |
|
| 601 | - } |
|
| 602 | - $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 603 | - if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 604 | - return $annee; |
|
| 605 | - } |
|
| 606 | - if ($annee != $a) { |
|
| 607 | - return _T( |
|
| 608 | - 'date_fmt_jour_mois_annee', |
|
| 609 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 610 | - ); |
|
| 611 | - } |
|
| 612 | - |
|
| 613 | - return _T( |
|
| 614 | - 'date_fmt_jour_mois', |
|
| 615 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 616 | - ); |
|
| 617 | - |
|
| 618 | - case 'entier': |
|
| 619 | - if ($avjc) { |
|
| 620 | - return $annee; |
|
| 621 | - } |
|
| 622 | - if ($jour) { |
|
| 623 | - return _T( |
|
| 624 | - 'date_fmt_jour_mois_annee', |
|
| 625 | - ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 626 | - ); |
|
| 627 | - } elseif ($mois) { |
|
| 628 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 629 | - } else { |
|
| 630 | - return $annee; |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - case 'nom_mois': |
|
| 634 | - return $nommois; |
|
| 635 | - |
|
| 636 | - case 'mois': |
|
| 637 | - return sprintf('%02s', $mois); |
|
| 638 | - |
|
| 639 | - case 'jour': |
|
| 640 | - return $jour; |
|
| 641 | - |
|
| 642 | - case 'journum': |
|
| 643 | - return $journum; |
|
| 644 | - |
|
| 645 | - case 'nom_jour': |
|
| 646 | - if (!$mois or !$njour) { |
|
| 647 | - return ''; |
|
| 648 | - } |
|
| 649 | - $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 650 | - $nom = 1 + date('w', $nom); |
|
| 651 | - $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 652 | - |
|
| 653 | - return _T('date_jour_' . $nom . $param); |
|
| 654 | - |
|
| 655 | - case 'mois_annee': |
|
| 656 | - if ($avjc) { |
|
| 657 | - return $annee; |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 661 | - |
|
| 662 | - case 'annee': |
|
| 663 | - return $annee; |
|
| 664 | - |
|
| 665 | - // Cas d'une vue non definie : retomber sur le format |
|
| 666 | - // de date propose par http://www.php.net/date |
|
| 667 | - default: |
|
| 668 | - [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 669 | - if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 670 | - $time = strtotime($numdate); |
|
| 671 | - } |
|
| 672 | - return date($vue, $time); |
|
| 673 | - } |
|
| 506 | + if (is_string($options)) { |
|
| 507 | + $options = ['param' => $options]; |
|
| 508 | + } |
|
| 509 | + $date_array = recup_date($numdate, false); |
|
| 510 | + if (!$date_array) { |
|
| 511 | + return; |
|
| 512 | + } |
|
| 513 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 514 | + |
|
| 515 | + // 1er, 21st, etc. |
|
| 516 | + $journum = $jour; |
|
| 517 | + |
|
| 518 | + if ($jour == 0) { |
|
| 519 | + $jour = ''; |
|
| 520 | + $njour = 0; |
|
| 521 | + } else { |
|
| 522 | + $njour = intval($jour); |
|
| 523 | + if ($jourth = _T('date_jnum' . $jour)) { |
|
| 524 | + $jour = $jourth; |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + $mois = intval($mois); |
|
| 529 | + if ($mois > 0 and $mois < 13) { |
|
| 530 | + /* Traiter le cas "abbr" pour les noms de mois */ |
|
| 531 | + $param = ((isset($options['param']) and $options['param'] === 'abbr') ? '_' . $options['param'] : ''); |
|
| 532 | + $nommois = _T('date_mois_' . $mois . $param); |
|
| 533 | + if ($jour) { |
|
| 534 | + $jourmois = _T('date_de_mois_' . $mois, ['j' => $jour, 'nommois' => $nommois]); |
|
| 535 | + } else { |
|
| 536 | + $jourmois = $nommois; |
|
| 537 | + } |
|
| 538 | + } else { |
|
| 539 | + $nommois = ''; |
|
| 540 | + $jourmois = ''; |
|
| 541 | + } |
|
| 542 | + |
|
| 543 | + if ($annee < 0) { |
|
| 544 | + $annee = -$annee . ' ' . _T('date_avant_jc'); |
|
| 545 | + $avjc = true; |
|
| 546 | + } else { |
|
| 547 | + $avjc = false; |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + switch ($vue) { |
|
| 551 | + case 'saison': |
|
| 552 | + case 'saison_annee': |
|
| 553 | + $saison = ''; |
|
| 554 | + if ($mois > 0) { |
|
| 555 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 556 | + if (($mois == 3 and $jour >= 21) or $mois > 3) { |
|
| 557 | + $saison = ($options['param'] == 'sud') ? 4 : 2; |
|
| 558 | + } |
|
| 559 | + if (($mois == 6 and $jour >= 21) or $mois > 6) { |
|
| 560 | + $saison = ($options['param'] == 'sud') ? 1 : 3; |
|
| 561 | + } |
|
| 562 | + if (($mois == 9 and $jour >= 21) or $mois > 9) { |
|
| 563 | + $saison = ($options['param'] == 'sud') ? 2 : 4; |
|
| 564 | + } |
|
| 565 | + if (($mois == 12 and $jour >= 21) or $mois > 12) { |
|
| 566 | + $saison = ($options['param'] == 'sud') ? 3 : 1; |
|
| 567 | + } |
|
| 568 | + } |
|
| 569 | + if ($vue == 'saison') { |
|
| 570 | + return $saison ? _T('date_saison_' . $saison) : ''; |
|
| 571 | + } else { |
|
| 572 | + return $saison ? trim(_T( |
|
| 573 | + 'date_fmt_saison_annee', |
|
| 574 | + ['saison' => _T('date_saison_' . $saison), 'annee' => $annee] |
|
| 575 | + )) : ''; |
|
| 576 | + } |
|
| 577 | + |
|
| 578 | + case 'court': |
|
| 579 | + if ($avjc) { |
|
| 580 | + return $annee; |
|
| 581 | + } |
|
| 582 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 583 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 584 | + return $annee; |
|
| 585 | + } |
|
| 586 | + if ($annee != $a) { |
|
| 587 | + return _T( |
|
| 588 | + 'date_fmt_mois_annee', |
|
| 589 | + ['mois' => $mois, 'nommois' => spip_ucfirst($nommois), 'annee' => $annee] |
|
| 590 | + ); |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + return _T( |
|
| 594 | + 'date_fmt_jour_mois', |
|
| 595 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 596 | + ); |
|
| 597 | + |
|
| 598 | + case 'jourcourt': |
|
| 599 | + if ($avjc) { |
|
| 600 | + return $annee; |
|
| 601 | + } |
|
| 602 | + $a = ((isset($options['annee_courante']) and $options['annee_courante']) ? $options['annee_courante'] : date('Y')); |
|
| 603 | + if ($annee < ($a - 100) or $annee > ($a + 100)) { |
|
| 604 | + return $annee; |
|
| 605 | + } |
|
| 606 | + if ($annee != $a) { |
|
| 607 | + return _T( |
|
| 608 | + 'date_fmt_jour_mois_annee', |
|
| 609 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 610 | + ); |
|
| 611 | + } |
|
| 612 | + |
|
| 613 | + return _T( |
|
| 614 | + 'date_fmt_jour_mois', |
|
| 615 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 616 | + ); |
|
| 617 | + |
|
| 618 | + case 'entier': |
|
| 619 | + if ($avjc) { |
|
| 620 | + return $annee; |
|
| 621 | + } |
|
| 622 | + if ($jour) { |
|
| 623 | + return _T( |
|
| 624 | + 'date_fmt_jour_mois_annee', |
|
| 625 | + ['jourmois' => $jourmois, 'jour' => $jour, 'mois' => $mois, 'nommois' => $nommois, 'annee' => $annee] |
|
| 626 | + ); |
|
| 627 | + } elseif ($mois) { |
|
| 628 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 629 | + } else { |
|
| 630 | + return $annee; |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + case 'nom_mois': |
|
| 634 | + return $nommois; |
|
| 635 | + |
|
| 636 | + case 'mois': |
|
| 637 | + return sprintf('%02s', $mois); |
|
| 638 | + |
|
| 639 | + case 'jour': |
|
| 640 | + return $jour; |
|
| 641 | + |
|
| 642 | + case 'journum': |
|
| 643 | + return $journum; |
|
| 644 | + |
|
| 645 | + case 'nom_jour': |
|
| 646 | + if (!$mois or !$njour) { |
|
| 647 | + return ''; |
|
| 648 | + } |
|
| 649 | + $nom = mktime(1, 1, 1, $mois, $njour, $annee); |
|
| 650 | + $nom = 1 + date('w', $nom); |
|
| 651 | + $param = ((isset($options['param']) and $options['param']) ? '_' . $options['param'] : ''); |
|
| 652 | + |
|
| 653 | + return _T('date_jour_' . $nom . $param); |
|
| 654 | + |
|
| 655 | + case 'mois_annee': |
|
| 656 | + if ($avjc) { |
|
| 657 | + return $annee; |
|
| 658 | + } |
|
| 659 | + |
|
| 660 | + return trim(_T('date_fmt_mois_annee', ['mois' => $mois, 'nommois' => $nommois, 'annee' => $annee])); |
|
| 661 | + |
|
| 662 | + case 'annee': |
|
| 663 | + return $annee; |
|
| 664 | + |
|
| 665 | + // Cas d'une vue non definie : retomber sur le format |
|
| 666 | + // de date propose par http://www.php.net/date |
|
| 667 | + default: |
|
| 668 | + [$annee, $mois, $jour, $heures, $minutes, $secondes] = $date_array; |
|
| 669 | + if (!$time = mktime($heures, $minutes, $secondes, $mois, (int) $jour, $annee)) { |
|
| 670 | + $time = strtotime($numdate); |
|
| 671 | + } |
|
| 672 | + return date($vue, $time); |
|
| 673 | + } |
|
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | |
@@ -697,11 +697,11 @@ discard block |
||
| 697 | 697 | * Nom du jour |
| 698 | 698 | **/ |
| 699 | 699 | function nom_jour($numdate, $forme = '') { |
| 700 | - if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 701 | - $forme = ''; |
|
| 702 | - } |
|
| 700 | + if (!($forme == 'abbr' or $forme == 'initiale')) { |
|
| 701 | + $forme = ''; |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | - return affdate_base($numdate, 'nom_jour', $forme); |
|
| 704 | + return affdate_base($numdate, 'nom_jour', $forme); |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | * Numéro du jour |
| 724 | 724 | **/ |
| 725 | 725 | function jour($numdate) { |
| 726 | - return affdate_base($numdate, 'jour'); |
|
| 726 | + return affdate_base($numdate, 'jour'); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /** |
@@ -741,7 +741,7 @@ discard block |
||
| 741 | 741 | * Numéro du jour |
| 742 | 742 | **/ |
| 743 | 743 | function journum($numdate) { |
| 744 | - return affdate_base($numdate, 'journum'); |
|
| 744 | + return affdate_base($numdate, 'journum'); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | * Numéro du mois (sur 2 chiffres) |
| 760 | 760 | **/ |
| 761 | 761 | function mois($numdate) { |
| 762 | - return affdate_base($numdate, 'mois'); |
|
| 762 | + return affdate_base($numdate, 'mois'); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | /** |
@@ -783,11 +783,11 @@ discard block |
||
| 783 | 783 | * Nom du mois |
| 784 | 784 | **/ |
| 785 | 785 | function nom_mois($numdate, $forme = '') { |
| 786 | - if (!($forme == 'abbr')) { |
|
| 787 | - $forme = ''; |
|
| 788 | - } |
|
| 786 | + if (!($forme == 'abbr')) { |
|
| 787 | + $forme = ''; |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - return affdate_base($numdate, 'nom_mois', $forme); |
|
| 790 | + return affdate_base($numdate, 'nom_mois', $forme); |
|
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | /** |
@@ -805,7 +805,7 @@ discard block |
||
| 805 | 805 | * Année (sur 4 chiffres) |
| 806 | 806 | **/ |
| 807 | 807 | function annee($numdate) { |
| 808 | - return affdate_base($numdate, 'annee'); |
|
| 808 | + return affdate_base($numdate, 'annee'); |
|
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | |
@@ -835,11 +835,11 @@ discard block |
||
| 835 | 835 | * La date formatée |
| 836 | 836 | **/ |
| 837 | 837 | function saison($numdate, $hemisphere = 'nord') { |
| 838 | - if ($hemisphere != 'sud') { |
|
| 839 | - $hemisphere = 'nord'; |
|
| 840 | - } |
|
| 838 | + if ($hemisphere != 'sud') { |
|
| 839 | + $hemisphere = 'nord'; |
|
| 840 | + } |
|
| 841 | 841 | |
| 842 | - return affdate_base($numdate, 'saison', $hemisphere); |
|
| 842 | + return affdate_base($numdate, 'saison', $hemisphere); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | 845 | |
@@ -868,11 +868,11 @@ discard block |
||
| 868 | 868 | * La date formatée |
| 869 | 869 | **/ |
| 870 | 870 | function saison_annee($numdate, $hemisphere = 'nord') { |
| 871 | - if ($hemisphere != 'sud') { |
|
| 872 | - $hemisphere = 'nord'; |
|
| 873 | - } |
|
| 871 | + if ($hemisphere != 'sud') { |
|
| 872 | + $hemisphere = 'nord'; |
|
| 873 | + } |
|
| 874 | 874 | |
| 875 | - return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 875 | + return affdate_base($numdate, 'saison_annee', $hemisphere); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | /** |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | * La date formatée |
| 901 | 901 | **/ |
| 902 | 902 | function affdate($numdate, $format = 'entier') { |
| 903 | - return affdate_base($numdate, $format); |
|
| 903 | + return affdate_base($numdate, $format); |
|
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | * La date formatée |
| 928 | 928 | **/ |
| 929 | 929 | function affdate_court($numdate, $annee_courante = null) { |
| 930 | - return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 930 | + return affdate_base($numdate, 'court', ['annee_courante' => $annee_courante]); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | * La date formatée |
| 955 | 955 | **/ |
| 956 | 956 | function affdate_jourcourt($numdate, $annee_courante = null) { |
| 957 | - return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 957 | + return affdate_base($numdate, 'jourcourt', ['annee_courante' => $annee_courante]); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | /** |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | * La date formatée |
| 973 | 973 | **/ |
| 974 | 974 | function affdate_mois_annee($numdate) { |
| 975 | - return affdate_base($numdate, 'mois_annee'); |
|
| 975 | + return affdate_base($numdate, 'mois_annee'); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | /** |
@@ -990,16 +990,16 @@ discard block |
||
| 990 | 990 | * La date formatée |
| 991 | 991 | **/ |
| 992 | 992 | function affdate_heure($numdate) { |
| 993 | - $date_array = recup_date($numdate); |
|
| 994 | - if (!$date_array) { |
|
| 995 | - return; |
|
| 996 | - } |
|
| 997 | - [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 998 | - |
|
| 999 | - return _T('date_fmt_jour_heure', [ |
|
| 1000 | - 'jour' => affdate($numdate), |
|
| 1001 | - 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1002 | - ]); |
|
| 993 | + $date_array = recup_date($numdate); |
|
| 994 | + if (!$date_array) { |
|
| 995 | + return; |
|
| 996 | + } |
|
| 997 | + [$annee, $mois, $jour, $heures, $minutes, $sec] = $date_array; |
|
| 998 | + |
|
| 999 | + return _T('date_fmt_jour_heure', [ |
|
| 1000 | + 'jour' => affdate($numdate), |
|
| 1001 | + 'heure' => _T('date_fmt_heures_minutes', ['h' => $heures, 'm' => $minutes]) |
|
| 1002 | + ]); |
|
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | 1005 | /** |
@@ -1031,117 +1031,117 @@ discard block |
||
| 1031 | 1031 | * Texte de la date |
| 1032 | 1032 | */ |
| 1033 | 1033 | function affdate_debut_fin($date_debut, $date_fin, $horaire = 'oui', $forme = '') { |
| 1034 | - $abbr = $jour = ''; |
|
| 1035 | - $affdate = 'affdate_jourcourt'; |
|
| 1036 | - if (strpos($forme, 'abbr') !== false) { |
|
| 1037 | - $abbr = 'abbr'; |
|
| 1038 | - } |
|
| 1039 | - if (strpos($forme, 'annee') !== false) { |
|
| 1040 | - $affdate = 'affdate'; |
|
| 1041 | - } |
|
| 1042 | - if (strpos($forme, 'jour') !== false) { |
|
| 1043 | - $jour = 'jour'; |
|
| 1044 | - } |
|
| 1045 | - |
|
| 1046 | - $dtstart = $dtend = $dtabbr = ''; |
|
| 1047 | - if (strpos($forme, 'hcal') !== false) { |
|
| 1048 | - $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1049 | - $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1050 | - $dtabbr = '</abbr>'; |
|
| 1051 | - } |
|
| 1052 | - |
|
| 1053 | - $date_debut = strtotime($date_debut); |
|
| 1054 | - $date_fin = strtotime($date_fin); |
|
| 1055 | - $d = date('Y-m-d', $date_debut); |
|
| 1056 | - $f = date('Y-m-d', $date_fin); |
|
| 1057 | - $h = ($horaire === 'oui' or $horaire === true); |
|
| 1058 | - $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1059 | - $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1060 | - |
|
| 1061 | - if ($d == $f) { // meme jour |
|
| 1062 | - $nomjour = nom_jour($d, $abbr); |
|
| 1063 | - $s = $affdate($d); |
|
| 1064 | - $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1065 | - if ($h) { |
|
| 1066 | - if ($hd == $hf) { |
|
| 1067 | - // Lundi 20 fevrier a 18h25 |
|
| 1068 | - $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1069 | - $s = "$dtstart$s$dtabbr"; |
|
| 1070 | - } else { |
|
| 1071 | - // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1072 | - if ($dtabbr && $dtstart && $dtend) { |
|
| 1073 | - $s = _T( |
|
| 1074 | - 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1075 | - [ |
|
| 1076 | - 'jour' => spip_ucfirst($s), |
|
| 1077 | - 'heure_debut' => $hd, |
|
| 1078 | - 'heure_fin' => $hf, |
|
| 1079 | - 'dtstart' => $dtstart, |
|
| 1080 | - 'dtend' => $dtend, |
|
| 1081 | - 'dtabbr' => $dtabbr |
|
| 1082 | - ], |
|
| 1083 | - [ |
|
| 1084 | - 'sanitize' => false |
|
| 1085 | - ] |
|
| 1086 | - ); |
|
| 1087 | - } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1088 | - else { |
|
| 1089 | - $s = spip_ucfirst(_T( |
|
| 1090 | - 'date_fmt_jour_heure_debut_fin', |
|
| 1091 | - ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1092 | - )); |
|
| 1093 | - } |
|
| 1094 | - } |
|
| 1095 | - } else { |
|
| 1096 | - if ($dtabbr && $dtstart) { |
|
| 1097 | - $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1098 | - } else { |
|
| 1099 | - $s = spip_ucfirst($s); |
|
| 1100 | - } |
|
| 1101 | - } |
|
| 1102 | - } else { |
|
| 1103 | - if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1104 | - if (!$h) { |
|
| 1105 | - $date_debut = jour($d); |
|
| 1106 | - } else { |
|
| 1107 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1108 | - } |
|
| 1109 | - $date_fin = $affdate($f); |
|
| 1110 | - if ($jour) { |
|
| 1111 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1112 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1113 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1114 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1115 | - } |
|
| 1116 | - if ($h) { |
|
| 1117 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1118 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1119 | - } |
|
| 1120 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1121 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1122 | - |
|
| 1123 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1124 | - } else { |
|
| 1125 | - $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1126 | - $date_fin = $affdate($f); |
|
| 1127 | - if ($jour) { |
|
| 1128 | - $nomjour_debut = nom_jour($d, $abbr); |
|
| 1129 | - $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1130 | - $nomjour_fin = nom_jour($f, $abbr); |
|
| 1131 | - $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1132 | - } |
|
| 1133 | - if ($h) { |
|
| 1134 | - $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1135 | - $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1136 | - } |
|
| 1137 | - |
|
| 1138 | - $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1139 | - $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1140 | - $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1141 | - } |
|
| 1142 | - } |
|
| 1143 | - |
|
| 1144 | - return $s; |
|
| 1034 | + $abbr = $jour = ''; |
|
| 1035 | + $affdate = 'affdate_jourcourt'; |
|
| 1036 | + if (strpos($forme, 'abbr') !== false) { |
|
| 1037 | + $abbr = 'abbr'; |
|
| 1038 | + } |
|
| 1039 | + if (strpos($forme, 'annee') !== false) { |
|
| 1040 | + $affdate = 'affdate'; |
|
| 1041 | + } |
|
| 1042 | + if (strpos($forme, 'jour') !== false) { |
|
| 1043 | + $jour = 'jour'; |
|
| 1044 | + } |
|
| 1045 | + |
|
| 1046 | + $dtstart = $dtend = $dtabbr = ''; |
|
| 1047 | + if (strpos($forme, 'hcal') !== false) { |
|
| 1048 | + $dtstart = "<abbr class='dtstart' title='" . date_iso($date_debut) . "'>"; |
|
| 1049 | + $dtend = "<abbr class='dtend' title='" . date_iso($date_fin) . "'>"; |
|
| 1050 | + $dtabbr = '</abbr>'; |
|
| 1051 | + } |
|
| 1052 | + |
|
| 1053 | + $date_debut = strtotime($date_debut); |
|
| 1054 | + $date_fin = strtotime($date_fin); |
|
| 1055 | + $d = date('Y-m-d', $date_debut); |
|
| 1056 | + $f = date('Y-m-d', $date_fin); |
|
| 1057 | + $h = ($horaire === 'oui' or $horaire === true); |
|
| 1058 | + $hd = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_debut), 'm' => date('i', $date_debut)]); |
|
| 1059 | + $hf = _T('date_fmt_heures_minutes_court', ['h' => date('H', $date_fin), 'm' => date('i', $date_fin)]); |
|
| 1060 | + |
|
| 1061 | + if ($d == $f) { // meme jour |
|
| 1062 | + $nomjour = nom_jour($d, $abbr); |
|
| 1063 | + $s = $affdate($d); |
|
| 1064 | + $s = _T('date_fmt_jour', ['nomjour' => $nomjour, 'jour' => $s]); |
|
| 1065 | + if ($h) { |
|
| 1066 | + if ($hd == $hf) { |
|
| 1067 | + // Lundi 20 fevrier a 18h25 |
|
| 1068 | + $s = spip_ucfirst(_T('date_fmt_jour_heure', ['jour' => $s, 'heure' => $hd])); |
|
| 1069 | + $s = "$dtstart$s$dtabbr"; |
|
| 1070 | + } else { |
|
| 1071 | + // Le <abbr...>lundi 20 fevrier de 18h00</abbr> a <abbr...>20h00</abbr> |
|
| 1072 | + if ($dtabbr && $dtstart && $dtend) { |
|
| 1073 | + $s = _T( |
|
| 1074 | + 'date_fmt_jour_heure_debut_fin_abbr', |
|
| 1075 | + [ |
|
| 1076 | + 'jour' => spip_ucfirst($s), |
|
| 1077 | + 'heure_debut' => $hd, |
|
| 1078 | + 'heure_fin' => $hf, |
|
| 1079 | + 'dtstart' => $dtstart, |
|
| 1080 | + 'dtend' => $dtend, |
|
| 1081 | + 'dtabbr' => $dtabbr |
|
| 1082 | + ], |
|
| 1083 | + [ |
|
| 1084 | + 'sanitize' => false |
|
| 1085 | + ] |
|
| 1086 | + ); |
|
| 1087 | + } // Le lundi 20 fevrier de 18h00 a 20h00 |
|
| 1088 | + else { |
|
| 1089 | + $s = spip_ucfirst(_T( |
|
| 1090 | + 'date_fmt_jour_heure_debut_fin', |
|
| 1091 | + ['jour' => $s, 'heure_debut' => $hd, 'heure_fin' => $hf] |
|
| 1092 | + )); |
|
| 1093 | + } |
|
| 1094 | + } |
|
| 1095 | + } else { |
|
| 1096 | + if ($dtabbr && $dtstart) { |
|
| 1097 | + $s = $dtstart . spip_ucfirst($s) . $dtabbr; |
|
| 1098 | + } else { |
|
| 1099 | + $s = spip_ucfirst($s); |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1102 | + } else { |
|
| 1103 | + if ((date('Y-m', $date_debut)) == date('Y-m', $date_fin)) { // meme annee et mois, jours differents |
|
| 1104 | + if (!$h) { |
|
| 1105 | + $date_debut = jour($d); |
|
| 1106 | + } else { |
|
| 1107 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1108 | + } |
|
| 1109 | + $date_fin = $affdate($f); |
|
| 1110 | + if ($jour) { |
|
| 1111 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1112 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1113 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1114 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1115 | + } |
|
| 1116 | + if ($h) { |
|
| 1117 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1118 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1119 | + } |
|
| 1120 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1121 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1122 | + |
|
| 1123 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1124 | + } else { |
|
| 1125 | + $date_debut = affdate_jourcourt($d, date('Y', $date_fin)); |
|
| 1126 | + $date_fin = $affdate($f); |
|
| 1127 | + if ($jour) { |
|
| 1128 | + $nomjour_debut = nom_jour($d, $abbr); |
|
| 1129 | + $date_debut = _T('date_fmt_jour', ['nomjour' => $nomjour_debut, 'jour' => $date_debut]); |
|
| 1130 | + $nomjour_fin = nom_jour($f, $abbr); |
|
| 1131 | + $date_fin = _T('date_fmt_jour', ['nomjour' => $nomjour_fin, 'jour' => $date_fin]); |
|
| 1132 | + } |
|
| 1133 | + if ($h) { |
|
| 1134 | + $date_debut = _T('date_fmt_jour_heure', ['jour' => $date_debut, 'heure' => $hd]); |
|
| 1135 | + $date_fin = _T('date_fmt_jour_heure', ['jour' => $date_fin, 'heure' => $hf]); |
|
| 1136 | + } |
|
| 1137 | + |
|
| 1138 | + $date_debut = $dtstart . $date_debut . $dtabbr; |
|
| 1139 | + $date_fin = $dtend . $date_fin . $dtabbr; |
|
| 1140 | + $s = _T('date_fmt_periode', ['date_debut' => $date_debut, 'date_fin' => $date_fin]); |
|
| 1141 | + } |
|
| 1142 | + } |
|
| 1143 | + |
|
| 1144 | + return $s; |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
@@ -1162,10 +1162,10 @@ discard block |
||
| 1162 | 1162 | * Date au format ical |
| 1163 | 1163 | **/ |
| 1164 | 1164 | function date_ical($date, $addminutes = 0) { |
| 1165 | - [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1166 | - [$annee, $mois, $jour] = recup_date($date); |
|
| 1165 | + [$heures, $minutes, $secondes] = recup_heure($date); |
|
| 1166 | + [$annee, $mois, $jour] = recup_date($date); |
|
| 1167 | 1167 | |
| 1168 | - return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1168 | + return gmdate('Ymd\THis\Z', mktime($heures, $minutes + $addminutes, $secondes, $mois, $jour, $annee)); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | |
@@ -1189,11 +1189,11 @@ discard block |
||
| 1189 | 1189 | * La date formatée |
| 1190 | 1190 | **/ |
| 1191 | 1191 | function date_iso($date_heure) { |
| 1192 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1193 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1194 | - $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1192 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1193 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1194 | + $time = @mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1195 | 1195 | |
| 1196 | - return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1196 | + return gmdate('Y-m-d\TH:i:s\Z', $time); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | /** |
@@ -1216,11 +1216,11 @@ discard block |
||
| 1216 | 1216 | * La date formatée |
| 1217 | 1217 | **/ |
| 1218 | 1218 | function date_822($date_heure) { |
| 1219 | - [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1220 | - [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1221 | - $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1219 | + [$annee, $mois, $jour] = recup_date($date_heure); |
|
| 1220 | + [$heures, $minutes, $secondes] = recup_heure($date_heure); |
|
| 1221 | + $time = mktime($heures, $minutes, $secondes, $mois, $jour, $annee); |
|
| 1222 | 1222 | |
| 1223 | - return date('r', $time); |
|
| 1223 | + return date('r', $time); |
|
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | /** |
@@ -1236,11 +1236,11 @@ discard block |
||
| 1236 | 1236 | * Date au format `Ymd` |
| 1237 | 1237 | **/ |
| 1238 | 1238 | function date_anneemoisjour($d) { |
| 1239 | - if (!$d) { |
|
| 1240 | - $d = date('Y-m-d'); |
|
| 1241 | - } |
|
| 1239 | + if (!$d) { |
|
| 1240 | + $d = date('Y-m-d'); |
|
| 1241 | + } |
|
| 1242 | 1242 | |
| 1243 | - return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1243 | + return substr($d, 0, 4) . substr($d, 5, 2) . substr($d, 8, 2); |
|
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | /** |
@@ -1256,11 +1256,11 @@ discard block |
||
| 1256 | 1256 | * Date au format `Ym` |
| 1257 | 1257 | **/ |
| 1258 | 1258 | function date_anneemois($d) { |
| 1259 | - if (!$d) { |
|
| 1260 | - $d = date('Y-m-d'); |
|
| 1261 | - } |
|
| 1259 | + if (!$d) { |
|
| 1260 | + $d = date('Y-m-d'); |
|
| 1261 | + } |
|
| 1262 | 1262 | |
| 1263 | - return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1263 | + return substr($d, 0, 4) . substr($d, 5, 2); |
|
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | /** |
@@ -1276,13 +1276,13 @@ discard block |
||
| 1276 | 1276 | * Date au lundi de la même semaine au format `Ymd` |
| 1277 | 1277 | **/ |
| 1278 | 1278 | function date_debut_semaine($annee, $mois, $jour) { |
| 1279 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1280 | - if ($w_day == 0) { |
|
| 1281 | - $w_day = 7; |
|
| 1282 | - } // Gaffe: le dimanche est zero |
|
| 1283 | - $debut = $jour - $w_day + 1; |
|
| 1279 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1280 | + if ($w_day == 0) { |
|
| 1281 | + $w_day = 7; |
|
| 1282 | + } // Gaffe: le dimanche est zero |
|
| 1283 | + $debut = $jour - $w_day + 1; |
|
| 1284 | 1284 | |
| 1285 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1285 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut, $annee)); |
|
| 1286 | 1286 | } |
| 1287 | 1287 | |
| 1288 | 1288 | /** |
@@ -1298,11 +1298,11 @@ discard block |
||
| 1298 | 1298 | * Date au dimanche de la même semaine au format `Ymd` |
| 1299 | 1299 | **/ |
| 1300 | 1300 | function date_fin_semaine($annee, $mois, $jour) { |
| 1301 | - $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1302 | - if ($w_day == 0) { |
|
| 1303 | - $w_day = 7; |
|
| 1304 | - } // Gaffe: le dimanche est zero |
|
| 1305 | - $debut = $jour - $w_day + 1; |
|
| 1301 | + $w_day = date('w', mktime(0, 0, 0, $mois, $jour, $annee)); |
|
| 1302 | + if ($w_day == 0) { |
|
| 1303 | + $w_day = 7; |
|
| 1304 | + } // Gaffe: le dimanche est zero |
|
| 1305 | + $debut = $jour - $w_day + 1; |
|
| 1306 | 1306 | |
| 1307 | - return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1307 | + return date('Ymd', mktime(0, 0, 0, $mois, $debut + 6, $annee)); |
|
| 1308 | 1308 | } |
@@ -416,7 +416,7 @@ |
||
| 416 | 416 | $h = generer_action_auteur('instituer_objet', "$type-$id-$statut"); |
| 417 | 417 | $t = supprimer_tags($titre); |
| 418 | 418 | |
| 419 | - return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>'; |
|
| 419 | + return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>".http_img_pack($img, $t).'</a>'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // compat |
@@ -18,18 +18,18 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if (!defined('_ACTIVER_PUCE_RAPIDE')) { |
| 25 | - /** |
|
| 26 | - * Activer le changement rapide de statut sur les listes d'objets ? |
|
| 27 | - * |
|
| 28 | - * Peut ralentir un site sur des listes très longues. |
|
| 29 | - * |
|
| 30 | - * @var bool |
|
| 31 | - **/ |
|
| 32 | - define('_ACTIVER_PUCE_RAPIDE', true); |
|
| 25 | + /** |
|
| 26 | + * Activer le changement rapide de statut sur les listes d'objets ? |
|
| 27 | + * |
|
| 28 | + * Peut ralentir un site sur des listes très longues. |
|
| 29 | + * |
|
| 30 | + * @var bool |
|
| 31 | + **/ |
|
| 32 | + define('_ACTIVER_PUCE_RAPIDE', true); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -57,31 +57,31 @@ discard block |
||
| 57 | 57 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 58 | 58 | */ |
| 59 | 59 | function inc_puce_statut_dist( |
| 60 | - $id_objet, |
|
| 61 | - $statut, |
|
| 62 | - $id_parent, |
|
| 63 | - $type, |
|
| 64 | - $ajax = false, |
|
| 65 | - $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 60 | + $id_objet, |
|
| 61 | + $statut, |
|
| 62 | + $id_parent, |
|
| 63 | + $type, |
|
| 64 | + $ajax = false, |
|
| 65 | + $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 66 | 66 | ) { |
| 67 | - static $f_puce_statut = []; |
|
| 68 | - $type = objet_type($type); |
|
| 69 | - // cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques |
|
| 70 | - if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) { |
|
| 71 | - $f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true); |
|
| 72 | - } |
|
| 73 | - if ($f_puce_statut[$type]) { |
|
| 74 | - return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // si statut_image trouve quelque chose (et '' est quelque chose) |
|
| 78 | - // composer une puce, avec si possible changement rapide |
|
| 79 | - elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) { |
|
| 80 | - return $puce; |
|
| 81 | - } // sinon fausse puce avec le type de l'image |
|
| 82 | - else { |
|
| 83 | - return http_img_pack("$type-16.png", ''); |
|
| 84 | - } |
|
| 67 | + static $f_puce_statut = []; |
|
| 68 | + $type = objet_type($type); |
|
| 69 | + // cas prioritaire : fonction perso, qui permet aussi de gerer les cas historiques |
|
| 70 | + if (!isset($f_puce_statut[$type]) or is_null($f_puce_statut[$type])) { |
|
| 71 | + $f_puce_statut[$type] = charger_fonction($type, 'puce_statut', true); |
|
| 72 | + } |
|
| 73 | + if ($f_puce_statut[$type]) { |
|
| 74 | + return $f_puce_statut[$type]($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // si statut_image trouve quelque chose (et '' est quelque chose) |
|
| 78 | + // composer une puce, avec si possible changement rapide |
|
| 79 | + elseif (!is_null($puce = puce_statut_changement_rapide($id_objet, $statut, $id_parent, $type, $ajax, $menu_rapide))) { |
|
| 80 | + return $puce; |
|
| 81 | + } // sinon fausse puce avec le type de l'image |
|
| 82 | + else { |
|
| 83 | + return http_img_pack("$type-16.png", ''); |
|
| 84 | + } |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -110,41 +110,41 @@ discard block |
||
| 110 | 110 | * null si pas capable de déterminer l'image |
| 111 | 111 | */ |
| 112 | 112 | function statut_image($objet, $statut) { |
| 113 | - $src = null; |
|
| 114 | - $table = table_objet_sql($objet); |
|
| 115 | - $desc = lister_tables_objets_sql($table); |
|
| 116 | - if (isset($desc['statut_images'])) { |
|
| 117 | - // si une declaration statut_images |
|
| 118 | - // mais rien pour le statut demande, ne rien afficher |
|
| 119 | - $src = ''; |
|
| 120 | - if (isset($desc['statut_images'][$statut])) { |
|
| 121 | - $src = $desc['statut_images'][$statut]; |
|
| 122 | - } // sinon image par defaut ? |
|
| 123 | - elseif (isset($desc['statut_images'][0])) { |
|
| 124 | - $src = $desc['statut_images'][0]; |
|
| 125 | - } |
|
| 126 | - } else { |
|
| 127 | - switch ($statut) { |
|
| 128 | - case 'prepa': |
|
| 129 | - $src = 'puce-preparer-xx.svg?12px'; |
|
| 130 | - break; |
|
| 131 | - case 'prop': |
|
| 132 | - $src = 'puce-proposer-xx.svg?12px'; |
|
| 133 | - break; |
|
| 134 | - case 'publie': |
|
| 135 | - $src = 'puce-publier-xx.svg?12px'; |
|
| 136 | - break; |
|
| 137 | - case 'refuse': |
|
| 138 | - $src = 'puce-refuser-xx.svg?12px'; |
|
| 139 | - break; |
|
| 140 | - case 'poubelle': |
|
| 141 | - case 'poub': |
|
| 142 | - $src = 'puce-supprimer-xx.svg?12px'; |
|
| 143 | - break; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - return $src; |
|
| 113 | + $src = null; |
|
| 114 | + $table = table_objet_sql($objet); |
|
| 115 | + $desc = lister_tables_objets_sql($table); |
|
| 116 | + if (isset($desc['statut_images'])) { |
|
| 117 | + // si une declaration statut_images |
|
| 118 | + // mais rien pour le statut demande, ne rien afficher |
|
| 119 | + $src = ''; |
|
| 120 | + if (isset($desc['statut_images'][$statut])) { |
|
| 121 | + $src = $desc['statut_images'][$statut]; |
|
| 122 | + } // sinon image par defaut ? |
|
| 123 | + elseif (isset($desc['statut_images'][0])) { |
|
| 124 | + $src = $desc['statut_images'][0]; |
|
| 125 | + } |
|
| 126 | + } else { |
|
| 127 | + switch ($statut) { |
|
| 128 | + case 'prepa': |
|
| 129 | + $src = 'puce-preparer-xx.svg?12px'; |
|
| 130 | + break; |
|
| 131 | + case 'prop': |
|
| 132 | + $src = 'puce-proposer-xx.svg?12px'; |
|
| 133 | + break; |
|
| 134 | + case 'publie': |
|
| 135 | + $src = 'puce-publier-xx.svg?12px'; |
|
| 136 | + break; |
|
| 137 | + case 'refuse': |
|
| 138 | + $src = 'puce-refuser-xx.svg?12px'; |
|
| 139 | + break; |
|
| 140 | + case 'poubelle': |
|
| 141 | + case 'poub': |
|
| 142 | + $src = 'puce-supprimer-xx.svg?12px'; |
|
| 143 | + break; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + return $src; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -172,40 +172,40 @@ discard block |
||
| 172 | 172 | * @return string |
| 173 | 173 | */ |
| 174 | 174 | function statut_titre($objet, $statut) { |
| 175 | - $titre = ''; |
|
| 176 | - $table = table_objet_sql($objet); |
|
| 177 | - $desc = lister_tables_objets_sql($table); |
|
| 178 | - if (isset($desc['statut_titres'])) { |
|
| 179 | - // si une declaration statut_titres |
|
| 180 | - // mais rien pour le statut demande, ne rien afficher |
|
| 181 | - if (isset($desc['statut_titres'][$statut])) { |
|
| 182 | - $titre = $desc['statut_titres'][$statut]; |
|
| 183 | - } // sinon image par defaut ? |
|
| 184 | - elseif (isset($desc['statut_titres'][0])) { |
|
| 185 | - $titre = $desc['statut_titres'][0]; |
|
| 186 | - } |
|
| 187 | - } else { |
|
| 188 | - switch ($statut) { |
|
| 189 | - case 'prepa': |
|
| 190 | - $titre = 'texte_statut_en_cours_redaction'; |
|
| 191 | - break; |
|
| 192 | - case 'prop': |
|
| 193 | - $titre = 'texte_statut_propose_evaluation'; |
|
| 194 | - break; |
|
| 195 | - case 'publie': |
|
| 196 | - $titre = 'texte_statut_publie'; |
|
| 197 | - break; |
|
| 198 | - case 'refuse': |
|
| 199 | - $titre = 'texte_statut_refuse'; |
|
| 200 | - break; |
|
| 201 | - case 'poubelle': |
|
| 202 | - case 'poub': |
|
| 203 | - $titre = 'texte_statut_poubelle'; |
|
| 204 | - break; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - return $titre ? _T($titre) : ''; |
|
| 175 | + $titre = ''; |
|
| 176 | + $table = table_objet_sql($objet); |
|
| 177 | + $desc = lister_tables_objets_sql($table); |
|
| 178 | + if (isset($desc['statut_titres'])) { |
|
| 179 | + // si une declaration statut_titres |
|
| 180 | + // mais rien pour le statut demande, ne rien afficher |
|
| 181 | + if (isset($desc['statut_titres'][$statut])) { |
|
| 182 | + $titre = $desc['statut_titres'][$statut]; |
|
| 183 | + } // sinon image par defaut ? |
|
| 184 | + elseif (isset($desc['statut_titres'][0])) { |
|
| 185 | + $titre = $desc['statut_titres'][0]; |
|
| 186 | + } |
|
| 187 | + } else { |
|
| 188 | + switch ($statut) { |
|
| 189 | + case 'prepa': |
|
| 190 | + $titre = 'texte_statut_en_cours_redaction'; |
|
| 191 | + break; |
|
| 192 | + case 'prop': |
|
| 193 | + $titre = 'texte_statut_propose_evaluation'; |
|
| 194 | + break; |
|
| 195 | + case 'publie': |
|
| 196 | + $titre = 'texte_statut_publie'; |
|
| 197 | + break; |
|
| 198 | + case 'refuse': |
|
| 199 | + $titre = 'texte_statut_refuse'; |
|
| 200 | + break; |
|
| 201 | + case 'poubelle': |
|
| 202 | + case 'poub': |
|
| 203 | + $titre = 'texte_statut_poubelle'; |
|
| 204 | + break; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + return $titre ? _T($titre) : ''; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -225,37 +225,37 @@ discard block |
||
| 225 | 225 | * @return string |
| 226 | 226 | */ |
| 227 | 227 | function statut_texte_instituer($objet, $statut) { |
| 228 | - $texte = ''; |
|
| 229 | - $table = table_objet_sql($objet); |
|
| 230 | - $desc = lister_tables_objets_sql($table); |
|
| 231 | - if (isset($desc['statut_textes_instituer'])) { |
|
| 232 | - // si une declaration statut_titres |
|
| 233 | - // mais rien pour le statut demande, ne rien afficher |
|
| 234 | - if (isset($desc['statut_textes_instituer'][$statut])) { |
|
| 235 | - $texte = $desc['statut_textes_instituer'][$statut]; |
|
| 236 | - } |
|
| 237 | - } else { |
|
| 238 | - switch ($statut) { |
|
| 239 | - case 'prepa': |
|
| 240 | - $texte = 'texte_statut_en_cours_redaction'; |
|
| 241 | - break; |
|
| 242 | - case 'prop': |
|
| 243 | - $texte = 'texte_statut_propose_evaluation'; |
|
| 244 | - break; |
|
| 245 | - case 'publie': |
|
| 246 | - $texte = 'texte_statut_publie'; |
|
| 247 | - break; |
|
| 248 | - case 'refuse': |
|
| 249 | - $texte = 'texte_statut_refuse'; |
|
| 250 | - break; |
|
| 251 | - case 'poubelle': |
|
| 252 | - case 'poub': |
|
| 253 | - $texte = 'texte_statut_poubelle'; |
|
| 254 | - break; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - return $texte ? _T($texte) : ''; |
|
| 228 | + $texte = ''; |
|
| 229 | + $table = table_objet_sql($objet); |
|
| 230 | + $desc = lister_tables_objets_sql($table); |
|
| 231 | + if (isset($desc['statut_textes_instituer'])) { |
|
| 232 | + // si une declaration statut_titres |
|
| 233 | + // mais rien pour le statut demande, ne rien afficher |
|
| 234 | + if (isset($desc['statut_textes_instituer'][$statut])) { |
|
| 235 | + $texte = $desc['statut_textes_instituer'][$statut]; |
|
| 236 | + } |
|
| 237 | + } else { |
|
| 238 | + switch ($statut) { |
|
| 239 | + case 'prepa': |
|
| 240 | + $texte = 'texte_statut_en_cours_redaction'; |
|
| 241 | + break; |
|
| 242 | + case 'prop': |
|
| 243 | + $texte = 'texte_statut_propose_evaluation'; |
|
| 244 | + break; |
|
| 245 | + case 'publie': |
|
| 246 | + $texte = 'texte_statut_publie'; |
|
| 247 | + break; |
|
| 248 | + case 'refuse': |
|
| 249 | + $texte = 'texte_statut_refuse'; |
|
| 250 | + break; |
|
| 251 | + case 'poubelle': |
|
| 252 | + case 'poub': |
|
| 253 | + $texte = 'texte_statut_poubelle'; |
|
| 254 | + break; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + return $texte ? _T($texte) : ''; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | * @return string |
| 276 | 276 | */ |
| 277 | 277 | function puce_statut_auteur_dist($id, $statut, $id_parent, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) { |
| 278 | - $img = statut_image('auteur', $statut); |
|
| 279 | - if (!$img) { |
|
| 280 | - return ''; |
|
| 281 | - } |
|
| 282 | - $alt = statut_titre('auteur', $statut); |
|
| 278 | + $img = statut_image('auteur', $statut); |
|
| 279 | + if (!$img) { |
|
| 280 | + return ''; |
|
| 281 | + } |
|
| 282 | + $alt = statut_titre('auteur', $statut); |
|
| 283 | 283 | |
| 284 | - $fond = ''; |
|
| 285 | - $titre = ''; |
|
| 284 | + $fond = ''; |
|
| 285 | + $titre = ''; |
|
| 286 | 286 | |
| 287 | - /* |
|
| 287 | + /* |
|
| 288 | 288 | if ($type != 'auteur') { |
| 289 | 289 | $img2 = chemin_image('del-16.png'); |
| 290 | 290 | $titre = _T('titre_image_redacteur'); |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | */ |
| 296 | 296 | |
| 297 | - return http_img_pack($img, $alt, $fond, $alt); |
|
| 297 | + return http_img_pack($img, $alt, $fond, $alt); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
| 301 | 301 | function puce_statut_rubrique_dist($id, $statut, $id_rubrique, $type, $ajax = '', $menu_rapide = _ACTIVER_PUCE_RAPIDE) { |
| 302 | - return http_img_pack('rubrique-16.png', ''); |
|
| 302 | + return http_img_pack('rubrique-16.png', ''); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -323,110 +323,110 @@ discard block |
||
| 323 | 323 | * Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent) |
| 324 | 324 | **/ |
| 325 | 325 | function puce_statut_changement_rapide( |
| 326 | - $id, |
|
| 327 | - $statut, |
|
| 328 | - $id_rubrique, |
|
| 329 | - $type = 'article', |
|
| 330 | - $ajax = false, |
|
| 331 | - $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 326 | + $id, |
|
| 327 | + $statut, |
|
| 328 | + $id_rubrique, |
|
| 329 | + $type = 'article', |
|
| 330 | + $ajax = false, |
|
| 331 | + $menu_rapide = _ACTIVER_PUCE_RAPIDE |
|
| 332 | 332 | ) { |
| 333 | - $src = statut_image($type, $statut); |
|
| 334 | - if (!$src) { |
|
| 335 | - return $src; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - if ( |
|
| 339 | - !$id |
|
| 340 | - or !_SPIP_AJAX |
|
| 341 | - or !$menu_rapide |
|
| 342 | - ) { |
|
| 343 | - $ajax_node = ''; |
|
| 344 | - } else { |
|
| 345 | - $ajax_node = " class='imgstatut$type$id'"; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - $t = statut_titre($type, $statut); |
|
| 350 | - $inser_puce = http_img_pack($src, $t, $ajax_node, $t); |
|
| 351 | - |
|
| 352 | - if (!$ajax_node) { |
|
| 353 | - return $inser_puce; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - $table = table_objet_sql($type); |
|
| 357 | - $desc = lister_tables_objets_sql($table); |
|
| 358 | - if (!isset($desc['statut_textes_instituer'])) { |
|
| 359 | - return $inser_puce; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - if (!function_exists('autoriser')) { |
|
| 363 | - include_spip('inc/autoriser'); |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique) |
|
| 367 | - if ($id_rubrique) { |
|
| 368 | - if (!autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 369 | - return $inser_puce; |
|
| 370 | - } |
|
| 371 | - } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie |
|
| 372 | - else { |
|
| 373 | - if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) { |
|
| 374 | - return $inser_puce; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - $coord = array_flip(array_keys($desc['statut_textes_instituer'])); |
|
| 379 | - if (!isset($coord[$statut])) { |
|
| 380 | - return $inser_puce; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - $unit = 18/*widh de img*/ + 0/*padding*/ |
|
| 384 | - ; |
|
| 385 | - $margin = 0; /* marge a gauche + droite */ |
|
| 386 | - $zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/ |
|
| 387 | - ; |
|
| 388 | - $clip = $zero + ($unit * $coord[$statut]); |
|
| 389 | - |
|
| 390 | - if ($ajax) { |
|
| 391 | - $width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin; |
|
| 392 | - $out = "<span class='puce_objet_fixe $type'>" |
|
| 393 | - . $inser_puce |
|
| 394 | - . '</span>' |
|
| 395 | - . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>"; |
|
| 396 | - $i = 0; |
|
| 397 | - foreach ($desc['statut_textes_instituer'] as $s => $t) { |
|
| 398 | - $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t)); |
|
| 399 | - } |
|
| 400 | - $out .= '</span>'; |
|
| 401 | - |
|
| 402 | - return $out; |
|
| 403 | - } else { |
|
| 404 | - $nom = 'puce_statut_'; |
|
| 405 | - $action = generer_url_ecrire('puce_statut', '', true); |
|
| 406 | - $lang_dir = lang_dir(lang_typo()); |
|
| 407 | - |
|
| 408 | - return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>" |
|
| 409 | - . $inser_puce |
|
| 410 | - . '</span>'; |
|
| 411 | - } |
|
| 333 | + $src = statut_image($type, $statut); |
|
| 334 | + if (!$src) { |
|
| 335 | + return $src; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + if ( |
|
| 339 | + !$id |
|
| 340 | + or !_SPIP_AJAX |
|
| 341 | + or !$menu_rapide |
|
| 342 | + ) { |
|
| 343 | + $ajax_node = ''; |
|
| 344 | + } else { |
|
| 345 | + $ajax_node = " class='imgstatut$type$id'"; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + $t = statut_titre($type, $statut); |
|
| 350 | + $inser_puce = http_img_pack($src, $t, $ajax_node, $t); |
|
| 351 | + |
|
| 352 | + if (!$ajax_node) { |
|
| 353 | + return $inser_puce; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + $table = table_objet_sql($type); |
|
| 357 | + $desc = lister_tables_objets_sql($table); |
|
| 358 | + if (!isset($desc['statut_textes_instituer'])) { |
|
| 359 | + return $inser_puce; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + if (!function_exists('autoriser')) { |
|
| 363 | + include_spip('inc/autoriser'); |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + // cas ou l'on a un parent connu (devrait disparaitre au profit du second cas plus generique) |
|
| 367 | + if ($id_rubrique) { |
|
| 368 | + if (!autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 369 | + return $inser_puce; |
|
| 370 | + } |
|
| 371 | + } // si pas d'id_rubrique fourni, tester directement instituer type avec le statut publie |
|
| 372 | + else { |
|
| 373 | + if (!autoriser('instituer', $type, $id, null, ['statut' => 'publie'])) { |
|
| 374 | + return $inser_puce; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + $coord = array_flip(array_keys($desc['statut_textes_instituer'])); |
|
| 379 | + if (!isset($coord[$statut])) { |
|
| 380 | + return $inser_puce; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + $unit = 18/*widh de img*/ + 0/*padding*/ |
|
| 384 | + ; |
|
| 385 | + $margin = 0; /* marge a gauche + droite */ |
|
| 386 | + $zero = 0 /*border*/ + $margin / 2 + 0 /*padding*/ |
|
| 387 | + ; |
|
| 388 | + $clip = $zero + ($unit * $coord[$statut]); |
|
| 389 | + |
|
| 390 | + if ($ajax) { |
|
| 391 | + $width = $unit * (is_countable($desc['statut_textes_instituer']) ? count($desc['statut_textes_instituer']) : 0) + $margin; |
|
| 392 | + $out = "<span class='puce_objet_fixe $type'>" |
|
| 393 | + . $inser_puce |
|
| 394 | + . '</span>' |
|
| 395 | + . "<span class='puce_objet_popup $type statutdecal$type$id' style='width:{$width}px;margin-left:-{$clip}px;'>"; |
|
| 396 | + $i = 0; |
|
| 397 | + foreach ($desc['statut_textes_instituer'] as $s => $t) { |
|
| 398 | + $out .= afficher_script_statut($id, $type, -$zero - $i++ * $unit, statut_image($type, $s), $s, _T($t)); |
|
| 399 | + } |
|
| 400 | + $out .= '</span>'; |
|
| 401 | + |
|
| 402 | + return $out; |
|
| 403 | + } else { |
|
| 404 | + $nom = 'puce_statut_'; |
|
| 405 | + $action = generer_url_ecrire('puce_statut', '', true); |
|
| 406 | + $lang_dir = lang_dir(lang_typo()); |
|
| 407 | + |
|
| 408 | + return "<span class='puce_objet $type' id='$nom$type$id' dir='$lang_dir' data-puce-nom='$nom' data-puce-type='$type' data-puce-id='$id' data-puce-action='$action'>" |
|
| 409 | + . $inser_puce |
|
| 410 | + . '</span>'; |
|
| 411 | + } |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | |
| 415 | 415 | function afficher_script_statut($id, $type, $n, $img, $statut, $titre, $act = '') { |
| 416 | - $h = generer_action_auteur('instituer_objet', "$type-$id-$statut"); |
|
| 417 | - $t = supprimer_tags($titre); |
|
| 416 | + $h = generer_action_auteur('instituer_objet', "$type-$id-$statut"); |
|
| 417 | + $t = supprimer_tags($titre); |
|
| 418 | 418 | |
| 419 | - return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>'; |
|
| 419 | + return "<a href=\"#\" data-puce-id=\"$id\" data-puce-type=\"$type\" data-puce-decal=\"$n\" data-puce-action=\"$h\" title=\"$t\"$act>" . http_img_pack($img, $t) . '</a>'; |
|
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | // compat |
| 423 | 423 | // La couleur du statut |
| 424 | 424 | |
| 425 | 425 | function puce_statut($statut, $atts = '') { |
| 426 | - $src = statut_image('article', $statut); |
|
| 427 | - if (!$src) { |
|
| 428 | - return ''; |
|
| 429 | - } |
|
| 426 | + $src = statut_image('article', $statut); |
|
| 427 | + if (!$src) { |
|
| 428 | + return ''; |
|
| 429 | + } |
|
| 430 | 430 | |
| 431 | - return http_img_pack($src, statut_titre('article', $statut), $atts); |
|
| 431 | + return http_img_pack($src, statut_titre('article', $statut), $atts); |
|
| 432 | 432 | } |