mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
add task for creating missing preview images
This commit is contained in:
parent
53654444f0
commit
c53b3babbd
|
@ -289,6 +289,87 @@ class SeedDMS_CheckSumTask extends SeedDMS_SchedulerTaskBase { /* {{{ */
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Class for processing a single folder
|
||||
*
|
||||
* SeedDMS_Task_Preview_Process_Folder::process() is used as a callable when
|
||||
* iterating over all folders recursively.
|
||||
*/
|
||||
class SeedDMS_Task_Preview_Process_Folder { /* {{{ */
|
||||
protected $logger;
|
||||
|
||||
protected $previewer;
|
||||
|
||||
protected $widths;
|
||||
|
||||
public function __construct($previewer, $widths, $logger) { /* {{{ */
|
||||
$this->logger = $logger;
|
||||
$this->previewer = $previewer;
|
||||
$this->widths = $widths;
|
||||
} /* }}} */
|
||||
|
||||
public function process($folder) { /* {{{ */
|
||||
$dms = $folder->getDMS();
|
||||
$documents = $folder->getDocuments();
|
||||
if($documents) {
|
||||
foreach($documents as $document) {
|
||||
$versions = $document->getContent();
|
||||
foreach($versions as $version) {
|
||||
foreach($this->widths as $width) {
|
||||
if($this->previewer->createPreview($version, $width)) {
|
||||
$this->logger->log('Task \'preview\': created preview ('.$width.'px) for document '.$document->getId().':'.$version->getVersion(), PEAR_LOG_INFO);
|
||||
// echo "Preview ".$width."px for ".$document->getId().":".$version->getVersion()." created\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* }}} */
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Class containing methods for running a scheduled task
|
||||
*
|
||||
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||
* @package SeedDMS
|
||||
* @subpackage core
|
||||
*/
|
||||
class SeedDMS_PreviewTask extends SeedDMS_SchedulerTaskBase { /* {{{ */
|
||||
|
||||
/**
|
||||
* Run the task
|
||||
*
|
||||
* @param $task task to be executed
|
||||
* @param $dms dms
|
||||
* @return boolean true if task was executed succesfully, otherwise false
|
||||
*/
|
||||
public function execute($task) {
|
||||
$dms = $this->dms;
|
||||
$logger = $this->logger;
|
||||
$settings = $this->settings;
|
||||
$taskparams = $task->getParameter();
|
||||
$folder = $dms->getRootFolder();
|
||||
|
||||
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
|
||||
|
||||
$folderprocess = new SeedDMS_Task_Preview_Process_Folder($previewer, array($settings->_previewWidthList, $settings->_previewWidthDetail), $logger);
|
||||
$tree = new SeedDMS_FolderTree($folder, array($folderprocess, 'process'));
|
||||
call_user_func(array($folderprocess, 'process'), $folder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return 'Check all documents for a missing preview image';
|
||||
}
|
||||
|
||||
public function getAdditionalParams() {
|
||||
return array(
|
||||
);
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['expireddocs'] = 'SeedDMS_ExpiredDocumentsTask';
|
||||
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['indexingdocs'] = 'SeedDMS_IndexingDocumentsTask';
|
||||
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['checksum'] = 'SeedDMS_CheckSumTask';
|
||||
$GLOBALS['SEEDDMS_SCHEDULER']['tasks']['core']['preview'] = 'SeedDMS_PreviewTask';
|
||||
|
|
Loading…
Reference in New Issue
Block a user