diff -urp views_filterblock_old/views_filterblock.info views_filterblock/views_filterblock.info --- views_filterblock_old/views_filterblock.info 2009-04-21 14:38:00.000000000 -0500 +++ views_filterblock/views_filterblock.info 2009-04-21 14:39:47.000000000 -0500 @@ -1,11 +1,11 @@ ; $Id: views_filterblock.info,v 1.1.2.3 2007/08/07 13:15:27 douggreen Exp $ name = Views FilterBlock description = Move the views filter form to a block. -dependencies = views +dependencies[] = views package = "Views" -; Information added by drupal.org packaging script on 2008-02-19 -version = "5.x-1.4" +version = "6.x-1.0" project = "views_filterblock" -datestamp = "1203429013" + +core = 6.x diff -urp views_filterblock_old/views_filterblock.module views_filterblock/views_filterblock.module --- views_filterblock_old/views_filterblock.module 2009-04-21 14:38:00.000000000 -0500 +++ views_filterblock/views_filterblock.module 2009-04-21 14:45:16.000000000 -0500 @@ -6,23 +6,20 @@ * in a block */ -include_once(drupal_get_path('module', 'views') .'/views_cache.inc'); +module_load_include('inc', 'views', 'views_cache'); /** * Implementation of hook_menu() */ -function views_filterblock_menu($may_cache) { - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/views_filterblock', - 'title' => t('Views Filter Block'), - 'description' => t('Move the views filter form to a block.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 'views_filterblock_settings', - 'access' => user_access('administer site configuration'), +function views_filterblock_menu() { + $items['admin/settings/views_filterblock'] = array( + 'title' => 'Views Filter Block', + 'description' => 'Move the views filter form to a block.', + 'page callback' => 'drupal_get_form', + 'page arguments' => 'views_filterblock_settings', + 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, // optional ); - } return $items; } @@ -49,17 +46,11 @@ function views_filterblock_block($op = ' } elseif ($op == 'configure') { $options[''] = '-- Select One --'; - $result = db_query('SELECT * FROM {view_view} WHERE page=1'); - while ($view = db_fetch_object($result)) { - $options[$view->name] = $view->description ? $view->description : $view->name; - $used[$view->name] = true; - } - $default_views = _views_get_default_views(); - foreach ($default_views as $name => $view) { - if ($view->page && !$used[$view->name]) { - $options[$view->name] = $view->description; - } - } + $views = views_get_all_views(); + foreach ($views as $view) { + $options[$view->name] = $view->name; + $used[$view->name] = TRUE; + } asort($options); $var = 'views_filterblock_view'; @@ -83,116 +74,23 @@ function views_filterblock_block($op = ' } function _views_filterblock_block($delta) { - // TODO: this needs to be rewritten for Drupal 5.0 if ($name = variable_get("views_filterblock_view.$delta", '')) { if ($view = views_get_view($name)) { - return drupal_get_form('views_filterblock', $view); + return views_filterblock($view); } } } function views_filterblock($view) { - $form = views_filters($view); - $form['#action'] = url($view->url); - $form['#views_filterblock'] = true; - return $form; -} - -function theme_views_filterblock($form) { - $view = $form['view']['#value']; - - // make the 'q' come first - $output = drupal_render($form['q']); - - foreach ($view->exposed_filter as $count => $filter) { - $newform["fieldset$count"] = array( - '#type' => 'fieldset', - '#title' => $filter['label'], - '#collapsible' => false, // don't want the form to collapse - ead 6.12.08 - '#weight' => $count - 1000, // we'll never have this many filters - ); - $newform["fieldset$count"]['#collapsed'] = false; // don't want the form to collapse - ead 6.12.08 - } - - foreach ($form as $field => $value) { - if (preg_match('/(op|filter)([0-9]+)/', $field, $match)) { - $curcount = $match[2]; - $newform["fieldset$curcount"][$field] = $value; - if ($newform["fieldset$curcount"][$field]['#value'] == '') { - unset($newform["fieldset$curcount"][$field]['#value']); - } - - if (!isset($newform["fieldset$curcount"]['#weight'])) { - $newform["fieldset$curcount"]['#weight'] = $value['#weight']; - } - } - else { - if ($field == 'submit' || drupal_substr($field, 0, 1) == '#') { - unset($curcount); - } - if (isset($curcount)) { - $newform["fieldset$curcount"][$field] = $value; - } - else { - $newform[$field] = $value; - } - } - } - - foreach ($view->exposed_filter as $count => $filter) { - if ($filter['is_default']) { - $newform["fieldset$count"]['#collapsed'] = FALSE; - $open = TRUE; - } - else { - $value = $newform["fieldset$count"]["filter$count"]['#default_value']; - if (isset($value)) { - if (is_array($value)) { - foreach ($value as $key => $item) { - if ($item != '') { - $newform["fieldset$count"]['#collapsed'] = FALSE; - $open = TRUE; - } - } - } - elseif ($value != '') { - $newform["fieldset$count"]['#collapsed'] = FALSE; - $open = TRUE; - } - } - } - } - if (!$open) { - $newform["fieldset0"]['#collapsed'] = FALSE; - } - - return $output . theme('views_filterblock_output', $newform); -} - -function theme_views_filterblock_output($form) { - return drupal_render($form); -} - -/** - * Implementation of hook_form_alter(). - */ -function views_filterblock_form_alter($form_id, &$form) { - if ($form_id == 'views_filters') { - /** - * Hide the form displayed as part of the view, when the - * filterform is displayed in a block - */ - $name = $form['view']['#value']->name; - if (!$form['#views_filterblock']) { - // get the list of regions - global $theme_key; - $result = db_query("SELECT delta FROM {blocks} WHERE theme = '%s' AND module = 'views_filterblock'", $theme_key); - while ($block = db_fetch_object($result)) { - if (variable_get('views_filterblock_view.'. $block->delta, '') == $name) { - $form['#type'] = 'hidden'; - return; - } - } - } - } + $view->set_display('default'); + $view->init_handlers(); + $form_state = array( + 'view' => $view, + 'display' => $view->display_handler->display, + 'method' => 'get', + 'rerender' => TRUE, + 'no_redirect' => TRUE, + ); + $output = drupal_build_form('views_exposed_form', $form_state); + return $output; }