今回はMantisのちょっとしたカスタムについて投稿します。
(ほぼ備忘録用です。)
ウガトリアでは不具合管理にMantisを使用しているのですが、サーバー移行に伴いMantisのバージョンを上げることになりました。
ところが、バージョンを上げて衝撃が走りました!
Mantisを使用する、最大とも言える理由であった”毒々しい一覧画面“が小綺麗になってしまったのです。
※使ったことのある方には伝わればいいなと思います。
ということで、この小綺麗になってしまった一覧画面を今一度”毒々しい一覧画面“に戻すべく手を加えます。
ではさっそく。。。
変更するファイル
※一覧の見た目が最重要なため、他の画面への影響はとりあえず置いておきます。
1.font-awesome-4.6.3-min.css(cssディレクトリ配下にあります)
2.status-config.php(cssディレクトリ配下にあります)
3.view_all_inc.php
変更作業
1.font-awesome-4.6.3-min.css
一覧のステータス欄に表示されるマーク(こんな「■」感じでスタータスの色を表すやつ)を、邪魔なので消します。
以下のstyleの定義があるので、こいつをコメントアウトしました。
fa-square:before{content:”\f0c8″}
↓こんな風に(やり方雑〜)
fa-square:before{/*content:”\f0c8″*/}
2.status-config.php
一覧のステータス欄に表示されるマークの色を設定するstyleでしたが、これを各行全体のstyleとして使用するために修正します。
ちなみにこれが実行されると下記のstyleが出来上がります。
1 2 3 4 5 6 7 |
.status-10-color { color: #FF0000; background-color: #FF0000; } .status-20-color { color: #FF66FF; background-color: #FF66FF; } .status-30-color { color: #FFFF00; background-color: #FFFF00; } .status-40-color { color: #4682B4; background-color: #4682B4; } .status-50-color { color: #FF9900; background-color: #FF9900; } .status-80-color { color: #d2f5b0; background-color: #d2f5b0; } .status-90-color { color: #c9ccc4; background-color: #c9ccc4; } |
このままだと、文字色まで変わってしまうので、背景色のみの設定にします。
こんな感じに仕上がります。
1 2 3 4 5 6 7 |
.status-10-color { background-color: #FF0000; } .status-20-color { background-color: #FF66FF; } .status-30-color { background-color: #FFFF00; } .status-40-color { background-color: #4682B4; } .status-50-color { background-color: #FF9900; } .status-80-color { background-color: #d2f5b0; } .status-90-color { background-color: #c9ccc4; } |
では、ファイルの末尾のほうに以下のコードがあるので変更していきます。
1 2 3 4 5 |
# Status color class if( array_key_exists( $t_label, $t_colors ) ) { echo '.' . $t_css_class . " { color: {$t_colors[$t_label]}; background-color: {$t_colors[$t_label]}; }\n"; } |
ここにある”color”の定義を削除します。
1 2 3 4 5 |
# Status color class if( array_key_exists( $t_label, $t_colors ) ) { echo '.' . $t_css_class . " { background-color: {$t_colors[$t_label]}; }\n"; } |
これで一覧で使用しても文字の色は影響しなくなります。
3.view_all_inc.php
こいつが一覧画面の本体になります。
これの各行にステータスに応じたclassを指定するだけです。
“write_bug_rows”というメソッドがあるので、ここでちょっとした処理を追加するだけです。
変更前のコードは以下です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<?php /** * Output Bug Rows * * @param array $p_rows An array of bug objects. * @return void */ function write_bug_rows( array $p_rows ) { global $g_columns, $g_filter; $t_in_stickies = ( $g_filter && ( 'on' == $g_filter[FILTER_PROPERTY_STICKY] ) ); # -- Loop over bug rows -- $t_rows = count( $p_rows ); for( $i=0; $i < $t_rows; $i++ ) { $t_row = $p_rows[$i]; if( ( 0 == $t_row->sticky ) && ( 0 == $i ) ) { $t_in_stickies = false; } if( ( 0 == $t_row->sticky ) && $t_in_stickies ) { # demarcate stickies, if any have been shown ?> <tr> <td colspan="<?php echo count( $g_columns ); ?>" bgcolor="#d3d3d3"></td> </tr> <?php $t_in_stickies = false; } echo '<tr>'; $t_column_value_function = 'print_column_value'; foreach( $g_columns as $t_column ) { helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row ) ); } echo '</tr>'; } } write_bug_rows( $t_rows ); # -- ====================== end of BUG LIST ========================= -- ?> |
変更後は以下です。
変更箇所はコードスニペットの31行目です。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<?php /** * Output Bug Rows * * @param array $p_rows An array of bug objects. * @return void */ function write_bug_rows( array $p_rows ) { global $g_columns, $g_filter; $t_in_stickies = ( $g_filter && ( 'on' == $g_filter[FILTER_PROPERTY_STICKY] ) ); # -- Loop over bug rows -- $t_rows = count( $p_rows ); for( $i=0; $i < $t_rows; $i++ ) { $t_row = $p_rows[$i]; if( ( 0 == $t_row->sticky ) && ( 0 == $i ) ) { $t_in_stickies = false; } if( ( 0 == $t_row->sticky ) && $t_in_stickies ) { # demarcate stickies, if any have been shown ?> <tr> <td colspan="<?php echo count( $g_columns ); ?>" bgcolor="#d3d3d3"></td> </tr> <?php $t_in_stickies = false; } echo '<tr class="status-'.$t_row->status.'-color">'; $t_column_value_function = 'print_column_value'; foreach( $g_columns as $t_column ) { helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row ) ); } echo '</tr>'; } } write_bug_rows( $t_rows ); # -- ====================== end of BUG LIST ========================= -- ?> |
ここまでやったら一覧を再表示してみてください。
あの”毒々しい一覧画面“が復活します!
以上、とっても簡単です。