Index: imagebrowser.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/imagebrowser/imagebrowser.module,v
retrieving revision 1.4.2.3
diff -u -r1.4.2.3 imagebrowser.module
--- imagebrowser.module	24 Oct 2009 17:04:41 -0000	1.4.2.3
+++ imagebrowser.module	1 Nov 2009 13:19:53 -0000
@@ -166,6 +166,16 @@
 }
 
 /**
+ * Implementation of hook_form_alter().
+ */
+function imagebrowser_form_views_exposed_form_alter(&$form, &$form_state) {
+  if ($form_state['view']->name == variable_get('imagebrowser_view','ib_browser')) {
+    $form['#theme'] = array('imagebrowser_exposed_form') + $form['#theme'];
+	$form['submit']['#value'] = t('Search');
+  }
+}
+
+/**
  * Replace title tokens.
  */
 function imagebrowser_title_callback($title, $rid = null) {
@@ -293,7 +303,8 @@
   
   //Get view javascript settings
   $args = array();
-
+  $path = (isset($plugins[$program])) ? 'imagebrowser/'.$program : 'imagebrowser';
+  $view->override_path = $path;
   $view = views_get_view(variable_get('imagebrowser_view','ib_browser'));
   $view->set_display('default');
   $settings = array(
@@ -659,10 +670,69 @@
         'classes' => NULL,
       ),
     ),
+    'imagebrowser_exposed_form' => array(
+      'template' => 'imagebrowser-exposed-form',
+      'path' => $path,
+      'arguments' => array(
+        'form' => NULL,
+      ),
+    ),
   );
 }
 
 /**
+ * This is the default preprocess function of Views for exposed forms.
+ */
+function template_preprocess_imagebrowser_exposed_form(&$vars) {
+  $form = &$vars['form'];
+
+  // Put all single checkboxes together in the last spot.
+  $checkboxes = '';
+
+  if (!empty($form['q'])) {
+    $vars['q'] = drupal_render($form['q']);
+  }
+
+  $vars['widgets'] = array();
+  foreach ($form['#info'] as $id => $info) {
+    // Set aside checkboxes.
+    if (isset($form[$info['value']]['#type']) && $form[$info['value']]['#type'] == 'checkbox') {
+      $checkboxes .= drupal_render($form[$info['value']]);
+      continue;
+    }
+    $widget = new stdClass;
+    // set up defaults so that there's always something there.
+    $widget->label = $widget->operator = $widget->widget = NULL;
+
+    if (!empty($info['label'])) {
+      $widget->label = $info['label'];
+    }
+    if (!empty($info['operator'])) {
+      $widget->operator = drupal_render($form[$info['operator']]);
+    }
+    $widget->widget = drupal_render($form[$info['value']]);
+    $vars['widgets'][$id] = $widget;
+  }
+
+  // Wrap up all the checkboxes we set aside into a widget.
+  if ($checkboxes) {
+    $widget = new stdClass;
+    // set up defaults so that there's always something there.
+    $widget->label = $widget->operator = $widget->widget = NULL;
+    $widget->widget = $checkboxes;
+    $vars['widgets']['checkboxes'] = $widget;
+  }
+
+  // Don't render these:
+  unset($form['form_id']);
+  unset($form['form_build_id']);
+  unset($form['form_token']);
+
+  // This includes the submit button.
+  $vars['button'] = drupal_render($form);
+}
+
+/**
  * Theme an IB image.
  */
 function theme_ibimage($image, $link, $link_target) {
--- imagebrowser-exposed-form.tpl.php
+++ imagebrowser-exposed-form.tpl.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * @file filters.tpl.php
+ *
+ * This template handles the layout of the views exposed filter form.
+ *
+ * Variables available:
+ * - $widgets: An array of exposed form widgets. Each widget contains:
+ * - $widget->label: The visible label to print. May be optional.
+ * - $widget->operator: The operator for the widget. May be optional.
+ * - $widget->widget: The widget itself.
+ * - $button: The submit button for the form.
+ *
+ * @ingroup views_templates
+ */
+?>
+<?php if (!empty($q)): ?>
+  <?php
+    // This ensures that, if clean URLs are off, the 'q' is added first so that
+    // it shows up first in the URL.
+    print $q;
+  ?>
+<?php endif; ?>
+<div class="imagebrowser-exposed-form">
+  <?php foreach($widgets as $id => $widget): ?>
+    <div class="imagebrowser-exposed-widget">
+      <?php if (!empty($widget->label)): ?>
+        <label>
+          <?php print $widget->label; ?>
+        </label>
+      <?php endif; ?>
+      <?php if (!empty($widget->operator)): ?>
+        <div class="imagebrowser-operator">
+          <?php print $widget->operator; ?>
+        </div>
+      <?php endif; ?>
+      <div class="imagebrowser-widget">
+        <?php print $widget->widget; ?>
+      </div>
+    </div>
+  <?php endforeach; ?>
+    <div class="imagebrowser-exposed-widget">
+      <?php print $button ?>
+    </div>
+  </div>
+</div>


