Created
April 12, 2013 09:40
-
-
Save inhji/5370866 to your computer and use it in GitHub Desktop.
XWiki Tagging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#set($sql = ", BaseObject as obj where obj.name = doc.fullName and obj.className = 'TagList.TagsClass' and obj.name <> 'TagList.TagsTemplate'") | |
#set($results = $xwiki.searchDocuments($sql)) | |
#set($predefinedTags = []) | |
#if(!$results.empty) | |
#foreach ($item in $results) | |
#set($tag = $xwiki.getDocument($item)) | |
#set($obj = $tag.getObject("TagList.TagsClass")) | |
#set($prop = $obj.get("tag")) | |
#set($foo = $predefinedTags.add($prop)) | |
#end | |
#end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{velocity}} | |
#if("$!request.docName" != '') | |
## Request for creating a new instance | |
#set($docName = $util.clearName(${request.docName})) | |
#set($targetDocName = "${request.spaceName}.${docName}") | |
#if(!$xwiki.exists($targetDocName) && $xwiki.hasAccessLevel('edit', $context.user, $targetDocName)) | |
##Testing creating a document programatically | |
#set($newDoc = $xwiki.getDocument($targetDocName)) | |
##Set a title | |
$newDoc.setTitle("{$docName}") | |
##Not necessary but good to know | |
$newDoc.setParent("${targetDocName}.WebHome") | |
##This is how you can use a template | |
$newDoc.setContent('{{include document="TagList.TagsSheet"/}}') | |
##Create a new object on the document | |
#set($newObj = $newDoc.newObject("TagList.TagsClass")) | |
##Set a field to a particular value | |
$newObj.set("tag", $docName) | |
$newDoc.save() | |
{{info}}Tag wurde erstellt{{/info}} | |
#elseif ("$!targetDocName" != '' && $xwiki.exists($targetDocName)) | |
{{warning}}Dieser Tag existiert bereits [[hier>>$targetDocName]]{{/warning}} | |
#elseif ("$!targetDocName" != '') | |
{{warning}}Sie haben nicht die nötigen Berechtigungen, um diese Aktion auszuführen{{/warning}} | |
#end | |
#end | |
= Neuen Tag hinzufügen = | |
{{html}} | |
<form action="" id="newdoc" method="post"> | |
<div> | |
<input type="hidden" name="parent" value="${doc.fullName}"/> | |
<input type="hidden" name="template" value="TagList.TagsTemplate"/> | |
<input type="hidden" name="sheet" value="1"/> | |
<input type="hidden" name="spaceName" value="TagList"/> | |
Tag: <input type="text" name="docName" value="Neuer Tag" class="withTip" size="50"/> | |
<span class="buttonwrapper"><input type="submit" value="Tag Erstellen" class="button"/></span> | |
</div> | |
</form> | |
{{/html}} | |
#set($columns = ["tag", "doc.creationDate", "_actions"]) | |
#set($columnsProperties = { | |
"tag" : { "type" : "text", "link" : "view", "html" : "true", "sortable":true }, | |
"_actions" : {"actions": ["edit","delete"]} | |
}) | |
#set($options = { | |
"className":"TagList.TagsClass", | |
"translationPrefix" : "tag.", | |
"tagCloud" : true, | |
"rowCount": 10 | |
}) | |
#livetable("tags" $columns $columnsProperties $options) | |
{{/velocity}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment