You are here

function views_handler_arg_month in Views (for Drupal 7) 5

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

File

modules/views_node.inc, line 564

Code

function views_handler_arg_month($op, &$query, $argtype, $arg = '') {
  $timezone = _views_get_timezone();
  switch ($op) {
    case 'summary':
      $fieldinfo['field'] = "MONTH(FROM_UNIXTIME(node.created+{$timezone}))";
      $fieldinfo['fieldname'] = 'name';
      $query
        ->add_field('created');
      return $fieldinfo;
      break;
    case 'sort':
      $query
        ->add_orderby(NULL, "MONTH(FROM_UNIXTIME(node.created+{$timezone}))", $argtype, 'name');
      break;
    case 'filter':
      $month = intval($arg);
      $query
        ->add_where("MONTH(FROM_UNIXTIME(node.created+{$timezone})) = {$month}");
      break;
    case 'link':
      return l(format_date($query->created, 'custom', 'F'), "{$arg}/{$query->name}");
    case 'title':
      $month = str_pad($query, 2, '0', STR_PAD_LEFT);
      return format_date(strtotime("2005{$month}15"), 'custom', 'F', 0);
  }
}