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) {
|
public static function dms_link_shortcode_handler($arguments, $content = null, $parser = null) {
|
||||||
$linkText = null;
|
$linkText = null;
|
||||||
if(isset($arguments['id']) && is_numeric($arguments['id'])) {
|
|
||||||
// get the document object
|
if (!empty($arguments['id'])) {
|
||||||
$document = DataObject::get_by_id('DMSDocument', Convert::raw2sql($arguments['id']));
|
$document = DMSDocument::get()->filter(array('ID' => $arguments['id']))->First();
|
||||||
if ($document && !$document->isHidden()) {
|
if ($document && !$document->isHidden()) {
|
||||||
if( $content ) {
|
if (!empty($content)) {
|
||||||
$linkText = sprintf('<a href="%s">%s</a>', $document->Link(), $parser->parse($content));
|
$linkText = sprintf('<a href="%s">%s</a>', $document->Link(), $parser->parse($content));
|
||||||
} else {
|
} else {
|
||||||
$extension = $document->getExtension();
|
$linkText = $document->Link();
|
||||||
$size = "data:{size:'{$document->getFileSizeFormatted()}'}";
|
|
||||||
$linkText = $document->getLink()."\" class=\"$size documentLink $extension";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$linkText) {
|
if (empty($linkText)) {
|
||||||
$errorPage = DataObject::get_one('ErrorPage', '"ErrorCode" = \'404\'');
|
$errorPage = ErrorPage::get()->filter(array('ErrorCode' => '404'))->First();
|
||||||
if ($errorPage) $linkText = $errorPage->Link();
|
if ($errorPage) {
|
||||||
|
$linkText = $errorPage->Link();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $linkText;
|
return $linkText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
var attributes = {
|
var attributes = {
|
||||||
href : href,
|
href : href,
|
||||||
target : target,
|
target : target,
|
||||||
|
class : 'documentLink',
|
||||||
title : this.find('.selected-document').text() //title is the text of the selected document
|
title : this.find('.selected-document').text() //title is the text of the selected document
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user