Skip to content

Commit 1e7850e

Browse files
committed
minor changes
- correct wiki link - utf-8 support only
1 parent d2dbf57 commit 1e7850e

8 files changed

+20
-236
lines changed

classes/class.rexsearch.inc.php

+14-30
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ class RexSearch
8787
var $surroundTags = array('<strong>','</strong>');
8888
var $tablePrefix;
8989
var $textMode = 'plain';
90-
var $utf8 = true;
9190
var $whitelist = array();
9291
var $where = '';
9392

@@ -186,26 +185,18 @@ function RexSearch($_clang = false, $_loadSettings = true, $_useStopwords = true
186185
$this->tablePrefix = $REX['TABLE_PREFIX'];
187186
$this->includePath = $REX['INCLUDE_PATH'];
188187
$this->generatedPath = $REX['GENERATED_PATH'];
189-
$this->utf8 = rex_lang_is_utf8();
190188
$this->documentRoot = realpath($_SERVER['DOCUMENT_ROOT']);
191189
$this->mediaFolder = $REX['MEDIAFOLDER'];
192190

193-
#$I18N->appendFile($REX['INCLUDE_PATH'].'/addons/rexsearch/lang/');
194-
if($this->utf8)
195-
$locale = 'de_de_utf8';
196-
else
197-
$locale = 'de_de';
191+
$locale = 'de_de';
198192

199193
$langfile = new i18n($locale, $REX['INCLUDE_PATH'].'/addons/rexsearch/lang/');
200194
$this->ellipsis = $langfile->Msg('a587_ellipsis');
201195

202196
// german stopwords
203197
if($_useStopwords)
204198
{
205-
if($this->utf8)
206-
include $this->includePath.'/addons/rexsearch/lang/stopwords_utf8.inc.php';
207-
else
208-
include $this->includePath.'/addons/rexsearch/lang/stopwords.inc.php';
199+
include $this->includePath.'/addons/rexsearch/lang/stopwords.inc.php';
209200
$this->stopwords = $german_stopwords;
210201
}
211202
}
@@ -426,16 +417,14 @@ function setSearchInIDs($_searchInIDs, $_reset = false)
426417

427418
/**
428419
* If utf8-encoding is used, the parameter will be appended with an "u".
420+
* Since there is only UTF-8 supported, it always appends the "u".
429421
*
430422
* @param string $_regex
431423
* @return string
432424
*/
433425
function encodeRegex($_regex)
434426
{
435-
if($this->utf8)
436-
return $_regex.'u';
437-
else
438-
return $_regex;
427+
return $_regex.'u';
439428
}
440429

