General Actions:
Log-in
Wiki:
L3D's Wiki
▼
:
Document Index
»
Space:
XWiki
▼
:
Document Index
»
Page:
WebSearchCode
Search
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Welcome to your wiki
»
Search
»
WebSearchCode
Wiki source code of
WebSearchCode
Last modified by
Administrator
on 2007/07/15 02:48
Content
·
Comments
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
## ================================================== ## Common code for WebSearch and WebSearchRss ## ================================================== ## Inputs: $text, $space ## Output: $list ## Note: Do not put any empty line or this will break ## the generated RSS feed ## ================================================== #set($datedlist = $util.arrayList) #if(!$text or $text == "") ## No search #else #set($text = $text.replaceAll("'", "''").replaceAll("%", "\\%")) #set($nbitems = 50) ## ----------------------------------------------------------- ## Non-admins should not see results from XWiki, Admin and ## Panels spaces. Also exclude the WebPreferences doc. ## ----------------------------------------------------------- #if ($xwiki.hasAdminRights()) #set ($excludedWebs = "") #else #set ($excludedWebs = "doc.space<>'XWiki' and doc.space<>'Admin' and doc.space<>'Panels' and doc.name<>'WebPreferences' and") #end ## ----------------------------------------------------------- ## Display only a given space if $request.space is defined ## ----------------------------------------------------------- #if($space and $space == "All") #set ($webClause = "$excludedWebs") #else #set ($webClause = "doc.space='$space' and $excludedWebs") #end #macro(addelement $item $list) #if($xwiki.hasAccessLevel("view", $context.user, "${context.database}:${item}")) #set($itemdoc = $xwiki.getDocument($item)) #set($sdate = $xwiki.formatDate($itemdoc.date, "yyyyMMddHHmmss")) #set($sitem = "${sdate}${item}") #if(!$list.contains($sitem)) #set($discard = $list.add($sitem)) #end #end #end ## ----------------------------------------------------------- ## Search in the page names ## ----------------------------------------------------------- #set ($sql = "where $webClause upper(doc.fullName) like upper('%$!text%') order by doc.date desc") #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) #addelement($item $datedlist) #end ## ----------------------------------------------------------- ## Search in page content ## ----------------------------------------------------------- #set ($sql = "where $webClause upper(doc.content) like upper('%$!text%') order by doc.date desc") #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) #addelement($item $datedlist) #end ## ----------------------------------------------------------- ## Search in text fields (simple String properties) ## ----------------------------------------------------------- #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%')") #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) #addelement($item $datedlist) #end ## ----------------------------------------------------------- ## Search in big text fields (textarea properties) ## ----------------------------------------------------------- #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%')") #foreach ($item in $xwiki.searchDocuments($sql , $nbitems, 0)) #addelement($item $datedlist) #end #end #set($list = $util.arrayList) #foreach($item in $util.sort($datedlist)) #set($ok = $list.add(0, $item.substring(14))) #end
Quick Links
L3D Calendar
Wiki Dashboard
Document Index
Blog
Sandbox