mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-11 17:44:56 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
f6ae2c3868
|
@ -33,11 +33,18 @@ class SeedDMS_ConversionMgr {
|
|||
*/
|
||||
public $services;
|
||||
|
||||
/**
|
||||
* @var $success set to false if conversion failed
|
||||
*/
|
||||
protected $success;
|
||||
|
||||
public function __construct() {
|
||||
$this->services = array();
|
||||
$this->success = true;
|
||||
}
|
||||
|
||||
public function addService($service) {
|
||||
$service->setConversionMgr($this);
|
||||
$this->services[$service->from][$service->to][] = $service;
|
||||
return $service;
|
||||
}
|
||||
|
@ -53,22 +60,30 @@ class SeedDMS_ConversionMgr {
|
|||
* Return the service that would be tried first for converting
|
||||
* the document.
|
||||
*
|
||||
* The conversion may not use this service but choose a different
|
||||
* The conversion manager may not use this service but choose a different
|
||||
* one when it fails.
|
||||
*/
|
||||
public function getService($from, $to) {
|
||||
public function getService($from, $to) { /* {{{ */
|
||||
if(!empty($this->services[$from][$to]))
|
||||
return end($this->services[$from][$to]);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
public function getServices() {
|
||||
public function getServices() { /* {{{ */
|
||||
return $this->services;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
public function wasSuccessful() { /* {{{ */
|
||||
return $this->success;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Convert a file
|
||||
* Convert a file from one format into another format
|
||||
*
|
||||
* This method will try each conversion service until a service
|
||||
* fails or was successful. If a service succeeds it must not
|
||||
* return false, null, '' or 0
|
||||
*
|
||||
* @param string $file name of file to convert
|
||||
* @param string $from mimetype of input file
|
||||
|
@ -86,8 +101,10 @@ class SeedDMS_ConversionMgr {
|
|||
for(end($services); key($services)!==null; prev($services)) {
|
||||
$service = current($services);
|
||||
$text = $service->convert($file, $target, $params);
|
||||
if(!$service->wasSuccessful())
|
||||
if(!$service->wasSuccessful()) {
|
||||
$this->success = false;
|
||||
return false;
|
||||
}
|
||||
if($text)
|
||||
return $text;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,11 @@ abstract class SeedDMS_ConversionServiceBase {
|
|||
*/
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* conversion manager
|
||||
*/
|
||||
protected $conversionmgr;
|
||||
|
||||
/**
|
||||
* @var $success set to false if conversion failed
|
||||
*/
|
||||
|
@ -45,12 +50,22 @@ abstract class SeedDMS_ConversionServiceBase {
|
|||
$this->from = null;
|
||||
$this->to = null;
|
||||
$this->success = true;
|
||||
$this->logger = null;
|
||||
$this->conversionmgr = null;
|
||||
}
|
||||
|
||||
public function setLogger($logger) {
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function setConversionMgr($conversionmgr) {
|
||||
$this->conversionmgr = $conversionmgr;
|
||||
}
|
||||
|
||||
public function getConversionMgr() {
|
||||
return $this->conversionmgr;
|
||||
}
|
||||
|
||||
public function getInfo() {
|
||||
return 'Conversion service';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user