Index: flexinode.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/flexinode/flexinode.module,v
retrieving revision 1.46.2.2
diff -U5 -r1.46.2.2 flexinode.module
--- flexinode.module	2 May 2005 16:37:16 -0000	1.46.2.2
+++ flexinode.module	2 Sep 2005 19:03:57 -0000
@@ -135,21 +135,26 @@
 
   if ($may_cache) {
     foreach (flexinode_content_types() as $ctype) {
       $items[] = array('path' => 'node/add/flexinode-'. $ctype->ctype_id, 'title' => t($ctype->name),
         'access' => user_access('create '. $ctype->name .' content'));
+      $items[] = $items[] = array('path' => 'search/flexinode/'. $ctype->ctype_id, 'title' => t($ctype->name),
+        'callback' => 'flexinode_page_search_form',
+        'access' => (user_access('access content') && user_access('search content')),
+        'type' => MENU_LOCAL_TASK);
     }
 
     $items[] = array('path' => 'flexinode/list', 'title' => t('list view'),
       'callback' => 'flexinode_page_list', 'access' => user_access('access content'),
       'type' => MENU_CALLBACK);
     $items[] = array('path' => 'flexinode/table', 'title' => t('tabular view'),
       'callback' => 'flexinode_page_table', 'access' => user_access('access content'),
       'type' => MENU_CALLBACK);
-    $items[] = array('path' => 'flexinode/search', 'title' => t('search'),
-      'callback' => 'flexinode_page_search_form', 'access' => user_access('access content'),
-      'type' => MENU_CALLBACK);
+    $items[] = array('path' => 'search/flexinode', 'title' => t('advanced'),
+      'callback' => 'flexinode_page_search_form',
+      'access' => (user_access('access content') && user_access('search content')),
+      'type' => MENU_LOCAL_TASK);
     $items[] = array('path' => 'flexinode/feed', 'title' => t('rss feed'),
       'callback' => 'flexinode_feed', 'access' => user_access('access content'),
       'type' => MENU_CALLBACK);
 
     $access = user_access('administer content types');
@@ -208,11 +213,11 @@
 
 /**
  * Menu callback; presents a search form for nodes of one type.
  */
 function flexinode_page_search_form($ctype_id = 0) {
-  if (!$ctype_id) {
+  if (!$ctype_id && !$ctype_id = arg(2)) {
     drupal_not_found();
   }
 
   if ($_POST['op'] == t('Search')) {
     return flexinode_page_table($ctype_id);
@@ -269,17 +274,18 @@
         $sql .= ' AND '. $clause;
       }
     }
 
     $search = db_escape_string($edit['search']);
-    if ($search) {
-      $sql .= " AND (n.title LIKE '%". $search ."%'";
-      foreach ($ctype->fields as $field) {
-        $sql .= 'OR flexinode_'. $field->field_id .".textual_data LIKE '%". $search ."%'";
-      }
-      $sql .= ')';
+    if ($search = '') {
+      $search = '%';
     }
+    $sql .= " AND (n.title LIKE '%". $search ."%'";
+    foreach ($ctype->fields as $field) {
+      $sql .= 'OR flexinode_'. $field->field_id .".textual_data LIKE '%". $search ."%'";
+    }
+    $sql .= ')';
   }
 
   // Build the columns.
   $header[] = array('data' => t('title'), 'field' => 'n.title');
   foreach ($ctype->fields as $field) {
@@ -310,14 +316,19 @@
       }
     }
     $rows[] = $row;
   }
 
-  $output .= theme('table', $header, $rows);
-  $output .= theme('pager', NULL, 20, 0, tablesort_pager());
+  if ($rows) {
+    $output .= theme('table', $header, $rows);
+    $output .= theme('pager', NULL, 20, 0, tablesort_pager());
+    drupal_set_title(t('%type search results', array('%type' => t($ctype->name))));
+  }
+  else {
+     $output .= theme('box', t('Your search yielded no results'), search_help('search#noresults'));
+  }
 
-  drupal_set_title(t('%type search results', array('%type' => t($ctype->name))));
   print theme('page', $output);
 }
 
 /**
  * Menu callback; presents a form to add a new content type.
