You are here

function views_handler_arg_year in Views (for Drupal 7) 5

1 string reference to 'views_handler_arg_year'
node_views_arguments in modules/views_node.inc

File

modules/views_node.inc, line 541

Code

function views_handler_arg_year($op, &$query, $argtype, $arg = '') {
  $timezone = _views_get_timezone();
  switch ($op) {
    case 'summary':
      $fieldinfo['field'] = "YEAR(FROM_UNIXTIME(node.created+{$timezone}))";
      $fieldinfo['fieldname'] = 'year';
      $query
        ->add_field('created');
      return $fieldinfo;
      break;
    case 'sort':
      $query
        ->add_orderby(NULL, "YEAR(FROM_UNIXTIME(node.created+{$timezone}))", $argtype, 'year');
      break;
    case 'filter':
      $year = intval($arg);
      $query
        ->add_where("YEAR(FROM_UNIXTIME(node.created+{$timezone})) = {$year}");
      break;
    case 'link':
      return l($query->year, "{$arg}/{$query->year}");
    case 'title':
      return check_plain($query);
  }
}