2020-09-08 15:06:26 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implementation of fulltext service
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @license GPL 2
|
|
|
|
* @version @version@
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2016 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of fulltext service
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @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;
|
2020-09-09 17:49:15 +00:00
|
|
|
$this->cmdtimeout = 5;
|
2020-09-08 15:06:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addService($name, $service) {
|
2020-09-09 17:49:15 +00:00
|
|
|
$this->services[] = $service;
|
2020-09-08 15:06:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setConverters($converters) {
|
|
|
|
$this->converters = $converters;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMaxSize($maxsize) {
|
|
|
|
$this->maxsize = $maxsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIndexDir($indexdir) {
|
|
|
|
$this->indexdir = $indexdir;
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:49:15 +00:00
|
|
|
public function setCmdTimeout($timeout) {
|
|
|
|
$this->cmdtimeout = $timeout;
|
2020-09-08 15:06:26 +00:00
|
|
|
}
|
|
|
|
|
2020-09-09 17:49:15 +00:00
|
|
|
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;
|
|
|
|
|
2020-09-08 15:06:26 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-09-09 17:49:15 +00:00
|
|
|
public function Search() {
|
|
|
|
return new $this->services[0]['Search']($this->index);
|
2020-09-08 15:06:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|