mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
85 lines
1.8 KiB
PHP
85 lines
1.8 KiB
PHP
<?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;
|
|
}
|
|
|
|
public function addService($name, $service) {
|
|
$this->services[$name] = $service;
|
|
}
|
|
|
|
public function setConverters($converters) {
|
|
$this->converters = $converters;
|
|
}
|
|
|
|
public function setMaxSize($maxsize) {
|
|
$this->maxsize = $maxsize;
|
|
}
|
|
|
|
public function setIndexDir($indexdir) {
|
|
$this->indexdir = $indexdir;
|
|
}
|
|
|
|
public function IndexedDocument($document) {
|
|
$indexcontent = $document->getLatestContent()->getFileSize() < $this->maxsize;
|
|
return new $this->services[0]['IndexedDocument']($document->getDMS(), $document, $this->converters, $indexcontent);
|
|
}
|
|
|
|
public function Indexer($recreate) {
|
|
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 Indexer($recreate) {
|
|
return new $this->services[0]['Search']();
|
|
}
|
|
}
|
|
|
|
|