Commit cb396db7 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-644] Upgrade Views to 3.5

parent 61b25013
......@@ -67,6 +67,15 @@
background-color: #f6f6f6;
}
.views-ui-dialog a {
color: #0071b3;
}
.views-ui-dialog a:hover,
.views-ui-dialog a:focus {
color: #018fe2;
}
/* @end */
/* @group CTools */
......
......@@ -127,7 +127,8 @@ fieldset.fieldset-no-legend {
.dependent-options,
.dependent-options.form-item,
.form-item-options-expose-required,
.form-item-options-expose-label {
.form-item-options-expose-label,
.form-item-options-expose-description {
margin-left: 1.5em;
}
......@@ -139,7 +140,8 @@ fieldset.fieldset-no-legend {
.views-admin-dependent .dependent-options .form-type-select,
.views-admin-dependent .dependent-options .form-type-textfield,
.form-item-options-expose-required,
.form-item-options-expose-label {
.form-item-options-expose-label,
.form-item-options-expose-description {
margin-bottom: 6px;
margin-top: 6px;
}
......
......@@ -380,6 +380,7 @@ td.group-title {
text-transform: uppercase;
}
.grouped-description,
.exposed-description {
float: left;
padding-top: 3px;
......@@ -433,6 +434,10 @@ td.group-title {
padding: 3px 9px;
}
.views-display-top #views-display-top {
max-width: 180px;
}
/* @end */
/* @group Attachment details tabs
......@@ -440,6 +445,18 @@ td.group-title {
* The tabs that switch between sections
*/
ul#views-display-menu-tabs {
margin-right: 200px;
}
ul#views-display-menu-tabs li {
margin-bottom: 5px;
}
ul#views-display-menu-tabs li.add ul.action-list li{
margin: 0;
}
.views-displays .secondary a {
border: 1px solid #cbcbcb;
display: inline-block;
......@@ -448,6 +465,15 @@ td.group-title {
padding: 3px 7px;
}
/**
* Display a red border if the display doesn't validate.
*/
.views-displays ul.secondary li.active a.active.error,
.views-displays .secondary a.error {
border: 2px solid #ED541D;
padding: 1px 6px;
}
.views-displays .secondary a:focus {
outline: none;
}
......@@ -907,7 +933,8 @@ td.group-title {
/* @group Expose filter form items */
.form-item-options-expose-required,
.form-item-options-expose-label {
.form-item-options-expose-label,
.form-item-options-expose-description {
margin-bottom: 6px;
margin-left: 18px;
margin-top: 6px;
......
<?php
/**
* @file
* Drush integration of views.
*
* * drush cache-clear views - Clears the views specific caches.
* * views-revert - Drush command to revert views overridden in the system.
* drush cache-clear views - Clears the views specific caches.
* views-revert - Drush command to revert views overridden in the system.
*/
/**
......@@ -50,7 +51,7 @@ function views_drush_command() {
$items['views-dev'] = array(
'callback' => 'views_development_settings',
'drupal dependencies' => array('views'),
'description' => 'Setup the views settings to a more developer oriented value..',
'description' => 'Set the Views settings to more developer-oriented values.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
'aliases' => array('vd'),
);
......@@ -236,6 +237,7 @@ function views_development_settings() {
variable_set('views_ui_show_listing_filters', TRUE);
variable_set('views_ui_show_master_display', TRUE);
variable_set('views_ui_show_advanced_column', TRUE);
variable_set('views_ui_always_live_preview', FALSE);
variable_set('views_ui_always_live_preview_button', TRUE);
variable_set('views_ui_show_preview_information', TRUE);
variable_set('views_ui_show_sql_query', TRUE);
......@@ -455,8 +457,8 @@ function drush_views_disable() {
_views_drush_changestatus($viewnames, TRUE);
}
/*
* Helper function to enable / disable views
/**
* Helper function to enable / disable views
* @param $viewnames: array of viewnames to process
* @param $status: TRUE to disable or FALSE to enable the view
*/
......@@ -481,8 +483,7 @@ function _views_drush_changestatus($viewnames = array(), $status = NULL) {
variable_set('views_defaults', $views_status);
views_invalidate_cache();
drush_log(dt("Views cache was cleared"), 'ok');
menu_rebuild();
drush_log(dt("Menu cache was cleared"), 'ok');
drush_log(dt("Menu cache is set to be rebuilt on the next request."), 'ok');
}
}
}
......
<?php
/**
* @file
* Views area handlers.
*/
/**
* @defgroup views_area_handlers Views' area handlers
* @defgroup views_area_handlers Views area handlers
* @{
* Handlers to tell Views what can display in header, footer
* and empty text in a view.
*/
/**
* Base class for area handlers.
*
* @ingroup views_area_handlers
*/
class views_handler_area extends views_handler {
/**
* Overrides views_handler::init().
*
* Make sure that no result area handlers are set to be shown when the result
* is empty.
*/
function init(&$view, &$options) {
parent::init($view, $options);
if ($this->handler_type == 'empty') {
$this->options['empty'] = TRUE;
}
}
/**
* Get this field's label.
*/
......@@ -28,7 +48,7 @@ class views_handler_area extends views_handler {
$this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : '';
$label = !empty($this->definition['label']) ? $this->definition['label'] : $this->definition['field'];
$options['label'] = array('default' => $label, 'translatable' => TRUE);
$options['empty'] = array('default' => 0, 'bool' => TRUE);
$options['empty'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
......
......@@ -2,13 +2,13 @@
/**
* @file
* Contains views_handler_area_result handler.
* Definition of views_handler_area_result.
*/
/**
* Views area handler to display some configurable result summary.
*
* @ingroup views_area_handlers Views' area handlers
* @ingroup views_area_handlers
*/
class views_handler_area_result extends views_handler_area {
......@@ -33,6 +33,7 @@ class views_handler_area_result extends views_handler_area {
'@name -- the human-readable name of the view',
'@per_page -- the number of items per page',
'@current_page -- the current page number',
'@current_record_count -- the current page record count',
'@page_count -- the total page count',
),
);
......@@ -61,7 +62,9 @@ class views_handler_area_result extends views_handler_area {
$current_page = (int) $this->view->get_current_page() + 1;
$per_page = (int) $this->view->get_items_per_page();
$count = count($this->view->result);
$total = $this->view->total_rows;
// @TODO: Maybe use a possible is views empty functionality.
// Not every view has total_rows set, use view->result instead.
$total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result);
$name = check_plain($this->view->human_name);
if ($per_page === 0) {
$page_count = 1;
......@@ -77,8 +80,9 @@ class views_handler_area_result extends views_handler_area {
$start = ($current_page - 1) * $per_page + 1;
$end = $total_count;
}
$current_record_count = ($end - $start) + 1;
// Get the search information.
$items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'page_count');
$items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'current_record_count', 'page_count');
$replacements = array();
foreach ($items as $item) {
$replacements["@$item"] = ${$item};
......@@ -90,4 +94,3 @@ class views_handler_area_result extends views_handler_area {
return $output;
}
}
......@@ -2,20 +2,21 @@
/**
* @file
* Contains views_handler_area_text handler.
* Definition of views_handler_area_text.
*/
/**
* Views area text handler.
* @ingroup views_area_handlers Views' area handlers
*/
*
* @ingroup views_area_handlers
*/
class views_handler_area_text extends views_handler_area {
function option_definition() {
$options = parent::option_definition();
$options['content'] = array('default' => '', 'translatable' => TRUE, 'format_key' => 'format');
$options['format'] = array('default' => NULL);
$options['tokenize'] = array('default' => FALSE);
$options['tokenize'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
......@@ -30,7 +31,7 @@ class views_handler_area_text extends views_handler_area {
'#wysiwyg' => FALSE,
);
// @TODO: Refactor token handling into a base class.
$form['tokenize'] = array(
'#type' => 'checkbox',
'#title' => t('Use replacement tokens from the first row'),
......@@ -50,7 +51,7 @@ class views_handler_area_text extends views_handler_area {
}
if (!empty($options)) {
$output = '<p>' . t('The following tokens are available. If you would like to have the characters %5B and %5D please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.)' . '</p>');
$output = '<p>' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.' . '</p>');
foreach (array_keys($options) as $type) {
if (!empty($options[$type])) {
$items = array();
......@@ -106,5 +107,4 @@ class views_handler_area_text extends views_handler_area {
return check_markup($value, $format, '', FALSE);
}
}
}
<?php
/**
* @file
* Definition of views_handler_area_text_custom.
*/
/**
* Views area text custom handler.
*
* @ingroup views_area_handlers
*/
class views_handler_area_text_custom extends views_handler_area_text {
function option_definition() {
$options = parent::option_definition();
unset($options['format']);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Alter the form element, to be a regular text area.
$form['content']['#type'] = 'textarea';
unset($form['content']['#format']);
unset($form['content']['#wysiwyg']);
// @TODO: Use the token refactored base class.
}
// Empty, so we don't inherit options_submit from the parent.
function options_submit(&$form, &$form_state) {
}
function render($empty = FALSE) {
if (!$empty || !empty($this->options['empty'])) {
return $this->render_textarea_custom($this->options['content']);
}
return '';
}
/**
* Render a text area with filter_xss_admin.
*/
function render_textarea_custom($value) {
if ($value) {
if ($this->options['tokenize']) {
$value = $this->view->style_plugin->tokenize_value($value, 0);
}
return $this->sanitize_value($value, 'xss_admin');
}
}
}
......@@ -2,8 +2,9 @@
/**
* @file
* Contains views_handler_area_view handler.
* Definition of views_handler_area_view.
*/
/**
* Views area handlers. Insert a view inside of an area.
*
......@@ -15,7 +16,7 @@ class views_handler_area_view extends views_handler_area {
$options = parent::option_definition();
$options['view_to_insert'] = array('default' => '');
$options['inherit_arguments'] = array('default' => FALSE, 'boolean' => TRUE);
$options['inherit_arguments'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
......@@ -29,7 +30,7 @@ class views_handler_area_view extends views_handler_area {
$view_display = $this->view->name . ':' . $this->view->current_display;
$options = array('' => t('-Select-'));
$options += views_get_views_as_options(FALSE, 'all', $view_display);
$options += views_get_views_as_options(FALSE, 'all', $view_display, FALSE, TRUE);
$form['view_to_insert'] = array(
'#type' => 'select',
'#title' => t('View to insert'),
......
<?php
/**
* @defgroup views_argument_handlers Handlers for arguments
* @file
* @todo.
*/
/**
* @defgroup views_argument_handlers Views argument handlers
* Handlers to tell Views how to contextually filter queries.
* @{
*/
......@@ -79,6 +85,9 @@ class views_handler_argument extends views_handler {
$this->options['summary']['format'] = $options['style_plugin'];
}
// Setup default value.
$options['style_options'] = isset($options['style_options']) ? $options['style_options'] : array();
if (!isset($options['summary']['sort_order']) && !empty($options['default_action']) && $options['default_action'] == 'summary asc') {
$this->options['default_action'] = 'summary';
$this->options['summary']['sort_order'] = 'asc';
......@@ -173,17 +182,17 @@ class views_handler_argument extends views_handler {
$options['exception'] = array(
'contains' => array(
'value' => array('default' => 'all'),
'title_enable' => array('default' => 0),
'title' => array('default' => t('All'), 'translatable' => TRUE),
'title_enable' => array('default' => FALSE, 'bool' => TRUE),
'title' => array('default' => 'All', 'translatable' => TRUE),
),
);
$options['title_enable'] = array('default' => 0);
$options['title_enable'] = array('default' => FALSE, 'bool' => TRUE);
$options['title'] = array('default' => '', 'translatable' => TRUE);
$options['breadcrumb_enable'] = array('default' => 0);
$options['breadcrumb_enable'] = array('default' => FALSE, 'bool' => TRUE);
$options['breadcrumb'] = array('default' => '', 'translatable' => TRUE);
$options['default_argument_type'] = array('default' => 'fixed', 'export' => 'export_plugin');
$options['default_argument_options'] = array('default' => array(), 'export' => FALSE);
$options['default_argument_skip_url'] = array('default' => FALSE);
$options['default_argument_skip_url'] = array('default' => FALSE, 'bool' => TRUE);
$options['summary_options'] = array('default' => array(), 'export' => FALSE);
$options['summary'] = array(
'contains' => array(
......@@ -192,7 +201,7 @@ class views_handler_argument extends views_handler {
'format' => array('default' => 'default_summary', 'export' => 'export_summary'),
),
);
$options['specify_validation'] = array('default' => 0);
$options['specify_validation'] = array('default' => FALSE, 'bool' => TRUE);
$options['validate'] = array(
'contains' => array(
'type' => array('default' => 'none', 'export' => 'export_validation'),
......@@ -371,6 +380,7 @@ class views_handler_argument extends views_handler {
'#prefix' => '<div id="edit-options-validate-options-' . $id . '-wrapper">',
'#suffix' => '</div>',
'#type' => 'item',
// Even if the plugin has no options add the key to the form_state.
'#input' => TRUE, // trick it into checking input to make #process run
'#dependency' => array(
'edit-options-specify-validation' => array('1'),
......@@ -507,6 +517,11 @@ class views_handler_argument extends views_handler {
'method' => 'default_empty',
'breadcrumb' => TRUE, // generate a breadcrumb to here
),
'access denied' => array(
'title' => t('Display "Access Denied"'),
'method' => 'default_access_denied',
'breadcrumb' => FALSE, // generate a breadcrumb to here
),
);
if ($this->view->display_handler->has_path()) {
......@@ -565,6 +580,8 @@ class views_handler_argument extends views_handler {
'#suffix' => '</div>',
'#id' => 'edit-options-argument-default-options-' . $id,
'#type' => 'item',
// Even if the plugin has no options add the key to the form_state.
'#input' => TRUE,
'#dependency' => array(
'radio:options[default_action]' => array('default'),
'edit-options-default-argument-type' => array($id)
......@@ -706,6 +723,17 @@ class views_handler_argument extends views_handler {
return FALSE;
}
/**
* Default action: access denied.
*
* If an argument was expected and was not given, in this case, report
* the view as 'access denied'.
*/
function default_access_denied() {
$this->view->build_info['denied'] = TRUE;
return FALSE;
}
/**
* Default action: empty
*
......
<?php
/**
* @file
* Definition of views_handler_argument_date.
*/
/**
* Abstract argument handler for dates.
*
......@@ -12,7 +18,8 @@
* - many to one: If true, the "many to one" helper will be used.
* - invalid input: A string to give to the user for obviously invalid input.
* This is deprecated in favor of argument validators.
* @see views_many_to_one_helper
*
* @see views_many_to_one_helper()
*
* @ingroup views_argument_handlers
*/
......
<?php
/**
* @file
* Definition of views_handler_argument_formula.
*/
/**
* Abstract argument handler for simple formulae.
*
......
<?php
/**
* @file
* Definition of views_handler_argument_group_by_numeric.
*/
/**
* Simple handler for arguments using group by.
*
......
<?php
/**
* @file
* Definition of views_handler_argument_many_to_one.
*/
/**
* An argument handler for use in fields that have a many to one relationship
* with the table(s) to the left. This adds a bunch of options that are
......@@ -26,11 +32,11 @@ class views_handler_argument_many_to_one extends views_handler_argument {
$options = parent::option_definition();
if (!empty($this->definition['numeric'])) {
$options['break_phrase'] = array('default' => FALSE);
$options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
}
$options['add_table'] = array('default' => FALSE);
$options['require_value'] = array('default' => FALSE);
$options['add_table'] = array('default' => FALSE, 'bool' => TRUE);
$options['require_value'] = array('default' => FALSE, 'bool' => TRUE);
if (isset($this->helper)) {
$this->helper->option_definition($options);
......
<?php
/**
* @file
* Definition of views_handler_argument_null.
*/
/**
* Argument handler that ignores the argument.
*
......@@ -7,7 +13,7 @@
class views_handler_argument_null extends views_handler_argument {
function option_definition() {
$options = parent::option_definition();
$options['must_not_be'] = array('default' => FALSE);
$options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
......
<?php
/**
* @file
* Contains the numeric argument handler.
* Definition of views_handler_argument_numeric.
*/
/**
......@@ -26,8 +27,8 @@ class views_handler_argument_numeric extends views_handler_argument {
function option_definition() {
$options = parent::option_definition();
$options['break_phrase'] = array('default' => FALSE);
$options['not'] = array('default' => FALSE);
$options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
$options['not'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
......