Skip to content

Commit

Permalink
Initial implementation of 7075 which integrates DokuWiki with Mantis.
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4126 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
vboctor committed Aug 9, 2006
1 parent a42fb35 commit 2bd4dff
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 13 deletions.
5 changes: 4 additions & 1 deletion bug_view_advanced_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_view_advanced_page.php,v 1.77 2006-01-01 02:56:40 thraxisp Exp $
# $Id: bug_view_advanced_page.php,v 1.78 2006-08-09 07:55:01 vboctor Exp $
# --------------------------------------------------------

require_once( 'core.php' );
Expand Down Expand Up @@ -74,6 +74,9 @@
<?php
}
?>
<span class="small">
<?php print_bracket_link( 'wiki.php?id='.$f_bug_id, lang_get( 'wiki' ) ) ?>
</span>
</td>

<!-- prev/next links -->
Expand Down
5 changes: 4 additions & 1 deletion bug_view_page.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: bug_view_page.php,v 1.78 2006-01-01 02:56:40 thraxisp Exp $
# $Id: bug_view_page.php,v 1.79 2006-08-09 07:55:01 vboctor Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -76,6 +76,9 @@
<?php
}
?>
<span class="small">
<?php print_bracket_link( 'wiki.php?id='.$f_bug_id, lang_get( 'wiki' ) ) ?>
</span>
</td>

<!-- prev/next links -->
Expand Down
18 changes: 17 additions & 1 deletion config_defaults_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: config_defaults_inc.php,v 1.305 2006-08-06 07:12:41 vboctor Exp $
# $Id: config_defaults_inc.php,v 1.306 2006-08-09 07:55:01 vboctor Exp $
# --------------------------------------------------------


Expand Down Expand Up @@ -1733,4 +1733,20 @@
# )
# );
$g_custom_group_actions = array();

#####################
# Wiki Integration
#####################

# Wiki Integration Enabled?
$g_wiki_enable = OFF;

# Wiki Engine
$g_wiki_engine = 'dokuwiki';

# Wiki namespace to be used as root for all pages relating to this mantis installation.
$g_wiki_root_namespace = 'mantis';

# URL under which the wiki engine is hosted. Must be on the same server.
$g_wiki_engine_url = $t_protocol . '://' . $t_host . '/%wiki_engine%/';
?>
40 changes: 33 additions & 7 deletions core/html_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: html_api.php,v 1.193 2006-05-16 23:59:28 vboctor Exp $
# $Id: html_api.php,v 1.194 2006-08-09 07:55:01 vboctor Exp $
# --------------------------------------------------------

###########################################################################
Expand Down Expand Up @@ -57,6 +57,7 @@
require_once( $t_core_dir . 'authentication_api.php' );
require_once( $t_core_dir . 'user_api.php' );
require_once( $t_core_dir . 'rss_api.php' );
require_once( $t_core_dir . 'wiki_api.php' );

$g_rss_feed_url = null;

Expand Down Expand Up @@ -517,6 +518,12 @@ function print_menu() {
$t_menu_options[] = '<a href="proj_doc_page.php">' . lang_get( 'docs_link' ) . '</a>';
}

# Project Wiki
if ( wiki_is_enabled() ) {
$t_current_project = helper_get_current_project();
$t_menu_options[] = '<a href="wiki.php?type=project&id=' . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>';
}

