Allgemeine Aktionen:
Anmelden
Erstellen
▼
:
Kommentar erstellen
Wiki
▼
:
Dokumentenindex
»
Space:
AnnotationCode
▼
:
Dokumentenverzeichnis
»
Seite:
Macros
Suche
Aktionen:
Exportieren
▼
:
Als PDF exportieren
Als RTF exportieren
Als HTML exportieren
Weitere Aktionen
▼
:
Druckvorschau
Zeige den Quellcode
Willkommen in den metamagix Wikis!
»
WebHome
»
Macros
Wiki-Quellcode von
Macros
Zuletzt geändert von
Administrator
am 2010/04/22 19:27
Inhalt
·
Kommentare
(0)
·
Anmerkungen
(0)
·
Anhänge
(0)
·
Historie
·
Information
Zeilennummern verstecken
1: 2: {{velocity filter="none" output="false"}} 3: #set($restURL = "${request.contextPath}/rest") 4: ## Retrieve the annotation class from the configuration 5: #set($config = 'AnnotationCode.AnnotationConfig') 6: #set($annotationClassDocName = $xwiki.getDocument($config).getObject($config).getProperty('annotationClass').value) 7: #set($annotationClass = $xwiki.getDocument("$!{annotationClassDocName}").getxWikiClass()) 8: ## 9: ## 10: ## Do not display these 'internal' properties in the form: 11: #set($hiddenProperties = ['selection', 'selectionLeftContext', 'selectionRightContext', 'originalSelection', 'target', 'date', 'author', 'state', 'color']) 12: ## 13: ## 14: #* 15: * Display a box for creating an annotation 16: * 17: * @param $space the space of the annotated document 18: * @param $page the name of the annotated document 19: * @param $annData a map containing the mandatory selection-related fields 20: * @param $docWiki the wiki of the annotated document 21: * @param $docSpace the space of the annotated document 22: * @param $docPage the page of the annotated document 23: *# 24: #macro(displayCreateBox $docWiki $docSpace $docPage $annData) 25: <div class="annotation-box annotation-box-create"> 26: <form method="POST" action="${restURL}/wikis/${escapetool.url($docWiki)}/spaces/${escapetool.url($docSpace)}/pages/${escapetool.url($docPage)}/annotations?media=json"> 27: <div class="hidden"> 28: #foreach($field in $annData.keySet()) 29: <input type="hidden" name="${field}" value="$!{annData.get(${field})}"/> 30: #end 31: </div> 32: #displayAnnotation($annData, 'create') 33: #displayAnnotationBoxButtons('create') 34: </form> 35: </div> 36: #end 37: #* 38: * Display a box for editing an annotation 39: * 40: * @param $target the annotated entity identifier 41: * @param $id the annotation identifier 42: * @param $docWiki the wiki of the annotated document 43: * @param $docSpace the space of the annotated document 44: * @param $docPage the page of the annotated document 45: *# 46: #macro(displayEditBox $id $docWiki $docSpace $docPage) 47: ## TODO: unhardcode this reference generation here when document reference will be available in velo. Or build Annotation velocity API for xwiki 48: #set($ann = $annotations.getAnnotation("${docWiki}:${docSpace}.${docPage}", $id)) 49: <div class="annotation-box annotation-box-edit"> 50: #if($ann) 51: #set($editURL = "${restURL}/wikis/" + $escapetool.url($docWiki) + "/spaces/" + $escapetool.url($docSpace) + "/pages/" + $escapetool.url($docPage) + "/annotation/" + $escapetool.url($ann.id) + "?method=PUT&media=json") 52: <form method='POST' action="${editURL}"> 53: #displayAnnotation($ann, 'edit') 54: #displayAnnotationBoxButtons('edit') 55: </form> 56: #else 57: <div class="box infomessage">$msg.get("annotations.action.edit.error.notfound")</div> 58: #end 59: </div> 60: #end 61: #* 62: * Display a box containing the annotation 63: * 64: * @param $target the annotated entity identifier 65: * @param $id the annotation identifier 66: * @param $docWiki the wiki of the annotated document 67: * @param $docSpace the space of the annotated document 68: * @param $docPage the page of the annotated document 69: *# 70: #macro(displayViewBox $id $docWiki $docSpace $docPage) 71: ## TODO: unhardcode this reference generation here when document reference will be available in velo. Or build Annotation velocity API for xwiki 72: #set($ann = $annotations.getAnnotation("${docWiki}:${docSpace}.${docPage}", $id)) 73: <div class="annotation-box annotation-box-view"> 74: #if ($ann) 75: #*<div class="links"> 76: <a href="#" class='annotation-view-hide'>$msg.get("annotations.action.view.hide.text")</a> 77: </div>*# 78: ##<div class="clearfloats"></div> 79: #displayAnnotation($ann $mode $docWiki $docSpace $docPage) 80: #else 81: <div class="box infomessage">$msg.get("annotations.action.view.error.notfound")</div> 82: #end 83: </div> 84: #end 85: ## 86: ## 87: ## 88: #* 89: * Display form buttons 90: * 91: * @param $mode 'create' or 'edit' 92: *# 93: #macro(displayAnnotationBoxButtons $mode) 94: <div class="buttons"> 95: <span class='buttonwrapper'><input type="submit" class='button' value='$msg.get("annotations.action.${mode}.submit.text")'/></span> 96: <span class='buttonwrapper'><input type="reset" class='button' value='$msg.get("annotations.action.${mode}.cancel.text")'/></span> 97: </div> 98: #end 99: ## 100: ## 101: #** 102: * Display an annotation 103: * 104: * @param $ann the annotation object 105: * @param $mode view (default), list, create or edit 106: *# 107: #macro(displayAnnotation $ann $mode $docWiki $docSpace $docPage) 108: #if(!$listtool.contains(['view', 'list', 'create', 'edit'], "$!{mode}")) 109: #set($mode = 'view') 110: #end 111: <div class="annotation $!{ann.state}" id="annotation_${mode}_$!{ann.id}"> 112: <div class="annotationHeader"> 113: #displayAnnotationTitle($ann) 114: #displayAnnotationToolbox($ann $mode $docWiki $docSpace $docPage) 115: </div> 116: <div class="annotationContent"> 117: #displayAnnotationBody($ann $mode) 118: </div> 119: </div> 120: #end 121: ## 122: ## 123: #** 124: * Display the annotation title, containing author and date 125: * 126: * @param $ann the annotation object 127: *# 128: #macro(displayAnnotationTitle $ann) 129: <div class="annotationTitle"> 130: <span class="annotationAuthor">$!xwiki.getUserName($ann.author)</span>## 131: ## Do not indent this, or the comma will be misplaced 132: #if("$!{ann.date}" != '')<span class="sep">, </span><span class="annotationDate">$xwiki.formatDate($ann.date, "dd/MM/yyyy")</span>#end 133: </div> 134: #end 135: ## 136: ## 137: #** 138: * Display the annotation toolbox: 139: * - 'verify' button for modified annotations 140: * - 'edit' button for annotation authors and other users with edit rights, unless already editing 141: * - 'delete' button for annotation authors and other users with edit rights 142: * 143: * @param $ann the annotation object 144: * @param $mode view (default), list, create or edit 145: * @param $docWiki the wiki of the annotated document 146: * @param $docSpace the space of the annotated document 147: * @param $docPage the page of the annotated document 148: *# 149: #macro(displayAnnotationToolbox $ann $mode $docWiki $docSpace $docPage) 150: <span class="annotationTools"> 151: #if($mode != 'create' && $annotations.canEditAnnotation($ann.id, $docWiki, $docSpace, $docPage)) 152: #set($editURL = "${restURL}/wikis/" + $escapetool.url($docWiki) + "/spaces/" + $escapetool.url($docSpace) + "/pages/" + $escapetool.url($docPage) + "/annotation/" + $escapetool.url($ann.id) + "?method=PUT&media=json") 153: #if ("$!{ann.state}" == 'UPDATED') 154: <span class="tool accept"><a class="validate" href="${editURL}" title="$msg.get('annotations.action.validate.tooltip')">$msg.get('annotations.action.validate.text')</a></span> 155: #end 156: #if ($mode != 'edit') 157: ## use an edit url just for the fanciness of it, it won't really be used in this case. An edit form will be loaded 158: <span class="tool annotationEdit"><a class="edit" href="${editURL}" title="$msg.get('annotations.action.edit.tooltip')">$msg.get('annotations.action.edit.text')</a></span> 159: #end 160: #set($deleteURL = "${restURL}/wikis/" + $escapetool.url($docWiki) + "/spaces/" + $escapetool.url($docSpace) + "/pages/" + $escapetool.url($docPage) + "/annotation/" + $escapetool.url($ann.id) + "?method=DELETE&media=json") 161: <span class="tool delete"><a class="delete" href="${deleteURL}" title="$msg.get('annotations.action.delete.tooltip')">$msg.get('annotations.action.delete.text')</a></span> 162: #end 163: </span> 164: #end 165: ## 166: ## 167: #** 168: * Display the annotation body, containing all but the hidden fields. 169: * For annotation lists (which are not displayed near the actual annotation text), also display 170: * in a block quote the corresponding annotated extract. 171: * Depending on the mode, display for each field label + input (edit, create) or the field value (view, list). 172: * 173: * @param $ann the annotation object 174: * @param $mode view (default), list, create or edit 175: *# 176: #macro(displayAnnotationBody $ann $mode) 177: #if ($mode == 'list') 178: #if ($ann.state == 'ALTERED') 179: <div class="annotationOriginalSelection">$msg.get("annotations.altered.text")</div> 180: #end 181: <blockquote class="annotatedText">$ann.selection</blockquote> 182: #end 183: ## in view mode and list mode, also display the original selection of this annotation 184: #if (($mode == 'view' || $mode == 'list') && $ann.state == 'UPDATED') 185: <div class="annotationOriginalSelection">$msg.get("annotations.updated.text")</div> 186: <blockquote class="annotatedText originalAnnotatedText">$ann.originalSelection</blockquote> 187: #end 188: ## Fake object that allows to use the API to generate the display 189: #set($fakeObj = $doc.newObject($annotationClassDocName)) 190: #set($properties = $annotationClass.properties) 191: <dl> 192: #foreach($prop in $properties) 193: #if (!$listtool.contains($hiddenProperties, $prop.name)) 194: #set($discard = $fakeObj.set($prop.name, "$!{ann.get($prop.name)}")) 195: <dt class="annotationLabel"><label for="$prop.name">$prop.prettyName</label></dt> 196: #if($mode == 'edit' || $mode == 'create') 197: <dd>$doc.displayEdit($prop, "" , $fakeObj)</dd> 198: #else 199: <dd>$doc.displayView($prop, "" , $fakeObj)</dd> 200: #end 201: #end 202: #end 203: </dl> 204: #end 205: {{/velocity}}