View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0011544 | mantisbt | wiki | public | 2010-02-23 15:05 | 2010-02-24 03:51 |
Reporter | PAB | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | acknowledged | Resolution | open | ||
Product Version | 1.2.0 | ||||
Summary | 0011544: Make CoreWikiPlugins more configureable | ||||
Description | The CoreWikiPlugins have many hardcoded strings. I attached a patch, which adds params for changing the name of the projectpage and the prefix for issuepages. Also i added an option for using rawurlencode() instead of urlencode() to avoid having the whitespace replaced by '+'. | ||||
Tags | patch | ||||
Attached Files | wiki.patch (7,357 bytes)
From fb7dab3f6009bba985f35468a57db22a9c80b184 Mon Sep 17 00:00:00 2001 From: Philipp Beckmann <philippbeckmann@pabnet.de> Date: Tue, 23 Feb 2010 20:57:09 +0100 Subject: [PATCH] Made CoreWikiPlugins more configureable --- config_defaults_inc.php | 18 +++++++++ core/classes/MantisCoreWikiPlugin.class.php | 52 ++++++++++++++++----------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 2c7c9cf..8f971fa 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -3599,6 +3599,24 @@ $g_wiki_root_namespace = 'mantis'; */ $g_wiki_engine_url = $t_protocol . '://' . $t_host . '/%wiki_engine%/'; +/** + * Wiki Prefix for issues pages + * @global string $g_wiki_issue_page + */ +$g_wiki_issue_page = "Issue "; + +/** + * Wiki Name of main project page + * @global string $g_wiki_project_page + */ +$g_wiki_project_page = "Main_Page"; + +/** +* Wiki Use rawurlencode() instead of urlencode() for sitenames? +* @global int $g_wiki_use_raw_encode +*/ +$g_wiki_use_raw_encode = OFF; + /******************** * Recently Visited * ********************/ diff --git a/core/classes/MantisCoreWikiPlugin.class.php b/core/classes/MantisCoreWikiPlugin.class.php index 4e7f333..092ce6d 100644 --- a/core/classes/MantisCoreWikiPlugin.class.php +++ b/core/classes/MantisCoreWikiPlugin.class.php @@ -39,8 +39,18 @@ abstract class MantisCoreWikiPlugin extends MantisWikiPlugin { return array( 'root_namespace' => config_get_global( 'wiki_root_namespace' ), 'engine_url' => config_get_global( 'wiki_engine_url' ), + 'issue_page' => config_get_global( 'wiki_issue_page' ), + 'project_page' => config_get_global( 'wiki_project_page' ), + 'use_raw_encode' => config_get_global( 'wiki_use_raw_encode' ), ); } + + function encode_name( $p_name ){ + if( plugin_config_get( 'use_raw_encode' ) == ON ) + return( rawurlencode( $p_name ) ); + else + return( urlencode( $p_name ) ); + } } /** @@ -63,21 +73,21 @@ class MantisCoreDokuwikiPlugin extends MantisCoreWikiPlugin { $t_namespace = plugin_config_get( 'root_namespace' ); if ( !is_blank( $t_namespace ) ) { - $t_base .= urlencode( $t_namespace ) . ':'; + $t_base .= $this->encode_name( $t_namespace ) . ':'; } if ( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) { - $t_base .= urlencode( project_get_name( $p_project_id ) ) . ':'; + $t_base .= $this->encode_name( project_get_name( $p_project_id ) ) . ':'; } return $t_base; } function link_bug( $p_event, $p_bug_id ) { - return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . 'issue:' . (int)$p_bug_id; + return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . plugin_config_get( 'issue_page' ) . (int)$p_bug_id; } function link_project( $p_event, $p_project_id ) { - return $this->base_url( $p_project_id ) . 'start'; + return $this->base_url( $p_project_id ) . plugin_config_get( 'project_page' ); } } @@ -99,26 +109,26 @@ class MantisCoreMediaWikiPlugin extends MantisCoreWikiPlugin { function base_url( $p_project_id=null ) { $t_base = plugin_config_get( 'engine_url' ) . 'index.php/'; if ( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) { - $t_base .= urlencode( project_get_name( $p_project_id ) ) . ':'; + $t_base .= $this->encode_name( project_get_name( $p_project_id ) ) . ':'; } else { - $t_base .= urlencode( plugin_config_get( 'root_namespace' ) ); + $t_base .= $this->encode_name( plugin_config_get( 'root_namespace' ) ); } 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; + return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . plugin_config_get( 'issue_page' ) . (int)$p_bug_id; } function link_project( $p_event, $p_project_id ) { - return $this->base_url( $p_project_id ) . 'Main_Page'; + return $this->base_url( $p_project_id ) . plugin_config_get( 'project_page' ); } } /** * Basic Twiki support with old-style wiki integration. * @package MantisBT - * @subpackage classes + * @subpackage classes */ class MantisCoreTwikiPlugin extends MantisCoreWikiPlugin { @@ -135,21 +145,21 @@ class MantisCoreTwikiPlugin extends MantisCoreWikiPlugin { $t_namespace = plugin_config_get( 'root_namespace' ); if ( !is_blank( $t_namespace ) ) { - $t_base .= urlencode( $t_namespace ) . '/'; + $t_base .= $this->encode_name( $t_namespace ) . '/'; } if ( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) { - $t_base .= urlencode( project_get_name( $p_project_id ) ) . '/'; + $t_base .= $this->encode_name( project_get_name( $p_project_id ) ) . '/'; } return $t_base; } function link_bug( $p_event, $p_bug_id ) { - return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . 'IssueNumber' . (int)$p_bug_id; + return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . plugin_config_get( 'issue_page' ) . (int)$p_bug_id; } function link_project( $p_event, $p_project_id ) { - return $this->base_url( $p_project_id ); + return $this->base_url( $p_project_id ) . plugin_config_get( 'project_page' ); } } @@ -173,21 +183,21 @@ class MantisCoreWikkaWikiPlugin extends MantisCoreWikiPlugin { $t_namespace = ucfirst( plugin_config_get( 'root_namespace' ) ); if ( !is_blank( $t_namespace ) ) { - $t_base .= urlencode( $t_namespace ); + $t_base .= $this->encode_name( $t_namespace ); } if ( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) { - $t_base .= urlencode( project_get_name( $p_project_id ) ); + $t_base .= $this->encode_name( project_get_name( $p_project_id ) ); } return $t_base; } function link_bug( $p_event, $p_bug_id ) { - return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . 'Issue' . (int)$p_bug_id; + return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . plugin_config_get( 'issue_page' ) . (int)$p_bug_id; } function link_project( $p_event, $p_project_id ) { - return $this->base_url( $p_project_id ) . 'Start'; + return $this->base_url( $p_project_id ) . plugin_config_get( 'project_page' ); } } @@ -209,18 +219,18 @@ class MantisCoreXwikiPlugin extends MantisCoreWikiPlugin { function base_url( $p_project_id=null ) { $t_base = plugin_config_get( 'engine_url' ); if ( !is_null( $p_project_id ) && $p_project_id != ALL_PROJECTS ) { - $t_base .= urlencode( project_get_name( $p_project_id ) ) . '/'; + $t_base .= $this->encode_name( project_get_name( $p_project_id ) ) . '/'; } else { - $t_base .= urlencode( plugin_config_get( 'root_namespace' ) ); + $t_base .= $this->encode_name( plugin_config_get( 'root_namespace' ) ); } 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; + return $this->base_url( bug_get_field( $p_bug_id, 'project_id' ) ) . plugin_config_get( 'issue_page' ) . (int)$p_bug_id; } function link_project( $p_event, $p_project_id ) { - return $this->base_url( $p_project_id ) . 'Main_Page'; + return $this->base_url( $p_project_id ) . plugin_config_get( 'project_page' ); } } -- 1.6.5.1.1367.gcd48 | ||||