cvs: php-bugs-web / bugs.sql search.php style.css /include functions.inc layout.inc

From: Date: Sun, 10 Feb 2002 03:00:53 +0000
Subject: cvs: php-bugs-web / bugs.sql search.php style.css /include functions.inc layout.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-8656@lists.php.net to get a copy of this message
jimw Sat Feb 9 22:00:53 2002 EDT Modified files: /php-bugs-web bugs.sql search.php style.css /php-bugs-web/include functions.inc layout.inc Log: redesign 'advanced search' form to be less crowded (added search by php version and sorting options). redisplay the search form when no bugs were found. make entering a bug in the top search box just go to the appropriate edit page if the magic cookie is set.

Index: php-bugs-web/bugs.sql diff -u php-bugs-web/bugs.sql:1.4 php-bugs-web/bugs.sql:1.5 --- php-bugs-web/bugs.sql:1.4 Mon Jan 28 19:17:40 2002 +++ php-bugs-web/bugs.sql Sat Feb 9 22:00:51 2002 @@ -18,6 +18,7 @@ assign varchar(16), passwd varchar(20),# user password PRIMARY KEY (id), + INDEX (php_version(1)), FULLTEXT (email,sdesc,ldesc) ); Index: php-bugs-web/search.php diff -u php-bugs-web/search.php:1.12 php-bugs-web/search.php:1.13 --- php-bugs-web/search.php:1.12 Mon Jan 28 19:17:40 2002 +++ php-bugs-web/search.php Sat Feb 9 22:00:51 2002 @@ -1,12 +1,19 @@ <?php /* vim: set noet ts=4 sw=4: : */ require_once 'prepend.inc'; +if (isset($MAGIC_COOKIE) && !isset($user) && !isset($pw)) { + list($user,$pw) = explode(":", base64_decode($MAGIC_COOKIE)); +} + if ($search_for && !preg_match("/\\D/",trim($search_for))) { - header("Location: bug.php?id=$search_for"); + $x = $pw ? ($user ? "&edit=1" : "&edit=2") : ""; + header("Location: bug.php?id=$search_for$x"); exit; } -commonHeader("Search", false); +commonHeader("Search"); + +$errors = array(); if (isset($cmd) && $cmd == "display") { @mysql_connect("localhost","nobody","") @@ -49,7 +56,16 @@ } if (empty($phpver)) $phpver = "4"; - if ($phpver) $where_clause .= " AND SUBSTRING(php_version,1,1) = '$phpver'"; + if ($phpver) { + // there's an index on php_version(1) to speed this up. + if (strlen($phpver) == 1) { + $where_clause .= " AND SUBSTRING(php_version,1,1) = '$phpver'"; + } + else { + $where_clause .= " AND php_version LIKE '$phpver%'"; + } + } + if (!empty($assign)) { $where_clause .= " AND assign = '$assign'"; } @@ -84,7 +100,7 @@ $total_rows = $row[0]; if (!$total_rows) { - echo "<h2 class=\"error\">No bugs with the specified criteria were found.</h2>"; + $errors[] = "No bugs with the specified critera were found."; } else { $res = @mysql_query($query); @@ -103,7 +119,7 @@ <th><a href="<?php echo $link;?>&amp;reorder_by=status">Status</a></th> <th><a href="<?php echo $link;?>&amp;reorder_by=php_version">Version</a></th> <th><a href="<?php echo $link;?>&amp;reorder_by=php_os">OS</a></th> - <th><a href="<?php echo $link;?>&amp;reorder_by=sdesc">Description</a></th> + <th><a href="<?php echo $link;?>&amp;reorder_by=sdesc">Summary</a></th> <th><a href="<?php echo $link;?>&amp;reorder_by=assign">Assigned</a></th> </tr> <?php @@ -130,56 +146,71 @@ ?> </table> <?php + commonFooter(); + exit; } -} else {?> -<table bgcolor="#ccccff" border="0" cellspacing="1"> - <form method="POST" action="<?php echo $PHP_SELF?>"> - <input type="hidden" name="cmd" value="display" /> - <tr> - <td rowspan="5" valign="top"><input type="submit" value="Display" /></td> - <td align="right">bugs&nbsp;with&nbsp;status:</td> - <td><select name="status"><?php show_state_options($status);?></select></td> - <td align="right">reported&nbsp;since:</td> - <td><select name="bug_age"><?php show_byage_options($bug_age);?></select></td> - </tr> - <tr> - <td align="right">of type:</td> - <td colspan="3"><select name="bug_type"><?php show_types($bug_type,1);?></select></td> - </tr> - <tr> - <td align="right">OS (substring):</td> - <td><input type="text" name="php_os" value="<?echo htmlspecialchars($php_os);?>" /></td> - <td align="right">assigned to:</td> - <td><input size="10" type="text" name="assign" value="<?echo htmlspecialchars($assign);?>" />&nbsp;<?php +} + +if ($errors) display_errors($errors); +?> +<form id="asearch" method="post" action="<?php echo $PHP_SELF?>"> +<table id="primary" width="95%"> + <tr> + <th>Find bugs</th> + <td nowrap="nowrap">with <b>any</b> of the words</td> + <td><input type="text" name="search_for" value="<?echo htmlspecialchars($search_for);?>" size="20" maxlength="255" /></td> + <td rowspan="2"> + <select name="limit"><?php show_limit_options($limit);?></select> + <br /> + <select name="order_by"><?php show_order_options($limit);?></select> + <br /> + <input type="hidden" name="cmd" value="display" /> + <input type="submit" value="Search" /> + </td> + </tr> + <tr> + <th>Status</th> + <td nowrap="nowrap">Return only bugs with <b>status</b></td> + <td><select name="status"><?php show_state_options($status);?></select></td> + </tr> +</table> +<table> + <tr> + <th>Category</th> + <td nowrap="nowrap">Return only bugs in <b>category</b></td> + <td><select name="bug_type"><?php show_types($bug_type,1);?></select></td> + </tr> + <tr> + <th>OS</th> + <td nowrap="nowrap">Return bugs with <b>operating system</b></td> + <td><input type="text" name="php_os" value="<?echo htmlspecialchars($php_os);?>" /></td> + </tr> + <tr> + <th>Version</th> + <td nowrap="nowrap">Return bugs reported with <b>PHP version</b></td> + <td><input type="text" name="phpver" value="<?echo htmlspecialchars($php_version);?>" /></td> + </tr> + <tr> + <th>Assigned</th> + <td nowrap="nowrap">Return only bugs <b>assigned</b> to</td> + <td><input type="text" name="assign" value="<?echo htmlspecialchars($php_version);?>" /> +<?php if (!empty($user)) { $u = stripslashes($user); print "<input type=\"button\" value=\"set to $u\" onclick=\"form.assign.value='$u'\" />"; } -?></td> - </tr> - <tr> - <td align="right">with text:</td> - <td colspan="3"><input type="text" name="search_for" value="<?echo htmlspecialchars($search_for);?>" /> in the report or email address</td> - </tr> - <tr> - <td align="right">max:</td> - <td colspan="3"><select name="limit"><?php show_limit_options($limit);?></select> entries / page.</td> - </tr> - </form> - <tr> - <td bgcolor="#000000" colspan="5"><?echo spacer(1,1);?></td> - </tr> - <form method="GET" action="bug.php"> - <tr> - <td align="right"><input type="submit" value="Edit" /></td> - <td align="right">bug number:</td> - <td colspan="3"><input type="text" name="id" value="<?echo $id?>"></td> - <input type="hidden" name="edit" value="<?php echo isset($MAGIC_COOKIE) ? 1 : 2;?>"> - </tr> - </form> +?> + </td> + </tr> + <tr> + <th>Date</th> + <td nowrap="nowrap">Return bugs submitted</td> + <td><select name="bug_age"><?php show_byage_options($bug_age);?></select></td> + </tr> </table> +</form> + <?php -} commonFooter(); function show_prev_next($begin,$rows,$total_rows,$link,$limit) { @@ -200,4 +231,22 @@ echo "<td width=\"33%\">&nbsp;</td>"; } echo "</tr></table></td></tr>"; +} + +function show_order_options ($current) { + $opts = array( + '' => "relevance", + 'id' => "ID", + 'bug_type' => "type", + 'status' => "status", + 'php_version' => "version", + 'php_os' => "os", + 'sdesc' => "summary", + 'assign' => "assignment", + ); + foreach ($opts as $k => $v) { + echo '<option value="', $k, '"', + ($v == $current ? ' selected="selected"' : ''), + '>Sort by ', $v, "</option>\n"; + } } Index: php-bugs-web/style.css diff -u php-bugs-web/style.css:1.14 php-bugs-web/style.css:1.15 --- php-bugs-web/style.css:1.14 Sat Feb 9 19:56:04 2002 +++ php-bugs-web/style.css Sat Feb 9 22:00:51 2002 @@ -174,3 +174,12 @@ margin-left: 10px; text-align: center; } + +form#asearch th { + text-align: left; + font-weight: bold; +} + +form#asearch table#primary { + background: #eee; +} Index: php-bugs-web/include/functions.inc diff -u php-bugs-web/include/functions.inc:1.20 php-bugs-web/include/functions.inc:1.21 --- php-bugs-web/include/functions.inc:1.20 Mon Feb 4 04:38:05 2002 +++ php-bugs-web/include/functions.inc Sat Feb 9 22:00:53 2002 @@ -38,7 +38,7 @@ function show_limit_options($limit=30) { for($i=10;$i<100;) { - echo "<option value=\"$i\"", ($limit==$i ? " selected" : ""),">$i</option>\n"; + echo "<option value=\"$i\"", ($limit==$i ? " selected" : ""),">$i bugs</option>\n"; $i=$i+10; } echo '<option value="All"', ($limit=='All' ? " selected": ""),">All</option>\n"; Index: php-bugs-web/include/layout.inc diff -u php-bugs-web/include/layout.inc:1.13 php-bugs-web/include/layout.inc:1.14 --- php-bugs-web/include/layout.inc:1.13 Sun Feb 3 15:33:58 2002 +++ php-bugs-web/include/layout.inc Sat Feb 9 22:00:53 2002 @@ -207,7 +207,7 @@ <form method="get" action="search.php"> <input type="hidden" name="cmd" value="display" /> <td align="right" valign="top" colspan="2" nowrap><font color="#ffffff"> - <small>search bugs for</small> + <small>go to bug id or search bugs for</small> <input class="small" type="text" name="search_for" value="<?php echo htmlspecialchars($prevsearch) ?>" size="30" /> <?php echo make_submit('small_submit_white.gif', 'search', 'bottom');?>&nbsp;<br> </font></td>
« previous php.mirrors (#8656) next »