@@ -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 | // utilise pour le logo du site, donc doit rester ici |
@@ -48,92 +48,92 @@ discard block |
||
| 48 | 48 | * @return array|false Variables d'environnement pour le fond |
| 49 | 49 | */ |
| 50 | 50 | function formulaires_editer_logo_charger_dist($objet, $id_objet, $retour = '', $options = []) { |
| 51 | - // pas dans une boucle ? formulaire pour le logo du site |
|
| 52 | - // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 53 | - if (!$objet) { |
|
| 54 | - $objet = 'site'; |
|
| 55 | - } |
|
| 51 | + // pas dans une boucle ? formulaire pour le logo du site |
|
| 52 | + // dans ce cas, il faut chercher un 'siteon0.ext' |
|
| 53 | + if (!$objet) { |
|
| 54 | + $objet = 'site'; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - $objet = objet_type($objet); |
|
| 58 | - $_id_objet = id_table_objet($objet); |
|
| 57 | + $objet = objet_type($objet); |
|
| 58 | + $_id_objet = id_table_objet($objet); |
|
| 59 | 59 | |
| 60 | - if (!is_array($options)) { |
|
| 61 | - $options = unserialize($options); |
|
| 62 | - } |
|
| 63 | - $options = spip_sanitize_from_request($options, '*'); |
|
| 60 | + if (!is_array($options)) { |
|
| 61 | + $options = unserialize($options); |
|
| 62 | + } |
|
| 63 | + $options = spip_sanitize_from_request($options, '*'); |
|
| 64 | 64 | |
| 65 | - if (!isset($options['titre'])) { |
|
| 66 | - $balise_img = chercher_filtre('balise_img'); |
|
| 67 | - $img = $balise_img(chemin_image('image-24.png'), '', 'cadre-icone'); |
|
| 68 | - $libelles = pipeline('libeller_logo', $GLOBALS['logo_libelles']); |
|
| 69 | - $libelle = (($id_objet or $objet != 'rubrique') ? $objet : 'racine'); |
|
| 70 | - if (isset($libelles[$libelle])) { |
|
| 71 | - $libelle = $libelles[$libelle]; |
|
| 72 | - } elseif ($libelle = objet_info($objet, 'texte_logo_objet')) { |
|
| 73 | - $libelle = _T($libelle); |
|
| 74 | - } else { |
|
| 75 | - $libelle = _L('Logo'); |
|
| 76 | - } |
|
| 77 | - switch ($objet) { |
|
| 78 | - case 'article': |
|
| 79 | - $libelle .= ' ' . aider('logoart'); |
|
| 80 | - break; |
|
| 81 | - case 'breve': |
|
| 82 | - $libelle .= ' ' . aider('breveslogo'); |
|
| 83 | - break; |
|
| 84 | - case 'rubrique': |
|
| 85 | - $libelle .= ' ' . aider('rublogo'); |
|
| 86 | - break; |
|
| 87 | - default: |
|
| 88 | - break; |
|
| 89 | - } |
|
| 65 | + if (!isset($options['titre'])) { |
|
| 66 | + $balise_img = chercher_filtre('balise_img'); |
|
| 67 | + $img = $balise_img(chemin_image('image-24.png'), '', 'cadre-icone'); |
|
| 68 | + $libelles = pipeline('libeller_logo', $GLOBALS['logo_libelles']); |
|
| 69 | + $libelle = (($id_objet or $objet != 'rubrique') ? $objet : 'racine'); |
|
| 70 | + if (isset($libelles[$libelle])) { |
|
| 71 | + $libelle = $libelles[$libelle]; |
|
| 72 | + } elseif ($libelle = objet_info($objet, 'texte_logo_objet')) { |
|
| 73 | + $libelle = _T($libelle); |
|
| 74 | + } else { |
|
| 75 | + $libelle = _L('Logo'); |
|
| 76 | + } |
|
| 77 | + switch ($objet) { |
|
| 78 | + case 'article': |
|
| 79 | + $libelle .= ' ' . aider('logoart'); |
|
| 80 | + break; |
|
| 81 | + case 'breve': |
|
| 82 | + $libelle .= ' ' . aider('breveslogo'); |
|
| 83 | + break; |
|
| 84 | + case 'rubrique': |
|
| 85 | + $libelle .= ' ' . aider('rublogo'); |
|
| 86 | + break; |
|
| 87 | + default: |
|
| 88 | + break; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - $options['titre'] = $img . $libelle; |
|
| 92 | - } |
|
| 93 | - if (!isset($options['editable'])) { |
|
| 94 | - include_spip('inc/autoriser'); |
|
| 95 | - $options['editable'] = autoriser('iconifier', $objet, $id_objet); |
|
| 96 | - } |
|
| 91 | + $options['titre'] = $img . $libelle; |
|
| 92 | + } |
|
| 93 | + if (!isset($options['editable'])) { |
|
| 94 | + include_spip('inc/autoriser'); |
|
| 95 | + $options['editable'] = autoriser('iconifier', $objet, $id_objet); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - $res = [ |
|
| 99 | - 'editable' => ($GLOBALS['meta']['activer_logos'] == 'oui' ? ' ' : '') && (!isset($options['editable']) or $options['editable']), |
|
| 100 | - 'logo_survol' => ($GLOBALS['meta']['activer_logos_survol'] == 'oui' ? ' ' : ''), |
|
| 101 | - 'objet' => $objet, |
|
| 102 | - 'id_objet' => $id_objet, |
|
| 103 | - '_options' => $options, |
|
| 104 | - '_show_upload_off' => '', |
|
| 105 | - ]; |
|
| 98 | + $res = [ |
|
| 99 | + 'editable' => ($GLOBALS['meta']['activer_logos'] == 'oui' ? ' ' : '') && (!isset($options['editable']) or $options['editable']), |
|
| 100 | + 'logo_survol' => ($GLOBALS['meta']['activer_logos_survol'] == 'oui' ? ' ' : ''), |
|
| 101 | + 'objet' => $objet, |
|
| 102 | + 'id_objet' => $id_objet, |
|
| 103 | + '_options' => $options, |
|
| 104 | + '_show_upload_off' => '', |
|
| 105 | + ]; |
|
| 106 | 106 | |
| 107 | - // rechercher le logo de l'objet |
|
| 108 | - // la fonction prend un parametre '_id_objet' etrange : |
|
| 109 | - // le nom de la cle primaire (et non le nom de la table) |
|
| 110 | - // ou directement le nom du raccourcis a chercher |
|
| 111 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 112 | - $etats = $res['logo_survol'] ? ['on', 'off'] : ['on']; |
|
| 113 | - foreach ($etats as $etat) { |
|
| 114 | - $logo = $chercher_logo($id_objet, $_id_objet, $etat); |
|
| 115 | - if ($logo) { |
|
| 116 | - $res['logo_' . $etat] = $logo[0]; |
|
| 117 | - $res['logo_id_' . $etat] = $logo[5]['id_document'] ?? ''; |
|
| 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 | - } |
|
| 107 | + // rechercher le logo de l'objet |
|
| 108 | + // la fonction prend un parametre '_id_objet' etrange : |
|
| 109 | + // le nom de la cle primaire (et non le nom de la table) |
|
| 110 | + // ou directement le nom du raccourcis a chercher |
|
| 111 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 112 | + $etats = $res['logo_survol'] ? ['on', 'off'] : ['on']; |
|
| 113 | + foreach ($etats as $etat) { |
|
| 114 | + $logo = $chercher_logo($id_objet, $_id_objet, $etat); |
|
| 115 | + if ($logo) { |
|
| 116 | + $res['logo_' . $etat] = $logo[0]; |
|
| 117 | + $res['logo_id_' . $etat] = $logo[5]['id_document'] ?? ''; |
|
| 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 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | * @return array|bool|null |
| 34 | 34 | */ |
| 35 | 35 | function quete_virtuel($id_article, $connect) { |
| 36 | - return sql_getfetsel( |
|
| 37 | - 'virtuel', |
|
| 38 | - 'spip_articles', |
|
| 39 | - ['id_article=' . intval($id_article), "statut='publie'"], |
|
| 40 | - '', |
|
| 41 | - '', |
|
| 42 | - '', |
|
| 43 | - '', |
|
| 44 | - $connect |
|
| 45 | - ); |
|
| 36 | + return sql_getfetsel( |
|
| 37 | + 'virtuel', |
|
| 38 | + 'spip_articles', |
|
| 39 | + ['id_article=' . intval($id_article), "statut='publie'"], |
|
| 40 | + '', |
|
| 41 | + '', |
|
| 42 | + '', |
|
| 43 | + '', |
|
| 44 | + $connect |
|
| 45 | + ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -57,41 +57,41 @@ discard block |
||
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | 59 | function quete_parent_lang($table, $id, string $connect = '') { |
| 60 | - static $cache_quete = []; |
|
| 61 | - |
|
| 62 | - if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | - if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | - if ( |
|
| 66 | - !$desc = $trouver_table( |
|
| 67 | - $table, |
|
| 68 | - $connect |
|
| 69 | - ) or !isset($desc['field']['id_rubrique']) |
|
| 70 | - ) { |
|
| 71 | - // pas de parent rubrique, on passe |
|
| 72 | - $cache_quete[$connect][$table]['_select'] = false; |
|
| 73 | - } else { |
|
| 74 | - $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 75 | - $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 76 | - $cache_quete[$connect][$table]['_select'] = $select; |
|
| 77 | - $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 78 | - } |
|
| 79 | - } |
|
| 80 | - if ($cache_quete[$connect][$table]['_select']) { |
|
| 81 | - $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 82 | - $cache_quete[$connect][$table]['_select'], |
|
| 83 | - $table, |
|
| 84 | - $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 85 | - '', |
|
| 86 | - '', |
|
| 87 | - '', |
|
| 88 | - '', |
|
| 89 | - $connect |
|
| 90 | - ); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return $cache_quete[$connect][$table][$id] ?? null; |
|
| 60 | + static $cache_quete = []; |
|
| 61 | + |
|
| 62 | + if (!isset($cache_quete[$connect][$table][$id])) { |
|
| 63 | + if (!isset($cache_quete[$connect][$table]['_select'])) { |
|
| 64 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 65 | + if ( |
|
| 66 | + !$desc = $trouver_table( |
|
| 67 | + $table, |
|
| 68 | + $connect |
|
| 69 | + ) or !isset($desc['field']['id_rubrique']) |
|
| 70 | + ) { |
|
| 71 | + // pas de parent rubrique, on passe |
|
| 72 | + $cache_quete[$connect][$table]['_select'] = false; |
|
| 73 | + } else { |
|
| 74 | + $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 75 | + $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 76 | + $cache_quete[$connect][$table]['_select'] = $select; |
|
| 77 | + $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + if ($cache_quete[$connect][$table]['_select']) { |
|
| 81 | + $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 82 | + $cache_quete[$connect][$table]['_select'], |
|
| 83 | + $table, |
|
| 84 | + $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 85 | + '', |
|
| 86 | + '', |
|
| 87 | + '', |
|
| 88 | + '', |
|
| 89 | + $connect |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return $cache_quete[$connect][$table][$id] ?? null; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | * @return int |
| 109 | 109 | */ |
| 110 | 110 | function quete_parent($id_rubrique, string $connect = '') { |
| 111 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 112 | - return 0; |
|
| 113 | - } |
|
| 114 | - $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 115 | - return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 111 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 112 | + return 0; |
|
| 113 | + } |
|
| 114 | + $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 115 | + return $id_parent ? $id_parent['id_parent'] : 0; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | * @return int |
| 129 | 129 | */ |
| 130 | 130 | function quete_rubrique($id_article, $serveur) { |
| 131 | - $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 131 | + $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 132 | 132 | |
| 133 | - return $id_parent['id_rubrique']; |
|
| 133 | + return $id_parent['id_rubrique']; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | * @return int |
| 145 | 145 | */ |
| 146 | 146 | function quete_profondeur($id, string $connect = '') { |
| 147 | - $n = 0; |
|
| 148 | - while ($id) { |
|
| 149 | - $n++; |
|
| 150 | - $id = quete_parent($id, $connect); |
|
| 151 | - } |
|
| 147 | + $n = 0; |
|
| 148 | + while ($id) { |
|
| 149 | + $n++; |
|
| 150 | + $id = quete_parent($id, $connect); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - return $n; |
|
| 153 | + return $n; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | * Morceau de la requête SQL testant la date |
| 167 | 167 | */ |
| 168 | 168 | function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) { |
| 169 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 170 | - return '1=1'; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - return |
|
| 174 | - (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | - and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 176 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 177 | - : '1=1'; |
|
| 169 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 170 | + return '1=1'; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return |
|
| 174 | + (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 175 | + and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 176 | + ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 177 | + : '1=1'; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
@@ -194,101 +194,101 @@ discard block |
||
| 194 | 194 | * @return array|string |
| 195 | 195 | */ |
| 196 | 196 | function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) { |
| 197 | - static $cond = []; |
|
| 198 | - $key = func_get_args(); |
|
| 199 | - $key = implode('-', $key); |
|
| 200 | - if (isset($cond[$key])) { |
|
| 201 | - return $cond[$key]; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - $liste_statuts = $publie; |
|
| 205 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 206 | - $liste_statuts = $previsu; |
|
| 207 | - } |
|
| 208 | - $not = false; |
|
| 209 | - if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 210 | - $not = true; |
|
| 211 | - $liste_statuts = substr($liste_statuts, 1); |
|
| 212 | - } |
|
| 213 | - // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 214 | - if (!strlen($liste_statuts)) { |
|
| 215 | - return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - $liste_statuts = explode(',', $liste_statuts); |
|
| 219 | - $where = []; |
|
| 220 | - foreach ($liste_statuts as $k => $v) { |
|
| 221 | - // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 222 | - // a ceux de l'auteur identifie |
|
| 223 | - if (strpos($v, '/') !== false) { |
|
| 224 | - $v = explode('/', $v); |
|
| 225 | - $filtre = end($v); |
|
| 226 | - $v = reset($v); |
|
| 227 | - $v = preg_replace(',\W,', '', $v); |
|
| 228 | - if ( |
|
| 229 | - $filtre == 'auteur' |
|
| 230 | - and (strpos($mstatut, '.') !== false) |
|
| 231 | - and $objet = explode('.', $mstatut) |
|
| 232 | - and $id_table = reset($objet) |
|
| 233 | - and $objet = objet_type($id_table) |
|
| 234 | - ) { |
|
| 235 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 236 | - |
|
| 237 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 238 | - // sinon l’auteur en session |
|
| 239 | - include_spip('inc/securiser_action'); |
|
| 240 | - if ($desc = decrire_token_previsu()) { |
|
| 241 | - $id_auteur = $desc['id_auteur']; |
|
| 242 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 243 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 244 | - } else { |
|
| 245 | - $id_auteur = null; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 249 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 250 | - // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 251 | - if (!$id_auteur) { |
|
| 252 | - $where[] = $w; |
|
| 253 | - } else { |
|
| 254 | - $primary = id_table_objet($objet); |
|
| 255 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 256 | - 'ssss.id_objet', |
|
| 257 | - 'spip_auteurs_liens AS ssss', |
|
| 258 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 259 | - '', |
|
| 260 | - '', |
|
| 261 | - '', |
|
| 262 | - '', |
|
| 263 | - $serveur |
|
| 264 | - ) . '))'; |
|
| 265 | - } |
|
| 266 | - } |
|
| 267 | - } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 268 | - else { |
|
| 269 | - $v = ''; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - // securite |
|
| 273 | - $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 274 | - } |
|
| 275 | - $liste_statuts = array_filter($liste_statuts); |
|
| 276 | - if (count($liste_statuts) == 1) { |
|
| 277 | - $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 278 | - } else { |
|
| 279 | - $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - while (count($where) > 1) { |
|
| 283 | - $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 284 | - $where[] = $and; |
|
| 285 | - } |
|
| 286 | - $cond[$key] = reset($where); |
|
| 287 | - if ($not) { |
|
| 288 | - $cond[$key] = ['NOT', $cond[$key]]; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - return $cond[$key]; |
|
| 197 | + static $cond = []; |
|
| 198 | + $key = func_get_args(); |
|
| 199 | + $key = implode('-', $key); |
|
| 200 | + if (isset($cond[$key])) { |
|
| 201 | + return $cond[$key]; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + $liste_statuts = $publie; |
|
| 205 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 206 | + $liste_statuts = $previsu; |
|
| 207 | + } |
|
| 208 | + $not = false; |
|
| 209 | + if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 210 | + $not = true; |
|
| 211 | + $liste_statuts = substr($liste_statuts, 1); |
|
| 212 | + } |
|
| 213 | + // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 214 | + if (!strlen($liste_statuts)) { |
|
| 215 | + return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + $liste_statuts = explode(',', $liste_statuts); |
|
| 219 | + $where = []; |
|
| 220 | + foreach ($liste_statuts as $k => $v) { |
|
| 221 | + // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 222 | + // a ceux de l'auteur identifie |
|
| 223 | + if (strpos($v, '/') !== false) { |
|
| 224 | + $v = explode('/', $v); |
|
| 225 | + $filtre = end($v); |
|
| 226 | + $v = reset($v); |
|
| 227 | + $v = preg_replace(',\W,', '', $v); |
|
| 228 | + if ( |
|
| 229 | + $filtre == 'auteur' |
|
| 230 | + and (strpos($mstatut, '.') !== false) |
|
| 231 | + and $objet = explode('.', $mstatut) |
|
| 232 | + and $id_table = reset($objet) |
|
| 233 | + and $objet = objet_type($id_table) |
|
| 234 | + ) { |
|
| 235 | + $w = "$mstatut<>" . sql_quote($v); |
|
| 236 | + |
|
| 237 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 238 | + // sinon l’auteur en session |
|
| 239 | + include_spip('inc/securiser_action'); |
|
| 240 | + if ($desc = decrire_token_previsu()) { |
|
| 241 | + $id_auteur = $desc['id_auteur']; |
|
| 242 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 243 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 244 | + } else { |
|
| 245 | + $id_auteur = null; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 249 | + if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 250 | + // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 251 | + if (!$id_auteur) { |
|
| 252 | + $where[] = $w; |
|
| 253 | + } else { |
|
| 254 | + $primary = id_table_objet($objet); |
|
| 255 | + $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 256 | + 'ssss.id_objet', |
|
| 257 | + 'spip_auteurs_liens AS ssss', |
|
| 258 | + 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 259 | + '', |
|
| 260 | + '', |
|
| 261 | + '', |
|
| 262 | + '', |
|
| 263 | + $serveur |
|
| 264 | + ) . '))'; |
|
| 265 | + } |
|
| 266 | + } |
|
| 267 | + } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 268 | + else { |
|
| 269 | + $v = ''; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + // securite |
|
| 273 | + $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 274 | + } |
|
| 275 | + $liste_statuts = array_filter($liste_statuts); |
|
| 276 | + if (count($liste_statuts) == 1) { |
|
| 277 | + $where[] = ['=', $mstatut, sql_quote(reset($liste_statuts), $serveur)]; |
|
| 278 | + } else { |
|
| 279 | + $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + while (count($where) > 1) { |
|
| 283 | + $and = ['AND', array_pop($where), array_pop($where)]; |
|
| 284 | + $where[] = $and; |
|
| 285 | + } |
|
| 286 | + $cond[$key] = reset($where); |
|
| 287 | + if ($not) { |
|
| 288 | + $cond[$key] = ['NOT', $cond[$key]]; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + return $cond[$key]; |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return array|bool|null |
| 300 | 300 | */ |
| 301 | 301 | function quete_fichier($id_document, $serveur = '') { |
| 302 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 302 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @return array|bool |
| 311 | 311 | */ |
| 312 | 312 | function quete_document($id_document, $serveur = '') { |
| 313 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 313 | + return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', [], '', '', $serveur); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | * @return array|bool|null |
| 322 | 322 | */ |
| 323 | 323 | function quete_meta($nom, $serveur) { |
| 324 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 324 | + return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -347,72 +347,72 @@ discard block |
||
| 347 | 347 | * Retourne soit un tableau, soit le chemin du fichier. |
| 348 | 348 | */ |
| 349 | 349 | function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag = false) { |
| 350 | - include_spip('base/objets'); |
|
| 351 | - $nom = strtolower($onoff); |
|
| 352 | - |
|
| 353 | - $cle_objet = id_table_objet($cle_objet); |
|
| 354 | - |
|
| 355 | - while (1) { |
|
| 356 | - $objet = objet_type($cle_objet); |
|
| 357 | - |
|
| 358 | - $on = quete_logo_objet($id, $objet, $nom); |
|
| 359 | - |
|
| 360 | - if ($on) { |
|
| 361 | - if ($flag) { |
|
| 362 | - return $on['fichier']; |
|
| 363 | - } else { |
|
| 364 | - $taille = @spip_getimagesize($on['chemin']); |
|
| 365 | - |
|
| 366 | - // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 367 | - // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 368 | - // alors on ne cherche pas du tout le survol ici |
|
| 369 | - if ($onoff != 'ON') { |
|
| 370 | - $off = ''; |
|
| 371 | - } else { |
|
| 372 | - // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 373 | - $off = quete_logo_objet($id, $objet, 'off'); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - // on retourne une url du type IMG/artonXX?timestamp |
|
| 377 | - // qui permet de distinguer le changement de logo |
|
| 378 | - // et placer un expire sur le dossier IMG/ |
|
| 379 | - $res = [ |
|
| 380 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 381 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 382 | - (!$taille ? '' : (' ' . $taille[3])) |
|
| 383 | - ]; |
|
| 384 | - $res['src'] = $res[0]; |
|
| 385 | - $res['logo_on'] = $res[0]; |
|
| 386 | - $res['logo_off'] = $res[1]; |
|
| 387 | - $res['width'] = ($taille ? $taille[0] : ''); |
|
| 388 | - $res['height'] = ($taille ? $taille[1] : ''); |
|
| 389 | - $res['fichier'] = $on['fichier']; |
|
| 390 | - $res['titre'] = ($on['titre'] ?? ''); |
|
| 391 | - $res['descriptif'] = ($on['descriptif'] ?? ''); |
|
| 392 | - $res['credits'] = ($on['credits'] ?? ''); |
|
| 393 | - $res['alt'] = ($on['alt'] ?? ''); |
|
| 394 | - $res['id'] = ($on['id_document'] ?? 0); |
|
| 395 | - |
|
| 396 | - return $res; |
|
| 397 | - } |
|
| 398 | - } else { |
|
| 399 | - if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 400 | - return ''; |
|
| 401 | - } else { |
|
| 402 | - if ($id_rubrique) { |
|
| 403 | - $cle_objet = 'id_rubrique'; |
|
| 404 | - $id = $id_rubrique; |
|
| 405 | - $id_rubrique = 0; |
|
| 406 | - } else { |
|
| 407 | - if ($id and $cle_objet == 'id_rubrique') { |
|
| 408 | - $id = quete_parent($id); |
|
| 409 | - } else { |
|
| 410 | - return ''; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - } |
|
| 415 | - } |
|
| 350 | + include_spip('base/objets'); |
|
| 351 | + $nom = strtolower($onoff); |
|
| 352 | + |
|
| 353 | + $cle_objet = id_table_objet($cle_objet); |
|
| 354 | + |
|
| 355 | + while (1) { |
|
| 356 | + $objet = objet_type($cle_objet); |
|
| 357 | + |
|
| 358 | + $on = quete_logo_objet($id, $objet, $nom); |
|
| 359 | + |
|
| 360 | + if ($on) { |
|
| 361 | + if ($flag) { |
|
| 362 | + return $on['fichier']; |
|
| 363 | + } else { |
|
| 364 | + $taille = @spip_getimagesize($on['chemin']); |
|
| 365 | + |
|
| 366 | + // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 367 | + // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 368 | + // alors on ne cherche pas du tout le survol ici |
|
| 369 | + if ($onoff != 'ON') { |
|
| 370 | + $off = ''; |
|
| 371 | + } else { |
|
| 372 | + // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 373 | + $off = quete_logo_objet($id, $objet, 'off'); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + // on retourne une url du type IMG/artonXX?timestamp |
|
| 377 | + // qui permet de distinguer le changement de logo |
|
| 378 | + // et placer un expire sur le dossier IMG/ |
|
| 379 | + $res = [ |
|
| 380 | + $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 381 | + ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 382 | + (!$taille ? '' : (' ' . $taille[3])) |
|
| 383 | + ]; |
|
| 384 | + $res['src'] = $res[0]; |
|
| 385 | + $res['logo_on'] = $res[0]; |
|
| 386 | + $res['logo_off'] = $res[1]; |
|
| 387 | + $res['width'] = ($taille ? $taille[0] : ''); |
|
| 388 | + $res['height'] = ($taille ? $taille[1] : ''); |
|
| 389 | + $res['fichier'] = $on['fichier']; |
|
| 390 | + $res['titre'] = ($on['titre'] ?? ''); |
|
| 391 | + $res['descriptif'] = ($on['descriptif'] ?? ''); |
|
| 392 | + $res['credits'] = ($on['credits'] ?? ''); |
|
| 393 | + $res['alt'] = ($on['alt'] ?? ''); |
|
| 394 | + $res['id'] = ($on['id_document'] ?? 0); |
|
| 395 | + |
|
| 396 | + return $res; |
|
| 397 | + } |
|
| 398 | + } else { |
|
| 399 | + if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 400 | + return ''; |
|
| 401 | + } else { |
|
| 402 | + if ($id_rubrique) { |
|
| 403 | + $cle_objet = 'id_rubrique'; |
|
| 404 | + $id = $id_rubrique; |
|
| 405 | + $id_rubrique = 0; |
|
| 406 | + } else { |
|
| 407 | + if ($id and $cle_objet == 'id_rubrique') { |
|
| 408 | + $id = quete_parent($id); |
|
| 409 | + } else { |
|
| 410 | + return ''; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + } |
|
| 415 | + } |
|
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | /** |
@@ -427,43 +427,43 @@ discard block |
||
| 427 | 427 | * @return bool|array |
| 428 | 428 | **/ |
| 429 | 429 | function quete_logo_objet($id_objet, $objet, $mode) { |
| 430 | - static $chercher_logo; |
|
| 431 | - if (is_null($chercher_logo)) { |
|
| 432 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 433 | - } |
|
| 434 | - $cle_objet = id_table_objet($objet); |
|
| 435 | - |
|
| 436 | - // On cherche pas la méthode classique |
|
| 437 | - $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 438 | - |
|
| 439 | - // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 440 | - if (!empty($infos_logo)) { |
|
| 441 | - $infos = [ |
|
| 442 | - 'chemin' => $infos_logo[0], |
|
| 443 | - 'timestamp' => $infos_logo[4], |
|
| 444 | - 'id_document' => ($infos_logo[5]['id_document'] ?? ''), |
|
| 445 | - ]; |
|
| 446 | - foreach (['fichier', 'titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 447 | - $infos[$champ] = ($infos_logo[5][$champ] ?? ''); |
|
| 448 | - } |
|
| 449 | - $infos_logo = $infos; |
|
| 450 | - } |
|
| 451 | - |
|
| 452 | - // On passe cette recherche de logo dans un pipeline |
|
| 453 | - $infos_logo = pipeline( |
|
| 454 | - 'quete_logo_objet', |
|
| 455 | - [ |
|
| 456 | - 'args' => [ |
|
| 457 | - 'id_objet' => $id_objet, |
|
| 458 | - 'objet' => $objet, |
|
| 459 | - 'cle_objet' => $cle_objet, |
|
| 460 | - 'mode' => $mode, |
|
| 461 | - ], |
|
| 462 | - 'data' => $infos_logo, |
|
| 463 | - ] |
|
| 464 | - ); |
|
| 465 | - |
|
| 466 | - return $infos_logo; |
|
| 430 | + static $chercher_logo; |
|
| 431 | + if (is_null($chercher_logo)) { |
|
| 432 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 433 | + } |
|
| 434 | + $cle_objet = id_table_objet($objet); |
|
| 435 | + |
|
| 436 | + // On cherche pas la méthode classique |
|
| 437 | + $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 438 | + |
|
| 439 | + // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 440 | + if (!empty($infos_logo)) { |
|
| 441 | + $infos = [ |
|
| 442 | + 'chemin' => $infos_logo[0], |
|
| 443 | + 'timestamp' => $infos_logo[4], |
|
| 444 | + 'id_document' => ($infos_logo[5]['id_document'] ?? ''), |
|
| 445 | + ]; |
|
| 446 | + foreach (['fichier', 'titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 447 | + $infos[$champ] = ($infos_logo[5][$champ] ?? ''); |
|
| 448 | + } |
|
| 449 | + $infos_logo = $infos; |
|
| 450 | + } |
|
| 451 | + |
|
| 452 | + // On passe cette recherche de logo dans un pipeline |
|
| 453 | + $infos_logo = pipeline( |
|
| 454 | + 'quete_logo_objet', |
|
| 455 | + [ |
|
| 456 | + 'args' => [ |
|
| 457 | + 'id_objet' => $id_objet, |
|
| 458 | + 'objet' => $objet, |
|
| 459 | + 'cle_objet' => $cle_objet, |
|
| 460 | + 'mode' => $mode, |
|
| 461 | + ], |
|
| 462 | + 'data' => $infos_logo, |
|
| 463 | + ] |
|
| 464 | + ); |
|
| 465 | + |
|
| 466 | + return $infos_logo; |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | /** |
@@ -476,25 +476,25 @@ discard block |
||
| 476 | 476 | * @return bool|string |
| 477 | 477 | */ |
| 478 | 478 | function quete_logo_file($row, $connect = null) { |
| 479 | - include_spip('inc/documents'); |
|
| 480 | - $logo = vignette_logo_document($row, $connect); |
|
| 481 | - if (!$logo) { |
|
| 482 | - $logo = image_du_document($row, $connect); |
|
| 483 | - } |
|
| 484 | - if (!$logo) { |
|
| 485 | - $f = charger_fonction('vignette', 'inc'); |
|
| 486 | - $logo = $f($row['extension'], false); |
|
| 487 | - } |
|
| 488 | - // si c'est une vignette type doc, la renvoyer direct |
|
| 489 | - if ( |
|
| 490 | - strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 491 | - or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 492 | - or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 493 | - ) { |
|
| 494 | - return $logo; |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - return get_spip_doc($logo); |
|
| 479 | + include_spip('inc/documents'); |
|
| 480 | + $logo = vignette_logo_document($row, $connect); |
|
| 481 | + if (!$logo) { |
|
| 482 | + $logo = image_du_document($row, $connect); |
|
| 483 | + } |
|
| 484 | + if (!$logo) { |
|
| 485 | + $f = charger_fonction('vignette', 'inc'); |
|
| 486 | + $logo = $f($row['extension'], false); |
|
| 487 | + } |
|
| 488 | + // si c'est une vignette type doc, la renvoyer direct |
|
| 489 | + if ( |
|
| 490 | + strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 491 | + or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 492 | + or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 493 | + ) { |
|
| 494 | + return $logo; |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + return get_spip_doc($logo); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -522,20 +522,20 @@ discard block |
||
| 522 | 522 | */ |
| 523 | 523 | function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, string $connect = '') { |
| 524 | 524 | |
| 525 | - include_spip('inc/documents'); |
|
| 526 | - $logo = ''; |
|
| 527 | - if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 528 | - $logo = vignette_logo_document($row, $connect); |
|
| 529 | - } |
|
| 530 | - // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 531 | - if ($mode_logo == 'vignette' and !$logo) { |
|
| 532 | - return ''; |
|
| 533 | - } |
|
| 534 | - if ($mode_logo == 'icone') { |
|
| 535 | - $row['fichier'] = ''; |
|
| 536 | - } |
|
| 537 | - |
|
| 538 | - return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 525 | + include_spip('inc/documents'); |
|
| 526 | + $logo = ''; |
|
| 527 | + if (!in_array($mode_logo, ['icone', 'apercu'])) { |
|
| 528 | + $logo = vignette_logo_document($row, $connect); |
|
| 529 | + } |
|
| 530 | + // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 531 | + if ($mode_logo == 'vignette' and !$logo) { |
|
| 532 | + return ''; |
|
| 533 | + } |
|
| 534 | + if ($mode_logo == 'icone') { |
|
| 535 | + $row['fichier'] = ''; |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | /** |
@@ -547,26 +547,26 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | function quete_html_logo($logo, $align, $lien) { |
| 549 | 549 | |
| 550 | - if (!is_array($logo)) { |
|
| 551 | - return ''; |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - $contexte = []; |
|
| 555 | - foreach ($logo as $k => $v) { |
|
| 556 | - if (!is_numeric($k)) { |
|
| 557 | - $contexte[$k] = $v; |
|
| 558 | - } |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - foreach (['titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 562 | - if (!empty($contexte[$champ])) { |
|
| 563 | - $contexte[$champ] = appliquer_traitement_champ($contexte[$champ] , $champ, 'document'); |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - $contexte['align'] = $align; |
|
| 568 | - $contexte['lien'] = $lien; |
|
| 569 | - return recuperer_fond('modeles/logo', $contexte); |
|
| 550 | + if (!is_array($logo)) { |
|
| 551 | + return ''; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + $contexte = []; |
|
| 555 | + foreach ($logo as $k => $v) { |
|
| 556 | + if (!is_numeric($k)) { |
|
| 557 | + $contexte[$k] = $v; |
|
| 558 | + } |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + foreach (['titre', 'descriptif', 'credits', 'alt'] as $champ) { |
|
| 562 | + if (!empty($contexte[$champ])) { |
|
| 563 | + $contexte[$champ] = appliquer_traitement_champ($contexte[$champ] , $champ, 'document'); |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + $contexte['align'] = $align; |
|
| 568 | + $contexte['lien'] = $lien; |
|
| 569 | + return recuperer_fond('modeles/logo', $contexte); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | /** |
@@ -580,14 +580,14 @@ discard block |
||
| 580 | 580 | * @return string|false |
| 581 | 581 | */ |
| 582 | 582 | function document_spip_externe($fichier, $connect) { |
| 583 | - if ($connect) { |
|
| 584 | - $site = quete_meta('adresse_site', $connect); |
|
| 585 | - if ($site) { |
|
| 586 | - $dir = quete_meta('dir_img', $connect); |
|
| 587 | - return "$site/$dir$fichier"; |
|
| 588 | - } |
|
| 589 | - } |
|
| 590 | - return false; |
|
| 583 | + if ($connect) { |
|
| 584 | + $site = quete_meta('adresse_site', $connect); |
|
| 585 | + if ($site) { |
|
| 586 | + $dir = quete_meta('dir_img', $connect); |
|
| 587 | + return "$site/$dir$fichier"; |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | + return false; |
|
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | /** |
@@ -601,23 +601,23 @@ discard block |
||
| 601 | 601 | */ |
| 602 | 602 | function vignette_logo_document($row, string $connect = '') { |
| 603 | 603 | |
| 604 | - if (!$row or empty($row['id_vignette'])) { |
|
| 605 | - return ''; |
|
| 606 | - } |
|
| 607 | - $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 608 | - if ($url = document_spip_externe($fichier, $connect)) { |
|
| 609 | - return $url; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - $f = get_spip_doc($fichier); |
|
| 613 | - if ($f and @file_exists($f)) { |
|
| 614 | - return $f; |
|
| 615 | - } |
|
| 616 | - if ($row['mode'] !== 'vignette') { |
|
| 617 | - return ''; |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 604 | + if (!$row or empty($row['id_vignette'])) { |
|
| 605 | + return ''; |
|
| 606 | + } |
|
| 607 | + $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 608 | + if ($url = document_spip_externe($fichier, $connect)) { |
|
| 609 | + return $url; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + $f = get_spip_doc($fichier); |
|
| 613 | + if ($f and @file_exists($f)) { |
|
| 614 | + return $f; |
|
| 615 | + } |
|
| 616 | + if ($row['mode'] !== 'vignette') { |
|
| 617 | + return ''; |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + return generer_objet_url($row['id_document'], 'document', '', '', null, '', $connect); |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | /** |
@@ -633,66 +633,66 @@ discard block |
||
| 633 | 633 | * @return bool|string |
| 634 | 634 | */ |
| 635 | 635 | function calcul_exposer($id, $prim, $reference, $parent, $type, string $connect = '') { |
| 636 | - static $exposer = []; |
|
| 637 | - |
|
| 638 | - // Que faut-il exposer ? Tous les elements de $reference |
|
| 639 | - // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 640 | - // qu'une fois (par squelette) et on conserve le resultat |
|
| 641 | - // en static. |
|
| 642 | - if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 643 | - $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 644 | - // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 645 | - // il n'est donc pas utile |
|
| 646 | - $parent = 0; |
|
| 647 | - if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 648 | - $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 649 | - if (isset($enfants[$type])) { |
|
| 650 | - foreach ($enfants[$type] as $t) { |
|
| 651 | - if ( |
|
| 652 | - isset($reference[$t]) |
|
| 653 | - // cas de la reference donnee dynamiquement par la pagination |
|
| 654 | - or isset($reference["@$t"]) |
|
| 655 | - ) { |
|
| 656 | - $type = $t; |
|
| 657 | - $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 658 | - continue; |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - } |
|
| 663 | - $exposer[$m][$type] = []; |
|
| 664 | - if ($principal) { |
|
| 665 | - $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 666 | - foreach ($principaux as $principal) { |
|
| 667 | - $exposer[$m][$type][$principal] = true; |
|
| 668 | - if ($type == 'id_mot') { |
|
| 669 | - if (!$parent) { |
|
| 670 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 671 | - } |
|
| 672 | - if ($parent) { |
|
| 673 | - $exposer[$m]['id_groupe'][$parent] = true; |
|
| 674 | - } |
|
| 675 | - } else { |
|
| 676 | - if ($type != 'id_groupe') { |
|
| 677 | - if (!$parent) { |
|
| 678 | - if ($type == 'id_rubrique') { |
|
| 679 | - $parent = $principal; |
|
| 680 | - } |
|
| 681 | - if ($type == 'id_article') { |
|
| 682 | - $parent = quete_rubrique($principal, $connect); |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - do { |
|
| 686 | - $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 687 | - } while ($parent = quete_parent($parent, $connect)); |
|
| 688 | - } |
|
| 689 | - } |
|
| 690 | - } |
|
| 691 | - } |
|
| 692 | - } |
|
| 693 | - |
|
| 694 | - // And the winner is... |
|
| 695 | - return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 636 | + static $exposer = []; |
|
| 637 | + |
|
| 638 | + // Que faut-il exposer ? Tous les elements de $reference |
|
| 639 | + // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 640 | + // qu'une fois (par squelette) et on conserve le resultat |
|
| 641 | + // en static. |
|
| 642 | + if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 643 | + $principal = $reference[$type] ?? $reference["@$type"] ?? ''; |
|
| 644 | + // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 645 | + // il n'est donc pas utile |
|
| 646 | + $parent = 0; |
|
| 647 | + if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 648 | + $enfants = ['id_rubrique' => ['id_article'], 'id_groupe' => ['id_mot']]; |
|
| 649 | + if (isset($enfants[$type])) { |
|
| 650 | + foreach ($enfants[$type] as $t) { |
|
| 651 | + if ( |
|
| 652 | + isset($reference[$t]) |
|
| 653 | + // cas de la reference donnee dynamiquement par la pagination |
|
| 654 | + or isset($reference["@$t"]) |
|
| 655 | + ) { |
|
| 656 | + $type = $t; |
|
| 657 | + $principal = $reference[$type] ?? $reference["@$type"]; |
|
| 658 | + continue; |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + } |
|
| 663 | + $exposer[$m][$type] = []; |
|
| 664 | + if ($principal) { |
|
| 665 | + $principaux = is_array($principal) ? $principal : [$principal]; |
|
| 666 | + foreach ($principaux as $principal) { |
|
| 667 | + $exposer[$m][$type][$principal] = true; |
|
| 668 | + if ($type == 'id_mot') { |
|
| 669 | + if (!$parent) { |
|
| 670 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 671 | + } |
|
| 672 | + if ($parent) { |
|
| 673 | + $exposer[$m]['id_groupe'][$parent] = true; |
|
| 674 | + } |
|
| 675 | + } else { |
|
| 676 | + if ($type != 'id_groupe') { |
|
| 677 | + if (!$parent) { |
|
| 678 | + if ($type == 'id_rubrique') { |
|
| 679 | + $parent = $principal; |
|
| 680 | + } |
|
| 681 | + if ($type == 'id_article') { |
|
| 682 | + $parent = quete_rubrique($principal, $connect); |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + do { |
|
| 686 | + $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 687 | + } while ($parent = quete_parent($parent, $connect)); |
|
| 688 | + } |
|
| 689 | + } |
|
| 690 | + } |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + |
|
| 694 | + // And the winner is... |
|
| 695 | + return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 696 | 696 | } |
| 697 | 697 | |
| 698 | 698 | /** |
@@ -707,23 +707,23 @@ discard block |
||
| 707 | 707 | * @return int |
| 708 | 708 | */ |
| 709 | 709 | function quete_debut_pagination($primary, $valeur, $pas, $iter) { |
| 710 | - // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 711 | - // ou composee, mais verifions |
|
| 712 | - if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 713 | - return 0; |
|
| 714 | - } |
|
| 715 | - |
|
| 716 | - $pos = 0; |
|
| 717 | - while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 718 | - $pos++; |
|
| 719 | - } |
|
| 720 | - // si on a pas trouve |
|
| 721 | - if (!$row or $row[$primary] != $valeur) { |
|
| 722 | - return 0; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - // sinon, calculer le bon numero de page |
|
| 726 | - return floor($pos / $pas) * $pas; |
|
| 710 | + // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 711 | + // ou composee, mais verifions |
|
| 712 | + if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 713 | + return 0; |
|
| 714 | + } |
|
| 715 | + |
|
| 716 | + $pos = 0; |
|
| 717 | + while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 718 | + $pos++; |
|
| 719 | + } |
|
| 720 | + // si on a pas trouve |
|
| 721 | + if (!$row or $row[$primary] != $valeur) { |
|
| 722 | + return 0; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + // sinon, calculer le bon numero de page |
|
| 726 | + return floor($pos / $pas) * $pas; |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | /** |
@@ -734,11 +734,11 @@ discard block |
||
| 734 | 734 | * @return boolean |
| 735 | 735 | */ |
| 736 | 736 | function is_whereable($value): bool { |
| 737 | - if (is_array($value) && count($value)) { |
|
| 738 | - return true; |
|
| 739 | - } |
|
| 740 | - if (is_scalar($value) && strlen($value)) { |
|
| 741 | - return true; |
|
| 742 | - } |
|
| 743 | - return false; |
|
| 737 | + if (is_array($value) && count($value)) { |
|
| 738 | + return true; |
|
| 739 | + } |
|
| 740 | + if (is_scalar($value) && strlen($value)) { |
|
| 741 | + return true; |
|
| 742 | + } |
|
| 743 | + return false; |
|
| 744 | 744 | } |
@@ -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 | |
@@ -49,38 +49,38 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | function balise_ID_LOGO__dist($p) { |
| 51 | 51 | |
| 52 | - preg_match(',^ID_LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 53 | - $type = strtolower($regs[1]); |
|
| 54 | - $suite_logo = $regs[2]; |
|
| 55 | - |
|
| 56 | - // cas de #ID_LOGO_SITE_SPIP |
|
| 57 | - if ($type == 'site_spip') { |
|
| 58 | - $type = 'site'; |
|
| 59 | - $_id_objet = "\"'0'\""; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - $id_objet = id_table_objet($type); |
|
| 63 | - if (!isset($_id_objet)) { |
|
| 64 | - $_id_objet = champ_sql($id_objet, $p); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 68 | - if ($type == 'document') { |
|
| 69 | - $qconnect = _q($connect); |
|
| 70 | - $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 71 | - $code = "table_valeur($doc, 'id_vignette')"; |
|
| 72 | - } elseif ($connect) { |
|
| 73 | - $code = "''"; |
|
| 74 | - spip_log('Les logos distants ne sont pas prevus'); |
|
| 75 | - } else { |
|
| 76 | - $champ_logo = 'id'; |
|
| 77 | - $code = generer_code_logo($id_objet, $_id_objet, $type, '', "''", $p, $suite_logo, $champ_logo); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - $p->code = $code; |
|
| 81 | - $p->interdire_scripts = false; |
|
| 82 | - |
|
| 83 | - return $p; |
|
| 52 | + preg_match(',^ID_LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 53 | + $type = strtolower($regs[1]); |
|
| 54 | + $suite_logo = $regs[2]; |
|
| 55 | + |
|
| 56 | + // cas de #ID_LOGO_SITE_SPIP |
|
| 57 | + if ($type == 'site_spip') { |
|
| 58 | + $type = 'site'; |
|
| 59 | + $_id_objet = "\"'0'\""; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + $id_objet = id_table_objet($type); |
|
| 63 | + if (!isset($_id_objet)) { |
|
| 64 | + $_id_objet = champ_sql($id_objet, $p); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 68 | + if ($type == 'document') { |
|
| 69 | + $qconnect = _q($connect); |
|
| 70 | + $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 71 | + $code = "table_valeur($doc, 'id_vignette')"; |
|
| 72 | + } elseif ($connect) { |
|
| 73 | + $code = "''"; |
|
| 74 | + spip_log('Les logos distants ne sont pas prevus'); |
|
| 75 | + } else { |
|
| 76 | + $champ_logo = 'id'; |
|
| 77 | + $code = generer_code_logo($id_objet, $_id_objet, $type, '', "''", $p, $suite_logo, $champ_logo); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + $p->code = $code; |
|
| 81 | + $p->interdire_scripts = false; |
|
| 82 | + |
|
| 83 | + return $p; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -109,28 +109,28 @@ discard block |
||
| 109 | 109 | * Code compilé retournant le chemin du logo ou le code HTML du logo. |
| 110 | 110 | **/ |
| 111 | 111 | function generer_code_logo($id_objet, $_id_objet, $type, $align, $_lien, $p, $suite, string $champ = ''): string { |
| 112 | - $onoff = 'ON'; |
|
| 113 | - $_id_rubrique = "''"; |
|
| 112 | + $onoff = 'ON'; |
|
| 113 | + $_id_rubrique = "''"; |
|
| 114 | 114 | |
| 115 | - if ($type === 'rubrique') { |
|
| 116 | - $_id_rubrique = "quete_parent($_id_objet)"; |
|
| 117 | - } |
|
| 115 | + if ($type === 'rubrique') { |
|
| 116 | + $_id_rubrique = "quete_parent($_id_objet)"; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - if ($suite === '_SURVOL') { |
|
| 120 | - $onoff = 'off'; |
|
| 121 | - } elseif ($suite === '_NORMAL') { |
|
| 122 | - $onoff = 'on'; |
|
| 123 | - } elseif ($suite === '_RUBRIQUE') { |
|
| 124 | - $_id_rubrique = champ_sql('id_rubrique', $p); |
|
| 125 | - } |
|
| 119 | + if ($suite === '_SURVOL') { |
|
| 120 | + $onoff = 'off'; |
|
| 121 | + } elseif ($suite === '_NORMAL') { |
|
| 122 | + $onoff = 'on'; |
|
| 123 | + } elseif ($suite === '_RUBRIQUE') { |
|
| 124 | + $_id_rubrique = champ_sql('id_rubrique', $p); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - $code = "quete_logo('$id_objet', '$onoff', $_id_objet, $_id_rubrique)"; |
|
| 127 | + $code = "quete_logo('$id_objet', '$onoff', $_id_objet, $_id_rubrique)"; |
|
| 128 | 128 | |
| 129 | - if ($champ) { |
|
| 130 | - return "table_valeur($code, '".addslashes($champ)."')"; |
|
| 131 | - } |
|
| 129 | + if ($champ) { |
|
| 130 | + return "table_valeur($code, '".addslashes($champ)."')"; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - $align = preg_replace(',\W,', '', $align); |
|
| 133 | + $align = preg_replace(',\W,', '', $align); |
|
| 134 | 134 | |
| 135 | - return "quete_html_logo($code, '$align', " . ($_lien ?: "''") . ')'; |
|
| 135 | + return "quete_html_logo($code, '$align', " . ($_lien ?: "''") . ')'; |
|
| 136 | 136 | } |
@@ -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 | |
@@ -56,88 +56,88 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | function balise_LOGO__dist($p) { |
| 58 | 58 | |
| 59 | - preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 60 | - $type = strtolower($regs[1]); |
|
| 61 | - $suite_logo = $regs[2]; |
|
| 62 | - |
|
| 63 | - // cas de #LOGO_SITE_SPIP |
|
| 64 | - if ($type == 'site_spip') { |
|
| 65 | - $type = 'site'; |
|
| 66 | - $_id_objet = "\"'0'\""; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $id_objet = id_table_objet($type); |
|
| 70 | - if (!isset($_id_objet)) { |
|
| 71 | - $_id_objet = champ_sql($id_objet, $p); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 75 | - $coord = []; |
|
| 76 | - $align = $lien = ''; |
|
| 77 | - $mode_logo = ''; |
|
| 78 | - |
|
| 79 | - if ($p->param and !$p->param[0][0]) { |
|
| 80 | - $params = $p->param[0]; |
|
| 81 | - array_shift($params); |
|
| 82 | - foreach ($params as $a) { |
|
| 83 | - if ($a[0]->type === 'texte') { |
|
| 84 | - $n = $a[0]->texte; |
|
| 85 | - if (is_numeric($n)) { |
|
| 86 | - $coord[] = $n; |
|
| 87 | - } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 88 | - $align = $n; |
|
| 89 | - } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 90 | - $mode_logo = $n; |
|
| 91 | - } |
|
| 92 | - } else { |
|
| 93 | - $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $coord_x = !$coord ? 0 : intval(array_shift($coord)); |
|
| 99 | - $coord_y = !$coord ? 0 : intval(array_shift($coord)); |
|
| 100 | - |
|
| 101 | - if ($p->etoile === '*') { |
|
| 102 | - include_spip('balise/url_'); |
|
| 103 | - $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 107 | - if ($type == 'document') { |
|
| 108 | - $qconnect = _q($connect); |
|
| 109 | - $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 110 | - if ($fichier) { |
|
| 111 | - $code = "quete_logo_file($doc, $qconnect)"; |
|
| 112 | - } else { |
|
| 113 | - $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 114 | - } |
|
| 115 | - // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 116 | - if ($p->descr['documents']) { |
|
| 117 | - $code = '(($doublons["documents"] .= ",". ' |
|
| 118 | - . $_id_objet |
|
| 119 | - . ") ? $code : '')"; |
|
| 120 | - } |
|
| 121 | - } elseif ($connect) { |
|
| 122 | - $code = "''"; |
|
| 123 | - spip_log('Les logos distants ne sont pas prevus'); |
|
| 124 | - } else { |
|
| 125 | - // pour generer_code_logo |
|
| 126 | - include_spip('balise/id_logo_'); |
|
| 127 | - $champ_logo = ''; |
|
| 128 | - if ($fichier) { |
|
| 129 | - $champ_logo = 'fichier'; |
|
| 130 | - } |
|
| 131 | - $code = generer_code_logo($id_objet, $_id_objet, $type, $align, $lien, $p, $suite_logo, $champ_logo); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 135 | - if ($coord_x or $coord_y) { |
|
| 136 | - $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - $p->code = $code; |
|
| 140 | - $p->interdire_scripts = false; |
|
| 141 | - |
|
| 142 | - return $p; |
|
| 59 | + preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
| 60 | + $type = strtolower($regs[1]); |
|
| 61 | + $suite_logo = $regs[2]; |
|
| 62 | + |
|
| 63 | + // cas de #LOGO_SITE_SPIP |
|
| 64 | + if ($type == 'site_spip') { |
|
| 65 | + $type = 'site'; |
|
| 66 | + $_id_objet = "\"'0'\""; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $id_objet = id_table_objet($type); |
|
| 70 | + if (!isset($_id_objet)) { |
|
| 71 | + $_id_objet = champ_sql($id_objet, $p); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + $fichier = ($p->etoile === '**') ? -1 : 0; |
|
| 75 | + $coord = []; |
|
| 76 | + $align = $lien = ''; |
|
| 77 | + $mode_logo = ''; |
|
| 78 | + |
|
| 79 | + if ($p->param and !$p->param[0][0]) { |
|
| 80 | + $params = $p->param[0]; |
|
| 81 | + array_shift($params); |
|
| 82 | + foreach ($params as $a) { |
|
| 83 | + if ($a[0]->type === 'texte') { |
|
| 84 | + $n = $a[0]->texte; |
|
| 85 | + if (is_numeric($n)) { |
|
| 86 | + $coord[] = $n; |
|
| 87 | + } elseif (in_array($n, ['top', 'left', 'right', 'center', 'bottom'])) { |
|
| 88 | + $align = $n; |
|
| 89 | + } elseif (in_array($n, ['auto', 'icone', 'apercu', 'vignette'])) { |
|
| 90 | + $mode_logo = $n; |
|
| 91 | + } |
|
| 92 | + } else { |
|
| 93 | + $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $coord_x = !$coord ? 0 : intval(array_shift($coord)); |
|
| 99 | + $coord_y = !$coord ? 0 : intval(array_shift($coord)); |
|
| 100 | + |
|
| 101 | + if ($p->etoile === '*') { |
|
| 102 | + include_spip('balise/url_'); |
|
| 103 | + $lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
| 107 | + if ($type == 'document') { |
|
| 108 | + $qconnect = _q($connect); |
|
| 109 | + $doc = "quete_document($_id_objet, $qconnect)"; |
|
| 110 | + if ($fichier) { |
|
| 111 | + $code = "quete_logo_file($doc, $qconnect)"; |
|
| 112 | + } else { |
|
| 113 | + $code = "quete_logo_document($doc, " . ($lien ?: "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 114 | + } |
|
| 115 | + // (x=non-faux ? y : '') pour affecter x en retournant y |
|
| 116 | + if ($p->descr['documents']) { |
|
| 117 | + $code = '(($doublons["documents"] .= ",". ' |
|
| 118 | + . $_id_objet |
|
| 119 | + . ") ? $code : '')"; |
|
| 120 | + } |
|
| 121 | + } elseif ($connect) { |
|
| 122 | + $code = "''"; |
|
| 123 | + spip_log('Les logos distants ne sont pas prevus'); |
|
| 124 | + } else { |
|
| 125 | + // pour generer_code_logo |
|
| 126 | + include_spip('balise/id_logo_'); |
|
| 127 | + $champ_logo = ''; |
|
| 128 | + if ($fichier) { |
|
| 129 | + $champ_logo = 'fichier'; |
|
| 130 | + } |
|
| 131 | + $code = generer_code_logo($id_objet, $_id_objet, $type, $align, $lien, $p, $suite_logo, $champ_logo); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
| 135 | + if ($coord_x or $coord_y) { |
|
| 136 | + $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + $p->code = $code; |
|
| 140 | + $p->interdire_scripts = false; |
|
| 141 | + |
|
| 142 | + return $p; |
|
| 143 | 143 | } |