mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
global search review and extension for physical files
This commit is contained in:
parent
cf0b12ac83
commit
2f338ab5b0
28 changed files with 3903 additions and 1485 deletions
203
search/stats.php
203
search/stats.php
|
@ -1,51 +1,75 @@
|
|||
<?php
|
||||
/* Prints some basic statistics about the current index.
|
||||
*
|
||||
* Does some diagnostics if you are logged in as an administrator.
|
||||
* */
|
||||
/**
|
||||
* Global Search Engine for Moodle
|
||||
* Michael Champanis (mchampan) [cynnical@gmail.com]
|
||||
* review 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
|
||||
* 2007/08/02
|
||||
*
|
||||
* Prints some basic statistics about the current index.
|
||||
* Does some diagnostics if you are logged in as an administrator.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("$CFG->dirroot/search/lib.php");
|
||||
require_once('../config.php');
|
||||
require_once("{$CFG->dirroot}/search/lib.php");
|
||||
|
||||
if ($CFG->forcelogin) {
|
||||
if ($CFG->forcelogin) {
|
||||
require_login();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($CFG->enableglobalsearch)) {
|
||||
error('Global searching is not enabled.');
|
||||
}
|
||||
|
||||
//check for php5, but don't die yet
|
||||
if ($check = search_check_php5()) {
|
||||
require_once("$CFG->dirroot/search/indexlib.php");
|
||||
if (empty($CFG->enableglobalsearch)) {
|
||||
error(get_string('globalsearchdisabled', 'search'));
|
||||
}
|
||||
|
||||
//check for php5, but don't die yet
|
||||
if ($check = search_check_php5()) {
|
||||
require_once("{$CFG->dirroot}/search/indexlib.php");
|
||||
|
||||
$indexinfo = new IndexInfo();
|
||||
} //if
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
} //if
|
||||
}
|
||||
|
||||
$strsearch = "Search"; //get_string();
|
||||
$strquery = "Search statistics"; //get_string();
|
||||
$strsearch = get_string('search', 'search');
|
||||
$strquery = get_string('statistics', 'search');
|
||||
|
||||
print_header("$site->shortname: $strsearch: $strquery", "$site->fullname",
|
||||
"<a href=\"index.php\">$strsearch</a> -> $strquery");
|
||||
print_header("$site->shortname: $strsearch: $strquery", "$site->fullname",
|
||||
"<a href=\"index.php\">$strsearch</a> -> $strquery");
|
||||
|
||||
//keep things pretty, even if php5 isn't available
|
||||
if (!$check) {
|
||||
//keep things pretty, even if php5 isn't available
|
||||
if (!$check) {
|
||||
print_heading(search_check_php5(true));
|
||||
print_footer();
|
||||
exit(0);
|
||||
} //if
|
||||
}
|
||||
|
||||
print_simple_box_start('center', '100%', '', 20);
|
||||
print_heading($strquery);
|
||||
print_box_start();
|
||||
print_heading($strquery);
|
||||
|
||||
print_simple_box_start('center', '', '', 20);
|
||||
print_box_start();
|
||||
|
||||
//this table is only for admins, shows index directory size and location
|
||||
if (isadmin()) {
|
||||
$databasestr = get_string('database', 'search');
|
||||
$documentsinindexstr = get_string('documentsinindex', 'search');
|
||||
$deletionsinindexstr = get_string('deletionsinindex', 'search');
|
||||
$documentsindatabasestr = get_string('documentsindatabase', 'search');
|
||||
$databasestatestr = get_string('databasestate', 'search');
|
||||
|
||||
//this table is only for admins, shows index directory size and location
|
||||
if (isadmin()) {
|
||||
$datadirectorystr = get_string('datadirectory', 'search');
|
||||
$inindexdirectorystr = get_string('filesinindexdirectory', 'search');
|
||||
$totalsizestr = get_string('totalsize', 'search');
|
||||
$errorsstr = get_string('errors', 'search');
|
||||
$solutionsstr = get_string('solutions', 'search');
|
||||
$checkdirstr = get_string('checkdir', 'search');
|
||||
$checkdbstr = get_string('checkdb', 'search');
|
||||
$checkdiradvicestr = get_string('checkdiradvice', 'search');
|
||||
$checkdbadvicestr = get_string('checkdbadvice', 'search');
|
||||
$runindexerteststr = get_string('runindexertest', 'search');
|
||||
$runindexerstr = get_string('runindexer', 'search');
|
||||
|
||||
$admin_table->tablealign = "center";
|
||||
$admin_table->align = array ("right", "left");
|
||||
$admin_table->wrap = array ("nowrap", "nowrap");
|
||||
|
@ -53,72 +77,73 @@
|
|||
$admin_table->cellspacing = 0;
|
||||
$admin_table->width = '500';
|
||||
|
||||
$admin_table->data[] = array('<strong>Data directory</strong>', '<em><strong>'.$indexinfo->path.'</strong></em>');
|
||||
$admin_table->data[] = array('Files in index directory', $indexinfo->filecount);
|
||||
$admin_table->data[] = array('Total size', $indexinfo->size);
|
||||
$admin_table->data[] = array("<strong>{$datadirectorystr}</strong>", '<em><strong>'.$indexinfo->path.'</strong></em>');
|
||||
$admin_table->data[] = array($inindexdirectorystr, $indexinfo->filecount);
|
||||
$admin_table->data[] = array($totalsizestr, $indexinfo->size);
|
||||
|
||||
if ($indexinfo->time > 0) {
|
||||
$admin_table->data[] = array('Created on', date('r', $indexinfo->time));
|
||||
} else {
|
||||
$admin_table->data[] = array('Created on', '-');
|
||||
} //else
|
||||
$admin_table->data[] = array(get_string('createdon', 'search'), date('r', $indexinfo->time));
|
||||
}
|
||||
else {
|
||||
$admin_table->data[] = array(get_string('createdon', 'search'), '-');
|
||||
}
|
||||
|
||||
if (!$indexinfo->valid($errors)) {
|
||||
$admin_table->data[] = array('<strong>Errors</strong>', ' ');
|
||||
$admin_table->data[] = array("<strong>{$errorsstr}</strong>", ' ');
|
||||
foreach ($errors as $key => $value) {
|
||||
$admin_table->data[] = array($key.' ... ', $value);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($errors as $key=>$value) {
|
||||
$admin_table->data[] = array($key.' ... ', $value);
|
||||
} //foreach
|
||||
|
||||
$admin_table->data[] = array('<strong>Solutions</strong>', ' ');
|
||||
|
||||
if (isset($errors['dir'])) {
|
||||
$admin_table->data[] = array('Check dir', 'Ensure the data directory exists and is writable.');
|
||||
} //if
|
||||
|
||||
if (isset($errors['db'])) {
|
||||
$admin_table->data[] = array('Check DB', 'Check your database for any problems.');
|
||||
} //if
|
||||
|
||||
$admin_table->data[] = array('Run indexer test', '<a href=\'tests/index.php\'>tests/index.php</a>');
|
||||
$admin_table->data[] = array('Run indexer', '<a href=\'indexersplash.php\'>indexersplash.php</a>');
|
||||
} //if
|
||||
} //if
|
||||
|
||||
//this is the standard summary table for normal users, shows document counts
|
||||
$table->tablealign = "center";
|
||||
$table->align = array ("right", "left");
|
||||
$table->wrap = array ("nowrap", "nowrap");
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '500';
|
||||
|
||||
$table->data[] = array('<strong>Database</strong>', '<em><strong>search_documents<strong></em>');
|
||||
|
||||
//add extra fields if we're admin
|
||||
if (isadmin()) {
|
||||
//don't want to confuse users if the two totals don't match (hint: they should)
|
||||
$table->data[] = array('Documents in index', $indexinfo->indexcount);
|
||||
|
||||
//*cough* they should match if deletions were actually removed from the index,
|
||||
//as it turns out, they're only marked as deleted and not returned in search results
|
||||
$table->data[] = array('Deletions in index', (int)$indexinfo->indexcount - (int)$indexinfo->dbcount);
|
||||
} //if
|
||||
|
||||
$table->data[] = array('Documents in database', $indexinfo->dbcount);
|
||||
|
||||
foreach($indexinfo->types as $key => $value) {
|
||||
$table->data[] = array("'$key' documents", $value);
|
||||
} //foreach
|
||||
|
||||
if (isadmin()) {
|
||||
print_table($admin_table);
|
||||
print_spacer(20);
|
||||
} //if
|
||||
print_heading($solutionsstr);
|
||||
|
||||
unset($admin_table->data);
|
||||
if (isset($errors['dir'])) {
|
||||
$admin_table->data[] = array($checkdirstr, $checkdiradvicestr);
|
||||
}
|
||||
if (isset($errors['db'])) {
|
||||
$admin_table->data[] = array($checkdbstr, $checkdbadvicestr);
|
||||
}
|
||||
|
||||
$admin_table->data[] = array($runindexerteststr, '<a href="tests/index.php" target="_blank">tests/index.php</a>');
|
||||
$admin_table->data[] = array($runindexerstr, '<a href="indexersplash.php" target="_blank">indexersplash.php</a>');
|
||||
|
||||
print_table($admin_table);
|
||||
print_spacer(20);
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
//this is the standard summary table for normal users, shows document counts
|
||||
$table->tablealign = "center";
|
||||
$table->align = array ("right", "left");
|
||||
$table->wrap = array ("nowrap", "nowrap");
|
||||
$table->cellpadding = 5;
|
||||
$table->cellspacing = 0;
|
||||
$table->width = '500';
|
||||
|
||||
print_simple_box_end();
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
$table->data[] = array("<strong>{$databasestr}</strong>", "<em><strong>{$CFG->prefix}search_documents</strong></em>");
|
||||
|
||||
//add extra fields if we're admin
|
||||
if (isadmin()) {
|
||||
//don't want to confuse users if the two totals don't match (hint: they should)
|
||||
$table->data[] = array($documentsinindexstr, $indexinfo->indexcount);
|
||||
|
||||
//*cough* they should match if deletions were actually removed from the index,
|
||||
//as it turns out, they're only marked as deleted and not returned in search results
|
||||
$table->data[] = array($deletionsinindexstr, (int)$indexinfo->indexcount - (int)$indexinfo->dbcount);
|
||||
}
|
||||
|
||||
$table->data[] = array($documentsindatabasestr, $indexinfo->dbcount);
|
||||
|
||||
foreach($indexinfo->types as $key => $value) {
|
||||
$table->data[] = array(get_string('documentsfor', 'search') . " '".get_string('modulenameplural', $key)."'", $value);
|
||||
}
|
||||
|
||||
print_heading($databasestatestr);
|
||||
print_table($table);
|
||||
|
||||
print_box_end();
|
||||
print_box_end();
|
||||
print_footer();
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue