@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * Retourne l'URL de redirection d'un article virtuel, seulement si il est publié |
| 30 | 30 | * |
| 31 | - * @param $id_article |
|
| 32 | - * @param $connect |
|
| 33 | - * @return array|bool|null |
|
| 31 | + * @param integer $id_article |
|
| 32 | + * @param string $connect |
|
| 33 | + * @return string |
|
| 34 | 34 | */ |
| 35 | 35 | function quete_virtuel($id_article, $connect) { |
| 36 | 36 | return sql_getfetsel( |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @uses quete_parent_lang() |
| 123 | 123 | * |
| 124 | 124 | * @param int $id_article |
| 125 | - * @param $serveur |
|
| 125 | + * @param string $serveur |
|
| 126 | 126 | * @return int |
| 127 | 127 | */ |
| 128 | 128 | function quete_rubrique($id_article, $serveur) { |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * |
| 294 | 294 | * @param int $id_document |
| 295 | 295 | * @param string $serveur |
| 296 | - * @return array|bool|null |
|
| 296 | + * @return string |
|
| 297 | 297 | */ |
| 298 | 298 | function quete_fichier($id_document, $serveur = '') { |
| 299 | 299 | return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | return sql_getfetsel( |
| 37 | 37 | 'virtuel', |
| 38 | 38 | 'spip_articles', |
| 39 | - array('id_article=' . intval($id_article), "statut='publie'"), |
|
| 39 | + array('id_article='.intval($id_article), "statut='publie'"), |
|
| 40 | 40 | '', |
| 41 | 41 | '', |
| 42 | 42 | '', |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $cache_quete[$connect][$table][$id] = sql_fetsel( |
| 79 | 79 | $cache_quete[$connect][$table]['_select'], |
| 80 | 80 | $table, |
| 81 | - $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 81 | + $cache_quete[$connect][$table]['_id'].'='.intval($id), |
|
| 82 | 82 | '', |
| 83 | 83 | '', |
| 84 | 84 | '', |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | return |
| 172 | 172 | (isset($GLOBALS['meta']['date_prochain_postdate']) |
| 173 | 173 | and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
| 174 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 174 | + ? "$champ_date<".sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 175 | 175 | : '1=1'; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | and $id_table = reset($objet) |
| 230 | 230 | and $objet = objet_type($id_table) |
| 231 | 231 | ) { |
| 232 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 232 | + $w = "$mstatut<>".sql_quote($v); |
|
| 233 | 233 | |
| 234 | 234 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 235 | 235 | // sinon l’auteur en session |
@@ -243,22 +243,22 @@ discard block |
||
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 246 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 246 | + if (!autoriser('previsualiser'.$v, $objet, '', $id_auteur)) { |
|
| 247 | 247 | // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
| 248 | 248 | if (!$id_auteur) { |
| 249 | 249 | $where[] = $w; |
| 250 | 250 | } else { |
| 251 | 251 | $primary = id_table_objet($objet); |
| 252 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 252 | + $where[] = "($w OR $id_table.$primary IN (".sql_get_select( |
|
| 253 | 253 | 'ssss.id_objet', |
| 254 | 254 | 'spip_auteurs_liens AS ssss', |
| 255 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 255 | + 'ssss.objet='.sql_quote($objet).' AND ssss.id_auteur='.intval($id_auteur), |
|
| 256 | 256 | '', |
| 257 | 257 | '', |
| 258 | 258 | '', |
| 259 | 259 | '', |
| 260 | 260 | $serveur |
| 261 | - ) . '))'; |
|
| 261 | + ).'))'; |
|
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | } // ignorer ce statut si on ne sait pas comment le filtrer |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @return array|bool|null |
| 297 | 297 | */ |
| 298 | 298 | function quete_fichier($id_document, $serveur = '') { |
| 299 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 299 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document='.intval($id_document)), '', array(), '', '', $serveur); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | * @return array|bool |
| 308 | 308 | */ |
| 309 | 309 | function quete_document($id_document, $serveur = '') { |
| 310 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 310 | + return sql_fetsel('*', 'spip_documents', ('id_document='.intval($id_document)), '', array(), '', '', $serveur); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @return array|bool|null |
| 319 | 319 | */ |
| 320 | 320 | function quete_meta($nom, $serveur) { |
| 321 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 321 | + return sql_getfetsel('valeur', 'spip_meta', 'nom='.sql_quote($nom), '', '', '', '', $serveur); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -372,9 +372,9 @@ discard block |
||
| 372 | 372 | // qui permet de distinguer le changement de logo |
| 373 | 373 | // et placer un expire sur le dossier IMG/ |
| 374 | 374 | $res = array( |
| 375 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 376 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 377 | - (!$taille ? '' : (' ' . $taille[3])) |
|
| 375 | + $on['chemin'].($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 376 | + ($off ? $off['chemin'].($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 377 | + (!$taille ? '' : (' '.$taille[3])) |
|
| 378 | 378 | ); |
| 379 | 379 | $res['src'] = $res[0]; |
| 380 | 380 | $res['logo_on'] = $res[0]; |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | // si c'est une vignette type doc, la renvoyer direct |
| 471 | 471 | if (strcmp($logo, _DIR_PLUGINS) == 0 |
| 472 | 472 | or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
| 473 | - or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 473 | + or strcmp($logo, _DIR_RACINE.'prive/') == 0 |
|
| 474 | 474 | ) { |
| 475 | 475 | return $logo; |
| 476 | 476 | } |
@@ -589,8 +589,7 @@ discard block |
||
| 589 | 589 | // qu'une fois (par squelette) et on conserve le resultat |
| 590 | 590 | // en static. |
| 591 | 591 | if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
| 592 | - $principal = isset($reference[$type]) ? $reference[$type] : |
|
| 593 | - // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 592 | + $principal = isset($reference[$type]) ? $reference[$type] : // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 594 | 593 | // et donne la reference dynamique @type=xx dans le contexte |
| 595 | 594 | (isset($reference["@$type"]) ? $reference["@$type"] : ''); |
| 596 | 595 | // le parent fournit en argument est le parent de $id, pas celui de $principal |
@@ -618,7 +617,7 @@ discard block |
||
| 618 | 617 | $exposer[$m][$type][$principal] = true; |
| 619 | 618 | if ($type == 'id_mot') { |
| 620 | 619 | if (!$parent) { |
| 621 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 620 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot='.intval($principal), '', '', '', '', $connect); |
|
| 622 | 621 | } |
| 623 | 622 | if ($parent) { |
| 624 | 623 | $exposer[$m]['id_groupe'][$parent] = true; |
@@ -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 | - array('id_article=' . intval($id_article), "statut='publie'"), |
|
| 40 | - '', |
|
| 41 | - '', |
|
| 42 | - '', |
|
| 43 | - '', |
|
| 44 | - $connect |
|
| 45 | - ); |
|
| 36 | + return sql_getfetsel( |
|
| 37 | + 'virtuel', |
|
| 38 | + 'spip_articles', |
|
| 39 | + array('id_article=' . intval($id_article), "statut='publie'"), |
|
| 40 | + '', |
|
| 41 | + '', |
|
| 42 | + '', |
|
| 43 | + '', |
|
| 44 | + $connect |
|
| 45 | + ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -57,38 +57,38 @@ discard block |
||
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | 59 | function quete_parent_lang($table, $id, $connect = '') { |
| 60 | - static $cache_quete = array(); |
|
| 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 (!$desc = $trouver_table($table, |
|
| 66 | - $connect) or !isset($desc['field']['id_rubrique']) |
|
| 67 | - ) { |
|
| 68 | - // pas de parent rubrique, on passe |
|
| 69 | - $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | - } else { |
|
| 71 | - $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | - $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | - $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | - $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | - $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | - $cache_quete[$connect][$table]['_select'], |
|
| 80 | - $table, |
|
| 81 | - $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 82 | - '', |
|
| 83 | - '', |
|
| 84 | - '', |
|
| 85 | - '', |
|
| 86 | - $connect |
|
| 87 | - ); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return isset($cache_quete[$connect][$table][$id]) ? $cache_quete[$connect][$table][$id] : null; |
|
| 60 | + static $cache_quete = array(); |
|
| 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 (!$desc = $trouver_table($table, |
|
| 66 | + $connect) or !isset($desc['field']['id_rubrique']) |
|
| 67 | + ) { |
|
| 68 | + // pas de parent rubrique, on passe |
|
| 69 | + $cache_quete[$connect][$table]['_select'] = false; |
|
| 70 | + } else { |
|
| 71 | + $select = ($table == 'spip_rubriques' ? 'id_parent' : 'id_rubrique'); |
|
| 72 | + $select .= isset($desc['field']['lang']) ? ', lang' : ''; |
|
| 73 | + $cache_quete[$connect][$table]['_select'] = $select; |
|
| 74 | + $cache_quete[$connect][$table]['_id'] = id_table_objet(objet_type($table)); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + if ($cache_quete[$connect][$table]['_select']) { |
|
| 78 | + $cache_quete[$connect][$table][$id] = sql_fetsel( |
|
| 79 | + $cache_quete[$connect][$table]['_select'], |
|
| 80 | + $table, |
|
| 81 | + $cache_quete[$connect][$table]['_id'] . '=' . intval($id), |
|
| 82 | + '', |
|
| 83 | + '', |
|
| 84 | + '', |
|
| 85 | + '', |
|
| 86 | + $connect |
|
| 87 | + ); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return isset($cache_quete[$connect][$table][$id]) ? $cache_quete[$connect][$table][$id] : null; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | * @return int |
| 106 | 106 | */ |
| 107 | 107 | function quete_parent($id_rubrique, $connect = '') { |
| 108 | - if (!$id_rubrique = intval($id_rubrique)) { |
|
| 109 | - return 0; |
|
| 110 | - } |
|
| 111 | - $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 108 | + if (!$id_rubrique = intval($id_rubrique)) { |
|
| 109 | + return 0; |
|
| 110 | + } |
|
| 111 | + $id_parent = quete_parent_lang('spip_rubriques', $id_rubrique, $connect); |
|
| 112 | 112 | |
| 113 | - return $id_parent['id_parent']; |
|
| 113 | + return $id_parent['id_parent']; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | * @return int |
| 127 | 127 | */ |
| 128 | 128 | function quete_rubrique($id_article, $serveur) { |
| 129 | - $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 129 | + $id_parent = quete_parent_lang('spip_articles', $id_article, $serveur); |
|
| 130 | 130 | |
| 131 | - return $id_parent['id_rubrique']; |
|
| 131 | + return $id_parent['id_rubrique']; |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
@@ -142,13 +142,13 @@ discard block |
||
| 142 | 142 | * @return int |
| 143 | 143 | */ |
| 144 | 144 | function quete_profondeur($id, $connect = '') { |
| 145 | - $n = 0; |
|
| 146 | - while ($id) { |
|
| 147 | - $n++; |
|
| 148 | - $id = quete_parent($id, $connect); |
|
| 149 | - } |
|
| 145 | + $n = 0; |
|
| 146 | + while ($id) { |
|
| 147 | + $n++; |
|
| 148 | + $id = quete_parent($id, $connect); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - return $n; |
|
| 151 | + return $n; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
@@ -164,15 +164,15 @@ discard block |
||
| 164 | 164 | * Morceau de la requête SQL testant la date |
| 165 | 165 | */ |
| 166 | 166 | function quete_condition_postdates($champ_date, $serveur = '', $ignore_previsu = false) { |
| 167 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 168 | - return '1=1'; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - return |
|
| 172 | - (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 173 | - and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 174 | - ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 175 | - : '1=1'; |
|
| 167 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 168 | + return '1=1'; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + return |
|
| 172 | + (isset($GLOBALS['meta']['date_prochain_postdate']) |
|
| 173 | + and $GLOBALS['meta']['date_prochain_postdate'] > time()) |
|
| 174 | + ? "$champ_date<" . sql_quote(date('Y-m-d H:i:s', $GLOBALS['meta']['date_prochain_postdate']), $serveur) |
|
| 175 | + : '1=1'; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -192,100 +192,100 @@ discard block |
||
| 192 | 192 | * @return array|string |
| 193 | 193 | */ |
| 194 | 194 | function quete_condition_statut($mstatut, $previsu, $publie, $serveur = '', $ignore_previsu = false) { |
| 195 | - static $cond = array(); |
|
| 196 | - $key = func_get_args(); |
|
| 197 | - $key = implode('-', $key); |
|
| 198 | - if (isset($cond[$key])) { |
|
| 199 | - return $cond[$key]; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - $liste_statuts = $publie; |
|
| 203 | - if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 204 | - $liste_statuts = $previsu; |
|
| 205 | - } |
|
| 206 | - $not = false; |
|
| 207 | - if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 208 | - $not = true; |
|
| 209 | - $liste_statuts = substr($liste_statuts, 1); |
|
| 210 | - } |
|
| 211 | - // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 212 | - if (!strlen($liste_statuts)) { |
|
| 213 | - return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - $liste_statuts = explode(',', $liste_statuts); |
|
| 217 | - $where = array(); |
|
| 218 | - foreach ($liste_statuts as $k => $v) { |
|
| 219 | - // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 220 | - // a ceux de l'auteur identifie |
|
| 221 | - if (strpos($v, '/') !== false) { |
|
| 222 | - $v = explode('/', $v); |
|
| 223 | - $filtre = end($v); |
|
| 224 | - $v = reset($v); |
|
| 225 | - $v = preg_replace(',\W,', '', $v); |
|
| 226 | - if ($filtre == 'auteur' |
|
| 227 | - and (strpos($mstatut, '.') !== false) |
|
| 228 | - and $objet = explode('.', $mstatut) |
|
| 229 | - and $id_table = reset($objet) |
|
| 230 | - and $objet = objet_type($id_table) |
|
| 231 | - ) { |
|
| 232 | - $w = "$mstatut<>" . sql_quote($v); |
|
| 233 | - |
|
| 234 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 235 | - // sinon l’auteur en session |
|
| 236 | - include_spip('inc/securiser_action'); |
|
| 237 | - if ($desc = decrire_token_previsu()) { |
|
| 238 | - $id_auteur = $desc['id_auteur']; |
|
| 239 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 240 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 241 | - } else { |
|
| 242 | - $id_auteur = null; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 246 | - if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 247 | - // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 248 | - if (!$id_auteur) { |
|
| 249 | - $where[] = $w; |
|
| 250 | - } else { |
|
| 251 | - $primary = id_table_objet($objet); |
|
| 252 | - $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 253 | - 'ssss.id_objet', |
|
| 254 | - 'spip_auteurs_liens AS ssss', |
|
| 255 | - 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 256 | - '', |
|
| 257 | - '', |
|
| 258 | - '', |
|
| 259 | - '', |
|
| 260 | - $serveur |
|
| 261 | - ) . '))'; |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 265 | - else { |
|
| 266 | - $v = ''; |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - // securite |
|
| 270 | - $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 271 | - } |
|
| 272 | - $liste_statuts = array_filter($liste_statuts); |
|
| 273 | - if (count($liste_statuts) == 1) { |
|
| 274 | - $where[] = array('=', $mstatut, sql_quote(reset($liste_statuts), $serveur)); |
|
| 275 | - } else { |
|
| 276 | - $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - while (count($where) > 1) { |
|
| 280 | - $and = array('AND', array_pop($where), array_pop($where)); |
|
| 281 | - $where[] = $and; |
|
| 282 | - } |
|
| 283 | - $cond[$key] = reset($where); |
|
| 284 | - if ($not) { |
|
| 285 | - $cond[$key] = array('NOT', $cond[$key]); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - return $cond[$key]; |
|
| 195 | + static $cond = array(); |
|
| 196 | + $key = func_get_args(); |
|
| 197 | + $key = implode('-', $key); |
|
| 198 | + if (isset($cond[$key])) { |
|
| 199 | + return $cond[$key]; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + $liste_statuts = $publie; |
|
| 203 | + if (defined('_VAR_PREVIEW') and _VAR_PREVIEW and !$ignore_previsu) { |
|
| 204 | + $liste_statuts = $previsu; |
|
| 205 | + } |
|
| 206 | + $not = false; |
|
| 207 | + if (strncmp($liste_statuts, '!', 1) == 0) { |
|
| 208 | + $not = true; |
|
| 209 | + $liste_statuts = substr($liste_statuts, 1); |
|
| 210 | + } |
|
| 211 | + // '' => ne rien afficher, '!'=> ne rien filtrer |
|
| 212 | + if (!strlen($liste_statuts)) { |
|
| 213 | + return $cond[$key] = ($not ? '1=1' : '0=1'); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + $liste_statuts = explode(',', $liste_statuts); |
|
| 217 | + $where = array(); |
|
| 218 | + foreach ($liste_statuts as $k => $v) { |
|
| 219 | + // filtrage /auteur pour limiter les objets d'un statut (prepa en general) |
|
| 220 | + // a ceux de l'auteur identifie |
|
| 221 | + if (strpos($v, '/') !== false) { |
|
| 222 | + $v = explode('/', $v); |
|
| 223 | + $filtre = end($v); |
|
| 224 | + $v = reset($v); |
|
| 225 | + $v = preg_replace(',\W,', '', $v); |
|
| 226 | + if ($filtre == 'auteur' |
|
| 227 | + and (strpos($mstatut, '.') !== false) |
|
| 228 | + and $objet = explode('.', $mstatut) |
|
| 229 | + and $id_table = reset($objet) |
|
| 230 | + and $objet = objet_type($id_table) |
|
| 231 | + ) { |
|
| 232 | + $w = "$mstatut<>" . sql_quote($v); |
|
| 233 | + |
|
| 234 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 235 | + // sinon l’auteur en session |
|
| 236 | + include_spip('inc/securiser_action'); |
|
| 237 | + if ($desc = decrire_token_previsu()) { |
|
| 238 | + $id_auteur = $desc['id_auteur']; |
|
| 239 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 240 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 241 | + } else { |
|
| 242 | + $id_auteur = null; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 246 | + if (!autoriser('previsualiser' . $v, $objet, '', $id_auteur)) { |
|
| 247 | + // si pas d'auteur identifie pas de sous-requete car pas d'article qui matche |
|
| 248 | + if (!$id_auteur) { |
|
| 249 | + $where[] = $w; |
|
| 250 | + } else { |
|
| 251 | + $primary = id_table_objet($objet); |
|
| 252 | + $where[] = "($w OR $id_table.$primary IN (" . sql_get_select( |
|
| 253 | + 'ssss.id_objet', |
|
| 254 | + 'spip_auteurs_liens AS ssss', |
|
| 255 | + 'ssss.objet=' . sql_quote($objet) . ' AND ssss.id_auteur=' . intval($id_auteur), |
|
| 256 | + '', |
|
| 257 | + '', |
|
| 258 | + '', |
|
| 259 | + '', |
|
| 260 | + $serveur |
|
| 261 | + ) . '))'; |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + } // ignorer ce statut si on ne sait pas comment le filtrer |
|
| 265 | + else { |
|
| 266 | + $v = ''; |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + // securite |
|
| 270 | + $liste_statuts[$k] = preg_replace(',\W,', '', $v); |
|
| 271 | + } |
|
| 272 | + $liste_statuts = array_filter($liste_statuts); |
|
| 273 | + if (count($liste_statuts) == 1) { |
|
| 274 | + $where[] = array('=', $mstatut, sql_quote(reset($liste_statuts), $serveur)); |
|
| 275 | + } else { |
|
| 276 | + $where[] = sql_in($mstatut, $liste_statuts, $not, $serveur); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + while (count($where) > 1) { |
|
| 280 | + $and = array('AND', array_pop($where), array_pop($where)); |
|
| 281 | + $where[] = $and; |
|
| 282 | + } |
|
| 283 | + $cond[$key] = reset($where); |
|
| 284 | + if ($not) { |
|
| 285 | + $cond[$key] = array('NOT', $cond[$key]); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + return $cond[$key]; |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | * @return array|bool|null |
| 297 | 297 | */ |
| 298 | 298 | function quete_fichier($id_document, $serveur = '') { |
| 299 | - return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 299 | + return sql_getfetsel('fichier', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | * @return array|bool |
| 308 | 308 | */ |
| 309 | 309 | function quete_document($id_document, $serveur = '') { |
| 310 | - return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 310 | + return sql_fetsel('*', 'spip_documents', ('id_document=' . intval($id_document)), '', array(), '', '', $serveur); |
|
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * @return array|bool|null |
| 319 | 319 | */ |
| 320 | 320 | function quete_meta($nom, $serveur) { |
| 321 | - return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 321 | + return sql_getfetsel('valeur', 'spip_meta', 'nom=' . sql_quote($nom), '', '', '', '', $serveur); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | /** |
@@ -344,64 +344,64 @@ discard block |
||
| 344 | 344 | * Retourne soit un tableau, soit le chemin du fichier. |
| 345 | 345 | */ |
| 346 | 346 | function quete_logo($cle_objet, $onoff, $id, $id_rubrique, $flag) { |
| 347 | - include_spip('base/objets'); |
|
| 348 | - $nom = strtolower($onoff); |
|
| 349 | - |
|
| 350 | - while (1) { |
|
| 351 | - $objet = objet_type($cle_objet); |
|
| 352 | - |
|
| 353 | - $on = quete_logo_objet($id, $objet, $nom); |
|
| 354 | - |
|
| 355 | - if ($on) { |
|
| 356 | - if ($flag) { |
|
| 357 | - return basename($on['chemin']); |
|
| 358 | - } else { |
|
| 359 | - $taille = @spip_getimagesize($on['chemin']); |
|
| 360 | - |
|
| 361 | - // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 362 | - // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 363 | - // alors on ne cherche pas du tout le survol ici |
|
| 364 | - if ($onoff != 'ON') { |
|
| 365 | - $off = ''; |
|
| 366 | - } else { |
|
| 367 | - // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 368 | - $off = quete_logo_objet($id, $objet, 'off'); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - // on retourne une url du type IMG/artonXX?timestamp |
|
| 372 | - // qui permet de distinguer le changement de logo |
|
| 373 | - // et placer un expire sur le dossier IMG/ |
|
| 374 | - $res = array( |
|
| 375 | - $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 376 | - ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 377 | - (!$taille ? '' : (' ' . $taille[3])) |
|
| 378 | - ); |
|
| 379 | - $res['src'] = $res[0]; |
|
| 380 | - $res['logo_on'] = $res[0]; |
|
| 381 | - $res['logo_off'] = $res[1]; |
|
| 382 | - $res['width'] = ($taille ? $taille[0] : ''); |
|
| 383 | - $res['height'] = ($taille ? $taille[1] : ''); |
|
| 384 | - |
|
| 385 | - return $res; |
|
| 386 | - } |
|
| 387 | - } else { |
|
| 388 | - if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 389 | - return ''; |
|
| 390 | - } else { |
|
| 391 | - if ($id_rubrique) { |
|
| 392 | - $cle_objet = 'id_rubrique'; |
|
| 393 | - $id = $id_rubrique; |
|
| 394 | - $id_rubrique = 0; |
|
| 395 | - } else { |
|
| 396 | - if ($id and $cle_objet == 'id_rubrique') { |
|
| 397 | - $id = quete_parent($id); |
|
| 398 | - } else { |
|
| 399 | - return ''; |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 347 | + include_spip('base/objets'); |
|
| 348 | + $nom = strtolower($onoff); |
|
| 349 | + |
|
| 350 | + while (1) { |
|
| 351 | + $objet = objet_type($cle_objet); |
|
| 352 | + |
|
| 353 | + $on = quete_logo_objet($id, $objet, $nom); |
|
| 354 | + |
|
| 355 | + if ($on) { |
|
| 356 | + if ($flag) { |
|
| 357 | + return basename($on['chemin']); |
|
| 358 | + } else { |
|
| 359 | + $taille = @spip_getimagesize($on['chemin']); |
|
| 360 | + |
|
| 361 | + // Si on a déjà demandé un survol directement ($onoff = off) |
|
| 362 | + // ou qu'on a demandé uniquement le normal ($onoff = on) |
|
| 363 | + // alors on ne cherche pas du tout le survol ici |
|
| 364 | + if ($onoff != 'ON') { |
|
| 365 | + $off = ''; |
|
| 366 | + } else { |
|
| 367 | + // Sinon, c'est qu'on demande normal ET survol à la fois, donc on cherche maintenant le survol |
|
| 368 | + $off = quete_logo_objet($id, $objet, 'off'); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + // on retourne une url du type IMG/artonXX?timestamp |
|
| 372 | + // qui permet de distinguer le changement de logo |
|
| 373 | + // et placer un expire sur le dossier IMG/ |
|
| 374 | + $res = array( |
|
| 375 | + $on['chemin'] . ($on['timestamp'] ? "?{$on['timestamp']}" : ''), |
|
| 376 | + ($off ? $off['chemin'] . ($off['timestamp'] ? "?{$off['timestamp']}" : '') : ''), |
|
| 377 | + (!$taille ? '' : (' ' . $taille[3])) |
|
| 378 | + ); |
|
| 379 | + $res['src'] = $res[0]; |
|
| 380 | + $res['logo_on'] = $res[0]; |
|
| 381 | + $res['logo_off'] = $res[1]; |
|
| 382 | + $res['width'] = ($taille ? $taille[0] : ''); |
|
| 383 | + $res['height'] = ($taille ? $taille[1] : ''); |
|
| 384 | + |
|
| 385 | + return $res; |
|
| 386 | + } |
|
| 387 | + } else { |
|
| 388 | + if (defined('_LOGO_RUBRIQUE_DESACTIVER_HERITAGE')) { |
|
| 389 | + return ''; |
|
| 390 | + } else { |
|
| 391 | + if ($id_rubrique) { |
|
| 392 | + $cle_objet = 'id_rubrique'; |
|
| 393 | + $id = $id_rubrique; |
|
| 394 | + $id_rubrique = 0; |
|
| 395 | + } else { |
|
| 396 | + if ($id and $cle_objet == 'id_rubrique') { |
|
| 397 | + $id = quete_parent($id); |
|
| 398 | + } else { |
|
| 399 | + return ''; |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | /** |
@@ -415,37 +415,37 @@ discard block |
||
| 415 | 415 | * "on" ou "off" suivant le logo normal ou survol |
| 416 | 416 | **/ |
| 417 | 417 | function quete_logo_objet($id_objet, $objet, $mode) { |
| 418 | - static $chercher_logo; |
|
| 419 | - if (is_null($chercher_logo)) { |
|
| 420 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 421 | - } |
|
| 422 | - $cle_objet = id_table_objet($objet); |
|
| 423 | - |
|
| 424 | - // On cherche pas la méthode classique |
|
| 425 | - $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 426 | - // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 427 | - if (!empty($infos_logo)) { |
|
| 428 | - $infos_logo = array( |
|
| 429 | - 'chemin' => $infos_logo[0], |
|
| 430 | - 'timestamp' => $infos_logo[4], |
|
| 431 | - ); |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - // On passe cette recherche de logo dans un pipeline |
|
| 435 | - $infos_logo = pipeline( |
|
| 436 | - 'quete_logo_objet', |
|
| 437 | - array( |
|
| 438 | - 'args' => array( |
|
| 439 | - 'id_objet' => $id_objet, |
|
| 440 | - 'objet' => $objet, |
|
| 441 | - 'cle_objet' => $cle_objet, |
|
| 442 | - 'mode' => $mode, |
|
| 443 | - ), |
|
| 444 | - 'data' => $infos_logo, |
|
| 445 | - ) |
|
| 446 | - ); |
|
| 447 | - |
|
| 448 | - return $infos_logo; |
|
| 418 | + static $chercher_logo; |
|
| 419 | + if (is_null($chercher_logo)) { |
|
| 420 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 421 | + } |
|
| 422 | + $cle_objet = id_table_objet($objet); |
|
| 423 | + |
|
| 424 | + // On cherche pas la méthode classique |
|
| 425 | + $infos_logo = $chercher_logo($id_objet, $cle_objet, $mode); |
|
| 426 | + // Si la méthode classique a trouvé quelque chose, on utilise le nouveau format |
|
| 427 | + if (!empty($infos_logo)) { |
|
| 428 | + $infos_logo = array( |
|
| 429 | + 'chemin' => $infos_logo[0], |
|
| 430 | + 'timestamp' => $infos_logo[4], |
|
| 431 | + ); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + // On passe cette recherche de logo dans un pipeline |
|
| 435 | + $infos_logo = pipeline( |
|
| 436 | + 'quete_logo_objet', |
|
| 437 | + array( |
|
| 438 | + 'args' => array( |
|
| 439 | + 'id_objet' => $id_objet, |
|
| 440 | + 'objet' => $objet, |
|
| 441 | + 'cle_objet' => $cle_objet, |
|
| 442 | + 'mode' => $mode, |
|
| 443 | + ), |
|
| 444 | + 'data' => $infos_logo, |
|
| 445 | + ) |
|
| 446 | + ); |
|
| 447 | + |
|
| 448 | + return $infos_logo; |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
@@ -458,24 +458,24 @@ discard block |
||
| 458 | 458 | * @return bool|string |
| 459 | 459 | */ |
| 460 | 460 | function quete_logo_file($row, $connect = null) { |
| 461 | - include_spip('inc/documents'); |
|
| 462 | - $logo = vignette_logo_document($row, $connect); |
|
| 463 | - if (!$logo) { |
|
| 464 | - $logo = image_du_document($row, $connect); |
|
| 465 | - } |
|
| 466 | - if (!$logo) { |
|
| 467 | - $f = charger_fonction('vignette', 'inc'); |
|
| 468 | - $logo = $f($row['extension'], false); |
|
| 469 | - } |
|
| 470 | - // si c'est une vignette type doc, la renvoyer direct |
|
| 471 | - if (strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 472 | - or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 473 | - or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 474 | - ) { |
|
| 475 | - return $logo; |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - return get_spip_doc($logo); |
|
| 461 | + include_spip('inc/documents'); |
|
| 462 | + $logo = vignette_logo_document($row, $connect); |
|
| 463 | + if (!$logo) { |
|
| 464 | + $logo = image_du_document($row, $connect); |
|
| 465 | + } |
|
| 466 | + if (!$logo) { |
|
| 467 | + $f = charger_fonction('vignette', 'inc'); |
|
| 468 | + $logo = $f($row['extension'], false); |
|
| 469 | + } |
|
| 470 | + // si c'est une vignette type doc, la renvoyer direct |
|
| 471 | + if (strcmp($logo, _DIR_PLUGINS) == 0 |
|
| 472 | + or strcmp($logo, _DIR_PLUGINS_DIST) == 0 |
|
| 473 | + or strcmp($logo, _DIR_RACINE . 'prive/') == 0 |
|
| 474 | + ) { |
|
| 475 | + return $logo; |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + return get_spip_doc($logo); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -503,20 +503,20 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | function quete_logo_document($row, $lien, $align, $mode_logo, $x, $y, $connect = null) { |
| 505 | 505 | |
| 506 | - include_spip('inc/documents'); |
|
| 507 | - $logo = ''; |
|
| 508 | - if (!in_array($mode_logo, array('icone', 'apercu'))) { |
|
| 509 | - $logo = vignette_logo_document($row, $connect); |
|
| 510 | - } |
|
| 511 | - // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 512 | - if ($mode_logo == 'vignette' and !$logo) { |
|
| 513 | - return ''; |
|
| 514 | - } |
|
| 515 | - if ($mode_logo == 'icone') { |
|
| 516 | - $row['fichier'] = ''; |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 506 | + include_spip('inc/documents'); |
|
| 507 | + $logo = ''; |
|
| 508 | + if (!in_array($mode_logo, array('icone', 'apercu'))) { |
|
| 509 | + $logo = vignette_logo_document($row, $connect); |
|
| 510 | + } |
|
| 511 | + // si on veut explicitement la vignette, ne rien renvoyer si il n'y en a pas |
|
| 512 | + if ($mode_logo == 'vignette' and !$logo) { |
|
| 513 | + return ''; |
|
| 514 | + } |
|
| 515 | + if ($mode_logo == 'icone') { |
|
| 516 | + $row['fichier'] = ''; |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + return vignette_automatique($logo, $row, $lien, $x, $y, $align, null, $connect); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -528,19 +528,19 @@ discard block |
||
| 528 | 528 | */ |
| 529 | 529 | function quete_html_logo($logo, $align, $lien) { |
| 530 | 530 | |
| 531 | - if (!is_array($logo)) { |
|
| 532 | - return ''; |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - $contexte = []; |
|
| 536 | - foreach ($logo as $k=>$v) { |
|
| 537 | - if (!is_numeric($k)) { |
|
| 538 | - $contexte[$k] = $v; |
|
| 539 | - } |
|
| 540 | - } |
|
| 541 | - $contexte['align'] = $align; |
|
| 542 | - $contexte['lien'] = $lien; |
|
| 543 | - return recuperer_fond('modeles/logo', $contexte); |
|
| 531 | + if (!is_array($logo)) { |
|
| 532 | + return ''; |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + $contexte = []; |
|
| 536 | + foreach ($logo as $k=>$v) { |
|
| 537 | + if (!is_numeric($k)) { |
|
| 538 | + $contexte[$k] = $v; |
|
| 539 | + } |
|
| 540 | + } |
|
| 541 | + $contexte['align'] = $align; |
|
| 542 | + $contexte['lien'] = $lien; |
|
| 543 | + return recuperer_fond('modeles/logo', $contexte); |
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -554,14 +554,14 @@ discard block |
||
| 554 | 554 | * @return string|false |
| 555 | 555 | */ |
| 556 | 556 | function document_spip_externe($fichier, $connect) { |
| 557 | - if ($connect) { |
|
| 558 | - $site = quete_meta('adresse_site', $connect); |
|
| 559 | - if ($site) { |
|
| 560 | - $dir = quete_meta('dir_img', $connect); |
|
| 561 | - return "$site/$dir$fichier"; |
|
| 562 | - } |
|
| 563 | - } |
|
| 564 | - return false; |
|
| 557 | + if ($connect) { |
|
| 558 | + $site = quete_meta('adresse_site', $connect); |
|
| 559 | + if ($site) { |
|
| 560 | + $dir = quete_meta('dir_img', $connect); |
|
| 561 | + return "$site/$dir$fichier"; |
|
| 562 | + } |
|
| 563 | + } |
|
| 564 | + return false; |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | /** |
@@ -574,23 +574,23 @@ discard block |
||
| 574 | 574 | * @return string |
| 575 | 575 | */ |
| 576 | 576 | function vignette_logo_document($row, $connect = '') { |
| 577 | - if (!$row['id_vignette']) { |
|
| 578 | - return ''; |
|
| 579 | - } |
|
| 580 | - $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 581 | - if ($url = document_spip_externe($fichier, $connect)) { |
|
| 582 | - return $url; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - $f = get_spip_doc($fichier); |
|
| 586 | - if ($f and @file_exists($f)) { |
|
| 587 | - return $f; |
|
| 588 | - } |
|
| 589 | - if ($row['mode'] !== 'vignette') { |
|
| 590 | - return ''; |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - return generer_url_entite($row['id_document'], 'document', '', '', $connect); |
|
| 577 | + if (!$row['id_vignette']) { |
|
| 578 | + return ''; |
|
| 579 | + } |
|
| 580 | + $fichier = quete_fichier($row['id_vignette'], $connect); |
|
| 581 | + if ($url = document_spip_externe($fichier, $connect)) { |
|
| 582 | + return $url; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + $f = get_spip_doc($fichier); |
|
| 586 | + if ($f and @file_exists($f)) { |
|
| 587 | + return $f; |
|
| 588 | + } |
|
| 589 | + if ($row['mode'] !== 'vignette') { |
|
| 590 | + return ''; |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + return generer_url_entite($row['id_document'], 'document', '', '', $connect); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | /** |
@@ -606,68 +606,68 @@ discard block |
||
| 606 | 606 | * @return bool|string |
| 607 | 607 | */ |
| 608 | 608 | function calcul_exposer($id, $prim, $reference, $parent, $type, $connect = '') { |
| 609 | - static $exposer = array(); |
|
| 610 | - |
|
| 611 | - // Que faut-il exposer ? Tous les elements de $reference |
|
| 612 | - // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 613 | - // qu'une fois (par squelette) et on conserve le resultat |
|
| 614 | - // en static. |
|
| 615 | - if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 616 | - $principal = isset($reference[$type]) ? $reference[$type] : |
|
| 617 | - // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 618 | - // et donne la reference dynamique @type=xx dans le contexte |
|
| 619 | - (isset($reference["@$type"]) ? $reference["@$type"] : ''); |
|
| 620 | - // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 621 | - // il n'est donc pas utile |
|
| 622 | - $parent = 0; |
|
| 623 | - if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 624 | - $enfants = array('id_rubrique' => array('id_article'), 'id_groupe' => array('id_mot')); |
|
| 625 | - if (isset($enfants[$type])) { |
|
| 626 | - foreach ($enfants[$type] as $t) { |
|
| 627 | - if (isset($reference[$t]) |
|
| 628 | - // cas de la reference donnee dynamiquement par la pagination |
|
| 629 | - or isset($reference["@$t"]) |
|
| 630 | - ) { |
|
| 631 | - $type = $t; |
|
| 632 | - $principal = isset($reference[$type]) ? $reference[$type] : $reference["@$type"]; |
|
| 633 | - continue; |
|
| 634 | - } |
|
| 635 | - } |
|
| 636 | - } |
|
| 637 | - } |
|
| 638 | - $exposer[$m][$type] = array(); |
|
| 639 | - if ($principal) { |
|
| 640 | - $principaux = is_array($principal) ? $principal : array($principal); |
|
| 641 | - foreach ($principaux as $principal) { |
|
| 642 | - $exposer[$m][$type][$principal] = true; |
|
| 643 | - if ($type == 'id_mot') { |
|
| 644 | - if (!$parent) { |
|
| 645 | - $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 646 | - } |
|
| 647 | - if ($parent) { |
|
| 648 | - $exposer[$m]['id_groupe'][$parent] = true; |
|
| 649 | - } |
|
| 650 | - } else { |
|
| 651 | - if ($type != 'id_groupe') { |
|
| 652 | - if (!$parent) { |
|
| 653 | - if ($type == 'id_rubrique') { |
|
| 654 | - $parent = $principal; |
|
| 655 | - } |
|
| 656 | - if ($type == 'id_article') { |
|
| 657 | - $parent = quete_rubrique($principal, $connect); |
|
| 658 | - } |
|
| 659 | - } |
|
| 660 | - do { |
|
| 661 | - $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 662 | - } while ($parent = quete_parent($parent, $connect)); |
|
| 663 | - } |
|
| 664 | - } |
|
| 665 | - } |
|
| 666 | - } |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - // And the winner is... |
|
| 670 | - return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 609 | + static $exposer = array(); |
|
| 610 | + |
|
| 611 | + // Que faut-il exposer ? Tous les elements de $reference |
|
| 612 | + // ainsi que leur hierarchie ; on ne fait donc ce calcul |
|
| 613 | + // qu'une fois (par squelette) et on conserve le resultat |
|
| 614 | + // en static. |
|
| 615 | + if (!isset($exposer[$m = md5(serialize($reference))][$prim])) { |
|
| 616 | + $principal = isset($reference[$type]) ? $reference[$type] : |
|
| 617 | + // cas de la pagination indecte @xx qui positionne la page avec l'id xx |
|
| 618 | + // et donne la reference dynamique @type=xx dans le contexte |
|
| 619 | + (isset($reference["@$type"]) ? $reference["@$type"] : ''); |
|
| 620 | + // le parent fournit en argument est le parent de $id, pas celui de $principal |
|
| 621 | + // il n'est donc pas utile |
|
| 622 | + $parent = 0; |
|
| 623 | + if (!$principal) { // regarder si un enfant est dans le contexte, auquel cas il expose peut etre le parent courant |
|
| 624 | + $enfants = array('id_rubrique' => array('id_article'), 'id_groupe' => array('id_mot')); |
|
| 625 | + if (isset($enfants[$type])) { |
|
| 626 | + foreach ($enfants[$type] as $t) { |
|
| 627 | + if (isset($reference[$t]) |
|
| 628 | + // cas de la reference donnee dynamiquement par la pagination |
|
| 629 | + or isset($reference["@$t"]) |
|
| 630 | + ) { |
|
| 631 | + $type = $t; |
|
| 632 | + $principal = isset($reference[$type]) ? $reference[$type] : $reference["@$type"]; |
|
| 633 | + continue; |
|
| 634 | + } |
|
| 635 | + } |
|
| 636 | + } |
|
| 637 | + } |
|
| 638 | + $exposer[$m][$type] = array(); |
|
| 639 | + if ($principal) { |
|
| 640 | + $principaux = is_array($principal) ? $principal : array($principal); |
|
| 641 | + foreach ($principaux as $principal) { |
|
| 642 | + $exposer[$m][$type][$principal] = true; |
|
| 643 | + if ($type == 'id_mot') { |
|
| 644 | + if (!$parent) { |
|
| 645 | + $parent = sql_getfetsel('id_groupe', 'spip_mots', 'id_mot=' . intval($principal), '', '', '', '', $connect); |
|
| 646 | + } |
|
| 647 | + if ($parent) { |
|
| 648 | + $exposer[$m]['id_groupe'][$parent] = true; |
|
| 649 | + } |
|
| 650 | + } else { |
|
| 651 | + if ($type != 'id_groupe') { |
|
| 652 | + if (!$parent) { |
|
| 653 | + if ($type == 'id_rubrique') { |
|
| 654 | + $parent = $principal; |
|
| 655 | + } |
|
| 656 | + if ($type == 'id_article') { |
|
| 657 | + $parent = quete_rubrique($principal, $connect); |
|
| 658 | + } |
|
| 659 | + } |
|
| 660 | + do { |
|
| 661 | + $exposer[$m]['id_rubrique'][$parent] = true; |
|
| 662 | + } while ($parent = quete_parent($parent, $connect)); |
|
| 663 | + } |
|
| 664 | + } |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + // And the winner is... |
|
| 670 | + return isset($exposer[$m][$prim]) ? isset($exposer[$m][$prim][$id]) : ''; |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | /** |
@@ -682,21 +682,21 @@ discard block |
||
| 682 | 682 | * @return int |
| 683 | 683 | */ |
| 684 | 684 | function quete_debut_pagination($primary, $valeur, $pas, $iter) { |
| 685 | - // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 686 | - // ou composee, mais verifions |
|
| 687 | - if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 688 | - return 0; |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - $pos = 0; |
|
| 692 | - while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 693 | - $pos++; |
|
| 694 | - } |
|
| 695 | - // si on a pas trouve |
|
| 696 | - if ($row[$primary] != $valeur) { |
|
| 697 | - return 0; |
|
| 698 | - } |
|
| 699 | - |
|
| 700 | - // sinon, calculer le bon numero de page |
|
| 701 | - return floor($pos / $pas) * $pas; |
|
| 685 | + // on ne devrait pas arriver ici si la cle primaire est inexistante |
|
| 686 | + // ou composee, mais verifions |
|
| 687 | + if (!$primary or preg_match('/[,\s]/', $primary)) { |
|
| 688 | + return 0; |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + $pos = 0; |
|
| 692 | + while ($row = $iter->fetch() and $row[$primary] != $valeur) { |
|
| 693 | + $pos++; |
|
| 694 | + } |
|
| 695 | + // si on a pas trouve |
|
| 696 | + if ($row[$primary] != $valeur) { |
|
| 697 | + return 0; |
|
| 698 | + } |
|
| 699 | + |
|
| 700 | + // sinon, calculer le bon numero de page |
|
| 701 | + return floor($pos / $pas) * $pas; |
|
| 702 | 702 | } |
@@ -42,6 +42,9 @@ discard block |
||
| 42 | 42 | define('_RACCOURCI_LIEN', "/\[([^][]*?([[]\w*[]][^][]*)*)->(>?)([^]]*)\]/msS"); |
| 43 | 43 | |
| 44 | 44 | // http://code.spip.net/@expanser_liens |
| 45 | +/** |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 45 | 48 | function expanser_liens($t, $connect = '', $env = array()) { |
| 46 | 49 | |
| 47 | 50 | $t = pipeline('pre_liens', $t); |
@@ -56,6 +59,9 @@ discard block |
||
| 56 | 59 | // Meme analyse mais pour eliminer les liens |
| 57 | 60 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 58 | 61 | // http://code.spip.net/@nettoyer_raccourcis_typo |
| 62 | +/** |
|
| 63 | + * @param string $texte |
|
| 64 | + */ |
|
| 59 | 65 | function nettoyer_raccourcis_typo($texte, $connect = '') { |
| 60 | 66 | return $texte; |
| 61 | 67 | } |
@@ -96,6 +102,9 @@ discard block |
||
| 96 | 102 | // 'url': seulement U (i.e. generer_url_RACCOURCI) |
| 97 | 103 | |
| 98 | 104 | // http://code.spip.net/@calculer_url |
| 105 | +/** |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 99 | 108 | function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 100 | 109 | $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
| 101 | 110 | |
@@ -256,7 +265,7 @@ discard block |
||
| 256 | 265 | * @param int $id Identifiant de l'objet |
| 257 | 266 | * @param string $type Type d'objet |
| 258 | 267 | * @param string|null $connect Connecteur SQL utilisé |
| 259 | - * @return array { |
|
| 268 | + * @return string { |
|
| 260 | 269 | * @var string $titre Titre si présent, sinon '' |
| 261 | 270 | * @var string $lang Langue si présente, sinon '' |
| 262 | 271 | * } |
@@ -302,6 +311,9 @@ discard block |
||
| 302 | 311 | define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
| 303 | 312 | |
| 304 | 313 | // http://code.spip.net/@traiter_modeles |
| 314 | +/** |
|
| 315 | + * @return string |
|
| 316 | + */ |
|
| 305 | 317 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
| 306 | 318 | // preserver la compatibilite : true = recherche des documents |
| 307 | 319 | if ($doublons === true) { |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('base/abstract_sql'); |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | // |
| 24 | 24 | |
| 25 | 25 | function inc_lien_dist( |
| 26 | - $lien, |
|
| 27 | - $texte = '', |
|
| 28 | - $class = '', |
|
| 29 | - $title = '', |
|
| 30 | - $hlang = '', |
|
| 31 | - $rel = '', |
|
| 32 | - $connect = '', |
|
| 33 | - $env = array() |
|
| 26 | + $lien, |
|
| 27 | + $texte = '', |
|
| 28 | + $class = '', |
|
| 29 | + $title = '', |
|
| 30 | + $hlang = '', |
|
| 31 | + $rel = '', |
|
| 32 | + $connect = '', |
|
| 33 | + $env = array() |
|
| 34 | 34 | ) { |
| 35 | - return $lien; |
|
| 35 | + return $lien; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip |
@@ -44,30 +44,30 @@ discard block |
||
| 44 | 44 | // http://code.spip.net/@expanser_liens |
| 45 | 45 | function expanser_liens($t, $connect = '', $env = array()) { |
| 46 | 46 | |
| 47 | - $t = pipeline('pre_liens', $t); |
|
| 47 | + $t = pipeline('pre_liens', $t); |
|
| 48 | 48 | |
| 49 | - // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | - // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | - $t = traiter_modeles($t, false, false, $connect); |
|
| 49 | + // on passe a traiter_modeles la liste des liens reperes pour lui permettre |
|
| 50 | + // de remettre le texte d'origine dans les parametres du modele |
|
| 51 | + $t = traiter_modeles($t, false, false, $connect); |
|
| 52 | 52 | |
| 53 | - return $t; |
|
| 53 | + return $t; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Meme analyse mais pour eliminer les liens |
| 57 | 57 | // et ne laisser que leur titre, a expliciter si ce n'est fait |
| 58 | 58 | // http://code.spip.net/@nettoyer_raccourcis_typo |
| 59 | 59 | function nettoyer_raccourcis_typo($texte, $connect = '') { |
| 60 | - return $texte; |
|
| 60 | + return $texte; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Repere dans la partie texte d'un raccourci [texte->...] |
| 64 | 64 | // la langue et la bulle eventuelles |
| 65 | 65 | // http://code.spip.net/@traiter_raccourci_lien_atts |
| 66 | 66 | function traiter_raccourci_lien_atts($texte) { |
| 67 | - $bulle = ''; |
|
| 68 | - $hlang = ''; |
|
| 67 | + $bulle = ''; |
|
| 68 | + $hlang = ''; |
|
| 69 | 69 | |
| 70 | - return array(trim($texte), $bulle, $hlang); |
|
| 70 | + return array(trim($texte), $bulle, $hlang); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | define('_RACCOURCI_CHAPO', '/^(\W*)(\W*)(\w*\d+([?#].*)?)$/'); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function virtuel_redirige($virtuel, $url = false) { |
| 86 | - return $virtuel; |
|
| 86 | + return $virtuel; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | // Cherche un lien du type [->raccourci 123] |
@@ -97,114 +97,114 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // http://code.spip.net/@calculer_url |
| 99 | 99 | function calculer_url($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 100 | - $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 100 | + $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 101 | 101 | |
| 102 | - return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 102 | + return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
| 106 | 106 | |
| 107 | 107 | // http://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
| 109 | - if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | - return ($pour != 'tout') ? '' : array('', '', '', ''); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $lien = entites_html(trim($ref)); |
|
| 114 | - |
|
| 115 | - // Liens explicites |
|
| 116 | - if (!$texte) { |
|
| 117 | - $texte = str_replace('"', '', $lien); |
|
| 118 | - // evite l'affichage de trops longues urls. |
|
| 119 | - $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | - $texte = $lien_court($texte); |
|
| 121 | - if ($echappe_typo) { |
|
| 122 | - $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // petites corrections d'URL |
|
| 127 | - if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | - $lien = "http://" . $lien; |
|
| 129 | - } else { |
|
| 130 | - if (strpos($lien, "@") && email_valide($lien)) { |
|
| 131 | - if (!$texte) { |
|
| 132 | - $texte = $lien; |
|
| 133 | - } |
|
| 134 | - $lien = "mailto:" . $lien; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - if ($pour == 'url') { |
|
| 139 | - return $lien; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - if ($pour == 'titre') { |
|
| 143 | - return $texte; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return array('url' => $lien, 'titre' => $texte); |
|
| 109 | + if (preg_match(_EXTRAIRE_LIEN, $ref)) { |
|
| 110 | + return ($pour != 'tout') ? '' : array('', '', '', ''); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $lien = entites_html(trim($ref)); |
|
| 114 | + |
|
| 115 | + // Liens explicites |
|
| 116 | + if (!$texte) { |
|
| 117 | + $texte = str_replace('"', '', $lien); |
|
| 118 | + // evite l'affichage de trops longues urls. |
|
| 119 | + $lien_court = charger_fonction('lien_court', 'inc'); |
|
| 120 | + $texte = $lien_court($texte); |
|
| 121 | + if ($echappe_typo) { |
|
| 122 | + $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // petites corrections d'URL |
|
| 127 | + if (preg_match('/^www\.[^@]+$/S', $lien)) { |
|
| 128 | + $lien = "http://" . $lien; |
|
| 129 | + } else { |
|
| 130 | + if (strpos($lien, "@") && email_valide($lien)) { |
|
| 131 | + if (!$texte) { |
|
| 132 | + $texte = $lien; |
|
| 133 | + } |
|
| 134 | + $lien = "mailto:" . $lien; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + if ($pour == 'url') { |
|
| 139 | + return $lien; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + if ($pour == 'titre') { |
|
| 143 | + return $texte; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return array('url' => $lien, 'titre' => $texte); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | - $url = $f($texte, $id); |
|
| 152 | - } else { |
|
| 153 | - $url = glossaire_std($texte); |
|
| 154 | - } |
|
| 150 | + if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 151 | + $url = $f($texte, $id); |
|
| 152 | + } else { |
|
| 153 | + $url = glossaire_std($texte); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - return $url; |
|
| 156 | + return $url; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // http://code.spip.net/@traiter_lien_implicite |
| 160 | 160 | function traiter_lien_implicite($ref, $texte = '', $pour = 'url', $connect = '') { |
| 161 | - if (!($match = typer_raccourci($ref))) { |
|
| 162 | - return false; |
|
| 163 | - } |
|
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | - // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | - // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | - if ($f = charger_fonction("implicite_$type", "liens", true)) { |
|
| 168 | - $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | - } |
|
| 170 | - if (!$url) { |
|
| 171 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | - } |
|
| 173 | - if (!$url) { |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 176 | - if (is_array($url)) { |
|
| 177 | - @list($type, $id) = $url; |
|
| 178 | - $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | - } |
|
| 180 | - if ($pour === 'url') { |
|
| 181 | - return $url; |
|
| 182 | - } |
|
| 183 | - $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | - if ($r) { |
|
| 185 | - $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | - } |
|
| 187 | - if ($texte = trim($texte)) { |
|
| 188 | - $r['titre'] = $texte; |
|
| 189 | - } |
|
| 190 | - if (!@$r['titre']) { |
|
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 192 | - } |
|
| 193 | - if ($pour == 'titre') { |
|
| 194 | - return $r['titre']; |
|
| 195 | - } |
|
| 196 | - $r['url'] = $url; |
|
| 197 | - |
|
| 198 | - // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | - if ($type == 'document' |
|
| 200 | - and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
|
| 201 | - "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 202 | - '', '', '', '', $connect) |
|
| 203 | - ) { |
|
| 204 | - $r['mime'] = $mime; |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - return $r; |
|
| 161 | + if (!($match = typer_raccourci($ref))) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 164 | + @list($type, , $id, , $args, , $ancre) = $match; |
|
| 165 | + // attention dans le cas des sites le lien doit pointer non pas sur |
|
| 166 | + // la page locale du site, mais directement sur le site lui-meme |
|
| 167 | + if ($f = charger_fonction("implicite_$type", "liens", true)) { |
|
| 168 | + $url = $f($texte, $id, $type, $args, $ancre, $connect); |
|
| 169 | + } |
|
| 170 | + if (!$url) { |
|
| 171 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 172 | + } |
|
| 173 | + if (!$url) { |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | + if (is_array($url)) { |
|
| 177 | + @list($type, $id) = $url; |
|
| 178 | + $url = generer_url_entite($id, $type, $args, $ancre, $connect ? $connect : null); |
|
| 179 | + } |
|
| 180 | + if ($pour === 'url') { |
|
| 181 | + return $url; |
|
| 182 | + } |
|
| 183 | + $r = traiter_raccourci_titre($id, $type, $connect); |
|
| 184 | + if ($r) { |
|
| 185 | + $r['class'] = ($type == 'site') ? 'spip_out' : 'spip_in'; |
|
| 186 | + } |
|
| 187 | + if ($texte = trim($texte)) { |
|
| 188 | + $r['titre'] = $texte; |
|
| 189 | + } |
|
| 190 | + if (!@$r['titre']) { |
|
| 191 | + $r['titre'] = _T($type) . " $id"; |
|
| 192 | + } |
|
| 193 | + if ($pour == 'titre') { |
|
| 194 | + return $r['titre']; |
|
| 195 | + } |
|
| 196 | + $r['url'] = $url; |
|
| 197 | + |
|
| 198 | + // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
|
| 199 | + if ($type == 'document' |
|
| 200 | + and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
|
| 201 | + "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 202 | + '', '', '', '', $connect) |
|
| 203 | + ) { |
|
| 204 | + $r['mime'] = $mime; |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + return $r; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes |
@@ -213,41 +213,41 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | // http://code.spip.net/@typer_raccourci |
| 215 | 215 | function typer_raccourci($lien) { |
| 216 | - if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 217 | - return array(); |
|
| 218 | - } |
|
| 219 | - $f = $match[1]; |
|
| 220 | - // valeur par defaut et alias historiques |
|
| 221 | - if (!$f) { |
|
| 222 | - $f = 'article'; |
|
| 223 | - } else { |
|
| 224 | - if ($f == 'art') { |
|
| 225 | - $f = 'article'; |
|
| 226 | - } else { |
|
| 227 | - if ($f == 'br') { |
|
| 228 | - $f = 'breve'; |
|
| 229 | - } else { |
|
| 230 | - if ($f == 'rub') { |
|
| 231 | - $f = 'rubrique'; |
|
| 232 | - } else { |
|
| 233 | - if ($f == 'aut') { |
|
| 234 | - $f = 'auteur'; |
|
| 235 | - } else { |
|
| 236 | - if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 237 | - $f = 'document'; |
|
| 238 | - } else { |
|
| 239 | - if (preg_match('/^br..?ve$/S', $f)) { |
|
| 240 | - $f = 'breve'; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - } # accents :( |
|
| 248 | - $match[0] = $f; |
|
| 249 | - |
|
| 250 | - return $match; |
|
| 216 | + if (!preg_match(_RACCOURCI_URL, $lien, $match)) { |
|
| 217 | + return array(); |
|
| 218 | + } |
|
| 219 | + $f = $match[1]; |
|
| 220 | + // valeur par defaut et alias historiques |
|
| 221 | + if (!$f) { |
|
| 222 | + $f = 'article'; |
|
| 223 | + } else { |
|
| 224 | + if ($f == 'art') { |
|
| 225 | + $f = 'article'; |
|
| 226 | + } else { |
|
| 227 | + if ($f == 'br') { |
|
| 228 | + $f = 'breve'; |
|
| 229 | + } else { |
|
| 230 | + if ($f == 'rub') { |
|
| 231 | + $f = 'rubrique'; |
|
| 232 | + } else { |
|
| 233 | + if ($f == 'aut') { |
|
| 234 | + $f = 'auteur'; |
|
| 235 | + } else { |
|
| 236 | + if ($f == 'doc' or $f == 'im' or $f == 'img' or $f == 'image' or $f == 'emb') { |
|
| 237 | + $f = 'document'; |
|
| 238 | + } else { |
|
| 239 | + if (preg_match('/^br..?ve$/S', $f)) { |
|
| 240 | + $f = 'breve'; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + } # accents :( |
|
| 248 | + $match[0] = $f; |
|
| 249 | + |
|
| 250 | + return $match; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -262,25 +262,25 @@ discard block |
||
| 262 | 262 | * } |
| 263 | 263 | **/ |
| 264 | 264 | function traiter_raccourci_titre($id, $type, $connect = null) { |
| 265 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 266 | - $desc = $trouver_table(table_objet($type)); |
|
| 267 | - if (!($desc and $s = $desc['titre'])) { |
|
| 268 | - return array(); |
|
| 269 | - } |
|
| 270 | - $_id = $desc['key']['PRIMARY KEY']; |
|
| 271 | - $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 272 | - if (!$r) { |
|
| 273 | - return array(); |
|
| 274 | - } |
|
| 275 | - $r['titre'] = supprimer_numero($r['titre']); |
|
| 276 | - if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 277 | - $r['titre'] = $r['surnom']; |
|
| 278 | - } |
|
| 279 | - if (!isset($r['lang'])) { |
|
| 280 | - $r['lang'] = ''; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - return $r; |
|
| 265 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 266 | + $desc = $trouver_table(table_objet($type)); |
|
| 267 | + if (!($desc and $s = $desc['titre'])) { |
|
| 268 | + return array(); |
|
| 269 | + } |
|
| 270 | + $_id = $desc['key']['PRIMARY KEY']; |
|
| 271 | + $r = sql_fetsel($s, $desc['table'], "$_id=$id", '', '', '', '', $connect); |
|
| 272 | + if (!$r) { |
|
| 273 | + return array(); |
|
| 274 | + } |
|
| 275 | + $r['titre'] = supprimer_numero($r['titre']); |
|
| 276 | + if (!$r['titre'] and !empty($r['surnom'])) { |
|
| 277 | + $r['titre'] = $r['surnom']; |
|
| 278 | + } |
|
| 279 | + if (!isset($r['lang'])) { |
|
| 280 | + $r['lang'] = ''; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + return $r; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // traite les modeles (dans la fonction typo), en remplacant |
@@ -292,115 +292,115 @@ discard block |
||
| 292 | 292 | // http://code.spip.net/@traiter_modeles |
| 293 | 293 | |
| 294 | 294 | define('_RACCOURCI_MODELE', |
| 295 | - '(<([a-z_-]{3,})' # <modele |
|
| 296 | - . '\s*([0-9]*)\s*' # id |
|
| 297 | - . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 298 | - . '\s*/?' . '>)' # fin du modele > |
|
| 299 | - . '\s*(<\/a>)?' # eventuel </a> |
|
| 295 | + '(<([a-z_-]{3,})' # <modele |
|
| 296 | + . '\s*([0-9]*)\s*' # id |
|
| 297 | + . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
|
| 298 | + . '\s*/?' . '>)' # fin du modele > |
|
| 299 | + . '\s*(<\/a>)?' # eventuel </a> |
|
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | 302 | define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
| 303 | 303 | |
| 304 | 304 | // http://code.spip.net/@traiter_modeles |
| 305 | 305 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
| 306 | - // preserver la compatibilite : true = recherche des documents |
|
| 307 | - if ($doublons === true) { |
|
| 308 | - $doublons = array('documents' => array('doc', 'emb', 'img')); |
|
| 309 | - } |
|
| 310 | - // detecter les modeles (rapide) |
|
| 311 | - if (strpos($texte, "<") !== false and |
|
| 312 | - preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 313 | - ) { |
|
| 314 | - include_spip('public/assembler'); |
|
| 315 | - $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true); |
|
| 316 | - foreach ($matches as $match) { |
|
| 317 | - // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 318 | - |
|
| 319 | - $a = strpos($texte, $match[0]); |
|
| 320 | - preg_match(_RACCOURCI_MODELE_DEBUT, |
|
| 321 | - substr($texte, $a), $regs); |
|
| 322 | - $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 323 | - list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 324 | - if ($fin and |
|
| 325 | - preg_match('/<a\s[^<>]*>\s*$/i', |
|
| 326 | - substr($texte, 0, $a), $r) |
|
| 327 | - ) { |
|
| 328 | - $lien = array( |
|
| 329 | - 'href' => extraire_attribut($r[0], 'href'), |
|
| 330 | - 'class' => extraire_attribut($r[0], 'class'), |
|
| 331 | - 'mime' => extraire_attribut($r[0], 'type'), |
|
| 332 | - 'title' => extraire_attribut($r[0], 'title'), |
|
| 333 | - 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 334 | - ); |
|
| 335 | - $n = strlen($r[0]); |
|
| 336 | - $a -= $n; |
|
| 337 | - $cherche = $n + strlen($regs[0]); |
|
| 338 | - } else { |
|
| 339 | - $lien = false; |
|
| 340 | - $cherche = strlen($mod); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - // calculer le modele |
|
| 344 | - # hack indexation |
|
| 345 | - if ($doublons) { |
|
| 346 | - $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 347 | - } # version normale |
|
| 348 | - else { |
|
| 349 | - // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 350 | - // dans les parametres, plutot que les liens echappes |
|
| 351 | - if (!is_null($liens)) { |
|
| 352 | - $params = str_replace($liens[0], $liens[1], $params); |
|
| 353 | - } |
|
| 354 | - $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 355 | - // en cas d'echec, |
|
| 356 | - // si l'objet demande a une url, |
|
| 357 | - // creer un petit encadre vers elle |
|
| 358 | - if ($modele === false) { |
|
| 359 | - if (!$lien) { |
|
| 360 | - $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 361 | - } |
|
| 362 | - if ($lien) { |
|
| 363 | - $modele = '<a href="' |
|
| 364 | - . $lien['url'] |
|
| 365 | - . '" class="spip_modele' |
|
| 366 | - . '">' |
|
| 367 | - . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 368 | - . "</a>"; |
|
| 369 | - } else { |
|
| 370 | - $modele = ""; |
|
| 371 | - if (test_espace_prive()) { |
|
| 372 | - $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 373 | - if (!is_null($liens)) { |
|
| 374 | - $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 375 | - } |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - // le remplacer dans le texte |
|
| 380 | - if ($modele !== false) { |
|
| 381 | - $modele = protege_js_modeles($modele); |
|
| 382 | - if ($wrap_embed_html) { |
|
| 383 | - $modele = $wrap_embed_html($mod, $modele); |
|
| 384 | - } |
|
| 385 | - $rempl = code_echappement($modele, $echap); |
|
| 386 | - $texte = substr($texte, 0, $a) |
|
| 387 | - . $rempl |
|
| 388 | - . substr($texte, $a + $cherche); |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - // hack pour tout l'espace prive |
|
| 393 | - if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 394 | - foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) { |
|
| 395 | - if (in_array($type, $modeles)) { |
|
| 396 | - $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 397 | - } |
|
| 398 | - } |
|
| 399 | - } |
|
| 400 | - } |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - return $texte; |
|
| 306 | + // preserver la compatibilite : true = recherche des documents |
|
| 307 | + if ($doublons === true) { |
|
| 308 | + $doublons = array('documents' => array('doc', 'emb', 'img')); |
|
| 309 | + } |
|
| 310 | + // detecter les modeles (rapide) |
|
| 311 | + if (strpos($texte, "<") !== false and |
|
| 312 | + preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER) |
|
| 313 | + ) { |
|
| 314 | + include_spip('public/assembler'); |
|
| 315 | + $wrap_embed_html = charger_fonction("wrap_embed_html", "inc", true); |
|
| 316 | + foreach ($matches as $match) { |
|
| 317 | + // Recuperer l'appel complet (y compris un eventuel lien) |
|
| 318 | + |
|
| 319 | + $a = strpos($texte, $match[0]); |
|
| 320 | + preg_match(_RACCOURCI_MODELE_DEBUT, |
|
| 321 | + substr($texte, $a), $regs); |
|
| 322 | + $regs[] = ""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide |
|
| 323 | + list(, $mod, $type, $id, $params, $fin) = $regs; |
|
| 324 | + if ($fin and |
|
| 325 | + preg_match('/<a\s[^<>]*>\s*$/i', |
|
| 326 | + substr($texte, 0, $a), $r) |
|
| 327 | + ) { |
|
| 328 | + $lien = array( |
|
| 329 | + 'href' => extraire_attribut($r[0], 'href'), |
|
| 330 | + 'class' => extraire_attribut($r[0], 'class'), |
|
| 331 | + 'mime' => extraire_attribut($r[0], 'type'), |
|
| 332 | + 'title' => extraire_attribut($r[0], 'title'), |
|
| 333 | + 'hreflang' => extraire_attribut($r[0], 'hreflang') |
|
| 334 | + ); |
|
| 335 | + $n = strlen($r[0]); |
|
| 336 | + $a -= $n; |
|
| 337 | + $cherche = $n + strlen($regs[0]); |
|
| 338 | + } else { |
|
| 339 | + $lien = false; |
|
| 340 | + $cherche = strlen($mod); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + // calculer le modele |
|
| 344 | + # hack indexation |
|
| 345 | + if ($doublons) { |
|
| 346 | + $texte .= preg_replace(',[|][^|=]*,s', ' ', $params); |
|
| 347 | + } # version normale |
|
| 348 | + else { |
|
| 349 | + // si un tableau de liens a ete passe, reinjecter le contenu d'origine |
|
| 350 | + // dans les parametres, plutot que les liens echappes |
|
| 351 | + if (!is_null($liens)) { |
|
| 352 | + $params = str_replace($liens[0], $liens[1], $params); |
|
| 353 | + } |
|
| 354 | + $modele = inclure_modele($type, $id, $params, $lien, $connect, $env); |
|
| 355 | + // en cas d'echec, |
|
| 356 | + // si l'objet demande a une url, |
|
| 357 | + // creer un petit encadre vers elle |
|
| 358 | + if ($modele === false) { |
|
| 359 | + if (!$lien) { |
|
| 360 | + $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect); |
|
| 361 | + } |
|
| 362 | + if ($lien) { |
|
| 363 | + $modele = '<a href="' |
|
| 364 | + . $lien['url'] |
|
| 365 | + . '" class="spip_modele' |
|
| 366 | + . '">' |
|
| 367 | + . sinon($lien['titre'], _T('ecrire:info_sans_titre')) |
|
| 368 | + . "</a>"; |
|
| 369 | + } else { |
|
| 370 | + $modele = ""; |
|
| 371 | + if (test_espace_prive()) { |
|
| 372 | + $modele = entites_html(substr($texte, $a, $cherche)); |
|
| 373 | + if (!is_null($liens)) { |
|
| 374 | + $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + // le remplacer dans le texte |
|
| 380 | + if ($modele !== false) { |
|
| 381 | + $modele = protege_js_modeles($modele); |
|
| 382 | + if ($wrap_embed_html) { |
|
| 383 | + $modele = $wrap_embed_html($mod, $modele); |
|
| 384 | + } |
|
| 385 | + $rempl = code_echappement($modele, $echap); |
|
| 386 | + $texte = substr($texte, 0, $a) |
|
| 387 | + . $rempl |
|
| 388 | + . substr($texte, $a + $cherche); |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + // hack pour tout l'espace prive |
|
| 393 | + if (((!_DIR_RESTREINT) or ($doublons)) and ($id)) { |
|
| 394 | + foreach ($doublons ? $doublons : array('documents' => array('doc', 'emb', 'img')) as $quoi => $modeles) { |
|
| 395 | + if (in_array($type, $modeles)) { |
|
| 396 | + $GLOBALS["doublons_{$quoi}_inclus"][] = $id; |
|
| 397 | + } |
|
| 398 | + } |
|
| 399 | + } |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + return $texte; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | // |
@@ -408,15 +408,15 @@ discard block |
||
| 408 | 408 | // |
| 409 | 409 | // http://code.spip.net/@traiter_raccourci_ancre |
| 410 | 410 | function traiter_raccourci_ancre($letexte) { |
| 411 | - return $letexte; |
|
| 411 | + return $letexte; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | // http://code.spip.net/@traiter_raccourci_glossaire |
| 415 | 415 | function traiter_raccourci_glossaire($texte) { |
| 416 | - return $texte; |
|
| 416 | + return $texte; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | // http://code.spip.net/@glossaire_std |
| 420 | 420 | function glossaire_std($terme) { |
| 421 | - return $terme; |
|
| 421 | + return $terme; |
|
| 422 | 422 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | -define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS'); |
|
| 105 | +define('_EXTRAIRE_LIEN', ',^\s*(?:'._PROTOCOLES_STD.'):?/?/?\s*$,iS'); |
|
| 106 | 106 | |
| 107 | 107 | // http://code.spip.net/@traiter_lien_explicite |
| 108 | 108 | function traiter_lien_explicite($ref, $texte = '', $pour = 'url', $connect = '', $echappe_typo = true) { |
@@ -119,19 +119,19 @@ discard block |
||
| 119 | 119 | $lien_court = charger_fonction('lien_court', 'inc'); |
| 120 | 120 | $texte = $lien_court($texte); |
| 121 | 121 | if ($echappe_typo) { |
| 122 | - $texte = "<html>" . quote_amp($texte) . "</html>"; |
|
| 122 | + $texte = "<html>".quote_amp($texte)."</html>"; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // petites corrections d'URL |
| 127 | 127 | if (preg_match('/^www\.[^@]+$/S', $lien)) { |
| 128 | - $lien = "http://" . $lien; |
|
| 128 | + $lien = "http://".$lien; |
|
| 129 | 129 | } else { |
| 130 | 130 | if (strpos($lien, "@") && email_valide($lien)) { |
| 131 | 131 | if (!$texte) { |
| 132 | 132 | $texte = $lien; |
| 133 | 133 | } |
| 134 | - $lien = "mailto:" . $lien; |
|
| 134 | + $lien = "mailto:".$lien; |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function liens_implicite_glose_dist($texte, $id, $type, $args, $ancre, $connect = '') { |
| 150 | - if (function_exists($f = 'glossaire_' . $ancre)) { |
|
| 150 | + if (function_exists($f = 'glossaire_'.$ancre)) { |
|
| 151 | 151 | $url = $f($texte, $id); |
| 152 | 152 | } else { |
| 153 | 153 | $url = glossaire_std($texte); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | if (!($match = typer_raccourci($ref))) { |
| 162 | 162 | return false; |
| 163 | 163 | } |
| 164 | - @list($type, , $id, , $args, , $ancre) = $match; |
|
| 164 | + @list($type,, $id,, $args,, $ancre) = $match; |
|
| 165 | 165 | // attention dans le cas des sites le lien doit pointer non pas sur |
| 166 | 166 | // la page locale du site, mais directement sur le site lui-meme |
| 167 | 167 | if ($f = charger_fonction("implicite_$type", "liens", true)) { |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $r['titre'] = $texte; |
| 189 | 189 | } |
| 190 | 190 | if (!@$r['titre']) { |
| 191 | - $r['titre'] = _T($type) . " $id"; |
|
| 191 | + $r['titre'] = _T($type)." $id"; |
|
| 192 | 192 | } |
| 193 | 193 | if ($pour == 'titre') { |
| 194 | 194 | return $r['titre']; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | // dans le cas d'un lien vers un doc, ajouter le type='mime/type' |
| 199 | 199 | if ($type == 'document' |
| 200 | 200 | and $mime = sql_getfetsel('mime_type', 'spip_types_documents', |
| 201 | - "extension IN (" . sql_get_select("extension", "spip_documents", "id_document=" . sql_quote($id)) . ")", |
|
| 201 | + "extension IN (".sql_get_select("extension", "spip_documents", "id_document=".sql_quote($id)).")", |
|
| 202 | 202 | '', '', '', '', $connect) |
| 203 | 203 | ) { |
| 204 | 204 | $r['mime'] = $mime; |
@@ -295,11 +295,11 @@ discard block |
||
| 295 | 295 | '(<([a-z_-]{3,})' # <modele |
| 296 | 296 | . '\s*([0-9]*)\s*' # id |
| 297 | 297 | . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>) |
| 298 | - . '\s*/?' . '>)' # fin du modele > |
|
| 298 | + . '\s*/?'.'>)' # fin du modele > |
|
| 299 | 299 | . '\s*(<\/a>)?' # eventuel </a> |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | -define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE . '@isS'); |
|
| 302 | +define('_RACCOURCI_MODELE_DEBUT', '@^'._RACCOURCI_MODELE.'@isS'); |
|
| 303 | 303 | |
| 304 | 304 | // http://code.spip.net/@traiter_modeles |
| 305 | 305 | function traiter_modeles($texte, $doublons = false, $echap = '', $connect = '', $liens = null, $env = array()) { |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | if (test_espace_prive()) { |
| 372 | 372 | $modele = entites_html(substr($texte, $a, $cherche)); |
| 373 | 373 | if (!is_null($liens)) { |
| 374 | - $modele = "<pre>" . str_replace($liens[0], $liens[1], $modele) . "</pre>"; |
|
| 374 | + $modele = "<pre>".str_replace($liens[0], $liens[1], $modele)."</pre>"; |
|
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | 377 | } |
@@ -1,3 +1,3 @@ |
||
| 1 | 1 | <?php |
| 2 | - # appel SPIP |
|
| 3 | - include('spip.php'); |
|
| 2 | + # appel SPIP |
|
| 3 | + include('spip.php'); |
|
@@ -11,24 +11,24 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function lister_traductions($id_trad, $objet) { |
| 18 | - $table_objet_sql = table_objet_sql($objet); |
|
| 19 | - $primary = id_table_objet($objet); |
|
| 18 | + $table_objet_sql = table_objet_sql($objet); |
|
| 19 | + $primary = id_table_objet($objet); |
|
| 20 | 20 | |
| 21 | - $select = "$primary as id,lang"; |
|
| 22 | - $where = 'id_trad=' . intval($id_trad); |
|
| 23 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 24 | - $desc = $trouver_table($table_objet_sql); |
|
| 25 | - if (isset($desc['field']['statut'])) { |
|
| 26 | - $select .= ',statut'; |
|
| 27 | - $where .= ' AND statut!='.sql_quote('poubelle'); |
|
| 28 | - } |
|
| 21 | + $select = "$primary as id,lang"; |
|
| 22 | + $where = 'id_trad=' . intval($id_trad); |
|
| 23 | + $trouver_table = charger_fonction('trouver_table','base'); |
|
| 24 | + $desc = $trouver_table($table_objet_sql); |
|
| 25 | + if (isset($desc['field']['statut'])) { |
|
| 26 | + $select .= ',statut'; |
|
| 27 | + $where .= ' AND statut!='.sql_quote('poubelle'); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $rows = sql_allfetsel($select, $table_objet_sql, $where); |
|
| 31 | - lang_select(); |
|
| 30 | + $rows = sql_allfetsel($select, $table_objet_sql, $where); |
|
| 31 | + lang_select(); |
|
| 32 | 32 | |
| 33 | - return $rows; |
|
| 33 | + return $rows; |
|
| 34 | 34 | } |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | $primary = id_table_objet($objet); |
| 20 | 20 | |
| 21 | 21 | $select = "$primary as id,lang"; |
| 22 | - $where = 'id_trad=' . intval($id_trad); |
|
| 23 | - $trouver_table = charger_fonction('trouver_table','base'); |
|
| 22 | + $where = 'id_trad='.intval($id_trad); |
|
| 23 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 24 | 24 | $desc = $trouver_table($table_objet_sql); |
| 25 | 25 | if (isset($desc['field']['statut'])) { |
| 26 | 26 | $select .= ',statut'; |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('prive/objets/liste/auteurs_fonctions'); |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/drapeau_edition'); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Fonctions |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -29,29 +29,29 @@ discard block |
||
| 29 | 29 | * @param <type> $left |
| 30 | 30 | */ |
| 31 | 31 | function critere_compteur_articles_filtres_dist($idb, &$boucles, $crit, $left = false) { |
| 32 | - $boucle = &$boucles[$idb]; |
|
| 32 | + $boucle = &$boucles[$idb]; |
|
| 33 | 33 | |
| 34 | - $_statut = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent); |
|
| 34 | + $_statut = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent); |
|
| 35 | 35 | |
| 36 | - $not = ''; |
|
| 37 | - if ($crit->not) { |
|
| 38 | - $not = ", 'NOT'"; |
|
| 39 | - } |
|
| 40 | - $boucle->from['LAA'] = 'spip_auteurs_liens'; |
|
| 41 | - $boucle->from_type['LAA'] = 'left'; |
|
| 42 | - $boucle->join['LAA'] = array("'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''"); |
|
| 36 | + $not = ''; |
|
| 37 | + if ($crit->not) { |
|
| 38 | + $not = ", 'NOT'"; |
|
| 39 | + } |
|
| 40 | + $boucle->from['LAA'] = 'spip_auteurs_liens'; |
|
| 41 | + $boucle->from_type['LAA'] = 'left'; |
|
| 42 | + $boucle->join['LAA'] = array("'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''"); |
|
| 43 | 43 | |
| 44 | - $boucle->from['articles'] = 'spip_articles'; |
|
| 45 | - $boucle->from_type['articles'] = 'left'; |
|
| 46 | - $boucle->join['articles'] = array( |
|
| 47 | - "'LAA'", |
|
| 48 | - "'id_article'", |
|
| 49 | - "'id_objet'", |
|
| 50 | - "'(articles.statut IS NULL OR '.sql_in('articles.statut',_q($_statut)$not).')'" |
|
| 51 | - ); |
|
| 44 | + $boucle->from['articles'] = 'spip_articles'; |
|
| 45 | + $boucle->from_type['articles'] = 'left'; |
|
| 46 | + $boucle->join['articles'] = array( |
|
| 47 | + "'LAA'", |
|
| 48 | + "'id_article'", |
|
| 49 | + "'id_objet'", |
|
| 50 | + "'(articles.statut IS NULL OR '.sql_in('articles.statut',_q($_statut)$not).')'" |
|
| 51 | + ); |
|
| 52 | 52 | |
| 53 | - $boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles'; |
|
| 54 | - $boucle->group[] = 'auteurs.id_auteur'; |
|
| 53 | + $boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles'; |
|
| 54 | + $boucle->group[] = 'auteurs.id_auteur'; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * Pile complétée par le code à générer |
| 70 | 70 | */ |
| 71 | 71 | function balise_COMPTEUR_ARTICLES_dist($p) { |
| 72 | - return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres'); |
|
| 72 | + return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres'); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -85,42 +85,42 @@ discard block |
||
| 85 | 85 | * @return <type> |
| 86 | 86 | */ |
| 87 | 87 | function afficher_initiale($url, $initiale, $compteur, $debut, $pas) { |
| 88 | - static $memo = null; |
|
| 89 | - static $res = array(); |
|
| 90 | - $out = ''; |
|
| 91 | - if (!$memo |
|
| 92 | - or (!$initiale and !$url) |
|
| 93 | - or ($initiale !== $memo['initiale']) |
|
| 94 | - ) { |
|
| 95 | - $newcompt = intval(floor(($compteur - 1) / $pas) * $pas); |
|
| 96 | - // si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien |
|
| 97 | - if (!$initiale and !$url and !$memo['compteur']) { |
|
| 98 | - $memo = null; |
|
| 99 | - } |
|
| 100 | - if ($memo) { |
|
| 101 | - $on = (($memo['compteur'] <= $debut) |
|
| 102 | - and ( |
|
| 103 | - $newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur']) |
|
| 104 | - )); |
|
| 105 | - $res[] = lien_ou_expose($memo['url'], $memo['initiale'], $on, 'lien_pagination'); |
|
| 106 | - } |
|
| 107 | - if ($initiale) { |
|
| 108 | - $memo = array( |
|
| 109 | - 'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0, |
|
| 110 | - 'initiale' => $initiale, |
|
| 111 | - 'url' => parametre_url($url, 'i', $initiale), |
|
| 112 | - 'compteur' => $newcompt |
|
| 113 | - ); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - if (!$initiale and !$url) { |
|
| 117 | - if (count($res) > 1) { |
|
| 118 | - $out = implode(' ', $res); |
|
| 119 | - } |
|
| 120 | - $memo = $res = null; |
|
| 121 | - } |
|
| 88 | + static $memo = null; |
|
| 89 | + static $res = array(); |
|
| 90 | + $out = ''; |
|
| 91 | + if (!$memo |
|
| 92 | + or (!$initiale and !$url) |
|
| 93 | + or ($initiale !== $memo['initiale']) |
|
| 94 | + ) { |
|
| 95 | + $newcompt = intval(floor(($compteur - 1) / $pas) * $pas); |
|
| 96 | + // si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien |
|
| 97 | + if (!$initiale and !$url and !$memo['compteur']) { |
|
| 98 | + $memo = null; |
|
| 99 | + } |
|
| 100 | + if ($memo) { |
|
| 101 | + $on = (($memo['compteur'] <= $debut) |
|
| 102 | + and ( |
|
| 103 | + $newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur']) |
|
| 104 | + )); |
|
| 105 | + $res[] = lien_ou_expose($memo['url'], $memo['initiale'], $on, 'lien_pagination'); |
|
| 106 | + } |
|
| 107 | + if ($initiale) { |
|
| 108 | + $memo = array( |
|
| 109 | + 'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0, |
|
| 110 | + 'initiale' => $initiale, |
|
| 111 | + 'url' => parametre_url($url, 'i', $initiale), |
|
| 112 | + 'compteur' => $newcompt |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + if (!$initiale and !$url) { |
|
| 117 | + if (count($res) > 1) { |
|
| 118 | + $out = implode(' ', $res); |
|
| 119 | + } |
|
| 120 | + $memo = $res = null; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - return $out; |
|
| 123 | + return $out; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -139,23 +139,23 @@ discard block |
||
| 139 | 139 | * @return string |
| 140 | 140 | */ |
| 141 | 141 | function auteur_lien_messagerie($id_auteur, $en_ligne, $statut, $imessage, $email = '') { |
| 142 | - static $time = null; |
|
| 143 | - if (!in_array($statut, array('0minirezo', '1comite'))) { |
|
| 144 | - return ''; |
|
| 145 | - } |
|
| 142 | + static $time = null; |
|
| 143 | + if (!in_array($statut, array('0minirezo', '1comite'))) { |
|
| 144 | + return ''; |
|
| 145 | + } |
|
| 146 | 146 | |
| 147 | - if (is_null($time)) { |
|
| 148 | - $time = time(); |
|
| 149 | - } |
|
| 150 | - $parti = (($time - strtotime($en_ligne)) > 15 * 60); |
|
| 147 | + if (is_null($time)) { |
|
| 148 | + $time = time(); |
|
| 149 | + } |
|
| 150 | + $parti = (($time - strtotime($en_ligne)) > 15 * 60); |
|
| 151 | 151 | |
| 152 | - if ($imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ? |
|
| 153 | - and $GLOBALS['meta']['messagerie_agenda'] != 'non' |
|
| 154 | - ) { |
|
| 155 | - return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self()); |
|
| 156 | - } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) { |
|
| 157 | - return 'mailto:' . $email; |
|
| 158 | - } else { |
|
| 159 | - return ''; |
|
| 160 | - } |
|
| 152 | + if ($imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ? |
|
| 153 | + and $GLOBALS['meta']['messagerie_agenda'] != 'non' |
|
| 154 | + ) { |
|
| 155 | + return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self()); |
|
| 156 | + } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) { |
|
| 157 | + return 'mailto:' . $email; |
|
| 158 | + } else { |
|
| 159 | + return ''; |
|
| 160 | + } |
|
| 161 | 161 | } |
@@ -154,7 +154,7 @@ |
||
| 154 | 154 | ) { |
| 155 | 155 | return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self()); |
| 156 | 156 | } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) { |
| 157 | - return 'mailto:' . $email; |
|
| 157 | + return 'mailto:'.$email; |
|
| 158 | 158 | } else { |
| 159 | 159 | return ''; |
| 160 | 160 | } |
@@ -11,40 +11,40 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function defaut_tri_defined($defaut) { |
| 18 | - if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 19 | - return $defaut; |
|
| 20 | - } |
|
| 18 | + if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 19 | + return $defaut; |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - $sens = 1; |
|
| 23 | - $tri = trim(_TRI_ARTICLES_RUBRIQUE); |
|
| 24 | - $tri = explode(' ', $tri); |
|
| 25 | - if (strncasecmp(end($tri), 'DESC', 4) == 0) { |
|
| 26 | - $sens = -1; |
|
| 27 | - array_pop($tri); |
|
| 28 | - } elseif (strncasecmp(end($tri), 'ASC', 3) == 0) { |
|
| 29 | - $sens = 1; |
|
| 30 | - array_pop($tri); |
|
| 31 | - } |
|
| 32 | - $tri = implode(' ', $tri); |
|
| 33 | - $tri = array($tri => $sens); |
|
| 34 | - foreach ($defaut as $n => $s) { |
|
| 35 | - if (!isset($tri[$n])) { |
|
| 36 | - $tri[$n] = $s; |
|
| 37 | - } |
|
| 38 | - } |
|
| 22 | + $sens = 1; |
|
| 23 | + $tri = trim(_TRI_ARTICLES_RUBRIQUE); |
|
| 24 | + $tri = explode(' ', $tri); |
|
| 25 | + if (strncasecmp(end($tri), 'DESC', 4) == 0) { |
|
| 26 | + $sens = -1; |
|
| 27 | + array_pop($tri); |
|
| 28 | + } elseif (strncasecmp(end($tri), 'ASC', 3) == 0) { |
|
| 29 | + $sens = 1; |
|
| 30 | + array_pop($tri); |
|
| 31 | + } |
|
| 32 | + $tri = implode(' ', $tri); |
|
| 33 | + $tri = array($tri => $sens); |
|
| 34 | + foreach ($defaut as $n => $s) { |
|
| 35 | + if (!isset($tri[$n])) { |
|
| 36 | + $tri[$n] = $s; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $tri; |
|
| 40 | + return $tri; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | function defaut_tri_par($par, $defaut) { |
| 44 | - if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 45 | - return $par; |
|
| 46 | - } |
|
| 47 | - $par = array_keys($defaut); |
|
| 44 | + if (!defined('_TRI_ARTICLES_RUBRIQUE')) { |
|
| 45 | + return $par; |
|
| 46 | + } |
|
| 47 | + $par = array_keys($defaut); |
|
| 48 | 48 | |
| 49 | - return reset($par); |
|
| 49 | + return reset($par); |
|
| 50 | 50 | } |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 4 | - return; |
|
| 4 | + return; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | include_spip('formulaires/selecteur/selecteur_fonctions'); |