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 anzeigen
{{velocity filter="none" output="false"}} #set($restURL = "${request.contextPath}/rest") ## Retrieve the annotation class from the configuration #set($config = 'AnnotationCode.AnnotationConfig') #set($annotationClassDocName = $xwiki.getDocument($config).getObject($config).getProperty('annotationClass').value) #set($annotationClass = $xwiki.getDocument("$!{annotationClassDocName}").getxWikiClass()) ## ## ## Do not display these 'internal' properties in the form: #set($hiddenProperties = ['selection', 'selectionLeftContext', 'selectionRightContext', 'originalSelection', 'target', 'date', 'author', 'state', 'color']) ## ## #* * Display a box for creating an annotation * * @param $space the space of the annotated document * @param $page the name of the annotated document * @param $annData a map containing the mandatory selection-related fields * @param $docWiki the wiki of the annotated document * @param $docSpace the space of the annotated document * @param $docPage the page of the annotated document *# #macro(displayCreateBox $docWiki $docSpace $docPage $annData) <div class="annotation-box annotation-box-create"> <form method="POST" action="${restURL}/wikis/${escapetool.url($docWiki)}/spaces/${escapetool.url($docSpace)}/pages/${escapetool.url($docPage)}/annotations?media=json"> <div class="hidden"> #foreach($field in $annData.keySet()) <input type="hidden" name="${field}" value="$!{annData.get(${field})}"/> #end </div> #displayAnnotation($annData, 'create') #displayAnnotationBoxButtons('create') </form> </div> #end #* * Display a box for editing an annotation * * @param $target the annotated entity identifier * @param $id the annotation identifier * @param $docWiki the wiki of the annotated document * @param $docSpace the space of the annotated document * @param $docPage the page of the annotated document *# #macro(displayEditBox $id $docWiki $docSpace $docPage) ## TODO: unhardcode this reference generation here when document reference will be available in velo. Or build Annotation velocity API for xwiki #set($ann = $annotations.getAnnotation("${docWiki}:${docSpace}.${docPage}", $id)) <div class="annotation-box annotation-box-edit"> #if($ann) #set($editURL = "${restURL}/wikis/" + $escapetool.url($docWiki) + "/spaces/" + $escapetool.url($docSpace) + "/pages/" + $escapetool.url($docPage) + "/annotation/" + $escapetool.url($ann.id) + "?method=PUT&media=json") <form method='POST' action="${editURL}"> #displayAnnotation($ann, 'edit') #displayAnnotationBoxButtons('edit') </form> #else <div class="box infomessage">$msg.get("annotations.action.edit.error.notfound")</div> #end </div> #end #* * Display a box containing the annotation * * @param $target the annotated entity identifier * @param $id the annotation identifier * @param $docWiki the wiki of the annotated document * @param $docSpace the space of the annotated document * @param $docPage the page of the annotated document *# #macro(displayViewBox $id $docWiki $docSpace $docPage) ## TODO: unhardcode this reference generation here when document reference will be available in velo. Or build Annotation velocity API for xwiki #set($ann = $annotations.getAnnotation("${docWiki}:${docSpace}.${docPage}", $id)) <div class="annotation-box annotation-box-view"> #if ($ann) #*<div class="links"> <a href="#" class='annotation-view-hide'>$msg.get("annotations.action.view.hide.text")</a> </div>*# ##<div class="clearfloats"></div> #displayAnnotation($ann $mode $docWiki $docSpace $docPage) #else <div class="box infomessage">$msg.get("annotations.action.view.error.notfound")</div> #end </div> #end ## ## ## #* * Display form buttons * * @param $mode 'create' or 'edit' *# #macro(displayAnnotationBoxButtons $mode) <div class="buttons"> <span class='buttonwrapper'><input type="submit" class='button' value='$msg.get("annotations.action.${mode}.submit.text")'/></span> <span class='buttonwrapper'><input type="reset" class='button' value='$msg.get("annotations.action.${mode}.cancel.text")'/></span> </div> #end ## ## #** * Display an annotation * * @param $ann the annotation object * @param $mode view (default), list, create or edit *# #macro(displayAnnotation $ann $mode $docWiki $docSpace $docPage) #if(!$listtool.contains(['view', 'list', 'create', 'edit'], "$!{mode}")) #set($mode = 'view') #end <div class="annotation $!{ann.state}" id="annotation_${mode}_$!{ann.id}"> <div class="annotationHeader"> #displayAnnotationTitle($ann) #displayAnnotationToolbox($ann $mode $docWiki $docSpace $docPage) </div> <div class="annotationContent"> #displayAnnotationBody($ann $mode) </div> </div> #end ## ## #** * Display the annotation title, containing author and date * * @param $ann the annotation object *# #macro(displayAnnotationTitle $ann) <div class="annotationTitle"> <span class="annotationAuthor">$!xwiki.getUserName($ann.author)</span>## ## Do not indent this, or the comma will be misplaced #if("$!{ann.date}" != '')<span class="sep">, </span><span class="annotationDate">$xwiki.formatDate($ann.date, "dd/MM/yyyy")</span>#end </div> #end ## ## #** * Display the annotation toolbox: * - 'verify' button for modified annotations * - 'edit' button for annotation authors and other users with edit rights, unless already editing * - 'delete' button for annotation authors and other users with edit rights * * @param $ann the annotation object * @param $mode view (default), list, create or edit * @param $docWiki the wiki of the annotated document * @param $docSpace the space of the annotated document * @param $docPage the page of the annotated document *# #macro(displayAnnotationToolbox $ann $mode $docWiki $docSpace $docPage) <span class="annotationTools"> #if($mode != 'create' && $annotations.canEditAnnotation($ann.id, $docWiki, $docSpace, $docPage)) #set($editURL = "${restURL}/wikis/" + $escapetool.url($docWiki) + "/spaces/" + $escapetool.url($docSpace) + "/pages/" + $escapetool.url($docPage) + "/annotation/" + $escapetool.url($ann.id) + "?method=PUT&media=json") #if ("$!{ann.state}" == 'UPDATED') <span class="tool accept"><a class="validate" href="${editURL}" title="$msg.get('annotations.action.validate.tooltip')">$msg.get('annotations.action.validate.text')</a></span> #end #if ($mode != 'edit') ## 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 <span class="tool annotationEdit"><a class="edit" href="${editURL}" title="$msg.get('annotations.action.edit.tooltip')">$msg.get('annotations.action.edit.text')</a></span> #end #set($deleteURL = "${restURL}/wikis/" + $escapetool.url($docWiki) + "/spaces/" + $escapetool.url($docSpace) + "/pages/" + $escapetool.url($docPage) + "/annotation/" + $escapetool.url($ann.id) + "?method=DELETE&media=json") <span class="tool delete"><a class="delete" href="${deleteURL}" title="$msg.get('annotations.action.delete.tooltip')">$msg.get('annotations.action.delete.text')</a></span> #end </span> #end ## ## #** * Display the annotation body, containing all but the hidden fields. * For annotation lists (which are not displayed near the actual annotation text), also display * in a block quote the corresponding annotated extract. * Depending on the mode, display for each field label + input (edit, create) or the field value (view, list). * * @param $ann the annotation object * @param $mode view (default), list, create or edit *# #macro(displayAnnotationBody $ann $mode) #if ($mode == 'list') #if ($ann.state == 'ALTERED') <div class="annotationOriginalSelection">$msg.get("annotations.altered.text")</div> #end <blockquote class="annotatedText">$ann.selection</blockquote> #end ## in view mode and list mode, also display the original selection of this annotation #if (($mode == 'view' || $mode == 'list') && $ann.state == 'UPDATED') <div class="annotationOriginalSelection">$msg.get("annotations.updated.text")</div> <blockquote class="annotatedText originalAnnotatedText">$ann.originalSelection</blockquote> #end ## Fake object that allows to use the API to generate the display #set($fakeObj = $doc.newObject($annotationClassDocName)) #set($properties = $annotationClass.properties) <dl> #foreach($prop in $properties) #if (!$listtool.contains($hiddenProperties, $prop.name)) #set($discard = $fakeObj.set($prop.name, "$!{ann.get($prop.name)}")) <dt class="annotationLabel"><label for="$prop.name">$prop.prettyName</label></dt> #if($mode == 'edit' || $mode == 'create') <dd>$doc.displayEdit($prop, "" , $fakeObj)</dd> #else <dd>$doc.displayView($prop, "" , $fakeObj)</dd> #end #end #end </dl> #end {{/velocity}}