Own wiki integration plugin

Post about your customizations to share with others.

Moderators: Developer, Contributor

Post Reply
PAB
Posts: 6
Joined: 18 Feb 2010, 20:29

Own wiki integration plugin

Post by PAB »

Hello,

is there a way to replace the integrated wikiplugin of 1.2.0 RC2 with a custom one?

Greetings
PAB
atrol
Site Admin
Posts: 8577
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Own wiki integration plugin

Post by atrol »

Yes
Please use Search before posting and read the Manual
PAB
Posts: 6
Joined: 18 Feb 2010, 20:29

Re: Own wiki integration plugin

Post by PAB »

Do you have some more info for me? (I know, i didn't explicitely requested... :roll: )
atrol
Site Admin
Posts: 8577
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Own wiki integration plugin

Post by atrol »

Short question (still the same after your second post) without any more information.
I don't know where to start and can not imagine which information will be helpful for you or not.

You should start with some kind of:
I installed MantisBT 1.2.0rc2, I tried out the Wiki module which is delivered with Wiki XYZ.
But this module does not fit my expections, because I want to have .......
I tried out various configurations, but this was still not what I want ....
After that I had a look at the sourcecode and ....
Please use Search before posting and read the Manual
PAB
Posts: 6
Joined: 18 Feb 2010, 20:29

Re: Own wiki integration plugin

Post by PAB »

I already patched the MediaWikiPlugin in core/classes/MantisCoreWikiPlugin.class.php, but want to separate my changes from the original code.

I had a look at core/wiki_api.php and found wiki_init with a hardcoded switch-case. My question is, how do i integrate a custom wikiplugin? Can I hook into the legacy style wiki integration or do i need to write a general plugin, which, for example, adds the "Wiki"-link in mantis' toolbar by itself?
atrol
Site Admin
Posts: 8577
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Own wiki integration plugin

Post by atrol »

much better :wink:

First to clarify: the current implementation is not a plugin in the way plugin's are meant in 1.2.x. (even if the name of it contains plugin)

There are at least two alternatives:

Change the current code, so that the hardcoding is replaced by customization.
Provide the patches to the developers.
They will have a look on it, and when they think that it's good enough, your changes will be merged into upcoming versions.
So there is no more need for you to seperate anything of your code.

However my opinion regarding long term development of MantisBT is, that this should be implemented as a seperated plugin (and after having the plugin the current implementation in core should be removed)
Check, whether the new plugin system provides enough functionality for it, I suggest it will.

If you think about starting with development of a new plugin, you should start with a source repository for it at: http://git.mantisforge.org/

First you should write to mantisbt-dev@lists.sourceforge.net where developers are listening.
I am pretty sure they will provide you with better technical and internal information than I am able to do.
But write more than: "Is there a way to replace the integrated wikiplugin of 1.2.0 RC2 with a custom one?" :wink:
Please use Search before posting and read the Manual
PAB
Posts: 6
Joined: 18 Feb 2010, 20:29

Re: Own wiki integration plugin

Post by PAB »

I think i'll try to post my changes as a patch. None the less, i'll ask on the mailinglist to clarify the "official" way to integrate wikiplugins.

Thanks for your help.
atrol
Site Admin
Posts: 8577
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Own wiki integration plugin

Post by atrol »

If you think about providing patches you should read this:
http://www.mantisforge.org/dev/manual/e ... ubmit.html
Please use Search before posting and read the Manual
PAB
Posts: 6
Joined: 18 Feb 2010, 20:29

Re: Own wiki integration plugin

Post by PAB »

Just played around with wikiplugins and found the way to implement: Inherit from MantisWikiPlugin and leave "wiki_engine" empty.

Here is a stub:

plugins/MyWiki/MyWiki.php

Code: Select all

<?php

require_once( config_get( 'class_path' ) . 'MantisWikiPlugin.class.php' );

class MyWikiPlugin extends MantisWikiPlugin {
	function register() {
		$this->name = 'Authors\' MyWikiPlugin';
		$this->description = 'Own MediaWiki link';

		$this->version = '0.1';
		$this->requires		= array(
			'MantisCore' => '1.2.0',
		);

		$this->author		= 'Author';
		$this->contact		= 'author@example.com';
		$this->url			= 'http://www.example.com';
	}
	
	function config(){}
	
	function base_url( $p_project_id=null ) {
		$t_base = 'http://example.com/mediawiki/index.php/';
		if ( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) {
			$t_base .= urlencode( project_get_name( $p_project_id ) ) . ':';
		} else {
			$t_base .= urlencode( 'root:'  );
		}
		return $t_base;
	}

	function link_bug( $p_event, $p_bug_id ) {
		return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . (int)$p_bug_id;
	}

	function link_project( $p_event, $p_project_id ) {
		return $this->base_url( $p_project_id ) . 'Main_Page';
	}
}
config_inc.php

Code: Select all

$g_wiki_enable = ON;
$g_wiki_engine = '';
atrol
Site Admin
Posts: 8577
Joined: 26 Mar 2008, 21:37
Location: Germany

Re: Own wiki integration plugin

Post by atrol »

Thank you for posting this information and also the patch you attached at http://www.mantisbt.org/bugs/view.php?id=11544
Please use Search before posting and read the Manual
wxfhnmdedc
Posts: 1
Joined: 01 Jun 2011, 07:33

Re: Own wiki integration plugin

Post by wxfhnmdedc »

I had a look at core/wiki_api.php and found wiki_init with a hardcoded switch-case. My question is, how do i integrate a custom wikiplugin? Can I hook into the legacy style wiki integration or do i need to write a general plugin, which, for example, adds the "Wiki"-link in mantis' toolbar by itself?
Post Reply