Skip to content

Commit

Permalink
Merge pull request #3 from backbone87/master
Browse files Browse the repository at this point in the history
fix download url generation, if request already contains a "?"
  • Loading branch information
discordier committed Mar 14, 2013
2 parents e2dc9f7 + dd31e5e commit 5a1671c
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ protected function parseMetaFile($strPath)
}
$this->arrProcessed[] = $strPath;
}

public function getDownloadLink($strFile) {
$strRequest = Environment::getInstance()->request;
$strRequest .= strpos($strRequest, '?') === false ? '?' : '&';
$strRequest .= 'file=' . urlencode($strFile);
return $strRequest;
}

protected function renderFile($strFile, $objSettings, $strId)
{
Expand Down Expand Up @@ -127,8 +134,7 @@ protected function renderFile($strFile, $objSettings, $strId)
'icon' => $strIcon,
'size' => $objFile->filesize,
'sizetext' => sprintf('(%s)', MetaModelController::getReadableSize($objFile->filesize, 2)),
'url' => Environment::getInstance()->request . (($GLOBALS['TL_CONFIG']['disableAlias'] || !$GLOBALS['TL_CONFIG']['rewriteURL']
&& count($_GET) || strlen($_GET['page'])) ? '&' : '?'). 'file=' . MetaModelController::urlEncode($strFile)
'url' => specialchars($this->getDownloadLink($strFile))
);

// images
Expand Down Expand Up @@ -346,4 +352,4 @@ protected function prepareTemplate(MetaModelTemplate $objTemplate, $arrRowData,
$this->arrSource = array();

}
}
}

0 comments on commit 5a1671c

Please sign in to comment.