Initial code using Drupal 6.38

This commit is contained in:
Manuel Cillero 2017-07-24 15:21:05 +02:00
commit 4824608a33
467 changed files with 90887 additions and 0 deletions

View file

@ -0,0 +1,36 @@
<?php
/**
* @file search-block-form.tpl.php
* Default theme implementation for displaying a search form within a block region.
*
* Available variables:
* - $search_form: The complete search form ready for print.
* - $search: Array of keyed search elements. Can be used to print each form
* element separately.
*
* Default keys within $search:
* - $search['search_block_form']: Text input area wrapped in a div.
* - $search['submit']: Form submit button.
* - $search['hidden']: Hidden form elements. Used to validate forms when submitted.
*
* Since $search is keyed, a direct print of the form element is possible.
* Modules can add to the search form so it is recommended to check for their
* existance before printing. The default keys will always exist.
*
* <?php if (isset($search['extra_field'])): ?>
* <div class="extra-field">
* <?php print $search['extra_field']; ?>
* </div>
* <?php endif; ?>
*
* To check for all available data within $search, use the code below.
*
* <?php print '<pre>'. check_plain(print_r($search, 1)) .'</pre>'; ?>
*
* @see template_preprocess_search_block_form()
*/
?>
<div class="container-inline">
<?php print $search_form; ?>
</div>

View file

@ -0,0 +1,58 @@
<?php
/**
* @file search-result.tpl.php
* Default theme implementation for displaying a single search result.
*
* This template renders a single search result and is collected into
* search-results.tpl.php. This and the parent template are
* dependent to one another sharing the markup for definition lists.
*
* Available variables:
* - $url: URL of the result.
* - $title: Title of the result.
* - $snippet: A small preview of the result. Does not apply to user searches.
* - $info: String of all the meta information ready for print. Does not apply
* to user searches.
* - $info_split: Contains same data as $info, split into a keyed array.
* - $type: The type of search, e.g., "node" or "user".
*
* Default keys within $info_split:
* - $info_split['type']: Node type.
* - $info_split['user']: Author of the node linked to users profile. Depends
* on permission.
* - $info_split['date']: Last update of the node. Short formatted.
* - $info_split['comment']: Number of comments output as "% comments", %
* being the count. Depends on comment.module.
* - $info_split['upload']: Number of attachments output as "% attachments", %
* being the count. Depends on upload.module.
*
* Since $info_split is keyed, a direct print of the item is possible.
* This array does not apply to user searches so it is recommended to check
* for their existance before printing. The default keys of 'type', 'user' and
* 'date' always exist for node searches. Modules may provide other data.
*
* <?php if (isset($info_split['comment'])) : ?>
* <span class="info-comment">
* <?php print $info_split['comment']; ?>
* </span>
* <?php endif; ?>
*
* To check for all available data within $info_split, use the code below.
*
* <?php print '<pre>'. check_plain(print_r($info_split, 1)) .'</pre>'; ?>
*
* @see template_preprocess_search_result()
*/
?>
<dt class="title">
<a href="<?php print $url; ?>"><?php print $title; ?></a>
</dt>
<dd>
<?php if ($snippet) : ?>
<p class="search-snippet"><?php print $snippet; ?></p>
<?php endif; ?>
<?php if ($info) : ?>
<p class="search-info"><?php print $info; ?></p>
<?php endif; ?>
</dd>

View file

@ -0,0 +1,26 @@
<?php
/**
* @file search-results.tpl.php
* Default theme implementation for displaying search results.
*
* This template collects each invocation of theme_search_result(). This and
* the child template are dependant to one another sharing the markup for
* definition lists.
*
* Note that modules may implement their own search type and theme function
* completely bypassing this template.
*
* Available variables:
* - $search_results: All results as it is rendered through
* search-result.tpl.php
* - $type: The type of search, e.g., "node" or "user".
*
*
* @see template_preprocess_search_results()
*/
?>
<dl class="search-results <?php print $type; ?>-results">
<?php print $search_results; ?>
</dl>
<?php print $pager; ?>

View file

