diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php index 59b87de887b580f37e15adfd29df5ddf014f1f11..73d2899ff7343a012f940fba9effd6530bce0559 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php @@ -19,20 +19,31 @@ * - 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. - * - arg_format: The format string to use on the current time when dealing with - * date values. * * @see Drupal\views\ManyTonOneHelper * * @ingroup views_argument_handlers * * @Plugin( - * id = "date", - * arg_format = "Y-m-d" + * id = "date" * ) */ class Date extends Formula { + /** + * The date format used in the title. + * + * @var string + */ + protected $format; + + /** + * The date format used in the query. + * + * @var string + */ + protected $argFormat = 'Y-m-d'; + var $option_name = 'default_argument_date'; /** @@ -50,7 +61,7 @@ function default_argument_form(&$form, &$form_state) { */ function get_default_argument($raw = FALSE) { if (!$raw && $this->options['default_argument_type'] == 'date') { - return date($this->definition['format'], REQUEST_TIME); + return date($this->argFormat, REQUEST_TIME); } elseif (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) { foreach (range(1, 3) as $i) { @@ -68,10 +79,10 @@ function get_default_argument($raw = FALSE) { return parent::get_default_argument(); } elseif ($this->options['default_argument_type'] == 'node_created') { - return date($this->definition['format'], $node->created); + return date($this->argFormat, $node->created); } elseif ($this->options['default_argument_type'] == 'node_changed') { - return date($this->definition['format'], $node->changed); + return date($this->argFormat, $node->changed); } } @@ -86,7 +97,7 @@ function get_sort_name() { * Overrides \Drupal\views\Plugin\views\argument\Formula::get_formula(). */ function get_formula() { - $this->formula = $this->getDateFormat($this->definition['arg_format']); + $this->formula = $this->getDateFormat($this->argFormat); return parent::get_formula(); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/DayDate.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/DayDate.php index 31a0610957f184639b33c7610df06fe8106fa37f..4fefcd530fda20dd52070e3c356b0c4a8872bebc 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/DayDate.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/DayDate.php @@ -14,20 +14,28 @@ * * @Plugin( * id = "date_day", - * arg_format = "d", - * format = "j", * module = "views" * ) */ class DayDate extends Date { + /** + * {@inheritdoc} + */ + protected $format = 'j'; + + /** + * {@inheritdoc} + */ + protected $argFormat = 'd'; + /** * Provide a link to the next level of the view */ function summary_name($data) { $day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT); // strtotime respects server timezone, so we need to set the time fixed as utc time - return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } /** @@ -35,7 +43,7 @@ function summary_name($data) { */ function title() { $day = str_pad($this->argument, 2, '0', STR_PAD_LEFT); - return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } function summary_argument($data) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/FullDate.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/FullDate.php index 9d34ba7ec2e0e8b2156d72b54fec519b4c9b1973..b1f5c432fdf6d62d21ea8e96ba1e40be3eb138a5 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/FullDate.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/FullDate.php @@ -14,26 +14,34 @@ * * @Plugin( * id = "date_fulldate", - * arg_format = "Ymd", - * format = "F j, Y", * module = "views" * ) */ class FullDate extends Date { + /** + * {@inheritdoc} + */ + protected $format = 'F j, Y'; + + /** + * {@inheritdoc} + */ + protected $argFormat = 'Ymd'; + /** * Provide a link to the next level of the view */ function summary_name($data) { $created = $data->{$this->name_alias}; - return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } /** * Provide a link to the next level of the view */ function title() { - return format_date(strtotime($this->argument . " 00:00:00 UTC"), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime($this->argument . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/MonthDate.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/MonthDate.php index 00a587e44af0668a06b121758b8d569c8ffd6a98..2a7a11b604a7521c885d41677f60e98cfca25e75 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/MonthDate.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/MonthDate.php @@ -14,19 +14,27 @@ * * @Plugin( * id = "date_month", - * arg_format = "m", - * format = "F", * module = "views" * ) */ class MonthDate extends Date { + /** + * {@inheritdoc} + */ + protected $format = 'F'; + + /** + * {@inheritdoc} + */ + protected $argFormat = 'm'; + /** * Provide a link to the next level of the view */ function summary_name($data) { $month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT); - return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->format, 'UTC'); } /** @@ -34,7 +42,7 @@ function summary_name($data) { */ function title() { $month = str_pad($this->argument, 2, '0', STR_PAD_LEFT); - return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } function summary_argument($data) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/WeekDate.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/WeekDate.php index 8348804628c6098a8abf7525c32f700d07b494b9..1f285932df8ac289aac81ff678778f8363c4c49b 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/WeekDate.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/WeekDate.php @@ -14,12 +14,16 @@ * * @Plugin( * id = "date_week", - * arg_format = "W", * module = "views" * ) */ class WeekDate extends Date { + /** + * {@inheritdoc} + */ + protected $argFormat = 'W'; + /** * Provide a link to the next level of the view */ diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearDate.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearDate.php index 44baf1a05580e4eb99e3dc4bded2a3bfeb16fca0..90b65bdd33caa7513f34d0ef0a356327f4859d3c 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearDate.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearDate.php @@ -14,10 +14,14 @@ * * @Plugin( * id = "date_year", - * arg_format = "Y", * module = "views" * ) */ class YearDate extends Date { + /** + * {@inheritdoc} + */ + protected $argFormat = 'Y'; + } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearMonthDate.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearMonthDate.php index ae52ab61362c061e9d31d3ed3fa99e3515fa41b1..e1ec3ff595cf199b1815363401b287b7e2d21dea 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearMonthDate.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/YearMonthDate.php @@ -14,26 +14,34 @@ * * @Plugin( * id = "date_year_month", - * format = "F Y", - * arg_format = "Ym", * module = "views" * ) */ class YearMonthDate extends Date { + /** + * {@inheritdoc} + */ + protected $format = 'F Y'; + + /** + * {@inheritdoc} + */ + protected $argFormat = 'Ym'; + /** * Provide a link to the next level of the view */ function summary_name($data) { $created = $data->{$this->name_alias}; - return format_date(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } /** * Provide a link to the next level of the view */ function title() { - return format_date(strtotime($this->argument . "15" . " 00:00:00 UTC"), 'custom', $this->definition['format'], 'UTC'); + return format_date(strtotime($this->argument . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } }