summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/argument.handlers.inc36
-rw-r--r--modules/node.views.inc23
-rw-r--r--views.module1
3 files changed, 50 insertions, 10 deletions
diff --git a/includes/argument.handlers.inc b/includes/argument.handlers.inc
index 921c1de..a884e56 100644
--- a/includes/argument.handlers.inc
+++ b/includes/argument.handlers.inc
@@ -681,6 +681,42 @@ class views_handler_argument_formula extends views_handler_argument {
}
/**
+ * Abstract argument handler for dates.
+ *
+ * Adds an option to set a default argument based on the current date.
+ *
+ * @param $arg_format
+ * The format string to use on the current time when
+ * creating a default date argument.
+ *
+ */
+class views_handler_argument_date extends views_handler_argument_formula {
+ var $option_name = 'default_argument_date';
+ var $arg_format = 'Y-m-d';
+
+ /**
+ * Add an option to set the default value to the current date.
+ */
+ function default_argument_form(&$form, &$form_state) {
+ parent::default_argument_form($form, $form_state);
+ $form['default_argument_type']['#options'] += array('date' => t('Current date'));
+ }
+
+ /**
+ * Set the empty argument value to the current date,
+ * formatted appropriately for this argument.
+ */
+ function get_default_argument($raw = FALSE) {
+ if (!$raw && $this->options['default_argument_type'] == 'date') {
+ return date($this->arg_format, time());
+ }
+ else {
+ return parent::get_default_argument($raw);
+ }
+ }
+}
+
+/**
* Basic argument handler to implement string arguments that may have length
* limits.
*/
diff --git a/modules/node.views.inc b/modules/node.views.inc
index 99f4b22..6b10acb 100644
--- a/modules/node.views.inc
+++ b/modules/node.views.inc
@@ -909,13 +909,14 @@ class views_handler_argument_node_vid extends views_handler_argument_numeric {
*
* @ingroup views_argument_handlers
*/
-class views_handler_argument_node_created_fulldate extends views_handler_argument_formula {
+class views_handler_argument_node_created_fulldate extends views_handler_argument_date {
/**
* Constructor implementation
*/
function construct() {
- $this->formula = views_date_sql_format('Ymd', "***table***.$this->real_field");
$this->format = 'F j, Y';
+ $this->arg_format = 'Ymd';
+ $this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
}
/**
@@ -939,11 +940,12 @@ class views_handler_argument_node_created_fulldate extends views_handler_argumen
*
* @ingroup views_argument_handlers
*/
-class views_handler_argument_node_created_year extends views_handler_argument_formula {
+class views_handler_argument_node_created_year extends views_handler_argument_date {
/**
* Constructor implementation
*/
function construct() {
+ $this->arg_format = 'Y';
$this->formula = views_date_sql_extract('YEAR', "***table***.$this->real_field");
}
}
@@ -953,15 +955,16 @@ class views_handler_argument_node_created_year extends views_handler_argument_fo
*
* @ingroup views_argument_handlers
*/
-class views_handler_argument_node_created_year_month extends views_handler_argument_formula {
+class views_handler_argument_node_created_year_month extends views_handler_argument_date {
/**
* Constructor implementation
*/
function construct() {
- $this->formula = views_date_sql_format('Ym', "***table***.$this->real_field");
$this->format = 'F, Y';
+ $this->arg_format = 'Ym';
+ $this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
}
-
+
/**
* Provide a link to the next level of the view
*/
@@ -983,13 +986,14 @@ class views_handler_argument_node_created_year_month extends views_handler_argum
*
* @ingroup views_argument_handlers
*/
-class views_handler_argument_node_created_month extends views_handler_argument_formula {
+class views_handler_argument_node_created_month extends views_handler_argument_date {
/**
* Constructor implementation
*/
function construct() {
$this->formula = views_date_sql_extract('MONTH', "***table***.$this->real_field");
$this->format = 'F';
+ $this->arg_format = 'm';
}
/**
@@ -1015,15 +1019,16 @@ class views_handler_argument_node_created_month extends views_handler_argument_f
}
/**
- * Argument handler for a full date (CCYYMMDD)
+ * Argument handler for a week.
*
* @ingroup views_argument_handlers
*/
-class views_handler_argument_node_created_week extends views_handler_argument_formula {
+class views_handler_argument_node_created_week extends views_handler_argument_date {
/**
* Constructor implementation
*/
function construct() {
+ $this->arg_format = 'w';
$this->formula = views_date_sql_extract('WEEK', "***table***.$this->real_field");
}
diff --git a/views.module b/views.module
index 7e1f2ad..eab0bc4 100644
--- a/views.module
+++ b/views.module
@@ -87,7 +87,6 @@ function views_theme() {
'pattern' => 'views_more__',
'arguments' => array('more_url' => NULL),
);
-
return $hooks;
}