@ -0,0 +1,10 @@
.search-advanced .criterion {
float: right;
margin-right: 0;
margin-left: 2em;
}
.search-advanced .action {
float: right;
clear: right;
}

View file

@ -0,0 +1,37 @@
<?php
/**
* @file search-theme-form.tpl.php
* Default theme implementation for displaying a search form directly into the
* theme layout. Not to be confused with the search block or the search page.
*
* Available variables:
* - $search_form: The complete search form ready for print.
* - $search: Array of keyed search elements. Can be used to print each form
* element separately.
*
* Default keys within $search:
* - $search['search_theme_form']: Text input area wrapped in a div.
* - $search['submit']: Form submit button.
* - $search['hidden']: Hidden form elements. Used to validate forms when submitted.
*
* Since $search is keyed, a direct print of the form element is possible.
* Modules can add to the search form so it is recommended to check for their
* existance before printing. The default keys will always exist.
*
* <?php if (isset($search['extra_field'])): ?>
* <div class="extra-field">
* <?php print $search['extra_field']; ?>
* </div>
* <?php endif; ?>
*
* To check for all available data within $search, use the code below.
*
* <?php print '<pre>'. check_plain(print_r($search, 1)) .'</pre>'; ?>
*
* @see template_preprocess_search_theme_form()
*/
?>
<div id="search" class="container-inline">
<?php print $search_form; ?>
</div>

View file

@ -0,0 +1,84 @@
<?php
/**
* @file
* Admin page callbacks for the search module.
*/
/**
* Menu callback: confirm wiping of the index.
*/
function search_wipe_confirm() {
return confirm_form(array(), t('Are you sure you want to re-index the site?'),
'admin/settings/search', t(' The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), t('Re-index site'), t('Cancel'));
}
/**
* Handler for wipe confirmation
*/
function search_wipe_confirm_submit(&$form, &$form_state) {
if ($form['confirm']) {
search_wipe();
drupal_set_message(t('The index will be rebuilt.'));
$form_state['redirect'] = 'admin/settings/search';
return;
}
}
/**
* Menu callback; displays the search module settings page.
*
* @ingroup forms
* @see system_settings_form()
* @see search_admin_settings_validate()
*/
function search_admin_settings() {
// Collect some stats
$remaining = 0;
$total = 0;
foreach (module_list() as $module) {
if (module_hook($module, 'search')) {
$status = module_invoke($module, 'search', 'status');
$remaining += $status['remaining'];
$total += $status['total'];
}
}
$count = format_plural($remaining, 'There is 1 item left to index.', 'There are @count items left to index.');
$percentage = ((int)min(100, 100 * ($total - $remaining) / max(1, $total))) .'%';
$status = '<p><strong>'. t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) .' '. $count .'</strong></p>';
$form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status'));
$form['status']['status'] = array('#value' => $status);
$form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'));
$items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500));
// Indexing throttle:
$form['indexing_throttle'] = array('#type' => 'fieldset', '#title' => t('Indexing throttle'));
$form['indexing_throttle']['search_cron_limit'] = array('#type' => 'select', '#title' => t('Number of items to index per cron run'), '#default_value' => variable_get('search_cron_limit', 100), '#options' => $items, '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))));
// Indexing settings:
$form['indexing_settings'] = array('#type' => 'fieldset', '#title' => t('Indexing settings'));
$form['indexing_settings']['info'] = array('#value' => t('<p><em>Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.</em></p><p><em>The default settings should be appropriate for the majority of sites.</em></p>'));
$form['indexing_settings']['minimum_word_size'] = array('#type' => 'textfield', '#title' => t('Minimum word length to index'), '#default_value' => variable_get('minimum_word_size', 3), '#size' => 5, '#maxlength' => 3, '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).'));
$form['indexing_settings']['overlap_cjk'] = array('#type' => 'checkbox', '#title' => t('Simple CJK handling'), '#default_value' => variable_get('overlap_cjk', TRUE), '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.'));
$form['#validate'] = array('search_admin_settings_validate');
// Per module settings
$form = array_merge($form, module_invoke_all('search', 'admin'));
return system_settings_form($form);
}
/**
* Validate callback.
*/
function search_admin_settings_validate($form, &$form_state) {
if ($form_state['values']['op'] == t('Re-index site')) {
drupal_goto('admin/settings/search/wipe');
}
// If these settings change, the index needs to be rebuilt.
if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) ||
(variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) {
drupal_set_message(t('The index will be rebuilt.'));
search_wipe();
}
}

