mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-12234, fixing unicode issues with global search
This commit is contained in:
parent
705b5874ce
commit
001f36522c
@ -51,7 +51,7 @@ $string['tofetchtheseresults'] = 'to fetch these results';
|
||||
$string['totalsize'] = 'Total Size ';
|
||||
$string['type'] = 'Type';
|
||||
$string['uncompleteindexingerror'] = 'Indexing was not successfully completed, please restart it.';
|
||||
$string['versiontoolow'] = 'Sorry, global search requires PHP 5.0.0 or later (currently using version '.$phpversion.')';
|
||||
$string['versiontoolow'] = 'Sorry, global search requires PHP 5.0.0 or later';
|
||||
$string['whichmodulestosearch?'] = 'Which modules to search?';
|
||||
$string['wordsintitle'] = 'Words in title';
|
||||
?>
|
||||
|
@ -97,10 +97,9 @@ abstract class Zend_Search_Lucene_Analysis_Analyzer
|
||||
* @param string $data
|
||||
* @return array
|
||||
*/
|
||||
public function tokenize($data, $encoding = '')
|
||||
public function tokenize($data, $encoding = 'UTF-8')
|
||||
{
|
||||
$this->setInput($data, $encoding);
|
||||
|
||||
$tokenList = array();
|
||||
while (($nextToken = $this->nextToken()) !== null) {
|
||||
$tokenList[] = $nextToken;
|
||||
@ -161,7 +160,7 @@ abstract class Zend_Search_Lucene_Analysis_Analyzer
|
||||
public static function getDefault()
|
||||
{
|
||||
if (!self::$_defaultImpl instanceof Zend_Search_Lucene_Analysis_Analyzer) {
|
||||
self::$_defaultImpl = new Zend_Search_Lucene_Analysis_Analyzer_Common_Text_CaseInsensitive();
|
||||
self::$_defaultImpl = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8();
|
||||
}
|
||||
|
||||
return self::$_defaultImpl;
|
||||
|
@ -40,7 +40,7 @@ $startindextime = time();
|
||||
|
||||
$indexdate = $CFG->search_indexer_run_date;
|
||||
|
||||
mtrace('<pre>Starting index update (additions)...');
|
||||
mtrace('Starting index update (additions)...');
|
||||
mtrace('Index size before: '.$CFG->search_index_size."\n");
|
||||
|
||||
//get all modules
|
||||
@ -139,6 +139,6 @@ set_config("search_index_size", (int)$CFG->search_index_size + (int)$addition_co
|
||||
|
||||
// print some additional info
|
||||
mtrace("Added $addition_count documents.");
|
||||
mtrace('Index size after: '.$index->count().'</pre>');
|
||||
mtrace('Index size after: '.$index->count());
|
||||
|
||||
?>
|
@ -11,15 +11,15 @@ try{
|
||||
$maxmemoryamount = ini_get('memory_limit');
|
||||
ini_set('memory_limit', '48M');
|
||||
|
||||
mtrace("<pre>Starting cron...\n");
|
||||
mtrace("--DELETE----");
|
||||
mtrace("\n--DELETE----");
|
||||
require_once("$CFG->dirroot/search/delete.php");
|
||||
mtrace("--UPDATE----");
|
||||
require_once("$CFG->dirroot/search/update.php");
|
||||
mtrace("--ADD-------");
|
||||
require_once("$CFG->dirroot/search/add.php");
|
||||
mtrace("------------");
|
||||
mtrace("cron finished.</pre>");
|
||||
//mtrace("cron finished.</pre>");
|
||||
mtrace('done');
|
||||
|
||||
// set back normal values for php limits
|
||||
ini_set('max_execution_time', $maxtimelimit);
|
||||
|
@ -38,7 +38,7 @@ $dbcontrol = new IndexDBControl();
|
||||
$deletion_count = 0;
|
||||
$startcleantime = time();
|
||||
|
||||
mtrace('<pre>Starting clean-up of removed records...');
|
||||
mtrace('Starting clean-up of removed records...');
|
||||
mtrace('Index size before: '.$CFG->search_index_size."\n");
|
||||
|
||||
if ($mods = get_records_select('modules')) {
|
||||
@ -127,6 +127,6 @@ set_config("search_indexer_cleanup_date", $startcleantime);
|
||||
set_config("search_index_size", (int)$CFG->search_index_size - (int)$deletion_count);
|
||||
|
||||
mtrace("Finished $deletion_count removals.");
|
||||
mtrace('Index size after: '.$index->count().'</pre>');
|
||||
mtrace('Index size after: '.$index->count());
|
||||
|
||||
?>
|
@ -64,7 +64,7 @@ require_once("$CFG->dirroot/search/indexlib.php");
|
||||
mtrace('<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /></head><body>');
|
||||
mtrace('<pre>Server Time: '.date('r',time())."\n");
|
||||
|
||||
if ($CFG->search_indexer_busy == '1') {
|
||||
if (isset($CFG->search_indexer_busy) && $CFG->search_indexer_busy == '1') {
|
||||
//means indexing was not finished previously
|
||||
mtrace("Warning: Indexing was not successfully completed last time, restarting.\n");
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ class IndexInfo {
|
||||
}
|
||||
|
||||
//check if the busy flag is set
|
||||
if ($CFG->search_indexer_busy == '1') {
|
||||
if (isset($CFG->search_indexer_busy) && $CFG->search_indexer_busy == '1') {
|
||||
$this->complete = false;
|
||||
}
|
||||
else {
|
||||
|
@ -132,11 +132,14 @@ if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
$strsearch = get_string('search', 'search');
|
||||
$strsearch = get_string('search', 'search');
|
||||
$strquery = get_string('enteryoursearchquery', 'search');
|
||||
|
||||
print_header("$site->shortname: $strsearch: $strquery", "$site->fullname",
|
||||
"<a href=\"index.php\">$strsearch</a> -> $strquery");
|
||||
$navlinks[] = array('name' => $strsearch, 'link' => "index.php", 'type' => 'misc');
|
||||
$navlinks[] = array('name' => $strquery, 'link' => null, 'type' => 'misc');
|
||||
$navigation = build_navigation($navlinks);
|
||||
$course = get_site();
|
||||
print_header("$strsearch", "$strsearch" , $navigation, "", "", true, " ", navmenu($course));
|
||||
|
||||
//keep things pretty, even if php5 isn't available
|
||||
if (!$check) {
|
||||
@ -154,7 +157,9 @@ $vars = get_object_vars($adv);
|
||||
|
||||
if (isset($vars)) {
|
||||
foreach ($vars as $key => $value) {
|
||||
$adv->$key = stripslashes(htmlentities($value));
|
||||
// htmlentities breaks non-ascii chars
|
||||
$adv->key = stripslashes($value);
|
||||
//$adv->$key = stripslashes(htmlentities($value));
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -305,11 +310,15 @@ if ($sq->is_valid()) {
|
||||
$scorestr = get_string('score', 'search');
|
||||
$authorstr = get_string('author', 'search');
|
||||
foreach ($hits as $listing) {
|
||||
if ($CFG->unicodedb) $listing->title = mb_convert_encoding($listing->title, 'auto', 'UTF8');
|
||||
//if ($CFG->unicodedb) {
|
||||
//$listing->title = mb_convert_encoding($listing->title, 'auto', 'UTF8');
|
||||
//}
|
||||
$title_post_processing_function = $listing->doctype.'_link_post_processing';
|
||||
require_once "{$CFG->dirroot}/search/documents/{$listing->doctype}_document.php";
|
||||
if (function_exists($title_post_processing_function))
|
||||
if (function_exists($title_post_processing_function)) {
|
||||
$listing->title = $title_post_processing_function($listing->title);
|
||||
}
|
||||
|
||||
print "<li value='".($listing->number+1)."'><a href='".str_replace('DEFAULT_POPUP_SETTINGS', DEFAULT_POPUP_SETTINGS ,$listing->url)."'>$listing->title</a><br />\n"
|
||||
."<em>".search_shorten_url($listing->url, 70)."</em><br />\n"
|
||||
."{$typestr}: ".$listing->doctype.", {$scorestr}: ".round($listing->score, 3).", {$authorstr}: ".$listing->author."\n"
|
||||
|
@ -39,7 +39,7 @@ $update_count = 0;
|
||||
$indexdate = $CFG->search_indexer_update_date;
|
||||
$startupdatedate = time();
|
||||
|
||||
mtrace("<pre>Starting index update (updates)...\n");
|
||||
mtrace("Starting index update (updates)...\n");
|
||||
|
||||
if ($mods = get_records_select('modules')) {
|
||||
$mods = array_merge($mods, search_get_additional_modules());
|
||||
@ -138,6 +138,6 @@ $index->commit();
|
||||
//update index date
|
||||
set_config("search_indexer_update_date", $startupdatedate);
|
||||
|
||||
mtrace("Finished $update_count updates.</pre>");
|
||||
mtrace("Finished $update_count updates");
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user