441430
/**
@@ -675,7 +664,7 @@ function indexArticle($_id,$_clang = false)
675664

676665
foreach(preg_split($this->encodeRegex('~[[:punct:][:space:]]+~ism'), $plaintext) as $keyword)
677666
{
678-
if($this->significantCharacterCount <= mb_strlen($keyword,$this->utf8?'UTF-8':mb_internal_encoding()))
667+
if($this->significantCharacterCount <= mb_strlen($keyword,'UTF-8'))
679668
$keywords[] = array('search'=>$keyword,'clang'=>$langID);
680669
}
681670

@@ -831,7 +820,7 @@ function indexColumn($_table, $_column, $_idcol = false, $_id = false, $_start =
831820

832821
foreach(preg_split($this->encodeRegex('~[[:punct:][:space:]]+~ism'), $plaintext) as $keyword)
833822
{
834-
if($this->significantCharacterCount <= mb_strlen($keyword,$this->utf8?'UTF-8':mb_internal_encoding()))
823+
if($this->significantCharacterCount <= mb_strlen($keyword,'UTF-8'))
835824
$keywords[] = array('search'=>$keyword,'clang'=>is_null($indexData['clang'])?false:$indexData['clang']);
836825
}
837826

@@ -950,10 +939,7 @@ function indexFile($_filename, $_doPlaintext = false, $_clang = false, $_fid = f
950939
{
951940
$tempFile = tempnam($this->generatedPath.'/files/', 'rexsearch');
952941

953-
if($this->utf8)
954-
$encoding = 'UTF-8';
955-
else
956-
$encoding = 'Latin1';
942+
$encoding = 'UTF-8';
957943

958944
exec('pdftotext '.escapeshellarg($this->documentRoot.'/'.$_filename).' '.escapeshellarg($tempFile).' -enc '.$encoding, $dummy, $return);
959945
if($return > 0)
@@ -987,8 +973,6 @@ function indexFile($_filename, $_doPlaintext = false, $_clang = false, $_fid = f
987973
{
988974
require_once 'class.pdf2txt.inc.php';
989975
$text = pdf2txt::directConvert($pdfContent);
990-
if(!$this->utf8)
991-
$text = utf8_decode($text);
992976
$error = false;
993977
}
994978
}
@@ -1016,7 +1000,7 @@ function indexFile($_filename, $_doPlaintext = false, $_clang = false, $_fid = f
10161000
return A587_FILE_NOEXIST;
10171001
}
10181002

1019-
$text = @iconv(mb_detect_encoding($text), $this->utf8?'UTF-8':'ISO-8859-15', $text);
1003+
$text = @iconv(mb_detect_encoding($text), 'UTF-8', $text);
10201004

10211005
// Plaintext
10221006
if(empty($plaintext))
@@ -1053,7 +1037,7 @@ function indexFile($_filename, $_doPlaintext = false, $_clang = false, $_fid = f
10531037
$keywords = array();
10541038
foreach(preg_split($this->encodeRegex('~[[:punct:][:space:]]+~ism'), $plaintext) as $keyword)
10551039
{
1056-
if($this->significantCharacterCount <= mb_strlen($keyword,$this->utf8?'UTF-8':mb_internal_encoding()))
1040+
if($this->significantCharacterCount <= mb_strlen($keyword,'UTF-8'))
10571041
$keywords[] = array('search'=>$keyword,'clang'=>!isset($fileData['clang'])?false:$fileData['clang']);
10581042
}
10591043
$this->storeKeywords($keywords, false);
@@ -1624,7 +1608,7 @@ function getHighlightedText($_text)
16241608
{
16251609
foreach($this->searchArray as $keyword)
16261610
{
1627-
$this->searchArray[] = array('search' => htmlentities($keyword['search'], ENT_COMPAT, $this->utf8?'UTF-8':mb_internal_encoding()));
1611+
$this->searchArray[] = array('search' => htmlentities($keyword['search'], ENT_COMPAT, 'UTF-8'));
16281612
}
16291613
}
16301614

@@ -1933,8 +1917,8 @@ function storeKeywords($_keywords, $_doCount = true)
19331917
foreach($_keywords as $keyword)
19341918
{
19351919
if(
1936-
!in_array(mb_strtolower($keyword['search'], $this->utf8?'UTF-8':mb_internal_encoding()), $this->blacklist) AND
1937-
!in_array(mb_strtolower($keyword['search'], $this->utf8?'UTF-8':mb_internal_encoding()), $this->stopwords)
1920+
!in_array(mb_strtolower($keyword['search'], 'UTF-8'), $this->blacklist) AND
1921+
!in_array(mb_strtolower($keyword['search'], 'UTF-8'), $this->stopwords)
19381922
)
19391923
{
19401924
$simWords[] = sprintf(
@@ -2124,7 +2108,7 @@ function search($_search)
21242108

21252109
if($this->searchEntities)
21262110
{
2127-
$match .= ' + '.sprintf("(( MATCH (`%s`) AGAINST ('%s')) * %d)", implode('`,`',$searchColumns), $sql->escape(htmlentities($keyword['search'], ENT_COMPAT, $this->utf8?'UTF-8':mb_internal_encoding())), $keyword['weight']);
2111+
$match .= ' + '.sprintf("(( MATCH (`%s`) AGAINST ('%s')) * %d)", implode('`,`',$searchColumns), $sql->escape(htmlentities($keyword['search'], ENT_COMPAT, 'UTF-8')), $keyword['weight']);
21282112
}
21292113

21302114
$Amatch[] = $match;
@@ -2143,7 +2127,7 @@ function search($_search)
21432127

21442128
if($this->searchEntities)
21452129
{
2146-
$tmpWhere[] = sprintf("(`%s` LIKE '%%%s%%')", $searchColumn, str_replace(array('%','_'),array('\%','\_'),$sql->escape(htmlentities($keyword['search'], ENT_COMPAT, $this->utf8?'UTF-8':mb_internal_encoding()))));
2130+
$tmpWhere[] = sprintf("(`%s` LIKE '%%%s%%')", $searchColumn, str_replace(array('%','_'),array('\%','\_'),$sql->escape(htmlentities($keyword['search'], ENT_COMPAT, 'UTF-8'))));
21472131
}
21482132
}
21492133

lang/de_de.lang

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ a587_ellipsis =
9494

9595
a587_cat_deleted = Alle Artikel der Kategorie sind noch im Suchindex enthalten. Sie m�ssen den <a href="index.php?page=rexsearch&subpage=generate">Suchindex erneuern</a>.
9696

97-
a587_help_wiki = Die Dokumentation des Addons finden Sie unter <a href="http://wiki.redaxo.de/index.php?n=R4.RexSearch">http://wiki.redaxo.de/index.php?n=R4.RexSearch</a>.
98-
a587_help_forum = Sollten Sie Fragen oder Probleme haben, k�nnen Sie diese im Redaxo-Forum stellen: <a href="http://forum.redaxo.de/ftopic12965">http://forum.redaxo.de/ftopic12965</a>.
97+
a587_help_wiki = Die Dokumentation des Addons finden Sie unter <a href="http://www.redaxo.org/de/wiki/index.php?n=R4.Rexsearch">http://www.redaxo.org/de/wiki/index.php?n=R4.Rexsearch</a>.
98+
a587_help_forum = Sollten Sie Fragen oder Probleme haben, k�nnen Sie diese im Redaxo-Forum stellen: <a href="http://www.redaxo.org/de/forum/addons-f30/addon-rexsearch-fulltext-search-addon-t12965.html">http://www.redaxo.org/de/forum/addons-f30/addon-rexsearch-fulltext-search-addon-t12965.html</a>.

lang/de_de_utf8.lang

-98
This file was deleted.

lang/en_gb.lang

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,5 @@ a587_ellipsis =
9494

9595
a587_cat_deleted = All articles are still included in the search index. You have to <a href="index.php?page=rexsearch&subpage=generate">regenerate the search index</a>.
9696

97-
a587_help_wiki = The documentation of this addon can be found at <a href="http://wiki.redaxo.de/index.php?n=R4.RexSearch">http://wiki.redaxo.de/index.php?n=R4.RexSearch</a>.
98-
a587_help_forum = Any questions or suggestions can be asked/made at <a href="http://forum.redaxo.de/ftopic12965">http://forum.redaxo.de/ftopic12965</a>.
97+
a587_help_wiki = The documentation of this addon can be found at <a href="http://www.redaxo.org/de/wiki/index.php?n=R4.Rexsearch">http://www.redaxo.org/de/wiki/index.php?n=R4.Rexsearch</a>.
98+
a587_help_forum = Any questions or suggestions can be asked/made at <a href="http://www.redaxo.org/de/forum/addons-f30/addon-rexsearch-fulltext-search-addon-t12965.html">http://www.redaxo.org/de/forum/addons-f30/addon-rexsearch-fulltext-search-addon-t12965.html</a>.

0 commit comments

Comments
 (0)