View source
<?php
class apachesolr_views_handler_argument extends views_handler_argument {
public function query() {
if (!empty($this->options['break_phrase'])) {
$this->value = explode(',', $this->argument);
}
else {
$this->value = array(
$this->argument,
);
}
foreach ($this->value as $facet_value) {
$this->query
->add_filter($this->real_field, apachesolr_views_query::escape_term($facet_value), $this->options['not']);
}
}
function option_definition() {
$options = parent::option_definition();
$options['break_phrase'] = array(
'default' => FALSE,
);
$options['not'] = array(
'default' => FALSE,
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['break_phrase'] = array(
'#type' => 'checkbox',
'#title' => t('Allow multiple terms per argument.'),
'#description' => t('If selected, users can enter multiple arguments in the form of 1,2,3.'),
'#default_value' => !empty($this->options['break_phrase']),
);
$form['not'] = array(
'#type' => 'checkbox',
'#title' => t('Exclude the argument'),
'#description' => t('If selected, the numbers entered in the argument will be excluded rather than limiting the view.'),
'#default_value' => !empty($this->options['not']),
);
}
function default_actions($which = NULL) {
$defaults = array(
'ignore' => array(
'title' => t('Display all values'),
'method' => 'default_ignore',
'breadcrumb' => TRUE,
),
'not found' => array(
'title' => t('Hide view / Page not found (404)'),
'method' => 'default_not_found',
'hard fail' => TRUE,
),
'empty' => array(
'title' => t('Display empty text'),
'method' => 'default_empty',
'breadcrumb' => TRUE,
),
'default' => array(
'title' => t('Provide default argument'),
'method' => 'default_default',
'form method' => 'default_argument_form',
'has default argument' => TRUE,
'default only' => TRUE,
),
);
if ($which) {
if (!empty($defaults[$which])) {
return $defaults[$which];
}
}
else {
return $defaults;
}
}
}