updated to 7.x-1.11

This commit is contained in:
Bachir Soussi Chiadmi
2014-02-07 10:01:18 +01:00
parent a30917d1d2
commit cf03e9ca52
69 changed files with 4629 additions and 1557 deletions
+9 -10
View File
@@ -1,5 +1,10 @@
<?php
/**
* @file
* Contains SearchApiStopWords.
*/
/**
* Processor for removing stopwords from index and search terms.
*/
@@ -21,8 +26,7 @@ class SearchApiStopWords extends SearchApiAbstractProcessor {
),
'file' => array(
'#type' => 'textfield',
'#title' => t('Stopwords file URI'),
'#title' => t('Enter the URI of your stopwords.txt file'),
'#title' => t('Stopwords file'),
'#description' => t('This must be a stream-type description like <code>public://stopwords/stopwords.txt</code> or <code>http://example.com/stopwords.txt</code> or <code>private://stopwords.txt</code>.'),
),
'stopwords' => array(
@@ -43,13 +47,8 @@ class SearchApiStopWords extends SearchApiAbstractProcessor {
public function configurationFormValidate(array $form, array &$values, array &$form_state) {
parent::configurationFormValidate($form, $values, $form_state);
$stopwords = trim($values['stopwords']);
$uri = $values['file'];
if (empty($stopwords) && empty($uri)) {
$el = $form['file'];
form_error($el, $el['#title'] . ': ' . t('At stopwords file or words are required.'));
}
if (!empty($uri) && !file_get_contents($uri)) {
if (!empty($uri) && !@file_get_contents($uri)) {
$el = $form['file'];
form_error($el, t('Stopwords file') . ': ' . t('The file %uri is not readable or does not exist.', array('%uri' => $uri)));
}
@@ -57,7 +56,7 @@ class SearchApiStopWords extends SearchApiAbstractProcessor {
public function process(&$value) {
$stopwords = $this->getStopWords();
if (empty($stopwords) && !is_string($value)) {
if (empty($stopwords) || !is_string($value)) {
return;
}
$words = preg_split('/\s+/', $value);
@@ -105,4 +104,4 @@ class SearchApiStopWords extends SearchApiAbstractProcessor {
$this->stopwords = array_flip(array_merge($file_words, $form_words));
return $this->stopwords;
}
}
}