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 | /* | |
14 | ||
15 | - Comment utiliser ce jeu d'URLs ? | |
16 | ||
17 | Recopiez le fichier "htaccess.txt" du repertoire de base du site SPIP sous | |
18 | le sous le nom ".htaccess" (attention a ne pas ecraser d'autres reglages | |
19 | que vous pourriez avoir mis dans ce fichier) ; si votre site est en | |
20 | "sous-repertoire", vous devrez aussi editer la ligne "RewriteBase" ce fichier. | |
21 | Les URLs definies seront alors redirigees vers les fichiers de SPIP. | |
22 | ||
23 | Definissez ensuite dans ecrire/mes_options.php : | |
24 | < ?php $type_urls = 'html'; ? > | |
25 | ||
26 | SPIP calculera alors ses liens sous la forme "article123.html". | |
27 | ||
28 | ||
29 | Note : si le fichier htaccess.txt se revele trop "puissant", car trop | |
30 | generique, et conduit a des problemes (en lien par exemple avec d'autres | |
31 | applications installees dans votre repertoire, a cote de SPIP), vous | |
32 | pouvez l'editer pour ne conserver que la partie concernant les URLS 'html'. | |
33 | ||
34 | */ | |
35 | ||
36 | if (!defined("_ECRIRE_INC_VERSION")) return; // securiser | |
37 | if (!function_exists('generer_url_article')) { // si la place n'est pas prise | |
38 | ||
39 | // http://doc.spip.org/@generer_url_article | |
40 | function generer_url_article($id_article) { | |
41 | return "article$id_article.html"; | |
42 | } | |
43 | ||
44 | // http://doc.spip.org/@generer_url_rubrique | |
45 | function generer_url_rubrique($id_rubrique) { | |
46 | return "rubrique$id_rubrique.html"; | |
47 | } | |
48 | ||
49 | // http://doc.spip.org/@generer_url_breve | |
50 | function generer_url_breve($id_breve) { | |
51 | return "breve$id_breve.html"; | |
52 | } | |
53 | ||
54 | // http://doc.spip.org/@generer_url_mot | |
55 | function generer_url_mot($id_mot) { | |
56 | return "mot$id_mot.html"; | |
57 | } | |
58 | ||
59 | // http://doc.spip.org/@generer_url_site | |
60 | function generer_url_site($id_syndic) { | |
61 | return "site$id_syndic.html"; | |
62 | } | |
63 | ||
64 | // http://doc.spip.org/@generer_url_auteur | |
65 | function generer_url_auteur($id_auteur) { | |
66 | return "auteur$id_auteur.html"; | |
67 | } | |
68 | ||
69 | // http://doc.spip.org/@generer_url_document | |
70 | function generer_url_document($id_document) { | |
71 | if (intval($id_document) <= 0) | |
72 | return ''; | |
73 | if (($GLOBALS['meta']["creer_htaccess"]) == 'oui') | |
74 | return generer_url_action('autoriser', "arg=$id_document", true); | |
75 | $row = @spip_fetch_array(spip_query("SELECT fichier FROM spip_documents WHERE id_document = $id_document")); | |
76 | if ($row) return ($row['fichier']); | |
77 | return ''; | |
78 | } | |
79 | ||
80 | ||
81 | // http://doc.spip.org/@recuperer_parametres_url | |
82 | function recuperer_parametres_url($fond, $url) { | |
83 | global $contexte; | |
84 | ||
85 | ||
86 | /* | |
87 | * Le bloc qui suit sert a faciliter les transitions depuis | |
88 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' | |
89 | * Il est inutile de le recopier si vous personnalisez vos URLs | |
90 | * et votre .htaccess | |
91 | */ | |
92 | // Si on est revenu en mode html, mais c'est une ancienne url_propre | |
93 | // on ne redirige pas, on assume le nouveau contexte (si possible) | |
94 | $url_propre = isset($_SERVER['REDIRECT_url_propre']) ? | |
95 | $_SERVER['REDIRECT_url_propre'] : | |
96 | (isset($GLOBALS['HTTP_ENV_VARS']['url_propre']) ? | |
97 | $GLOBALS['HTTP_ENV_VARS']['url_propre'] : | |
98 | ''); | |
99 | if ($url_propre AND preg_match(',^(article|breve|rubrique|mot|auteur|site)$,', $fond)) { | |
100 | $url_propre = (preg_replace('/^[_+-]{0,2}(.*?)[_+-]{0,2}(\.html)?$/', | |
101 | '$1', $url_propre)); | |
102 | $id = id_table_objet($fond); | |
103 | $r = spip_query("SELECT $id AS id FROM spip_" . table_objet($fond) . " WHERE url_propre = " . _q($url_propre)); | |
104 | if ($r AND $r = spip_fetch_array($r)) | |
105 | $contexte[$id] = $r['id']; | |
106 | } | |
107 | /* Fin du bloc compatibilite url-propres */ | |
108 | } | |
109 | ||
110 | ||
111 | // | |
112 | // URLs des forums | |
113 | // | |
114 | ||
115 | // http://doc.spip.org/@generer_url_forum | |
116 | function generer_url_forum($id_forum, $show_thread=false) { | |
117 | include_spip('inc/forum'); | |
118 | return generer_url_forum_dist($id_forum, $show_thread); | |
119 | } | |
120 | } | |
121 | ?> |