Skip to content

Commit

Permalink
Feature: Screenshot for Download
Browse files Browse the repository at this point in the history
  • Loading branch information
KratorD committed May 17, 2016
1 parent f139f35 commit 9cfbacb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions lib/Downloads/Controller/User.php
Expand Up @@ -113,15 +113,15 @@ public function display($args)
//$item['filetype'] = FileUtil::getExtension($item['filename']);
$filename = $item->getFilename();
$filetype = (!empty($filename)) ? FileUtil::getExtension($filename) : $this->__('unknown');
// screenshot path
$ssPath = $this->getVar('screenshot_folder'). "/";
// screenshot path
$ssPath = $this->getVar('screenshot_folder'). "/";

$this->view->setCacheId('display|lid_' . $lid);

return $this->view
->assign('item', $item)
->assign('filetype', $filetype)
->assign('ssPath', $ssPath)
->assign('ssPath', $ssPath)
->fetch('user/display.tpl');
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Downloads/Entity/Download.php
Expand Up @@ -343,7 +343,7 @@ public function setObjectid($objectid)
$this->objectid = $objectid;
}

public function getScreenshot()
public function getScreenshot()
{
return $this->screenshot;
}
Expand Down
26 changes: 13 additions & 13 deletions lib/Downloads/Form/Handler/Admin/Edit.php
Expand Up @@ -77,11 +77,11 @@ public function handleCommand(Zikula_Form_View $view, &$args)
if(SecurityUtil::checkPermission('Downloads::', '::', ACCESS_DELETE)) {
$file = $this->entityManager->getRepository('Downloads_Entity_Download')->find($this->id);
// file
$oldname = $file->getFilename();
$oldname = $file->getFilename();
$fullpath = DataUtil::formatForOS("$storage/$oldname");
@unlink($fullpath);
// screenshot
$oldssname = $file->getScreenshot();
// screenshot
$oldssname = $file->getScreenshot();
$fullsspath = DataUtil::formatForOS("$screens_folder/$oldssname");
@unlink($fullsspath);
$this->entityManager->remove($file);
Expand Down Expand Up @@ -111,11 +111,11 @@ public function handleCommand(Zikula_Form_View $view, &$args)
$plugin->setError($this->__('OR specify a download url.'));
return false;
}
// validate the max file size for screenshot
$screenshotmaxsize = $this->getVar('screenshotmaxsize');
if ($data['screenshot']['size'] > $screenshotmaxsize){
return LogUtil::registerError($this->__f('Screenshot file is bigger that the max. file size:', $screenshotmaxsize));
}
// validate the max file size for screenshot
$screenshotmaxsize = $this->getVar('screenshotmaxsize');
if ($data['screenshot']['size'] > $screenshotmaxsize){
return LogUtil::registerError($this->__f('Screenshot file is bigger that the max. file size:', $screenshotmaxsize));
}

$newFileUploadedFlag = false;
$data['update'] = new DateTime();
Expand All @@ -138,9 +138,9 @@ public function handleCommand(Zikula_Form_View $view, &$args)
$data['filename'] = '';
}

// screenshot
if ((is_array($data['screenshot'])) && ($data['screenshot']['size'] > 0)) {
$result = Downloads_Util::uploadFile('screenshot', $screens_folder, $data['screenshot']['name']);
// screenshot
if ((is_array($data['screenshot'])) && ($data['screenshot']['size'] > 0)) {
$result = Downloads_Util::uploadFile('screenshot', $screens_folder, $data['screenshot']['name']);
if (!$result) {
return LogUtil::registerError($result);
}
Expand All @@ -164,8 +164,8 @@ public function handleCommand(Zikula_Form_View $view, &$args)
} else {
$data['filename'] = $file->getFilename();
}
// screenshot
$oldssname = $file->getScreenshot();
// screenshot
$oldssname = $file->getScreenshot();
if ($newSSUploadedFlag) {
$fullpath = "$screens_folder/$oldssname";
@unlink($fullpath);
Expand Down
2 changes: 1 addition & 1 deletion lib/Downloads/Installer.php
Expand Up @@ -194,7 +194,7 @@ private function createUploadDir()
LogUtil::registerStatus($this->__f('Created the file storage directory successfully at [%s]. Be sure that this directory is accessible via web and writable by the webserver.', $uploaddir));
}

// upload dir creation
// screenshot dir creation
$screenshotdir = $this->getVar('screenshot_folder');

if (mkdir($screenshotdir, System::getVar('system.chmod_dir', 0777), true)) {
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/edit.tpl
Expand Up @@ -45,7 +45,7 @@
{formuploadinput id="screenshot"}
</div>

<div class="z-formrow">
<div class="z-formrow">
{formlabel mandatorysym=true for="submitter" __text="Submitted by"}
{formtextinput id="submitter" mandatory=true maxLength=60}
</div>
Expand Down

0 comments on commit 9cfbacb

Please sign in to comment.