Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Views 7.x-3.23
Browse files Browse the repository at this point in the history
  • Loading branch information
olofbokedal committed May 27, 2019
1 parent 6fbf028 commit f1717c1
Show file tree
Hide file tree
Showing 71 changed files with 2,467 additions and 510 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* IE7 has no idea how large this container should be and it doesn't
* apply has-layout. Expand it's width to 100% and trigger has-layout.
* apply has-layout. Expand its width to 100% and trigger has-layout.
*/
.views-edit-view .views-displays {
height: 1%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,7 @@ div.form-item-options-value-all {

/* @end */



/* @group Javascript dependent styling */
/* @group JavaScript dependent styling */

.js-only {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ function views_drush_command() {
* Callback function for views-revert command.
*/
function views_revert_views() {
$args = func_get_args();
// The provided views names specified in the command.
$viewnames = _convert_csv_to_array($args);
$views = views_get_all_views();
$i = 0;
// The provided views names specified in the command.
$viewnames = _convert_csv_to_array(func_get_args());

// Find all overridden views.
foreach ($views as $view) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class views_handler_area_result extends views_handler_area {
$replacements["@$item"] = ${$item};
}
// Send the output.
if (!empty($total)) {
if (!empty($total) || !empty($this->options['empty'])) {
$output .= filter_xss_admin(str_replace(array_keys($replacements), array_values($replacements), $format));
}
return $output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Base class for arguments.
*
* The basic argument works for very simple arguments such as nid and uid
* The basic argument works for very simple arguments such as nid and uid.
*
* Definition terms for this handler:
* - name field: The field to use for the name to use in the summary, which is
Expand Down Expand Up @@ -158,9 +158,10 @@ class views_handler_argument extends views_handler {
}

/**
* Determine if the argument can generate a breadcrumb
* Determine if the argument can generate a breadcrumb.
*
* @return bool
* Indicates whether the argument can generate a breadcrumb.
*/
public function uses_breadcrumb() {
$info = $this->default_actions($this->options['default_action']);
Expand Down Expand Up @@ -195,6 +196,7 @@ class views_handler_argument extends views_handler {
* Determine if the argument needs a style plugin.
*
* @return bool
* the argument needs a plugin style.
*/
public function needs_style_plugin() {
$info = $this->default_actions($this->options['default_action']);
Expand Down Expand Up @@ -527,8 +529,7 @@ class views_handler_argument extends views_handler {
}

/**
* Provide a list of default behaviors for this argument if the argument
* is not present.
* List of default behaviors for this argument if the argument is not present.
*
* Override this method to provide additional (or fewer) default behaviors.
*/
Expand Down Expand Up @@ -657,8 +658,9 @@ class views_handler_argument extends views_handler {
}

/**
* Provide a form for selecting further summary options when the default
* action is set to display one.
* Form for selecting further summary options.
*
* Only used when the default action is set to display one.
*/
public function default_summary_form(&$form, &$form_state) {
$style_plugins = views_fetch_plugin_data('style');
Expand Down Expand Up @@ -795,10 +797,10 @@ class views_handler_argument extends views_handler {
}

/**
* Default action: empty
* Default action: empty.
*
* If an argument was expected and was not given, in this case, display the
* view's empty text
* view's empty text.
*/
public function default_empty() {
// We return with no query; this will force the empty text.
Expand Down Expand Up @@ -967,6 +969,8 @@ class views_handler_argument extends views_handler {
*
* @param string $order
* The order selected in the UI.
* @param string $by
* Optional alias for this field.
*/
public function summary_sort($order, $by = NULL) {
$this->query->add_orderby(NULL, NULL, $order, (!empty($by) ? $by : $this->name_alias));
Expand Down Expand Up @@ -1116,7 +1120,7 @@ class views_handler_argument extends views_handler {
}

/**
* Set the input for this argument
* Set the input for this argument.
*
* @return bool
* TRUE if it successfully validates; FALSE if it does not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Definitions terms:
* - 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.
* This is deprecated in favor of argument validators.
*
* @see views_many_to_one_helper()
*
Expand All @@ -26,12 +26,12 @@
class views_handler_argument_date extends views_handler_argument_formula {

/**
*
* @var string
*/
public $option_name = 'default_argument_date';

/**
*
* @var string
*/
public $arg_format = 'Y-m-d';

Expand All @@ -46,9 +46,9 @@ class views_handler_argument_date extends views_handler_argument_formula {
}

/**
* Set the empty argument value to the current date,
* Set the empty argument value to the current date.
*
* formatted appropriately for this argument.
* Formatted appropriately for this argument.
*
* @return string
* The default argument.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class views_handler_argument_string extends views_handler_argument {
$options['path_case'] = array('default' => 'none');
$options['transform_dash'] = array('default' => FALSE, 'bool' => TRUE);
$options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE);
$options['not'] = array('default' => FALSE, 'bool' => TRUE);

if (!empty($this->definition['many to one'])) {
$options['add_table'] = array('default' => FALSE, 'bool' => TRUE);
Expand Down Expand Up @@ -132,6 +133,13 @@ class views_handler_argument_string extends views_handler_argument {
'#default_value' => !empty($this->options['break_phrase']),
'#fieldset' => 'more',
);
$form['not'] = array(
'#type' => 'checkbox',
'#title' => t('Exclude'),
'#description' => t('If selected, the numbers entered for the filter will be excluded rather than limiting the view.'),
'#default_value' => !empty($this->options['not']),
'#fieldset' => 'more',
);
}

/**
Expand Down Expand Up @@ -207,21 +215,19 @@ class views_handler_argument_string extends views_handler_argument {
}

if (count($this->value) > 1) {
$operator = 'IN';
$operator = empty($this->options['not']) ? 'IN' : 'NOT IN';
$argument = $this->value;
}
else {
$operator = '=';
$operator = empty($this->options['not']) ? '=' : '!=';
}

if ($formula) {
$placeholder = $this->placeholder();
if ($operator == 'IN') {
$field .= " IN($placeholder)";
}
else {
$field .= ' = ' . $placeholder;
if (count($this->value) > 1) {
$placeholder = "($placeholder)";
}
$field .= " $operator $placeholder";
$placeholders = array(
$placeholder => $argument,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class views_handler_field extends views_handler {

/**
* @var array
* Stores additional fields which get's added to the query.
* Stores additional fields which get added to the query.
* The generated aliases are stored in $aliases.
*/
public $additional_fields = array();
Expand Down Expand Up @@ -424,6 +424,7 @@ class views_handler_field extends views_handler {
'absolute' => array('default' => FALSE, 'bool' => TRUE),
'external' => array('default' => FALSE, 'bool' => TRUE),
'replace_spaces' => array('default' => FALSE, 'bool' => TRUE),
'unwanted_characters' => array('default' => ''),
'path_case' => array('default' => 'none', 'translatable' => FALSE),
'trim_whitespace' => array('default' => FALSE, 'bool' => TRUE),
'alt' => array('default' => '', 'translatable' => TRUE),
Expand Down Expand Up @@ -744,6 +745,16 @@ class views_handler_field extends views_handler {
'edit-options-alter-make-link' => array(1),
),
);
$form['alter']['unwanted_characters'] = array(
'#type' => 'textfield',
'#title' => t('Remove unwanted characters'),
'#description' => t('Space-separated list of characters to remove from the URL path'),
'#default_value' => $this->options['alter']['unwanted_characters'],
'#dependency' => array(
'edit-options-alter-make-link' => array(1)
),
'#maxlength' => 255,
);
$form['alter']['path_case'] = array(
'#type' => 'select',
'#title' => t('Transform the case'),
Expand Down Expand Up @@ -782,7 +793,7 @@ class views_handler_field extends views_handler {
'#title' => t('Rel Text'),
'#type' => 'textfield',
'#default_value' => $this->options['alter']['rel'],
'#description' => t('Include Rel attribute for use in lightbox2 or other javascript utility.'),
'#description' => t('Include Rel attribute for use in lightbox2 or other JavaScript utility.'),
'#dependency' => array(
'edit-options-alter-make-link' => array(1),
),
Expand Down Expand Up @@ -1234,8 +1245,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
* Render this field as altered text, from a fieldset set by the user.
*/
public function render_altered($alter, $tokens) {
// Filter this right away as our substitutions are already sanitized.
$value = filter_xss_admin($alter['text']);
// We trust admins so we allow any tag content. This is important for
// displays such as XML where we should not mess with tags.
$value = $alter['text'];
$value = strtr($value, $tokens);

return $value;
Expand Down Expand Up @@ -1287,6 +1299,12 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
if (!empty($alter['replace_spaces'])) {
$path = str_replace(' ', '-', $path);
}

if (!empty($alter['unwanted_characters'])) {
foreach (explode(' ', $alter['unwanted_characters']) as $unwanted) {
$path = str_replace($unwanted, '', $path);
}
}
}

// Parse the URL and move any query and fragment parameters out of the path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/**
* A handler to provide proper displays for dates.
*
* This may be used on table fields that hold either UNIX timestamps or SQL
* datetime strings.
*
* @ingroup views_field_handlers
*/
class views_handler_field_date extends views_handler_field {
Expand Down Expand Up @@ -138,6 +141,12 @@ class views_handler_field_date extends views_handler_field {
*/
public function render($values) {
$value = $this->get_value($values);

if (!is_numeric($value)) {
// If the value isn't numeric, assume it's an SQL DATETIME.
$value = strtotime($value);
}

$format = $this->options['date_format'];
if (in_array($format, $this->supported_date_types())) {
$custom_format = $this->options['custom_date_format'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ class views_handler_field_entity extends views_handler_field {

// Initialize the entity-type used.
$table_data = views_fetch_data($this->table);
$this->entity_type = $table_data['table']['entity type'];
if (isset($table_data['table']['entity type'])) {
$this->entity_type = $table_data['table']['entity type'];
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class views_handler_field_links extends views_handler_field {
public function options_submit(&$form, &$form_state) {
// Remove unselected options.
$form_state['values']['options']['fields'] = array_filter($form_state['values']['options']['fields']);
parent::options_submit($form, $form_state);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ class views_handler_field_numeric extends views_handler_field {
public function render($values) {
$value = $this->get_value($values);

// Output nothing if the value is null.
if (is_null($value)) {
return '';
}

// Hiding should happen before rounding or adding prefix/suffix.
if ($this->options['hide_empty'] && empty($value) && ($value !== 0 || $this->options['empty_zero'])) {
return '';
Expand All @@ -127,12 +132,13 @@ class views_handler_field_numeric extends views_handler_field {
$value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']);
}
else {
$remainder = abs($value) - intval(abs($value));
$point_position = strpos($value, '.');
$remainder = ($point_position === FALSE) ? '' : substr($value, $point_position + 1);
$value = $value > 0 ? floor($value) : ceil($value);
$value = number_format($value, 0, '', $this->options['separator']);
if ($remainder) {
// The substr may not be locale safe.
$value .= $this->options['decimal'] . substr($remainder, 2);
$value .= $this->options['decimal'] . $remainder;
}
}

Expand Down
Loading

0 comments on commit f1717c1

Please sign in to comment.