summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGabriel Birke <Gabriel.Birke@delti.com>2007-09-12 20:27:59 +0200
committerGabriel Birke <Gabriel.Birke@delti.com>2007-09-12 20:27:59 +0200
commit981f048a597be073d01aefa348e6eecb2c52f100 (patch)
tree6ddf44ebff8fc7a4e82e74c031322e5671d1b406 /bin
parent5beb1a2c2cff9b3100da215c30d3906deda02068 (diff)
downloadrpg-981f048a597be073d01aefa348e6eecb2c52f100.tar.gz
rpg-981f048a597be073d01aefa348e6eecb2c52f100.tar.bz2
typo fix and quiet option for bin/indexer.php FS#1249
darcs-hash:20070912182759-79ce3-f882026d1635a66e493b16f56777585b01451d55.gz
Diffstat (limited to 'bin')
-rwxr-xr-xbin/indexer.php39
1 files changed, 25 insertions, 14 deletions
diff --git a/bin/indexer.php b/bin/indexer.php
index 7b4e7d197..d5f4c6446 100755
--- a/bin/indexer.php
+++ b/bin/indexer.php
@@ -16,8 +16,8 @@ session_write_close();
if(!defined('INDEXER_VERSION')) define('INDEXER_VERSION', 1);
// handle options
-$short_opts = 'hcu';
-$long_opts = array('help', 'clean', 'update');
+$short_opts = 'hcuq';
+$long_opts = array('help', 'clear', 'update', 'quiet');
$OPTS = Doku_Cli_Opts::getOptions(__FILE__,$short_opts,$long_opts);
if ( $OPTS->isError() ) {
fwrite( STDERR, $OPTS->getMessage() . "\n");
@@ -25,6 +25,7 @@ if ( $OPTS->isError() ) {
exit(1);
}
$CLEAR = false;
+$QUIET = false;
foreach ($OPTS->options as $key => $val) {
switch ($key) {
case 'h':
@@ -35,13 +36,17 @@ foreach ($OPTS->options as $key => $val) {
case 'clear':
$CLEAR = true;
break;
+ case 'q':
+ case 'quiet':
+ $QUIET = true;
+ break;
}
}
#------------------------------------------------------------------------------
# Action
-if($CLEAR) _clearindex();
+if($CLEAR) _clearindex();
_update();
@@ -50,22 +55,23 @@ _update();
function _usage() {
print "Usage: indexer.php <options>
-
+
Updates the searchindex by indexing all new or changed pages
when the -c option is given the index is cleared first.
-
+
OPTIONS
-h, --help show this help and exit
-c, --clear clear the index before updating
+ -q, --quiet don't produce any output
";
}
function _update(){
global $conf;
$data = array();
- echo "Searching pages... ";
+ _quietecho("Searching pages... ");
search($data,$conf['datadir'],'search_allpages',array());
- echo count($data)." pages found.\n";
+ _quietecho(count($data)." pages found.\n");
foreach($data as $val){
_index($val['id']);
@@ -87,10 +93,10 @@ function _index($id){
}
_lock();
- echo "$id... ";
+ _quietecho("$id... ");
idx_addPage($id);
io_saveFile(metaFN($id,'.indexed'),INDEXER_VERSION);
- echo "done.\n";
+ _quietecho("done.\n");
_unlock();
}
@@ -107,16 +113,16 @@ function _lock(){
@rmdir($lock);
}else{
if($said){
- echo ".";
+ _quietecho(".");
}else{
- echo "Waiting for lockfile (max. 5 min)";
+ _quietecho("Waiting for lockfile (max. 5 min)");
$said = true;
}
sleep(15);
}
}
if($conf['dperm']) chmod($lock, $conf['dperm']);
- if($said) print "\n";
+ if($said) _quietecho("\n");
}
/**
@@ -134,7 +140,7 @@ function _unlock(){
function _clearindex(){
global $conf;
_lock();
- echo "Clearing index... ";
+ _quietecho("Clearing index... ");
io_saveFile($conf['indexdir'].'/page.idx','');
$dir = @opendir($conf['indexdir']);
if($dir!==false){
@@ -144,8 +150,13 @@ function _clearindex(){
@unlink($conf['indexdir']."/$f");
}
}
- echo "done.\n";
+ _quietecho("done.\n");
_unlock();
}
+function _quietecho($msg) {
+ global $QUIET;
+ if(!$QUIET) echo $msg;
+}
+
//Setup VIM: ex: et ts=2 enc=utf-8 :