View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0012387 | mantisbt | feature | public | 2010-09-22 08:20 | 2011-05-27 05:27 |
| Reporter | sveyret | Assigned To | |||
| Priority | normal | Severity | tweak | Reproducibility | always |
| Status | new | Resolution | open | ||
| Product Version | 1.2.3 | ||||
| Summary | 0012387: Condensed project menu bar | ||||
| Description | In my compagny, we have more than 200 projects. Having too many projects causes some graphical problems for users :
I created a patch which adds the ability to have a “condensed view” of the project. It adds a new configuration option : When kept OFF, this option has no effect. If set to ON :
Sorry again for posting a simple standard patch (to be applied with patch -p1) instead of real git patch. | ||||
| Tags | patch, redesign | ||||
| Attached Files | proj-condensed.patch (6,361 bytes)
diff -Naur mantisbt-1.2.3/config_defaults_inc.php mantisbt-patch/config_defaults_inc.php
--- mantisbt-1.2.3/config_defaults_inc.php 2010-09-22 10:39:51.000000000 +0200
+++ mantisbt-patch/config_defaults_inc.php 2010-09-22 10:49:00.000000000 +0200
@@ -777,6 +777,14 @@
$g_show_project_menu_bar = OFF;
/**
+ * Show available projects in a condensed mode: only current project,
+ * its parents and children are displayed in the project menu bar;
+ * projects are displayed only once in project dropdown.
+ * @global int $g_show_projects_condensed
+ */
+ $g_show_projects_condensed = OFF;
+
+ /**
* show assigned to names
* This is in the view all pages
* @global int $g_show_assigned_names
diff -Naur mantisbt-1.2.3/core/html_api.php mantisbt-patch/core/html_api.php
--- mantisbt-1.2.3/core/html_api.php 2010-09-22 10:40:42.000000000 +0200
+++ mantisbt-patch/core/html_api.php 2010-09-22 11:30:16.000000000 +0200
@@ -865,9 +865,33 @@
echo '<td class="menu">';
echo '<a href="' . helper_mantis_url( 'set_project.php?project_id=' . ALL_PROJECTS ) . '">' . lang_get( 'all_projects' ) . '</a>';
- foreach( $t_project_ids as $t_id ) {
- echo ' | <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_id ) . '">' . string_html_specialchars( project_get_field( $t_id, 'name' ) ) . '</a>';
- print_subproject_menu_bar( $t_id, $t_id . ';' );
+ if( config_get( 'show_projects_condensed' ) == OFF ) {
+ foreach( $t_project_ids as $t_id ) {
+ echo ' | <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_id ) . '">' . string_html_specialchars( project_get_field( $t_id, 'name' ) ) . '</a>';
+ print_subproject_menu_bar( $t_id, $t_id . ';' );
+ }
+ } else {
+ # Show only a condensed version of the menu bar
+ $t_project_path = helper_get_current_project_trace();
+ $t_parents = '';
+ if( $t_project_path[0] == ALL_PROJECTS ) array_shift( $t_project_path );
+
+ while( count( $t_project_path ) > 0 && in_array( $t_project_path[0], $t_project_ids ) ) {
+ $t_parents = $t_parents . $t_project_path[0];
+ echo ' > <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_parents ) . '">' . string_html_specialchars( project_get_field( $t_project_path[0], 'name' ) ) . '</a>';
+ $t_parents .= ';';
+ $t_project_ids = current_user_get_accessible_subprojects( $t_project_path[0] );
+ array_shift( $t_project_path );
+ }
+
+ if( count( $t_project_path ) > 0 ) {
+ $t_parents = $t_parents . $t_project_path[ count( $t_project_path ) - 1 ];
+ echo ' >> <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $t_parents ) . '">' . string_html_specialchars( project_get_field( $t_project_path[ count( $t_project_path ) - 1 ], 'name' ) ) . '</a>';
+ $t_parents .= ';';
+ $t_project_ids = current_user_get_accessible_subprojects( $t_project_path[ count( $t_project_path ) - 1 ] );
+ }
+
+ print_subproject_menu_bar( $t_project_ids, $t_parents );
}
echo '</td>';
@@ -880,11 +904,19 @@
* @return null
*/
function print_subproject_menu_bar( $p_project_id, $p_parents = '' ) {
- $t_subprojects = current_user_get_accessible_subprojects( $p_project_id );
+ $t_recursive = false;
+ $t_subprojects = $p_project_id;
+ if( !is_array( $p_project_id ) ) {
+ $t_recursive = true;
+ $t_subprojects = current_user_get_accessible_subprojects( $p_project_id );
+ }
+
$t_char = ':';
foreach( $t_subprojects as $t_subproject ) {
echo $t_char . ' <a href="' . helper_mantis_url( 'set_project.php?project_id=' . $p_parents . $t_subproject ) . '">' . string_html_specialchars( project_get_field( $t_subproject, 'name' ) ) . '</a>';
- print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' );
+ if( $t_recursive ) {
+ print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' );
+ }
$t_char = ',';
}
}
diff -Naur mantisbt-1.2.3/core/print_api.php mantisbt-patch/core/print_api.php
--- mantisbt-1.2.3/core/print_api.php 2010-09-22 10:41:12.000000000 +0200
+++ mantisbt-patch/core/print_api.php 2010-09-22 13:56:34.000000000 +0200
@@ -462,7 +462,9 @@
* @return void
*/
function print_project_option_list( $p_project_id = null, $p_include_all_projects = true, $p_filter_project_id = null, $p_trace = false ) {
- $t_project_ids = current_user_get_accessible_projects();
+ $t_condensed = ( config_get( 'show_projects_condensed' ) != OFF );
+ $t_project_ids = $t_condensed ? current_user_get_all_accessible_subprojects( ALL_PROJECTS ) :
+ current_user_get_accessible_projects();
project_cache_array_rows( $t_project_ids );
if( $p_include_all_projects ) {
@@ -471,14 +473,24 @@
echo '>' . lang_get( 'all_projects' ) . '</option>' . "\n";
}
- $t_project_count = count( $t_project_ids );
- for( $i = 0;$i < $t_project_count;$i++ ) {
- $t_id = $t_project_ids[$i];
+ $t_projects = array();
+ foreach( $t_project_ids as $t_id ) {
+ $t_projects[$t_id] = project_get_field( $t_id, 'name' );
+ }
+ asort( $t_projects );
+ if( $t_condensed ) {
+ $t_selected_id = split( ';', $p_project_id );
+ $p_project_id = $t_selected_id[ count( $t_selected_id ) - 1 ];
+ }
+
+ foreach( $t_projects as $t_id => $t_name ) {
if( $t_id != $p_filter_project_id ) {
echo '<option value="' . $t_id . '"';
check_selected( $p_project_id, $t_id );
- echo '>' . string_attribute( project_get_field( $t_id, 'name' ) ) . '</option>' . "\n";
- print_subproject_option_list( $t_id, $p_project_id, $p_filter_project_id, $p_trace, Array() );
+ echo '>' . string_attribute( $t_name ) . '</option>' . "\n";
+ if( !$t_condensed ) {
+ print_subproject_option_list( $t_id, $p_project_id, $p_filter_project_id, $p_trace, Array() );
+ }
}
}
}
diff -Naur mantisbt-1.2.3/core/user_api.php mantisbt-patch/core/user_api.php
--- mantisbt-1.2.3/core/user_api.php 2010-09-22 10:40:58.000000000 +0200
+++ mantisbt-patch/core/user_api.php 2010-09-22 13:58:39.000000000 +0200
@@ -1001,7 +1001,7 @@
/** @todo (thraxisp) Should all top level projects be a sub-project of ALL_PROJECTS implicitly?
* affects how news and some summaries are generated
*/
- $t_todo = user_get_accessible_subprojects( $p_user_id, $p_project_id );
+ $t_todo = $p_project_id == ALL_PROJECTS ? user_get_accessible_projects( $p_user_id ) : user_get_accessible_subprojects( $p_user_id, $p_project_id );
$t_subprojects = Array();
while( $t_todo ) {
| ||||