Simple Link-to-Wiki-addon for 1.0.8

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
treczoks
Posts: 2
Joined: 16 Nov 2007, 13:31

Simple Link-to-Wiki-addon for 1.0.8

Post by treczoks »

Hi!

I'm quite new here (I installed Mantis for the first time two days ago), but I already have written a little hack to link our mantis and our inhouse developer-wiki.

I wanted to be able to put simple links from mantis notes into the wiki in a similar syntax as people here are used to. So I patched one core file (core/string_api.php) to recognize links of the types "[[Topic|Title]]" and "[[Topic]]" and replace them by "[Wiki] <a href="(confgured URL)Topic">Title</a>" (if no Title is given, replace by Topic). The URL is configurable (e.g. $g_wiki_url = 'https://ew/Wiki/index.php/';) in config.inc.php and the patch is against core/string_api.php:

Code: Select all

103a104
> 		$p_string = string_process_wiki_link( $p_string );
107a109,121
> 	# --------------------
> 	# Process Wiki links
> 	function string_process_wiki_link( $p_string ){
> 		$t_wiki_url = config_get( 'wiki_url' );
> 		# Wiki-links a la [[Title|Displayname]]
> 		$t_replace_with = '[Wiki] <a href="'.$t_wiki_url.'\\1">\\2</a>';
> 		$p_string = preg_replace( '/\[\[([^\|\]]*)\|([^\]]*)\]\]/', $t_replace_with, $p_string );
> 		# Wiki-links a la [[Title]]
> 		$t_replace_with = '[Wiki] <a href="'.$t_wiki_url.'\\1">\\1</a>';
> 		$p_string = preg_replace( '/\[\[([^\]]*)\]\]/', $t_replace_with, $p_string );
> 		return $p_string;
> 	}
> 	
Feel free to use it as you like.

Yours, Christian Treczoks
vboctor
Site Admin
Posts: 1293
Joined: 13 Feb 2005, 22:11
Location: Redmond, Washington
Contact:

Re: Simple Link-to-Wiki-addon for 1.0.8

Post by vboctor »

Thanks for your contribution. This is a useful behavior that has been talked about before. In 1.2.x, I am expecting such behavior will either be part of the specific wiki integration drivers or standalone plugins in 1.2. The advantage of being part of the wiki is that the syntax can be different depending on which Wiki engine Mantis is being integrated with. This will guarantee that the format is consistent with what the users are familiar with. If we go with the driver option, then there can be a default syntax that is used unless overriden by the specific driver.
Migrate your MantisBT to the MantisHub Cloud
Post Reply