# Manage Users (admins) or Manage Project (managers) or Manage Custom Fields
$t_show_access = min( config_get( 'manage_project_threshold' ), config_get( 'manage_custom_fields_threshold' ), ADMINISTRATOR );
if ( access_has_global_level( $t_show_access) || access_has_any_project( $t_show_access ) ) {
Expand Down Expand Up @@ -874,22 +881,28 @@ function html_status_percentage_legend() {

# --------------------
# Print an html button inside a form
function html_button ( $p_action, $p_button_text, $p_fields = null ) {
function html_button ( $p_action, $p_button_text, $p_fields = null, $p_method = 'post' ) {
$p_action = urlencode( $p_action );
$p_button_text = string_attribute( $p_button_text );
if ( null === $p_fields ) {
$p_fields = array();
}

PRINT "<form method=\"post\" action=\"$p_action\">\n";


if ( strtolower( $p_method ) == 'get' ) {
$t_method = 'get';
} else {
$t_method = 'post';
}

PRINT "<form method=\"$t_method\" action=\"$p_action\">\n";

foreach ( $p_fields as $key => $val ) {
$key = string_attribute( $key );
$val = string_attribute( $val );

PRINT " <input type=\"hidden\" name=\"$key\" value=\"$val\" />\n";
}

PRINT " <input type=\"submit\" class=\"button\" value=\"$p_button_text\" />\n";
PRINT "</form>\n";
}
Expand Down Expand Up @@ -1100,6 +1113,19 @@ function html_button_bug_delete( $p_bug_id ) {
}
}

# --------------------
# Print a button to create a wiki page
function html_button_wiki( $p_bug_id ) {
if ( ON == config_get( 'wiki_enable' ) ) {
if ( access_has_bug_level( config_get( 'update_bug_threshold' ), $p_bug_id ) ) {
html_button( 'wiki.php',
lang_get_defaulted( 'Wiki' ),
array( 'id' => $p_bug_id, 'type' => 'issue' ),
'get' );
}
}
}

# --------------------
# Print all buttons for view bug pages
function html_buttons_view_bug_page( $p_bug_id ) {
Expand Down
65 changes: 65 additions & 0 deletions core/wiki_api.php
@@ -0,0 +1,65 @@
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2006 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: wiki_api.php,v 1.1 2006-08-09 07:55:01 vboctor Exp $
# --------------------------------------------------------

require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'helper_api.php' );
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'utility_api.php' );
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'database_api.php' );
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'authentication_api.php' );
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'gpc_api.php' );
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'access_api.php' );
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'project_api.php' );
require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'wiki_' . config_get( 'wiki_engine' ) . '_api.php' );

# ----------------------
# Calls a function with the specified name (not including prefix) and given the array
# of parameters supplied. An example prefix is "wiki_dokuwiki_".
function wiki_call( $p_function, $p_args_array ) {
$t_function = 'wiki_' . config_get_global( 'wiki_engine' ) . '_' . $p_function;
return call_user_func_array( $t_function, $p_args_array );
}

# ----------------------
# Checks if the Wiki feature is enabled or not.
function wiki_is_enabled() {
return config_get( 'wiki_enable' ) == ON;
}

# ----------------------
# Ensures that the wiki feature is enabled.
function wiki_ensure_enabled() {
if ( !wiki_is_enabled() ) {
access_denied();
}
}

# ----------------------
# Gets the wiki URL for the issue with the specified id.
function wiki_get_url_for_issue( $p_issue_id ) {
return wiki_call( 'get_url_for_issue', array( $p_issue_id ) );
}

# ----------------------
# Gets the wiki URL for the project with the specified id. The project id can be ALL_PROJECTS.
function wiki_get_url_for_project( $p_project_id ) {
return wiki_call( 'get_url_for_project', array( $p_project_id ) );
}

# ----------------------
/*
function wiki_string_display_links( $p_string ) {
if ( !wiki_is_enabled() ) {
return $p_string;
}
return wiki_call( 'string_display_links', array( $p_string ) );
}
*/
?>
91 changes: 91 additions & 0 deletions core/wiki_dokuwiki_api.php
@@ -0,0 +1,91 @@
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2006 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: wiki_dokuwiki_api.php,v 1.1 2006-08-09 07:55:01 vboctor Exp $
# --------------------------------------------------------

# ----------------------
# Gets the URL for the page with the specified page id. This function is used
# internally by this API.
function wiki_dokuwiki_get_url_for_page_id( $p_page_id ) {
$t_root_url = config_get_global( 'wiki_engine_url' );

$t_root_namespace = config_get( 'wiki_root_namespace' );

if ( is_blank( $t_root_namespace ) ) {
$t_page_id = $p_page_id;
} else {
$t_page_id = $t_root_namespace . ':' . $p_page_id;
}

return $t_root_url . 'doku.php?id=' . urlencode( $t_page_id );
}

