1<?php
2# MantisBT - A PHP based bugtracking system
3
4# MantisBT is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 2 of the License, or
7# (at your option) any later version.
8#
9# MantisBT is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with MantisBT.  If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * Mantis Core Wiki Plugins
19 * @copyright Copyright 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
20 * @copyright Copyright 2002  MantisBT Team - mantisbt-dev@lists.sourceforge.net
21 * @link http://www.mantisbt.org
22 * @package MantisBT
23 * @subpackage classes
24 */
25
26/**
27 * requires MantisWikiPlugin.class
28 */
29require_once( 'MantisWikiPlugin.class.php' );
30
31/**
32 * Base that uses the old style wiki definitions from config_inc.php
33 */
34abstract class MantisCoreWikiPlugin extends MantisWikiPlugin {
35	/**
36	 * Config Function
37	 * @return array
38	 */
39	function config() {
40		return array(
41			'root_namespace' => config_get_global( 'wiki_root_namespace' ),
42			'engine_url' => config_get_global( 'wiki_engine_url' ),
43		);
44	}
45}
46
47/**
48 * Basic Dokuwiki support with old-style wiki integration.
49 */
50class MantisCoreDokuwikiPlugin extends MantisCoreWikiPlugin {
51	/**
52	 * Plugin Registration
53	 * @return void
54	 */
55	function register() {
56		$this->name = 'MantisBT Dokuwiki Integration';
57		$this->version = '0.1';
58		$this->requires = array(
59			'MantisCore' => '2.0.0',
60		);
61	}
62
63	/**
64	 * Wiki base url
65	 *
66	 * @param integer $p_project_id A project identifier.
67	 * @return string
68	 */
69	function base_url( $p_project_id = null ) {
70		$t_base = plugin_config_get( 'engine_url' ) . 'doku.php?id=';
71
72		$t_namespace = plugin_config_get( 'root_namespace' );
73		if( !is_blank( $t_namespace ) ) {
74			$t_base .= $t_namespace . ':';
75		}
76
77		if( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) {
78			$t_base .= urlencode( project_get_name( $p_project_id ) ) . ':';
79		}
80		return $t_base;
81	}
82
83	/**
84	 * Wiki link to a bug
85	 *
86	 * @param integer $p_event  Event.
87	 * @param integer $p_bug_id A bug identifier.
88	 * @return string
89	 */
90	function link_bug( $p_event, $p_bug_id ) {
91		return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) .  'issue:' . (int)$p_bug_id;
92	}
93
94	/**
95	 * Wiki link to a project
96	 *
97	 * @param integer $p_event      Event.
98	 * @param integer $p_project_id A project identifier.
99	 * @return string
100	 */
101	function link_project( $p_event, $p_project_id ) {
102		return $this->base_url( $p_project_id ) . 'start';
103	}
104}
105
106/**
107 * Basic MediaWiki support with old-style wiki integration.
108 */
109class MantisCoreMediaWikiPlugin extends MantisCoreWikiPlugin {
110	/**
111	 * Plugin Registration
112	 * @return void
113	 */
114	function register() {
115		$this->name = 'MantisBT MediaWiki Integration';
116		$this->version = '0.1';
117		$this->requires = array(
118			'MantisCore' => '2.0.0',
119		);
120	}
121
122	/**
123	 * Wiki base url
124	 *
125	 * @param integer $p_project_id A project identifier.
126	 * @return string
127	 */
128	function base_url( $p_project_id = null ) {
129		$t_base = plugin_config_get( 'engine_url' ) . 'index.php/';
130		if( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) {
131			$t_base .= urlencode( project_get_name( $p_project_id ) ) . ':';
132		} else {
133			$t_base .= plugin_config_get( 'root_namespace' );
134		}
135		return $t_base;
136	}
137
138	/**
139	 * Wiki link to a bug
140	 *
141	 * @param integer $p_event  Event.
142	 * @param integer $p_bug_id A bug identifier.
143	 * @return string
144	 */
145	function link_bug( $p_event, $p_bug_id ) {
146		return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . (int)$p_bug_id;
147	}
148
149	/**
150	 * Wiki link to a project
151	 *
152	 * @param integer $p_event      Event.
153	 * @param integer $p_project_id A project identifier.
154	 * @return string
155	 */
156	function link_project( $p_event, $p_project_id ) {
157		return $this->base_url( $p_project_id ) . 'Main_Page';
158	}
159}
160
161/**
162 * Basic Twiki support with old-style wiki integration.
163 */
164class MantisCoreTwikiPlugin extends MantisCoreWikiPlugin {
165	/**
166	 * Plugin Registration
167	 * @return void
168	 */
169	function register() {
170		$this->name = 'MantisBT Twiki Integration';
171		$this->version = '0.1';
172		$this->requires = array(
173			'MantisCore' => '2.0.0',
174		);
175	}
176
177	/**
178	 * Wiki base url
179	 *
180	 * @param integer $p_project_id A project identifier.
181	 * @return string
182	 */
183	function base_url( $p_project_id = null ) {
184		$t_base = plugin_config_get( 'engine_url' );
185
186		$t_namespace = plugin_config_get( 'root_namespace' );
187		if( !is_blank( $t_namespace ) ) {
188			$t_base .= $t_namespace . '/';
189		}
190
191		if( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) {
192			$t_base .= urlencode( project_get_name( $p_project_id ) ) . '/';
193		}
194		return $t_base;
195	}
196
197	/**
198	 * Wiki link to a bug
199	 *
200	 * @param integer $p_event  Event.
201	 * @param integer $p_bug_id A bug identifier.
202	 * @return string
203	 */
204	function link_bug( $p_event, $p_bug_id ) {
205		return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . 'IssueNumber' . (int)$p_bug_id;
206	}
207
208	/**
209	 * Wiki link to a project
210	 *
211	 * @param integer $p_event 	    Event.
212	 * @param integer $p_project_id A project identifier.
213	 * @return string
214	 */
215	function link_project( $p_event, $p_project_id ) {
216		return $this->base_url( $p_project_id );
217	}
218}
219
220/**
221 * Basic WikkaWiki support with old-style wiki integration.
222 */
223class MantisCoreWikkaWikiPlugin extends MantisCoreWikiPlugin {
224	/**
225	 * Plugin Registration
226	 * @return void
227	 */
228	function register() {
229		$this->name = 'MantisBT WikkaWiki Integration';
230		$this->version = '0.1';
231		$this->requires = array(
232			'MantisCore' => '2.0.0',
233		);
234	}
235
236	/**
237	 * Wiki base url
238	 *
239	 * @param integer $p_project_id A project identifier.
240	 * @return string
241	 */
242	function base_url( $p_project_id = null ) {
243		$t_base = plugin_config_get( 'engine_url' ) . 'wikka.php?wakka=';
244
245		$t_namespace = ucfirst( plugin_config_get( 'root_namespace' ) );
246		if( !is_blank( $t_namespace ) ) {
247			$t_base .= $t_namespace;
248		}
249
250		if( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) {
251			$t_base .= urlencode( project_get_name( $p_project_id ) );
252		}
253		return $t_base;
254	}
255
256	/**
257	 * Wiki link to a bug
258	 *
259	 * @param integer $p_event  Event.
260	 * @param integer $p_bug_id A bug identifier.
261	 * @return string
262	 */
263	function link_bug( $p_event, $p_bug_id ) {
264		return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . 'Issue' . (int)$p_bug_id;
265	}
266
267	/**
268	 * Wiki link to a project
269	 *
270	 * @param integer $p_event      Event.
271	 * @param integer $p_project_id A project identifier.
272	 * @return string
273	 */
274	function link_project( $p_event, $p_project_id ) {
275		return $this->base_url( $p_project_id ) . 'Start';
276	}
277}
278
279/**
280 * Basic Xwiki support with old-style wiki integration.
281 */
282class MantisCoreXwikiPlugin extends MantisCoreWikiPlugin {
283	/**
284	 * Plugin Registration
285	 * @return void
286	 */
287	function register() {
288		$this->name = 'MantisBT Xwiki Integration';
289		$this->version = '0.1';
290		$this->requires = array(
291			'MantisCore' => '2.0.0',
292		);
293	}
294
295	/**
296	 * Wiki base url
297	 *
298	 * @param integer $p_project_id A project identifier.
299	 * @return string
300	 */
301	function base_url( $p_project_id = null ) {
302		$t_base = plugin_config_get( 'engine_url' );
303		if( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) {
304			$t_base .= urlencode( project_get_name( $p_project_id ) ) . '/';
305		} else {
306			$t_base .= plugin_config_get( 'root_namespace' );
307		}
308		return $t_base;
309	}
310
311	/**
312	 * Wiki link to a bug
313	 *
314	 * @param integer $p_event  Event.
315	 * @param integer $p_bug_id A bug identifier.
316	 * @return string
317	 */
318	function link_bug( $p_event, $p_bug_id ) {
319		return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) .  (int)$p_bug_id;
320	}
321
322	/**
323	 * Wiki link to a project
324	 *
325	 * @param integer $p_event      Event.
326	 * @param integer $p_project_id A project identifier.
327	 * @return string
328	 */
329	function link_project( $p_event, $p_project_id ) {
330		return $this->base_url( $p_project_id ) . 'Main_Page';
331	}
332}
333