Skip to content

Commit 703c984

Browse files
committed
When viewing logs, allow filtering by log type.
1 parent 85348f2 commit 703c984

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

test/view_logs.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ function($a, $b) {
4141
}
4242
);
4343

44+
// If we've been given a type, filter by type; otherwise display everything.
45+
if ( !empty($_REQUEST['type']) ) {
46+
$filter_type = function($log) {
47+
return ( $log->type == $_REQUEST['type'] );
48+
};
49+
50+
$logs->incidence = array_filter(
51+
$logs->incidence,
52+
$filter_type
53+
);
54+
55+
$logs->log = array_filter(
56+
$logs->log,
57+
$filter_type
58+
);
59+
}
60+
4461
?>
4562
<!doctype html>
4663
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
@@ -72,9 +89,11 @@ function($a, $b) {
7289
<aside class="span2">
7390
<ul class="nav nav-list">
7491
<li class="nav-header">Type:</li>
75-
<li class="active"><a href="#">Error</a></li>
76-
<li><a href="#">Info</a></li>
77-
<li><a href="#">Log</a></li>
92+
<?php foreach ( array('error', 'info', 'log') as $type ) : ?>
93+
94+
<?php $active = ( $type == $_REQUEST['type'] ) ? 'active' : ''; ?>
95+
<li class="<?php echo $active ?>"><a href="?type=<?php echo $type ?>"><?php echo ucwords($type) ?></a></li>
96+
<?php endforeach ?>
7897
</ul>
7998
</aside>
8099
<div class="span10">

0 commit comments

Comments
 (0)