Index: bot_factoid/bot_factoid.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bot/bot_factoid/Attic/bot_factoid.module,v
retrieving revision 1.1.2.6.2.13
diff -u -p -r1.1.2.6.2.13 bot_factoid.module
--- bot_factoid/bot_factoid.module	15 Jul 2008 00:08:21 -0000	1.1.2.6.2.13
+++ bot_factoid/bot_factoid.module	3 Dec 2008 02:52:19 -0000
@@ -51,7 +51,14 @@ function bot_factoid_overview() {
   $headers = array(t('Subject'), t('Is/Are'), t('Statement'));
 
   $rows = array(); // storage of gimme-gimme awesomeness. wheedoggy!
-  $results = pager_query('SELECT subject, is_are, statement FROM {bot_factoid} ORDER BY subject', 25);
+  // Optionally filter result set by passed-in search term.
+  if (!empty($_GET['search']) && !(isset($_GET['op']) && $_GET['op'] == t('Reset'))) {
+    $where = " WHERE LOWER(subject) LIKE LOWER('%%s%') OR LOWER(statement) LIKE LOWER('%%s%') ";
+  }
+  else {
+    $where = $_GET['search'] = '';
+  }
+  $results = pager_query('SELECT subject, is_are, statement FROM {bot_factoid} ' . $where . ' ORDER BY subject', 25, 0, NULL, $_GET['search']);
   while ($result = db_fetch_object($results)) {
     $rows[] = array(
       array('data' => check_plain($result->subject), 'class' => 'subject'),
@@ -59,6 +66,7 @@ function bot_factoid_overview() {
       array('data' => check_plain($result->statement), 'class' => 'statement')
     );
   }
+  $output .= drupal_get_form('bot_factoid_search_form');
   $output .= theme('table', $headers, $rows, array('id' => 'factoids'));
   $output .= theme('pager', NULL, 25, 0);
 
@@ -66,6 +74,33 @@ function bot_factoid_overview() {
 }
 
 /**
+ * Render a form to search for factoids.
+ */
+function bot_factoid_search_form() {
+  $form['#method'] = 'get';
+  $form['search'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Search'),
+    '#description' => t('Enter a (case-insensitive) text string to search for.'),
+    '#collapsible' => FALSE,
+  );
+  $form['search'][0] = array(
+    '#prefix' => '<div class="container-inline">',
+    '#suffix' => '</div>',
+  );
+  $form['search'][0]['search'] = array(
+    '#type' => 'textfield',
+    '#default_value' => (!empty($_GET['search']) ? $_GET['search'] : ''),
+    '#size' => 60,
+    '#maxlength' => 128,
+    '#required' => TRUE,
+  );
+  $form['search'][0]['submit'] = array('#type' => 'submit', '#value' => t('Search'));
+  $form['search'][0]['reset'] = array('#type' => 'submit', '#value' => t('Reset'));
+  return $form;
+}
+
+/**
  * Listen for conversation directed at, or about, the bot.
  *
  * @param $data
