@@ -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 | /** |
@@ -33,19 +33,19 @@ discard block |
||
| 33 | 33 | * @return array Environnement du formulaire |
| 34 | 34 | **/ |
| 35 | 35 | function formulaires_recherche_ecrire_charger_dist($action = '', $class = '') { |
| 36 | - if ($GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 37 | - $lang = $GLOBALS['spip_lang']; |
|
| 38 | - } else { |
|
| 39 | - $lang = ''; |
|
| 40 | - } |
|
| 36 | + if ($GLOBALS['spip_lang'] != $GLOBALS['meta']['langue_site']) { |
|
| 37 | + $lang = $GLOBALS['spip_lang']; |
|
| 38 | + } else { |
|
| 39 | + $lang = ''; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - return |
|
| 43 | - [ |
|
| 44 | - 'action' => ($action ?: generer_url_ecrire('recherche')), |
|
| 45 | - # action specifique, ne passe pas par Verifier, ni Traiter |
|
| 46 | - 'recherche' => _request('recherche'), |
|
| 47 | - 'lang' => $lang, |
|
| 48 | - 'class' => $class, |
|
| 49 | - '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 50 | - ]; |
|
| 42 | + return |
|
| 43 | + [ |
|
| 44 | + 'action' => ($action ?: generer_url_ecrire('recherche')), |
|
| 45 | + # action specifique, ne passe pas par Verifier, ni Traiter |
|
| 46 | + 'recherche' => _request('recherche'), |
|
| 47 | + 'lang' => $lang, |
|
| 48 | + 'class' => $class, |
|
| 49 | + '_id_champ' => 'rechercher_' . substr(md5($action . $class), 0, 4), |
|
| 50 | + ]; |
|
| 51 | 51 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -28,24 +28,24 @@ discard block |
||
| 28 | 28 | * Environnement du formulaire |
| 29 | 29 | **/ |
| 30 | 30 | function formulaires_configurer_reducteur_charger_dist() { |
| 31 | - $valeurs = []; |
|
| 32 | - foreach ( |
|
| 33 | - [ |
|
| 34 | - 'image_process', |
|
| 35 | - 'formats_graphiques', |
|
| 36 | - 'creer_preview', |
|
| 37 | - 'taille_preview', |
|
| 38 | - ] as $m |
|
| 39 | - ) { |
|
| 40 | - $valeurs[$m] = $GLOBALS['meta'][$m] ?? null; |
|
| 41 | - } |
|
| 31 | + $valeurs = []; |
|
| 32 | + foreach ( |
|
| 33 | + [ |
|
| 34 | + 'image_process', |
|
| 35 | + 'formats_graphiques', |
|
| 36 | + 'creer_preview', |
|
| 37 | + 'taille_preview', |
|
| 38 | + ] as $m |
|
| 39 | + ) { |
|
| 40 | + $valeurs[$m] = $GLOBALS['meta'][$m] ?? null; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $valeurs['taille_preview'] = intval($valeurs['taille_preview']); |
|
| 44 | - if ($valeurs['taille_preview'] < 10) { |
|
| 45 | - $valeurs['taille_preview'] = 120; |
|
| 46 | - } |
|
| 43 | + $valeurs['taille_preview'] = intval($valeurs['taille_preview']); |
|
| 44 | + if ($valeurs['taille_preview'] < 10) { |
|
| 45 | + $valeurs['taille_preview'] = 120; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - return $valeurs; |
|
| 48 | + return $valeurs; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | |
@@ -56,53 +56,53 @@ discard block |
||
| 56 | 56 | * Retours des traitements |
| 57 | 57 | **/ |
| 58 | 58 | function formulaires_configurer_reducteur_traiter_dist() { |
| 59 | - $res = ['editable' => true]; |
|
| 59 | + $res = ['editable' => true]; |
|
| 60 | 60 | |
| 61 | - if (is_array($image_process = _request('image_process_'))) { |
|
| 62 | - $image_process = array_keys($image_process); |
|
| 63 | - $image_process = reset($image_process); |
|
| 61 | + if (is_array($image_process = _request('image_process_'))) { |
|
| 62 | + $image_process = array_keys($image_process); |
|
| 63 | + $image_process = reset($image_process); |
|
| 64 | 64 | |
| 65 | - // application du choix de vignette |
|
| 66 | - if ($image_process) { |
|
| 67 | - // mettre a jour les formats graphiques lisibles |
|
| 68 | - switch ($image_process) { |
|
| 69 | - case 'gd1': |
|
| 70 | - case 'gd2': |
|
| 71 | - $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 72 | - break; |
|
| 73 | - case 'netpbm': |
|
| 74 | - $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 75 | - break; |
|
| 76 | - case 'convert': |
|
| 77 | - case 'imagick': |
|
| 78 | - $formats_graphiques = 'gif,jpg,png,webp'; |
|
| 79 | - break; |
|
| 80 | - default: #debug |
|
| 81 | - $formats_graphiques = ''; |
|
| 82 | - $image_process = 'non'; |
|
| 83 | - break; |
|
| 84 | - } |
|
| 85 | - ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 86 | - ecrire_meta('image_process', $image_process, 'non'); |
|
| 87 | - } |
|
| 88 | - } |
|
| 65 | + // application du choix de vignette |
|
| 66 | + if ($image_process) { |
|
| 67 | + // mettre a jour les formats graphiques lisibles |
|
| 68 | + switch ($image_process) { |
|
| 69 | + case 'gd1': |
|
| 70 | + case 'gd2': |
|
| 71 | + $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 72 | + break; |
|
| 73 | + case 'netpbm': |
|
| 74 | + $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 75 | + break; |
|
| 76 | + case 'convert': |
|
| 77 | + case 'imagick': |
|
| 78 | + $formats_graphiques = 'gif,jpg,png,webp'; |
|
| 79 | + break; |
|
| 80 | + default: #debug |
|
| 81 | + $formats_graphiques = ''; |
|
| 82 | + $image_process = 'non'; |
|
| 83 | + break; |
|
| 84 | + } |
|
| 85 | + ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 86 | + ecrire_meta('image_process', $image_process, 'non'); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - foreach ( |
|
| 91 | - [ |
|
| 92 | - 'creer_preview' |
|
| 93 | - ] as $m |
|
| 94 | - ) { |
|
| 95 | - if (!is_null($v = _request($m))) { |
|
| 96 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - if (!is_null($v = _request('taille_preview'))) { |
|
| 100 | - ecrire_meta('taille_preview', intval($v)); |
|
| 101 | - } |
|
| 90 | + foreach ( |
|
| 91 | + [ |
|
| 92 | + 'creer_preview' |
|
| 93 | + ] as $m |
|
| 94 | + ) { |
|
| 95 | + if (!is_null($v = _request($m))) { |
|
| 96 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + if (!is_null($v = _request('taille_preview'))) { |
|
| 100 | + ecrire_meta('taille_preview', intval($v)); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 103 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 104 | 104 | |
| 105 | - return $res; |
|
| 105 | + return $res; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
@@ -115,37 +115,37 @@ discard block |
||
| 115 | 115 | * URL d'action pour tester la librairie graphique en créant une vignette |
| 116 | 116 | **/ |
| 117 | 117 | function url_vignette_choix($process) { |
| 118 | - switch ($process) { |
|
| 119 | - case 'gd2': |
|
| 120 | - if (!function_exists('ImageCreateTrueColor')) { |
|
| 121 | - return ''; |
|
| 122 | - } |
|
| 123 | - break; |
|
| 124 | - case 'gd1': |
|
| 125 | - if ( |
|
| 126 | - !function_exists('ImageGif') |
|
| 127 | - and !function_exists('ImageJpeg') |
|
| 128 | - and !function_exists('ImagePng') |
|
| 129 | - ) { |
|
| 130 | - return ''; |
|
| 131 | - } |
|
| 132 | - break; |
|
| 133 | - case 'netpbm': |
|
| 134 | - if (defined('_PNMSCALE_COMMAND') and _PNMSCALE_COMMAND == '') { |
|
| 135 | - return ''; |
|
| 136 | - } |
|
| 137 | - break; |
|
| 138 | - case 'imagick': |
|
| 139 | - if (!method_exists(\Imagick::class, 'readImage')) { |
|
| 140 | - return ''; |
|
| 141 | - } |
|
| 142 | - break; |
|
| 143 | - case 'convert': |
|
| 144 | - if (defined('_CONVERT_COMMAND') and _CONVERT_COMMAND == '') { |
|
| 145 | - return ''; |
|
| 146 | - } |
|
| 147 | - break; |
|
| 148 | - } |
|
| 118 | + switch ($process) { |
|
| 119 | + case 'gd2': |
|
| 120 | + if (!function_exists('ImageCreateTrueColor')) { |
|
| 121 | + return ''; |
|
| 122 | + } |
|
| 123 | + break; |
|
| 124 | + case 'gd1': |
|
| 125 | + if ( |
|
| 126 | + !function_exists('ImageGif') |
|
| 127 | + and !function_exists('ImageJpeg') |
|
| 128 | + and !function_exists('ImagePng') |
|
| 129 | + ) { |
|
| 130 | + return ''; |
|
| 131 | + } |
|
| 132 | + break; |
|
| 133 | + case 'netpbm': |
|
| 134 | + if (defined('_PNMSCALE_COMMAND') and _PNMSCALE_COMMAND == '') { |
|
| 135 | + return ''; |
|
| 136 | + } |
|
| 137 | + break; |
|
| 138 | + case 'imagick': |
|
| 139 | + if (!method_exists(\Imagick::class, 'readImage')) { |
|
| 140 | + return ''; |
|
| 141 | + } |
|
| 142 | + break; |
|
| 143 | + case 'convert': |
|
| 144 | + if (defined('_CONVERT_COMMAND') and _CONVERT_COMMAND == '') { |
|
| 145 | + return ''; |
|
| 146 | + } |
|
| 147 | + break; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 150 | + return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 151 | 151 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | **/ |
| 22 | 22 | |
| 23 | 23 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 24 | - return; |
|
| 24 | + return; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -31,28 +31,28 @@ discard block |
||
| 31 | 31 | * Environnement du formulaire |
| 32 | 32 | **/ |
| 33 | 33 | function formulaires_configurer_preferences_charger_dist() { |
| 34 | - // travailler sur des meta fraiches |
|
| 35 | - include_spip('inc/meta'); |
|
| 36 | - lire_metas(); |
|
| 34 | + // travailler sur des meta fraiches |
|
| 35 | + include_spip('inc/meta'); |
|
| 36 | + lire_metas(); |
|
| 37 | 37 | |
| 38 | - $valeurs = []; |
|
| 39 | - $valeurs['display_navigation'] = $GLOBALS['visiteur_session']['prefs']['display_navigation'] ?? 'navigation_avec_icones'; |
|
| 40 | - $valeurs['display_outils'] = $GLOBALS['visiteur_session']['prefs']['display_outils'] ?? 'oui'; |
|
| 41 | - $valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2; |
|
| 42 | - $valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1; |
|
| 38 | + $valeurs = []; |
|
| 39 | + $valeurs['display_navigation'] = $GLOBALS['visiteur_session']['prefs']['display_navigation'] ?? 'navigation_avec_icones'; |
|
| 40 | + $valeurs['display_outils'] = $GLOBALS['visiteur_session']['prefs']['display_outils'] ?? 'oui'; |
|
| 41 | + $valeurs['display'] = (isset($GLOBALS['visiteur_session']['prefs']['display']) and $GLOBALS['visiteur_session']['prefs']['display'] > 0) ? $GLOBALS['visiteur_session']['prefs']['display'] : 2; |
|
| 42 | + $valeurs['couleur'] = (isset($GLOBALS['visiteur_session']['prefs']['couleur']) and $GLOBALS['visiteur_session']['prefs']['couleur'] > 0) ? $GLOBALS['visiteur_session']['prefs']['couleur'] : 1; |
|
| 43 | 43 | |
| 44 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 45 | - $les_couleurs = $couleurs(); |
|
| 46 | - foreach ($les_couleurs as $k => $c) { |
|
| 47 | - $valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr=' |
|
| 48 | - . $GLOBALS['spip_lang_left'] . '&' |
|
| 49 | - . $couleurs($k)); |
|
| 50 | - $valeurs['couleurs'][$k] = $c; |
|
| 51 | - } |
|
| 44 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 45 | + $les_couleurs = $couleurs(); |
|
| 46 | + foreach ($les_couleurs as $k => $c) { |
|
| 47 | + $valeurs['_couleurs_url'][$k] = generer_url_public('style_prive.css', 'ltr=' |
|
| 48 | + . $GLOBALS['spip_lang_left'] . '&' |
|
| 49 | + . $couleurs($k)); |
|
| 50 | + $valeurs['couleurs'][$k] = $c; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage']; |
|
| 53 | + $valeurs['imessage'] = $GLOBALS['visiteur_session']['imessage']; |
|
| 54 | 54 | |
| 55 | - return $valeurs; |
|
| 55 | + return $valeurs; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -63,36 +63,36 @@ discard block |
||
| 63 | 63 | **/ |
| 64 | 64 | function formulaires_configurer_preferences_traiter_dist() { |
| 65 | 65 | |
| 66 | - if ($couleur = _request('couleur')) { |
|
| 67 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 68 | - $les_couleurs = $couleurs([], true); |
|
| 69 | - if (isset($les_couleurs[$couleur])) { |
|
| 70 | - $GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur; |
|
| 71 | - } |
|
| 72 | - } |
|
| 73 | - if ($display = intval(_request('display'))) { |
|
| 74 | - $GLOBALS['visiteur_session']['prefs']['display'] = $display; |
|
| 75 | - } |
|
| 76 | - if ( |
|
| 77 | - $display_navigation = _request('display_navigation') |
|
| 78 | - and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones']) |
|
| 79 | - ) { |
|
| 80 | - $GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation; |
|
| 81 | - } |
|
| 82 | - if (!is_null($display_outils = _request('display_outils'))) { |
|
| 83 | - $GLOBALS['visiteur_session']['prefs']['display_outils'] = ($display_outils ? 'oui' : ''); |
|
| 84 | - } |
|
| 66 | + if ($couleur = _request('couleur')) { |
|
| 67 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 68 | + $les_couleurs = $couleurs([], true); |
|
| 69 | + if (isset($les_couleurs[$couleur])) { |
|
| 70 | + $GLOBALS['visiteur_session']['prefs']['couleur'] = $couleur; |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | + if ($display = intval(_request('display'))) { |
|
| 74 | + $GLOBALS['visiteur_session']['prefs']['display'] = $display; |
|
| 75 | + } |
|
| 76 | + if ( |
|
| 77 | + $display_navigation = _request('display_navigation') |
|
| 78 | + and in_array($display_navigation, ['navigation_sans_icone', 'navigation_avec_icones']) |
|
| 79 | + ) { |
|
| 80 | + $GLOBALS['visiteur_session']['prefs']['display_navigation'] = $display_navigation; |
|
| 81 | + } |
|
| 82 | + if (!is_null($display_outils = _request('display_outils'))) { |
|
| 83 | + $GLOBALS['visiteur_session']['prefs']['display_outils'] = ($display_outils ? 'oui' : ''); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - if (intval($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 87 | - include_spip('action/editer_auteur'); |
|
| 88 | - $c = ['prefs' => serialize($GLOBALS['visiteur_session']['prefs'])]; |
|
| 86 | + if (intval($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 87 | + include_spip('action/editer_auteur'); |
|
| 88 | + $c = ['prefs' => serialize($GLOBALS['visiteur_session']['prefs'])]; |
|
| 89 | 89 | |
| 90 | - if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) { |
|
| 91 | - $c['imessage'] = $imessage; |
|
| 92 | - } |
|
| 90 | + if ($imessage = _request('imessage') and in_array($imessage, ['oui', 'non'])) { |
|
| 91 | + $c['imessage'] = $imessage; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c); |
|
| 95 | - } |
|
| 94 | + auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], $c); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return ['message_ok' => _T('config_info_enregistree'), 'editable' => true]; |
|
| 97 | + return ['message_ok' => _T('config_info_enregistree'), 'editable' => true]; |
|
| 98 | 98 | } |
@@ -11,56 +11,56 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_identite_charger_dist() { |
| 18 | - // travailler sur des meta fraiches |
|
| 19 | - include_spip('inc/meta'); |
|
| 20 | - lire_metas(); |
|
| 18 | + // travailler sur des meta fraiches |
|
| 19 | + include_spip('inc/meta'); |
|
| 20 | + lire_metas(); |
|
| 21 | 21 | |
| 22 | - $valeurs = []; |
|
| 23 | - foreach (['nom_site', 'adresse_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 24 | - $valeurs[$k] = $GLOBALS['meta'][$k] ?? ''; |
|
| 25 | - } |
|
| 22 | + $valeurs = []; |
|
| 23 | + foreach (['nom_site', 'adresse_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 24 | + $valeurs[$k] = $GLOBALS['meta'][$k] ?? ''; |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - return $valeurs; |
|
| 27 | + return $valeurs; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | function formulaires_configurer_identite_verifier_dist() { |
| 31 | - $erreurs = []; |
|
| 31 | + $erreurs = []; |
|
| 32 | 32 | |
| 33 | - // adresse_site est obligatoire mais rempli automatiquement si absent ! |
|
| 34 | - foreach (['nom_site'/*,'adresse_site'*/] as $obli) { |
|
| 35 | - if (!_request($obli)) { |
|
| 36 | - $erreurs[$obli] = _T('info_obligatoire'); |
|
| 37 | - } |
|
| 38 | - } |
|
| 33 | + // adresse_site est obligatoire mais rempli automatiquement si absent ! |
|
| 34 | + foreach (['nom_site'/*,'adresse_site'*/] as $obli) { |
|
| 35 | + if (!_request($obli)) { |
|
| 36 | + $erreurs[$obli] = _T('info_obligatoire'); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - if ($email = _request('email_webmaster') and !email_valide($email)) { |
|
| 41 | - $erreurs['email_webmaster'] = _T('info_email_invalide'); |
|
| 42 | - } |
|
| 40 | + if ($email = _request('email_webmaster') and !email_valide($email)) { |
|
| 41 | + $erreurs['email_webmaster'] = _T('info_email_invalide'); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - return $erreurs; |
|
| 44 | + return $erreurs; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function formulaires_configurer_identite_traiter_dist() { |
| 48 | - include_spip('inc/config'); |
|
| 49 | - $adresse_site = $GLOBALS['meta']['adresse_site'] ?? ''; |
|
| 50 | - if (_request('adresse_site') != $adresse_site) { |
|
| 51 | - refuser_traiter_formulaire_ajax(); |
|
| 52 | - } |
|
| 48 | + include_spip('inc/config'); |
|
| 49 | + $adresse_site = $GLOBALS['meta']['adresse_site'] ?? ''; |
|
| 50 | + if (_request('adresse_site') != $adresse_site) { |
|
| 51 | + refuser_traiter_formulaire_ajax(); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - set_request('adresse_site', appliquer_adresse_site(_request('adresse_site'))); |
|
| 54 | + set_request('adresse_site', appliquer_adresse_site(_request('adresse_site'))); |
|
| 55 | 55 | |
| 56 | - include_spip('inc/meta'); |
|
| 57 | - foreach (['nom_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 58 | - ecrire_meta($k, _request($k)); |
|
| 59 | - } |
|
| 56 | + include_spip('inc/meta'); |
|
| 57 | + foreach (['nom_site', 'slogan_site', 'descriptif_site', 'email_webmaster'] as $k) { |
|
| 58 | + ecrire_meta($k, _request($k)); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - include_spip('inc/texte_mini'); |
|
| 62 | - $reload = texte_script(couper(_request('nom_site'), 35)); |
|
| 63 | - $reload = "<script type='text/javascript'>if (window.jQuery) jQuery('#bando_identite .nom_site_spip .nom').html('$reload');</script>"; |
|
| 61 | + include_spip('inc/texte_mini'); |
|
| 62 | + $reload = texte_script(couper(_request('nom_site'), 35)); |
|
| 63 | + $reload = "<script type='text/javascript'>if (window.jQuery) jQuery('#bando_identite .nom_site_spip .nom').html('$reload');</script>"; |
|
| 64 | 64 | |
| 65 | - return ['message_ok' => _T('config_info_enregistree') . $reload, 'editable' => true]; |
|
| 65 | + return ['message_ok' => _T('config_info_enregistree') . $reload, 'editable' => true]; |
|
| 66 | 66 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | **/ |
| 31 | 31 | |
| 32 | 32 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 33 | - return; |
|
| 33 | + return; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | global $logo_libelles; |
@@ -49,91 +49,91 @@ discard block |
||
| 49 | 49 | * @return array Variables d'environnement pour le fond |
| 50 | 50 | */ |
| 51 | 51 | function formulaires_editer_logo_charger_dist($objet, $id_objet, $retour = '', $options = []) { |
| 52 | - // pas dans une boucle ? formulaire pour le logo du site |
|
| 53 | - // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 54 | - if (!$objet) { |
|
| 55 | - $objet = 'site'; |
|
| 56 | - } |
|
| 52 | + // pas dans une boucle ? formulaire pour le logo du site |
|
| 53 | + // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 54 | + if (!$objet) { |
|
| 55 | + $objet = 'site'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $objet = objet_type($objet); |
|
| 59 | - $_id_objet = id_table_objet($objet); |
|
| 58 | + $objet = objet_type($objet); |
|
| 59 | + $_id_objet = id_table_objet($objet); |
|
| 60 | 60 | |
| 61 | - if (!is_array($options)) { |
|
| 62 | - $options = unserialize($options); |
|
| 63 | - } |
|
| 64 | - $options = spip_sanitize_from_request($options, '*'); |
|
| 61 | + if (!is_array($options)) { |
|
| 62 | + $options = unserialize($options); |
|
| 63 | + } |
|
| 64 | + $options = spip_sanitize_from_request($options, '*'); |
|
| 65 | 65 | |
| 66 | - if (!isset($options['titre'])) { |
|
| 67 | - $balise_img = chercher_filtre('balise_img'); |
|
| 68 | - $img = $balise_img(chemin_image('image-24.png'), '', 'cadre-icone'); |
|
| 69 | - $libelles = pipeline('libeller_logo', $GLOBALS['logo_libelles']); |
|
| 70 | - $libelle = (($id_objet or $objet != 'rubrique') ? $objet : 'racine'); |
|
| 71 | - if (isset($libelles[$libelle])) { |
|
| 72 | - $libelle = $libelles[$libelle]; |
|
| 73 | - } elseif ($libelle = objet_info($objet, 'texte_logo_objet')) { |
|
| 74 | - $libelle = _T($libelle); |
|
| 75 | - } else { |
|
| 76 | - $libelle = _L('Logo'); |
|
| 77 | - } |
|
| 78 | - switch ($objet) { |
|
| 79 | - case 'article': |
|
| 80 | - $libelle .= ' ' . aider('logoart'); |
|
| 81 | - break; |
|
| 82 | - case 'breve': |
|
| 83 | - $libelle .= ' ' . aider('breveslogo'); |
|
| 84 | - break; |
|
| 85 | - case 'rubrique': |
|
| 86 | - $libelle .= ' ' . aider('rublogo'); |
|
| 87 | - break; |
|
| 88 | - default: |
|
| 89 | - break; |
|
| 90 | - } |
|
| 66 | + if (!isset($options['titre'])) { |
|
| 67 | + $balise_img = chercher_filtre('balise_img'); |
|
| 68 | + $img = $balise_img(chemin_image('image-24.png'), '', 'cadre-icone'); |
|
| 69 | + $libelles = pipeline('libeller_logo', $GLOBALS['logo_libelles']); |
|
| 70 | + $libelle = (($id_objet or $objet != 'rubrique') ? $objet : 'racine'); |
|
| 71 | + if (isset($libelles[$libelle])) { |
|
| 72 | + $libelle = $libelles[$libelle]; |
|
| 73 | + } elseif ($libelle = objet_info($objet, 'texte_logo_objet')) { |
|
| 74 | + $libelle = _T($libelle); |
|
| 75 | + } else { |
|
| 76 | + $libelle = _L('Logo'); |
|
| 77 | + } |
|
| 78 | + switch ($objet) { |
|
| 79 | + case 'article': |
|
| 80 | + $libelle .= ' ' . aider('logoart'); |
|
| 81 | + break; |
|
| 82 | + case 'breve': |
|
| 83 | + $libelle .= ' ' . aider('breveslogo'); |
|
| 84 | + break; |
|
| 85 | + case 'rubrique': |
|
| 86 | + $libelle .= ' ' . aider('rublogo'); |
|
| 87 | + break; |
|
| 88 | + default: |
|
| 89 | + break; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $options['titre'] = $img . $libelle; |
|
| 93 | - } |
|
| 94 | - if (!isset($options['editable'])) { |
|
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - $options['editable'] = autoriser('iconifier', $objet, $id_objet); |
|
| 97 | - } |
|
| 92 | + $options['titre'] = $img . $libelle; |
|
| 93 | + } |
|
| 94 | + if (!isset($options['editable'])) { |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + $options['editable'] = autoriser('iconifier', $objet, $id_objet); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - $res = [ |
|
| 100 | - 'editable' => ($GLOBALS['meta']['activer_logos'] == 'oui' ? ' ' : '') && (!isset($options['editable']) or $options['editable']), |
|
| 101 | - 'logo_survol' => ($GLOBALS['meta']['activer_logos_survol'] == 'oui' ? ' ' : ''), |
|
| 102 | - 'objet' => $objet, |
|
| 103 | - 'id_objet' => $id_objet, |
|
| 104 | - '_options' => $options, |
|
| 105 | - '_show_upload_off' => '', |
|
| 106 | - ]; |
|
| 99 | + $res = [ |
|
| 100 | + 'editable' => ($GLOBALS['meta']['activer_logos'] == 'oui' ? ' ' : '') && (!isset($options['editable']) or $options['editable']), |
|
| 101 | + 'logo_survol' => ($GLOBALS['meta']['activer_logos_survol'] == 'oui' ? ' ' : ''), |
|
| 102 | + 'objet' => $objet, |
|
| 103 | + 'id_objet' => $id_objet, |
|
| 104 | + '_options' => $options, |
|
| 105 | + '_show_upload_off' => '', |
|
| 106 | + ]; |
|
| 107 | 107 | |
| 108 | - // rechercher le logo de l'objet |
|
| 109 | - // la fonction prend un parametre '_id_objet' etrange : |
|
| 110 | - // le nom de la cle primaire (et non le nom de la table) |
|
| 111 | - // ou directement le nom du raccourcis a chercher |
|
| 112 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 113 | - $etats = $res['logo_survol'] ? ['on', 'off'] : ['on']; |
|
| 114 | - foreach ($etats as $etat) { |
|
| 115 | - $logo = $chercher_logo($id_objet, $_id_objet, $etat); |
|
| 116 | - if ($logo) { |
|
| 117 | - $res['logo_' . $etat] = $logo[0]; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - // pas de logo_on -> pas de formulaire pour le survol |
|
| 121 | - if (!isset($res['logo_on'])) { |
|
| 122 | - $res['logo_survol'] = ''; |
|
| 123 | - } elseif (!isset($res['logo_off']) and _request('logo_up')) { |
|
| 124 | - $res['_show_upload_off'] = ' '; |
|
| 125 | - } |
|
| 108 | + // rechercher le logo de l'objet |
|
| 109 | + // la fonction prend un parametre '_id_objet' etrange : |
|
| 110 | + // le nom de la cle primaire (et non le nom de la table) |
|
| 111 | + // ou directement le nom du raccourcis a chercher |
|
| 112 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 113 | + $etats = $res['logo_survol'] ? ['on', 'off'] : ['on']; |
|
| 114 | + foreach ($etats as $etat) { |
|
| 115 | + $logo = $chercher_logo($id_objet, $_id_objet, $etat); |
|
| 116 | + if ($logo) { |
|
| 117 | + $res['logo_' . $etat] = $logo[0]; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + // pas de logo_on -> pas de formulaire pour le survol |
|
| 121 | + if (!isset($res['logo_on'])) { |
|
| 122 | + $res['logo_survol'] = ''; |
|
| 123 | + } elseif (!isset($res['logo_off']) and _request('logo_up')) { |
|
| 124 | + $res['_show_upload_off'] = ' '; |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - // si le logo n'est pas editable et qu'il n'y en a pas, on affiche pas du tout le formulaire |
|
| 128 | - if ( |
|
| 129 | - !$res['editable'] |
|
| 130 | - and !isset($res['logo_off']) |
|
| 131 | - and !isset($res['logo_on']) |
|
| 132 | - ) { |
|
| 133 | - return false; |
|
| 134 | - } |
|
| 127 | + // si le logo n'est pas editable et qu'il n'y en a pas, on affiche pas du tout le formulaire |
|
| 128 | + if ( |
|
| 129 | + !$res['editable'] |
|
| 130 | + and !isset($res['logo_off']) |
|
| 131 | + and !isset($res['logo_on']) |
|
| 132 | + ) { |
|
| 133 | + return false; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - return $res; |
|
| 136 | + return $res; |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @return string Hash du formulaire |
| 148 | 148 | */ |
| 149 | 149 | function formulaires_editer_logo_identifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 150 | - return serialize([$objet, $id_objet]); |
|
| 150 | + return serialize([$objet, $id_objet]); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -163,31 +163,31 @@ discard block |
||
| 163 | 163 | * @return array Erreurs du formulaire |
| 164 | 164 | */ |
| 165 | 165 | function formulaires_editer_logo_verifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 166 | - $erreurs = []; |
|
| 167 | - // verifier les extensions |
|
| 168 | - $sources = formulaire_editer_logo_get_sources(); |
|
| 169 | - include_spip('action/editer_logo'); |
|
| 170 | - $extensions_possibles = $GLOBALS['formats_logos']; |
|
| 171 | - if (in_array('jpg', $extensions_possibles)) { |
|
| 172 | - $extensions_possibles[] = 'jpeg'; |
|
| 173 | - } |
|
| 174 | - foreach ($sources as $etat => $file) { |
|
| 175 | - // seulement si une reception correcte a eu lieu |
|
| 176 | - if ($file and $file['error'] == 0) { |
|
| 177 | - if ( |
|
| 178 | - !in_array( |
|
| 179 | - strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)), |
|
| 180 | - $extensions_possibles |
|
| 181 | - ) |
|
| 182 | - ) { |
|
| 183 | - $erreurs['logo_' . $etat] = _L('Extension non reconnue'); |
|
| 184 | - } |
|
| 185 | - } elseif ($file and $file['error'] != 0 and isset($file['msg'])) { |
|
| 186 | - $erreurs['message_erreur'] = $file['msg']; |
|
| 187 | - } |
|
| 188 | - } |
|
| 166 | + $erreurs = []; |
|
| 167 | + // verifier les extensions |
|
| 168 | + $sources = formulaire_editer_logo_get_sources(); |
|
| 169 | + include_spip('action/editer_logo'); |
|
| 170 | + $extensions_possibles = $GLOBALS['formats_logos']; |
|
| 171 | + if (in_array('jpg', $extensions_possibles)) { |
|
| 172 | + $extensions_possibles[] = 'jpeg'; |
|
| 173 | + } |
|
| 174 | + foreach ($sources as $etat => $file) { |
|
| 175 | + // seulement si une reception correcte a eu lieu |
|
| 176 | + if ($file and $file['error'] == 0) { |
|
| 177 | + if ( |
|
| 178 | + !in_array( |
|
| 179 | + strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)), |
|
| 180 | + $extensions_possibles |
|
| 181 | + ) |
|
| 182 | + ) { |
|
| 183 | + $erreurs['logo_' . $etat] = _L('Extension non reconnue'); |
|
| 184 | + } |
|
| 185 | + } elseif ($file and $file['error'] != 0 and isset($file['msg'])) { |
|
| 186 | + $erreurs['message_erreur'] = $file['msg']; |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - return $erreurs; |
|
| 190 | + return $erreurs; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -203,47 +203,47 @@ discard block |
||
| 203 | 203 | * @return array Retour des traitements |
| 204 | 204 | */ |
| 205 | 205 | function formulaires_editer_logo_traiter_dist($objet, $id_objet, $retour = '', $options = []) { |
| 206 | - $res = ['editable' => ' ']; |
|
| 206 | + $res = ['editable' => ' ']; |
|
| 207 | 207 | |
| 208 | - // pas dans une boucle ? formulaire pour le logo du site |
|
| 209 | - // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 210 | - if (!$objet) { |
|
| 211 | - $objet = 'site'; |
|
| 212 | - } |
|
| 208 | + // pas dans une boucle ? formulaire pour le logo du site |
|
| 209 | + // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 210 | + if (!$objet) { |
|
| 211 | + $objet = 'site'; |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - include_spip('action/editer_logo'); |
|
| 214 | + include_spip('action/editer_logo'); |
|
| 215 | 215 | |
| 216 | - // effectuer la suppression si demandee d'un logo |
|
| 217 | - $on = _request('supprimer_logo_on'); |
|
| 218 | - if ($on or _request('supprimer_logo_off')) { |
|
| 219 | - logo_supprimer($objet, $id_objet, $on ? 'on' : 'off'); |
|
| 220 | - $res['message_ok'] = ''; // pas besoin de message : la validation est visuelle |
|
| 221 | - set_request('logo_up', ' '); |
|
| 222 | - } // sinon supprimer ancien logo puis copier le nouveau |
|
| 223 | - else { |
|
| 224 | - $sources = formulaire_editer_logo_get_sources(); |
|
| 225 | - foreach ($sources as $etat => $file) { |
|
| 226 | - if ($file and $file['error'] == 0) { |
|
| 227 | - if ($err = logo_modifier($objet, $id_objet, $etat, $file)) { |
|
| 228 | - $res['message_erreur'] = $err; |
|
| 229 | - } else { |
|
| 230 | - $res['message_ok'] = ''; |
|
| 231 | - } // pas besoin de message : la validation est visuelle |
|
| 232 | - set_request('logo_up', ' '); |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - } |
|
| 216 | + // effectuer la suppression si demandee d'un logo |
|
| 217 | + $on = _request('supprimer_logo_on'); |
|
| 218 | + if ($on or _request('supprimer_logo_off')) { |
|
| 219 | + logo_supprimer($objet, $id_objet, $on ? 'on' : 'off'); |
|
| 220 | + $res['message_ok'] = ''; // pas besoin de message : la validation est visuelle |
|
| 221 | + set_request('logo_up', ' '); |
|
| 222 | + } // sinon supprimer ancien logo puis copier le nouveau |
|
| 223 | + else { |
|
| 224 | + $sources = formulaire_editer_logo_get_sources(); |
|
| 225 | + foreach ($sources as $etat => $file) { |
|
| 226 | + if ($file and $file['error'] == 0) { |
|
| 227 | + if ($err = logo_modifier($objet, $id_objet, $etat, $file)) { |
|
| 228 | + $res['message_erreur'] = $err; |
|
| 229 | + } else { |
|
| 230 | + $res['message_ok'] = ''; |
|
| 231 | + } // pas besoin de message : la validation est visuelle |
|
| 232 | + set_request('logo_up', ' '); |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - // Invalider les caches de l'objet |
|
| 238 | - include_spip('inc/invalideur'); |
|
| 239 | - suivre_invalideur("id='$objet/$id_objet'"); |
|
| 237 | + // Invalider les caches de l'objet |
|
| 238 | + include_spip('inc/invalideur'); |
|
| 239 | + suivre_invalideur("id='$objet/$id_objet'"); |
|
| 240 | 240 | |
| 241 | 241 | |
| 242 | - if ($retour) { |
|
| 243 | - $res['redirect'] = $retour; |
|
| 244 | - } |
|
| 242 | + if ($retour) { |
|
| 243 | + $res['redirect'] = $retour; |
|
| 244 | + } |
|
| 245 | 245 | |
| 246 | - return $res; |
|
| 246 | + return $res; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -255,29 +255,29 @@ discard block |
||
| 255 | 255 | * Sources des fichiers dans les clés `on` ou `off` |
| 256 | 256 | */ |
| 257 | 257 | function formulaire_editer_logo_get_sources() { |
| 258 | - if (!$_FILES) { |
|
| 259 | - $_FILES = $GLOBALS['HTTP_POST_FILES'] ?? []; |
|
| 260 | - } |
|
| 261 | - if (!is_array($_FILES)) { |
|
| 262 | - return []; |
|
| 263 | - } |
|
| 258 | + if (!$_FILES) { |
|
| 259 | + $_FILES = $GLOBALS['HTTP_POST_FILES'] ?? []; |
|
| 260 | + } |
|
| 261 | + if (!is_array($_FILES)) { |
|
| 262 | + return []; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - include_spip('inc/documents'); |
|
| 266 | - $sources = []; |
|
| 267 | - foreach (['on', 'off'] as $etat) { |
|
| 268 | - $logo = 'logo_' . $etat; |
|
| 269 | - if (isset($_FILES[$logo])) { |
|
| 270 | - if ($_FILES[$logo]['error'] == 0) { |
|
| 271 | - $sources[$etat] = $_FILES[$logo]; |
|
| 272 | - } elseif ($_FILES[$logo]['error'] != 0) { |
|
| 273 | - $msg = check_upload_error($_FILES[$logo]['error'], false, true); |
|
| 274 | - if ($msg and is_string($msg)) { |
|
| 275 | - $sources[$etat] = $_FILES[$logo]; |
|
| 276 | - $sources[$etat]['msg'] = $msg; |
|
| 277 | - } |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - } |
|
| 265 | + include_spip('inc/documents'); |
|
| 266 | + $sources = []; |
|
| 267 | + foreach (['on', 'off'] as $etat) { |
|
| 268 | + $logo = 'logo_' . $etat; |
|
| 269 | + if (isset($_FILES[$logo])) { |
|
| 270 | + if ($_FILES[$logo]['error'] == 0) { |
|
| 271 | + $sources[$etat] = $_FILES[$logo]; |
|
| 272 | + } elseif ($_FILES[$logo]['error'] != 0) { |
|
| 273 | + $msg = check_upload_error($_FILES[$logo]['error'], false, true); |
|
| 274 | + if ($msg and is_string($msg)) { |
|
| 275 | + $sources[$etat] = $_FILES[$logo]; |
|
| 276 | + $sources[$etat]['msg'] = $msg; |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - return $sources; |
|
| 282 | + return $sources; |
|
| 283 | 283 | } |
@@ -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 | |
@@ -45,136 +45,136 @@ discard block |
||
| 45 | 45 | **/ |
| 46 | 46 | function formulaires_dater_charger_dist($objet, $id_objet, $retour = '', $options = []) { |
| 47 | 47 | |
| 48 | - $jour = null; |
|
| 49 | - $mois = null; |
|
| 50 | - $annee = null; |
|
| 51 | - $heure = null; |
|
| 52 | - $minute = null; |
|
| 53 | - $objet = objet_type($objet); |
|
| 54 | - if (!$objet or !intval($id_objet)) { |
|
| 55 | - return false; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - if (!is_array($options)) { |
|
| 59 | - $options = unserialize($options); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - $_id_objet = id_table_objet($objet); |
|
| 63 | - $table = table_objet($objet); |
|
| 64 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | - $desc = $trouver_table($table); |
|
| 66 | - |
|
| 67 | - if (!$desc) { |
|
| 68 | - return false; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - $champ_date = $desc['date'] ?: 'date'; |
|
| 72 | - if (isset($options['champ_date']) and $options['champ_date']) { |
|
| 73 | - $champ_date = $options['champ_date']; |
|
| 74 | - } |
|
| 75 | - if (!isset($desc['field'][$champ_date])) { |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - $valeurs = [ |
|
| 80 | - 'objet' => $objet, |
|
| 81 | - 'id_objet' => $id_objet, |
|
| 82 | - 'id' => $id_objet, |
|
| 83 | - ]; |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - $select = "$champ_date as date"; |
|
| 87 | - $champ_date_redac = 'date_redac'; |
|
| 88 | - if (isset($options['champ_date_redac']) and $options['champ_date_redac']) { |
|
| 89 | - $champ_date_redac = $options['champ_date_redac']; |
|
| 90 | - } |
|
| 91 | - if (isset($desc['field'][$champ_date_redac])) { |
|
| 92 | - $select .= ",$champ_date_redac as date_redac"; |
|
| 93 | - } |
|
| 94 | - if (isset($desc['field']['statut'])) { |
|
| 95 | - $select .= ',statut'; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . intval($id_objet)); |
|
| 100 | - $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
|
| 101 | - |
|
| 102 | - $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
|
| 103 | - |
|
| 104 | - $possedeDateRedac = false; |
|
| 105 | - |
|
| 106 | - if ( |
|
| 107 | - isset($row['date_redac']) and |
|
| 108 | - $regs = recup_date($row['date_redac'], false) |
|
| 109 | - ) { |
|
| 110 | - $annee_redac = $regs[0]; |
|
| 111 | - $mois_redac = $regs[1]; |
|
| 112 | - $jour_redac = $regs[2]; |
|
| 113 | - $heure_redac = $regs[3]; |
|
| 114 | - $minute_redac = $regs[4]; |
|
| 115 | - $possedeDateRedac = true; |
|
| 116 | - // attention : les vrai dates de l'annee 1 sont stockee avec +9000 => 9001 |
|
| 117 | - // mais reviennent ici en annee 1 par recup_date |
|
| 118 | - // on verifie donc que le intval($row['date_redac']) qui ressort l'annee |
|
| 119 | - // est bien lui aussi <=1 : dans ce cas c'est une date sql 'nulle' ou presque, selon |
|
| 120 | - // le gestionnnaire sql utilise (0001-01-01 pour PG par exemple) |
|
| 121 | - if (intval($row['date_redac']) <= 1 and ($annee_redac <= 1) and ($mois_redac <= 1) and ($jour_redac <= 1)) { |
|
| 122 | - $possedeDateRedac = false; |
|
| 123 | - } |
|
| 124 | - } else { |
|
| 125 | - $annee_redac = $mois_redac = $jour_redac = $heure_redac = $minute_redac = 0; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if ($regs = recup_date($row['date'], false)) { |
|
| 129 | - $annee = $regs[0]; |
|
| 130 | - $mois = $regs[1]; |
|
| 131 | - $jour = $regs[2]; |
|
| 132 | - $heure = $regs[3]; |
|
| 133 | - $minute = $regs[4]; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - // attention, si la variable s'appelle date ou date_redac, le compilo va |
|
| 137 | - // la normaliser, ce qu'on ne veut pas ici. |
|
| 138 | - $valeurs['afficher_date_redac'] = ($possedeDateRedac ? $row['date_redac'] : ''); |
|
| 139 | - $valeurs['date_redac_jour'] = dater_formater_saisie_jour($jour_redac, $mois_redac, $annee_redac); |
|
| 140 | - $valeurs['date_redac_heure'] = "$heure_redac:$minute_redac"; |
|
| 141 | - |
|
| 142 | - $valeurs['afficher_date'] = $row['date']; |
|
| 143 | - $valeurs['date_jour'] = dater_formater_saisie_jour($jour, $mois, $annee); |
|
| 144 | - $valeurs['date_heure'] = "$heure:$minute"; |
|
| 145 | - |
|
| 146 | - $valeurs['sans_redac'] = !$possedeDateRedac; |
|
| 147 | - |
|
| 148 | - if (isset($options['date_redac'])) { |
|
| 149 | - $valeurs['_editer_date_anterieure'] = $options['date_redac']; |
|
| 150 | - } else { |
|
| 151 | - $valeurs['_editer_date_anterieure'] = ($objet == 'article' and ($GLOBALS['meta']['articles_redac'] != 'non' or $possedeDateRedac)); |
|
| 152 | - } |
|
| 153 | - $valeurs['_label_date'] = (($statut == 'publie') ? |
|
| 154 | - _T('texte_date_publication_objet') : _T('texte_date_creation_objet')); |
|
| 155 | - if (isset($options['label_date']) and $options['label_date']) { |
|
| 156 | - $valeurs['_label_date'] = $options['label_date']; |
|
| 157 | - } |
|
| 158 | - if (isset($options['label_date_redac']) and $options['label_date_redac']) { |
|
| 159 | - $valeurs['_label_date_redac'] = $options['label_date_redac']; |
|
| 160 | - } |
|
| 161 | - if (isset($options['texte_sans_date_redac']) and $options['texte_sans_date_redac']) { |
|
| 162 | - $valeurs['_texte_sans_date_redac'] = $options['texte_sans_date_redac']; |
|
| 163 | - } |
|
| 164 | - if (isset($options['class']) and $options['class']) { |
|
| 165 | - $valeurs['_class'] = $options['class']; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - $valeurs['_saisie_en_cours'] = (_request('_saisie_en_cours') !== null or _request('date_jour') !== null); |
|
| 169 | - |
|
| 170 | - // cas ou l'on ne peut pas dater mais on peut modifier la date de redac anterieure |
|
| 171 | - // https://core.spip.net/issues/3494 |
|
| 172 | - $valeurs['_editer_date'] = $valeurs['editable']; |
|
| 173 | - if ($valeurs['_editer_date_anterieure'] and !$valeurs['editable']) { |
|
| 174 | - $valeurs['editable'] = autoriser('modifier', $objet, $id_objet); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return $valeurs; |
|
| 48 | + $jour = null; |
|
| 49 | + $mois = null; |
|
| 50 | + $annee = null; |
|
| 51 | + $heure = null; |
|
| 52 | + $minute = null; |
|
| 53 | + $objet = objet_type($objet); |
|
| 54 | + if (!$objet or !intval($id_objet)) { |
|
| 55 | + return false; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + if (!is_array($options)) { |
|
| 59 | + $options = unserialize($options); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + $_id_objet = id_table_objet($objet); |
|
| 63 | + $table = table_objet($objet); |
|
| 64 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | + $desc = $trouver_table($table); |
|
| 66 | + |
|
| 67 | + if (!$desc) { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + $champ_date = $desc['date'] ?: 'date'; |
|
| 72 | + if (isset($options['champ_date']) and $options['champ_date']) { |
|
| 73 | + $champ_date = $options['champ_date']; |
|
| 74 | + } |
|
| 75 | + if (!isset($desc['field'][$champ_date])) { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + $valeurs = [ |
|
| 80 | + 'objet' => $objet, |
|
| 81 | + 'id_objet' => $id_objet, |
|
| 82 | + 'id' => $id_objet, |
|
| 83 | + ]; |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + $select = "$champ_date as date"; |
|
| 87 | + $champ_date_redac = 'date_redac'; |
|
| 88 | + if (isset($options['champ_date_redac']) and $options['champ_date_redac']) { |
|
| 89 | + $champ_date_redac = $options['champ_date_redac']; |
|
| 90 | + } |
|
| 91 | + if (isset($desc['field'][$champ_date_redac])) { |
|
| 92 | + $select .= ",$champ_date_redac as date_redac"; |
|
| 93 | + } |
|
| 94 | + if (isset($desc['field']['statut'])) { |
|
| 95 | + $select .= ',statut'; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + $row = sql_fetsel($select, $desc['table'], "$_id_objet=" . intval($id_objet)); |
|
| 100 | + $statut = $row['statut'] ?? 'publie'; // pas de statut => publie |
|
| 101 | + |
|
| 102 | + $valeurs['editable'] = autoriser('dater', $objet, $id_objet, null, ['statut' => $statut]); |
|
| 103 | + |
|
| 104 | + $possedeDateRedac = false; |
|
| 105 | + |
|
| 106 | + if ( |
|
| 107 | + isset($row['date_redac']) and |
|
| 108 | + $regs = recup_date($row['date_redac'], false) |
|
| 109 | + ) { |
|
| 110 | + $annee_redac = $regs[0]; |
|
| 111 | + $mois_redac = $regs[1]; |
|
| 112 | + $jour_redac = $regs[2]; |
|
| 113 | + $heure_redac = $regs[3]; |
|
| 114 | + $minute_redac = $regs[4]; |
|
| 115 | + $possedeDateRedac = true; |
|
| 116 | + // attention : les vrai dates de l'annee 1 sont stockee avec +9000 => 9001 |
|
| 117 | + // mais reviennent ici en annee 1 par recup_date |
|
| 118 | + // on verifie donc que le intval($row['date_redac']) qui ressort l'annee |
|
| 119 | + // est bien lui aussi <=1 : dans ce cas c'est une date sql 'nulle' ou presque, selon |
|
| 120 | + // le gestionnnaire sql utilise (0001-01-01 pour PG par exemple) |
|
| 121 | + if (intval($row['date_redac']) <= 1 and ($annee_redac <= 1) and ($mois_redac <= 1) and ($jour_redac <= 1)) { |
|
| 122 | + $possedeDateRedac = false; |
|
| 123 | + } |
|
| 124 | + } else { |
|
| 125 | + $annee_redac = $mois_redac = $jour_redac = $heure_redac = $minute_redac = 0; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if ($regs = recup_date($row['date'], false)) { |
|
| 129 | + $annee = $regs[0]; |
|
| 130 | + $mois = $regs[1]; |
|
| 131 | + $jour = $regs[2]; |
|
| 132 | + $heure = $regs[3]; |
|
| 133 | + $minute = $regs[4]; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + // attention, si la variable s'appelle date ou date_redac, le compilo va |
|
| 137 | + // la normaliser, ce qu'on ne veut pas ici. |
|
| 138 | + $valeurs['afficher_date_redac'] = ($possedeDateRedac ? $row['date_redac'] : ''); |
|
| 139 | + $valeurs['date_redac_jour'] = dater_formater_saisie_jour($jour_redac, $mois_redac, $annee_redac); |
|
| 140 | + $valeurs['date_redac_heure'] = "$heure_redac:$minute_redac"; |
|
| 141 | + |
|
| 142 | + $valeurs['afficher_date'] = $row['date']; |
|
| 143 | + $valeurs['date_jour'] = dater_formater_saisie_jour($jour, $mois, $annee); |
|
| 144 | + $valeurs['date_heure'] = "$heure:$minute"; |
|
| 145 | + |
|
| 146 | + $valeurs['sans_redac'] = !$possedeDateRedac; |
|
| 147 | + |
|
| 148 | + if (isset($options['date_redac'])) { |
|
| 149 | + $valeurs['_editer_date_anterieure'] = $options['date_redac']; |
|
| 150 | + } else { |
|
| 151 | + $valeurs['_editer_date_anterieure'] = ($objet == 'article' and ($GLOBALS['meta']['articles_redac'] != 'non' or $possedeDateRedac)); |
|
| 152 | + } |
|
| 153 | + $valeurs['_label_date'] = (($statut == 'publie') ? |
|
| 154 | + _T('texte_date_publication_objet') : _T('texte_date_creation_objet')); |
|
| 155 | + if (isset($options['label_date']) and $options['label_date']) { |
|
| 156 | + $valeurs['_label_date'] = $options['label_date']; |
|
| 157 | + } |
|
| 158 | + if (isset($options['label_date_redac']) and $options['label_date_redac']) { |
|
| 159 | + $valeurs['_label_date_redac'] = $options['label_date_redac']; |
|
| 160 | + } |
|
| 161 | + if (isset($options['texte_sans_date_redac']) and $options['texte_sans_date_redac']) { |
|
| 162 | + $valeurs['_texte_sans_date_redac'] = $options['texte_sans_date_redac']; |
|
| 163 | + } |
|
| 164 | + if (isset($options['class']) and $options['class']) { |
|
| 165 | + $valeurs['_class'] = $options['class']; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + $valeurs['_saisie_en_cours'] = (_request('_saisie_en_cours') !== null or _request('date_jour') !== null); |
|
| 169 | + |
|
| 170 | + // cas ou l'on ne peut pas dater mais on peut modifier la date de redac anterieure |
|
| 171 | + // https://core.spip.net/issues/3494 |
|
| 172 | + $valeurs['_editer_date'] = $valeurs['editable']; |
|
| 173 | + if ($valeurs['_editer_date_anterieure'] and !$valeurs['editable']) { |
|
| 174 | + $valeurs['editable'] = autoriser('modifier', $objet, $id_objet); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return $valeurs; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
@@ -192,20 +192,20 @@ discard block |
||
| 192 | 192 | * Date formatée tel que `02/10/2012` |
| 193 | 193 | **/ |
| 194 | 194 | function dater_formater_saisie_jour($jour, $mois, $annee, $sep = '/') { |
| 195 | - $annee = str_pad($annee, 4, '0', STR_PAD_LEFT); |
|
| 196 | - if (intval($jour)) { |
|
| 197 | - $jour = str_pad($jour, 2, '0', STR_PAD_LEFT); |
|
| 198 | - $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 195 | + $annee = str_pad($annee, 4, '0', STR_PAD_LEFT); |
|
| 196 | + if (intval($jour)) { |
|
| 197 | + $jour = str_pad($jour, 2, '0', STR_PAD_LEFT); |
|
| 198 | + $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 199 | 199 | |
| 200 | - return "$jour$sep$mois$sep$annee"; |
|
| 201 | - } |
|
| 202 | - if (intval($mois)) { |
|
| 203 | - $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 200 | + return "$jour$sep$mois$sep$annee"; |
|
| 201 | + } |
|
| 202 | + if (intval($mois)) { |
|
| 203 | + $mois = str_pad($mois, 2, '0', STR_PAD_LEFT); |
|
| 204 | 204 | |
| 205 | - return "$mois$sep$annee"; |
|
| 206 | - } |
|
| 205 | + return "$mois$sep$annee"; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - return $annee; |
|
| 208 | + return $annee; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * Hash du formulaire |
| 225 | 225 | **/ |
| 226 | 226 | function formulaires_dater_identifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 227 | - return serialize([$objet, $id_objet]); |
|
| 227 | + return serialize([$objet, $id_objet]); |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -242,30 +242,30 @@ discard block |
||
| 242 | 242 | * Tableau des erreurs |
| 243 | 243 | */ |
| 244 | 244 | function formulaires_dater_verifier_dist($objet, $id_objet, $retour = '', $options = []) { |
| 245 | - $erreurs = []; |
|
| 246 | - |
|
| 247 | - // ouvrir le formulaire en edition ? |
|
| 248 | - if (_request('_saisie_en_cours')) { |
|
| 249 | - $erreurs['message_erreur'] = ''; |
|
| 250 | - |
|
| 251 | - return $erreurs; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - if (_request('changer')) { |
|
| 255 | - foreach (['date', 'date_redac'] as $k) { |
|
| 256 | - if ($v = _request($k . '_jour') and !dater_recuperer_date_saisie($v, $k)) { |
|
| 257 | - $erreurs[$k] = _T('format_date_incorrecte'); |
|
| 258 | - } elseif ($v = _request($k . '_heure') and !dater_recuperer_heure_saisie($v)) { |
|
| 259 | - $erreurs[$k] = _T('format_heure_incorrecte'); |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - if (!_request('date_jour')) { |
|
| 264 | - $erreurs['date'] = _T('info_obligatoire'); |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - return $erreurs; |
|
| 245 | + $erreurs = []; |
|
| 246 | + |
|
| 247 | + // ouvrir le formulaire en edition ? |
|
| 248 | + if (_request('_saisie_en_cours')) { |
|
| 249 | + $erreurs['message_erreur'] = ''; |
|
| 250 | + |
|
| 251 | + return $erreurs; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + if (_request('changer')) { |
|
| 255 | + foreach (['date', 'date_redac'] as $k) { |
|
| 256 | + if ($v = _request($k . '_jour') and !dater_recuperer_date_saisie($v, $k)) { |
|
| 257 | + $erreurs[$k] = _T('format_date_incorrecte'); |
|
| 258 | + } elseif ($v = _request($k . '_heure') and !dater_recuperer_heure_saisie($v)) { |
|
| 259 | + $erreurs[$k] = _T('format_heure_incorrecte'); |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + if (!_request('date_jour')) { |
|
| 264 | + $erreurs['date'] = _T('info_obligatoire'); |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + return $erreurs; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -283,79 +283,79 @@ discard block |
||
| 283 | 283 | * Retours des traitements |
| 284 | 284 | */ |
| 285 | 285 | function formulaires_dater_traiter_dist($objet, $id_objet, $retour = '', $options = []) { |
| 286 | - $res = ['editable' => ' ']; |
|
| 287 | - |
|
| 288 | - if (_request('changer')) { |
|
| 289 | - $table = table_objet($objet); |
|
| 290 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 291 | - $desc = $trouver_table($table); |
|
| 292 | - |
|
| 293 | - if (!$desc) { |
|
| 294 | - return ['message_erreur' => _L('erreur')]; |
|
| 295 | - } #impossible en principe |
|
| 296 | - |
|
| 297 | - $champ_date = $desc['date'] ?: 'date'; |
|
| 298 | - if (isset($options['champ_date']) and $options['champ_date']) { |
|
| 299 | - $champ_date = $options['champ_date']; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - $set = []; |
|
| 303 | - |
|
| 304 | - $charger = charger_fonction('charger', 'formulaires/dater/'); |
|
| 305 | - $v = $charger($objet, $id_objet, $retour, $options); |
|
| 306 | - |
|
| 307 | - if ($v['_editer_date']) { |
|
| 308 | - if (!$d = dater_recuperer_date_saisie(_request('date_jour'))) { |
|
| 309 | - $d = [date('Y'), date('m'), date('d')]; |
|
| 310 | - } |
|
| 311 | - if (!$h = dater_recuperer_heure_saisie(_request('date_heure'))) { |
|
| 312 | - $h = [0, 0]; |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - $champ_date_redac = 'date_redac'; |
|
| 319 | - if (isset($options['champ_date_redac']) and $options['champ_date_redac']) { |
|
| 320 | - $champ_date_redac = $options['champ_date_redac']; |
|
| 321 | - } |
|
| 322 | - if (isset($desc['field'][$champ_date_redac]) and $v['_editer_date_anterieure']) { |
|
| 323 | - if (!_request('date_redac_jour') or _request('sans_redac')) { |
|
| 324 | - $set[$champ_date_redac] = sql_format_date(0, 0, 0, 0, 0, 0); |
|
| 325 | - } else { |
|
| 326 | - if (!$d = dater_recuperer_date_saisie(_request('date_redac_jour'), 'date_redac')) { |
|
| 327 | - $d = [date('Y'), date('m'), date('d')]; |
|
| 328 | - } |
|
| 329 | - if (!$h = dater_recuperer_heure_saisie(_request('date_redac_heure'))) { |
|
| 330 | - $h = [0, 0]; |
|
| 331 | - } |
|
| 332 | - $set[$champ_date_redac] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - if (count($set)) { |
|
| 337 | - $publie_avant = objet_test_si_publie($objet, $id_objet); |
|
| 338 | - include_spip('action/editer_objet'); |
|
| 339 | - objet_modifier($objet, $id_objet, $set); |
|
| 340 | - $publie_apres = objet_test_si_publie($objet, $id_objet); |
|
| 341 | - if ($publie_avant !== $publie_apres) { |
|
| 342 | - // on refuse ajax pour forcer le rechargement de la page ici |
|
| 343 | - // on refera traiter une 2eme fois, mais c'est sans consequence |
|
| 344 | - refuser_traiter_formulaire_ajax(); |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - if ($retour) { |
|
| 350 | - $res['redirect'] = $retour; |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - set_request('date_jour'); |
|
| 354 | - set_request('date_redac_jour'); |
|
| 355 | - set_request('date_heure'); |
|
| 356 | - set_request('date_redac_heure'); |
|
| 357 | - |
|
| 358 | - return $res; |
|
| 286 | + $res = ['editable' => ' ']; |
|
| 287 | + |
|
| 288 | + if (_request('changer')) { |
|
| 289 | + $table = table_objet($objet); |
|
| 290 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 291 | + $desc = $trouver_table($table); |
|
| 292 | + |
|
| 293 | + if (!$desc) { |
|
| 294 | + return ['message_erreur' => _L('erreur')]; |
|
| 295 | + } #impossible en principe |
|
| 296 | + |
|
| 297 | + $champ_date = $desc['date'] ?: 'date'; |
|
| 298 | + if (isset($options['champ_date']) and $options['champ_date']) { |
|
| 299 | + $champ_date = $options['champ_date']; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + $set = []; |
|
| 303 | + |
|
| 304 | + $charger = charger_fonction('charger', 'formulaires/dater/'); |
|
| 305 | + $v = $charger($objet, $id_objet, $retour, $options); |
|
| 306 | + |
|
| 307 | + if ($v['_editer_date']) { |
|
| 308 | + if (!$d = dater_recuperer_date_saisie(_request('date_jour'))) { |
|
| 309 | + $d = [date('Y'), date('m'), date('d')]; |
|
| 310 | + } |
|
| 311 | + if (!$h = dater_recuperer_heure_saisie(_request('date_heure'))) { |
|
| 312 | + $h = [0, 0]; |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + $set[$champ_date] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + $champ_date_redac = 'date_redac'; |
|
| 319 | + if (isset($options['champ_date_redac']) and $options['champ_date_redac']) { |
|
| 320 | + $champ_date_redac = $options['champ_date_redac']; |
|
| 321 | + } |
|
| 322 | + if (isset($desc['field'][$champ_date_redac]) and $v['_editer_date_anterieure']) { |
|
| 323 | + if (!_request('date_redac_jour') or _request('sans_redac')) { |
|
| 324 | + $set[$champ_date_redac] = sql_format_date(0, 0, 0, 0, 0, 0); |
|
| 325 | + } else { |
|
| 326 | + if (!$d = dater_recuperer_date_saisie(_request('date_redac_jour'), 'date_redac')) { |
|
| 327 | + $d = [date('Y'), date('m'), date('d')]; |
|
| 328 | + } |
|
| 329 | + if (!$h = dater_recuperer_heure_saisie(_request('date_redac_heure'))) { |
|
| 330 | + $h = [0, 0]; |
|
| 331 | + } |
|
| 332 | + $set[$champ_date_redac] = sql_format_date($d[0], $d[1], $d[2], $h[0], $h[1]); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + if (count($set)) { |
|
| 337 | + $publie_avant = objet_test_si_publie($objet, $id_objet); |
|
| 338 | + include_spip('action/editer_objet'); |
|
| 339 | + objet_modifier($objet, $id_objet, $set); |
|
| 340 | + $publie_apres = objet_test_si_publie($objet, $id_objet); |
|
| 341 | + if ($publie_avant !== $publie_apres) { |
|
| 342 | + // on refuse ajax pour forcer le rechargement de la page ici |
|
| 343 | + // on refera traiter une 2eme fois, mais c'est sans consequence |
|
| 344 | + refuser_traiter_formulaire_ajax(); |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + if ($retour) { |
|
| 350 | + $res['redirect'] = $retour; |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + set_request('date_jour'); |
|
| 354 | + set_request('date_redac_jour'); |
|
| 355 | + set_request('date_heure'); |
|
| 356 | + set_request('date_redac_heure'); |
|
| 357 | + |
|
| 358 | + return $res; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | /** |
@@ -366,24 +366,24 @@ discard block |
||
| 366 | 366 | * @return array|string Chaîne vide si date invalide, tableau (année, mois, jour) sinon. |
| 367 | 367 | */ |
| 368 | 368 | function dater_recuperer_date_saisie($post, $quoi = 'date') { |
| 369 | - if (!preg_match('#^(?:(?:([0-9]{1,2})[/-])?([0-9]{1,2})[/-])?([0-9]{4}|[0-9]{1,2})#', $post, $regs)) { |
|
| 370 | - return ''; |
|
| 371 | - } |
|
| 372 | - if ($quoi == 'date_redac') { |
|
| 373 | - if ($regs[3] <> '' and $regs[3] < 1001) { |
|
| 374 | - $regs[3] += 9000; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - return [$regs[3], $regs[2], $regs[1]]; |
|
| 378 | - } else { |
|
| 379 | - if ( |
|
| 380 | - checkdate(intval($regs[2]), intval($regs[1]), intval($regs[3])) |
|
| 381 | - and $t = mktime(0, 0, 0, $regs[2], $regs[1], $regs[3]) |
|
| 382 | - ) { |
|
| 383 | - return [date('Y', $t), date('m', $t), date('d', $t)]; |
|
| 384 | - } |
|
| 385 | - return ''; |
|
| 386 | - } |
|
| 369 | + if (!preg_match('#^(?:(?:([0-9]{1,2})[/-])?([0-9]{1,2})[/-])?([0-9]{4}|[0-9]{1,2})#', $post, $regs)) { |
|
| 370 | + return ''; |
|
| 371 | + } |
|
| 372 | + if ($quoi == 'date_redac') { |
|
| 373 | + if ($regs[3] <> '' and $regs[3] < 1001) { |
|
| 374 | + $regs[3] += 9000; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + return [$regs[3], $regs[2], $regs[1]]; |
|
| 378 | + } else { |
|
| 379 | + if ( |
|
| 380 | + checkdate(intval($regs[2]), intval($regs[1]), intval($regs[3])) |
|
| 381 | + and $t = mktime(0, 0, 0, $regs[2], $regs[1], $regs[3]) |
|
| 382 | + ) { |
|
| 383 | + return [date('Y', $t), date('m', $t), date('d', $t)]; |
|
| 384 | + } |
|
| 385 | + return ''; |
|
| 386 | + } |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -393,12 +393,12 @@ discard block |
||
| 393 | 393 | * @return array |
| 394 | 394 | */ |
| 395 | 395 | function dater_recuperer_heure_saisie($post) { |
| 396 | - if (!preg_match('#([0-9]{1,2})(?:[h:](?:([0-9]{1,2}))?)?#', $post, $regs)) { |
|
| 397 | - return ''; |
|
| 398 | - } |
|
| 399 | - if ($regs[1] > 23 or $regs[2] > 59) { |
|
| 400 | - return ''; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - return [$regs[1], $regs[2]]; |
|
| 396 | + if (!preg_match('#([0-9]{1,2})(?:[h:](?:([0-9]{1,2}))?)?#', $post, $regs)) { |
|
| 397 | + return ''; |
|
| 398 | + } |
|
| 399 | + if ($regs[1] > 23 or $regs[2] > 59) { |
|
| 400 | + return ''; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + return [$regs[1], $regs[2]]; |
|
| 404 | 404 | } |
@@ -11,53 +11,53 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_multilinguisme_charger_dist() { |
| 18 | - $valeurs = []; |
|
| 19 | - $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 20 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 21 | - $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - if ( |
|
| 25 | - is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0 |
|
| 26 | - or count(explode(',', $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 27 | - ) { |
|
| 28 | - $selection = (is_null(_request('multi_objets')) ? |
|
| 29 | - explode(',', $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 30 | - $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 31 | - $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - return $valeurs; |
|
| 18 | + $valeurs = []; |
|
| 19 | + $valeurs['multi_secteurs'] = $GLOBALS['meta']['multi_secteurs']; |
|
| 20 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 21 | + $valeurs[$m] = explode(',', $GLOBALS['meta'][$m] ?? ''); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + if ( |
|
| 25 | + is_countable($valeurs['multi_objets']) ? count($valeurs['multi_objets']) : 0 |
|
| 26 | + or count(explode(',', $GLOBALS['meta']['langues_utilisees'])) > 1 |
|
| 27 | + ) { |
|
| 28 | + $selection = (is_null(_request('multi_objets')) ? |
|
| 29 | + explode(',', $GLOBALS['meta']['langues_multilingue']) : _request('langues_auth')); |
|
| 30 | + $valeurs['_langues'] = saisie_langues_utiles('langues_auth', $selection ?: []); |
|
| 31 | + $valeurs['_nb_langues_selection'] = is_countable($selection) ? count($selection) : 0; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + return $valeurs; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | function formulaires_configurer_multilinguisme_traiter_dist() { |
| 39 | - $res = ['editable' => true]; |
|
| 40 | - // un checkbox seul de name X non coche n'est pas poste. |
|
| 41 | - // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 42 | - foreach (['multi_secteurs'] as $m) { |
|
| 43 | - if (!is_null(_request($m . '_check'))) { |
|
| 44 | - ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 48 | - if (!is_null($v = _request($m))) { |
|
| 49 | - // join et enlever la valeur vide '' |
|
| 50 | - ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($i = _request('langues_auth') and is_array($i)) { |
|
| 55 | - $i = array_unique(array_merge($i, explode(',', $GLOBALS['meta']['langues_utilisees']))); |
|
| 56 | - ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 57 | - } |
|
| 58 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 59 | - |
|
| 60 | - return $res; |
|
| 39 | + $res = ['editable' => true]; |
|
| 40 | + // un checkbox seul de name X non coche n'est pas poste. |
|
| 41 | + // on verifie le champ X_check qui indique que la checkbox etait presente dans le formulaire. |
|
| 42 | + foreach (['multi_secteurs'] as $m) { |
|
| 43 | + if (!is_null(_request($m . '_check'))) { |
|
| 44 | + ecrire_meta($m, _request($m) ? 'oui' : 'non'); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + foreach (['multi_objets', 'gerer_trad_objets'] as $m) { |
|
| 48 | + if (!is_null($v = _request($m))) { |
|
| 49 | + // join et enlever la valeur vide '' |
|
| 50 | + ecrire_meta($m, implode(',', array_diff($v, ['']))); |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($i = _request('langues_auth') and is_array($i)) { |
|
| 55 | + $i = array_unique(array_merge($i, explode(',', $GLOBALS['meta']['langues_utilisees']))); |
|
| 56 | + ecrire_meta('langues_multilingue', implode(',', $i)); |
|
| 57 | + } |
|
| 58 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 59 | + |
|
| 60 | + return $res; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | 69 | function table_supporte_lang($table_sql) { |
| 70 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 71 | - $desc = $trouver_table($table_sql); |
|
| 72 | - if (!$desc or !isset($desc['field']['lang'])) { |
|
| 73 | - return ''; |
|
| 74 | - } |
|
| 70 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 71 | + $desc = $trouver_table($table_sql); |
|
| 72 | + if (!$desc or !isset($desc['field']['lang'])) { |
|
| 73 | + return ''; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return ' '; |
|
| 76 | + return ' '; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -83,67 +83,67 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function table_supporte_trad($table_sql) { |
| 86 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 87 | - $desc = $trouver_table($table_sql); |
|
| 88 | - if (!$desc or !isset($desc['field']['id_trad'])) { |
|
| 89 | - return ''; |
|
| 90 | - } |
|
| 86 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 87 | + $desc = $trouver_table($table_sql); |
|
| 88 | + if (!$desc or !isset($desc['field']['id_trad'])) { |
|
| 89 | + return ''; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return ' '; |
|
| 92 | + return ' '; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | function saisie_langues_utiles($name, $selection) { |
| 97 | - include_spip('inc/lang_liste'); |
|
| 98 | - $langues = $GLOBALS['codes_langues']; |
|
| 99 | - |
|
| 100 | - $langues_installees = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 101 | - $langues_trad = array_flip($langues_installees); |
|
| 102 | - |
|
| 103 | - $langues_bloquees = explode(',', $GLOBALS['meta']['langues_utilisees']); |
|
| 104 | - |
|
| 105 | - $res = ''; |
|
| 106 | - |
|
| 107 | - $i = 0; |
|
| 108 | - foreach ($langues_bloquees as $code_langue) { |
|
| 109 | - $nom_langue = $langues[$code_langue]; |
|
| 110 | - $res .= "<li class='choix " |
|
| 111 | - . alterner(++$i, 'odd', 'even') |
|
| 112 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 113 | - . "'>" |
|
| 114 | - . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 115 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 116 | - . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 117 | - . '</li>'; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if ($res) { |
|
| 121 | - $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - $res .= "<ul id='langues_proposees'>"; |
|
| 125 | - |
|
| 126 | - $i = 0; |
|
| 127 | - $langues_bloquees = array_flip($langues_bloquees); |
|
| 128 | - foreach ($langues as $code_langue => $nom_langue) { |
|
| 129 | - if (!isset($langues_bloquees[$code_langue])) { |
|
| 130 | - $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 131 | - $res .= "<li class='choix " |
|
| 132 | - . alterner(++$i, 'odd', 'even') |
|
| 133 | - . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 134 | - . "'>" |
|
| 135 | - . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 136 | - . $checked |
|
| 137 | - . '/>' |
|
| 138 | - . "<label for='{$name}_$code_langue'" |
|
| 139 | - . ($checked ? " class='on'" : '') |
|
| 140 | - . '>' |
|
| 141 | - . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 142 | - . '</li>'; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - $res .= "</ul><div class='nettoyeur'></div>"; |
|
| 147 | - |
|
| 148 | - return $res; |
|
| 97 | + include_spip('inc/lang_liste'); |
|
| 98 | + $langues = $GLOBALS['codes_langues']; |
|
| 99 | + |
|
| 100 | + $langues_installees = explode(',', $GLOBALS['meta']['langues_proposees']); |
|
| 101 | + $langues_trad = array_flip($langues_installees); |
|
| 102 | + |
|
| 103 | + $langues_bloquees = explode(',', $GLOBALS['meta']['langues_utilisees']); |
|
| 104 | + |
|
| 105 | + $res = ''; |
|
| 106 | + |
|
| 107 | + $i = 0; |
|
| 108 | + foreach ($langues_bloquees as $code_langue) { |
|
| 109 | + $nom_langue = $langues[$code_langue]; |
|
| 110 | + $res .= "<li class='choix " |
|
| 111 | + . alterner(++$i, 'odd', 'even') |
|
| 112 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 113 | + . "'>" |
|
| 114 | + . "<input type='hidden' name='{$name}[]' value='$code_langue'>" // necessaire ... |
|
| 115 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue' checked='checked' disabled='disabled' />" |
|
| 116 | + . "<label for='{$name}_$code_langue'>" . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 117 | + . '</li>'; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if ($res) { |
|
| 121 | + $res = "<ul id='langues_bloquees'>" . $res . "</ul><div class='nettoyeur'></div>"; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + $res .= "<ul id='langues_proposees'>"; |
|
| 125 | + |
|
| 126 | + $i = 0; |
|
| 127 | + $langues_bloquees = array_flip($langues_bloquees); |
|
| 128 | + foreach ($langues as $code_langue => $nom_langue) { |
|
| 129 | + if (!isset($langues_bloquees[$code_langue])) { |
|
| 130 | + $checked = (in_array($code_langue, $selection) ? ' checked="checked"' : ''); |
|
| 131 | + $res .= "<li class='choix " |
|
| 132 | + . alterner(++$i, 'odd', 'even') |
|
| 133 | + . (isset($langues_trad[$code_langue]) ? ' traduite' : '') |
|
| 134 | + . "'>" |
|
| 135 | + . "<input type='checkbox' name='{$name}[]' id='{$name}_$code_langue' value='$code_langue'" |
|
| 136 | + . $checked |
|
| 137 | + . '/>' |
|
| 138 | + . "<label for='{$name}_$code_langue'" |
|
| 139 | + . ($checked ? " class='on'" : '') |
|
| 140 | + . '>' |
|
| 141 | + . $nom_langue . " <span class='code_langue'>[$code_langue]</span></label>" |
|
| 142 | + . '</li>'; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + $res .= "</ul><div class='nettoyeur'></div>"; |
|
| 147 | + |
|
| 148 | + return $res; |
|
| 149 | 149 | } |
@@ -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 | include_spip('inc/rechercher'); |
| 24 | 24 | if (!defined('_DELAI_CACHE_resultats')) { |
| 25 | - define('_DELAI_CACHE_resultats', 600); |
|
| 25 | + define('_DELAI_CACHE_resultats', 600); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -49,129 +49,129 @@ discard block |
||
| 49 | 49 | * @return array |
| 50 | 50 | */ |
| 51 | 51 | function inc_prepare_recherche_dist( |
| 52 | - $recherche, |
|
| 53 | - $table = 'articles', |
|
| 54 | - $cond = false, |
|
| 55 | - $serveur = '', |
|
| 56 | - $modificateurs = [], |
|
| 57 | - $primary = '' |
|
| 52 | + $recherche, |
|
| 53 | + $table = 'articles', |
|
| 54 | + $cond = false, |
|
| 55 | + $serveur = '', |
|
| 56 | + $modificateurs = [], |
|
| 57 | + $primary = '' |
|
| 58 | 58 | ) { |
| 59 | - $where = null; |
|
| 60 | - $rows = null; |
|
| 61 | - static $cache = []; |
|
| 62 | - $delai_fraicheur = min( |
|
| 63 | - \_DELAI_CACHE_resultats, |
|
| 64 | - time() - ($GLOBALS['meta']['derniere_modif'] ?? 0) |
|
| 65 | - ); |
|
| 66 | - |
|
| 67 | - // si recherche n'est pas dans le contexte, on va prendre en globals |
|
| 68 | - // ca permet de faire des inclure simple. |
|
| 69 | - if (!isset($recherche) and isset($GLOBALS['recherche'])) { |
|
| 70 | - $recherche = $GLOBALS['recherche']; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - // traiter le cas {recherche?} |
|
| 74 | - if ($cond and !strlen($recherche)) { |
|
| 75 | - return [ |
|
| 76 | - '0 as points' /* as points */, /* where */ |
|
| 77 | - '' |
|
| 78 | - ]; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - $rechercher = false; |
|
| 83 | - |
|
| 84 | - $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND'); |
|
| 85 | - if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 86 | - $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : ''); |
|
| 87 | - $hash = substr(md5($recherche . $table), 0, 16); |
|
| 88 | - $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')"; |
|
| 89 | - $row = sql_fetsel( |
|
| 90 | - 'recherche', |
|
| 91 | - 'spip_resultats AS resultats', |
|
| 92 | - $where . " AND $where_resultat_recent", |
|
| 93 | - '', |
|
| 94 | - '', |
|
| 95 | - '0,1' |
|
| 96 | - ); |
|
| 97 | - if ( |
|
| 98 | - !$row |
|
| 99 | - or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 100 | - ) { |
|
| 101 | - $rechercher = true; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - // si on n'a pas encore traite les donnees dans une boucle precedente |
|
| 106 | - if ($rechercher) { |
|
| 107 | - //$tables = liste_des_champs(); |
|
| 108 | - $x = objet_type($table); |
|
| 109 | - $points = recherche_en_base( |
|
| 110 | - $recherche, |
|
| 111 | - $x, |
|
| 112 | - [ |
|
| 113 | - 'score' => true, |
|
| 114 | - 'toutvoir' => true, |
|
| 115 | - 'jointures' => true |
|
| 116 | - ], |
|
| 117 | - $serveur |
|
| 118 | - ); |
|
| 119 | - // pas de résultat, pas de point |
|
| 120 | - $points = $points[$x] ?? []; |
|
| 121 | - |
|
| 122 | - // permettre aux plugins de modifier le resultat |
|
| 123 | - $points = pipeline('prepare_recherche', [ |
|
| 124 | - 'args' => [ |
|
| 125 | - 'type' => $x, |
|
| 126 | - 'recherche' => $recherche, |
|
| 127 | - 'serveur' => $serveur, |
|
| 128 | - 'modificateurs' => $modificateurs |
|
| 129 | - ], |
|
| 130 | - 'data' => $points |
|
| 131 | - ]); |
|
| 132 | - |
|
| 133 | - // supprimer les anciens resultats de cette recherche |
|
| 134 | - // et les resultats trop vieux avec une marge |
|
| 135 | - // pas de AS resultats dans un delete (mysql) |
|
| 136 | - $whered = str_replace( |
|
| 137 | - ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'], |
|
| 138 | - ['recherche', 'table_objet', 'serveur'], |
|
| 139 | - $where |
|
| 140 | - ); |
|
| 141 | - |
|
| 142 | - sql_delete( |
|
| 143 | - 'spip_resultats', |
|
| 144 | - "NOT($where_resultat_recent) OR ($whered)" |
|
| 145 | - ); |
|
| 146 | - |
|
| 147 | - // inserer les resultats dans la table de cache des resultats |
|
| 148 | - if (is_countable($points) ? count($points) : 0) { |
|
| 149 | - $tab_couples = []; |
|
| 150 | - foreach ($points as $id => $p) { |
|
| 151 | - $tab_couples[] = [ |
|
| 152 | - 'recherche' => $hash, |
|
| 153 | - 'id' => $id, |
|
| 154 | - 'points' => $p['score'], |
|
| 155 | - 'table_objet' => $table, |
|
| 156 | - 'serveur' => $hash_serv, |
|
| 157 | - ]; |
|
| 158 | - } |
|
| 159 | - sql_insertq_multi('spip_resultats', $tab_couples, []); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 164 | - if (!$serveur) { |
|
| 165 | - $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where]; |
|
| 166 | - } else { |
|
| 167 | - if (sql_countsel('spip_resultats as resultats', $where)) { |
|
| 168 | - $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where); |
|
| 169 | - } |
|
| 170 | - $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur); |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - return $cache[$serveur][$table][$recherche]; |
|
| 59 | + $where = null; |
|
| 60 | + $rows = null; |
|
| 61 | + static $cache = []; |
|
| 62 | + $delai_fraicheur = min( |
|
| 63 | + \_DELAI_CACHE_resultats, |
|
| 64 | + time() - ($GLOBALS['meta']['derniere_modif'] ?? 0) |
|
| 65 | + ); |
|
| 66 | + |
|
| 67 | + // si recherche n'est pas dans le contexte, on va prendre en globals |
|
| 68 | + // ca permet de faire des inclure simple. |
|
| 69 | + if (!isset($recherche) and isset($GLOBALS['recherche'])) { |
|
| 70 | + $recherche = $GLOBALS['recherche']; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + // traiter le cas {recherche?} |
|
| 74 | + if ($cond and !strlen($recherche)) { |
|
| 75 | + return [ |
|
| 76 | + '0 as points' /* as points */, /* where */ |
|
| 77 | + '' |
|
| 78 | + ]; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + $rechercher = false; |
|
| 83 | + |
|
| 84 | + $where_resultat_recent = sql_date_proche('maj', (0 - ($delai_fraicheur + 100)), ' SECOND'); |
|
| 85 | + if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 86 | + $hash_serv = ($serveur ? substr(md5($serveur), 0, 16) : ''); |
|
| 87 | + $hash = substr(md5($recherche . $table), 0, 16); |
|
| 88 | + $where = "(resultats.recherche='$hash' AND resultats.table_objet=" . sql_quote($table) . " AND resultats.serveur='$hash_serv')"; |
|
| 89 | + $row = sql_fetsel( |
|
| 90 | + 'recherche', |
|
| 91 | + 'spip_resultats AS resultats', |
|
| 92 | + $where . " AND $where_resultat_recent", |
|
| 93 | + '', |
|
| 94 | + '', |
|
| 95 | + '0,1' |
|
| 96 | + ); |
|
| 97 | + if ( |
|
| 98 | + !$row |
|
| 99 | + or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul') |
|
| 100 | + ) { |
|
| 101 | + $rechercher = true; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + // si on n'a pas encore traite les donnees dans une boucle precedente |
|
| 106 | + if ($rechercher) { |
|
| 107 | + //$tables = liste_des_champs(); |
|
| 108 | + $x = objet_type($table); |
|
| 109 | + $points = recherche_en_base( |
|
| 110 | + $recherche, |
|
| 111 | + $x, |
|
| 112 | + [ |
|
| 113 | + 'score' => true, |
|
| 114 | + 'toutvoir' => true, |
|
| 115 | + 'jointures' => true |
|
| 116 | + ], |
|
| 117 | + $serveur |
|
| 118 | + ); |
|
| 119 | + // pas de résultat, pas de point |
|
| 120 | + $points = $points[$x] ?? []; |
|
| 121 | + |
|
| 122 | + // permettre aux plugins de modifier le resultat |
|
| 123 | + $points = pipeline('prepare_recherche', [ |
|
| 124 | + 'args' => [ |
|
| 125 | + 'type' => $x, |
|
| 126 | + 'recherche' => $recherche, |
|
| 127 | + 'serveur' => $serveur, |
|
| 128 | + 'modificateurs' => $modificateurs |
|
| 129 | + ], |
|
| 130 | + 'data' => $points |
|
| 131 | + ]); |
|
| 132 | + |
|
| 133 | + // supprimer les anciens resultats de cette recherche |
|
| 134 | + // et les resultats trop vieux avec une marge |
|
| 135 | + // pas de AS resultats dans un delete (mysql) |
|
| 136 | + $whered = str_replace( |
|
| 137 | + ['resultats.recherche', 'resultats.table_objet', 'resultats.serveur'], |
|
| 138 | + ['recherche', 'table_objet', 'serveur'], |
|
| 139 | + $where |
|
| 140 | + ); |
|
| 141 | + |
|
| 142 | + sql_delete( |
|
| 143 | + 'spip_resultats', |
|
| 144 | + "NOT($where_resultat_recent) OR ($whered)" |
|
| 145 | + ); |
|
| 146 | + |
|
| 147 | + // inserer les resultats dans la table de cache des resultats |
|
| 148 | + if (is_countable($points) ? count($points) : 0) { |
|
| 149 | + $tab_couples = []; |
|
| 150 | + foreach ($points as $id => $p) { |
|
| 151 | + $tab_couples[] = [ |
|
| 152 | + 'recherche' => $hash, |
|
| 153 | + 'id' => $id, |
|
| 154 | + 'points' => $p['score'], |
|
| 155 | + 'table_objet' => $table, |
|
| 156 | + 'serveur' => $hash_serv, |
|
| 157 | + ]; |
|
| 158 | + } |
|
| 159 | + sql_insertq_multi('spip_resultats', $tab_couples, []); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if (!isset($cache[$serveur][$table][$recherche])) { |
|
| 164 | + if (!$serveur) { |
|
| 165 | + $cache[$serveur][$table][$recherche] = ['resultats.points AS points', $where]; |
|
| 166 | + } else { |
|
| 167 | + if (sql_countsel('spip_resultats as resultats', $where)) { |
|
| 168 | + $rows = sql_allfetsel('resultats.id,resultats.points', 'spip_resultats as resultats', $where); |
|
| 169 | + } |
|
| 170 | + $cache[$serveur][$table][$recherche] = generer_select_where_explicites($table, $primary, $rows, $serveur); |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + return $cache[$serveur][$table][$recherche]; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -187,22 +187,22 @@ discard block |
||
| 187 | 187 | * @return array |
| 188 | 188 | */ |
| 189 | 189 | function generer_select_where_explicites($table, $primary, $rows, $serveur) { |
| 190 | - # calculer le {id_article IN()} et le {... as points} |
|
| 191 | - if (!count($rows)) { |
|
| 192 | - return ["''", '0=1']; |
|
| 193 | - } else { |
|
| 194 | - $listes_ids = []; |
|
| 195 | - $select = '0'; |
|
| 196 | - foreach ($rows as $r) { |
|
| 197 | - $listes_ids[$r['points']][] = $r['id']; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - foreach ($listes_ids as $p => $ids) { |
|
| 201 | - $select .= "+$p*(" . |
|
| 202 | - sql_in("$table.$primary", $ids, '', $serveur) |
|
| 203 | - . ') '; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)]; |
|
| 207 | - } |
|
| 190 | + # calculer le {id_article IN()} et le {... as points} |
|
| 191 | + if (!count($rows)) { |
|
| 192 | + return ["''", '0=1']; |
|
| 193 | + } else { |
|
| 194 | + $listes_ids = []; |
|
| 195 | + $select = '0'; |
|
| 196 | + foreach ($rows as $r) { |
|
| 197 | + $listes_ids[$r['points']][] = $r['id']; |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + foreach ($listes_ids as $p => $ids) { |
|
| 201 | + $select .= "+$p*(" . |
|
| 202 | + sql_in("$table.$primary", $ids, '', $serveur) |
|
| 203 | + . ') '; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + return ["$select AS points ", sql_in("$table.$primary", array_map('reset', $rows), '', $serveur)]; |
|
| 207 | + } |
|
| 208 | 208 | } |
@@ -16,10 +16,10 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Pipelines |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | if (test_espace_prive()) { |
| 22 | - include_spip('inc/pipelines_ecrire'); |
|
| 22 | + include_spip('inc/pipelines_ecrire'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -45,28 +45,28 @@ discard block |
||
| 45 | 45 | * @return string Contenu qui sera inséré dans le head HTML |
| 46 | 46 | **/ |
| 47 | 47 | function f_jQuery($texte) { |
| 48 | - $x = ''; |
|
| 49 | - $jquery_plugins = pipeline( |
|
| 50 | - 'jquery_plugins', |
|
| 51 | - [ |
|
| 52 | - 'javascript/jquery.js', |
|
| 53 | - 'javascript/jquery.form.js', |
|
| 54 | - 'javascript/jquery.autosave.js', |
|
| 55 | - 'javascript/jquery.placeholder-label.js', |
|
| 56 | - 'javascript/ajaxCallback.js', |
|
| 57 | - 'javascript/js.cookie.js', |
|
| 58 | - ] |
|
| 59 | - ); |
|
| 60 | - foreach (array_unique($jquery_plugins) as $script) { |
|
| 61 | - if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 62 | - $script = timestamp($script); |
|
| 63 | - $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 64 | - } |
|
| 65 | - } |
|
| 48 | + $x = ''; |
|
| 49 | + $jquery_plugins = pipeline( |
|
| 50 | + 'jquery_plugins', |
|
| 51 | + [ |
|
| 52 | + 'javascript/jquery.js', |
|
| 53 | + 'javascript/jquery.form.js', |
|
| 54 | + 'javascript/jquery.autosave.js', |
|
| 55 | + 'javascript/jquery.placeholder-label.js', |
|
| 56 | + 'javascript/ajaxCallback.js', |
|
| 57 | + 'javascript/js.cookie.js', |
|
| 58 | + ] |
|
| 59 | + ); |
|
| 60 | + foreach (array_unique($jquery_plugins) as $script) { |
|
| 61 | + if ($script = find_in_path(supprimer_timestamp($script))) { |
|
| 62 | + $script = timestamp($script); |
|
| 63 | + $x .= "\n<script src=\"$script\" type=\"text/javascript\"></script>\n"; |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - $texte = $x . $texte; |
|
| 67 | + $texte = $x . $texte; |
|
| 68 | 68 | |
| 69 | - return $texte; |
|
| 69 | + return $texte; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | * @return string Contenu de la page envoyée au navigateur |
| 86 | 86 | **/ |
| 87 | 87 | function f_surligne($texte) { |
| 88 | - if (!$GLOBALS['html']) { |
|
| 89 | - return $texte; |
|
| 90 | - } |
|
| 91 | - $rech = _request('var_recherche'); |
|
| 92 | - if ( |
|
| 93 | - !$rech |
|
| 94 | - and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 95 | - or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 96 | - or !isset($_SERVER['HTTP_REFERER'])) |
|
| 97 | - ) { |
|
| 98 | - return $texte; |
|
| 99 | - } |
|
| 100 | - include_spip('inc/surligne'); |
|
| 88 | + if (!$GLOBALS['html']) { |
|
| 89 | + return $texte; |
|
| 90 | + } |
|
| 91 | + $rech = _request('var_recherche'); |
|
| 92 | + if ( |
|
| 93 | + !$rech |
|
| 94 | + and (!defined('_SURLIGNE_RECHERCHE_REFERERS') |
|
| 95 | + or !_SURLIGNE_RECHERCHE_REFERERS |
|
| 96 | + or !isset($_SERVER['HTTP_REFERER'])) |
|
| 97 | + ) { |
|
| 98 | + return $texte; |
|
| 99 | + } |
|
| 100 | + include_spip('inc/surligne'); |
|
| 101 | 101 | |
| 102 | - if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 103 | - $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 104 | - } |
|
| 105 | - if ($rech) { |
|
| 106 | - $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 107 | - } |
|
| 102 | + if (isset($_SERVER['HTTP_REFERER'])) { |
|
| 103 | + $_SERVER['HTTP_REFERER'] = preg_replace(',[^\w\,/#&;:-]+,', ' ', $_SERVER['HTTP_REFERER']); |
|
| 104 | + } |
|
| 105 | + if ($rech) { |
|
| 106 | + $rech = preg_replace(',[^\w\,/#&;:-]+,', ' ', $rech); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - return surligner_mots($texte, $rech); |
|
| 109 | + return surligner_mots($texte, $rech); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -123,33 +123,33 @@ discard block |
||
| 123 | 123 | * @return string Contenu de la page envoyée au navigateur |
| 124 | 124 | **/ |
| 125 | 125 | function f_tidy($texte) { |
| 126 | - /** |
|
| 127 | - * Indentation à faire ? |
|
| 128 | - * |
|
| 129 | - * - true : actif. |
|
| 130 | - * - false par défaut. |
|
| 131 | - */ |
|
| 126 | + /** |
|
| 127 | + * Indentation à faire ? |
|
| 128 | + * |
|
| 129 | + * - true : actif. |
|
| 130 | + * - false par défaut. |
|
| 131 | + */ |
|
| 132 | 132 | |
| 133 | - if ( |
|
| 134 | - $GLOBALS['xhtml'] # tidy demande |
|
| 135 | - and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 136 | - and strlen($texte) |
|
| 137 | - and !headers_sent() |
|
| 138 | - ) { |
|
| 139 | - # Compatibilite ascendante |
|
| 140 | - if (!is_string($GLOBALS['xhtml'])) { |
|
| 141 | - $GLOBALS['xhtml'] = 'tidy'; |
|
| 142 | - } |
|
| 133 | + if ( |
|
| 134 | + $GLOBALS['xhtml'] # tidy demande |
|
| 135 | + and $GLOBALS['html'] # verifie que la page avait l'entete text/html |
|
| 136 | + and strlen($texte) |
|
| 137 | + and !headers_sent() |
|
| 138 | + ) { |
|
| 139 | + # Compatibilite ascendante |
|
| 140 | + if (!is_string($GLOBALS['xhtml'])) { |
|
| 141 | + $GLOBALS['xhtml'] = 'tidy'; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 145 | - spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 146 | - $f = charger_fonction('sax', 'xml'); |
|
| 147 | - } |
|
| 144 | + if (!$f = charger_fonction($GLOBALS['xhtml'], 'inc', true)) { |
|
| 145 | + spip_log("tidy absent, l'indenteur SPIP le remplace"); |
|
| 146 | + $f = charger_fonction('sax', 'xml'); |
|
| 147 | + } |
|
| 148 | 148 | |
| 149 | - return $f($texte); |
|
| 150 | - } |
|
| 149 | + return $f($texte); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - return $texte; |
|
| 152 | + return $texte; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -168,21 +168,21 @@ discard block |
||
| 168 | 168 | * @return string Contenu de la page envoyée au navigateur |
| 169 | 169 | **/ |
| 170 | 170 | function f_insert_head($texte) { |
| 171 | - if (!$GLOBALS['html']) { |
|
| 172 | - return $texte; |
|
| 173 | - } |
|
| 174 | - include_spip('public/admin'); // pour strripos |
|
| 171 | + if (!$GLOBALS['html']) { |
|
| 172 | + return $texte; |
|
| 173 | + } |
|
| 174 | + include_spip('public/admin'); // pour strripos |
|
| 175 | 175 | |
| 176 | - ($pos = stripos($texte, '</head>')) |
|
| 177 | - || ($pos = stripos($texte, '<body>')) |
|
| 178 | - || ($pos = 0); |
|
| 176 | + ($pos = stripos($texte, '</head>')) |
|
| 177 | + || ($pos = stripos($texte, '<body>')) |
|
| 178 | + || ($pos = 0); |
|
| 179 | 179 | |
| 180 | - if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 181 | - $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 182 | - $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 183 | - } |
|
| 180 | + if (false === strpos(substr($texte, 0, $pos), '<!-- insert_head -->')) { |
|
| 181 | + $insert = "\n" . pipeline('insert_head', '<!-- f_insert_head -->') . "\n"; |
|
| 182 | + $texte = substr_replace($texte, $insert, $pos, 0); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return $texte; |
|
| 185 | + return $texte; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -198,34 +198,34 @@ discard block |
||
| 198 | 198 | * @return string Contenu de la page envoyée au navigateur |
| 199 | 199 | **/ |
| 200 | 200 | function f_admin($texte) { |
| 201 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 202 | - include_spip('inc/filtres'); // pour http_img_pack |
|
| 203 | - $x = "<div class='spip-previsu' " |
|
| 204 | - . http_style_background('preview-32.png', '', 32) |
|
| 205 | - . '>' |
|
| 206 | - . _T('previsualisation') |
|
| 207 | - . '</div>'; |
|
| 208 | - if (!$pos = stripos($texte, '</body>')) { |
|
| 209 | - $pos = strlen($texte); |
|
| 210 | - } |
|
| 211 | - $texte = substr_replace($texte, $x, $pos, 0); |
|
| 212 | - // pas de preview en fenetre enfant |
|
| 213 | - $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>"; |
|
| 214 | - if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 215 | - $pos = -1; |
|
| 216 | - } |
|
| 217 | - $texte = substr_replace($texte, $x, $pos + 1, 0); |
|
| 218 | - } |
|
| 201 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and $GLOBALS['html']) { |
|
| 202 | + include_spip('inc/filtres'); // pour http_img_pack |
|
| 203 | + $x = "<div class='spip-previsu' " |
|
| 204 | + . http_style_background('preview-32.png', '', 32) |
|
| 205 | + . '>' |
|
| 206 | + . _T('previsualisation') |
|
| 207 | + . '</div>'; |
|
| 208 | + if (!$pos = stripos($texte, '</body>')) { |
|
| 209 | + $pos = strlen($texte); |
|
| 210 | + } |
|
| 211 | + $texte = substr_replace($texte, $x, $pos, 0); |
|
| 212 | + // pas de preview en fenetre enfant |
|
| 213 | + $x = "<script type='text/javascript'>const frameEl = window.frameElement;if (frameEl) {frameEl.sandbox='sandbox';window.location.href='" . addslashes($GLOBALS['meta']['adresse_site']) . "';}</script>"; |
|
| 214 | + if (!$pos = stripos($texte, '<head') or !$pos = strpos($texte, '>', $pos)) { |
|
| 215 | + $pos = -1; |
|
| 216 | + } |
|
| 217 | + $texte = substr_replace($texte, $x, $pos + 1, 0); |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 221 | - include_spip('public/admin'); |
|
| 222 | - $texte = affiche_boutons_admin($texte); |
|
| 223 | - } |
|
| 224 | - if (_request('var_mode') == 'noajax') { |
|
| 225 | - $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 226 | - } |
|
| 220 | + if (isset($GLOBALS['affiche_boutons_admin']) and $GLOBALS['affiche_boutons_admin']) { |
|
| 221 | + include_spip('public/admin'); |
|
| 222 | + $texte = affiche_boutons_admin($texte); |
|
| 223 | + } |
|
| 224 | + if (_request('var_mode') == 'noajax') { |
|
| 225 | + $texte = preg_replace(',(class=[\'"][^\'"]*)ajax([^\'"]*[\'"]),Uims', "\\1\\2", $texte); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - return $texte; |
|
| 228 | + return $texte; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | /** |
@@ -243,11 +243,11 @@ discard block |
||
| 243 | 243 | * @return array $flux Description et contenu de l'inclusion |
| 244 | 244 | **/ |
| 245 | 245 | function f_recuperer_fond($flux) { |
| 246 | - if (!test_espace_prive()) { |
|
| 247 | - return $flux; |
|
| 248 | - } |
|
| 246 | + if (!test_espace_prive()) { |
|
| 247 | + return $flux; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - return f_afficher_blocs_ecrire($flux); |
|
| 250 | + return f_afficher_blocs_ecrire($flux); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -261,30 +261,30 @@ discard block |
||
| 261 | 261 | * @return string Contenu de la page envoyée au navigateur |
| 262 | 262 | */ |
| 263 | 263 | function f_queue($texte) { |
| 264 | - // eviter une inclusion si rien a faire |
|
| 265 | - if ( |
|
| 266 | - _request('action') == 'cron' |
|
| 267 | - or queue_sleep_time_to_next_job() > 0 |
|
| 268 | - or defined('_DEBUG_BLOCK_QUEUE') |
|
| 269 | - ) { |
|
| 270 | - return $texte; |
|
| 271 | - } |
|
| 264 | + // eviter une inclusion si rien a faire |
|
| 265 | + if ( |
|
| 266 | + _request('action') == 'cron' |
|
| 267 | + or queue_sleep_time_to_next_job() > 0 |
|
| 268 | + or defined('_DEBUG_BLOCK_QUEUE') |
|
| 269 | + ) { |
|
| 270 | + return $texte; |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - include_spip('inc/queue'); |
|
| 274 | - $code = queue_affichage_cron(); |
|
| 273 | + include_spip('inc/queue'); |
|
| 274 | + $code = queue_affichage_cron(); |
|
| 275 | 275 | |
| 276 | - // si rien a afficher |
|
| 277 | - // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 278 | - if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 279 | - return $texte; |
|
| 280 | - } |
|
| 276 | + // si rien a afficher |
|
| 277 | + // ou si on est pas dans une page html, on ne sait rien faire de mieux |
|
| 278 | + if (!$code or !isset($GLOBALS['html']) or !$GLOBALS['html']) { |
|
| 279 | + return $texte; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 283 | - if (($p = strpos($texte, '</body>')) !== false) { |
|
| 284 | - $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 285 | - } else { |
|
| 286 | - $texte .= $code; |
|
| 287 | - } |
|
| 282 | + // inserer avant le </body> fermant si on peut, a la fin de la page sinon |
|
| 283 | + if (($p = strpos($texte, '</body>')) !== false) { |
|
| 284 | + $texte = substr($texte, 0, $p) . $code . substr($texte, $p); |
|
| 285 | + } else { |
|
| 286 | + $texte .= $code; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - return $texte; |
|
| 289 | + return $texte; |
|
| 290 | 290 | } |