/** * Download a file * * @return void */ public function downloadTask() { // Incoming $pid = Request::getInt('id', 0); $vid = Request::getInt('v', 0); $source = NULL; // Need pub and version ID if (!$pid || $pid == 0 || !$vid) { return; } // Get the file name $uri = Request::getVar('REQUEST_URI', '', 'server'); if (strstr($uri, 'Image:')) { $file = str_replace('Image:', '', strstr($uri, 'Image:')); } elseif (strstr($uri, 'File:')) { $file = str_replace('File:', '', strstr($uri, 'File:')); } //decode file name $file = urldecode($file); if (strtolower($file) == 'thumb') { // Get publication thumbnail $source = Helpers\Html::getThumb($pid, $vid, $this->config); } else { // Build publication path $path = Helpers\Html::buildPubPath($pid, $vid, $this->config->get('webpath')); if (strtolower($file) == 'master') { // Get master image $source = $path . DS . 'master.png'; // Default image if (!is_file(PATH_APP . DS . $source)) { // Grab first bigger image in gallery if (is_dir(PATH_APP . DS . $path . DS . 'gallery')) { $file_list = scandir(PATH_APP . DS . $path . DS . 'gallery'); foreach ($file_list as $file) { list($width, $height, $type, $attr) = getimagesize(PATH_APP . DS . $path . DS . 'gallery' . DS . $file); if ($width > 200) { $source = $path . DS . 'gallery' . DS . $file; break; } } } if (!is_file(PATH_APP . DS . $source)) { $source = PATH_CORE . DS . trim($this->config->get('masterimage', 'components/com_publications/site/assets/img/master.png'), DS); } } } else { // Load from gallery $source = PATH_APP . DS . $path . DS . 'gallery' . DS . $file; // Default image if (!is_file($source)) { $source = PATH_CORE . DS . trim($this->config->get('gallery_thumb', 'components/com_publications/site/assets/img/gallery_thumb.gif'), DS); } } } if (is_file($source)) { $server = new \Hubzero\Content\Server(); $server->filename($source); $server->serve_inline($source); exit; } return; }