28
modules/search/search.css Normal file
View file

@ -0,0 +1,28 @@
.search-form {
margin-bottom: 1em;
}
.search-form input {
margin-top: 0;
margin-bottom: 0;
}
.search-results p {
margin-top: 0;
}
.search-results dt {
font-size: 1.1em;
}
.search-results dd {
margin-bottom: 1em;
}
.search-results .search-info {
font-size: 0.85em;
}
.search-advanced .criterion {
float: left; /* LTR */
margin-right: 2em; /* LTR */
}
.search-advanced .action {
float: left; /* LTR */
clear: left; /* LTR */
}

View file

@ -0,0 +1,11 @@
name = Search
description = Enables site-wide keyword searching.
package = Core - optional
version = VERSION
core = 6.x
; Information added by Drupal.org packaging script on 2016-02-24
version = "6.38"
project = "drupal"
datestamp = "1456343372"

View file

@ -0,0 +1,152 @@
<?php
/**
* Implementation of hook_install().
*/
function search_install() {
// Create tables.
drupal_install_schema('search');
}
/**
* Implementation of hook_uninstall().
*/
function search_uninstall() {
// Remove tables.
drupal_uninstall_schema('search');
variable_del('minimum_word_size');
variable_del('overlap_cjk');
variable_del('search_cron_limit');
}
/**
* Implementation of hook_schema().
*/
function search_schema() {
$schema['search_dataset'] = array(
'description' => 'Stores items that will be searched.',
'fields' => array(
'sid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Search item ID, e.g. node ID for nodes.',
),
'type' => array(
'type' => 'varchar',
'length' => 16,
'not null' => FALSE,
'description' => 'Type of item, e.g. node.',
),
'data' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'List of space-separated words from the item.',
),
'reindex' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Set to force node reindexing.',
),
),
'unique keys' => array('sid_type' => array('sid', 'type')),
);
$schema['search_index'] = array(
'description' => 'Stores the search index, associating words, items and scores.',
'fields' => array(
'word' => array(
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
'description' => 'The {search_total}.word that is associated with the search item.',
),
'sid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {search_dataset}.sid of the searchable item to which the word belongs.',
),
'type' => array(
'type' => 'varchar',
'length' => 16,
'not null' => FALSE,
'description' => 'The {search_dataset}.type of the searchable item to which the word belongs.',
),
'score' => array(
'type' => 'float',
'not null' => FALSE,
'description' => 'The numeric score of the word, higher being more important.',
),
),
'indexes' => array(
'sid_type' => array('sid', 'type'),
'word' => array('word')
),
'unique keys' => array('word_sid_type' => array('word', 'sid', 'type')),
);
$schema['search_total'] = array(
'description' => 'Stores search totals for words.',
'fields' => array(
'word' => array(
'description' => 'Primary Key: Unique word in the search index.',
'type' => 'varchar',
'length' => 50,
'not null' => TRUE,
'default' => '',
),
'count' => array(
'description' => "The count of the word in the index using Zipf's law to equalize the probability distribution.",
'type' => 'float',
'not null' => FALSE,
),
),
'primary key' => array('word'),
);
$schema['search_node_links'] = array(
'description' => 'Stores items (like nodes) that link to other nodes, used to improve search scores for nodes that are frequently linked to.',
'fields' => array(
'sid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {search_dataset}.sid of the searchable item containing the link to the node.',
),
'type' => array(
'type' => 'varchar',
'length' => 16,
'not null' => TRUE,
'default' => '',
'description' => 'The {search_dataset}.type of the searchable item containing the link to the node.',
),
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {node}.nid that this item links to.',
),
'caption' => array(
'type' => 'text',
'size' => 'big',
'not null' => FALSE,
'description' => 'The text used to link to the {node}.nid.',
),
),
'primary key' => array('sid', 'type', 'nid'),
'indexes' => array('nid' => array('nid')),
);
return $schema;
}

