[aur-dev] [PATCH] Refactored pkg_search_form.php

Michael Klier chi at chimeric.de
Thu Jun 5 17:09:51 EDT 2008


This patch refactores the pkg_search_form.php template to use less tables. It
also introduces some new CSS because the way the page is structured now the
currently used CSS is not 100% compatible/usable. It also reduces the number
of validation errors for the search page with an empty result from 222 to 44.

---
 web/html/css/arch.css            |   61 +++++++++++
 web/template/pkg_search_form.php |  219 +++++++++++++++++---------------------
 2 files changed, 157 insertions(+), 123 deletions(-)

diff --git a/web/html/css/arch.css b/web/html/css/arch.css
index 92781f2..3190623 100644
--- a/web/html/css/arch.css
+++ b/web/html/css/arch.css
@@ -452,5 +452,66 @@ textarea.vLargeTextField {
   border-collapse: separate;
   border-spacing: 0 15px;
 }
+
+/**
+ * DISCLAIMER
+ *
+ * The following CSS is for the transistion in getting rid of most inline CSS
+ * once the transition is compele this file will be restructured and the CSS
+ * will be moved to the appropriate places, the new used CSS also follows a
+ * more semantic approach.
+ */
+div.aur_box {
+  border: 3px solid #ddd;
+  width: 89.5%; /* to match the old width */
+  margin-left: auto;
+  margin-right: auto;
+  margin-bottom: 1em;
+}
+
+div.aur_box div.aur_box_title {
+  border-bottom: 3px solid #ddd;
+  background-color: #f1f2f4;
+  text-align: left;
+}
+
+div.aur_box div.aur_box_title span {
+  font-weight: bold;
+  padding: 1px 0 0 3px;
+  color: #888;
+  border-top: 1px solid #fff;
+  border-bottoM: 1px solid #fff;
+  display: block;
+}
+
+div.aur_box div.aur_box_content {
+  padding: 0.5em;
+  background-color: #fff;
+}
+
+div.aur_box div.aur_box_content table {
+  width: 100%;
+  margin-bottom: 0.5em;
+}
+
+div.aur_box div.aur_box_content td.center {
+  text-align: center;
+}
+
+div.aur_box .center_align { text-align: center; }
+div.aur_box .right_align { text-align: right; }
+div.aur_box .left_align { text_align: left; }
+
+div.aur_box form#aur_package_search input.button {
+  width: 80px;
+}
+
+div.aur_box form#aur_package_search label {
+  text-align: right;
+  font-size: 11px;
+  color: #6c83b0;
+  display: block;
+}
+
 /* vim:ts=2:sw=2:et:enc=utf-8: 
  * */
