Fix #14 - Shortcode download link fixed

This commit is contained in:
Stephen Shkardoon 2013-08-23 01:09:06 +12:00
parent c4586c7404
commit 6d0af08f1a
2 changed files with 13 additions and 11 deletions

View File

@ -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;
}

View File

@ -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));