move code for getting version into method version()

This commit is contained in:
Uwe Steinmann 2019-03-27 15:30:11 +01:00
parent f97af846e6
commit cd4eb3d115

View File

@ -24,8 +24,25 @@ class SeedDMS_Controller_Download extends SeedDMS_Controller_Common {
public function version() { /* {{{ */
$dms = $this->params['dms'];
$content = $this->params['content'];
$version = $this->params['version'];
$document = $this->params['document'];
if($version < 1) {
$content = $this->callHook('documentLatestContent', $document);
if($content === null)
$content = $document->getLatestContent();
} else {
$content = $this->callHook('documentContent', $document, $version);
if($content === null)
$content = $document->getContentByVersion($version);
}
if (!is_object($content)) {
$this->errormsg = 'invalid_version';
return false;
}
/* set params['content'] for compatiblity with older extensions which
* expect the content in the controller
*/
$this->params['content'] = $content;
if(null === $this->callHook('version')) {
if(file_exists($dms->contentDir . $content->getPath())) {
header("Content-Transfer-Encoding: binary");
@ -174,25 +191,6 @@ class SeedDMS_Controller_Download extends SeedDMS_Controller_Common {
$dms = $this->params['dms'];
$type = $this->params['type'];
$version = $this->params['version'];
$document = $this->params['document'];
if($version < 1) {
$content = $this->callHook('documentLatestContent', $document);
if($content === null)
$content = $document->getLatestContent();
} else {
$content = $this->callHook('documentContent', $document, $version);
if($content === null)
$content = $document->getContentByVersion($version);
}
if (!is_object($content)) {
$this->errormsg = 'invalid_version';
return false;
}
/* set params['content'] for compatiblity with older extensions which
* expect the content in the controller
*/
$this->params['content'] = $content;
switch($type) {
case "version":
return $this->version();