1303
modules/search/search.module Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,129 @@
<?php
/**
* @file
* User page callbacks for the search module.
*/
/**
* Menu callback; presents the search form and/or search results.
*/
function search_view($type = 'node') {
// Search form submits with POST but redirects to GET. This way we can keep
// the search query URL clean as a whistle:
// search/type/keyword+keyword
if (!isset($_POST['form_id'])) {
if ($type == '') {
// Note: search/node can not be a default tab because it would take on the
// path of its parent (search). It would prevent remembering keywords when
// switching tabs. This is why we drupal_goto to it from the parent instead.
drupal_goto('search/node');
}
$keys = search_get_keys();
// Only perform search if there is non-whitespace search term:
$results = '';
if (trim($keys)) {
// Log the search keys:
watchdog('search', '%keys (@type).', array('%keys' => $keys, '@type' => module_invoke($type, 'search', 'name')), WATCHDOG_NOTICE, l(t('results'), 'search/'. $type .'/'. $keys));
// Collect the search results:
$results = search_data($keys, $type);
if ($results) {
$results = theme('box', t('Search results'), $results);
}
else {
$results = theme('box', t('Your search yielded no results'), search_help('search#noresults', drupal_help_arg()));
}
}
// Construct the search form.
$output = drupal_get_form('search_form', NULL, $keys, $type);
$output .= $results;
return $output;
}
return drupal_get_form('search_form', NULL, empty($keys) ? '' : $keys, $type);
}
/**
* Process variables for search-results.tpl.php.
*
* The $variables array contains the following arguments:
* - $results
* - $type
*
* @see search-results.tpl.php
*/
function template_preprocess_search_results(&$variables) {
$variables['search_results'] = '';
foreach ($variables['results'] as $result) {
$variables['search_results'] .= theme('search_result', $result, $variables['type']);
}
$variables['pager'] = theme('pager', NULL, 10, 0);
// Provide alternate search results template.
$variables['template_files'][] = 'search-results-'. $variables['type'];
}
/**
* Process variables for search-result.tpl.php.
*
* The $variables array contains the following arguments:
* - $result
* - $type
*
* @see search-result.tpl.php
*/
function template_preprocess_search_result(&$variables) {
$result = $variables['result'];
$variables['url'] = check_url($result['link']);
$variables['title'] = check_plain($result['title']);
$info = array();
if (!empty($result['type'])) {
$info['type'] = check_plain($result['type']);
}
if (!empty($result['user'])) {
$info['user'] = $result['user'];
}
if (!empty($result['date'])) {
$info['date'] = format_date($result['date'], 'small');
}
if (isset($result['extra']) && is_array($result['extra'])) {
$info = array_merge($info, $result['extra']);
}
// Check for existence. User search does not include snippets.
$variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : '';
// Provide separated and grouped meta information..
$variables['info_split'] = $info;
$variables['info'] = implode(' - ', $info);
// Provide alternate search result template.
$variables['template_files'][] = 'search-result-'. $variables['type'];
}
/**
* As the search form collates keys from other modules hooked in via
* hook_form_alter, the validation takes place in _submit.
* search_form_validate() is used solely to set the 'processed_keys' form
* value for the basic search form.
*/
function search_form_validate($form, &$form_state) {
form_set_value($form['basic']['inline']['processed_keys'], trim($form_state['values']['keys']), $form_state);
}
/**
* Process a search form submission.
*/
function search_form_submit($form, &$form_state) {
$keys = $form_state['values']['processed_keys'];
if ($keys == '') {
form_set_error('keys', t('Please enter some keywords.'));
// Fall through to the drupal_goto() call.
}
$type = $form_state['values']['module'] ? $form_state['values']['module'] : 'node';
$form_state['redirect'] = 'search/'. $type .'/'. $keys;
return;
}