Skip to content

Commit

Permalink
MantisGraph, highlight active graph page link.
Browse files Browse the repository at this point in the history
Display as active the link for current graph summary page.

Fixes: #25163
  • Loading branch information
cproensa authored and dregad committed Feb 14, 2019
1 parent 29d3076 commit 4ec7a42
Showing 1 changed file with 60 additions and 11 deletions.
71 changes: 60 additions & 11 deletions plugins/MantisGraph/MantisGraph.php
Expand Up @@ -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(
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( helper_mantis_url( 'summary_page.php' ), $t_filter_param ) . '"> <i class="fa fa-table"></i> ' . plugin_lang_get( 'synthesis_link' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'developer_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . lang_get( 'by_developer' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'reporter_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . lang_get( 'by_reporter' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'status_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . plugin_lang_get( 'status_link' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'resolution_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . plugin_lang_get( 'resolution_link' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'priority_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . plugin_lang_get( 'priority_link' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'severity_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . plugin_lang_get( 'severity_link' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'category_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . plugin_lang_get( 'category_link' ) . '</a>',
'<a class="btn btn-sm btn-primary btn-white" href="' . helper_url_combine( plugin_page( 'issues_trend_graph.php' ), $t_filter_param ) . '"> <i class="fa fa-bar-chart"></i> ' . plugin_lang_get( 'issue_trends_link' ) . '</a>',
);
$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 = '<a class="btn btn-sm btn-primary btn-white' . $t_class_active . '" href="' . $t_item['url'] . '">';
$t_html .= ' <i class="fa ' . $t_item['icon'] . '"></i> ';
$t_html .= $t_item['title'] . '</a>';
$t_html_links[] = $t_html;
}
return $t_html_links;
}
}

0 comments on commit 4ec7a42

Please sign in to comment.