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
Hide line numbers 1: {{velocity output="false"}} 2: #set ($searchConfigDoc = $xwiki.getDocument('XWiki.SearchConfig')) 3: #set ($searchConfigClass = $xwiki.getDocument('XWiki.SearchConfigClass').xWikiClass) 4: 5: ## Get or create the configuration object 6: #set ($searchConfigObj = $searchConfigDoc.getObject($searchConfigClass.name, true)) 7: #set ($searchEngine = "$!{searchConfigObj.getProperty('engine').value}") 8: 9: ## Default search engine to use in case the configured one is not found: 10: ## - 'solr' is the preferred default 11: ## - 'database' is the fall-back default 12: #set ($searchExtensions = $services.uix.getExtensions('org.xwiki.platform.search', {'sortByCustomOrder' : "${searchEngine}, solr, database"})) 13: #if (!$searchExtensions.isEmpty()) 14: #set ($searchExtension = $searchExtensions[0]) 15: 16: ## Update the configuration if it is out of synch with the reality (installed extensions). 17: #set ($needsUpdate = $searchEngine != $searchExtension.id) 18: #set ($searchEngine = $searchExtension.id) 19: #if ($needsUpdate && $searchConfigDoc.hasAccessLevel('edit')) 20: #if ($searchConfigDoc.parent == '') 21: $searchConfigDoc.setParent('XWiki.SearchAdmin') 22: #end 23: ## Save the updated configuration. Make sure to set it hidden as it's a technical document. 24: $searchConfigObj.set('engine', $searchEngine) 25: $searchConfigDoc.setHidden(true) 26: $searchConfigDoc.save() 27: #end 28: 29: #set ($searchPage = $searchExtension.parameters.search) 30: #set ($searchAdminPage = $searchExtension.parameters.admin) 31: #else 32: ## No Search UI Extension was found! 33: #set ($searchPage = '') 34: #set ($searchAdminPage = '') 35: #end 36: {{/velocity}}

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