001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-tool/tool/src/java/org/sakaiproject/search/tool/OpenSearchBeanImpl.java $
003: * $Id: OpenSearchBeanImpl.java 30222 2007-05-09 18:34:57Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.search.tool;
021:
022: import javax.servlet.http.HttpServletRequest;
023:
024: import org.sakaiproject.component.cover.ServerConfigurationService;
025: import org.sakaiproject.entity.api.ResourceProperties;
026: import org.sakaiproject.exception.IdUnusedException;
027: import org.sakaiproject.search.api.SearchService;
028: import org.sakaiproject.search.tool.api.OpenSearchBean;
029: import org.sakaiproject.site.api.Site;
030: import org.sakaiproject.site.api.SiteService;
031: import org.sakaiproject.tool.api.Placement;
032: import org.sakaiproject.tool.api.ToolManager;
033: import org.sakaiproject.util.FormattedText;
034:
035: /**
036: * @author ieb
037: */
038: public class OpenSearchBeanImpl implements OpenSearchBean {
039:
040: private SearchService searchService;
041:
042: private SiteService siteService;
043:
044: private String placementId;
045:
046: private String toolId;
047:
048: private String siteId;
049:
050: private Site currentSite;
051:
052: private HttpServletRequest request;
053:
054: private Placement placement;
055:
056: private String baseURL;
057:
058: public OpenSearchBeanImpl(HttpServletRequest request,
059: SearchService searchService, SiteService siteService,
060: ToolManager toolManager) throws IdUnusedException {
061: this .request = request;
062: this .searchService = searchService;
063: this .siteService = siteService;
064: this .placement = toolManager.getCurrentPlacement();
065: this .placementId = toolManager.getCurrentPlacement().getId();
066: this .toolId = toolManager.getCurrentTool().getId();
067: this .siteId = toolManager.getCurrentPlacement().getContext();
068: this .currentSite = this .siteService.getSite(this .siteId);
069: String siteCheck = currentSite.getReference();
070: baseURL = getBaseURL();
071: }
072:
073: private String getBaseURL() {
074: return ServerConfigurationService.getPortalUrl() + "/tool/"
075: + placementId;
076: }
077:
078: public String getAdultContent() {
079: return "false";
080: }
081:
082: public String getAttibution() {
083: String copyright = ServerConfigurationService
084: .getString("default.copyright");
085: String siteCopyright = currentSite.getProperties().getProperty(
086: ResourceProperties.PROP_COPYRIGHT);
087: if (siteCopyright != null) {
088: copyright = siteCopyright;
089: }
090: return FormattedText.escapeHtml(copyright, false);
091: }
092:
093: public String getHTMLSearchFormUrl() {
094: return baseURL + "/index";
095: }
096:
097: public String getHTMLSearchTemplate() {
098: return baseURL + "/index?panel=Main&search={searchTerms}";
099: }
100:
101: public String getIconUrl() {
102: String iconURL = currentSite.getIconUrlFull();
103: if (iconURL == null) {
104: iconURL = ServerConfigurationService.getServerUrl()
105: + "/favicon.ico";
106: }
107: return FormattedText.escapeHtml(iconURL, false);
108: }
109:
110: public String getRSSSearchTemplate() {
111: return baseURL + "/rss20?panel=Main&search={searchTerms}";
112: }
113:
114: public String getSindicationRight() {
115: String sindicationRights = "private";
116: if (currentSite.isPubView()) {
117: sindicationRights = "limited";
118: }
119: return FormattedText.escapeHtml(sindicationRights, false);
120: }
121:
122: public String getSiteName() {
123: return FormattedText.escapeHtml(currentSite.getTitle(), false);
124: }
125:
126: public String getSystemName() {
127: return FormattedText.escapeHtml(ServerConfigurationService
128: .getString("ui.service", "Sakai"), false);
129: }
130:
131: }
|