mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
Fix #14 - Shortcode download link fixed
This commit is contained in:
parent
c4586c7404
commit
6d0af08f1a
@ -923,24 +923,25 @@ class DMSDocument_Controller extends Controller {
|
||||
*/
|
||||
public static function dms_link_shortcode_handler($arguments, $content = null, $parser = null) {
|
||||
$linkText = null;
|
||||
if(isset($arguments['id']) && is_numeric($arguments['id'])) {
|
||||
// get the document object
|
||||
$document = DataObject::get_by_id('DMSDocument', Convert::raw2sql($arguments['id']));
|
||||
|
||||
if (!empty($arguments['id'])) {
|
||||
$document = DMSDocument::get()->filter(array('ID' => $arguments['id']))->First();
|
||||
if ($document && !$document->isHidden()) {
|
||||
if( $content ) {
|
||||
if (!empty($content)) {
|
||||
$linkText = sprintf('<a href="%s">%s</a>', $document->Link(), $parser->parse($content));
|
||||
} else {
|
||||
$extension = $document->getExtension();
|
||||
$size = "data:{size:'{$document->getFileSizeFormatted()}'}";
|
||||
$linkText = $document->getLink()."\" class=\"$size documentLink $extension";
|
||||
$linkText = $document->Link();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$linkText) {
|
||||
$errorPage = DataObject::get_one('ErrorPage', '"ErrorCode" = \'404\'');
|
||||
if ($errorPage) $linkText = $errorPage->Link();
|
||||
if (empty($linkText)) {
|
||||
$errorPage = ErrorPage::get()->filter(array('ErrorCode' => '404'))->First();
|
||||
if ($errorPage) {
|
||||
$linkText = $errorPage->Link();
|
||||
}
|
||||
}
|
||||
|
||||
return $linkText;
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
var attributes = {
|
||||
href : href,
|
||||
target : target,
|
||||
class : 'documentLink',
|
||||
title : this.find('.selected-document').text() //title is the text of the selected document
|
||||
};
|
||||
|
||||
@ -104,4 +105,4 @@
|
||||
});
|
||||
});
|
||||
|
||||
}(jQuery));
|
||||
}(jQuery));
|
||||
|
Loading…
Reference in New Issue
Block a user