From adddd26d54c2334d7018e6d20d6a2c42e2afdcbb Mon Sep 17 00:00:00 2001 From: diml Date: Tue, 15 Apr 2008 21:46:55 +0000 Subject: [PATCH] finish resolution on merge --- search/add.php | 3 ++- search/documents/chat_document.php | 2 +- search/documents/data_document.php | 9 +++++++++ search/documents/forum_document.php | 8 ++++++++ search/documents/glossary_document.php | 2 +- search/documents/lesson_document.php | 9 +++++++++ search/documents/physical_pdf.php | 11 ++++++++--- search/documents/resource_document.php | 2 +- search/documents/techproject_document.php | 8 ++++++++ search/documents/wiki_document.php | 9 +++++++++ search/indexer.php | 7 ++----- search/indexersplash.php | 10 +++++----- search/query.php | 16 +++++++--------- search/stats.php | 12 ++++++++++-- search/update.php | 3 +-- 15 files changed, 81 insertions(+), 30 deletions(-) diff --git a/search/add.php b/search/add.php index 1f99bd200b..cfdb5fb255 100644 --- a/search/add.php +++ b/search/add.php @@ -54,6 +54,7 @@ require_once("$CFG->dirroot/search/lib.php"); mtrace('Index size before: '.$CFG->search_index_size."\n"); /// get all modules + if ($mods = get_records_select('modules')) { /// append virtual modules onto array @@ -155,4 +156,4 @@ require_once("$CFG->dirroot/search/lib.php"); mtrace("Added $addition_count documents."); mtrace('Index size after: '.$index->count()); -?> \ No newline at end of file +?> diff --git a/search/documents/chat_document.php b/search/documents/chat_document.php index 4361d32d73..acc4ffb479 100644 --- a/search/documents/chat_document.php +++ b/search/documents/chat_document.php @@ -296,6 +296,6 @@ function chat_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c function chat_link_post_processing($title){ setLocale(LC_TIME, substr(current_language(), 0, 2)); $title = preg_replace('/TT_(.*)_TT/e', "userdate(\\1)", $title); - return $title; + return mb_convert_encoding($title, 'UTF-8', 'auto'); } ?> \ No newline at end of file diff --git a/search/documents/data_document.php b/search/documents/data_document.php index aaeeea3928..4b301ffaa8 100644 --- a/search/documents/data_document.php +++ b/search/documents/data_document.php @@ -399,4 +399,13 @@ function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c return true; } + +/** +* post processes the url for cleaner output. +* @param string $title +*/ +function data_link_post_processing($title){ + return mb_convert_encoding($title, 'UTF-8', 'auto'); +} + ?> \ No newline at end of file diff --git a/search/documents/forum_document.php b/search/documents/forum_document.php index ae3b3b2190..3cbe2e108a 100644 --- a/search/documents/forum_document.php +++ b/search/documents/forum_document.php @@ -297,4 +297,12 @@ function forum_check_text_access($path, $itemtype, $this_id, $user, $group_id, $ return true; } +/** +* post processes the url for cleaner output. +* @param string $title +*/ +function forum_link_post_processing($title){ + return mb_convert_encoding($title, 'UTF-8', 'auto'); +} + ?> \ No newline at end of file diff --git a/search/documents/glossary_document.php b/search/documents/glossary_document.php index 8d48e112b2..2ec59ef8fd 100644 --- a/search/documents/glossary_document.php +++ b/search/documents/glossary_document.php @@ -251,7 +251,7 @@ function glossary_check_text_access($path, $itemtype, $this_id, $user, $group_id * @param string $title */ function glossary_link_post_processing($title){ - return mb_convert_encoding($title, 'auto', 'UTF-8'); + return mb_convert_encoding($title, 'UTF-8', 'auto'); } ?> \ No newline at end of file diff --git a/search/documents/lesson_document.php b/search/documents/lesson_document.php index 42615b8927..674dc0b63c 100644 --- a/search/documents/lesson_document.php +++ b/search/documents/lesson_document.php @@ -204,4 +204,13 @@ function lesson_check_text_access($path, $itemtype, $this_id, $user, $group_id, return true; } + +/** +* this call back is called when displaying the link for some last post processing +* +*/ +function lesson_link_post_processing($title){ + return mb_convert_encoding($title, 'UTF-8', 'auto'); +} + ?> \ No newline at end of file diff --git a/search/documents/physical_pdf.php b/search/documents/physical_pdf.php index 703f68bf1e..291e0f4a05 100644 --- a/search/documents/physical_pdf.php +++ b/search/documents/physical_pdf.php @@ -22,14 +22,19 @@ function get_text_for_indexing_pdf(&$resource){ // SECURITY : do not allow non admin execute anything on system !! if (!isadmin($USER->id)) return; + + // adds moodle root switch if none was defined + if (!isset($CFG->block_search_usemoodleroot)){ + set_config('block_search_usemoodleroot', 1); + } - $moodleroot = (@$CFG->block_search_usemoodleroot) ? "{$CFG->dirroot}/" : '' ; + $moodleroot = ($CFG->block_search_usemoodleroot) ? "{$CFG->dirroot}/" : '' ; // just call pdftotext over stdout and capture the output if (!empty($CFG->block_search_pdf_to_text_cmd)){ preg_match("/^\S+/", $CFG->block_search_pdf_to_text_cmd, $matches); if (!file_exists("{$moodleroot}{$matches[0]}")){ - mtrace('Error with pdf to text converter command : exectuable not found.'); + mtrace('Error with pdf to text converter command : exectuable not found at '.$moodleroot.$matches[0]); } else{ $file = escapeshellarg($CFG->dataroot.'/'.$resource->course.'/'.$resource->reference); @@ -40,7 +45,7 @@ function get_text_for_indexing_pdf(&$resource){ return $result; } else{ - mtrace('Error with pdf to text converter command : execution failed.'); + mtrace('Error with pdf to text converter command : execution failed for '.$text_converter_cmd.'. Check for execution permission on pdf converter executable.'); return ''; } } diff --git a/search/documents/resource_document.php b/search/documents/resource_document.php index 0e60706b2b..844da54bc7 100644 --- a/search/documents/resource_document.php +++ b/search/documents/resource_document.php @@ -323,6 +323,6 @@ function resource_check_text_access($path, $itemtype, $this_id, $user, $group_id * @param string $title */ function resource_link_post_processing($title){ - return mb_convert_encoding($title, 'auto', 'UTF-8'); + return mb_convert_encoding($title, 'UTF-8', 'auto'); } ?> \ No newline at end of file diff --git a/search/documents/techproject_document.php b/search/documents/techproject_document.php index 52976d1928..53f5a4a81a 100644 --- a/search/documents/techproject_document.php +++ b/search/documents/techproject_document.php @@ -290,4 +290,12 @@ function techproject_check_text_access($path, $entry_type, $this_id, $user, $gro return true; } //techproject_check_text_access +/** +* this call back is called when displaying the link for some last post processing +* +*/ +function techproject_link_post_processing($title){ + return mb_convert_encoding($title, 'UTF-8', 'auto'); +} + ?> \ No newline at end of file diff --git a/search/documents/wiki_document.php b/search/documents/wiki_document.php index 23ed2f8a36..d23ca9e8a4 100644 --- a/search/documents/wiki_document.php +++ b/search/documents/wiki_document.php @@ -262,4 +262,13 @@ function wiki_check_text_access($path, $itemtype, $this_id, $user, $group_id, $c return true; } + +/** +* this call back is called when displaying the link for some last post processing +* +*/ +function wiki_link_post_processing($title){ + return mb_convert_encoding($title, 'UTF-8', 'auto'); +} + ?> \ No newline at end of file diff --git a/search/indexer.php b/search/indexer.php index 379af25fdc..a7396aefd3 100644 --- a/search/indexer.php +++ b/search/indexer.php @@ -62,7 +62,6 @@ require_once("$CFG->dirroot/search/lib.php"); /// check for php5 (lib.php) if (!search_check_php5()) { - $phpversion = phpversion(); mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")"); exit(0); } @@ -94,12 +93,10 @@ require_once("$CFG->dirroot/search/lib.php"); mtrace("Data directory ($index_path) does not exist, attempting to create."); if (!mkdir($index_path)) { search_pexit("Error creating data directory at: $index_path. Please correct."); - } - else { + } else { mtrace("Directory successfully created."); } - } - else { + } else { mtrace("Using $index_path as data directory."); } diff --git a/search/indexersplash.php b/search/indexersplash.php index 7198d58edd..8efdab6140 100644 --- a/search/indexersplash.php +++ b/search/indexersplash.php @@ -25,17 +25,16 @@ require_once("$CFG->dirroot/search/lib.php"); require_login(); if (empty($CFG->enableglobalsearch)) { - print_error('globalsearchdisabled', 'search'); + error(get_string('globalsearchdisabled', 'search')); } if (!isadmin()) { - print_error('beadmin', 'search', "$CFG->wwwroot/login/index.php"); + error(get_string('beadmin', 'search'), "$CFG->wwwroot/login/index.php"); } /// check for php5 (lib.php) if (!search_check_php5()) { - $phpversion = phpversion(); mtrace("Sorry, global search requires PHP 5.0.0 or later (currently using version ".phpversion().")"); exit(0); } @@ -50,7 +49,8 @@ require_once("$CFG->dirroot/search/lib.php"); $navlinks[] = array('name' => $strsearch, 'link' => "index.php", 'type' => 'misc'); $navlinks[] = array('name' => $strquery, 'link' => "stats.php", 'type' => 'misc'); $navlinks[] = array('name' => get_string('runindexer','search'), 'link' => null, 'type' => 'misc'); - if ($CFG->version <= 2007021541){ // 1.8 branch stable timestamp + // if ($CFG->version <= 2007021541){ // 1.8 branch stable timestamp NOT RELIABLE + if (!function_exists('build_navigation')){ // 1.8 branch stable timestamp $navigation = ''; } else { $navigation = build_navigation($navlinks); @@ -77,4 +77,4 @@ require_once("$CFG->dirroot/search/lib.php"); else { header('Location: indexer.php?areyousure=yes'); } -?> +?> \ No newline at end of file diff --git a/search/query.php b/search/query.php index 47b4e78f04..cd62c2cbef 100644 --- a/search/query.php +++ b/search/query.php @@ -43,7 +43,7 @@ } if (empty($CFG->enableglobalsearch)) { - print_error('globalsearchdisabled', 'search'); + error(get_string('globalsearchdisabled', 'search')); } $adv = new Object(); @@ -61,8 +61,7 @@ if ($pages && isset($_SESSION['search_advanced_query'])) { // if both are set, then we are busy browsing through the result pages of an advanced query $adv = unserialize($_SESSION['search_advanced_query']); - } - else if ($advanced) { + } else if ($advanced) { // otherwise we are dealing with a new advanced query unset($_SESSION['search_advanced_query']); session_unregister('search_advanced_query'); @@ -144,7 +143,8 @@ $strsearch = get_string('search', 'search'); $strquery = get_string('enteryoursearchquery', 'search'); - if ($CFG->version < 2007032200){ +// if ($CFG->version < 2007032200){ NOT RELIABLE + if (!function_exists('build_navigation')){ print_header("$site->shortname: $strsearch: $strquery", "$site->fullname", "$strsearch -> $strquery"); } else { @@ -187,8 +187,7 @@ | @@ -277,8 +276,7 @@ if ($sq->is_valid_index()) { //use cached variable to show up-to-date index size (takes deletions into account) print $CFG->search_index_size; - } - else { + } else { print "0"; } @@ -358,4 +356,4 @@ } print_box_end(); print_footer(); -?> +?> \ No newline at end of file diff --git a/search/stats.php b/search/stats.php index 9e64c04cb6..8412241ef2 100644 --- a/search/stats.php +++ b/search/stats.php @@ -45,8 +45,16 @@ require_once("{$CFG->dirroot}/search/lib.php"); $strsearch = get_string('search', 'search'); $strquery = get_string('statistics', 'search'); - print_header("$site->shortname: $strsearch: $strquery", "$site->fullname", - "$strsearch -> $strquery"); + if (!function_exists('build_navigation')){ + print_header("$site->shortname: $strsearch: $strquery", "$site->fullname", + "$strsearch -> $strquery"); + } else { + $navlinks[] = array('name' => $strsearch, 'link' => "index.php", 'type' => 'misc'); + $navlinks[] = array('name' => $strquery, 'link' => null, 'type' => 'misc'); + $navigation = build_navigation($navlinks); + $site = get_site(); + print_header("$strsearch", "$site->fullname" , $navigation, "", "", true, " ", navmenu($site)); + } /// keep things pretty, even if php5 isn't available diff --git a/search/update.php b/search/update.php index 610735dcc6..c83e2f8595 100644 --- a/search/update.php +++ b/search/update.php @@ -134,8 +134,7 @@ require_once("$CFG->dirroot/search/lib.php"); mtrace(" Add: $add->title (database id = $add->dbid, moodle instance id = $add->docid)"); $index->addDocument($add); } - } - else{ + } else { mtrace("No types to update.\n"); } mtrace("Finished $mod->name.\n"); -- 2.39.5