View source
<?php
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
define('PREG_CLASS_NUMBERS', '\\x{30}-\\x{39}\\x{b2}\\x{b3}\\x{b9}\\x{bc}-\\x{be}\\x{660}-\\x{669}\\x{6f0}-\\x{6f9}' . '\\x{966}-\\x{96f}\\x{9e6}-\\x{9ef}\\x{9f4}-\\x{9f9}\\x{a66}-\\x{a6f}\\x{ae6}-\\x{aef}' . '\\x{b66}-\\x{b6f}\\x{be7}-\\x{bf2}\\x{c66}-\\x{c6f}\\x{ce6}-\\x{cef}\\x{d66}-\\x{d6f}' . '\\x{e50}-\\x{e59}\\x{ed0}-\\x{ed9}\\x{f20}-\\x{f33}\\x{1040}-\\x{1049}\\x{1369}-' . '\\x{137c}\\x{16ee}-\\x{16f0}\\x{17e0}-\\x{17e9}\\x{17f0}-\\x{17f9}\\x{1810}-\\x{1819}' . '\\x{1946}-\\x{194f}\\x{2070}\\x{2074}-\\x{2079}\\x{2080}-\\x{2089}\\x{2153}-\\x{2183}' . '\\x{2460}-\\x{249b}\\x{24ea}-\\x{24ff}\\x{2776}-\\x{2793}\\x{3007}\\x{3021}-\\x{3029}' . '\\x{3038}-\\x{303a}\\x{3192}-\\x{3195}\\x{3220}-\\x{3229}\\x{3251}-\\x{325f}\\x{3280}-' . '\\x{3289}\\x{32b1}-\\x{32bf}\\x{ff10}-\\x{ff19}');
define('PREG_CLASS_PUNCTUATION', '\\x{21}-\\x{23}\\x{25}-\\x{2a}\\x{2c}-\\x{2f}\\x{3a}\\x{3b}\\x{3f}\\x{40}\\x{5b}-\\x{5d}' . '\\x{5f}\\x{7b}\\x{7d}\\x{a1}\\x{ab}\\x{b7}\\x{bb}\\x{bf}\\x{37e}\\x{387}\\x{55a}-\\x{55f}' . '\\x{589}\\x{58a}\\x{5be}\\x{5c0}\\x{5c3}\\x{5f3}\\x{5f4}\\x{60c}\\x{60d}\\x{61b}\\x{61f}' . '\\x{66a}-\\x{66d}\\x{6d4}\\x{700}-\\x{70d}\\x{964}\\x{965}\\x{970}\\x{df4}\\x{e4f}' . '\\x{e5a}\\x{e5b}\\x{f04}-\\x{f12}\\x{f3a}-\\x{f3d}\\x{f85}\\x{104a}-\\x{104f}\\x{10fb}' . '\\x{1361}-\\x{1368}\\x{166d}\\x{166e}\\x{169b}\\x{169c}\\x{16eb}-\\x{16ed}\\x{1735}' . '\\x{1736}\\x{17d4}-\\x{17d6}\\x{17d8}-\\x{17da}\\x{1800}-\\x{180a}\\x{1944}\\x{1945}' . '\\x{2010}-\\x{2027}\\x{2030}-\\x{2043}\\x{2045}-\\x{2051}\\x{2053}\\x{2054}\\x{2057}' . '\\x{207d}\\x{207e}\\x{208d}\\x{208e}\\x{2329}\\x{232a}\\x{23b4}-\\x{23b6}\\x{2768}-' . '\\x{2775}\\x{27e6}-\\x{27eb}\\x{2983}-\\x{2998}\\x{29d8}-\\x{29db}\\x{29fc}\\x{29fd}' . '\\x{3001}-\\x{3003}\\x{3008}-\\x{3011}\\x{3014}-\\x{301f}\\x{3030}\\x{303d}\\x{30a0}' . '\\x{30fb}\\x{fd3e}\\x{fd3f}\\x{fe30}-\\x{fe52}\\x{fe54}-\\x{fe61}\\x{fe63}\\x{fe68}' . '\\x{fe6a}\\x{fe6b}\\x{ff01}-\\x{ff03}\\x{ff05}-\\x{ff0a}\\x{ff0c}-\\x{ff0f}\\x{ff1a}' . '\\x{ff1b}\\x{ff1f}\\x{ff20}\\x{ff3b}-\\x{ff3d}\\x{ff3f}\\x{ff5b}\\x{ff5d}\\x{ff5f}-' . '\\x{ff65}');
define('PREG_CLASS_CJK', '\\x{1100}-\\x{11FF}\\x{3040}-\\x{309F}\\x{30A1}-\\x{318E}' . '\\x{31A0}-\\x{31B7}\\x{31F0}-\\x{31FF}\\x{3400}-\\x{4DBF}\\x{4E00}-\\x{9FCF}' . '\\x{A000}-\\x{A48F}\\x{A4D0}-\\x{A4FD}\\x{A960}-\\x{A97F}\\x{AC00}-\\x{D7FF}' . '\\x{F900}-\\x{FAFF}\\x{FF21}-\\x{FF3A}\\x{FF41}-\\x{FF5A}\\x{FF66}-\\x{FFDC}' . '\\x{20000}-\\x{2FFFD}\\x{30000}-\\x{3FFFD}');
function search_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.search':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Search module provides the ability to set up search pages based on plugins provided by other modules. In Drupal core, there are two page-type plugins: the Content page type provides keyword searching for content managed by the Node module, and the Users page type provides keyword searching for registered users. Contributed modules may provide other page-type plugins. For more information, see the <a href=":search-module">online documentation for the Search module</a>.', array(
':search-module' => 'https://www.drupal.org/documentation/modules/search',
)) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Configuring search pages') . '</dt>';
$output .= '<dd>' . t('To configure search pages, visit the <a href=":search-settings">Search pages page</a>. In the Search pages section, you can add a new search page, edit the configuration of existing search pages, enable and disable search pages, and choose the default search page. Each enabled search page has a URL path starting with <em>search</em>, and each will appear as a tab or local task link on the <a href=":search-url">search page</a>; you can configure the text that is shown in the tab. In addition, some search page plugins have additional settings that you can configure for each search page.', array(
':search-settings' => \Drupal::url('entity.search_page.collection'),
':search-url' => \Drupal::url('search.view'),
)) . '</dd>';
$output .= '<dt>' . t('Managing the search index') . '</dt>';
$output .= '<dd>' . t('Some search page plugins, such as the core Content search page, index searchable text using the Drupal core search index, and will not work unless content is indexed. Indexing is done during <em>cron</em> runs, so it requires a <a href=":cron">cron maintenance task</a> to be set up. There are also several settings affecting indexing that can be configured on the <a href=":search-settings">Search pages page</a>: the number of items to index per cron run, the minimum word length to index, and how to handle Chinese, Japanese, and Korean characters.', array(
':cron' => \Drupal::url('system.cron_settings'),
':search-settings' => \Drupal::url('entity.search_page.collection'),
)) . '</dd>';
$output .= '<dd>' . t('Modules providing search page plugins generally ensure that content-related actions on your site (creating, editing, or deleting content and comments) automatically cause affected content items to be marked for indexing or reindexing at the next cron run. When content is marked for reindexing, the previous content remains in the index until cron runs, at which time it is replaced by the new content. However, there are some actions related to the structure of your site that do not cause affected content to be marked for reindexing. Examples of structure-related actions that affect content include deleting or editing taxonomy terms, enabling or disabling modules that add text to content (such as Taxonomy, Comment, and field-providing modules), and modifying the fields or display parameters of your content types. If you take one of these actions and you want to ensure that the search index is updated to reflect your changed site structure, you can mark all content for reindexing by clicking the "Re-index site" button on the <a href=":search-settings">Search pages page</a>. If you have a lot of content on your site, it may take several cron runs for the content to be reindexed.', array(
':search-settings' => \Drupal::url('entity.search_page.collection'),
)) . '</dd>';
$output .= '<dt>' . t('Displaying the Search block') . '</dt>';
$output .= '<dd>' . t('The Search module includes a block, which can be enabled and configured on the <a href=":blocks">Block layout page</a>, if you have the Block module enabled; the default block title is Search, and it is the Search form block in the Forms category, if you wish to add another instance. The block is available to users with the <a href=":search_permission">Use search</a> permission, and it performs a search using the configured default search page.', array(
':blocks' => \Drupal::moduleHandler()
->moduleExists('block') ? \Drupal::url('block.admin_display') : '#',
':search_permission' => \Drupal::url('user.admin_permissions', array(), array(
'fragment' => 'module-search',
)),
)) . '</dd>';
$output .= '<dt>' . t('Searching your site') . '</dt>';
$output .= '<dd>' . t('Users with <a href=":search_permission">Use search</a> permission can use the Search block and <a href=":search">Search page</a>. Users with the <a href=":node_permission">View published content</a> permission can use configured search pages of type <em>Content</em> to search for content containing exact keywords; in addition, users with <a href=":search_permission">Use advanced search</a> permission can use more complex search filtering. Users with the <a href=":user_permission">View user information</a> permission can use configured search pages of type <em>Users</em> to search for active users containing the keyword anywhere in the username, and users with the <a href=":user_permission">Administer users</a> permission can search for active and blocked users, by email address or username keyword.', array(
':search' => \Drupal::url('search.view'),
':search_permission' => \Drupal::url('user.admin_permissions', array(), array(
'fragment' => 'module-search',
)),
':node_permission' => \Drupal::url('user.admin_permissions', array(), array(
'fragment' => 'module-node',
)),
':user_permission' => \Drupal::url('user.admin_permissions', array(), array(
'fragment' => 'module-user',
)),
)) . '</dd>';
$output .= '<dt>' . t('Extending the Search module') . '</dt>';
$output .= '<dd>' . t('By default, the Search module only supports exact keyword matching in content searches. You can modify this behavior by installing a language-specific stemming module for your language (such as <a href=":porterstemmer_url">Porter Stemmer</a> for American English), which allows words such as walk, walking, and walked to be matched in the Search module. Another approach is to use a third-party search technology with stemming or partial word matching features built in, such as <a href=":solr_url">Apache Solr</a> or <a href=":sphinx_url">Sphinx</a>. There are also contributed modules that provide additional search pages. These and other <a href=":contrib-search">search-related contributed modules</a> can be downloaded by visiting Drupal.org.', array(
':contrib-search' => 'https://www.drupal.org/project/project_module?f[2]=im_vid_3%3A105',
':porterstemmer_url' => 'https://www.drupal.org/project/porterstemmer',
':solr_url' => 'https://www.drupal.org/project/apachesolr',
':sphinx_url' => 'https://www.drupal.org/project/sphinx',
)) . '</dd>';
$output .= '</dl>';
return $output;
}
}
function search_theme() {
return array(
'search_result' => array(
'variables' => array(
'result' => NULL,
'plugin_id' => NULL,
),
'file' => 'search.pages.inc',
),
);
}
function search_preprocess_block(&$variables) {
if ($variables['plugin_id'] == 'search_form_block') {
$variables['attributes']['role'] = 'search';
}
}
function search_index_clear($type = NULL, $sid = NULL, $langcode = NULL) {
$query_index = db_delete('search_index');
$query_dataset = db_delete('search_dataset');
if ($type) {
$query_index
->condition('type', $type);
$query_dataset
->condition('type', $type);
if ($sid) {
$query_index
->condition('sid', $sid);
$query_dataset
->condition('sid', $sid);
if ($langcode) {
$query_index
->condition('langcode', $langcode);
$query_dataset
->condition('langcode', $langcode);
}
}
}
$query_index
->execute();
$query_dataset
->execute();
if ($type) {
Cache::invalidateTags([
'search_index:' . $type,
]);
}
else {
Cache::invalidateTags([
'search_index',
]);
}
}
function search_dirty($word = NULL) {
$dirty =& drupal_static(__FUNCTION__, array());
if ($word !== NULL) {
$dirty[$word] = TRUE;
}
else {
return $dirty;
}
}
function search_cron() {
drupal_register_shutdown_function('search_update_totals');
$search_page_repository = \Drupal::service('search.search_page_repository');
foreach ($search_page_repository
->getIndexableSearchPages() as $entity) {
$entity
->getPlugin()
->updateIndex();
}
}
function search_update_totals() {
foreach (search_dirty() as $word => $dummy) {
$total = db_query("SELECT SUM(score) FROM {search_index} WHERE word = :word", array(
':word' => $word,
), array(
'target' => 'replica',
))
->fetchField();
$total = log10(1 + 1 / max(1, $total));
db_merge('search_total')
->key('word', $word)
->fields(array(
'count' => $total,
))
->execute();
}
$result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL", array(), array(
'target' => 'replica',
));
$or = db_or();
foreach ($result as $word) {
$or
->condition('word', $word->realword);
}
if (count($or) > 0) {
db_delete('search_total')
->condition($or)
->execute();
}
}
function search_simplify($text, $langcode = NULL) {
$text = Html::decodeEntities($text);
$text = Unicode::strtolower($text);
$text = \Drupal::service('transliteration')
->removeDiacritics($text);
search_invoke_preprocess($text, $langcode);
if (\Drupal::config('search.settings')
->get('index.overlap_cjk')) {
$text = preg_replace_callback('/[' . PREG_CLASS_CJK . ']+/u', 'search_expand_cjk', $text);
}
$text = preg_replace('/([' . PREG_CLASS_NUMBERS . ']+)[' . PREG_CLASS_PUNCTUATION . ']+(?=[' . PREG_CLASS_NUMBERS . '])/u', '\\1', $text);
$text = preg_replace('/[.-]{2,}/', ' ', $text);
$text = preg_replace('/[._-]+/', '', $text);
$text = preg_replace('/[' . Unicode::PREG_CLASS_WORD_BOUNDARY . ']+/u', ' ', $text);
$words = explode(' ', $text);
array_walk($words, '_search_index_truncate');
$text = implode(' ', $words);
return $text;
}
function search_expand_cjk($matches) {
$min = \Drupal::config('search.settings')
->get('index.minimum_word_size');
$str = $matches[0];
$length = Unicode::strlen($str);
if ($length <= $min) {
return ' ' . $str . ' ';
}
$tokens = ' ';
$chars = array();
for ($i = 0; $i < $length; $i++) {
$current = Unicode::substr($str, 0, 1);
$str = substr($str, strlen($current));
$chars[] = $current;
if ($i >= $min - 1) {
$tokens .= implode('', $chars) . ' ';
array_shift($chars);
}
}
return $tokens;
}
function search_index_split($text, $langcode = NULL) {
$last =& drupal_static(__FUNCTION__);
$lastsplit =& drupal_static(__FUNCTION__ . ':lastsplit');
if ($last == $text) {
return $lastsplit;
}
$text = search_simplify($text, $langcode);
$words = explode(' ', $text);
$last = $text;
$lastsplit = $words;
return $words;
}
function _search_index_truncate(&$text) {
static $truncated = array();
if (isset($truncated[$text])) {
$text = $truncated[$text];
return;
}
$original = $text;
if (is_numeric($text)) {
$text = ltrim($text, '0');
}
$text = Unicode::truncate($text, 50);
$truncated[$original] = $text;
}
function search_invoke_preprocess(&$text, $langcode = NULL) {
foreach (\Drupal::moduleHandler()
->getImplementations('search_preprocess') as $module) {
$text = \Drupal::moduleHandler()
->invoke($module, 'search_preprocess', array(
$text,
$langcode,
));
}
}
function search_index($type, $sid, $langcode, $text) {
$minimum_word_size = \Drupal::config('search.settings')
->get('index.minimum_word_size');
$tags = \Drupal::config('search.settings')
->get('index.tag_weights');
$text = str_replace(array(
'<',
'>',
), array(
' <',
'> ',
), $text);
$text = strip_tags($text, '<' . implode('><', array_keys($tags)) . '>');
$split = preg_split('/\\s*<([^>]+?)>\\s*/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
$tag = FALSE;
$score = 1;
$accum = ' ';
$tagstack = array();
$tagwords = 0;
$focus = 1;
$scored_words = array();
foreach ($split as $value) {
if ($tag) {
list($tagname) = explode(' ', $value, 2);
$tagname = Unicode::strtolower($tagname);
if ($tagname[0] == '/') {
$tagname = substr($tagname, 1);
if (!count($tagstack) || $tagstack[0] != $tagname) {
$tagstack = array();
$score = 1;
}
else {
$score = max(1, $score - $tags[array_shift($tagstack)]);
}
}
else {
if (isset($tagstack[0]) && $tagstack[0] == $tagname) {
$tagstack = array();
$score = 1;
}
else {
array_unshift($tagstack, $tagname);
$score += $tags[$tagname];
}
}
$tagwords = 0;
}
else {
if ($value != '') {
$words = search_index_split($value, $langcode);
foreach ($words as $word) {
$accum .= $word . ' ';
if (is_numeric($word) || Unicode::strlen($word) >= $minimum_word_size) {
if (!isset($scored_words[$word])) {
$scored_words[$word] = 0;
}
$scored_words[$word] += $score * $focus;
$focus = min(1, 0.01 + 3.5 / (2 + count($scored_words) * 0.015));
}
$tagwords++;
if (count($tagstack) && $tagwords >= 15) {
$tagstack = array();
$score = 1;
}
}
}
}
$tag = !$tag;
}
search_index_clear($type, $sid, $langcode);
db_insert('search_dataset')
->fields(array(
'sid' => $sid,
'langcode' => $langcode,
'type' => $type,
'data' => $accum,
'reindex' => 0,
))
->execute();
foreach ($scored_words as $word => $score) {
db_merge('search_index')
->keys(array(
'word' => $word,
'sid' => $sid,
'langcode' => $langcode,
'type' => $type,
))
->fields(array(
'score' => $score,
))
->expression('score', 'score + :score', array(
':score' => $score,
))
->execute();
search_dirty($word);
}
}
function search_mark_for_reindex($type = NULL, $sid = NULL, $langcode = NULL) {
$query = db_update('search_dataset')
->fields(array(
'reindex' => REQUEST_TIME,
))
->condition('reindex', 0);
if ($type) {
$query
->condition('type', $type);
if ($sid) {
$query
->condition('sid', $sid);
if ($langcode) {
$query
->condition('langcode', $langcode);
}
}
}
$query
->execute();
}
function search_excerpt($keys, $text, $langcode = NULL) {
$boundary_character = '[' . Unicode::PREG_CLASS_WORD_BOUNDARY . PREG_CLASS_CJK . ']';
$preceded_by_boundary = '(?<=' . $boundary_character . ')';
$followed_by_boundary = '(?=' . $boundary_character . ')';
preg_match_all('/ ("([^"]+)"|(?!OR)([^" ]+))/', ' ' . $keys, $matches);
$keys = array_merge($matches[2], $matches[3]);
$text = strip_tags(str_replace(array(
'<',
'>',
), array(
' <',
'> ',
), $text));
$text = Html::decodeEntities($text);
$text_length = strlen($text);
$temp_keys = array();
foreach ($keys as $key) {
$key = _search_find_match_with_simplify($key, $text, $boundary_character, $langcode);
if (isset($key)) {
$temp_keys[] = preg_quote($key, '/');
}
}
$keys = array_unique($temp_keys);
$ranges = array();
$length = 0;
$look_start = array();
$remaining_keys = $keys;
while ($length < 256 && !empty($remaining_keys)) {
$found_keys = array();
foreach ($remaining_keys as $key) {
if ($length >= 256) {
break;
}
if (!isset($look_start[$key])) {
$look_start[$key] = 0;
}
$matches = array();
if (preg_match('/' . $preceded_by_boundary . $key . $followed_by_boundary . '/iu', ' ' . $text . ' ', $matches, PREG_OFFSET_CAPTURE, $look_start[$key])) {
$found_position = $matches[0][1];
$look_start[$key] = $found_position + 1;
$found_keys[] = $key;
$before = strpos(' ' . $text, ' ', max(0, $found_position - 61));
if ($before !== FALSE && $before <= $found_position) {
if ($text_length > $found_position + 60) {
$after = strrpos(substr($text, 0, $found_position + 60), ' ', $found_position);
}
else {
$after = $text_length;
}
if ($after !== FALSE && $after > $found_position) {
$before = max($before - 1, 0);
if ($before < $after) {
$ranges[$before] = $after;
$length += $after - $before;
}
}
}
}
}
$remaining_keys = $found_keys;
}
if (empty($ranges)) {
return [
'#plain_text' => Unicode::truncate($text, 256, TRUE, TRUE),
];
}
ksort($ranges);
$new_ranges = array();
$max_end = 0;
foreach ($ranges as $this_from => $this_to) {
$max_end = max($max_end, $this_to);
if (!isset($working_from)) {
$working_from = $this_from;
$working_to = $this_to;
continue;
}
if ($this_from <= $working_to) {
$working_to = max($working_to, $this_to);
}
else {
$new_ranges[$working_from] = $working_to;
$working_from = $this_from;
$working_to = $this_to;
}
}
$new_ranges[$working_from] = $working_to;
$out = array();
foreach ($new_ranges as $from => $to) {
$out[] = substr($text, $from, $to - $from);
}
$ellipses = explode('@excerpt', t('… @excerpt … @excerpt …'));
$text = (isset($new_ranges[0]) ? '' : $ellipses[0]) . implode($ellipses[1], $out) . ($max_end < strlen($text) - 1 ? $ellipses[2] : '');
$text = Html::escape($text);
$text = trim(preg_replace('/' . $preceded_by_boundary . '(?:' . implode('|', $keys) . ')' . $followed_by_boundary . '/iu', '<strong>\\0</strong>', ' ' . $text . ' '));
return [
'#markup' => $text,
'#allowed_tags' => [
'strong',
],
];
}
function _search_find_match_with_simplify($key, $text, $boundary, $langcode = NULL) {
$preceded_by_boundary = '(?<=' . $boundary . ')';
$followed_by_boundary = '(?=' . $boundary . ')';
$temp = trim($key);
if ($temp == '') {
return NULL;
}
if (preg_match('/' . $preceded_by_boundary . preg_quote($temp, '/') . $followed_by_boundary . '/iu', ' ' . $text . ' ')) {
return $temp;
}
$new_text = Unicode::strtolower($text);
$new_text = \Drupal::service('transliteration')
->removeDiacritics($new_text);
$new_key = Unicode::strtolower($temp);
$new_key = \Drupal::service('transliteration')
->removeDiacritics($new_key);
if (preg_match('/' . $preceded_by_boundary . preg_quote($new_key, '/') . $followed_by_boundary . '/u', ' ' . $new_text . ' ')) {
$position = Unicode::strpos($new_text, $new_key);
return Unicode::substr($text, $position, Unicode::strlen($new_key));
}
$simplified_key = trim(search_simplify($key, $langcode));
$simplified_text = trim(search_simplify($text, $langcode));
if ($simplified_key == '' || $simplified_text == '' || strpos($simplified_text, $simplified_key) === FALSE) {
return NULL;
}
$words = preg_split('/' . $boundary . '+/u', $text, NULL, PREG_SPLIT_OFFSET_CAPTURE);
$words[] = array(
'',
strlen($text),
);
$start_index = 0;
$start_pos = $words[$start_index][1];
$min_end_index = 1;
$max_end_index = count($words) - 1;
while ($max_end_index > $min_end_index) {
$proposed_end_index = floor(($max_end_index + $min_end_index) / 2);
$proposed_end_pos = $words[$proposed_end_index][1];
$trial_text = trim(search_simplify(substr($text, $start_pos, $proposed_end_pos - $start_pos), $langcode));
if (strpos($trial_text, $simplified_key) !== FALSE) {
$max_end_index = $proposed_end_index;
}
else {
$min_end_index = $proposed_end_index + 1;
}
}
$end_index = $min_end_index;
$end_pos = $words[$end_index][1];
$min_start_index = 0;
$max_start_index = $end_index - 1;
while ($max_start_index > $min_start_index) {
$proposed_start_index = ceil(($max_start_index + $min_start_index) / 2);
$proposed_start_pos = $words[$proposed_start_index][1];
$trial_text = trim(search_simplify(substr($text, $proposed_start_pos, $end_pos - $proposed_start_pos), $langcode));
if (strpos($trial_text, $simplified_key) !== FALSE) {
$min_start_index = $proposed_start_index;
}
else {
$max_start_index = $proposed_start_index - 1;
}
}
$start_index = $max_start_index;
return trim(substr($text, $words[$start_index][1], $words[$end_index][1] - $words[$start_index][1]));
}
function search_form_search_block_form_alter(&$form, FormStateInterface $form_state) {
$form['form_build_id']['#access'] = FALSE;
$form['form_token']['#access'] = FALSE;
$form['form_id']['#access'] = FALSE;
}