function views_handler_argument_date::get_default_argument

Same name in other branches
  1. 7.x-3.x handlers/views_handler_argument_date.inc \views_handler_argument_date::get_default_argument()

Set the empty argument value to the current date, formatted appropriately for this argument.

Overrides views_handler_argument::get_default_argument

File

handlers/views_handler_argument_date.inc, line 36

Class

views_handler_argument_date
Abstract argument handler for dates.

Code

function get_default_argument($raw = FALSE) {
    if (!$raw && $this->options['default_argument_type'] == 'date') {
        return date($this->arg_format, time());
    }
    else {
        if (!$raw && in_array($this->options['default_argument_type'], array(
            'node_created',
            'node_changed',
        ))) {
            foreach (range(1, 3) as $i) {
                $node = menu_get_object('node', $i);
                if (!empty($node)) {
                    continue;
                }
            }
            if (arg(0) == 'node' && is_numeric(arg(1))) {
                $node = node_load(arg(1));
            }
            if (empty($node)) {
                return parent::get_default_argument();
            }
            else {
                if ($this->options['default_argument_type'] == 'node_created') {
                    return date($this->arg_format, $node->created);
                }
                else {
                    if ($this->options['default_argument_type'] == 'node_changed') {
                        return date($this->arg_format, $node->changed);
                    }
                }
            }
        }
    }
    return parent::get_default_argument($raw);
}