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