From 4ec7a42c8638383cc653df6e1eb94d1cfe054079 Mon Sep 17 00:00:00 2001 From: Carlos Proensa Date: Mon, 7 Jan 2019 15:51:55 +0100 Subject: [PATCH] MantisGraph, highlight active graph page link. Display as active the link for current graph summary page. Fixes: #25163 --- plugins/MantisGraph/MantisGraph.php | 71 ++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/plugins/MantisGraph/MantisGraph.php b/plugins/MantisGraph/MantisGraph.php index f3015319e3..b8d9bdd014 100644 --- a/plugins/MantisGraph/MantisGraph.php +++ b/plugins/MantisGraph/MantisGraph.php @@ -149,16 +149,65 @@ function resources() { function summary_submenu() { $t_filter = summary_get_filter(); $t_filter_param = filter_get_temporary_key_param( $t_filter ); - return array( - ' ' . plugin_lang_get( 'synthesis_link' ) . '', - ' ' . lang_get( 'by_developer' ) . '', - ' ' . lang_get( 'by_reporter' ) . '', - ' ' . plugin_lang_get( 'status_link' ) . '', - ' ' . plugin_lang_get( 'resolution_link' ) . '', - ' ' . plugin_lang_get( 'priority_link' ) . '', - ' ' . plugin_lang_get( 'severity_link' ) . '', - ' ' . plugin_lang_get( 'category_link' ) . '', - ' ' . plugin_lang_get( 'issue_trends_link' ) . '', - ); + $t_param_page = explode( '/', gpc_get_string( 'page', '' ) ); + $t_plugin_page_current = end( $t_param_page ); + + # Core should implement the automatic highlighting of active links, but that requires + # changing the format of the menu and submenu events. + # For now, it's responsability of the plugin to detect and render each link properly. + $t_menu_items = array(); + $t_menu_items[] = array( 'icon' => 'fa-table', 'title' => plugin_lang_get( 'synthesis_link' ), + 'url' => helper_url_combine( helper_mantis_url( 'summary_page.php' ), $t_filter_param ) ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => lang_get( 'by_developer' ), + 'url' => helper_url_combine( plugin_page( 'developer_graph.php' ), $t_filter_param ), + 'plugin_page' => 'developer_graph.php' ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => lang_get( 'by_reporter' ), + 'url' => helper_url_combine( plugin_page( 'reporter_graph.php' ), $t_filter_param ), + 'plugin_page' => 'reporter_graph.php' ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => plugin_lang_get( 'status_link' ), + 'url' => helper_url_combine( plugin_page( 'status_graph.php' ), $t_filter_param ), + 'plugin_page' => 'status_graph.php' ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => plugin_lang_get( 'resolution_link' ), + 'url' => helper_url_combine( plugin_page( 'resolution_graph.php' ), $t_filter_param ), + 'plugin_page' => 'resolution_graph.php' ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => plugin_lang_get( 'priority_link' ), + 'url' => helper_url_combine( plugin_page( 'priority_graph.php' ), $t_filter_param ), + 'plugin_page' => 'priority_graph.php' ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => plugin_lang_get( 'severity_link' ), + 'url' => helper_url_combine( plugin_page( 'severity_graph.php' ), $t_filter_param ), + 'plugin_page' => 'severity_graph.php' ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => plugin_lang_get( 'category_link' ), + 'url' => helper_url_combine( plugin_page( 'category_graph.php' ), $t_filter_param ), + 'plugin_page' => 'category_graph.php' ); + + $t_menu_items[] = array( 'icon' => 'fa-bar-chart', 'title' => plugin_lang_get( 'issue_trends_link' ), + 'url' => helper_url_combine( plugin_page( 'issues_trend_graph.php' ), $t_filter_param ), + 'plugin_page' => 'issues_trend_graph.php' ); + + $t_html_links = array(); + foreach( $t_menu_items as $t_item ) { + $t_class_active = ''; + if( isset( $t_item['plugin_page'] ) ) { + if( $t_item['plugin_page'] == $t_plugin_page_current ) { + $t_class_active = ' active'; + } + } else { + if( 'summary_page.php' == basename( $_SERVER['SCRIPT_NAME'] ) ) { + $t_class_active = ' active'; + } + } + $t_html = ''; + $t_html .= ' '; + $t_html .= $t_item['title'] . ''; + $t_html_links[] = $t_html; + } + return $t_html_links; } }