Allgemeine Aktionen:
Anmelden
Registrieren
Start ▼: Wiki Verzeichnis
»
Bereich: XWiki
»
Seite: XWikiSyntax
default
Aktionen:
Exportieren ▼: Als PDF exportieren Als RTF exportieren Als HTML exportieren
Weitere Aktionen ▼: Druckvorschau Zeige den Quellcode
Willkommen bei bytebang » XWiki Syntax Hilfe

# Wiki-Quellcode von XWiki Syntax Hilfe

Zuletzt geändert von Administrator am 2014/06/29 19:30
Anhänge (0) · Information
Zeilennummern anzeigen {{velocity output="false"}} #set($SUPPORTED_SYNTAXES = {}) #set($void = $SUPPORTED_SYNTAXES.put(1.0, 'XWiki Syntax 1.0')) #set($void = $SUPPORTED_SYNTAXES.put(2.0, 'XWiki Syntax 2.0')) #set($void = $SUPPORTED_SYNTAXES.put(2.1, 'XWiki Syntax 2.1')) #if ($request.xaction == 'switchContext') $response.sendRedirect($request.target) #stop #end #set ($crtCategoryId = "$!{request.category}") #if ($crtCategoryId != '') #set ($crtCategoryId = $mathtool.toInteger($crtCategoryId)) #end #set ($crtSectionId = "$!{request.section}") #set ($crtSyntaxVer = $mathtool.toDouble($request.syntax)) #if ($crtSyntaxVer && $SUPPORTED_SYNTAXES.containsKey($crtSyntaxVer)) #set ($crtSyntaxVer = $mathtool.toDouble($crtSyntaxVer)) #else #set ($crtSyntaxVer = 2.1) ## Default to Syntax 2.1 #end #set ($extraParamList = []) #if ($request.language) #set ($discard = $extraParamList.add("language=$escapetool.url($request.language)")) #end #if ($request.xpage) #set ($discard = $extraParamList.add("xpage=$escapetool.url($request.xpage)")) #end #if ($extraParamList.isEmpty()) #set ($extraParams = '') #else #set ($extraParams = '&'+$stringtool.join($extraParamList,'&')) #end ## ## Syntax menu map ## #set($syntaxMenu = []) #set($catCount = -1) #set($catName = "") #set($catChildren = []) #set($results = $services.query.xwql('from doc.object(XWiki.XWikiSyntaxClass) as syntax order by syntax.category, syntax.section').addFilter('currentlanguage').execute()) #if($results.empty) No syntax sections found! #else #foreach ($item in $results) #set($sectionDoc = $xwiki.getDocument($item)) #set($obj = $sectionDoc.getObject("XWiki.XWikiSyntaxClass")) #set($sectionOrigList = $sectionDoc.getSections()) #set($sectionList = $sectionDoc.getTranslatedDocument().getSections()) ## Get catName for first category #if($catCount == -1) #set($catCount = $catCount + 1) #set($catId = $sectionOrigList.get(0).getSectionTitle()) #set($catName = $sectionList.get(0).getSectionTitle()) ## Put previous category into map, get new catName and reset children map #elseif($catCount < $obj.getProperty("category").value) #set($cat = { 'id' : $catId.toLowerCase(), 'name' : $catName, 'children' : $catChildren }) $syntaxMenu.add($cat) #set($catCount = $catCount + 1) #set($catId = $sectionOrigList.get(0).getSectionTitle()) #set($catName = $sectionList.get(0).getSectionTitle()) #set($catChildren = []) #end ## Add new sections to children map #set($child = {'id' : $sectionDoc.getName().substring(11), 'minSyntax' : $obj.getProperty("minSyntaxVersion").value, 'maxSyntax' : $obj.getProperty("maxSyntaxVersion").value, 'name' : $sectionList.get(1).getSectionTitle()}) $catChildren.add($child) #end #end #set($cat = { 'id' : $catId.toLowerCase(), 'name' : $catName, 'children' : $catChildren }) $syntaxMenu.add($cat) ## ## Filter only the sections that are valid for a Syntax ## #set ($categoriesToRemove = []) #foreach ($category in $syntaxMenu) #set ($sectionsToRemove = []) #foreach ($section on $category.children) #if ($section.minSyntax > $crtSyntaxVer) #set ($discard = $sectionsToRemove.add($section)) #if ($section.id == $crtSectionId) #set ($crtSectionId = '') ## clear section if it doesn't exist (can happen when switching from 2.0 to 2.1 syntax) #end #end #end #set ($discard = $category.children.removeAll($sectionsToRemove)) #if ($category.children.size() == 0) #set ($discard = $categoriesToRemove.add($category)) #end #end #set ($discard = $syntaxMenu.removeAll($categoriesToRemove)) #if ("$!crtCategoryId" != '' && $crtCategoryId >= $syntaxMenu.size()) #set ($crtCategoryId = '') #end #if ($crtSectionId != '') #set ($crtItemId = $crtSectionId) #elseif ($crtCategoryId != '') #set ($crtItemId = $syntaxMenu.get($crtCategoryId).id) #end #set ($crtSection = $util.null) #set ($crtCategory = $util.null) ## ## Prepare the Syntax menu map for processing ## #foreach ($category in $syntaxMenu) ## "Standard" URLs and icons for categories #set ($category.url = "?syntax=$escapetool.url(${crtSyntaxVer})&category=${mathtool.sub($velocityCount, 1)}${extraParams}") #set ($category.cssClass = "${category.id}Icon") #if ("$!{crtCategoryId}" != '' && $velocityCount == $mathtool.add($crtCategoryId, 1)) #set ($crtCategory = $category) #end ## ## Process each syntax section #foreach ($section in $category.children) #if ($xwiki.exists("XWiki.XWikiSyntax${section.id}")) #if ($crtSectionId == $section.id) #set ($crtSection = $section) #set ($crtCategory = $category) #end #set ($section.url = "?syntax=$escapetool.url(${crtSyntaxVer})&section=$escapetool.url(${section.id})${extraParams}") #end #end #end #** * Displays the sections from a syntax category * * Expected format: * sections = vector of items * item = map with the following fields: * 'id' : mandatory * 'name' : the text displayed for the corresponding menu item; * optional, defaults to * $services.localization.render("$!{translationPrefix}${item.id}") * * @param $sections the sections list, in the format described above * @param $translationPrefix the translation prefix added to the id of each * item, in order to generate the name and description; ignored when * name or description are specified * @param $heading the heading syntax *# #macro(syntax_displayCategory $sections $translationPrefix $heading) #foreach ($section in $sections) #set ($displayVersion = $crtSyntaxVer) #if ($crtSyntaxVer > $section.maxSyntax) #set ($displayVersion = $section.maxSyntax) #end (% class="sectionheader" %) $heading $section.name $heading {{include reference="XWiki.XWikiSyntax${section.id}" section="H${displayVersion}${section.id}"/}} #end #end #** * Displays the syntax categories * * Expected format: * sections = vector of items * item = map with the following fields: * 'id' : mandatory * 'name' : the text displayed for the corresponding menu item; * optional, defaults to * $services.localization.render("$!{translationPrefix}${item.id}") * * @param $sections the sections list, in the format described above * @param $translationPrefix the translation prefix added to the id of each * item, in order to generate the name and description; ignored when * name or description are specified *# #macro(syntax_displayCategories $syntaxMenu $translationPrefix) #set ($subHeading = '====') #foreach ($category in $syntaxMenu) == $category.name == #syntax_displayCategory($category.children 'syntax.' '===') #end #end #** * Displays the drop down allowing to switch the syntax. *# #macro (syntaxSwitch) #set ($crtSelection = "") #if ("$!{crtCategoryId}" != '') #set ($crtSelection = "category=$escapetool.url($!{crtCategoryId})") #elseif ($crtSectionId != '') #set ($crtSelection = "section=$escapetool.url($!{crtSectionId})") #end #if ($crtSelection != "") #set ($crtSelection = "${crtSelection}${extraParams}") #else #set ($crtSelection = "$extraParams") #end {{html}} <form id="change-context" class="xformInline" action=""> <div> <input type="hidden" name="xaction" value="switchContext" /> #if ($request.language) <input type="hidden" name="language" value="$escapetool.xml($request.language)" /> #end #if ($request.xpage) <input type="hidden" name="xpage" value="$escapetool.xml($request.xpage)" /> #end <select id="goto-select" name="target" title="$escapetool.xml($services.localization.render("help.changesyntax"))"> <optgroup label="$services.localization.render('help.choose_syntax')"> #set ($query = "syntax=1.0&${crtSelection}") <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==1.0)selected="selected"#end>$SUPPORTED_SYNTAXES.get(1.0)</option> #set ($query = "syntax=2.0&${crtSelection}") <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==2.0)selected="selected"#end>$SUPPORTED_SYNTAXES.get(2.0)</option> #set ($query = "syntax=2.1&${crtSelection}") <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==2.1)selected="selected"#end>$SUPPORTED_SYNTAXES.get(2.1)</option> </optgroup> </select> <span class="buttonwrapper"><input type="submit" value="$escapetool.xml($services.localization.render('admin.switchContext'))" class="button" /></span> </div> </form> {{/html}} #end {{/velocity}} {{velocity}} ##************************************************************************************************** ## From the Administration Sheet, used to display a common UI for some wiki features ## here used to display all categories / sections of the syntax guide ##************************************************************************************************** $xwiki.get('jsx').use($doc.getFullName())## $xwiki.get('ssx').use($doc.getFullName())## #if ($crtSectionId != '') #set ($sectionName = ${crtSection.name}) #elseif ($crtCategoryId != '') #set ($sectionName = ${crtCategory.name}) #else #set ($sectionName = $services.localization.render("help.syntaxall")) #end #set ($syntaxTitle = $services.localization.render("help.syntaxtitle", ["${crtSyntaxVer}"])) #syntaxSwitch() ((( #set ($query = "syntax=$escapetool.url(${crtSyntaxVer})${extraParams}") #if ($crtCategory){{html}}<a href="${doc.getURL('view', ${query})}">$syntaxTitle</a>{{/html}}#{else}(% class="current" %)$syntaxTitle#{end}#if ($crtCategory) (% class="separator" %)» #if ($crtSection){{html}}<a href="${crtCategory.url}">${crtCategory.name}</a>{{/html}}#{else}(% class="current" %)${crtCategory.name}#{end}#if ($crtSection) (% class="separator" %)» (% class="current" %)${crtSection.name}#end#end ))) == $syntaxTitle: $sectionName == #verticalNavigation($syntaxMenu {'translationPrefix' : 'syntax.', 'crtItemId' : "$!crtItemId", 'cssClass' : 'syntax-menu'}) ##----------------------------------------- ## syntax-page display ##----------------------------------------- (% id="syntax-page-content" %)((( #if(!$crtSection && !$crtCategory) #syntax_displayCategories($syntaxMenu 'syntax.') #elseif (!$crtSection) #set ($subHeading = '===') #syntax_displayCategory($crtCategory.children 'syntax.' '==') #else #set ($displayVersion = $crtSyntaxVer) #if ($crtSyntaxVer > $crtSection.maxSyntax) #set ($displayVersion = $crtSection.maxSyntax) #end #set ($subHeading = '==') {{include reference="XWiki.XWikiSyntax${crtSection.id}" section="H${displayVersion}${crtSection.id}"/}} #end ))) ## syntax-page-content {{/velocity}}

(c) 2025, by bytebang e.U. - Impressum - Datenschutz / Nutzungsbedingungen
-