Index: views/views.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/views.module,v retrieving revision 1.166.2.43 diff -u -p -r1.166.2.43 views.module --- views/views.module 14 Jul 2007 18:54:16 -0000 1.166.2.43 +++ views/views.module 24 Jul 2007 00:26:46 -0000 @@ -1,6 +1,9 @@ access) { + if (!$view->access) { return TRUE; } @@ -523,7 +526,7 @@ function views_build_view($type, &$view, if ($args == NULL) { $args = array(); } - + // if no filter values are passed in, get them from the $_GET array if ($filters == NULL) { $filters = views_get_filter_values(); @@ -592,6 +595,15 @@ function views_build_view($type, &$view, return $info; } + // modify the view if it is a form -- remove exposed filters and add in + // any items that have been selected by the user + if($view->page_type == 'form') { + if ($view->missing) { + $items = array_merge($view->missing, $items); + } + $view->exposed_filter = array(); + } + // Call a hook that'll let modules modify the view just before it is displayed. foreach (module_implements('views_pre_view') as $module) { $function = $module .'_views_pre_view'; @@ -832,47 +844,47 @@ function views_invalidate_cache() { */ function _views_view_fields() { return array( - 'vid' => '%d', - 'name' => "'%s'", - 'description' => "'%s'", - 'access' => "'%s'", - 'page' => '%d', - 'page_title' => "'%s'", - 'page_header' => "'%s'", - 'page_header_format' => '%d', - 'page_footer' => "'%s'", - 'page_footer_format' => '%d', - 'page_empty' => "'%s'", - 'page_empty_format' => '%d', - 'page_type' => "'%s'", - 'use_pager' => '%d', - 'nodes_per_page' => '%d', - 'url' => "'%s'", - 'menu' => '%d', - 'menu_tab' => '%d', - 'menu_tab_default' => '%d', - 'menu_tab_weight' => '%d', - 'menu_title' => "'%s'", + 'vid' => '%d', + 'name' => "'%s'", + 'description' => "'%s'", + 'access' => "'%s'", + 'page' => '%d', + 'page_title' => "'%s'", + 'page_header' => "'%s'", + 'page_header_format' => '%d', + 'page_footer' => "'%s'", + 'page_footer_format' => '%d', + 'page_empty' => "'%s'", + 'page_empty_format' => '%d', + 'page_type' => "'%s'", + 'use_pager' => '%d', + 'nodes_per_page' => '%d', + 'url' => "'%s'", + 'menu' => '%d', + 'menu_tab' => '%d', + 'menu_tab_default' => '%d', + 'menu_tab_weight' => '%d', + 'menu_title' => "'%s'", 'menu_tab_default_parent_type' => "'%s'", - 'menu_parent_title' => "'%s'", - 'menu_parent_tab_weight' => '%d', - 'block' => '%d', - 'block_title' => "'%s'", - 'block_use_page_header' => '%d', - 'block_header' => "'%s'", - 'block_header_format' => '%d', - 'block_use_page_footer' => '%d', - 'block_footer' => "'%s'", - 'block_footer_format' => '%d', - 'block_use_page_empty' => '%d', - 'block_empty' => "'%s'", - 'block_empty_format' => '%d', - 'block_type' => "'%s'", - 'nodes_per_block' => '%d', - 'block_more' => '%d', - 'breadcrumb_no_home' => '%d', - 'changed' => '%d', - 'view_args_php' => "'%s'", + 'menu_parent_title' => "'%s'", + 'menu_parent_tab_weight' => '%d', + 'block' => '%d', + 'block_title' => "'%s'", + 'block_use_page_header' => '%d', + 'block_header' => "'%s'", + 'block_header_format' => '%d', + 'block_use_page_footer' => '%d', + 'block_footer' => "'%s'", + 'block_footer_format' => '%d', + 'block_use_page_empty' => '%d', + 'block_empty' => "'%s'", + 'block_empty_format' => '%d', + 'block_type' => "'%s'", + 'nodes_per_block' => '%d', + 'block_more' => '%d', + 'breadcrumb_no_home' => '%d', + 'changed' => '%d', + 'view_args_php' => "'%s'", 'is_cacheable' => '%d', ); } @@ -1314,7 +1326,7 @@ function views_filters($view) { $form['#action'] = url($view->real_url ? $view->real_url : $view->url, NULL, NULL, true); $form['view'] = array('#type' => 'value', '#value' => $view); $form['submit'] = array('#type' => 'button', '#name' => '', '#value' => t('Submit')); - + // clean URL get forms breaks if we don't give it a 'q'. if (!(bool)variable_get('clean_url', '0')) { $form['q'] = array( @@ -1386,7 +1398,7 @@ function _views_build_filters_form($view } $form["filter$count"] = $item; } - + return $form; } @@ -1854,6 +1866,14 @@ function views_views_style_plugins() { 'theme' => 'views_view_nodes', 'weight' => -7, ), + 'form' => array( + 'name' => t('View Form'), + 'theme' => 'views_view_form', + 'needs_fields' => true, + 'needs_table_header' => true, + 'weight' => -9, + 'hide' => true, + ), ); } @@ -1999,7 +2019,7 @@ function views_handler_filter_null($op, $operator = $filter['operator']; $query->add_where("$field $operator NULL"); break; - } + } } /** @@ -2143,4 +2163,40 @@ function views_form_alter($form_id, &$fo // An implementation of hook_devel_caches() from devel.module. Must be in views.module so it always is included. function views_devel_caches() { return array('cache_views'); -} \ No newline at end of file +} + +/** +* Implementation of hook_elements(); +* +* Here we define a views_node_selector form element that can be used to +* get back 1 or more nids using a view. We use the front page view as a +* default, as this ships with every views install. Of course, you'll want to +* override this default in your use of the element. +* +* We also provide a #multiple field to indicate if this field is a single +* select or multi-select. +*/ +function views_elements() { + + $type['views_node_selector'] = array( + '#input' => TRUE, + '#process' => array('views_form_process_element' => array()), + '#view' => VIEWS_FORM_DEFAULT_VIEW, + '#multiple' => false, + '#page' => 0, + '#collapsed' => false, + '#collapsible' => false, + '#arguments' => array(), + '#embedded' => false, // kratib: This new setting controls whether we're embedding the selector in its own view. + ); + + return $type; +} + +/** + * A place holder for the element processing function, located in views_form.inc + */ +function views_form_process_element($element) { + include_once drupal_get_path('module', 'views') . '/views_form.inc'; + return _views_form_process_element($element); +} Index: views/views_cache.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/views_cache.inc,v retrieving revision 1.2.2.18 diff -u -p -r1.2.2.18 views_cache.inc --- views/views_cache.inc 14 Jul 2007 19:12:02 -0000 1.2.2.18 +++ views/views_cache.inc 24 Jul 2007 00:26:46 -0000 @@ -307,7 +307,7 @@ function _views_get_query(&$view, $args, * array is cached in a static variable so that arguments * are only constructed once per run. */ -function _views_get_style_plugins($titles = false) { +function _views_get_style_plugins($titles = false, $display_only = false) { static $views_style_plugins; global $locale; @@ -331,5 +331,16 @@ function _views_get_style_plugins($title cache_set("views_style_plugins:$locale", 'cache_views', serialize($cache)); } } - return ($titles ? $views_style_plugins['title'] : $views_style_plugins['base']); -} \ No newline at end of file + $return = $views_style_plugins; + // remove any plugins that are not listed in drop down menu if $display_only is true + if ($display_only) { + foreach($views_style_plugins['base'] as $plugin => $def) { + if ($def['hide'] == true) { + unset($return['base'][$plugin]); + unset($return['titles'][$plugin]); + } + } + } + + return ($titles ? $return['title'] : $return['base']); +} Index: views/views_ui.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/views_ui.module,v retrieving revision 1.44.2.25 diff -u -p -r1.44.2.25 views_ui.module --- views/views_ui.module 14 Jul 2007 19:54:20 -0000 1.44.2.25 +++ views/views_ui.module 24 Jul 2007 00:26:48 -0000 @@ -715,7 +715,7 @@ function _views_check_ops(&$view, $op, $ /** * Custom form element to do our nice images. */ -function views_elements() { +function views_ui_elements() { $type['views_imagebutton'] = array('#input' => TRUE, '#button_type' => 'submit',); return $type; } @@ -848,7 +848,7 @@ function views_edit_view($view, $op = '' '#type' => 'select', '#title' => t('View Type'), '#default_value' => $view->page_type, - '#options' => _views_get_style_plugins(true), + '#options' => _views_get_style_plugins(true, true), '#description' => t('How the nodes should be displayed to the user.'), ); @@ -1037,7 +1037,7 @@ function views_edit_view($view, $op = '' '#type' => 'select', '#title' => t('View Type'), '#default_value' => $view->block_type, - '#options' => _views_get_style_plugins(true), + '#options' => _views_get_style_plugins(true, true), '#description' => t('How the nodes should be displayed to the user.'), ); Index: views/modules/views_node.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/modules/views_node.inc,v retrieving revision 1.30.2.19 diff -u -p -r1.30.2.19 views_node.inc --- views/modules/views_node.inc 14 Jul 2007 19:30:51 -0000 1.30.2.19 +++ views/modules/views_node.inc 24 Jul 2007 00:26:48 -0000 @@ -241,6 +241,14 @@ function node_views_tables() { 'handler' => 'views_handler_filter_body', 'help' => t('This filter allows nodes to be filtered by their body.'), ), + 'include_exclude' => array( + 'name' => t('Node: Include/Exclude Nodes'), + 'field' => 'nid', + 'operator' => 'views_handler_operator_or', + 'value' => views_handler_filter_nid_value_form(VIEWS_FORM_DEFAULT_VIEW), + 'value-type' => 'array', + 'help' => t('This filter allows you to limit your view to only apply to some specific nodes. You can limit your view to a specific list of nodes, or you can exclude specific nodes from every being returned.'), + ), ), ); @@ -925,3 +933,17 @@ function views_handler_node_delete_desti function views_handler_node_nid($fieldinfo, $fielddata, $value, $data) { return $data->nid; } + +/** + * Provide a configuration form for the include/exclude filter + */ +function views_handler_filter_nid_value_form($view) { + + $form['vns'] = array ( + '#type' => 'views_node_selector', + '#view' => $view, + '#multiple' => true, + ); + + return $form; +}