KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > template > CmsDumpStylesheet


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/template/CmsDumpStylesheet.java,v $
3 * Date : $Date: 2005/05/17 13:47:32 $
4 * Version: $Revision: 1.1 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29
30 package com.opencms.template;
31
32 import org.opencms.file.CmsObject;
33 import org.opencms.main.CmsException;
34
35 import com.opencms.legacy.CmsXmlTemplateLoader;
36
37 import java.util.Hashtable JavaDoc;
38
39 import javax.servlet.http.HttpServletRequest JavaDoc;
40
41 /**
42  * Dump the correct stylesheet for the current browser.
43  *
44  * @author Alexander Lucas
45  * @version $Revision: 1.1 $ $Date: 2005/05/17 13:47:32 $
46  *
47  * @deprecated Will not be supported past the OpenCms 6 release.
48  */

49 public class CmsDumpStylesheet extends CmsDumpTemplate {
50
51     /**
52      * Get the content and log this in the vector described above.
53      *
54      * @param cms A_CmsObject Object for accessing system resources.
55      * @param templateFile Filename of the template file.
56      * @param elementName Element name of this template in our parent template.
57      * @param parameters Hashtable with all template class parameters.
58      *
59      * @return Array of bytes that contains the page.
60      *
61      * @throws CmsException if something goes wrong
62      */

63     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters) throws CmsException {
64         HttpServletRequest JavaDoc orgReq = CmsXmlTemplateLoader.getRequest(cms.getRequestContext()).getOriginalRequest();
65         int dotIdx = templateFile.lastIndexOf(".");
66         String JavaDoc pre = templateFile.substring(0, dotIdx);
67         String JavaDoc post = templateFile.substring(dotIdx);
68
69         // Get the user's browser
70
String JavaDoc browser = orgReq.getHeader("user-agent");
71         if (browser.indexOf("MSIE") > -1) {
72             templateFile = pre + "-ie" + post;
73         } else {
74             templateFile = pre + "-ns" + post;
75         }
76         return super.getContent(cms, templateFile, elementName, parameters);
77     }
78
79     /**
80      * Get the content and log this in the vector described above.
81      *
82      * @param cms A_CmsObject Object for accessing system resources
83      * @param templateFile Filename of the template file
84      * @param elementName <em>not used here</em>.
85      * @param parameters <em>not used here</em>.
86      * @param templateSelector <em>not used here</em>.
87      * @return Unprocessed content of the given template file.
88      * @throws CmsException if something goes wrong
89      */

90     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
91
92         // ignore the templateSelector since we only dump the template
93
return getContent(cms, templateFile, elementName, parameters);
94     }
95
96     /**
97      * gets the caching information from the current template class.
98      *
99      * @param cms CmsObject Object for accessing system resources
100      * @param templateFile Filename of the template file
101      * @param elementName Element name of this template in our parent template.
102      * @param parameters Hashtable with all template class parameters.
103      * @param templateSelector template section that should be processed.
104      * @return <EM>true</EM> if this class may stream it's results, <EM>false</EM> otherwise.
105      */

106     public CmsCacheDirectives getCacheDirectives(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
107
108         // First build our own cache directives.
109
CmsCacheDirectives result = new CmsCacheDirectives(false, true, false, false, true);
110         return result;
111     }
112
113     /**
114      * Indicates if the results of this class are cacheable.
115      *
116      * @param cms A_CmsObject Object for accessing system resources
117      * @param templateFile Filename of the template file
118      * @param elementName Element name of this template in our parent template.
119      * @param parameters Hashtable with all template class parameters.
120      * @param templateSelector template section that should be processed.
121      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
122      */

123     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName, Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
124         return false;
125     }
126 }
127
Popular Tags