commit 37688ccdb93bbe6cbd9e57f1888a07bb63e7ff1b Author: Robert Caracaus Date: Thu May 23 19:04:16 2013 +1000 1843748-56.patch diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index 3f30a4a..2c49bc5 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -47,6 +47,43 @@ function hook_search_info() { } /** + * Provide search query conditions. + * + * Callback for hook_search_info(). + * + * This callback is invoked by search_view() to get an array of additional + * search conditions to pass to search_data(). For example, a search module + * may get additional keywords, filters, or modifiers for the search from + * the query string. + * + * This example pulls additional search keywords out of the $_REQUEST variable, + * (i.e. from the query string of the request). The conditions may also be + * generated internally - for example based on a module's settings. + * + * @param $keys + * The search keywords string. + * + * @return + * An array of additional conditions, such as filters. + * + * @ingroup search + */ +function callback_search_conditions($keys) { + $conditions = array(); + + if (!empty($_REQUEST['keys'])) { + $conditions['keys'] = $_REQUEST['keys']; + } + if (!empty($_REQUEST['sample_search_keys'])) { + $conditions['sample_search_keys'] = $_REQUEST['sample_search_keys']; + } + if ($force_keys = config('sample_search.settings')->get('force_keywords')) { + $conditions['sample_search_force_keywords'] = $force_keys; + } + return $conditions; +} + +/** * Define access to a custom search routine. * * This hook allows a module to define permissions for a search tab. @@ -359,42 +396,3 @@ function hook_update_index() { /** * @} End of "addtogroup hooks". */ - -/** - * Provide search query conditions. - * - * Callback for hook_search_info(). - * - * This callback is invoked by search_view() to get an array of additional - * search conditions to pass to search_data(). For example, a search module - * may get additional keywords, filters, or modifiers for the search from - * the query string. - * - * This example pulls additional search keywords out of the $_REQUEST variable, - * (i.e. from the query string of the request). The conditions may also be - * generated internally - for example based on a module's settings. - * - * @param $keys - * The search keywords string. - * - * @return - * An array of additional conditions, such as filters. - * - * @ingroup callbacks - * @ingroup search - */ -function callback_search_conditions($keys) { - $conditions = array(); - - if (!empty($_REQUEST['keys'])) { - $conditions['keys'] = $_REQUEST['keys']; - } - if (!empty($_REQUEST['sample_search_keys'])) { - $conditions['sample_search_keys'] = $_REQUEST['sample_search_keys']; - } - if ($force_keys = config('sample_search.settings')->get('force_keywords')) { - $conditions['sample_search_force_keywords'] = $force_keys; - } - return $conditions; -} - diff --git a/core/modules/views/templates/views-view-field.tpl.php b/core/modules/views/templates/views-view-field.tpl.php deleted file mode 100644 index 91d92ee..0000000 --- a/core/modules/views/templates/views-view-field.tpl.php +++ /dev/null @@ -1,25 +0,0 @@ -{$field->field_alias} - * - * The above will guarantee that you'll always get the correct data, - * regardless of any changes in the aliasing that might happen if - * the view is modified. - */ -?> - diff --git a/core/modules/views/templates/views-view-fields.html.twig b/core/modules/views/templates/views-view-fields.html.twig new file mode 100644 index 0000000..38525c7 --- /dev/null +++ b/core/modules/views/templates/views-view-fields.html.twig @@ -0,0 +1,42 @@ +{# +/** + * @file + * Default view template to display all the fields in a row. + * + * Available variables: + * - view: The view in use. + * - fields: A list of fields, each one contains: + * - content: The output of the field. + * - raw: The raw data for the field, if it exists. This is NOT output safe. + * - class: The safe class ID to use. + * - handler: The Views field handler controlling this field. + * - inline: Whether or not the field should be inline. + * - inline_html: Either div or span based on the 'inline' flag. + * - wrapper_prefix: A complete wrapper containing the inline_html to use. + * - wrapper_suffix: The closing tag for the wrapper. + * - separator: An optional separator that may appear before a field. + * - label: The field's label text. + * - label_html: The full HTML of the label to use including configured + * element type. + * - row: The raw result from the query, with all data it fetched. + * + * @see template_preprocess() + * @see template_preprocess_views_view_fields() + * + * @ingroup themeable + */ +#} + +{% for field in fields %} + {{ field.separator }} + + {{ field.wrapper_prefix }} + {{ field.label_html }} + {{ field.content }} + {{ field.wrapper_suffix }} +{% endfor %} diff --git a/core/modules/views/templates/views-view-fields.tpl.php b/core/modules/views/templates/views-view-fields.tpl.php deleted file mode 100644 index ae3a4c6..0000000 --- a/core/modules/views/templates/views-view-fields.tpl.php +++ /dev/null @@ -1,36 +0,0 @@ -content: The output of the field. - * - $field->raw: The raw data for the field, if it exists. This is NOT output safe. - * - $field->class: The safe class id to use. - * - $field->handler: The Views field handler object controlling this field. Do not use - * var_export to dump this object, as it can't handle the recursion. - * - $field->inline: Whether or not the field should be inline. - * - $field->inline_html: either div or span based on the above flag. - * - $field->wrapper_prefix: A complete wrapper containing the inline_html to use. - * - $field->wrapper_suffix: The closing tag for the wrapper. - * - $field->separator: an optional separator that may appear before a field. - * - $field->label: The wrap label text to use. - * - $field->label_html: The full HTML of the label to use including - * configured element type. - * - $row: The raw result object from the query, with all data it fetched. - * - * @ingroup views_templates - */ -?> - $field): ?> - separator)): ?> - separator; ?> - - - wrapper_prefix; ?> - label_html; ?> - content; ?> - wrapper_suffix; ?> - diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index e987ffd..93919f5 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -175,7 +175,23 @@ function template_preprocess_views_view(&$vars) { } /** - * Preprocess theme function to print a single record from a row, with fields + * Prepares variables for views fields templates. + * + * Default template: views-view-fields.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: The view object. + * - options: An array of options. Each option contains: + * - inline: An array that contains the fields that are to be + * displayed inline. + * - default_field_elements: If default field wrapper + * elements are to be provided. + * - hide_empty: Whether the field is to be hidden if empty. + * - element_default_classes: If the default classes are to be added. + * - separator: A string to be placed between inline fields to keep them + * visually distinct. + * - row: An array containing information about the current row. */ function template_preprocess_views_view_fields(&$vars) { $view = $vars['view']; @@ -295,6 +311,28 @@ function template_preprocess_views_view_fields(&$vars) { } +/* + * Display multiple views fields. + */ +function theme_views_view_fields($vars) { + $fields = $vars['fields']; + $output = ''; + + foreach ($fields as $id => $field) { + if (!empty($field->separator)) { + $output .= $field->separator; + } + + $output .= $field->wrapper_prefix; + $output .= $field->label_html; + $output .= $field->content; + + $output .= $field->wrapper_suffix; + } + + return $output; +} + /** * Process a single grouping within a view. */