#**
 * Required context variables:
 *
 * $action      - the Webwork export action that is performing the export
 * $contentTree - the ContentTree to be displayed
 *#
 
#requireResource("confluence.web.resources:ajs")
#requireResource("confluence.sections.space.export.view:spaceexport")

#macro (displayPageHierarchyWithCheckboxes $contentTree $checkboxName)
    #foreach ($rootNode in $contentTree.getRootNodes())
        #displayPageHierarchyWithCheckboxesHelper($rootNode $checkboxName)
    #end
#end

#macro (displayPageHierarchyWithCheckboxesHelper $node $checkboxName)
    <li style="list-style:none">
        <input type="checkbox" name="$checkboxName" class="exportContentTreeCheckbox" value="$node.getPage().getId()" checked="checked" style="vertical-align: middle" />
        <label class="label">#contentLink2($node.getPage() false false)</label>
        #if (!$node.children.isEmpty())
            <a class="togglemeonlytreenode" href="#">&nbsp;</a>
        #end
        
        #foreach ($childNode in $node.children)
            <ul style="list-style:none">
            #displayPageHierarchyWithCheckboxesHelper($childNode $checkboxName)
            </ul>
        #end
    </li>
#end

<a id="checkAllLink" href="">$action.getText("check-all")</a>&nbsp;|&nbsp;<a id="clearAllLink" href="">$action.getText("clear-all")</a>
<ul id="exportContentTree">
    #displayPageHierarchyWithCheckboxes($contentTree 'contentToBeExported')
</ul>
