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 verstecken 1: {{velocity output="false"}} 2: #set($SUPPORTED_SYNTAXES = {}) 3: #set($void = $SUPPORTED_SYNTAXES.put(1.0, 'XWiki Syntax 1.0')) 4: #set($void = $SUPPORTED_SYNTAXES.put(2.0, 'XWiki Syntax 2.0')) 5: #set($void = $SUPPORTED_SYNTAXES.put(2.1, 'XWiki Syntax 2.1')) 6: 7: #if ($request.xaction == 'switchContext') 8: $response.sendRedirect($request.target) 9: #stop 10: #end 11: 12: #set ($crtCategoryId = "$!{request.category}") 13: #if ($crtCategoryId != '') 14: #set ($crtCategoryId = $mathtool.toInteger($crtCategoryId)) 15: #end 16: #set ($crtSectionId = "$!{request.section}") 17: #set ($crtSyntaxVer = $mathtool.toDouble($request.syntax)) 18: #if ($crtSyntaxVer && $SUPPORTED_SYNTAXES.containsKey($crtSyntaxVer)) 19: #set ($crtSyntaxVer = $mathtool.toDouble($crtSyntaxVer)) 20: 21: #else 22: #set ($crtSyntaxVer = 2.1) ## Default to Syntax 2.1 23: #end 24: 25: #set ($extraParamList = []) 26: #if ($request.language) 27: #set ($discard = $extraParamList.add("language=$escapetool.url($request.language)")) 28: #end 29: #if ($request.xpage) 30: #set ($discard = $extraParamList.add("xpage=$escapetool.url($request.xpage)")) 31: #end 32: #if ($extraParamList.isEmpty()) 33: #set ($extraParams = '') 34: #else 35: #set ($extraParams = '&'+$stringtool.join($extraParamList,'&')) 36: #end 37: 38: ## 39: ## Syntax menu map 40: ## 41: #set($syntaxMenu = []) 42: #set($catCount = -1) 43: #set($catName = "") 44: #set($catChildren = []) 45: #set($results = $services.query.xwql('from doc.object(XWiki.XWikiSyntaxClass) as syntax order by syntax.category, syntax.section').addFilter('currentlanguage').execute()) 46: 47: #if($results.empty) 48: No syntax sections found! 49: #else 50: #foreach ($item in $results) 51: #set($sectionDoc = $xwiki.getDocument($item)) 52: #set($obj = $sectionDoc.getObject("XWiki.XWikiSyntaxClass")) 53: #set($sectionOrigList = $sectionDoc.getSections()) 54: #set($sectionList = $sectionDoc.getTranslatedDocument().getSections()) 55: 56: ## Get catName for first category 57: #if($catCount == -1) 58: #set($catCount = $catCount + 1) 59: #set($catId = $sectionOrigList.get(0).getSectionTitle()) 60: #set($catName = $sectionList.get(0).getSectionTitle()) 61: 62: ## Put previous category into map, get new catName and reset children map 63: #elseif($catCount < $obj.getProperty("category").value) 64: #set($cat = { 'id' : $catId.toLowerCase(), 'name' : $catName, 'children' : $catChildren }) 65: $syntaxMenu.add($cat) 66: #set($catCount = $catCount + 1) 67: #set($catId = $sectionOrigList.get(0).getSectionTitle()) 68: #set($catName = $sectionList.get(0).getSectionTitle()) 69: #set($catChildren = []) 70: #end 71: 72: ## Add new sections to children map 73: #set($child = {'id' : $sectionDoc.getName().substring(11), 'minSyntax' : $obj.getProperty("minSyntaxVersion").value, 'maxSyntax' : $obj.getProperty("maxSyntaxVersion").value, 'name' : $sectionList.get(1).getSectionTitle()}) 74: $catChildren.add($child) 75: #end 76: #end 77: #set($cat = { 'id' : $catId.toLowerCase(), 'name' : $catName, 'children' : $catChildren }) 78: $syntaxMenu.add($cat) 79: 80: 81: ## 82: ## Filter only the sections that are valid for a Syntax 83: ## 84: #set ($categoriesToRemove = []) 85: #foreach ($category in $syntaxMenu) 86: #set ($sectionsToRemove = []) 87: #foreach ($section on $category.children) 88: #if ($section.minSyntax > $crtSyntaxVer) 89: #set ($discard = $sectionsToRemove.add($section)) 90: #if ($section.id == $crtSectionId) 91: #set ($crtSectionId = '') ## clear section if it doesn't exist (can happen when switching from 2.0 to 2.1 syntax) 92: #end 93: #end 94: #end 95: #set ($discard = $category.children.removeAll($sectionsToRemove)) 96: #if ($category.children.size() == 0) 97: #set ($discard = $categoriesToRemove.add($category)) 98: #end 99: #end 100: #set ($discard = $syntaxMenu.removeAll($categoriesToRemove)) 101: #if ("$!crtCategoryId" != '' && $crtCategoryId >= $syntaxMenu.size()) 102: #set ($crtCategoryId = '') 103: #end 104: 105: #if ($crtSectionId != '') 106: #set ($crtItemId = $crtSectionId) 107: #elseif ($crtCategoryId != '') 108: #set ($crtItemId = $syntaxMenu.get($crtCategoryId).id) 109: #end 110: #set ($crtSection = $util.null) 111: #set ($crtCategory = $util.null) 112: 113: 114: ## 115: ## Prepare the Syntax menu map for processing 116: ## 117: #foreach ($category in $syntaxMenu) 118: ## "Standard" URLs and icons for categories 119: #set ($category.url = "?syntax=$escapetool.url(${crtSyntaxVer})&category=${mathtool.sub($velocityCount, 1)}${extraParams}") 120: #set ($category.cssClass = "${category.id}Icon") 121: #if ("$!{crtCategoryId}" != '' && $velocityCount == $mathtool.add($crtCategoryId, 1)) 122: #set ($crtCategory = $category) 123: #end 124: ## 125: ## Process each syntax section 126: #foreach ($section in $category.children) 127: #if ($xwiki.exists("XWiki.XWikiSyntax${section.id}")) 128: #if ($crtSectionId == $section.id) 129: #set ($crtSection = $section) 130: #set ($crtCategory = $category) 131: #end 132: #set ($section.url = "?syntax=$escapetool.url(${crtSyntaxVer})&section=$escapetool.url(${section.id})${extraParams}") 133: #end 134: #end 135: #end 136: 137: #** 138: * Displays the sections from a syntax category 139: * 140: * Expected format: 141: * sections = vector of items 142: * item = map with the following fields: 143: * 'id' : mandatory 144: * 'name' : the text displayed for the corresponding menu item; 145: * optional, defaults to 146: * $services.localization.render("$!{translationPrefix}${item.id}") 147: * 148: * @param $sections the sections list, in the format described above 149: * @param $translationPrefix the translation prefix added to the id of each 150: * item, in order to generate the name and description; ignored when 151: * name or description are specified 152: * @param $heading the heading syntax 153: *# 154: #macro(syntax_displayCategory $sections $translationPrefix $heading) 155: #foreach ($section in $sections) 156: #set ($displayVersion = $crtSyntaxVer) 157: #if ($crtSyntaxVer > $section.maxSyntax) 158: #set ($displayVersion = $section.maxSyntax) 159: #end 160: (% class="sectionheader" %) 161: $heading $section.name $heading 162: 163: {{include reference="XWiki.XWikiSyntax${section.id}" section="H${displayVersion}${section.id}"/}} 164: #end 165: #end 166: 167: 168: #** 169: * Displays the syntax categories 170: * 171: * Expected format: 172: * sections = vector of items 173: * item = map with the following fields: 174: * 'id' : mandatory 175: * 'name' : the text displayed for the corresponding menu item; 176: * optional, defaults to 177: * $services.localization.render("$!{translationPrefix}${item.id}") 178: * 179: * @param $sections the sections list, in the format described above 180: * @param $translationPrefix the translation prefix added to the id of each 181: * item, in order to generate the name and description; ignored when 182: * name or description are specified 183: *# 184: #macro(syntax_displayCategories $syntaxMenu $translationPrefix) 185: #set ($subHeading = '====') 186: #foreach ($category in $syntaxMenu) 187: == $category.name == 188: 189: #syntax_displayCategory($category.children 'syntax.' '===') 190: #end 191: #end 192: 193: #** 194: * Displays the drop down allowing to switch the syntax. 195: *# 196: #macro (syntaxSwitch) 197: #set ($crtSelection = "") 198: #if ("$!{crtCategoryId}" != '') 199: #set ($crtSelection = "category=$escapetool.url($!{crtCategoryId})") 200: #elseif ($crtSectionId != '') 201: #set ($crtSelection = "section=$escapetool.url($!{crtSectionId})") 202: #end 203: #if ($crtSelection != "") 204: #set ($crtSelection = "${crtSelection}${extraParams}") 205: #else 206: #set ($crtSelection = "$extraParams") 207: #end 208: {{html}} 209: <form id="change-context" class="xformInline" action=""> 210: <div> 211: <input type="hidden" name="xaction" value="switchContext" /> 212: #if ($request.language) 213: <input type="hidden" name="language" value="$escapetool.xml($request.language)" /> 214: #end 215: #if ($request.xpage) 216: <input type="hidden" name="xpage" value="$escapetool.xml($request.xpage)" /> 217: #end 218: <select id="goto-select" name="target" title="$escapetool.xml($services.localization.render("help.changesyntax"))"> 219: <optgroup label="$services.localization.render('help.choose_syntax')"> 220: #set ($query = "syntax=1.0&${crtSelection}") 221: <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==1.0)selected="selected"#end>$SUPPORTED_SYNTAXES.get(1.0)</option> 222: #set ($query = "syntax=2.0&${crtSelection}") 223: <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==2.0)selected="selected"#end>$SUPPORTED_SYNTAXES.get(2.0)</option> 224: #set ($query = "syntax=2.1&${crtSelection}") 225: <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==2.1)selected="selected"#end>$SUPPORTED_SYNTAXES.get(2.1)</option> 226: </optgroup> 227: </select> 228: <span class="buttonwrapper"><input type="submit" value="$escapetool.xml($services.localization.render('admin.switchContext'))" class="button" /></span> 229: </div> 230: </form> 231: {{/html}} 232: #end 233: {{/velocity}} 234: 235: {{velocity}} 236: ##************************************************************************************************** 237: ## From the Administration Sheet, used to display a common UI for some wiki features 238: ## here used to display all categories / sections of the syntax guide 239: ##************************************************************************************************** 240: $xwiki.get('jsx').use($doc.getFullName())## 241: $xwiki.get('ssx').use($doc.getFullName())## 242: #if ($crtSectionId != '') 243: #set ($sectionName = ${crtSection.name}) 244: #elseif ($crtCategoryId != '') 245: #set ($sectionName = ${crtCategory.name}) 246: #else 247: #set ($sectionName = $services.localization.render("help.syntaxall")) 248: #end 249: #set ($syntaxTitle = $services.localization.render("help.syntaxtitle", ["${crtSyntaxVer}"])) 250: #syntaxSwitch() 251: ((( 252: #set ($query = "syntax=$escapetool.url(${crtSyntaxVer})${extraParams}") 253: #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 254: ))) 255: == $syntaxTitle: $sectionName == 256: 257: #verticalNavigation($syntaxMenu {'translationPrefix' : 'syntax.', 'crtItemId' : "$!crtItemId", 'cssClass' : 'syntax-menu'}) 258: ##----------------------------------------- 259: ## syntax-page display 260: ##----------------------------------------- 261: (% id="syntax-page-content" %)((( 262: #if(!$crtSection && !$crtCategory) 263: #syntax_displayCategories($syntaxMenu 'syntax.') 264: #elseif (!$crtSection) 265: #set ($subHeading = '===') 266: #syntax_displayCategory($crtCategory.children 'syntax.' '==') 267: #else 268: #set ($displayVersion = $crtSyntaxVer) 269: #if ($crtSyntaxVer > $crtSection.maxSyntax) 270: #set ($displayVersion = $crtSection.maxSyntax) 271: #end 272: #set ($subHeading = '==') 273: {{include reference="XWiki.XWikiSyntax${crtSection.id}" section="H${displayVersion}${crtSection.id}"/}} 274: #end 275: ))) ## syntax-page-content 276: {{/velocity}}

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