# ----------------------
# Gets the page id for the specified issue. The page id can then be converted
# to a URL using wiki_dokuwiki_get_url_for_page_id().
function wiki_dokuwiki_get_page_id_for_issue( $p_issue_id ) {
$c_issue_id = db_prepare_int( $p_issue_id );

$t_project_id = bug_get_field( $p_issue_id, 'project_id' );
$t_project_name = project_get_name( $t_project_id );

# create a namespace for the project to contain all project documentation.
# create within it a namespace for issues. This is to allow the creation of a _template.txt
# file to act as the template for issues belonging to this project.
return $t_project_name . ':issue:' . $c_issue_id;
}

# ----------------------
# Gets the page url for the specified issue id.
function wiki_dokuwiki_get_url_for_issue( $p_issue_id ) {
return wiki_dokuwiki_get_url_for_page_id( wiki_dokuwiki_get_page_id_for_issue( $p_issue_id ) );
}

# ----------------------
# Gets the page id for the specified project. The project id can be ALL_PROJECTS
# The page id can then be converted to URL using wiki_dokuwiki_get_url_for_page_id().
function wiki_dokuwiki_get_page_id_for_project( $p_project_id ) {
$t_home = 'start';
if ( $p_project_id == ALL_PROJECTS ) {
return $t_home;
} else {
$t_project_name = project_get_name( $p_project_id );
return $t_project_name . ':' . $t_home;
}
}

# ----------------------
# Get URL for the specified project id. The project is can be ALL_PROJECTS.
function wiki_dokuwiki_get_url_for_project( $p_project_id ) {
return wiki_dokuwiki_get_url_for_page_id( wiki_dokuwiki_get_page_id_for_project( $p_project_id ) );
}

/*
function wiki_dokuwiki_string_display_links( $p_string ) {
#$t_string = $p_string;
#$t_string = str_replace( '[[', '{', $p_string );
$t_wiki_web = config_get_global( 'wiki_engine_url' );
preg_match_all( '/(^|.+?)(?:(?<=^|\W)' . '\[\[' . '([a-zA-Z0-9_:]+)\]\]|$)/s',
$p_string, $t_matches, PREG_SET_ORDER );
$t_result = '';
foreach ( $t_matches as $t_match ) {
$t_result .= $t_match[1];
if ( isset( $t_match[2] ) ) {
$t_result .= '<a href="' . wiki_dokuwiki_get_url_for_page_id( $t_match[2] ) . '">[[' . $t_match[2] . ']]</a>';
}
}
return $t_result;
}
*/
?>
8 changes: 5 additions & 3 deletions lang/strings_english.txt
Expand Up @@ -9,11 +9,11 @@
###########################################################################
# English strings for Mantis
# -------------------------------------------------
# $Revision: 1.274 $
# $Revision: 1.275 $
# $Author: vboctor $
# $Date: 2006-08-06 07:12:41 $
# $Date: 2006-08-09 07:55:01 $
#
# $Id: strings_english.txt,v 1.274 2006-08-06 07:12:41 vboctor Exp $
# $Id: strings_english.txt,v 1.275 2006-08-09 07:55:01 vboctor Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -1306,4 +1306,6 @@ $s_before = 'Before' ;
$s_after = 'After' ;
$s_on_or_after = 'On Or After' ;

# wiki related strings
$s_wiki = 'Wiki';
?>
31 changes: 31 additions & 0 deletions wiki.php
@@ -0,0 +1,31 @@
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2006 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: wiki.php,v 1.1 2006-08-09 07:55:01 vboctor Exp $
# --------------------------------------------------------
?>
<?php
require_once( 'core.php' );

$t_core_path = config_get( 'core_path' );

require_once( $t_core_path . 'wiki_api.php' );

$f_id = gpc_get_int( 'id' );
$f_type = gpc_get_string( 'type', 'issue' );

if ( $f_type == 'project' ) {
project_ensure_exists( $f_id );
$t_url = wiki_get_url_for_project( $f_id );
} else {
bug_ensure_exists( $f_id );
$t_url = wiki_get_url_for_issue( $f_id );
}

print_header_redirect( $t_url );
?>

0 comments on commit 2bd4dff

Please sign in to comment.