Now all modules are in core modules folder

This commit is contained in:
Manuel Cillero 2017-08-08 12:14:45 +02:00
parent 5ba1cdfa0b
commit 05b6a91b0c
1907 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,81 @@
<?php
/**
* Field handler to provide simple renderer that allows linking to a node.
*/
class views_handler_field_search_score extends views_handler_field_numeric {
function option_definition() {
$options = parent::option_definition();
$options['alternate_sort'] = array('default' => '');
$options['alternate_order'] = array('default' => 'asc');
return $options;
}
function options_form(&$form, &$form_state) {
$style_options = $this->view->display_handler->get_option('style_options');
if (isset($style_options['default']) && $style_options['default'] == $this->options['id']) {
$handlers = $this->view->display_handler->get_handlers('field');
$options = array('' => t('No alternate'));
foreach ($handlers as $id => $handler) {
$options[$id] = $handler->ui_name();
}
$form['alternate_sort'] = array(
'#type' => 'select',
'#title' => t('Alternative sort'),
'#description' => t('Pick an alternative default table sort field to use when the search score field is unavailable.'),
'#options' => $options,
'#default_value' => $this->options['alternate_sort'],
);
$form['alternate_order'] = array(
'#type' => 'select',
'#title' => t('Alternate sort order'),
'#options' => array('asc' => t('Ascending'), 'desc' => t('Descending')),
'#default_value' => $this->options['alternate_order'],
);
}
parent::options_form($form, $form_state);
}
function query() {
// Check to see if the search filter added 'score' to the table.
// Our filter stores it as $handler->search_score -- and we also
// need to check its relationship to make sure that we're using the same
// one or obviously this won't work.
foreach ($this->view->filter as $handler) {
if (isset($handler->search_score) && $handler->relationship == $this->relationship) {
$this->field_alias = $handler->search_score;
$this->table_alias = $handler->table_alias;
return;
}
}
// Hide this field if no search filter is in place.
$this->options['exclude'] = TRUE;
if (!empty($this->options['alternate_sort'])) {
if (isset($this->view->style_plugin->options['default']) && $this->view->style_plugin->options['default'] == $this->options['id']) {
// Since the style handler initiates fields, we plug these values right into the active handler.
$this->view->style_plugin->options['default'] = $this->options['alternate_sort'];
$this->view->style_plugin->options['order'] = $this->options['alternate_order'];
}
}
}
function click_sort($order) {
if (isset($this->table_alias)) {
$this->query->add_orderby(NULL, NULL, $order, $this->field_alias);
}
}
function render($values) {
// Only render if we exist.
if (isset($this->table_alias)) {
return parent::render($values);
}
}
}

View file

@ -0,0 +1,112 @@
<?php
/**
* Field handler to provide simple renderer that allows linking to a node.
*/
class views_handler_filter_search extends views_handler_filter {
var $no_single = TRUE;
function option_definition() {
$options = parent::option_definition();
$options['operator']['default'] = 'optional';
return $options;
}
/**
* Provide simple equality operator
*/
function operator_form(&$form, &$form_state) {
$form['operator'] = array(
'#type' => 'radios',
'#title' => t('On empty input'),
'#default_value' => $this->operator,
'#options' => array(
'optional' => t('Show All'),
'required' => t('Show None'),
),
);
}
/**
* Provide a simple textfield for equality
*/
function exposed_form(&$form, &$form_state) {
if (isset($this->options['expose']['identifier'])) {
$key = $this->options['expose']['identifier'];
$form[$key] = array(
'#type' => 'textfield',
'#size' => 15,
'#default_value' => $this->value,
'#attributes' => array('title' => t('Enter the terms you wish to search for.')),
);
}
}
/**
* Validate the options form.
*/
function exposed_validate(&$form, &$form_state) {
if (!isset($this->options['expose']['identifier'])) {
return;
}
$key = $this->options['expose']['identifier'];
if (!empty($form_state['values'][$key])) {
$this->search_query = search_parse_query($form_state['values'][$key]);
if ($this->search_query[2] == '') {
form_set_error($key, t('You must include at least one positive keyword with @count characters or more.', array('@count' => variable_get('minimum_word_size', 3))));
}
if ($this->search_query[6]) {
if ($this->search_query[6] == 'or') {
drupal_set_message(t('Search for either of the two terms with uppercase <strong>OR</strong>. For example, <strong>cats OR dogs</strong>.'));
}
}
}
}
/**
* Add this filter to the query.
*
* Due to the nature of fapi, the value and the operator have an unintended
* level of indirection. You will find them in $this->operator
* and $this->value respectively.
*/
function query() {
if (!isset($this->search_query) || empty($this->search_query[3])) {
if ($this->operator == 'required') {
$this->query->add_where($this->options['group'], 'FALSE');
}
}
else {
$search_index = $this->ensure_my_table();
$this->search_query[2] = str_replace('i.', "$search_index.", $this->search_query[2]);
// Create a new join to relate the 'serach_total' table to our current 'search_index' table.
$join = new views_join;
$join->construct('search_total', $search_index, 'word', 'word');
$search_total = $this->query->add_relationship('search_total', $join, $search_index);
$this->search_score = $this->query->add_field('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE));
$this->query->add_where($this->options['group'], $this->search_query[2], $this->search_query[3]);
if (empty($this->query->relationships[$this->relationship])) {
$base_table = $this->query->base_table;
}
else {
$base_table = $this->query->relationships[$this->relationship]['base'];
}
$this->query->add_where($this->options['group'], "$search_index.type = '%s'", $base_table);
if (!$this->search_query[5]) {
$search_dataset = $this->query->add_table('search_dataset');
$this->search_query[0] = str_replace('d.', "$search_dataset.", $this->search_query[0]);
$this->query->add_where($this->options['group'], $this->search_query[0], $this->search_query[1]);
}
$this->query->add_groupby("$search_index.sid");
$this->query->add_having($this->options['group'], 'COUNT(*) >= %d', $this->search_query[4]);
}
}
}

View file

@ -0,0 +1,24 @@
<?php
/**
* Field handler to provide simple renderer that allows linking to a node.
*/
class views_handler_sort_search_score extends views_handler_sort {
function query() {
// Check to see if the search filter added 'score' to the table.
// Our filter stores it as $handler->search_score -- and we also
// need to check its relationship to make sure that we're using the same
// one or obviously this won't work.
foreach ($this->view->filter as $handler) {
if (isset($handler->search_score) && $handler->relationship == $this->relationship) {
$this->query->add_orderby(NULL, NULL, $this->options['order'], $handler->search_score);
$this->table_alias = $handler->table_alias;
return;
}
}
// Do absolutely nothing if there is no filter in place; there is no reason to
// sort on the raw scores with this handler.
}
}

View file

@ -0,0 +1,33 @@
<?php
/**
* @file
* Contains the search row style plugin.
*/
/**
* Plugin which performs a node_view on the resulting object.
*/
class views_plugin_row_search_view extends views_plugin_row {
function option_definition() {
$options = parent::option_definition();
$options['score'] = array('default' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
$form['score'] = array(
'#type' => 'checkbox',
'#title' => t('Display score'),
'#default_value' => $this->options['score'],
);
}
/**
* Override the behavior of the render() function.
*/
function render($row) {
return theme($this->theme_functions(), $this->view, $this->options, $row);
}
}