check if index and indexconf is set

This commit is contained in:
Uwe Steinmann 2020-03-24 06:46:22 +01:00
parent 072d203379
commit bab648b988
2 changed files with 23 additions and 19 deletions

View File

@ -40,30 +40,31 @@ if(!$settings->_enableFullSearch) {
UI::exitError(getMLText("admin_tools"),getMLText("fulltextsearch_disabled")); UI::exitError(getMLText("admin_tools"),getMLText("fulltextsearch_disabled"));
} }
$index = null;
if(!isset($_GET['action']) || $_GET['action'] == 'show') { if(!isset($_GET['action']) || $_GET['action'] == 'show') {
if(isset($_GET['create']) && $_GET['create'] == 1) { if($indexconf) {
if(isset($_GET['confirm']) && $_GET['confirm'] == 1) { if(isset($_GET['create']) && $_GET['create'] == 1) {
$index = $indexconf['Indexer']::create($settings->_luceneDir); if(isset($_GET['confirm']) && $_GET['confirm'] == 1) {
$index = $indexconf['Indexer']::create($settings->_luceneDir);
if(!$index) {
UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex"));
}
$indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
header('Location: out.CreateIndex.php');
exit;
}
} else {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if(!$index) { if(!$index) {
UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex")); $index = $indexconf['Indexer']::create($settings->_luceneDir);
if(!$index) {
UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex"));
}
} }
$indexconf['Indexer']::init($settings->_stopWordsFile); $indexconf['Indexer']::init($settings->_stopWordsFile);
} else {
header('Location: out.CreateIndex.php');
exit;
} }
} else {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if(!$index) {
$index = $indexconf['Indexer']::create($settings->_luceneDir);
if(!$index) {
UI::exitError(getMLText("admin_tools"),getMLText("no_fulltextindex"));
}
}
$indexconf['Indexer']::init($settings->_stopWordsFile);
} }
} else {
$index = null;
} }
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) { if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {

View File

@ -201,6 +201,7 @@ $(document).ready( function() {
$this->contentStart(); $this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools"); $this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("update_fulltext_index")); $this->contentHeading(getMLText("update_fulltext_index"));
if($index) {
?> ?>
<style type="text/css"> <style type="text/css">
li {line-height: 20px;} li {line-height: 20px;}
@ -230,7 +231,9 @@ li {line-height: 20px;}
$index->commit(); $index->commit();
$index->optimize(); $index->optimize();
} else {
$this->warningMsg(getMLText('fulltextsearch_disabled'));
}
$this->contentEnd(); $this->contentEnd();
$this->htmlEndPage(); $this->htmlEndPage();
} /* }}} */ } /* }}} */