mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-07-15 08:58:10 +00:00
add support for conversion service pass to IndexedDocument()
This commit is contained in:
parent
6d8dcd8125
commit
0f9fa74bbe
|
@ -179,29 +179,39 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
if($version && !$nocontent) {
|
if($version && !$nocontent) {
|
||||||
$path = $dms->contentDir . $version->getPath();
|
$path = $dms->contentDir . $version->getPath();
|
||||||
if(file_exists($path)) {
|
if(file_exists($path)) {
|
||||||
$content = '';
|
|
||||||
$mimetype = $version->getMimeType();
|
$mimetype = $version->getMimeType();
|
||||||
$this->mimetype = $mimetype;
|
$this->mimetype = $mimetype;
|
||||||
$cmd = '';
|
if(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) {
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
if($convcmd->hasService($mimetype, 'text/plain')) {
|
||||||
if(isset($convcmd[$mimetype])) {
|
$content = $convcmd->convert($path, $mimetype, 'text/plain');
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
if($content) {
|
||||||
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
self::setContent($content);
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
} elseif(isset($convcmd['*'])) {
|
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
}
|
|
||||||
if($cmd) {
|
|
||||||
$this->cmd = $cmd;
|
|
||||||
try {
|
|
||||||
$content = self::execWithTimeout($cmd, $timeout);
|
|
||||||
if($content['stdout']) {
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8'));
|
|
||||||
}
|
}
|
||||||
if($content['stderr']) {
|
}
|
||||||
$this->errormsg = $content['stderr'];
|
} else {
|
||||||
|
$content = '';
|
||||||
|
$cmd = '';
|
||||||
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
|
if(isset($convcmd[$mimetype])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd['*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
}
|
||||||
|
if($cmd) {
|
||||||
|
$this->cmd = $cmd;
|
||||||
|
try {
|
||||||
|
$content = self::execWithTimeout($cmd, $timeout);
|
||||||
|
if($content['stdout']) {
|
||||||
|
self::setContent($content['stdout']);
|
||||||
|
// $this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8'));
|
||||||
|
}
|
||||||
|
if($content['stderr']) {
|
||||||
|
$this->errormsg = $content['stderr'];
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,9 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates our indexable document and adds all
|
* Constructor. Creates our indexable document and adds all
|
||||||
* necessary fields to it using the passed in document
|
* necessary fields to it using the passed in document
|
||||||
|
*
|
||||||
|
* $convcmd can either be an array of conversion commands or
|
||||||
|
* an object of class SeedDMS_ConversionMgr
|
||||||
*/
|
*/
|
||||||
public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { /* {{{ */
|
public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { /* {{{ */
|
||||||
$this->errormsg = '';
|
$this->errormsg = '';
|
||||||
|
@ -176,29 +179,42 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
if($version && !$nocontent) {
|
if($version && !$nocontent) {
|
||||||
$path = $dms->contentDir . $version->getPath();
|
$path = $dms->contentDir . $version->getPath();
|
||||||
if(file_exists($path)) {
|
if(file_exists($path)) {
|
||||||
$content = '';
|
|
||||||
$mimetype = $version->getMimeType();
|
$mimetype = $version->getMimeType();
|
||||||
$this->mimetype = $mimetype;
|
$this->mimetype = $mimetype;
|
||||||
$cmd = '';
|
if(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) {
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
if($convcmd->hasService($mimetype, 'text/plain')) {
|
||||||
if(isset($convcmd[$mimetype])) {
|
$content = $convcmd->convert($path, $mimetype, 'text/plain');
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
if($content) {
|
||||||
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
self::setContent($content);
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
} elseif(isset($convcmd['*'])) {
|
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
}
|
|
||||||
if($cmd) {
|
|
||||||
$this->cmd = $cmd;
|
|
||||||
try {
|
|
||||||
$content = self::execWithTimeout($cmd, $timeout);
|
|
||||||
if($content['stdout']) {
|
|
||||||
$this->addField(SeedDMS_SQLiteFTS_Field::UnStored('content', $content['stdout']));
|
|
||||||
}
|
}
|
||||||
if($content['stderr']) {
|
$this->cmd = get_class($convcmd);
|
||||||
$this->errormsg = $content['stderr'];
|
} else {
|
||||||
|
$this->cmd = 'No service to convert '.$mimetype.' to text/plain';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$content = '';
|
||||||
|
$cmd = '';
|
||||||
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
|
if(isset($convcmd[$mimetype])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd['*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
}
|
||||||
|
if($cmd) {
|
||||||
|
$this->cmd = $cmd;
|
||||||
|
try {
|
||||||
|
$content = self::execWithTimeout($cmd, $timeout);
|
||||||
|
if($content['stdout']) {
|
||||||
|
self::setContent($content['stdout']);
|
||||||
|
// $this->addField(SeedDMS_SQLiteFTS_Field::UnStored('content', $content['stdout']));
|
||||||
|
}
|
||||||
|
if($content['stderr']) {
|
||||||
|
$this->errormsg = $content['stderr'];
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user