Commit 236c5826 authored by Riccardo Padovani's avatar Riccardo Padovani

Updated views to 7.x-3.10

parent 5e8ef58b
File mode changed from 100755 to 100644
......@@ -423,11 +423,13 @@ class views_handler_argument extends views_handler {
$plugin->options_validate($form['argument_default'][$default_id], $form_state, $form_state['values']['options']['argument_default'][$default_id]);
}
// summary plugin
$summary_id = $form_state['values']['options']['summary']['format'];
$plugin = $this->get_plugin('style', $summary_id);
if ($plugin) {
$plugin->options_validate($form['summary']['options'][$summary_id], $form_state, $form_state['values']['options']['summary']['options'][$summary_id]);
// Validate summary plugin options if one is present.
if (isset($form_state['values']['options']['summary']['format'])) {
$summary_id = $form_state['values']['options']['summary']['format'];
$plugin = $this->get_plugin('style', $summary_id);
if ($plugin) {
$plugin->options_validate($form['summary']['options'][$summary_id], $form_state, $form_state['values']['options']['summary']['options'][$summary_id]);
}
}
$validate_id = $form_state['values']['options']['validate']['type'];
......@@ -453,14 +455,16 @@ class views_handler_argument extends views_handler {
$form_state['values']['options']['default_argument_options'] = $options;
}
// summary plugin
$summary_id = $form_state['values']['options']['summary']['format'];
$plugin = $this->get_plugin('style', $summary_id);
if ($plugin) {
$options = &$form_state['values']['options']['summary']['options'][$summary_id];
$plugin->options_submit($form['summary']['options'][$summary_id], $form_state, $options);
// Copy the now submitted options to their final resting place so they get saved.
$form_state['values']['options']['summary_options'] = $options;
// Handle summary plugin options if one is present.
if (isset($form_state['values']['options']['summary']['format'])) {
$summary_id = $form_state['values']['options']['summary']['format'];
$plugin = $this->get_plugin('style', $summary_id);
if ($plugin) {
$options = &$form_state['values']['options']['summary']['options'][$summary_id];
$plugin->options_submit($form['summary']['options'][$summary_id], $form_state, $options);
// Copy the now submitted options to their final resting place so they get saved.
$form_state['values']['options']['summary_options'] = $options;
}
}
$validate_id = $form_state['values']['options']['validate']['type'];
......
......@@ -14,6 +14,7 @@ class views_handler_field_counter extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['counter_start'] = array('default' => 1);
$options['reverse'] = array('default' => FALSE);
return $options;
}
......@@ -26,6 +27,13 @@ class views_handler_field_counter extends views_handler_field {
'#size' => 2,
);
$form['reverse'] = array(
'#type' => 'checkbox',
'#title' => t('Reverse'),
'#default_value' => $this->options['reverse'],
'#description' => t('Reverse the counter.'),
);
parent::options_form($form, $form_state);
}
......@@ -34,16 +42,24 @@ class views_handler_field_counter extends views_handler_field {
}
function render($values) {
$reverse = empty($this->options['reverse']) ? 1 : -1;
// Note: 1 is subtracted from the counter start value below because the
// counter value is incremented by 1 at the end of this function.
$count = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] - 1 : 0;
$counter_start = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] : 0;
$count = ($reverse == -1) ? count($this->view->result) + $counter_start : $counter_start -1;
$pager = $this->view->query->pager;
// Get the base count of the pager.
if ($pager->use_pager()) {
$count += ($pager->get_items_per_page() * $pager->get_current_page() + $pager->get_offset());
if ($reverse == -1) {
$count = ($pager->total_items + $counter_start - ($pager->get_current_page() * $pager->get_items_per_page()) + $pager->get_offset());
} else {
$count += (($pager->get_items_per_page() * $pager->get_current_page() + $pager->get_offset())) * $reverse;
}
}
// Add the counter for the current site.
$count += $this->view->row_index + 1;
$count += ($this->view->row_index + 1) * $reverse;
return $count;
}
......
......@@ -855,9 +855,6 @@ function views_ui_break_lock_confirm($form, &$form_state, $view) {
}
$cancel = 'admin/structure/views/view/' . $view->name . '/edit';
if (!empty($_REQUEST['cancel'])) {
$cancel = $_REQUEST['cancel'];
}
$account = user_load($view->locked->uid);
return confirm_form($form,
......@@ -2964,7 +2961,7 @@ function views_ui_ajax_form($js, $key, $view, $display_id = '') {
else {
$output = array();
$output[] = views_ajax_command_dismiss_form();
$output[] = views_ajax_command_show_buttons();
$output[] = views_ajax_command_show_buttons(!empty($view->changed));
$output[] = views_ajax_command_trigger_preview();
if (!empty($form_state['#page_title'])) {
$output[] = views_ajax_command_replace_title($form_state['#page_title']);
......
......@@ -169,12 +169,16 @@ function views_ajax_command_scroll_top($selector) {
/**
* Shows Save and Cancel buttons.
*
* @param bool $changed
* Whether of not the view has changed.
*
* @return
* An array suitable for use with the ajax_render() function.
*/
function views_ajax_command_show_buttons() {
function views_ajax_command_show_buttons($changed) {
$command = array(
'command' => 'viewsShowButtons',
'changed' => (bool) $changed,
);
return $command;
}
......
......@@ -117,7 +117,7 @@ class views_object {
$localization_keys = $this->localization_keys;
}
// but plugins don't because there isn't a common init() these days.
else if (!empty($this->is_plugin)) {
else if (!empty($this->is_plugin) && empty($localization_keys)) {
if ($this->plugin_type != 'display') {
$localization_keys = array($this->view->current_display);
$localization_keys[] = $this->plugin_type;
......
......@@ -61,7 +61,9 @@
Drupal.ajax.prototype.commands.viewsShowButtons = function (ajax, response, status) {
$('div.views-edit-view div.form-actions').removeClass('js-hide');
$('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
if (response.changed) {
$('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
}
};
Drupal.ajax.prototype.commands.viewsTriggerPreview = function (ajax, response, status) {
......
......@@ -57,7 +57,7 @@ Drupal.views.ajaxView = function(settings) {
this.settings = settings;
// Add the ajax to exposed forms.
this.$exposed_form = $('form#views-exposed-form-'+ settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));
this.$exposed_form = this.$view.children('.view-filters').children('form');
this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
// Add the ajax to pagers.
......@@ -67,6 +67,12 @@ Drupal.views.ajaxView = function(settings) {
.filter(jQuery.proxy(this.filterNestedViews, this))
.once(jQuery.proxy(this.attachPagerAjax, this));
// Add a trigger to update this view specifically. In order to trigger a
// refresh use the following code.
//
// @code
// jQuery('.view-name').trigger('RefreshView');
// @endcode
// Add a trigger to update this view specifically.
var self_settings = this.element_settings;
self_settings.event = 'RefreshView';
......
......@@ -20,7 +20,7 @@
*/
(function ($, undefined) {
if ($.ui && $.ui.dialog) {
if ($.ui && $.ui.dialog && $.ui.dialog.overlay) {
$.ui.dialog.overlay.events = $.map('focus,keydown,keypress'.split(','),
function(event) { return event + '.dialog-overlay'; }).join(' ');
}
......
......@@ -9,7 +9,7 @@ Drupal.behaviors.viewsContextualLinks = {
// If there are views-related contextual links attached to the main page
// content, find the smallest region that encloses both the links and the
// view, and display it as a contextual links region.
$('.views-contextual-links-page', context).closest(':has(.view)').addClass('contextual-links-region');
$('.views-contextual-links-page', context).closest(':has(".view"):not("body")').addClass('contextual-links-region');
}
};
......
......@@ -25,7 +25,8 @@ function comment_views_default_views() {
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Recent comments';
$handler->display->display_options['use_more'] = TRUE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access comments';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......@@ -134,7 +135,8 @@ function comment_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Recent posts';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......
......@@ -488,7 +488,13 @@ function list_field_views_data($field) {
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $field_name => $field_data) {
if (isset($field_data['filter']) && $field_name != 'delta') {
$data[$table_name][$field_name]['filter']['handler'] = 'views_handler_filter_field_list';
if ($field['type'] == 'list_boolean') {
// Special handler for boolean fields.
$data[$table_name][$field_name]['filter']['handler'] = 'views_handler_filter_field_list_boolean';
}
else {
$data[$table_name][$field_name]['filter']['handler'] = 'views_handler_filter_field_list';
}
}
if (isset($field_data['argument']) && $field_name != 'delta') {
if ($field['type'] == 'list_text') {
......
<?php
/**
* @file
* Definition of views_handler_filter_field_list_boolean.
*/
/**
* Filter handler for boolean fields.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_field_list_boolean extends views_handler_filter_field_list {
function get_value_options() {
$field = field_info_field($this->definition['field_name']);
$value_options = list_allowed_values($field);
// Boolean fields have an option for using the label as the 'on' value. This
// results in there being no label values in the allows values array.
// If this is the case, we need to provide the labels.
$filtered = array_filter($value_options);
if (empty($filtered)) {
// We can't provide the label in the same way the FieldAPI formatter does,
// as these are different on each instance, and we may be operating on
// more than one bundle.
$value_options[0] = t('Off');
$value_options[1] = t('On');
}
$this->value_options = $value_options;
}
}
......@@ -24,7 +24,8 @@ function node_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Monthly archive';
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......@@ -110,7 +111,8 @@ function node_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......@@ -192,7 +194,8 @@ function node_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......
......@@ -24,6 +24,7 @@ function node_views_templates() {
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->display->display_options['title'] = 'Image gallery';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
......
......@@ -23,7 +23,8 @@ function search_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......
......@@ -25,7 +25,8 @@ function statistics_views_default_views() {
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Popular content';
$handler->display->display_options['use_more'] = TRUE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......
......@@ -23,7 +23,8 @@ function taxonomy_views_default_views() {
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['access']['perm'] = 'access content';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['query']['options']['query_comment'] = FALSE;
......
......@@ -75,6 +75,7 @@ class ViewsUiCommentViewsWizard extends ViewsUiBaseViewsWizard {
// Add permission-based access control.
$display_options['access']['type'] = 'perm';
$display_options['access']['perm'] = 'access comments';
// Add a relationship to nodes.
$display_options['relationships']['nid']['id'] = 'nid';
......
......@@ -64,6 +64,7 @@ class ViewsUiNodeViewsWizard extends ViewsUiBaseViewsWizard {
// Add permission-based access control.
$display_options['access']['type'] = 'perm';
$display_options['access']['perm'] = 'access content';
// Remove the default fields, since we are customizing them here.
unset($display_options['fields']);
......
......@@ -15,6 +15,7 @@ class ViewsUiTaxonomyTermViewsWizard extends ViewsUiBaseViewsWizard {
// Add permission-based access control.
$display_options['access']['type'] = 'perm';
$display_options['access']['perm'] = 'access content';
// Remove the default fields, since we are customizing them here.
unset($display_options['fields']);
......
......@@ -5,9 +5,9 @@ core = 7.x
dependencies[] = views
hidden = TRUE
; Information added by Drupal.org packaging script on 2014-05-20
version = "7.x-3.8"
; Information added by Drupal.org packaging script on 2015-02-11
version = "7.x-3.10"
core = "7.x"
project = "views"
datestamp = "1400618928"
datestamp = "1423648085"
......@@ -910,7 +910,7 @@ function hook_views_pre_view(&$view, &$display_id, &$args) {
user_access('administer site configuration') &&
$display_id == 'public_display'
) {
$display_id = 'private_display';
$view->set_display('private_display');
}
}
......
......@@ -102,6 +102,7 @@ files[] = modules/contact/views_handler_field_contact_link.inc
files[] = modules/field/views_handler_field_field.inc
files[] = modules/field/views_handler_relationship_entity_reverse.inc
files[] = modules/field/views_handler_argument_field_list.inc
files[] = modules/field/views_handler_filter_field_list_boolean.inc
files[] = modules/field/views_handler_argument_field_list_string.inc
files[] = modules/field/views_handler_filter_field_list.inc
files[] = modules/filter/views_handler_field_filter_format_name.inc
......@@ -317,9 +318,9 @@ files[] = tests/views_cache.test
files[] = tests/views_view.test
files[] = tests/views_ui.test
; Information added by Drupal.org packaging script on 2014-05-20
version = "7.x-3.8"
; Information added by Drupal.org packaging script on 2015-02-11
version = "7.x-3.10"
core = "7.x"
project = "views"
datestamp = "1400618928"
datestamp = "1423648085"
......@@ -465,16 +465,31 @@ function views_menu_alter(&$callbacks) {
* The menu argument index. This counts from 1.
*/
function views_arg_load($value, $name, $display_id, $index) {
static $views = array();
// Make sure we haven't already loaded this views argument for a similar menu
// item elsewhere.
$key = $name . ':' . $display_id . ':' . $value . ':' . $index;
if (isset($views[$key])) {
return $views[$key];
static $views = array();
$display_ids = is_array($display_id) ? $display_id : array($display_id);
$display_id = reset($display_ids);
foreach ($display_ids as $id) {
// Make sure we haven't already loaded this views argument for a similar
// menu item elsewhere. Since access is always checked for the current user,
// we are sure that the static cache contains valid entries.
$key = $name . ':' . $id . ':' . $value . ':' . $index;
if (isset($views[$key])) {
return $views[$key];
}
// Lazy load the view object to avoid unnecessary work.
if (!isset($view)) {
$view = views_get_view($name);
}
// Pick the first display we have access to.
if ($view && count($display_ids) > 1 && $view->access($id)) {
$display_id = $id;
break;
}
}
if ($view = views_get_view($name)) {
if ($view) {
$view->set_display($display_id);
$view->init_handlers();
......@@ -548,7 +563,7 @@ function views_page_alter(&$page) {
}
/**
* Implements MODULE_preprocess_HOOK().
* Implements MODULE_preprocess_HOOK() for html.tpl.php.
*/
function views_preprocess_html(&$variables) {
// If the page contains a view as its main content, contextual links may have
......@@ -566,7 +581,7 @@ function views_preprocess_html(&$variables) {
if (!empty($variables['page']['#views_contextual_links_info'])) {
$key = array_search('contextual-links-region', $variables['classes_array']);
if ($key !== FALSE) {
unset($variables['classes_array'][$key]);
$variables['classes_array'] = array_diff($variables['classes_array'], array('contextual-links-region'));
// Add the JavaScript, with a group and weight such that it will run
// before modules/contextual/contextual.js.
drupal_add_js(drupal_get_path('module', 'views') . '/js/views-contextual.js', array('group' => JS_LIBRARY, 'weight' => -1));
......@@ -574,6 +589,27 @@ function views_preprocess_html(&$variables) {
}
}
/**
* Implements hook_preprocess_HOOK() for page.tpl.php.
*/
function views_preprocess_page(&$variables) {
// If the page contains a view as its main content, contextual links may have
// been attached to the page as a whole; for example, by views_page_alter().
// This allows them to be associated with the page and rendered by default
// next to the page title (which we want). However, it also causes the
// Contextual Links module to treat the wrapper for the entire page (i.e.,
// the <body> tag) as the HTML element that these contextual links are
// associated with. This we don't want; for better visual highlighting, we
// prefer a smaller region to be chosen. The region we prefer differs from
// theme to theme and depends on the details of the theme's markup in
// page.tpl.php, so we can only find it using JavaScript. We therefore remove
// the "contextual-links-region" class from the <body> tag here and add
// JavaScript that will insert it back in the correct place.
if (!empty($variables['page']['#views_contextual_links_info'])) {
$variables['classes_array'] = array_diff($variables['classes_array'], array('contextual-links-region'));
}
}
/**
* Implements hook_contextual_links_view_alter().
*/
......
......@@ -7,9 +7,9 @@ dependencies[] = views
files[] = views_ui.module
files[] = plugins/views_wizard/views_ui_base_views_wizard.class.php
; Information added by Drupal.org packaging script on 2014-05-20
version = "7.x-3.8"
; Information added by Drupal.org packaging script on 2015-02-11
version = "7.x-3.10"
core = "7.x"
project = "views"
datestamp = "1400618928"
datestamp = "1423648085"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment