View source
<?php
class apachesolr_views_handler_field_generic {
private $_original;
public function &__get($name) {
if (isset($this->_original->{$name})) {
return $this->_original->{$name};
}
return NULL;
}
public function __set($name, $value) {
$this->_original->{$name} = $value;
}
public function __isset($name) {
return isset($this->_original->{$name});
}
public function __unset($name) {
unset($this->_original->{$name});
}
public function __call($name, $args) {
if (!method_exists($this->_original, $name)) {
trigger_error("tried to call undefined instance method {$name}", E_USER_ERROR);
}
return call_user_func_array(array(
$this->_original,
$name,
), $args);
}
public static function __callStatic($name, $args) {
$method = array(
get_class($this->_original),
$name,
);
if (!method_exists($method)) {
trigger_error("tried to call undefined static method {$name}", E_USER_ERROR);
}
call_user_func_array($method, $args);
}
public function set_definition($definition) {
if (empty($definition['apachesolr base handler'])) {
watchdog('views', 'no base handler specified for apachesolr field handler', array(), WATCHDOG_ERROR);
}
$o = $definition['apachesolr base handler'];
$this->_original = views_get_handler($o['table'], $o['field'], 'field');
if (empty($this->_original)) {
watchdog('views', 'invalid base handler specified for apachesolr field handler: ' . $o['table'] . '/' . $o['field'], array(), WATCHDOG_ERROR);
}
$this->_original
->set_definition($definition);
}
public function options_form(&$form, &$form_state) {
return $this->_original
->options_form($form, $form_state);
}
public function construct() {
$this->_original
->construct();
$this->_original->aliases = drupal_map_assoc(array(
'id',
'site',
'hash',
'url',
'title',
'body',
'type',
'type_name',
'path',
'path_alias',
'uid',
'name',
'created',
'changed',
'last_comment_or_change',
'nid',
'status',
'promote',
'moderate',
'sticky',
'tnid',
'translate',
'language',
'comment_count',
'tid',
'vid',
'timestamp',
));
}
public function ensure_my_table() {
}
public function query() {
$this->_original->field_alias = $this->_original->real_field;
$this->_original->query
->add_field($this->_original->real_field);
$this
->add_additional_fields();
}
public function add_additional_fields($fields = NULL) {
if (!empty($fields)) {
return $this->_original
->add_additional_fields($fields);
}
foreach ($this->_original->additional_fields as $f) {
$this->_original->query
->add_field($f);
}
}
public function click_sort($order) {
$special_sort_fields = array(
'name' => 'sort_name',
'title' => 'sort_title',
);
if (empty($special_sort_fields[$this->real_field])) {
$this->_original->query
->add_sort($this->_original->real_field, $order, TRUE);
}
else {
$this->_original->query
->add_sort($special_sort_fields[$this->_original->real_field], $order, TRUE);
}
}
}