1 | <?php |
---|
2 | |
---|
3 | if (!defined('_ECRIRE_INC_VERSION')) return; |
---|
4 | |
---|
5 | // pour definir des liens vers |
---|
6 | if (!defined('CODES_SPIP_BRANCHE')) { |
---|
7 | #define(CODES_SPIP_BRANCHE, '3.0'); |
---|
8 | define(CODES_SPIP_BRANCHE, 'dev'); |
---|
9 | } |
---|
10 | |
---|
11 | |
---|
12 | function glossaire_core($chemin, $ligne=0) { |
---|
13 | // gestion des aiguillages automatiques |
---|
14 | // vers core_plugins lorsque le chemin indique un fichier qui y pointe. |
---|
15 | static $aiguillages = array( |
---|
16 | 'dev' => array( |
---|
17 | 'plugins-dist' => '', |
---|
18 | 'squelettes-dist' => 'dist', |
---|
19 | ), |
---|
20 | '3.1' => array( |
---|
21 | 'plugins-dist' => '', |
---|
22 | 'squelettes-dist' => 'dist', |
---|
23 | ), |
---|
24 | '3.0' => array( |
---|
25 | 'plugins-dist' => '', |
---|
26 | 'squelettes-dist' => 'dist', |
---|
27 | ), |
---|
28 | '2.1' => array( |
---|
29 | 'extensions' => '', |
---|
30 | ), |
---|
31 | ); |
---|
32 | if (isset($aiguillages[CODES_SPIP_BRANCHE])) { |
---|
33 | foreach ( $aiguillages[CODES_SPIP_BRANCHE] AS $repertoire => $remplacer ) { |
---|
34 | if (substr($chemin, 0, $len = strlen($repertoire)) == $repertoire) { |
---|
35 | return glossaire_spip_url('core_plugins', $remplacer . substr($chemin, $len), $ligne); |
---|
36 | } |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | // sinon c'est la... |
---|
41 | return glossaire_spip_url('core', $chemin, $ligne); |
---|
42 | } |
---|
43 | |
---|
44 | |
---|
45 | function glossaire_core_plugins($chemin, $ligne=0) { |
---|
46 | return glossaire_spip_url('core_plugins', $chemin, $ligne); |
---|
47 | } |
---|
48 | |
---|
49 | function glossaire_zone_plugins($chemin, $ligne=0) { |
---|
50 | return glossaire_spip_url('zone_plugins', $chemin, $ligne); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | function glossaire_spip_url($type='core', $chemin, $ligne) { |
---|
55 | static $sources = array( |
---|
56 | 'dev' => array( |
---|
57 | 'core' => 'http://core.spip.org/projects/spip/repository/entry/spip/@file@', |
---|
58 | 'core_plugins' => 'http://zone.spip.org/trac/spip-zone/browser/_core_/plugins/@file@', |
---|
59 | 'zone_plugins' => 'http://zone.spip.org/trac/spip-zone/browser/_plugins_/@file@', |
---|
60 | ), |
---|
61 | 'branches' => array( |
---|
62 | 'core' => 'http://core.spip.org/projects/spip/repository/entry/branches/spip-@branche@/@file@', |
---|
63 | 'core_plugins' => 'http://zone.spip.org/trac/spip-zone/browser/_core_/branches/spip-@branche@/plugins/@file@', |
---|
64 | 'zone_plugins' => 'http://zone.spip.org/trac/spip-zone/browser/_plugins_/@file@', |
---|
65 | ), |
---|
66 | ); |
---|
67 | |
---|
68 | // retrouver selon la branche |
---|
69 | if (CODES_SPIP_BRANCHE == 'dev') { |
---|
70 | $source = $sources['dev']; |
---|
71 | } else { |
---|
72 | $source = $sources['branches']; |
---|
73 | } |
---|
74 | |
---|
75 | // retrouver selon le type demande |
---|
76 | $source = $source[$type]; |
---|
77 | |
---|
78 | // inserer les valeurs correctes de branche et de fichier et ligne |
---|
79 | $source = str_replace('@branche@', CODES_SPIP_BRANCHE, $source); |
---|
80 | |
---|
81 | // on remplace le chemin du fichier et ajoute l'eventuelle ligne. |
---|
82 | return str_replace('@file@', $chemin, $source) . ($ligne ? '#L' . $ligne : ''); |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | ## |
---|
90 | # CODE MORT |
---|
91 | # maintenu quelques temps |
---|
92 | ## |
---|
93 | |
---|
94 | |
---|
95 | // trac SVN |
---|
96 | # @define('_URL_BROWSER_TRAC', 'http://trac.rezo.net/trac/spip/browser/spip/'); |
---|
97 | |
---|
98 | // trac GIT |
---|
99 | #@define('_URL_BROWSER_TRAC', 'http://core.spip.org/trac/spip/browser/@file@?rev=spip-2.1'); |
---|
100 | |
---|
101 | // redmine SVN (trunk) |
---|
102 | @define('_URL_BROWSER_TRAC', 'http://core.spip.org/projects/spip/repository/entry/spip/@file@'); |
---|
103 | |
---|
104 | // redmine SVN (branche 2.1) |
---|
105 | #@define('_URL_BROWSER_TRAC', 'http://core.spip.org/projects/spip/repository/entry/branches/spip-2.1/@file@'); |
---|
106 | |
---|
107 | /* |
---|
108 | * Obsolete, a migrer vers les nouveaux glossaires |
---|
109 | * |
---|
110 | * Un raccourci pour des chemins vers de trac |
---|
111 | * [?ecrire/inc_version.php#trac] |
---|
112 | * [?ecrire/inc_version.php#tracNNN] // NNN = numero de ligne |
---|
113 | * |
---|
114 | */ |
---|
115 | if (!function_exists('glossaire_trac')) { |
---|
116 | function glossaire_trac($texte, $id=0) { |
---|
117 | // si @file@ present dans le define, on remplace par le texte |
---|
118 | if (false !== strpos(_URL_BROWSER_TRAC, '@file@')) { |
---|
119 | return str_replace('@file@', $texte, _URL_BROWSER_TRAC) . ($id ? '#L'.$id : ''); |
---|
120 | } |
---|
121 | |
---|
122 | // sinon, on met bout a bout comme avant... |
---|
123 | return _URL_BROWSER_TRAC . $texte . ($id ? '#L'.$id : ''); |
---|
124 | } |
---|
125 | } |
---|
126 | ?> |
---|