* @copyright Copyright (C) 2016 Uwe Steinmann * @version Release: @package_version@ */ /** * Implementation of fulltext service * * @category DMS * @package SeedDMS * @author Uwe Steinmann * @copyright Copyright (C) 2016 Uwe Steinmann * @version Release: @package_version@ */ class SeedDMS_FulltextService { /** * List of services for searching fulltext */ protected $services; /** * List of converters */ protected $converters; /** * Max file size for imediate indexing */ protected $maxsize; public function __construct() { $this->services = array(); $this->converters = array(); $this->maxsize = 0; $this->indexdir = ''; $this->index = null; $this->cmdtimeout = 5; } public function addService($name, $service) { $this->services[] = $service; } public function setConverters($converters) { $this->converters = $converters; } public function setMaxSize($maxsize) { $this->maxsize = $maxsize; } public function setIndexDir($indexdir) { $this->indexdir = $indexdir; } public function setCmdTimeout($timeout) { $this->cmdtimeout = $timeout; } public function IndexedDocument($document, $forceupdate=false) { $nocontent = ($document->getLatestContent()->getFileSize() > $this->maxsize) && !$forceupdate; return new $this->services[0]['IndexedDocument']($document->getDMS(), $document, $this->converters, $nocontent, $this->cmdtimeout); } public function Indexer($recreate=false) { if($this->index) return $this->index; if($this->indexdir) { if($recreate) $this->index = $this->services[0]['Indexer']::create($this->indexdir); else $this->index = $this->services[0]['Indexer']::open($this->indexdir); return $this->index; } else return null; } public function Search() { return new $this->services[0]['Search']($this->index); } }