Bugfixes for Freemarker Macro libraries
git-svn-id: https://svn.libreccm.org/ccm/trunk@6226 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
3d8af10d17
commit
bfc8434d9d
|
|
@ -6,10 +6,29 @@
|
|||
>
|
||||
|
||||
<#function getFileAttachments item>
|
||||
<#return item["./fileAttachments"]?sort_by("fileOrder")>
|
||||
|
||||
<#return item["./fileAttachments"]?map(
|
||||
file -> {
|
||||
"fileType": _getFileType(file),
|
||||
"mimeType": file["./mimeType/mimeType"].@@text,
|
||||
"mimeTypeLabel": file["./mimeType/label"].@@text,
|
||||
"fileSize": file["./length"].@@text?number,
|
||||
"fileExtension": file["./mimeType/fileExtension"],
|
||||
"fileId": file["./id"].@@text,
|
||||
"fileName": file["./name"].@@text,
|
||||
"description": file["./description"].@@text,
|
||||
"fileUrl": dispatcherPrefix + '/cms-service/stream/asset/' + file["./name"].@@text + '?asset_id=' + file["./id"],
|
||||
"fileOrder": file["./fileOrder"]?number
|
||||
})?sort_by("fileOrder")>
|
||||
|
||||
<#-- <#return item["./fileAttachments"]?sort_by("fileOrder")> -->
|
||||
</#function>
|
||||
|
||||
<#function getFileType file>
|
||||
<#-- <#function getFileType file>
|
||||
<#return file.fileType>
|
||||
</#function> -->
|
||||
|
||||
<#function _getFileType file>
|
||||
<#if (file["./mimeType/mimeType"].@@text == "text/plain") && file["./mimeType/label"].@@text == "caption">
|
||||
<#return "caption">
|
||||
<#else>
|
||||
|
|
@ -17,16 +36,16 @@
|
|||
</#if>
|
||||
</#function>
|
||||
|
||||
<#function getMimeType file>
|
||||
<#return file["./mimeType/mimeType"]>
|
||||
<#-- <#function getMimeType file>
|
||||
<#return file["./mimeType/mimeType"]>
|
||||
</#function>
|
||||
|
||||
<#function getMimeTypeLabel file>
|
||||
<#return file["./mimeType/label"]>
|
||||
<#return file["./mimeType/label"]>
|
||||
</#function>
|
||||
|
||||
<#function getMimeTypeFileExtension file>
|
||||
<#return file["./mimeType/fileExtension"]>
|
||||
<#return file["./mimeType/fileExtension"]>
|
||||
</#function>
|
||||
|
||||
<#function getFileSize file unit="byte">
|
||||
|
|
@ -57,7 +76,7 @@
|
|||
|
||||
<#function getFileUrl file>
|
||||
<#return dispatcherPrefix + '/cms-service/stream/asset/' + getFileName(file) + '?asset_id=' + getFileId(file)>
|
||||
</#function>
|
||||
</#function> -->
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,23 @@
|
|||
>
|
||||
|
||||
<#function getImageAttachments item>
|
||||
<#return item["./imageAttachments"]>
|
||||
|
||||
<#return item["./imageAttachments"]?map(
|
||||
image -> {
|
||||
"imageId": image["./image/id"].@@text,
|
||||
"name": image["./image/name"].@@text,
|
||||
"caption": image["./caption"].@@text,
|
||||
"sortKey": image["./sortKey"]@number,
|
||||
"width": image["./width"]@number,
|
||||
"height": image["./width"]@number,
|
||||
"imageUrl: dispatcherPrefix + "/cms-service/stream/image/?image_id=" + image["./image/id"].@@text
|
||||
}
|
||||
)?sort_by("sortKey")>
|
||||
|
||||
<#-- <#return item["./imageAttachments"]> -->
|
||||
</#function>
|
||||
|
||||
<#function getImageId image>
|
||||
<#-- <#function getImageId image>
|
||||
<#return image["./image/id"]>
|
||||
</#function>
|
||||
|
||||
|
|
@ -35,4 +48,4 @@
|
|||
|
||||
<#function getImageUrl image>
|
||||
<#return dispatcherPrefix + '/cms-service/stream/image/?image_id=' + getImageId(image)>
|
||||
</#function>
|
||||
</#function> -->
|
||||
|
|
|
|||
|
|
@ -6,9 +6,14 @@
|
|||
>
|
||||
|
||||
<#function getNotes item>
|
||||
<#return item["./ca_notes"]>
|
||||
<#-- <#return item["./ca_notes"]> -->
|
||||
<#return item["./ca_notes"]?map(
|
||||
note -> {
|
||||
"content": note["./content"],
|
||||
"rank": note["./rank"]?number
|
||||
})?sort_by("rank")>
|
||||
</#function>
|
||||
|
||||
<#function getContent note>
|
||||
<#-- <#function getContent note>
|
||||
<#return note["./content"]>
|
||||
</#function>
|
||||
</#function> -->
|
||||
|
|
@ -7,10 +7,19 @@
|
|||
|
||||
<#function getRelatedLinks item linkListName="NONE">
|
||||
|
||||
<#return item["./links[./linkListName='${linkListName}']"]?sort_by("linkOrder")>
|
||||
<#return item["./links[./linkListName='${linkListName}']"]?map(
|
||||
link -> {
|
||||
"linkType": _getLinkType(link),
|
||||
"title": link["./linkTitle"].@@text,
|
||||
"description": link["./linkDescription"].@@text,
|
||||
"linkOrder": link["./linkOrder"]?number,
|
||||
"targetUri": _getTargetUri(link)
|
||||
})?sort_by("linkOrder")>
|
||||
|
||||
<#-- <#return item["./links[./linkListName='${linkListName}']"]?sort_by("linkOrder")> -->
|
||||
</#function>
|
||||
|
||||
<#function getLinkType link>
|
||||
<#function _getLinkType link>
|
||||
<#if (link["./targetType"].@@text == "externalLink" && link["./targetURI"] == "caption")>
|
||||
<#return "caption">
|
||||
<#elseif (link["./targetType"].@@text == "internalLink")>
|
||||
|
|
@ -20,7 +29,7 @@
|
|||
</#if>
|
||||
</#function>
|
||||
|
||||
<#function getLinkTitle link>
|
||||
<#-- <#function getLinkTitle link>
|
||||
<#return link["./linkTitle"].@@text>
|
||||
</#function>
|
||||
|
||||
|
|
@ -30,10 +39,12 @@
|
|||
|
||||
<#function getLinkOrder link>
|
||||
<#return link["./linkOrder"].@@text>
|
||||
</#function>
|
||||
</#function> -->
|
||||
|
||||
<#function getInternalLinkParameters link>
|
||||
<#if (link["./targetURI"]?size > 0)>
|
||||
<#function _getInternalLinkParameters link>
|
||||
<#if (_getLinkType(link) == "caption")>
|
||||
<#return "">
|
||||
<#elseif (link["./targetURI"]?size > 0)>
|
||||
<#assign targetUri=link["./targetURI"].@@text>
|
||||
<#if (targetUri@starts_with("&?"))>
|
||||
<#return "&${targetUri[3]}">
|
||||
|
|
@ -45,8 +56,10 @@
|
|||
</#if>
|
||||
</#function>
|
||||
|
||||
<#function getTargetUri link>
|
||||
<#if (getLinkType(link) == "internalLink")>
|
||||
<#function _getTargetUri link>
|
||||
<#if (_getLinkType(link) == "caption")>
|
||||
<#return "">
|
||||
<#elseif (_getLinkType(link) == "internalLink")>
|
||||
<#return "${contextPrefix}/redirect/?oid=${link['./targetItem/@oid']}${getInternalLinkParameters(link)}">
|
||||
<#else>
|
||||
<#return link["./targetURI"].@@text>
|
||||
|
|
|
|||
|
|
@ -620,7 +620,6 @@ public class FreeMarkerPresentationManager implements PresentationManager {
|
|||
@Override
|
||||
public Object exec(final List list) throws TemplateModelException {
|
||||
|
||||
// list.get(0).get(0).get("fileOrder").getNode().getTextContent()
|
||||
if (list.isEmpty() || list.size() != 2) {
|
||||
throw new IllegalArgumentException(
|
||||
"SortAttachmentList requires the following parameters: "
|
||||
|
|
@ -629,11 +628,16 @@ public class FreeMarkerPresentationManager implements PresentationManager {
|
|||
);
|
||||
}
|
||||
|
||||
if (list.get(0) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(list.get(0) instanceof TemplateModelListSequence)) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The first argument of SortAttachmentList must be a "
|
||||
+ "Sequence."
|
||||
+ "Sequence but is a %s...",
|
||||
list.get(0).getClass().getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue