01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-util/tool-lib/src/java/org/sakaiproject/metaobj/shared/control/SakaiStyleSheetInterceptor.java $
03: * $Id: SakaiStyleSheetInterceptor.java 14230 2006-09-05 18:02:51Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2004, 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.shared.control;
21:
22: import javax.servlet.http.HttpServletRequest;
23: import javax.servlet.http.HttpServletResponse;
24:
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27: import org.sakaiproject.component.cover.ServerConfigurationService;
28: import org.sakaiproject.metaobj.shared.model.Id;
29: import org.sakaiproject.metaobj.worksite.mgt.WorksiteManager;
30: import org.sakaiproject.site.cover.SiteService;
31: import org.springframework.web.servlet.ModelAndView;
32: import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
33:
34: public class SakaiStyleSheetInterceptor extends
35: HandlerInterceptorAdapter {
36: protected WorksiteManager worksiteManager;
37: private static Log M_log = LogFactory
38: .getLog(SakaiStyleSheetInterceptor.class);
39:
40: public SakaiStyleSheetInterceptor() {
41: }
42:
43: public void postHandle(HttpServletRequest request,
44: HttpServletResponse response, Object handler,
45: ModelAndView modelAndView) throws Exception {
46: // code borrowed from sakai's VmServlet.setVmStdRef() method
47:
48: // form the skin based on the current site, and the defaults as configured
49: //String skinRoot = ServerConfigurationService.getString("skin.root", "/sakai-shared/css/");
50: String skinRoot = ServerConfigurationService.getString(
51: "skin.repo", "/library/skin");
52: String skin = ServerConfigurationService.getString(
53: "skin.default", "default");
54:
55: Id siteId = getWorksiteManager().getCurrentWorksiteId();
56:
57: if (siteId != null) {
58: String siteSkin = SiteService
59: .getSiteSkin(siteId.getValue());
60:
61: if (siteSkin != null) {
62: skin = siteSkin;
63: }
64:
65: request.setAttribute("sakai_skin_base", skinRoot
66: + "/tool_base.css");
67: request.setAttribute("sakai_skin", skinRoot + "/" + skin
68: + "/tool.css");
69:
70: //TODO figure out if this is still needed
71: // form the portal root for the skin - removing the .css and adding "portalskins" before
72: int pos = skin.indexOf(".css");
73: if (pos != -1) {
74: skin = skin.substring(0, pos);
75: }
76:
77: request.setAttribute("sakai_portalskin", skinRoot
78: + "portalskins" + "/" + skin + "/");
79: request.setAttribute("sakai_skin_id", skin);
80: }
81: }
82:
83: public WorksiteManager getWorksiteManager() {
84: return worksiteManager;
85: }
86:
87: public void setWorksiteManager(WorksiteManager worksiteManager) {
88: this.worksiteManager = worksiteManager;
89: }
90: }
|