Permalink
Browse files

add html_get_status_css_class function to replace lang_get calls

  • Loading branch information...
grangeway committed Feb 7, 2013
1 parent b97cdba commit 6ccec55ee982a6302c1a819fcb68ebf4a8d92726
Showing with 43 additions and 10 deletions.
  1. +8 −2 account_sponsor_page.php
  2. +5 −1 bug_update_page.php
  3. +5 −1 bug_view_inc.php
  4. +5 −1 core/bug_group_action_api.php
  5. +10 −1 core/html_api.php
  6. +4 −1 core/relationship_api.php
  7. +2 −2 my_view_inc.php
  8. +4 −1 view_all_inc.php
View
@@ -182,7 +182,10 @@
$t_released_label = $t_bug->fixed_in_version;
}
- echo '<tr class="' . MantisEnum::getLabel( config_get('status_enum_string' ), $t_bug->status ) . '-color">';
+ # choose color based on status
+ $status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
+
+ echo '<tr class="' . $status_label . '">';
echo '<td><a href="' . string_get_bug_view_url( $row['bug'] ) . '">' . bug_format_id( $row['bug'] ) . '</a></td>';
echo '<td>' . project_get_field( $t_bug->project_id, 'name' ) . '&#160;</td>';
echo '<td class="right">' . $t_released_label . '&#160;</td>';
@@ -308,7 +311,10 @@
$t_released_label = $t_bug->fixed_in_version;
}
- echo '<tr class="' . MantisEnum::getLabel( config_get('status_enum_string' ), $t_bug->status ) . '-color">';
+ # choose color based on status
+ $status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
+
+ echo '<tr class="' . $status_label . '">';
echo '<td><a href="' . string_get_bug_view_url( $row['bug'] ) . '">' . bug_format_id( $row['bug'] ) . '</a></td>';
echo '<td>' . project_get_field( $t_bug->project_id, 'name' ) . '&#160;</td>';
echo '<td class="right">' . $t_released_label . '&#160;</td>';
View
@@ -387,7 +387,11 @@
if ( $tpl_show_status ) {
# Status
echo '<th class="category"><label for="status">' . _( 'Status' ) . '</label></th>';
- echo '<td class="', get_enum_element( config_get('status_enum_string' ), $tpl_bug->status ), '-color">';
+
+ # choose color based on status
+ $status_label = html_get_status_css_class( $tpl_bug->status );
+
+ echo '<td class="' . $status_label . '">';
print_status_option_list( 'status', $tpl_bug->status,
( $tpl_bug->reporter_id == auth_get_current_user_id() &&
( ON == config_get( 'allow_reporter_close' ) ) ), $tpl_bug->project_id );
View
@@ -474,7 +474,11 @@
# Status
if ( $tpl_show_status ) {
echo '<th class="bug-status category">', _( 'Status' ), '</th>';
- echo '<td class="bug-status ', MantisEnum::getLabel( config_get('status_enum_string' ), $tpl_bug->status ), '-color">', $tpl_status, '</td>';
+
+ # choose color based on status
+ $status_label = html_get_status_css_class( $tpl_bug->status );
+
+ echo '<td class="bug-status ', $status_label, '">', $tpl_status, '</td>';
} else {
$t_spacer += 2;
}
@@ -103,7 +103,11 @@ function bug_group_action_print_bug_list( $p_bug_ids_array ) {
foreach( $p_bug_ids_array as $t_bug_id ) {
$t_class = sprintf( "row-%d", ( $t_i++ % 2 ) + 1 );
- echo sprintf( "<tr class=\"%s-color\"> <td>%s</td> <td>%s</td> </tr>\n", MantisEnum::getLabel( config_get('status_enum_string' ), bug_get_field( $t_bug_id, 'status' ) ), string_get_bug_view_link( $t_bug_id ), string_attribute( bug_get_field( $t_bug_id, 'summary' ) ) );
+
+ # choose color based on status
+ $status_label = html_get_status_css_class( bug_get_field( $t_bug_id, 'status' ), auth_get_current_user_id(), bug_get_field( $t_bug_id, 'project_id' ) );
+
+ echo sprintf( "<tr class=\"%s\"> <td>%s</td> <td>%s</td> </tr>\n", $status_label, string_get_bug_view_link( $t_bug_id ), string_attribute( bug_get_field( $t_bug_id, 'summary' ) ) );
}
echo '</table>';
View
@@ -1208,7 +1208,7 @@ function html_status_legend() {
}
$t_status_array = MantisEnum::getAssocArrayIndexedByValues( config_get( 'status_enum_string' ) );
- $t_status_names = MantisEnum::getAssocArrayIndexedByValues( lang_get( 'status_enum_string' ) );
+ $t_status_names = MantisEnum::getAssocArrayIndexedByValues( _( config_get( 'status_enum_string' ) ) );
$enum_count = count( $t_status_array );
# read through the list and eliminate unused ones for the selected project
@@ -1669,3 +1669,12 @@ function html_buttons_view_bug_page( $p_bug ) {
echo '</tr></table>';
}
+
+/**
+ * get the css class name for the given status, user and project
+ * @param int $p_status
+ * @return string
+ */
+function html_get_status_css_class( $p_status, $p_user = null, $p_project = null ) {
+ return string_attribute( MantisEnum::getLabel( config_get('status_enum_string', null, $p_user, $p_project ), $p_status ) . '-color' );
+}
@@ -644,7 +644,10 @@ function relationship_get_details( $p_bug_id, $p_relationship, $p_html = false,
$t_relationship_info_text .= "\n";
if( $p_html_preview == false ) {
- $t_relationship_info_html = '<tr class="' . MantisEnum::getLabel( config_get('status_enum_string' ), $t_bug->status ) . '-color">' . $t_relationship_info_html . '</tr>' . "\n";
+ # choose color based on status
+ $status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
+
+ $t_relationship_info_html = '<tr class="' . $status_label . '">' . $t_relationship_info_html . '</tr>' . "\n";
} else {
$t_relationship_info_html = '<tr>' . $t_relationship_info_html . '</tr>';
}
View
@@ -477,7 +477,7 @@
$t_last_updated = date( config_get( 'normal_date_format' ), $t_bug->last_updated );
# choose color based on status
- $status_label = MantisEnum::getLabel( config_get('status_enum_string' ), $t_bug->status );
+ $status_label = html_get_status_css_class( $t_bug->status, auth_get_current_user_id(), $t_bug->project_id );
# Check for attachments
$t_attachment_count = 0;
@@ -497,7 +497,7 @@
}
?>
-<tr class="my-buglist-bug <?php echo $t_bug_class?> <?php echo $status_label . '-color'; ?>">
+<tr class="my-buglist-bug <?php echo $t_bug_class?> <?php echo $status_label ?>">
<?php
# -- Bug ID and details link + Pencil shortcut --?>
<td class="center nowrap my-buglist-id">
View
@@ -200,7 +200,10 @@ function write_bug_rows ( $p_rows )
$t_in_stickies = false;
}
- echo '<tr class="', MantisEnum::getLabel( config_get('status_enum_string' ), $t_row->status ), '-color">';
+ # choose color based on status
+ $status_label = html_get_status_css_class( $t_row->status, auth_get_current_user_id(), $t_row->project_id );
+
+ echo '<tr class="' . $status_label . '">';
foreach( $t_columns as $t_column ) {
$t_column_value_function = 'print_column_value';

0 comments on commit 6ccec55

Please sign in to comment.