General Actions:
Log-in
Register
Home ▼: Wiki Index
»
Space: XWiki
»
Page: SearchCode
default
Page Actions:
Export ▼: Export as PDF Export as RTF Export as HTML
More actions ▼: Print preview View Source
Welcome to bytebang » SearchCode

# Wiki source code of SearchCode

Last modified by Administrator on 2014/06/29 19:29
Attachments (0) · Information
Show line numbers {{velocity output="false"}} #set ($searchConfigDoc = $xwiki.getDocument('XWiki.SearchConfig')) #set ($searchConfigClass = $xwiki.getDocument('XWiki.SearchConfigClass').xWikiClass) ## Get or create the configuration object #set ($searchConfigObj = $searchConfigDoc.getObject($searchConfigClass.name, true)) #set ($searchEngine = "$!{searchConfigObj.getProperty('engine').value}") ## Default search engine to use in case the configured one is not found: ## - 'solr' is the preferred default ## - 'database' is the fall-back default #set ($searchExtensions = $services.uix.getExtensions('org.xwiki.platform.search', {'sortByCustomOrder' : "${searchEngine}, solr, database"})) #if (!$searchExtensions.isEmpty()) #set ($searchExtension = $searchExtensions[0]) ## Update the configuration if it is out of synch with the reality (installed extensions). #set ($needsUpdate = $searchEngine != $searchExtension.id) #set ($searchEngine = $searchExtension.id) #if ($needsUpdate && $searchConfigDoc.hasAccessLevel('edit')) #if ($searchConfigDoc.parent == '') $searchConfigDoc.setParent('XWiki.SearchAdmin') #end ## Save the updated configuration. Make sure to set it hidden as it's a technical document. $searchConfigObj.set('engine', $searchEngine) $searchConfigDoc.setHidden(true) $searchConfigDoc.save() #end #set ($searchPage = $searchExtension.parameters.search) #set ($searchAdminPage = $searchExtension.parameters.admin) #else ## No Search UI Extension was found! #set ($searchPage = '') #set ($searchAdminPage = '') #end {{/velocity}}

(c) 2026, by bytebang e.U. - Impressum - Datenschutz / Nutzungsbedingungen
-