You are here

function views_handler_arg_nodeletter in Views (for Drupal 7) 5

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

File

modules/views_node.inc, line 514

Code

function views_handler_arg_nodeletter($op, &$query, $argtype, $arg = '') {
  static $field = NULL;
  switch ($op) {
    case 'summary':
      $len = intval($arg);
      $field = $fieldinfo['field'] = $len <= 0 ? "node.title" : ($fieldinfo['field'] = "LEFT(node.title, {$len})");
      $fieldinfo['fieldname'] = 'letter';
      return $fieldinfo;
      break;
    case 'sort':
      $query
        ->add_orderby('node', $field, $argtype, 'letter');
      break;
    case 'filter':
      $len = intval($argtype['options']);
      if ($len <= 0) {
        $query
          ->add_where("node.title = '%s'", $arg);
      }
      else {
        $query
          ->add_where("LEFT(node.title, {$len}) = '%s'", $arg);
      }
      break;
    case 'link':
      return l(strtoupper($query->letter), "{$arg}/{$query->letter}");
    case 'title':
      return check_plain(strtoupper($query));
  }
}