View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0008253 | mantisbt | integration | public | 2007-08-10 15:25 | 2008-08-12 09:37 |
Reporter | vboctor | Assigned To | jreese | ||
Priority | normal | Severity | feature | Reproducibility | have not tried |
Status | closed | Resolution | suspended | ||
Product Version | 1.1.0a4 | ||||
Summary | 0008253: Improve Mantis/DokuWiki integration theme | ||||
Description | Following is an example: | ||||
Tags | No tags attached. | ||||
Attached Files | mantis-urls-2007-11-08.patch (22,850 bytes)
diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 185a83e..089d221 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -96,9 +96,15 @@ $t_host = 'www.example.com'; } - $t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) ); - if ( '/' == $t_path || '\\' == $t_path ) { - $t_path = ''; + $t_docroot = $_SERVER['DOCUMENT_ROOT']; + $t_file_path = __FILE__; + if ( preg_match( '@'.$t_docroot.'(.*)@', $t_file_path, $t_matches ) ) { + $t_path = dirname( strip_tags( $t_matches[1] ) ); + } else { + $t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) ); + if ( '/' == $t_path || '\\' == $t_path ) { + $t_path = ''; + } } $g_path = $t_protocol . '://' . $t_host . $t_path.'/'; @@ -110,6 +116,9 @@ # requires trailing / $g_icon_path = '%path%images/'; + # Short web path without the domain name + $g_short_path = $t_path . '/'; + # absolute path to your installation. Requires trailing / or \ # Symbolic links are allowed since release 0.17.3 $g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; diff --git a/core/helper_api.php b/core/helper_api.php index fe845d3..2542a20 100644 --- a/core/helper_api.php +++ b/core/helper_api.php @@ -421,4 +421,9 @@ auth_is_user_authenticated() && access_has_global_level( config_get( 'show_queries_threshold' ) ); } + + # Return a URL relative to the web root, compatible with other applications + function helper_mantis_url( $p_url ) { + return config_get( 'short_path' ) . $p_url; + } ?> diff --git a/core/html_api.php b/core/html_api.php index 4a0fe8a..1c660ee 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -98,7 +98,7 @@ global $g_rss_feed_url; if ( $g_rss_feed_url !== null ) { - echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"$g_rss_feed_url\" />"; + echo '<link rel="alternate" type="application/rss+xml" title="RSS" href="', $g_rss_feed_url, ' />'; } } @@ -112,7 +112,7 @@ html_content_type(); include( config_get( 'meta_include_file' ) ); html_rss_link(); - echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'; + echo '<link rel="shortcut icon" href="', helper_mantis_url( 'images/favicon.ico' ), '" type="image/x-icon" />'; html_title( $p_page_title ); html_head_javascript(); } @@ -266,16 +266,16 @@ # (6a) Javascript... function html_head_javascript() { if ( ON == config_get( 'use_javascript' ) ) { - echo "\t" . '<script type="text/javascript" language="JavaScript" src="javascript/common.js">'; - echo '</script>' . "\n"; - echo "\t" . '<script type="text/JavaScript" src="javascript/ajax.js">'; - echo '</script>' . "\n"; + echo "\t", '<script type="text/javascript" language="JavaScript" src="', helper_mantis_url( 'javascript/common.js' ), '">'; + echo '</script>', "\n"; + echo "\t", '<script type="text/JavaScript" src="', helper_mantis_url( 'javascript/ajax.js' ), '">'; + echo '</script>', "\n"; global $g_enable_projax; if ( $g_enable_projax ) { - echo '<script type="text/javascript" src="javascript/projax/prototype.js"></script>'; - echo '<script type="text/javascript" src="javascript/projax/scriptaculous.js"></script>'; + echo '<script type="text/javascript" src="', helper_mantis_url( 'javascript/projax/prototype.js' ), '"></script>'; + echo '<script type="text/javascript" src="', helper_mantis_url( 'javascript/projax/scriptaculous.js' ), '"></script>'; } } } @@ -316,7 +316,7 @@ } echo '<div align="', $t_align, '">'; - echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img border="0" width="242" height="102" alt="Mantis Bugtracker" src="images/mantis_logo.gif" /></a>'; + echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img border="0" alt="Mantis Bugtracker" src="' . helper_mantis_url( 'images/mantis_logo.gif' ) . '" /></a>'; echo '</div>'; } @@ -342,9 +342,9 @@ } $t_return_page = string_url( $t_return_page ); - PRINT lang_get( 'anonymous' ) . ' | <a href="login_page.php?return=' . $t_return_page . '">' . lang_get( 'login_link' ) . '</a>'; + PRINT lang_get( 'anonymous' ) . ' | <a href="' . helper_mantis_url( 'login_page.php?return=' . $t_return_page ) . '">' . lang_get( 'login_link' ) . '</a>'; if ( config_get( 'allow_signup' ) == ON ) { - PRINT ' | <a href="signup_page.php">' . lang_get( 'signup_link' ) . '</a>'; + PRINT ' | <a href="' . helper_mantis_url( signup_page.php ) . '">' . lang_get( 'signup_link' ) . '</a>'; } } else { echo lang_get( 'logged_in_as' ), ": <span class=\"italic\">", string_display( $t_username ), "</span> <span class=\"small\">"; @@ -356,7 +356,7 @@ PRINT "<span class=\"italic\">$t_now</span>"; PRINT '</td>'; PRINT '<td class="login-info-right">'; - PRINT '<form method="post" name="form_set_project" action="set_project.php">'; + PRINT '<form method="post" name="form_set_project" action="' . helper_mantis_url( 'set_project.php' ) . '">'; echo lang_get( 'email_project' ), ': '; if ( ON == config_get( 'show_extended_project_browser' ) ) { @@ -375,7 +375,7 @@ if ( OFF != config_get( 'rss_enabled' ) ) { # Link to RSS issues feed for the selected project, including authentication details. PRINT '<a href="' . rss_get_issues_feed_url() . '">'; - PRINT '<img src="images/rss.gif" alt="' . lang_get( 'rss' ) . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; + PRINT '<img src="' . helper_mantis_url( 'images/rss.gif' ) . '" alt="' . lang_get( 'rss' ) . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; PRINT '</a>'; } @@ -473,7 +473,7 @@ } echo '</td><td><div align="right">'; - echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="images/mantis_logo_button.gif" width="88" height="35" alt="Powered by Mantis Bugtracker" border="0" /></a>'; + echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="' . helper_mantis_url( 'images/mantis_logo_button.gif' ) . '" width="88" height="35" alt="Powered by Mantis Bugtracker" border="0" /></a>'; echo '</div></td></tr></table>'; } @@ -525,13 +525,13 @@ $t_menu_options = array(); # Main Page - $t_menu_options[] = '<a href="main_page.php">' . lang_get( 'main_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'main_page.php">' ) . lang_get( 'main_link' ) . '</a>'; # My View - $t_menu_options[] = '<a href="my_view_page.php">' . lang_get( 'my_view_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'my_view_page.php">' ) . lang_get( 'my_view_link' ) . '</a>'; # View Bugs - $t_menu_options[] = '<a href="view_all_bug_page.php">' . lang_get( 'view_bugs_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'view_all_bug_page.php">' ) . lang_get( 'view_bugs_link' ) . '</a>'; # Report Bugs if ( access_has_project_level( config_get( 'report_bug_threshold' ) ) ) { @@ -540,27 +540,27 @@ # Changelog Page if ( access_has_project_level( config_get( 'view_changelog_threshold' ) ) ) { - $t_menu_options[] = '<a href="changelog_page.php">' . lang_get( 'changelog_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'changelog_page.php">' ) . lang_get( 'changelog_link' ) . '</a>'; } # Roadmap Page if ( access_has_project_level( config_get( 'roadmap_view_threshold' ) ) ) { - $t_menu_options[] = '<a href="roadmap_page.php">' . lang_get( 'roadmap_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'roadmap_page.php">' ) . lang_get( 'roadmap_link' ) . '</a>'; } # Summary Page if ( access_has_project_level( config_get( 'view_summary_threshold' ) ) ) { - $t_menu_options[] = '<a href="summary_page.php">' . lang_get( 'summary_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'summary_page.php">' ) . lang_get( 'summary_link' ) . '</a>'; } # Project Documentation Page if( ON == config_get( 'enable_project_documentation' ) ) { - $t_menu_options[] = '<a href="proj_doc_page.php">' . lang_get( 'docs_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'proj_doc_page.php">' ) . lang_get( 'docs_link' ) . '</a>'; } # Project Wiki if ( wiki_is_enabled() ) { - $t_menu_options[] = '<a href="wiki.php?type=project&id=' . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'wiki.php?type=project&id=' ) . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>'; } # Manage Users (admins) or Manage Project (managers) or Manage Custom Fields @@ -568,13 +568,13 @@ if ( access_has_global_level( $t_show_access) || access_has_any_project( $t_show_access ) ) { $t_current_project = helper_get_current_project(); if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { - $t_link = 'manage_user_page.php'; + $t_link = helper_mantis_url( 'manage_user_page.php' ); } else { if ( access_has_project_level( config_get( 'manage_project_threshold' ), $t_current_project ) && ( $t_current_project <> ALL_PROJECTS ) ) { - $t_link = 'manage_proj_edit_page.php?project_id=' . $t_current_project; + $t_link = helper_mantis_url( 'manage_proj_edit_page.php?project_id=' ) . $t_current_project; } else { - $t_link = 'manage_proj_page.php'; + $t_link = helper_mantis_url( 'manage_proj_page.php' ); } } $t_menu_options[] = "<a href=\"$t_link\">" . lang_get( 'manage_link' ) . '</a>'; @@ -584,31 +584,31 @@ if ( access_has_project_level( config_get( 'manage_news_threshold' ) ) ) { # Admin can edit news for All Projects (site-wide) if ( ( ALL_PROJECTS != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) { - $t_menu_options[] = '<a href="news_menu_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'news_menu_page.php">' ) . lang_get( 'edit_news_link' ) . '</a>'; } else { - $t_menu_options[] = '<a href="login_select_proj_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'login_select_proj_page.php">' ) . lang_get( 'edit_news_link' ) . '</a>'; } } # Account Page (only show accounts that are NOT protected) if ( OFF == $t_protected ) { - $t_menu_options[] = '<a href="account_page.php">' . lang_get( 'account_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'account_page.php">' ) . lang_get( 'account_link' ) . '</a>'; } # Add custom options $t_custom_options = prepare_custom_menu_options( 'main_menu_custom_options' ); $t_menu_options = array_merge( $t_menu_options, $t_custom_options ); if ( config_get('time_tracking_enabled') && config_get('time_tracking_with_billing') ) - $t_menu_options[] = '<a href="billing_page.php">' . lang_get( 'time_tracking_billing_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'billing_page.php">' ) . lang_get( 'time_tracking_billing_link' ) . '</a>'; # Logout (no if anonymously logged in) if ( !current_user_is_anonymous() ) { - $t_menu_options[] = '<a href="logout_page.php">' . lang_get( 'logout_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'logout_page.php">' ) . lang_get( 'logout_link' ) . '</a>'; } PRINT implode( $t_menu_options, ' | ' ); PRINT '</td>'; PRINT '<td class="menu right nowrap">'; - PRINT '<form method="post" action="jump_to_bug.php">'; + PRINT '<form method="post" action="' . helper_mantis_url( 'jump_to_bug.php">' ) ; if ( ON == config_get( 'use_javascript' ) ) { $t_bug_label = lang_get( 'issue_id' ); @@ -633,10 +633,10 @@ PRINT '<table class="width100" cellspacing="0">'; PRINT '<tr>'; PRINT '<td class="menu">'; - PRINT '<a href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</a>'; + PRINT '<a href="' . helper_mantis_url( 'set_project.php?project_id=' . ALL_PROJECTS ) . '">' . lang_get( 'all_projects' ) . '</a>'; foreach ( $t_project_ids as $t_id ) { - PRINT " | <a href=\"set_project.php?project_id=$t_id\">" . string_display( project_get_field( $t_id, 'name' ) ) . '</a>'; + PRINT ' | <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_id ) . ' ">' . string_display( project_get_field( $t_id, 'name' ) ) . '</a>'; print_subproject_menu_bar( $t_id, $t_id . ';' ); } @@ -651,7 +651,7 @@ $t_subprojects = current_user_get_accessible_subprojects( $p_project_id ); $t_char = ':'; foreach ( $t_subprojects as $t_subproject ) { - PRINT "$t_char <a href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a>'; + PRINT $t_char . ' <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $p_parents . $t_subproject ) . ' ">' . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a>'; print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' ); $t_char = ','; } @@ -664,12 +664,12 @@ $t_icon_path = config_get( 'icon_path' ); PRINT '<br />'; - PRINT '<a href="summary_page.php"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_status.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_priority.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_severity.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_category.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_resolution.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>'; + PRINT '<a href="' . helper_mantis_url( 'summary_page.php' ) . '"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_status.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_priority.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_severity.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_category.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_resolution.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>'; } } @@ -711,22 +711,22 @@ PRINT '<br /><div align="center">'; if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { - print_bracket_link( $t_manage_user_page, lang_get( 'manage_users_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_user_page ), lang_get( 'manage_users_link' ) ); } if ( access_has_project_level( config_get( 'manage_project_threshold' ) ) ) { - print_bracket_link( $t_manage_project_menu_page, lang_get( 'manage_projects_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_project_menu_page ), lang_get( 'manage_projects_link' ) ); } if ( access_has_global_level( config_get( 'manage_custom_fields_threshold' ) ) ) { - print_bracket_link( $t_manage_custom_field_page, lang_get( 'manage_custom_field_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_custom_field_page ), lang_get( 'manage_custom_field_link' ) ); } if ( access_has_global_level( config_get( 'manage_global_profile_threshold' ) ) ) { - print_bracket_link( $t_manage_prof_menu_page, lang_get( 'manage_global_profiles_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_prof_menu_page ), lang_get( 'manage_global_profiles_link' ) ); } if ( access_has_global_level( config_get( 'manage_plugin_threshold' ) ) ) { - print_bracket_link( $t_manage_plugin_page, lang_get( 'manage_plugin_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_plugin_page ), lang_get( 'manage_plugin_link' ) ); } if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { - print_bracket_link( $t_manage_config_page, lang_get( 'manage_config_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_config_page ), lang_get( 'manage_config_link' ) ); } # print_bracket_link( $t_documentation_page, lang_get( 'documentation_link' ) ); PRINT '</div>'; @@ -762,11 +762,11 @@ PRINT '<br /><div align="center">'; if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { - print_bracket_link( $t_configuration_report, lang_get_defaulted( 'configuration_report' ) ); - print_bracket_link( $t_permissions_summary_report, lang_get( 'permissions_summary_report' ) ); - print_bracket_link( $t_manage_work_threshold, lang_get( 'manage_threshold_config' ) ); - print_bracket_link( $t_manage_workflow, lang_get( 'manage_workflow_config' ) ); - print_bracket_link( $t_manage_email, lang_get( 'manage_email_config' ) ); + print_bracket_link( helper_mantis_url( $t_configuration_report ), lang_get_defaulted( 'configuration_report' ) ); + print_bracket_link( helper_mantis_url( $t_permissions_summary_report ), lang_get( 'permissions_summary_report' ) ); + print_bracket_link( helper_mantis_url( $t_manage_work_threshold ), lang_get( 'manage_threshold_config' ) ); + print_bracket_link( helper_mantis_url( $t_manage_workflow ), lang_get( 'manage_workflow_config' ) ); + print_bracket_link( helper_mantis_url( $t_manage_email ), lang_get( 'manage_email_config' ) ); } PRINT '</div>'; } @@ -787,15 +787,15 @@ case $t_account_sponsor_page : $t_account_sponsor_page = ''; break; } - print_bracket_link( $t_account_page, lang_get( 'account_link' ) ); - print_bracket_link( $t_account_prefs_page, lang_get( 'change_preferences_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_page ), lang_get( 'account_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_prefs_page ), lang_get( 'change_preferences_link' ) ); if ( access_has_project_level( config_get( 'add_profile_threshold' ) ) ) { - print_bracket_link( $t_account_profile_menu_page, lang_get( 'manage_profiles_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_profile_menu_page ), lang_get( 'manage_profiles_link' ) ); } if ( ( config_get( 'enable_sponsorship' ) == ON ) && ( access_has_project_level( config_get( 'view_sponsorship_total_threshold' ) ) ) && !current_user_is_anonymous() ) { - print_bracket_link( $t_account_sponsor_page, lang_get( 'my_sponsorship' ) ); + print_bracket_link( helper_mantis_url( $t_account_sponsor_page ), lang_get( 'my_sponsorship' ) ); } } @@ -813,10 +813,10 @@ case $t_proj_doc_add_page : $t_proj_doc_add_page = ''; break; } - print_bracket_link( $t_documentation_html, lang_get( 'user_documentation' ) ); - print_bracket_link( $t_proj_doc_page, lang_get( 'project_documentation' ) ); + print_bracket_link( helper_mantis_url( $t_documentation_html ), lang_get( 'user_documentation' ) ); + print_bracket_link( helper_mantis_url( $t_proj_doc_page ), lang_get( 'project_documentation' ) ); if ( file_allow_project_upload() ) { - print_bracket_link( $t_proj_doc_add_page, lang_get( 'add_file' ) ); + print_bracket_link( helper_mantis_url( $t_proj_doc_add_page ), lang_get( 'add_file' ) ); } } @@ -836,8 +836,8 @@ case $t_summary_jpgraph_page: $t_summary_jpgraph_page = ''; break; } - print_bracket_link( $t_summary_page, lang_get( 'summary_link' ) ); - print_bracket_link( $t_summary_jpgraph_page, lang_get( 'summary_jpgraph_link' ) ); + print_bracket_link( helper_mantis_url( $t_summary_page ), lang_get( 'summary_link' ) ); + print_bracket_link( helper_mantis_url( $t_summary_jpgraph_page ), lang_get( 'summary_jpgraph_link' ) ); } PRINT '</div>'; } diff --git a/core/string_api.php b/core/string_api.php index 913b905..e029eef 100644 --- a/core/string_api.php +++ b/core/string_api.php @@ -503,6 +503,8 @@ $t_link = '<a href="'; if ( $p_fqdn ) { $t_link .= config_get( 'path' ); + } else { + $t_link .= config_get( 'short_path' ); } $t_link .= string_get_bug_view_url( $p_bug_id, $p_user_id ) . '"'; if ( $p_detail_info ) { @@ -526,6 +528,8 @@ $t_link = '<a href="'; if ( $p_fqdn ) { $t_link .= config_get( 'path' ); + } else { + $t_link .= config_get( 'short_path' ); } $t_link .= string_get_bugnote_view_url( $p_bug_id, $p_bugnote_id, $p_user_id ) . '"'; @@ -586,7 +590,7 @@ # account for the user preference and site override function string_get_bug_update_link( $p_bug_id, $p_user_id = null ) { $t_summary = string_attribute( bug_get_field( $p_bug_id, 'summary' ) ); - return '<a href="' . string_get_bug_update_url( $p_bug_id, $p_user_id ) . '" title="' . $t_summary . '">' . bug_format_id( $p_bug_id ) . '</a>'; + return '<a href="' . helper_mantis_url( string_get_bug_update_url( $p_bug_id, $p_user_id ) ) . '" title="' . $t_summary . '">' . bug_format_id( $p_bug_id ) . '</a>'; } # -------------------- @@ -607,7 +611,7 @@ # return an href anchor that links to a bug REPORT page for the given bug # account for the user preference and site override function string_get_bug_report_link( $p_user_id = null ) { - return '<a href="' . string_get_bug_report_url( $p_user_id ) . '">' . lang_get( 'report_bug_link' ) . '</a>'; + return '<a href="' . helper_mantis_url( string_get_bug_report_url( $p_user_id ) ) . '">' . lang_get( 'report_bug_link' ) . '</a>'; } # -------------------- mantis-urls-2007-11-09.patch (23,515 bytes)
diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 185a83e..078e5d5 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -96,9 +96,23 @@ $t_host = 'www.example.com'; } - $t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) ); - if ( '/' == $t_path || '\\' == $t_path ) { - $t_path = ''; + # Get server root to compare with path to this file + $t_docroot = $_SERVER['DOCUMENT_ROOT']; + $t_file_path = __FILE__; + + # Check for Windows server to modify file path. + if ( strtolower( "win" == substr( PHP_OS, 0, 3 ) ) ) { + $t_file_path = str_replace( '\\', '/', $t_file_path ); + } + + # Extract the unique directory path of this file relative to the server's documunt root + if ( preg_match( '@'.$t_docroot.'(.*)@', $t_file_path, $t_matches ) ) { + $t_path = dirname( strip_tags( $t_matches[1] ) ); + } else { + $t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) ); + if ( '/' == $t_path || '\\' == $t_path ) { + $t_path = ''; + } } $g_path = $t_protocol . '://' . $t_host . $t_path.'/'; @@ -110,6 +124,9 @@ # requires trailing / $g_icon_path = '%path%images/'; + # Short web path without the domain name + $g_short_path = $t_path . '/'; + # absolute path to your installation. Requires trailing / or \ # Symbolic links are allowed since release 0.17.3 $g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; diff --git a/core/helper_api.php b/core/helper_api.php index fe845d3..2542a20 100644 --- a/core/helper_api.php +++ b/core/helper_api.php @@ -421,4 +421,9 @@ auth_is_user_authenticated() && access_has_global_level( config_get( 'show_queries_threshold' ) ); } + + # Return a URL relative to the web root, compatible with other applications + function helper_mantis_url( $p_url ) { + return config_get( 'short_path' ) . $p_url; + } ?> diff --git a/core/html_api.php b/core/html_api.php index b836767..c591872 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -98,7 +98,7 @@ global $g_rss_feed_url; if ( $g_rss_feed_url !== null ) { - echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"$g_rss_feed_url\" />"; + echo '<link rel="alternate" type="application/rss+xml" title="RSS" href="', $g_rss_feed_url, ' />'; } } @@ -112,7 +112,7 @@ html_content_type(); include( config_get( 'meta_include_file' ) ); html_rss_link(); - echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'; + echo '<link rel="shortcut icon" href="', helper_mantis_url( 'images/favicon.ico' ), '" type="image/x-icon" />'; html_title( $p_page_title ); html_head_javascript(); } @@ -270,16 +270,16 @@ # (6a) Javascript... function html_head_javascript() { if ( ON == config_get( 'use_javascript' ) ) { - echo "\t" . '<script type="text/javascript" language="JavaScript" src="javascript/common.js">'; - echo '</script>' . "\n"; - echo "\t" . '<script type="text/JavaScript" src="javascript/ajax.js">'; - echo '</script>' . "\n"; + echo "\t", '<script type="text/javascript" language="JavaScript" src="', helper_mantis_url( 'javascript/common.js' ), '">'; + echo '</script>', "\n"; + echo "\t", '<script type="text/JavaScript" src="', helper_mantis_url( 'javascript/ajax.js' ), '">'; + echo '</script>', "\n"; global $g_enable_projax; if ( $g_enable_projax ) { - echo '<script type="text/javascript" src="javascript/projax/prototype.js"></script>'; - echo '<script type="text/javascript" src="javascript/projax/scriptaculous.js"></script>'; + echo '<script type="text/javascript" src="', helper_mantis_url( 'javascript/projax/prototype.js' ), '"></script>'; + echo '<script type="text/javascript" src="', helper_mantis_url( 'javascript/projax/scriptaculous.js' ), '"></script>'; } } } @@ -320,7 +320,7 @@ } echo '<div align="', $t_align, '">'; - echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img border="0" width="242" height="102" alt="Mantis Bugtracker" src="images/mantis_logo.gif" /></a>'; + echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img border="0" alt="Mantis Bugtracker" src="' . helper_mantis_url( 'images/mantis_logo.gif' ) . '" /></a>'; echo '</div>'; } @@ -346,9 +346,9 @@ } $t_return_page = string_url( $t_return_page ); - PRINT lang_get( 'anonymous' ) . ' | <a href="login_page.php?return=' . $t_return_page . '">' . lang_get( 'login_link' ) . '</a>'; + PRINT lang_get( 'anonymous' ) . ' | <a href="' . helper_mantis_url( 'login_page.php?return=' . $t_return_page ) . '">' . lang_get( 'login_link' ) . '</a>'; if ( config_get( 'allow_signup' ) == ON ) { - PRINT ' | <a href="signup_page.php">' . lang_get( 'signup_link' ) . '</a>'; + PRINT ' | <a href="' . helper_mantis_url( signup_page.php ) . '">' . lang_get( 'signup_link' ) . '</a>'; } } else { echo lang_get( 'logged_in_as' ), ": <span class=\"italic\">", string_display( $t_username ), "</span> <span class=\"small\">"; @@ -360,7 +360,7 @@ PRINT "<span class=\"italic\">$t_now</span>"; PRINT '</td>'; PRINT '<td class="login-info-right">'; - PRINT '<form method="post" name="form_set_project" action="set_project.php">'; + PRINT '<form method="post" name="form_set_project" action="' . helper_mantis_url( 'set_project.php' ) . '">'; echo lang_get( 'email_project' ), ': '; if ( ON == config_get( 'show_extended_project_browser' ) ) { @@ -379,7 +379,7 @@ if ( OFF != config_get( 'rss_enabled' ) ) { # Link to RSS issues feed for the selected project, including authentication details. PRINT '<a href="' . rss_get_issues_feed_url() . '">'; - PRINT '<img src="images/rss.gif" alt="' . lang_get( 'rss' ) . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; + PRINT '<img src="' . helper_mantis_url( 'images/rss.gif' ) . '" alt="' . lang_get( 'rss' ) . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; PRINT '</a>'; } @@ -475,7 +475,7 @@ } echo '</td><td><div align="right">'; - echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="images/mantis_logo_button.gif" width="88" height="35" alt="Powered by Mantis Bugtracker" border="0" /></a>'; + echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="' . helper_mantis_url( 'images/mantis_logo_button.gif' ) . '" width="88" height="35" alt="Powered by Mantis Bugtracker" border="0" /></a>'; echo '</div></td></tr></table>'; } @@ -527,13 +527,13 @@ $t_menu_options = array(); # Main Page - $t_menu_options[] = '<a href="main_page.php">' . lang_get( 'main_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'main_page.php">' ) . lang_get( 'main_link' ) . '</a>'; # My View - $t_menu_options[] = '<a href="my_view_page.php">' . lang_get( 'my_view_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'my_view_page.php">' ) . lang_get( 'my_view_link' ) . '</a>'; # View Bugs - $t_menu_options[] = '<a href="view_all_bug_page.php">' . lang_get( 'view_bugs_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'view_all_bug_page.php">' ) . lang_get( 'view_bugs_link' ) . '</a>'; # Report Bugs if ( access_has_project_level( config_get( 'report_bug_threshold' ) ) ) { @@ -542,27 +542,27 @@ # Changelog Page if ( access_has_project_level( config_get( 'view_changelog_threshold' ) ) ) { - $t_menu_options[] = '<a href="changelog_page.php">' . lang_get( 'changelog_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'changelog_page.php">' ) . lang_get( 'changelog_link' ) . '</a>'; } # Roadmap Page if ( access_has_project_level( config_get( 'roadmap_view_threshold' ) ) ) { - $t_menu_options[] = '<a href="roadmap_page.php">' . lang_get( 'roadmap_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'roadmap_page.php">' ) . lang_get( 'roadmap_link' ) . '</a>'; } # Summary Page if ( access_has_project_level( config_get( 'view_summary_threshold' ) ) ) { - $t_menu_options[] = '<a href="summary_page.php">' . lang_get( 'summary_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'summary_page.php">' ) . lang_get( 'summary_link' ) . '</a>'; } # Project Documentation Page if( ON == config_get( 'enable_project_documentation' ) ) { - $t_menu_options[] = '<a href="proj_doc_page.php">' . lang_get( 'docs_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'proj_doc_page.php">' ) . lang_get( 'docs_link' ) . '</a>'; } # Project Wiki if ( wiki_is_enabled() ) { - $t_menu_options[] = '<a href="wiki.php?type=project&id=' . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'wiki.php?type=project&id=' ) . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>'; } # Plugin / Event added options @@ -580,13 +580,13 @@ if ( access_has_global_level( $t_show_access) || access_has_any_project( $t_show_access ) ) { $t_current_project = helper_get_current_project(); if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { - $t_link = 'manage_user_page.php'; + $t_link = helper_mantis_url( 'manage_user_page.php' ); } else { if ( access_has_project_level( config_get( 'manage_project_threshold' ), $t_current_project ) && ( $t_current_project <> ALL_PROJECTS ) ) { - $t_link = 'manage_proj_edit_page.php?project_id=' . $t_current_project; + $t_link = helper_mantis_url( 'manage_proj_edit_page.php?project_id=' ) . $t_current_project; } else { - $t_link = 'manage_proj_page.php'; + $t_link = helper_mantis_url( 'manage_proj_page.php' ); } } $t_menu_options[] = "<a href=\"$t_link\">" . lang_get( 'manage_link' ) . '</a>'; @@ -596,31 +596,31 @@ if ( access_has_project_level( config_get( 'manage_news_threshold' ) ) ) { # Admin can edit news for All Projects (site-wide) if ( ( ALL_PROJECTS != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) { - $t_menu_options[] = '<a href="news_menu_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'news_menu_page.php">' ) . lang_get( 'edit_news_link' ) . '</a>'; } else { - $t_menu_options[] = '<a href="login_select_proj_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'login_select_proj_page.php">' ) . lang_get( 'edit_news_link' ) . '</a>'; } } # Account Page (only show accounts that are NOT protected) if ( OFF == $t_protected ) { - $t_menu_options[] = '<a href="account_page.php">' . lang_get( 'account_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'account_page.php">' ) . lang_get( 'account_link' ) . '</a>'; } # Add custom options $t_custom_options = prepare_custom_menu_options( 'main_menu_custom_options' ); $t_menu_options = array_merge( $t_menu_options, $t_custom_options ); if ( config_get('time_tracking_enabled') && config_get('time_tracking_with_billing') ) - $t_menu_options[] = '<a href="billing_page.php">' . lang_get( 'time_tracking_billing_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'billing_page.php">' ) . lang_get( 'time_tracking_billing_link' ) . '</a>'; # Logout (no if anonymously logged in) if ( !current_user_is_anonymous() ) { - $t_menu_options[] = '<a href="logout_page.php">' . lang_get( 'logout_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'logout_page.php">' ) . lang_get( 'logout_link' ) . '</a>'; } PRINT implode( $t_menu_options, ' | ' ); PRINT '</td>'; PRINT '<td class="menu right nowrap">'; - PRINT '<form method="post" action="jump_to_bug.php">'; + PRINT '<form method="post" action="' . helper_mantis_url( 'jump_to_bug.php">' ) ; if ( ON == config_get( 'use_javascript' ) ) { $t_bug_label = lang_get( 'issue_id' ); @@ -645,10 +645,10 @@ PRINT '<table class="width100" cellspacing="0">'; PRINT '<tr>'; PRINT '<td class="menu">'; - PRINT '<a href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</a>'; + PRINT '<a href="' . helper_mantis_url( 'set_project.php?project_id=' . ALL_PROJECTS ) . '">' . lang_get( 'all_projects' ) . '</a>'; foreach ( $t_project_ids as $t_id ) { - PRINT " | <a href=\"set_project.php?project_id=$t_id\">" . string_display( project_get_field( $t_id, 'name' ) ) . '</a>'; + PRINT ' | <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_id ) . ' ">' . string_display( project_get_field( $t_id, 'name' ) ) . '</a>'; print_subproject_menu_bar( $t_id, $t_id . ';' ); } @@ -663,7 +663,7 @@ $t_subprojects = current_user_get_accessible_subprojects( $p_project_id ); $t_char = ':'; foreach ( $t_subprojects as $t_subproject ) { - PRINT "$t_char <a href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a>'; + PRINT $t_char . ' <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $p_parents . $t_subproject ) . ' ">' . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a>'; print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' ); $t_char = ','; } @@ -676,12 +676,12 @@ $t_icon_path = config_get( 'icon_path' ); PRINT '<br />'; - PRINT '<a href="summary_page.php"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_status.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_priority.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_severity.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_category.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_resolution.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>'; + PRINT '<a href="' . helper_mantis_url( 'summary_page.php' ) . '"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_status.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_priority.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_severity.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_category.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_resolution.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>'; } } @@ -723,22 +723,22 @@ PRINT '<br /><div align="center">'; if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { - print_bracket_link( $t_manage_user_page, lang_get( 'manage_users_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_user_page ), lang_get( 'manage_users_link' ) ); } if ( access_has_project_level( config_get( 'manage_project_threshold' ) ) ) { - print_bracket_link( $t_manage_project_menu_page, lang_get( 'manage_projects_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_project_menu_page ), lang_get( 'manage_projects_link' ) ); } if ( access_has_global_level( config_get( 'manage_custom_fields_threshold' ) ) ) { - print_bracket_link( $t_manage_custom_field_page, lang_get( 'manage_custom_field_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_custom_field_page ), lang_get( 'manage_custom_field_link' ) ); } if ( access_has_global_level( config_get( 'manage_global_profile_threshold' ) ) ) { - print_bracket_link( $t_manage_prof_menu_page, lang_get( 'manage_global_profiles_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_prof_menu_page ), lang_get( 'manage_global_profiles_link' ) ); } if ( access_has_global_level( config_get( 'manage_plugin_threshold' ) ) ) { - print_bracket_link( $t_manage_plugin_page, lang_get( 'manage_plugin_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_plugin_page ), lang_get( 'manage_plugin_link' ) ); } if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { - print_bracket_link( $t_manage_config_page, lang_get( 'manage_config_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_config_page ), lang_get( 'manage_config_link' ) ); } # print_bracket_link( $t_documentation_page, lang_get( 'documentation_link' ) ); PRINT '</div>'; @@ -774,11 +774,11 @@ PRINT '<br /><div align="center">'; if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { - print_bracket_link( $t_configuration_report, lang_get_defaulted( 'configuration_report' ) ); - print_bracket_link( $t_permissions_summary_report, lang_get( 'permissions_summary_report' ) ); - print_bracket_link( $t_manage_work_threshold, lang_get( 'manage_threshold_config' ) ); - print_bracket_link( $t_manage_workflow, lang_get( 'manage_workflow_config' ) ); - print_bracket_link( $t_manage_email, lang_get( 'manage_email_config' ) ); + print_bracket_link( helper_mantis_url( $t_configuration_report ), lang_get_defaulted( 'configuration_report' ) ); + print_bracket_link( helper_mantis_url( $t_permissions_summary_report ), lang_get( 'permissions_summary_report' ) ); + print_bracket_link( helper_mantis_url( $t_manage_work_threshold ), lang_get( 'manage_threshold_config' ) ); + print_bracket_link( helper_mantis_url( $t_manage_workflow ), lang_get( 'manage_workflow_config' ) ); + print_bracket_link( helper_mantis_url( $t_manage_email ), lang_get( 'manage_email_config' ) ); } PRINT '</div>'; } @@ -799,15 +799,15 @@ case $t_account_sponsor_page : $t_account_sponsor_page = ''; break; } - print_bracket_link( $t_account_page, lang_get( 'account_link' ) ); - print_bracket_link( $t_account_prefs_page, lang_get( 'change_preferences_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_page ), lang_get( 'account_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_prefs_page ), lang_get( 'change_preferences_link' ) ); if ( access_has_project_level( config_get( 'add_profile_threshold' ) ) ) { - print_bracket_link( $t_account_profile_menu_page, lang_get( 'manage_profiles_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_profile_menu_page ), lang_get( 'manage_profiles_link' ) ); } if ( ( config_get( 'enable_sponsorship' ) == ON ) && ( access_has_project_level( config_get( 'view_sponsorship_total_threshold' ) ) ) && !current_user_is_anonymous() ) { - print_bracket_link( $t_account_sponsor_page, lang_get( 'my_sponsorship' ) ); + print_bracket_link( helper_mantis_url( $t_account_sponsor_page ), lang_get( 'my_sponsorship' ) ); } } @@ -825,10 +825,10 @@ case $t_proj_doc_add_page : $t_proj_doc_add_page = ''; break; } - print_bracket_link( $t_documentation_html, lang_get( 'user_documentation' ) ); - print_bracket_link( $t_proj_doc_page, lang_get( 'project_documentation' ) ); + print_bracket_link( helper_mantis_url( $t_documentation_html ), lang_get( 'user_documentation' ) ); + print_bracket_link( helper_mantis_url( $t_proj_doc_page ), lang_get( 'project_documentation' ) ); if ( file_allow_project_upload() ) { - print_bracket_link( $t_proj_doc_add_page, lang_get( 'add_file' ) ); + print_bracket_link( helper_mantis_url( $t_proj_doc_add_page ), lang_get( 'add_file' ) ); } } @@ -848,8 +848,8 @@ case $t_summary_jpgraph_page: $t_summary_jpgraph_page = ''; break; } - print_bracket_link( $t_summary_page, lang_get( 'summary_link' ) ); - print_bracket_link( $t_summary_jpgraph_page, lang_get( 'summary_jpgraph_link' ) ); + print_bracket_link( helper_mantis_url( $t_summary_page ), lang_get( 'summary_link' ) ); + print_bracket_link( helper_mantis_url( $t_summary_jpgraph_page ), lang_get( 'summary_jpgraph_link' ) ); } PRINT '</div>'; } diff --git a/core/plugin_api.php b/core/plugin_api.php index bd97952..44f32fc 100644 --- a/core/plugin_api.php +++ b/core/plugin_api.php @@ -107,7 +107,7 @@ function plugin_page( $p_page, $p_basename=null ) { } else { $t_current = $p_basename; } - return 'plugin.php?page='.$t_current.'/'.$p_page; + return helper_mantis_url( 'plugin.php?page='.$t_current.'/'.$p_page ); } /** diff --git a/core/string_api.php b/core/string_api.php index 0a616b8..16426f5 100644 --- a/core/string_api.php +++ b/core/string_api.php @@ -503,6 +503,8 @@ $t_link = '<a href="'; if ( $p_fqdn ) { $t_link .= config_get( 'path' ); + } else { + $t_link .= config_get( 'short_path' ); } $t_link .= string_get_bug_view_url( $p_bug_id, $p_user_id ) . '"'; if ( $p_detail_info ) { @@ -526,6 +528,8 @@ $t_link = '<a href="'; if ( $p_fqdn ) { $t_link .= config_get( 'path' ); + } else { + $t_link .= config_get( 'short_path' ); } $t_link .= string_get_bugnote_view_url( $p_bug_id, $p_bugnote_id, $p_user_id ) . '"'; @@ -586,7 +590,7 @@ # account for the user preference and site override function string_get_bug_update_link( $p_bug_id, $p_user_id = null ) { $t_summary = string_attribute( bug_get_field( $p_bug_id, 'summary' ) ); - return '<a href="' . string_get_bug_update_url( $p_bug_id, $p_user_id ) . '" title="' . $t_summary . '">' . bug_format_id( $p_bug_id ) . '</a>'; + return '<a href="' . helper_mantis_url( string_get_bug_update_url( $p_bug_id, $p_user_id ) ) . '" title="' . $t_summary . '">' . bug_format_id( $p_bug_id ) . '</a>'; } # -------------------- @@ -607,7 +611,7 @@ # return an href anchor that links to a bug REPORT page for the given bug # account for the user preference and site override function string_get_bug_report_link( $p_user_id = null ) { - return '<a href="' . string_get_bug_report_url( $p_user_id ) . '">' . lang_get( 'report_bug_link' ) . '</a>'; + return '<a href="' . helper_mantis_url( string_get_bug_report_url( $p_user_id ) ) . '">' . lang_get( 'report_bug_link' ) . '</a>'; } # -------------------- mantis-urls-2007-11-10.patch (23,388 bytes)
diff --git a/config_defaults_inc.php b/config_defaults_inc.php index 185a83e..702d175 100644 --- a/config_defaults_inc.php +++ b/config_defaults_inc.php @@ -96,9 +96,18 @@ $t_host = 'www.example.com'; } - $t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) ); - if ( '/' == $t_path || '\\' == $t_path ) { - $t_path = ''; + # Get server root to compare with path to this file + $t_docroot = $_SERVER['DOCUMENT_ROOT']; + $t_file_path = str_replace( DIRECTORY_SEPARATOR, '/', __FILE__ ); + + # Extract the unique directory path of this file relative to the server's documunt root + if ( preg_match( '@'.$t_docroot.'(.*)@', $t_file_path, $t_matches ) ) { + $t_path = dirname( strip_tags( $t_matches[1] ) ); + } else { + $t_path = dirname( strip_tags( $_SERVER['PHP_SELF'] ) ); + if ( '/' == $t_path || '\\' == $t_path ) { + $t_path = ''; + } } $g_path = $t_protocol . '://' . $t_host . $t_path.'/'; @@ -110,6 +119,9 @@ # requires trailing / $g_icon_path = '%path%images/'; + # Short web path without the domain name + $g_short_path = $t_path . '/'; + # absolute path to your installation. Requires trailing / or \ # Symbolic links are allowed since release 0.17.3 $g_absolute_path = dirname( __FILE__ ) . DIRECTORY_SEPARATOR; diff --git a/core/helper_api.php b/core/helper_api.php index fe845d3..64bd072 100644 --- a/core/helper_api.php +++ b/core/helper_api.php @@ -421,4 +421,9 @@ auth_is_user_authenticated() && access_has_global_level( config_get( 'show_queries_threshold' ) ); } + + # Return a URL relative to the web root, compatible with other applications + function helper_mantis_url( $p_url ) { + return config_get_global( 'short_path' ) . $p_url; + } ?> diff --git a/core/html_api.php b/core/html_api.php index b836767..c591872 100644 --- a/core/html_api.php +++ b/core/html_api.php @@ -98,7 +98,7 @@ global $g_rss_feed_url; if ( $g_rss_feed_url !== null ) { - echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"$g_rss_feed_url\" />"; + echo '<link rel="alternate" type="application/rss+xml" title="RSS" href="', $g_rss_feed_url, ' />'; } } @@ -112,7 +112,7 @@ html_content_type(); include( config_get( 'meta_include_file' ) ); html_rss_link(); - echo '<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />'; + echo '<link rel="shortcut icon" href="', helper_mantis_url( 'images/favicon.ico' ), '" type="image/x-icon" />'; html_title( $p_page_title ); html_head_javascript(); } @@ -270,16 +270,16 @@ # (6a) Javascript... function html_head_javascript() { if ( ON == config_get( 'use_javascript' ) ) { - echo "\t" . '<script type="text/javascript" language="JavaScript" src="javascript/common.js">'; - echo '</script>' . "\n"; - echo "\t" . '<script type="text/JavaScript" src="javascript/ajax.js">'; - echo '</script>' . "\n"; + echo "\t", '<script type="text/javascript" language="JavaScript" src="', helper_mantis_url( 'javascript/common.js' ), '">'; + echo '</script>', "\n"; + echo "\t", '<script type="text/JavaScript" src="', helper_mantis_url( 'javascript/ajax.js' ), '">'; + echo '</script>', "\n"; global $g_enable_projax; if ( $g_enable_projax ) { - echo '<script type="text/javascript" src="javascript/projax/prototype.js"></script>'; - echo '<script type="text/javascript" src="javascript/projax/scriptaculous.js"></script>'; + echo '<script type="text/javascript" src="', helper_mantis_url( 'javascript/projax/prototype.js' ), '"></script>'; + echo '<script type="text/javascript" src="', helper_mantis_url( 'javascript/projax/scriptaculous.js' ), '"></script>'; } } } @@ -320,7 +320,7 @@ } echo '<div align="', $t_align, '">'; - echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img border="0" width="242" height="102" alt="Mantis Bugtracker" src="images/mantis_logo.gif" /></a>'; + echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img border="0" alt="Mantis Bugtracker" src="' . helper_mantis_url( 'images/mantis_logo.gif' ) . '" /></a>'; echo '</div>'; } @@ -346,9 +346,9 @@ } $t_return_page = string_url( $t_return_page ); - PRINT lang_get( 'anonymous' ) . ' | <a href="login_page.php?return=' . $t_return_page . '">' . lang_get( 'login_link' ) . '</a>'; + PRINT lang_get( 'anonymous' ) . ' | <a href="' . helper_mantis_url( 'login_page.php?return=' . $t_return_page ) . '">' . lang_get( 'login_link' ) . '</a>'; if ( config_get( 'allow_signup' ) == ON ) { - PRINT ' | <a href="signup_page.php">' . lang_get( 'signup_link' ) . '</a>'; + PRINT ' | <a href="' . helper_mantis_url( signup_page.php ) . '">' . lang_get( 'signup_link' ) . '</a>'; } } else { echo lang_get( 'logged_in_as' ), ": <span class=\"italic\">", string_display( $t_username ), "</span> <span class=\"small\">"; @@ -360,7 +360,7 @@ PRINT "<span class=\"italic\">$t_now</span>"; PRINT '</td>'; PRINT '<td class="login-info-right">'; - PRINT '<form method="post" name="form_set_project" action="set_project.php">'; + PRINT '<form method="post" name="form_set_project" action="' . helper_mantis_url( 'set_project.php' ) . '">'; echo lang_get( 'email_project' ), ': '; if ( ON == config_get( 'show_extended_project_browser' ) ) { @@ -379,7 +379,7 @@ if ( OFF != config_get( 'rss_enabled' ) ) { # Link to RSS issues feed for the selected project, including authentication details. PRINT '<a href="' . rss_get_issues_feed_url() . '">'; - PRINT '<img src="images/rss.gif" alt="' . lang_get( 'rss' ) . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; + PRINT '<img src="' . helper_mantis_url( 'images/rss.gif' ) . '" alt="' . lang_get( 'rss' ) . '" style="border-style: none; margin: 5px; vertical-align: middle;" />'; PRINT '</a>'; } @@ -475,7 +475,7 @@ } echo '</td><td><div align="right">'; - echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="images/mantis_logo_button.gif" width="88" height="35" alt="Powered by Mantis Bugtracker" border="0" /></a>'; + echo '<a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="' . helper_mantis_url( 'images/mantis_logo_button.gif' ) . '" width="88" height="35" alt="Powered by Mantis Bugtracker" border="0" /></a>'; echo '</div></td></tr></table>'; } @@ -527,13 +527,13 @@ $t_menu_options = array(); # Main Page - $t_menu_options[] = '<a href="main_page.php">' . lang_get( 'main_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'main_page.php">' ) . lang_get( 'main_link' ) . '</a>'; # My View - $t_menu_options[] = '<a href="my_view_page.php">' . lang_get( 'my_view_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'my_view_page.php">' ) . lang_get( 'my_view_link' ) . '</a>'; # View Bugs - $t_menu_options[] = '<a href="view_all_bug_page.php">' . lang_get( 'view_bugs_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'view_all_bug_page.php">' ) . lang_get( 'view_bugs_link' ) . '</a>'; # Report Bugs if ( access_has_project_level( config_get( 'report_bug_threshold' ) ) ) { @@ -542,27 +542,27 @@ # Changelog Page if ( access_has_project_level( config_get( 'view_changelog_threshold' ) ) ) { - $t_menu_options[] = '<a href="changelog_page.php">' . lang_get( 'changelog_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'changelog_page.php">' ) . lang_get( 'changelog_link' ) . '</a>'; } # Roadmap Page if ( access_has_project_level( config_get( 'roadmap_view_threshold' ) ) ) { - $t_menu_options[] = '<a href="roadmap_page.php">' . lang_get( 'roadmap_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'roadmap_page.php">' ) . lang_get( 'roadmap_link' ) . '</a>'; } # Summary Page if ( access_has_project_level( config_get( 'view_summary_threshold' ) ) ) { - $t_menu_options[] = '<a href="summary_page.php">' . lang_get( 'summary_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'summary_page.php">' ) . lang_get( 'summary_link' ) . '</a>'; } # Project Documentation Page if( ON == config_get( 'enable_project_documentation' ) ) { - $t_menu_options[] = '<a href="proj_doc_page.php">' . lang_get( 'docs_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'proj_doc_page.php">' ) . lang_get( 'docs_link' ) . '</a>'; } # Project Wiki if ( wiki_is_enabled() ) { - $t_menu_options[] = '<a href="wiki.php?type=project&id=' . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'wiki.php?type=project&id=' ) . $t_current_project . '">' . lang_get( 'wiki' ) . '</a>'; } # Plugin / Event added options @@ -580,13 +580,13 @@ if ( access_has_global_level( $t_show_access) || access_has_any_project( $t_show_access ) ) { $t_current_project = helper_get_current_project(); if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { - $t_link = 'manage_user_page.php'; + $t_link = helper_mantis_url( 'manage_user_page.php' ); } else { if ( access_has_project_level( config_get( 'manage_project_threshold' ), $t_current_project ) && ( $t_current_project <> ALL_PROJECTS ) ) { - $t_link = 'manage_proj_edit_page.php?project_id=' . $t_current_project; + $t_link = helper_mantis_url( 'manage_proj_edit_page.php?project_id=' ) . $t_current_project; } else { - $t_link = 'manage_proj_page.php'; + $t_link = helper_mantis_url( 'manage_proj_page.php' ); } } $t_menu_options[] = "<a href=\"$t_link\">" . lang_get( 'manage_link' ) . '</a>'; @@ -596,31 +596,31 @@ if ( access_has_project_level( config_get( 'manage_news_threshold' ) ) ) { # Admin can edit news for All Projects (site-wide) if ( ( ALL_PROJECTS != helper_get_current_project() ) || ( access_has_project_level( ADMINISTRATOR ) ) ) { - $t_menu_options[] = '<a href="news_menu_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'news_menu_page.php">' ) . lang_get( 'edit_news_link' ) . '</a>'; } else { - $t_menu_options[] = '<a href="login_select_proj_page.php">' . lang_get( 'edit_news_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'login_select_proj_page.php">' ) . lang_get( 'edit_news_link' ) . '</a>'; } } # Account Page (only show accounts that are NOT protected) if ( OFF == $t_protected ) { - $t_menu_options[] = '<a href="account_page.php">' . lang_get( 'account_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'account_page.php">' ) . lang_get( 'account_link' ) . '</a>'; } # Add custom options $t_custom_options = prepare_custom_menu_options( 'main_menu_custom_options' ); $t_menu_options = array_merge( $t_menu_options, $t_custom_options ); if ( config_get('time_tracking_enabled') && config_get('time_tracking_with_billing') ) - $t_menu_options[] = '<a href="billing_page.php">' . lang_get( 'time_tracking_billing_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'billing_page.php">' ) . lang_get( 'time_tracking_billing_link' ) . '</a>'; # Logout (no if anonymously logged in) if ( !current_user_is_anonymous() ) { - $t_menu_options[] = '<a href="logout_page.php">' . lang_get( 'logout_link' ) . '</a>'; + $t_menu_options[] = '<a href="' . helper_mantis_url( 'logout_page.php">' ) . lang_get( 'logout_link' ) . '</a>'; } PRINT implode( $t_menu_options, ' | ' ); PRINT '</td>'; PRINT '<td class="menu right nowrap">'; - PRINT '<form method="post" action="jump_to_bug.php">'; + PRINT '<form method="post" action="' . helper_mantis_url( 'jump_to_bug.php">' ) ; if ( ON == config_get( 'use_javascript' ) ) { $t_bug_label = lang_get( 'issue_id' ); @@ -645,10 +645,10 @@ PRINT '<table class="width100" cellspacing="0">'; PRINT '<tr>'; PRINT '<td class="menu">'; - PRINT '<a href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</a>'; + PRINT '<a href="' . helper_mantis_url( 'set_project.php?project_id=' . ALL_PROJECTS ) . '">' . lang_get( 'all_projects' ) . '</a>'; foreach ( $t_project_ids as $t_id ) { - PRINT " | <a href=\"set_project.php?project_id=$t_id\">" . string_display( project_get_field( $t_id, 'name' ) ) . '</a>'; + PRINT ' | <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_id ) . ' ">' . string_display( project_get_field( $t_id, 'name' ) ) . '</a>'; print_subproject_menu_bar( $t_id, $t_id . ';' ); } @@ -663,7 +663,7 @@ $t_subprojects = current_user_get_accessible_subprojects( $p_project_id ); $t_char = ':'; foreach ( $t_subprojects as $t_subproject ) { - PRINT "$t_char <a href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a>'; + PRINT $t_char . ' <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $p_parents . $t_subproject ) . ' ">' . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a>'; print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' ); $t_char = ','; } @@ -676,12 +676,12 @@ $t_icon_path = config_get( 'icon_path' ); PRINT '<br />'; - PRINT '<a href="summary_page.php"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_status.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_priority.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_severity.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_category.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | '; - PRINT '<a href="summary_graph_imp_resolution.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>'; + PRINT '<a href="' . helper_mantis_url( 'summary_page.php' ) . '"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_status.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_priority.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_severity.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_category.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | '; + PRINT '<a href="' . helper_mantis_url( 'summary_graph_imp_resolution.php' ) . '"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>'; } } @@ -723,22 +723,22 @@ PRINT '<br /><div align="center">'; if ( access_has_global_level( config_get( 'manage_user_threshold' ) ) ) { - print_bracket_link( $t_manage_user_page, lang_get( 'manage_users_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_user_page ), lang_get( 'manage_users_link' ) ); } if ( access_has_project_level( config_get( 'manage_project_threshold' ) ) ) { - print_bracket_link( $t_manage_project_menu_page, lang_get( 'manage_projects_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_project_menu_page ), lang_get( 'manage_projects_link' ) ); } if ( access_has_global_level( config_get( 'manage_custom_fields_threshold' ) ) ) { - print_bracket_link( $t_manage_custom_field_page, lang_get( 'manage_custom_field_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_custom_field_page ), lang_get( 'manage_custom_field_link' ) ); } if ( access_has_global_level( config_get( 'manage_global_profile_threshold' ) ) ) { - print_bracket_link( $t_manage_prof_menu_page, lang_get( 'manage_global_profiles_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_prof_menu_page ), lang_get( 'manage_global_profiles_link' ) ); } if ( access_has_global_level( config_get( 'manage_plugin_threshold' ) ) ) { - print_bracket_link( $t_manage_plugin_page, lang_get( 'manage_plugin_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_plugin_page ), lang_get( 'manage_plugin_link' ) ); } if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { - print_bracket_link( $t_manage_config_page, lang_get( 'manage_config_link' ) ); + print_bracket_link( helper_mantis_url( $t_manage_config_page ), lang_get( 'manage_config_link' ) ); } # print_bracket_link( $t_documentation_page, lang_get( 'documentation_link' ) ); PRINT '</div>'; @@ -774,11 +774,11 @@ PRINT '<br /><div align="center">'; if ( access_has_project_level( config_get( 'view_configuration_threshold' ) ) ) { - print_bracket_link( $t_configuration_report, lang_get_defaulted( 'configuration_report' ) ); - print_bracket_link( $t_permissions_summary_report, lang_get( 'permissions_summary_report' ) ); - print_bracket_link( $t_manage_work_threshold, lang_get( 'manage_threshold_config' ) ); - print_bracket_link( $t_manage_workflow, lang_get( 'manage_workflow_config' ) ); - print_bracket_link( $t_manage_email, lang_get( 'manage_email_config' ) ); + print_bracket_link( helper_mantis_url( $t_configuration_report ), lang_get_defaulted( 'configuration_report' ) ); + print_bracket_link( helper_mantis_url( $t_permissions_summary_report ), lang_get( 'permissions_summary_report' ) ); + print_bracket_link( helper_mantis_url( $t_manage_work_threshold ), lang_get( 'manage_threshold_config' ) ); + print_bracket_link( helper_mantis_url( $t_manage_workflow ), lang_get( 'manage_workflow_config' ) ); + print_bracket_link( helper_mantis_url( $t_manage_email ), lang_get( 'manage_email_config' ) ); } PRINT '</div>'; } @@ -799,15 +799,15 @@ case $t_account_sponsor_page : $t_account_sponsor_page = ''; break; } - print_bracket_link( $t_account_page, lang_get( 'account_link' ) ); - print_bracket_link( $t_account_prefs_page, lang_get( 'change_preferences_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_page ), lang_get( 'account_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_prefs_page ), lang_get( 'change_preferences_link' ) ); if ( access_has_project_level( config_get( 'add_profile_threshold' ) ) ) { - print_bracket_link( $t_account_profile_menu_page, lang_get( 'manage_profiles_link' ) ); + print_bracket_link( helper_mantis_url( $t_account_profile_menu_page ), lang_get( 'manage_profiles_link' ) ); } if ( ( config_get( 'enable_sponsorship' ) == ON ) && ( access_has_project_level( config_get( 'view_sponsorship_total_threshold' ) ) ) && !current_user_is_anonymous() ) { - print_bracket_link( $t_account_sponsor_page, lang_get( 'my_sponsorship' ) ); + print_bracket_link( helper_mantis_url( $t_account_sponsor_page ), lang_get( 'my_sponsorship' ) ); } } @@ -825,10 +825,10 @@ case $t_proj_doc_add_page : $t_proj_doc_add_page = ''; break; } - print_bracket_link( $t_documentation_html, lang_get( 'user_documentation' ) ); - print_bracket_link( $t_proj_doc_page, lang_get( 'project_documentation' ) ); + print_bracket_link( helper_mantis_url( $t_documentation_html ), lang_get( 'user_documentation' ) ); + print_bracket_link( helper_mantis_url( $t_proj_doc_page ), lang_get( 'project_documentation' ) ); if ( file_allow_project_upload() ) { - print_bracket_link( $t_proj_doc_add_page, lang_get( 'add_file' ) ); + print_bracket_link( helper_mantis_url( $t_proj_doc_add_page ), lang_get( 'add_file' ) ); } } @@ -848,8 +848,8 @@ case $t_summary_jpgraph_page: $t_summary_jpgraph_page = ''; break; } - print_bracket_link( $t_summary_page, lang_get( 'summary_link' ) ); - print_bracket_link( $t_summary_jpgraph_page, lang_get( 'summary_jpgraph_link' ) ); + print_bracket_link( helper_mantis_url( $t_summary_page ), lang_get( 'summary_link' ) ); + print_bracket_link( helper_mantis_url( $t_summary_jpgraph_page ), lang_get( 'summary_jpgraph_link' ) ); } PRINT '</div>'; } diff --git a/core/plugin_api.php b/core/plugin_api.php index bd97952..44f32fc 100644 --- a/core/plugin_api.php +++ b/core/plugin_api.php @@ -107,7 +107,7 @@ function plugin_page( $p_page, $p_basename=null ) { } else { $t_current = $p_basename; } - return 'plugin.php?page='.$t_current.'/'.$p_page; + return helper_mantis_url( 'plugin.php?page='.$t_current.'/'.$p_page ); } /** diff --git a/core/string_api.php b/core/string_api.php index 0a616b8..16426f5 100644 --- a/core/string_api.php +++ b/core/string_api.php @@ -503,6 +503,8 @@ $t_link = '<a href="'; if ( $p_fqdn ) { $t_link .= config_get( 'path' ); + } else { + $t_link .= config_get( 'short_path' ); } $t_link .= string_get_bug_view_url( $p_bug_id, $p_user_id ) . '"'; if ( $p_detail_info ) { @@ -526,6 +528,8 @@ $t_link = '<a href="'; if ( $p_fqdn ) { $t_link .= config_get( 'path' ); + } else { + $t_link .= config_get( 'short_path' ); } $t_link .= string_get_bugnote_view_url( $p_bug_id, $p_bugnote_id, $p_user_id ) . '"'; @@ -586,7 +590,7 @@ # account for the user preference and site override function string_get_bug_update_link( $p_bug_id, $p_user_id = null ) { $t_summary = string_attribute( bug_get_field( $p_bug_id, 'summary' ) ); - return '<a href="' . string_get_bug_update_url( $p_bug_id, $p_user_id ) . '" title="' . $t_summary . '">' . bug_format_id( $p_bug_id ) . '</a>'; + return '<a href="' . helper_mantis_url( string_get_bug_update_url( $p_bug_id, $p_user_id ) ) . '" title="' . $t_summary . '">' . bug_format_id( $p_bug_id ) . '</a>'; } # -------------------- @@ -607,7 +611,7 @@ # return an href anchor that links to a bug REPORT page for the given bug # account for the user preference and site override function string_get_bug_report_link( $p_user_id = null ) { - return '<a href="' . string_get_bug_report_url( $p_user_id ) . '">' . lang_get( 'report_bug_link' ) . '</a>'; + return '<a href="' . helper_mantis_url( string_get_bug_report_url( $p_user_id ) ) . '">' . lang_get( 'report_bug_link' ) . '</a>'; } # -------------------- | ||||
He also has forum integrated |
|
Hi!
I have added a zip-file with all changes files. If I get write access to the wiki I would make a more detailed description. |
|
Thanks Silbaer for your contribution. I've created the Wiki page associated with this issue, you should have the necessary access to edit it. |
|
Reminder sent to: jreese jreese, you may want to collaborate with Silbaer on this, since you seem to have implemented such DokuWiki integration improvements in your instances. |
|
I've been working on a private branch for Mantis that changes the necessary portions of Mantis to behave better with other apps that use it's page header and footer. I will attach a patch here when I get it completed and tested. |
|
I've attached the first piece of this puzzle: a patch that provides a mechanism for creating a 'short_path' link that's directly relative to the webroot. Using this, I have modified all the menu links and such to use this new method for generating URLs. With this patch, other applications such as Dokuwiki can include the Mantis core and call the html_page_top() and html_page_bottom() functions, and all the links will work appropriately, rather than link to incorrect locations. It can then also be extended for use elsewhere, for added benefit to other apps using the Mantis menu system. If this patch could be reviewed for any potential issues, that would be great, and I can fix or commit the changes. |
|
I tried the patch on Windows, but it did not work.
is always false because of the diffrent "directory separator" as follows. $t_docroot: C:/tmp/htdocs replace |
|
I've posted a new patch with the appropriate fix for Windows servers, plus some commenting in that section. |
|
Looks good. Some comments:
|
|
New patch with some improvements suggested by Victor. |
|
Looks fine. |
|
Is there anywhere I can download the dokuwiki template that John is using? |
|
I am working on getting permission from the original theme's author about distributing my modified theme for/with Mantis. |
|
After applying this patch some Buttons in bug_view_page.php do not work. In html_api.php $g_path is passed to html_button(). Buttons created with this patched code are not functional because html_button() internally calls urlencode() and it generates an invalid URL for the buttons.
... function html_button ( $p_action, $p_button_text, $p_fields = null, $p_method = 'post' ) { To fix this problem $g_path must be removed from all html_button() calls which indeed won't affect anything as those buttons are not be visible in the Wiki. |
|
I'm getting a weird error when I try to load dokuwiki w/ the mantis template enabled. Here is the error: Warning: 100 in /var/www/dplusk.com/mantis/core/config_api.php on line 158 Warning: implode() [function.implode]: Bad arguments. in /var/www/dplusk.com/mantis/core/config_api.php on line 330 Warning: 100 in /var/www/dplusk.com/mantis/core/config_api.php on line 158 Warning: 100 in /var/www/dplusk.com/mantis/core/config_api.php on line 158 Warning: 100 in /var/www/dplusk.com/mantis/core/config_api.php on line 158 Fatal error: Call to undefined function db_is_connected() in /var/www/dplusk.com/mantis/core/authentication_api.php on line 557 I used the files in the mantiswiki.zip archive attached to this issue. Any idea where those error messages are coming from? |
|
MantisBT: master 601bd436 2007-11-10 15:48 Details Diff |
Fix 0008253: Improve Mantis integration with other applications. Created and used helper_mantis_url() to generate webroot-relative links. External apps can now call html_page_top() and html_page_bottom() without breaking menu links and such. git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4737 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9 |
Affected Issues 0008253 |
|
mod - core/helper_api.php | Diff File | ||
mod - core/plugin_api.php | Diff File | ||
mod - config_defaults_inc.php | Diff File | ||
mod - core/html_api.php | Diff File | ||
mod - core/string_api.php | Diff File |