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 59b87de887b5..73d2899ff734 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 @@ use Drupal\Core\Database\Database; * - 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 @@ class Date extends Formula { */ 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 @@ class Date extends Formula { 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 @@ class Date extends Formula { * 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 31a0610957f1..4fefcd530fda 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 @@ use Drupal\Component\Annotation\Plugin; * * @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 @@ class DayDate extends Date { */ 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 9d34ba7ec2e0..b1f5c432fdf6 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 @@ use Drupal\Component\Annotation\Plugin; * * @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 00a587e44af0..2a7a11b604a7 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 @@ use Drupal\Component\Annotation\Plugin; * * @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 @@ class MonthDate extends Date { */ 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 8348804628c6..1f285932df8a 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 @@ use Drupal\Component\Annotation\Plugin; * * @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 44baf1a05580..90b65bdd33ca 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 @@ use Drupal\Component\Annotation\Plugin; * * @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 ae52ab61362c..e1ec3ff595cf 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 @@ use Drupal\Component\Annotation\Plugin; * * @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'); } }