{{groovy}} def String addChildrenToContent(String parentDocName, String content, int level = 1) { parentDoc = xwiki.getDocument(parentDocName) extendedContent = content; toc = "" toc_counter[level - 1] = level == 1 ? 1 : toc_counter[level - 1] + 1 for (byte i = level; i<6; ++i) toc_counter[i] = 0 header_level_markup = "=" for (byte i=0; i>#H${toc}${ucMarkup}${cleanedTitle}-1]]" + header_level_markup + "\n" return toc } def String makeTOC(String parentDocName, int level = 1) { parentDoc = xwiki.getDocument(parentDocName) toc = " " toc = makeHeader(level) for (childName in parentDoc.getChildren()) { childDoc = xwiki.getDocument(childName) if (childDoc.getObject("MDCode.IncrementClass") == null) toc += makeTOC(childName,level+1) } return toc; } if (request.baselineName != null) { targetDocName = "BaselineHelperPage" if (xwiki.hasAccessLevel("edit", xcontext.getUser(), targetDocName)) { newDoc = xwiki.getDocument(targetDocName) newDoc.setTitle(request.baselineName) newDoc.setParent(doc.fullName) srsParentDoc = xwiki.getDocument("Polaris.SoftwareRequirementsSpecification") baselineContent = "" baselineContent = makeTOC(srsParentDoc.getFullName()) + addChildrenToContent(srsParentDoc.getFullName(), baselineContent) newDoc.setContent("") newDoc.setContent(baselineContent) newDoc.save("${request.baselineName}", true) response.sendRedirect(newDoc.getURL("view", "xpage=pdfoptions")) } else println "{{warning}}You don't have permission to create that document{{/warning}}" } {{/groovy}} {{html}}
{{/html}}