mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
add coloured output, do not include Log.php, use PHP_EOL
This commit is contained in:
parent
932cfab13e
commit
3d754a376b
|
@ -4,20 +4,19 @@ if(isset($_SERVER['SEEDDMS_HOME'])) {
|
||||||
} else {
|
} else {
|
||||||
require_once("../inc/inc.ClassSettings.php");
|
require_once("../inc/inc.ClassSettings.php");
|
||||||
}
|
}
|
||||||
require("Log.php");
|
|
||||||
|
|
||||||
function usage() { /* {{{ */
|
function usage() { /* {{{ */
|
||||||
echo "Usage:\n";
|
echo "Usage:".PHP_EOL;
|
||||||
echo " seeddms-indexer [-h] [-v] [--config <file>]\n";
|
echo " seeddms-indexer [-h] [-v] [--config <file>]".PHP_EOL;
|
||||||
echo "\n";
|
echo "".PHP_EOL;
|
||||||
echo "Description:\n";
|
echo "Description:".PHP_EOL;
|
||||||
echo " This program recreates the full text index of SeedDMS.\n";
|
echo " This program recreates the full text index of SeedDMS.".PHP_EOL;
|
||||||
echo "\n";
|
echo "".PHP_EOL;
|
||||||
echo "Options:\n";
|
echo "Options:".PHP_EOL;
|
||||||
echo " -h, --help: print usage information and exit.\n";
|
echo " -h, --help: print usage information and exit.".PHP_EOL;
|
||||||
echo " -v, --version: print version and exit.\n";
|
echo " -v, --version: print version and exit.".PHP_EOL;
|
||||||
echo " -c: recreate index.\n";
|
echo " -c: recreate index.".PHP_EOL;
|
||||||
echo " --config: set alternative config file.\n";
|
echo " --config: set alternative config file.".PHP_EOL;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
$version = "0.0.2";
|
$version = "0.0.2";
|
||||||
|
@ -36,7 +35,7 @@ if(isset($options['h']) || isset($options['help'])) {
|
||||||
|
|
||||||
/* Print version and exit */
|
/* Print version and exit */
|
||||||
if(isset($options['v']) || isset($options['verѕion'])) {
|
if(isset($options['v']) || isset($options['verѕion'])) {
|
||||||
echo $version."\n";
|
echo $version."".PHP_EOL;
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +59,7 @@ if(isset($settings->_extraPath))
|
||||||
require_once("inc/inc.Init.php");
|
require_once("inc/inc.Init.php");
|
||||||
require_once("inc/inc.Extension.php");
|
require_once("inc/inc.Extension.php");
|
||||||
require_once("inc/inc.DBInit.php");
|
require_once("inc/inc.DBInit.php");
|
||||||
|
require "vendor/autoload.php";
|
||||||
|
|
||||||
if($settings->_fullSearchEngine == 'sqlitefts') {
|
if($settings->_fullSearchEngine == 'sqlitefts') {
|
||||||
$indexconf = array(
|
$indexconf = array(
|
||||||
|
@ -80,8 +80,8 @@ if($settings->_fullSearchEngine == 'sqlitefts') {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
||||||
global $settings;
|
global $settings, $themes;
|
||||||
echo $indent."D ".$folder->getName()."\n";
|
echo $themes->black($indent."D ".$folder->getName()).PHP_EOL;
|
||||||
$subfolders = $folder->getSubFolders();
|
$subfolders = $folder->getSubFolders();
|
||||||
foreach($subfolders as $subfolder) {
|
foreach($subfolders as $subfolder) {
|
||||||
tree($dms, $index, $indexconf, $subfolder, $indent.' ');
|
tree($dms, $index, $indexconf, $subfolder, $indent.' ');
|
||||||
|
@ -101,9 +101,9 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$index->addDocument($idoc);
|
$index->addDocument($idoc);
|
||||||
echo " (Document added)\n";
|
echo $themes->green(" (Document added)").PHP_EOL;
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
echo " (Timeout)\n";
|
echo $themes->error(" (Timeout)").PHP_EOL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -113,7 +113,7 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
||||||
}
|
}
|
||||||
$content = $document->getLatestContent();
|
$content = $document->getLatestContent();
|
||||||
if($created > $content->getDate()) {
|
if($created > $content->getDate()) {
|
||||||
echo " (Document unchanged)\n";
|
echo $themes->italic(" (Document unchanged)").PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
$index->delete($hit->id);
|
$index->delete($hit->id);
|
||||||
try {
|
try {
|
||||||
|
@ -126,21 +126,23 @@ function tree($dms, $index, $indexconf, $folder, $indent='') { /* {{{ */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$index->addDocument($idoc);
|
$index->addDocument($idoc);
|
||||||
echo " (Document updated)\n";
|
echo $themes->green(" (Document updated)").PHP_EOL;
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
echo " (Timeout)\n";
|
echo $themes->error(" (Timeout)").PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
$themes = new \AlecRabbit\ConsoleColour\Themes();
|
||||||
|
|
||||||
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
|
$db = new SeedDMS_Core_DatabaseAccess($settings->_dbDriver, $settings->_dbHostname, $settings->_dbUser, $settings->_dbPass, $settings->_dbDatabase);
|
||||||
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
|
$db->connect() or die ("Could not connect to db-server \"" . $settings->_dbHostname . "\"");
|
||||||
|
|
||||||
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
|
$dms = new SeedDMS_Core_DMS($db, $settings->_contentDir.$settings->_contentOffsetDir);
|
||||||
if(!$dms->checkVersion()) {
|
if(!$settings->_doNotCheckDBVersion && !$dms->checkVersion()) {
|
||||||
echo "Database update needed.\n";
|
echo "Database update needed.".PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +153,7 @@ if($recreate)
|
||||||
else
|
else
|
||||||
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
$index = $indexconf['Indexer']::open($settings->_luceneDir);
|
||||||
if(!$index) {
|
if(!$index) {
|
||||||
echo "Could not create index.\n";
|
echo "Could not create index.".PHP_EOL;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user