Commit 8ee62ae5102e7f896dc3297b716c7fd7a2c73d90
1 parent
8ba7bdc3
KTS-2402
"Display the search expression tree" Implemented. Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8288 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
119 additions
and
4 deletions
search2/indexing/indexerCore.inc.php
| @@ -475,10 +475,21 @@ abstract class Indexer | @@ -475,10 +475,21 @@ abstract class Indexer | ||
| 475 | * @param string $document | 475 | * @param string $document |
| 476 | * @param string $what | 476 | * @param string $what |
| 477 | */ | 477 | */ |
| 478 | - public static function index($document, $what='C') | 478 | + public static function index($document, $what='A') |
| 479 | { | 479 | { |
| 480 | global $default; | 480 | global $default; |
| 481 | 481 | ||
| 482 | + if (is_numeric($document)) | ||
| 483 | + { | ||
| 484 | + $document = Document::get($document+0); | ||
| 485 | + } | ||
| 486 | + | ||
| 487 | + if (PEAR::isError($document)) | ||
| 488 | + { | ||
| 489 | + $default->log->error("index: Could not index document: " .$document->getMessage()); | ||
| 490 | + return; | ||
| 491 | + } | ||
| 492 | + | ||
| 482 | $document_id = $document->getId(); | 493 | $document_id = $document->getId(); |
| 483 | $userid=$_SESSION['userID']; | 494 | $userid=$_SESSION['userID']; |
| 484 | if (empty($userid)) $userid=1; | 495 | if (empty($userid)) $userid=1; |
search2/search/bin/search2graphviz.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id:$ | ||
| 5 | + * | ||
| 6 | + * KnowledgeTree Open Source Edition | ||
| 7 | + * Document Management Made Simple | ||
| 8 | + * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited | ||
| 9 | + * | ||
| 10 | + * This program is free software; you can redistribute it and/or modify it under | ||
| 11 | + * the terms of the GNU General Public License version 3 as published by the | ||
| 12 | + * Free Software Foundation. | ||
| 13 | + * | ||
| 14 | + * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 16 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 17 | + * details. | ||
| 18 | + * | ||
| 19 | + * You should have received a copy of the GNU General Public License | ||
| 20 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | + * | ||
| 22 | + * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | ||
| 23 | + * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | ||
| 24 | + * | ||
| 25 | + * The interactive user interfaces in modified source and object code versions | ||
| 26 | + * of this program must display Appropriate Legal Notices, as required under | ||
| 27 | + * Section 5 of the GNU General Public License version 3. | ||
| 28 | + * | ||
| 29 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | ||
| 30 | + * these Appropriate Legal Notices must retain the display of the "Powered by | ||
| 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | ||
| 32 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
| 33 | + * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 34 | + * copyright notice. | ||
| 35 | + * Contributor( s): ______________________________________ | ||
| 36 | + * | ||
| 37 | + */ | ||
| 38 | + | ||
| 39 | +$curdir = getcwd(); | ||
| 40 | +chdir(dirname(__FILE__)); | ||
| 41 | +require_once(realpath('../../../config/dmsDefaults.php')); | ||
| 42 | + | ||
| 43 | +$expr = ''; | ||
| 44 | + | ||
| 45 | +$filename = 'search2graphviz.jpg'; | ||
| 46 | +$verbose = false; | ||
| 47 | +if ($argc > 0) | ||
| 48 | +{ | ||
| 49 | + foreach($argv as $arg) | ||
| 50 | + { | ||
| 51 | + if (strpos($arg, '=') === false) | ||
| 52 | + { | ||
| 53 | + $expr = $arg; | ||
| 54 | + continue; | ||
| 55 | + } | ||
| 56 | + list($param, $value) = explode('=', $arg); | ||
| 57 | + | ||
| 58 | + switch (strtolower($param)) | ||
| 59 | + { | ||
| 60 | + case 'verbose': | ||
| 61 | + $verbose=true; | ||
| 62 | + break; | ||
| 63 | + case 'output': | ||
| 64 | + $filename = $value; | ||
| 65 | + if ($verbose) print "* output = $value\n"; | ||
| 66 | + break; | ||
| 67 | + case 'user': | ||
| 68 | + $username = $value; | ||
| 69 | + if ($verbose) print "* User = $value\n"; | ||
| 70 | + break; | ||
| 71 | + case 'pass': | ||
| 72 | + $password = $value; | ||
| 73 | + if ($verbose) print "* User = $value\n"; | ||
| 74 | + break; | ||
| 75 | + case 'help': | ||
| 76 | + print "Usage: search2graphviz.php [verbose] output=filename 'search criteria'\n"; | ||
| 77 | + exit; | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +if ($verbose) print _kt('Visgraph search expression') . "...\n"; | ||
| 83 | + | ||
| 84 | +try | ||
| 85 | +{ | ||
| 86 | + $expr = parseExpression($expr); | ||
| 87 | + | ||
| 88 | + $expr->toVizGraph(array('tofile'=>$filename)); | ||
| 89 | + | ||
| 90 | + if ($verbose) | ||
| 91 | + { | ||
| 92 | + print _kt("Done.") . "\n"; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | +} | ||
| 96 | +catch(Exception $e) | ||
| 97 | +{ | ||
| 98 | + print $e->getMessage(); | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +?> | ||
| 0 | \ No newline at end of file | 102 | \ No newline at end of file |
search2/search/expr.inc.php
| @@ -273,18 +273,21 @@ class Expr | @@ -273,18 +273,21 @@ class Expr | ||
| 273 | $ext = pathinfo($filename, PATHINFO_EXTENSION); | 273 | $ext = pathinfo($filename, PATHINFO_EXTENSION); |
| 274 | $base = substr($filename, 0, -strlen($ext)-1); | 274 | $base = substr($filename, 0, -strlen($ext)-1); |
| 275 | 275 | ||
| 276 | - $dotfile="$path/$base.$ext"; | ||
| 277 | - $jpgfile="$path/$base.jpg"; | 276 | + $curdir = getcwd(); |
| 277 | + chdir($_ENV['PWD']); | ||
| 278 | + $dotfile="$base.$ext"; | ||
| 279 | + $jpgfile="$base.jpg"; | ||
| 278 | $fp = fopen($dotfile,'wt'); | 280 | $fp = fopen($dotfile,'wt'); |
| 279 | fwrite($fp, $str); | 281 | fwrite($fp, $str); |
| 280 | fclose($fp); | 282 | fclose($fp); |
| 281 | 283 | ||
| 282 | - system("dot -Tjpg -o$jpgfile $dotfile"); | 284 | + system("dot -Tjpg -o$jpgfile $dotfile 2>1 >/dev/null "); |
| 283 | 285 | ||
| 284 | if (isset($options['view']) && $options['view']) | 286 | if (isset($options['view']) && $options['view']) |
| 285 | { | 287 | { |
| 286 | system("eog $jpgfile"); | 288 | system("eog $jpgfile"); |
| 287 | } | 289 | } |
| 290 | + chdir($curdir); | ||
| 288 | } | 291 | } |
| 289 | 292 | ||
| 290 | return $str; | 293 | return $str; |