diff --git a/web/template/pkg_search_form.php b/web/template/pkg_search_form.php
index 05b2da7..0b0397a 100644
--- a/web/template/pkg_search_form.php
+++ b/web/template/pkg_search_form.php
@@ -1,123 +1,96 @@
-
-    <form action='packages.php' method='get'>
-    <input type='hidden' name='O' value='0'>
-
-    <center>
-    <table cellspacing='3' class='boxSoft'>
-    <tr>
-      <td class='boxSoftTitle' align='right'>
-      <span class='f3'><?php echo __('Search Criteria'); ?></span>
-      </td>
-    </tr>
-    <tr>
-      <td class='boxSoft'>
-    <table style='width: 100%' align='center'>
-
-    <tr>
-    <td align='right'>
-    <span class='f5'><span class='blue'><?php echo __('Location'); ?>
-    </span></span><br />
-      <select name='L'>
-      <option value='0'><?php echo __('Any'); ?>
-
-<?php
-
-    // The search form - XXX: split into own function?
-    //
-    // FIXME: highly fugly. whoever makes this use
-    //        less print statements gets a cookie
-    // FIXME: ugly html. whoever un-tables this gets
-    //        another cookie
-    while (list($id, $loc) = each($locs)) {
-        if (intval($_REQUEST["L"]) == $id) {
-            print "  <option value=".$id." selected> ".$loc."\n";
-        } else {
-            print "  <option value=".$id."> ".$loc."\n";
-        }
-    }
-    print "  </select>\n";
-    print "</td>\n";
-
-    print "<td align='right'>\n";
-    print "  <span class='f5'><span class='blue'>".__("Category");
-    print "</span></span><br />\n";
-    print "  <select name='C'>\n";
-    print "  <option value=0> ".__("Any")."\n";
-    while (list($id, $cat) = each($cats)) {
-        if (intval($_REQUEST["C"]) == $id) {
-            print "  <option value=".$id." selected> ".$cat."\n";
-        } else {
-            print "  <option value=".$id."> ".$cat."\n";
-        }
-    }
-    print "  </select>\n";
-    print "</td>\n";
-
-    print "<td align='right'>\n";
-    print "  <span class='f5'><span class='blue'>".__("Keywords");
-    print "</span></span><br />\n";
-    print "  <input type='text' name='K' size='20'";
-
-    $K = trim(htmlspecialchars($_REQUEST["K"], ENT_QUOTES));
-    print " value=\"".stripslashes($K)."\" maxlength='35'>\n";
-    print "</td>\n";
-
-    print "<td align='right'>\n";
-    print "  <span class='f5'><span class='blue'>".__("Search by");
-    print "</span></span><br />\n";
-
-    print "  <select name='SeB'>\n";
-    # by name/description
-    print "  <option value=nd";
-    $_REQUEST["SeB"] == "nd" ? print " selected> " : print "> ";
-    print __("Name")."</option>\n";
-    # by maintainer
-    print "  <option value=m";
-    $_REQUEST["SeB"] == "m" ? print " selected> " : print "> ";
-    print __("Maintainer")."</option>\n";
-    print "  <option value=s";
-    $_REQUEST["SeB"] == "s" ? print " selected> " : print "> ";
-    print __("Submitter")."</option>\n";
-
-    print "  </select>\n";
-    print "</td>\n";
-
-    print "<td align='right'>\n";
-    print "  <span class='f5'><span class='blue'>".__("Per page");
-    print "</span></span><br />\n";
-    print "  <select name='PP'>\n";
-    print "  <option value=25";
-    $PP == 25 ? print " selected> 25\n" : print "> 25\n";
-    print "  <option value=50";
-    $PP == 50 ? print " selected> 50\n" : print "> 50\n";
-    print "  <option value=75";
-    $PP == 75 ? print " selected> 75\n" : print "> 75\n";
-    print "  <option value=100";
-    $PP == 100 ? print " selected> 100\n" : print "> 100\n";
-    print "  </select>\n";
-    print "</td>\n";
-
-    // Added to break put the buttons in a new line
-?>
-    </tr></table><center><table><tr>
-
-    <td align='right' valign='bottom'>&nbsp;
-      <input type='submit' style='width:80px' class='button' name='do_Search'
-    value='<?php echo __('Go'); ?>'>
-    </td>
-
-    <td align='right' valign='bottom'>&nbsp;
-      <input type='submit' style='width:80px'  class='button' name='do_Orphans'
-	      value='<?php echo __('Orphans'); ?>'>
-    </td>
-
-    </tr>
-    </table>
-
-      </td>
-    </tr>
-    </table>
-    </center>
-    </form>
-    <br />
-
+  <center>
+    <div class="aur_box">
+
+      <div class="aur_box_title">
+        <span><?php echo __('Search Criteria'); ?></span>
+      </div>
+
+      <!-- Form Start -->
+      <form action="packages.php" id="aur_package_search" method="get">
+        <input type="hidden" name="O" value="0" />
+
+        <!-- Box Content Start -->
+        <div class="aur_box_content">
+
+          <!-- Table Start -->
+          <table cellspacing="0" cellpadding="0">
+            <tr>
+
+              <!-- Search Location -->
+              <td class="right_align">
+                <label><?php echo __('Location'); ?></label>
+                <select name="L">
+                  <option value="0"><?php echo __('Any'); ?></option>
+                  <?php
+                  while (list($id, $loc) = each($locs)) {
+                      if (intval($_REQUEST['L']) == $id) {
+                          print '  <option value="' . $id . '" selected>' . $loc . "</option>\n";
+                      } else {
+                          print '  <option value="' . $id . '">' . $loc . "</option>\n";
+                      }
+                  }
+                  ?>
+                </select>
+              </td>
+
+              <!-- Search Category -->
+              <td class="right_align">
+                <label><?php echo __('Category')?></label>
+                <select name="C">
+                  <option value="0"><?php echo __('Any')?></option>
+                  <?php
+                  while (list($id, $cat) = each($cats)) {
+                      if (intval($_REQUEST['C']) == $id) {
+                          print '  <option value="' . $id . '" selected>' . $cat . "</option>\n";
+                      } else {
+                          print '  <option value="' . $id . '">' . $cat . "</option>\n";
+                      }
+                  }
+                  ?>
+                </select>
+              </td>
+
+              <!-- Search Keywords -->
+              <td class="right_align">
+                <label><?php echo __('Keywords')?></label>
+                <input type="text" name="K" size="20" value="<?php echo stripslashes(trim(htmlspecialchars($_REQUEST['K'])))?>" maxlength="35">
+              </td>
+
+              <!-- Search by -->
+              <td class="right_align">
+                <label><?php echo __("Search by")?></label>
+                <select name="SeB">
+                  <option value="nd" <?php if ($_REQUEST['SeB'] == "nd") print 'selected'?>><?php echo __('Name')?></option>
+                  <option value="m" <?php if ($_REQUEST['SeB'] == "m") print 'selected'?>><?php echo __('Maintainer')?></option>
+                  <option value="s" <?php if ($_REQUEST['SeB'] == "s") print 'selected'?>><?php echo __('Submitter')?></option>
+                </select>
+              </td>
+
+              <!-- Per Page -->
+              <td class="right_align">
+                <label><?php echo __('Per page')?></label>
+                <select name="PP">
+                  <option value="25" <?php if ($PP == 25) print 'selected'?>>25</option>
+                  <option value="50" <?php if ($PP == 50) print 'selected'?>>50</option>
+                  <option value="75" <?php if ($PP == 75) print 'selected'?>>75</option>
+                  <option value="100" <?php if ($PP == 100) print 'selected'?>>100</option>
+                </select>
+              </td>
+
+            </tr>
+          </table>
+          <!-- Table End -->
+
+          <div class="center_align">
+            <input type="submit" class="button" name="do_Search" value="<?php echo __('Go'); ?>" />
+            <input type="submit" class="button" name="do_Orphans" value="<?php echo __('Orphans'); ?>" />
+          </div>
+
+        </div>
+        <!-- Box Content End -->
+
+      </form>
+      <!-- Form End -->
+
+    </div>
+  </center>
-- 
1.4.4.4


-- 
Michael Klier

www:    http://www.chimeric.de
jabber: chi at jabber.shipdown.de
key:    http://downloads.chimeric.de/chi.asc
key-id: 0x8308F551
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://archlinux.org/pipermail/aur-dev/attachments/20080605/fbadd4b0/attachment.pgp>


More information about the aur-dev mailing list