mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
move code for getting version into method version()
This commit is contained in:
parent
f97af846e6
commit
cd4eb3d115
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user