Commit | Line | Data |
---|---|---|
c495c100 P |
1 | <?php |
2 | ||
3 | /***************************************************************************\ | |
4 | * SPIP, Systeme de publication pour l'internet * | |
5 | * * | |
6 | * Copyright (c) 2001-2007 * | |
7 | * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * | |
8 | * * | |
9 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * | |
10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * | |
11 | \***************************************************************************/ | |
12 | ||
13 | if (!defined("_ECRIRE_INC_VERSION")) return; // securiser | |
14 | if (!function_exists('generer_url_article')) { // si la place n'est pas prise | |
15 | ||
16 | ||
17 | ####### modifications possibles dans ecrire/mes_options | |
18 | # on peut indiquer '.html' pour faire joli | |
19 | define ('_terminaison_urls_page', ''); | |
20 | # ci-dessous, ce qu'on veut ou presque (de preference pas de '/') | |
21 | # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite | |
22 | define ('_separateur_urls_page', ''); | |
23 | # on peut indiquer '' si on a installe le .htaccess | |
24 | define ('_debut_urls_page', get_spip_script('./').'?'); | |
25 | ####### | |
26 | ||
27 | ||
28 | // http://doc.spip.org/@composer_url_page | |
29 | function composer_url_page($page,$id) { | |
30 | return _debut_urls_page . $page . _separateur_urls_page | |
31 | . $id . _terminaison_urls_page; | |
32 | } | |
33 | ||
34 | // http://doc.spip.org/@generer_url_article | |
35 | function generer_url_article($id_article) { | |
36 | return composer_url_page('article', $id_article); | |
37 | } | |
38 | ||
39 | // http://doc.spip.org/@generer_url_rubrique | |
40 | function generer_url_rubrique($id_rubrique) { | |
41 | return composer_url_page('rubrique', $id_rubrique); | |
42 | } | |
43 | ||
44 | // http://doc.spip.org/@generer_url_breve | |
45 | function generer_url_breve($id_breve) { | |
46 | return composer_url_page('breve', $id_breve); | |
47 | } | |
48 | ||
49 | // http://doc.spip.org/@generer_url_mot | |
50 | function generer_url_mot($id_mot) { | |
51 | return composer_url_page('mot', $id_mot); | |
52 | } | |
53 | ||
54 | // http://doc.spip.org/@generer_url_site | |
55 | function generer_url_site($id_syndic) { | |
56 | return composer_url_page('site', $id_syndic); | |
57 | } | |
58 | ||
59 | // http://doc.spip.org/@generer_url_auteur | |
60 | function generer_url_auteur($id_auteur) { | |
61 | return composer_url_page('auteur', $id_auteur); | |
62 | } | |
63 | ||
64 | // http://doc.spip.org/@generer_url_document | |
65 | function generer_url_document($id_document) { | |
66 | if (($id_document = intval($id_document)) <= 0) | |
67 | return ''; | |
68 | if (($GLOBALS['meta']["creer_htaccess"]) == 'oui') | |
69 | return generer_url_action('autoriser',"arg=$id_document", true); | |
70 | $row = @spip_fetch_array(spip_query("SELECT fichier FROM spip_documents WHERE id_document = $id_document")); | |
71 | if ($row) return ($row['fichier']); | |
72 | return ''; | |
73 | } | |
74 | ||
75 | // http://doc.spip.org/@recuperer_parametres_url | |
76 | function recuperer_parametres_url(&$fond, $url) { | |
77 | global $contexte; | |
78 | ||
79 | // Ce bloc gere les urls page et la compatibilite avec les "urls standard" | |
80 | if ($fond=='sommaire' | |
81 | AND preg_match( | |
82 | ',^[^?]*[?/](article|rubrique|breve|mot|site|auteur)(?:\.php3?)?.*?([0-9]+),', | |
83 | $url, $regs)) { | |
84 | $fond = $regs[1]; | |
85 | if ($regs[1] == 'site') { | |
86 | if (!isset($contexte['id_syndic'])) | |
87 | $contexte['id_syndic'] = $regs[2]; | |
88 | } else { | |
89 | if (!isset($contexte['id_'.$fond])) | |
90 | $contexte['id_'.$fond] = $regs[2]; | |
91 | } | |
92 | ||
93 | return; | |
94 | } | |
95 | ||
96 | /* | |
97 | * Le bloc qui suit sert a faciliter les transitions depuis | |
98 | * le mode 'urls-propres' vers les modes 'urls-standard/page' et 'url-html' | |
99 | * Il est inutile de le recopier si vous personnalisez vos URLs | |
100 | * et votre .htaccess | |
101 | */ | |
102 | // Si on est revenu en mode page, mais c'est une ancienne url_propre | |
103 | // on ne redirige pas, on assume le nouveau contexte (si possible) | |
104 | if ( | |
105 | (isset($_SERVER['REDIRECT_url_propre']) AND $url_propre = $_SERVER['REDIRECT_url_propre']) | |
106 | OR (isset($GLOBALS['HTTP_ENV_VARS']['url_propre']) AND $url_propre = $GLOBALS['HTTP_ENV_VARS']['url_propre']) | |
107 | AND preg_match(',^(article|breve|rubrique|mot|auteur|site)$,', $fond)) { | |
108 | $url_propre = (preg_replace('/^[_+-]{0,2}(.*?)[_+-]{0,2}(\.html)?$/', | |
109 | '$1', $url_propre)); | |
110 | $r = "spip_" . table_objet($fond); | |
111 | $id = id_table_objet($fond); | |
112 | $r = spip_query("SELECT $id AS id FROM $r WHERE url_propre = " . _q($url_propre)); | |
113 | if ($r AND $r = spip_fetch_array($r)) | |
114 | $contexte[$id] = $r['id']; | |
115 | } | |
116 | ||
117 | /* Fin du bloc compatibilite url-propres */ | |
118 | } | |
119 | ||
120 | // | |
121 | // URLs des forums | |
122 | // | |
123 | ||
124 | // http://doc.spip.org/@generer_url_forum | |
125 | function generer_url_forum($id_forum, $show_thread=false) { | |
126 | include_spip('inc/forum'); | |
127 | return generer_url_forum_dist($id_forum, $show_thread); | |
128 | } | |
129 | } | |
130 | ?> |