diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php index 91a86e6..b81d1f1 100755 --- a/search2/indexing/indexerCore.inc.php +++ b/search2/indexing/indexerCore.inc.php @@ -475,10 +475,21 @@ abstract class Indexer * @param string $document * @param string $what */ - public static function index($document, $what='C') + public static function index($document, $what='A') { global $default; + if (is_numeric($document)) + { + $document = Document::get($document+0); + } + + if (PEAR::isError($document)) + { + $default->log->error("index: Could not index document: " .$document->getMessage()); + return; + } + $document_id = $document->getId(); $userid=$_SESSION['userID']; if (empty($userid)) $userid=1; diff --git a/search2/search/bin/search2graphviz.php b/search2/search/bin/search2graphviz.php new file mode 100644 index 0000000..d2fe464 --- /dev/null +++ b/search2/search/bin/search2graphviz.php @@ -0,0 +1,101 @@ +. + * + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +$curdir = getcwd(); +chdir(dirname(__FILE__)); +require_once(realpath('../../../config/dmsDefaults.php')); + +$expr = ''; + +$filename = 'search2graphviz.jpg'; +$verbose = false; +if ($argc > 0) +{ + foreach($argv as $arg) + { + if (strpos($arg, '=') === false) + { + $expr = $arg; + continue; + } + list($param, $value) = explode('=', $arg); + + switch (strtolower($param)) + { + case 'verbose': + $verbose=true; + break; + case 'output': + $filename = $value; + if ($verbose) print "* output = $value\n"; + break; + case 'user': + $username = $value; + if ($verbose) print "* User = $value\n"; + break; + case 'pass': + $password = $value; + if ($verbose) print "* User = $value\n"; + break; + case 'help': + print "Usage: search2graphviz.php [verbose] output=filename 'search criteria'\n"; + exit; + } + } +} + +if ($verbose) print _kt('Visgraph search expression') . "...\n"; + +try +{ + $expr = parseExpression($expr); + + $expr->toVizGraph(array('tofile'=>$filename)); + + if ($verbose) + { + print _kt("Done.") . "\n"; + } + +} +catch(Exception $e) +{ + print $e->getMessage(); +} + +?> \ No newline at end of file diff --git a/search2/search/expr.inc.php b/search2/search/expr.inc.php index 0b47c8d..0f7efdd 100755 --- a/search2/search/expr.inc.php +++ b/search2/search/expr.inc.php @@ -273,18 +273,21 @@ class Expr $ext = pathinfo($filename, PATHINFO_EXTENSION); $base = substr($filename, 0, -strlen($ext)-1); - $dotfile="$path/$base.$ext"; - $jpgfile="$path/$base.jpg"; + $curdir = getcwd(); + chdir($_ENV['PWD']); + $dotfile="$base.$ext"; + $jpgfile="$base.jpg"; $fp = fopen($dotfile,'wt'); fwrite($fp, $str); fclose($fp); - system("dot -Tjpg -o$jpgfile $dotfile"); + system("dot -Tjpg -o$jpgfile $dotfile 2>1 >/dev/null "); if (isset($options['view']) && $options['view']) { system("eog $jpgfile"); } + chdir($curdir); } return $str;