General Actions:
Log-in
Wiki:
L3D's Wiki
▼
:
Document Index
»
Space:
XWiki
▼
:
Document Index
»
Page:
DeletedAttachments
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to your wiki
»
Documents on this Wiki
»
Deleted Attachments
Wiki source code of
Deleted Attachments
Last modified by
Administrator
on 2011/03/02 17:34
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: {{velocity}} 2: #if(!$xwiki.hasProgrammingRights()) 3: {{warning}}This document requires programming rights and needs to be saved by an administrator of this Wiki{{/warning}} 4: #else 5: #set($dateFormat = 'yyyy MMMM d, HH:mm') 6: #if(!$request.list) 7: $xwiki.ssx.use('XWiki.DeletedAttachments')## 8: $xwiki.jsx.use('XWiki.DeletedAttachments', {'minify' : 'false'})## 9: ## 10: #set($columns = ['datt.filename', 'datt.docName', 'datt.date', 'datt.deleter', 'actions']) 11: #set($columnProperties = { 12: 'datt.filename' : { 'type' : 'text', 'size' : 10 }, 13: 'datt.docName' : { 'type' : 'text', 'size' : 10 }, 14: 'datt.date' : { 'type' : 'date', 'filterable' : false }, 15: 'datt.deleter' : { 'type' : 'text', 'size' : 10 }, 16: 'actions' : { 'type' : 'text', 'filterable' : false, 'sortable' : false } 17: })## 18: #set($options = { 19: 'url' : "$xwiki.getURL('XWiki.DeletedAttachments', 'view', 'list=1&xpage=plain&outputSyntax=plain')", 20: 'callback' : 'XWiki.index.trash.attachments.displayEntry', 21: 'translationPrefix' : 'xe.index.trash.attachments.' 22: })## 23: ## 24: ## 25: ## 26: {{html wiki="true" clean="false"}} 27: <div class="hidden"> 28: #livetable('attachmentTrash' $columns $columnProperties $options) 29: </div> 30: {{/html}} 31: 32: {{html wiki="true" clean="false"}} 33: <noscript> 34: 35: #set($deletedAttachments = $xwiki.search('select count(datt.id) from DeletedAttachment as datt').get(0)) 36: #if($deletedAttachments == 0) 37: 38: {{info}}$msg.get('xe.index.trash.attachments.empty'){{/info}} 39: 40: #else 41: #macro(displayDeletedAttachment $id) 42: #set($datt = $xwiki.getDeletedAttachment("$id")) 43: #set($originalAttachment = $datt.getAttachment()) 44: #set($originalDocument = $xwiki.getDocument($datt.docName)) 45: <tr> 46: <td><a href="$originalDocument.getAttachmentRevisionURL($originalAttachment.filename, $originalAttachment.version, "rid=${datt.id}").replaceAll('&', '&')">$datt.filename</a></td> 47: <td><a href="$originalDocument.getURL()">$originalDocument.displayTitle (${originalDocument.fullName})</a></td> 48: <td>$xwiki.formatDate($datt.getDate(), $dateFormat)</td> 49: <td>$xwiki.getLocalUserName($datt.getDeleter())</td> 50: <td class="itemActions"> 51: #if($datt.canDelete()) 52: <a href="${originalDocument.getAttachmentURL($datt.filename, 'delattachment', "trashId=${datt.id}&xredirect=$util.encodeURI($!request.getRequestURI())?$util.encodeURI($!request.getQueryString())")}" class="tool delete" title="$msg.get('xe.index.trash.attachments.actions.delete.tooltip')">$msg.get('xe.index.trash.attachments.delete.text')</a> 53: #end 54: </td> 55: </tr> 56: #end 57: ## 58: #if("$!{request.view}" == '') 59: #set($queryParams = '') 60: #else 61: #set($queryParams = "view=$!{request.view}") 62: #end 63: #set($paginationParameters = { 64: 'totalItems' : $xwiki.search("select count(datt.id) from DeletedAttachment as datt").get(0), 65: 'defaultItemsPerPage' : 15, 66: 'url' : $doc.getURL('view', $queryParams) 67: }) 68: #pagination($paginationParameters) 69: <table id="searchResults" class="xwiki-livetable xwiki-livetable-display"> 70: <thead class="xwiki-livetable-display-header"><tr> 71: <th scope="col" class="xwiki-livetable-display-header-text selected asc">$msg.get('xe.index.trash.attachments.datt.filename')</th> 72: <th scope="col" class="xwiki-livetable-display-header-text">$msg.get('xe.index.trash.attachments.datt.docName')</th> 73: <th scope="col" class="xwiki-livetable-display-header-text">$msg.get('xe.index.trash.attachments.datt.date')</th> 74: <th scope="col" class="xwiki-livetable-display-header-text">$msg.get('xe.index.trash.attachments.datt.deleter')</th> 75: <th scope="col" class="xwiki-livetable-display-header-text">$msg.get('xe.index.trash.attachments.actions')</th> 76: </tr></thead> 77: <tbody class="xwiki-livetable-display-body"> 78: #foreach($item in $xwiki.search('select datt.id from DeletedAttachment as datt order by datt.filename asc', $paginationParameters.itemsPerPage, $paginationParameters.firstItem)) 79: #displayDeletedAttachment($item) 80: #end 81: </tbody> 82: </table> 83: #set($discard = $paginationParameters.put('position', 'bottom')) 84: #pagination($paginationParameters) 85: #end ## deletedAttachments != 0 86: </noscript> 87: {{/html}}## 88: #else ## request.list 89: ## ============================================================================================ 90: ## This page is called from live table via Ajax with the argument xpage=plain. It returns a 91: ## set of results serialized in JSON. 92: ## @programming This service page needs to be saved by a user with the programming access level 93: ## to work as expected 94: ## ============================================================================================ 95: #if("$!{request.get('xpage')}" == 'plain') 96: $response.setContentType('application/json') 97: #set($offset = $util.parseInt($request.get('offset'))) 98: ## offset starts from 0 in velocity and 1 in javascript 99: #set($offset = $offset - 1) 100: #set($limit = $util.parseInt($request.get('limit'))) 101: #set($filenameFilter = $request.get('datt.filename')) 102: #set($docNameFilter = $request.get('datt.docName')) 103: #set($deleterFilter = $request.get('datt.deleter')) 104: #set($sql = '') 105: #if("$!{filenameFilter}" != '') 106: #set($sql = "and lower(datt.filename) like '%${filenameFilter.trim().toLowerCase()}%' ") 107: #end 108: #if("$!{docNameFilter}" != '') 109: #set($sql = "and lower(datt.docName) like '%${docNameFilter.trim().toLowerCase()}%' ") 110: #end 111: #if("$!{deleterFilter}" != '') 112: #set($sql = $sql + "and lower(datt.deleter) like '%${deleterFilter.trim().toLowerCase()}%' ") 113: #end 114: #if("$!{request.sort}" != '') 115: #set($order = $request.sort) 116: #else 117: #set($order = 'datt.id') 118: #end 119: #if("$!{request.dir}" != '') 120: #set($dir = $request.dir) 121: #else 122: #set($dir = 'asc') 123: #end 124: #set($selectSql = "select datt.id, $order from DeletedAttachment as datt where 1=1 " + $sql + " order by $order $dir") 125: #set($countSql = "select count(*) from DeletedAttachment as datt where 1=1 " + $sql) 126: #set($items = $xwiki.search($selectSql, $limit, $offset)) 127: #set($totalItems = $xwiki.search($countSql).get(0)) 128: #set($returnedItems = $items.size()) 129: ## ============================================== 130: ## json starts 131: ## ============================================== 132: { 133: "totalrows": $totalItems, 134: "returnedrows": $returnedItems, 135: "offset": ${request.get('offset')}, 136: "reqNo": ${request.reqNo}, 137: "query" : "$selectSql", 138: "rows": [ 139: #foreach($item in $items) 140: #set($datt = $xwiki.getDeletedAttachment("$item.get(0)")) 141: #if($velocityCount > 1) , #end 142: { 143: #set($originalAttachment = $datt.getAttachment()) 144: #set($originalDocument = $xwiki.getDocument($datt.docName)) 145: "filename" : "$datt.filename", 146: "docName" : "$datt.docName", 147: "title" : "$originalDocument.displayTitle", 148: "url" : "$originalDocument.getAttachmentRevisionURL($originalAttachment.filename, $originalAttachment.version, "rid=${datt.id}")", 149: "documentUrl" : "$originalDocument.getURL()", 150: "canDelete" : $datt.canDelete(), 151: "deleteUrl" : "$originalDocument.getAttachmentURL($datt.filename, 'delattachment', "trashId=${datt.id}")", 152: "canRestore" : $datt.canRestore(), 153: "alreadyExists" : #if($originalDocument.getAttachment($datt.filename)) true #else false #end, 154: "restoreUrl" : "$originalDocument.getAttachmentURL($datt.filename)", 155: "date" : "$xwiki.formatDate($datt.date, $dateFormat)", 156: "deleter" : "$datt.deleter", 157: "deletername" : "$xwiki.getUserName($datt.deleter, false)", 158: "deleterurl" : "$xwiki.getURL($datt.deleter, 'view')" 159: } 160: #end 161: ]} 162: ## ============================================== 163: ## json ended 164: ## ============================================== 165: #end## xpage=plain 166: #end## request.list 167: #end## hasProgramR 168: {{/velocity}}
Quick Links
L3D Calendar
Wiki Dashboard
Document Index
Blog
Sandbox