<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <#----------------------------------------------------------------------------- Macros and functions for working with properties and property lists ------------------------------------------------------------------------------> <#-- Return true iff there are statements for this property --> <#function hasStatements propertyGroups propertyName> <#local property = propertyGroups.getProperty(propertyName)!> <#-- First ensure that the property is defined (an unpopulated property while logged out is undefined) --> <#if ! property?has_content> <#return false> <#if property.collatedBySubclass!false> <#-- collated object property--> <#return property.subclasses?has_content> <#else> <#return property.statements?has_content> <#-- data property or uncollated object property --> <#----------------------------------------------------------------------------- Macros for generating property lists ------------------------------------------------------------------------------> <#macro dataPropertyListing property editable> <#if property?has_content> <#-- true when the property is in the list, even if not populated (when editing) --> <@addLinkWithLabel property editable /> <@dataPropertyList property editable /> <#macro dataPropertyList property editable> <#list property.statements as statement> <@propertyListItem property statement editable >${statement.value} <#macro objectProperty property editable template=property.template> <#if property.collatedBySubclass> <#-- collated --> <@collatedObjectPropertyList property editable template /> <#else> <#-- uncollated --> <#-- We pass property.statements and property.template even though we are also passing property, because objectPropertyList can get other values, and doesn't necessarily use property.statements and property.template --> <@objectPropertyList property editable property.statements template /> <#macro collatedObjectPropertyList property editable template=property.template > <#local subclasses = property.subclasses> <#list subclasses as subclass> <#local subclassName = subclass.name!> <#if subclassName?has_content>
  • ${subclassName?lower_case}

  • <#else> <#-- If not in a real subclass, the statements are in a dummy subclass with an empty name. List them in the top level ul, not nested. --> <@objectPropertyList property editable subclass.statements template/> <#-- Full object property listing, including heading and ul wrapper element. Assumes property is non-null. --> <#macro objectPropertyListing property editable template=property.template> <#local localName = property.localName>

    ${property.name?capitalize} <@addLink property editable /> <@verboseDisplay property />

    <#macro objectPropertyList property editable statements=property.statements template=property.template> <#list statements as statement> <@propertyListItem property statement editable><#include "${template}"> <#-- Some properties usually display without a label. But if there's an add link, we need to also show the property label. If no label is specified, the property name will be used as the label. --> <#macro addLinkWithLabel property editable label="${property.name?capitalize}" extraParams=""> <#local addLink><@addLink property editable label extraParams /> <#local verboseDisplay><@verboseDisplay property /> <#-- Changed to display the label when user is in edit mode, even if there's no add link (due to displayLimitAnnot, for example). Otherwise the display looks odd, since neighboring properties have labels. <#if addLink?has_content || verboseDisplay?has_content>

    ${label} ${addLink!} ${verboseDisplay!}

    --> <#if editable>

    ${label} ${addLink!} ${verboseDisplay!}

    <#macro addLink property editable label="${property.name}" extraParams=""> <#if editable> <#local url = property.addUrl> <#if url?has_content> <@showAddLink property.localName label addParamsToEditUrl(url, extraParams) /> <#function addParamsToEditUrl url extraParams=""> <#if extraParams?is_hash_ex> <#list extraParams?keys as key> <#local url = "${url}&${key}=${extraParams[key]?url}"> <#return url> <#macro showAddLink propertyLocalName label url> add <#macro propertyLabel property label="${property.name?capitalize}">

    ${label} <@verboseDisplay property />

    <#macro propertyListItem property statement editable >
  • <#nested> <@editingLinks "${property.localName}" statement editable/>
  • <#macro editingLinks propertyLocalName statement editable extraParams=""> <#if editable> <@editLink propertyLocalName statement extraParams /> <@deleteLink propertyLocalName statement extraParams /> <#macro editLink propertyLocalName statement extraParams=""> <#local url = statement.editUrl> <#if url?has_content> <@showEditLink propertyLocalName addParamsToEditUrl(url, extraParams) /> <#macro showEditLink propertyLocalName url> edit <#macro deleteLink propertyLocalName statement extraParams=""> <#local url = statement.deleteUrl> <#if url?has_content> <@showDeleteLink propertyLocalName addParamsToEditUrl(url, extraParams) /> <#macro showDeleteLink propertyLocalName url> delete <#macro verboseDisplay property> <#local verboseDisplay = property.verboseDisplay!> <#if verboseDisplay?has_content>
    ${verboseDisplay.localName} (${property.type?lower_case} property); order in group: ${verboseDisplay.displayRank}; display level: ${verboseDisplay.displayLevel}; update level: ${verboseDisplay.updateLevel}
    <#----------------------------------------------------------------------------- Macros for specific properties ------------------------------------------------------------------------------> <#-- Image Values for showPlaceholder: "always", "never", "with_add_link" Note that this macro has a side-effect in the call to propertyGroups.pullProperty(). --> <#macro image individual propertyGroups namespaces editable showPlaceholder="never" placeholder=""> <#local mainImage = propertyGroups.pullProperty("${namespaces.vitroPublic}mainImage")!> <#local extraParams = ""> <#if placeholder?has_content> <#local extraParams = { "placeholder" : placeholder } > <#local thumbUrl = individual.thumbUrl!> <#-- Don't assume that if the mainImage property is populated, there is a thumbnail image (though that is the general case). If there's a mainImage statement but no thumbnail image, treat it as if there is no image. --> <#if (mainImage.statements)?has_content && thumbUrl?has_content> ${individual.name} <@editingLinks "${mainImage.localName}" mainImage.first() editable extraParams /> <#else> <#local imageLabel><@addLinkWithLabel mainImage editable "Photo" extraParams /> ${imageLabel} <#if placeholder?has_content> <#if showPlaceholder == "always" || (showPlaceholder="with_add_link" && imageLabel?has_content)> placeholder image <#-- Label --> <#macro label individual editable> <#local label = individual.nameStatement> ${label.value} <@editingLinks "label" label editable /> <#-- Most specific types --> <#macro mostSpecificTypes individual> <#list individual.mostSpecificTypes as type> ${type}