General Actions:
Log-in
Wiki:
Courses
▼
:
Document Index
»
Space:
Main
▼
:
Document Index
»
Page:
DatabaseSearch
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to L3D's XWiki for Courses
»
Search
»
Database Search
Wiki source code of
Database Search
Last modified by
Administrator
on 2010/05/26 10:09
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Hide line numbers
1: {{velocity}} 2: $xwiki.jsfx.use("uicomponents/search/search.js", false)## 3: $xwiki.ssfx.use("uicomponents/search/search.css", true)## 4: ## Disable the document extra data: comments, attachments, history... 5: #set($docextras = []) 6: #set ($rssmode = ("$!request.xpage" == 'plain')) 7: ## --------------- 8: ## Space filtering 9: ## --------------- 10: #set($spaces = $xwiki.spaces) 11: #set($selectedSpace = "$!request.space") 12: ## --------------- 13: ## Space macros 14: ## --------------- 15: #macro(spaceoption $space $selectedSpace) 16: <option value="${space}" #if($selectedSpace == $space)selected="selected"#end>$space</option> 17: #end 18: #macro(spaceselect $selectedSpace $spaces) 19: <select name="space" title="$msg.get('search.page.bar.spaces.title')"> 20: <option value="" #if($selectedSpace == '')selected="selected"#end>$msg.get('search.page.bar.spaces.all')</option> 21: #foreach($space in $spaces) 22: #if (!$blacklistedSpaces.contains($space)) 23: #spaceoption($space $selectedSpace) 24: #end 25: #end 26: </select> 27: #end 28: ## 29: ## 30: #set($text = "$!request.getParameter('text')") 31: #set($utext = $util.encodeURI($text)) 32: ## --------------- 33: ## Query form 34: ## --------------- 35: #if(!$rssmode) 36: {{html}} 37: <form action="" id="searchBar"> 38: <div class="centered"> 39: <label for="text" class="hidden">$msg.get('search.page.query.label')</label> 40: <input type="text" id="text" name="text" class="searchQuery #if($text == '') defaultText#end" #if($text == '') value="$msg.get('search.page.bar.query.tip')" #else value="${escapetool.xml($text)}" #end title="$msg.get('search.page.bar.query.title')"/> 41: #spaceselect($selectedSpace $spaces) 42: <input type="submit" class="searchButton" value="$msg.get('search.page.bar.submit')" title="$msg.get('search.page.bar.submit.title')"/> 43: </div> 44: </form> 45: {{/html}} 46: #end 47: #set($space = $selectedSpace) 48: #set($datedlist = $util.arrayList) 49: #if("$!text" == '') 50: ## No search 51: #else 52: #set($text = $text.replaceAll("'", "''").replaceAll("%", "\\%")) 53: #set($nbitems = 50) 54: ## ---------------------------------------------------------------------- 55: ## Exclude Blacklisted spaces ($blacklistedSpaces is set in xwikivars.vm) 56: ## Also exclude WebPreferences. 57: ## ---------------------------------------------------------------------- 58: #set ($webClause = '') 59: #foreach ($blacklistedSpace in $blacklistedSpaces) 60: #set ($webClause = "${webClause} doc.space <> '$blacklistedSpace' and") 61: #end 62: #if(!$hasAdmin && !$isAdvancedUser) 63: #set ($webClause = "${webClause} doc.name<>'WebPreferences' and") 64: #end 65: ## ----------------------------------------------------------- 66: ## Display only a given space if $request.space is defined 67: ## ----------------------------------------------------------- 68: #if("$!space" != '') 69: #set ($webClause = "${webClause} doc.space='$space' and") 70: #end 71: #macro(addelement $item $list) 72: #if($xwiki.hasAccessLevel('view', $context.user, "${context.database}:${item}")) 73: #set($itemdoc = $xwiki.getDocument($item)) 74: ## All items will be sorted by the date; since the list is obtained from several queries, we can't order in the HQL. 75: ## Prefix all item names with the date for sorting the combined results. 76: #set($sdate = $xwiki.formatDate($itemdoc.date, 'yyyyMMddHHmmss')) 77: #set($sitem = "${sdate}${item}") 78: #if(!$list.contains($sitem)) 79: #set($discard = $list.add($sitem)) 80: #end 81: #end 82: #end 83: ## ----------------------------------------------------------- 84: ## Search in the page names 85: ## ----------------------------------------------------------- 86: #set ($sql = "where $webClause upper(doc.fullName) like upper('%$!text%') order by doc.date desc") 87: #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) 88: #addelement($item $datedlist) 89: #end 90: ## ----------------------------------------------------------- 91: ## Search in page content 92: ## ----------------------------------------------------------- 93: #set ($sql = "where $webClause upper(doc.content) like upper('%$!text%') order by doc.date desc") 94: #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) 95: #addelement($item $datedlist) 96: #end 97: ## ----------------------------------------------------------- 98: ## Search in text fields (simple String properties) 99: ## ----------------------------------------------------------- 100: #set($sql= ", BaseObject as obj, StringProperty as prop where $webClause obj.name=doc.fullName and prop.id.id = obj.id and upper(prop.value) like upper('%$!text%')") 101: #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) 102: #addelement($item $datedlist) 103: #end 104: ## ----------------------------------------------------------- 105: ## Search in big text fields (textarea properties) 106: ## ----------------------------------------------------------- 107: #set($sql= ", BaseObject as obj, LargeStringProperty as prop where $webClause obj.name=doc.fullName and prop.id.id = obj.id and upper(prop.value) like upper('%$!text%')") 108: #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) 109: #addelement($item $datedlist) 110: #end 111: #end 112: #set($list = $util.arrayList) 113: #foreach($item in $util.sort($datedlist)) 114: ## datedlist contains items prefixed with the date; strip the date from the actual item name: 115: #set($ok = $list.add(0, $item.substring(14))) 116: #end 117: #if ("$!utext" != '') 118: #if($rssmode) 119: #set ($feed = $xwiki.feed.getDocumentFeed($list, $util.getHashMap())) 120: #set ($feedURI = $doc.getExternalURL("view")) 121: #set ($discard = $feed.setLink($feedURI)) 122: #set ($discard = $feed.setUri($feedURI)) 123: #set ($discard = $feed.setAuthor('XWiki')) 124: #set ($discard = $feed.setTitle($msg.get('search.rss', [$text]))) 125: #set ($discard = $feed.setDescription($msg.get('search.rss', [$text]))) 126: #set ($discard = $feed.setLanguage($context.language)) 127: #set ($discard = $feed.setCopyright($xwiki.getXWikiPreference('copyright'))) 128: {{{$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))}}} 129: #else 130: 131: {{include document="XWiki.Results"/}} 132: 133: #if($selectedSpace == '') 134: #set($rssURL = $xwiki.getURL($doc.fullName, 'view', "xpage=plain&outputSyntax=plain&text=${utext}" )) 135: #else 136: #set($rssURL = $xwiki.getURL($doc.fullName, 'view', "xpage=plain&outputSyntax=plain&space=${selectedSpace}&text=${utext}")) 137: #end 138: {{html}} 139: <a href="${rssURL}"><img src="$xwiki.getSkinFile("icons/silk/feed.gif")" alt="RSS icon"/>$msg.get("search.rss", ["[$text]"])</a> 140: {{/html}} 141: #end 142: #end 143: {{/velocity}}
Welcome
Welcome to this XWiki!
Quick Links
DSSF 2008
DCNM 2009
HCCF 2010
Document Index
Sandbox
My Recent Modifications
ASSIGNMENTNAME