'.__('You don\'t have enough privileges to view this section').'');
}
if ($sysconf['index']['type'] == 'mongodb') {
if (!class_exists('MongoClient')) {
throw new Exception('PHP Mongodb extension library is not installed yet!');
} else {
$Mongo = new MongoClient();
// select index
$biblio = $Mongo->slims->biblio;
}
}
/* main content */
if (isset($_POST['detail']) OR (isset($_GET['action']) AND $_GET['action'] == 'detail')) {
if (!($can_read AND $can_write)) {
die('
'.__('You don\'t have enough privileges to view this section').'
');
}
/* empty table */
if ($_GET['detail'] == 'empty') {
$indexer = new biblio_indexer($dbs);
$empty = $indexer->emptyingIndex();
if ($empty) {
$message = __('Index table truncated!');
} else {
$message = __('Index table FAILED to truncated, probably because of database query error!');
}
$_SESSION['message'] = $message;
}
/* Update table */
if ($_GET['detail'] == 'update') {
set_time_limit(0);
$indexer = new biblio_indexer($dbs);
$indexer->updateFullIndex();
$finish_minutes = $indexer->indexing_time/60;
$finish_sec = $indexer->indexing_time%60;
// message
$message = sprintf(__('%d records (from total of %d) re-indexed. Finished in %d minutes %d second(s)'), $indexer->indexed, $indexer->total_records, $finish_minutes, $finish_sec);
if ($indexer->failed) {
$message = ''.sprintf(__('%d index records failed to indexed. The IDs are: %s'), count($indexer->failed), implode(', ', $indexer->failed)).'
';
}
$_SESSION['message'] = $message;
}
/* re-create index table */
if ($_GET['detail'] == 'reindex') {
set_time_limit(0);
$bib_sql = 'SELECT COUNT(*) FROM search_biblio';
$rec_bib_q = $dbs->query($bib_sql);
$rec_bib_d = $rec_bib_q->fetch_row();
if ($rec_bib_d[0] > 0) {
$message = __('Please empty the Index first before re-creating the Index');
echo ''.$message.'
'."\n";
} else {
$indexer = new biblio_indexer($dbs);
$indexer->createFullIndex(false);
$finish_minutes = $indexer->indexing_time/60;
$finish_sec = $indexer->indexing_time%60;
// message
$message = sprintf(__('%d records (from total of %d) re-indexed. Finished in %d second(s)'), $indexer->indexed, $indexer->total_records, $finish_minutes, $finish_sec);
if ($indexer->failed) {
$message = ''.sprintf(__('%d index records failed to indexed. The IDs are: %s'), count($indexer->failed), implode(', ', $indexer->failed)).'
';
}
$_SESSION['message'] = $message;
}
}
echo '';
exit();
} else {
?>
'."\n";
// Index info
$rec_bib_q = $dbs->query('SELECT COUNT(*) FROM biblio');
$rec_bib_d = $rec_bib_q->fetch_row();
$bib_total = $rec_bib_d[0];
if ($sysconf['index']['type'] == 'mongodb' && isset($biblio)) {
$idx_total = $biblio->count();
} else {
$idx_bib_q = $dbs->query('SELECT COUNT(*) FROM search_biblio');
$idx_bib_d = $idx_bib_q->fetch_row();
$idx_total = $idx_bib_d[0];
}
$unidx_total = $bib_total - $idx_total;
if (isset($_SESSION['message'])) {
echo ''.$_SESSION['message'].'
';
unset($_SESSION['message']);
}
echo 'Total data on biblio: ' . $bib_total . ' records.
';
echo 'Total indexed data: ' . $idx_total . ' records.
';
echo 'Unidexed data: ' . $unidx_total . ' records.
';
echo '';
}