KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > meshcms > taglib > PageBody


1 /*
2  * MeshCMS - A simple CMS based on SiteMesh
3  * Copyright (C) 2004-2007 Luciano Vernaschi
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * You can contact the author at http://www.cromoteca.com
20  * and at info@cromoteca.com
21  */

22
23 package org.meshcms.taglib;
24
25 import java.io.*;
26 import java.util.*;
27 import javax.servlet.jsp.*;
28 import org.meshcms.core.*;
29 import org.meshcms.util.*;
30 import org.meshcms.webui.*;
31 import com.opensymphony.module.sitemesh.*;
32
33 /**
34  * Writes the page body or the main part of the page editor.
35  */

36 public class PageBody extends AbstractTag {
37   public static final int MINIMUM_PAGE_SIZE = 32;
38   public void writeTag() throws IOException {
39     String JavaDoc body = getPage().getBody();
40
41     // Let's prevent caching of pages with a "small body"
42
if (body.length() < MINIMUM_PAGE_SIZE) {
43       WebUtils.setBlockCache(request);
44     }
45
46     getOut().write(body);
47   }
48
49   public void writeEditTag() throws IOException {
50     UserInfo userInfo = (UserInfo) pageContext.getAttribute("userInfo",
51       PageContext.SESSION_SCOPE);
52     Locale locale = WebUtils.getPageLocale(pageContext);
53     ResourceBundle bundle = ResourceBundle.getBundle("org/meshcms/webui/Locales", locale);
54
55     Writer w = getOut();
56
57     w.write("<div align='right'>" + Help.icon(webSite, cp, Help.EDIT_PAGE, userInfo) + "</div>\n");
58
59     w.write("<fieldset class='meshcmseditor'>\n");
60     w.write("<legend>" + bundle.getString("editorMainSection") + "</legend>\n");
61     w.write("<div class='meshcmsfieldlabel'><label for='pagetitle'>" +
62       bundle.getString("editorPageTitle") + "</label></div>\n");
63     w.write("<div class='meshcmsfield'><input type='text' id='pagetitle' name='pagetitle' value=\"" +
64       Utils.noNull(getPage().getTitle()) +
65       "\" style='width: 100%;' /></div>\n");
66
67     w.write("<div class='meshcmsfieldlabel'><img alt=\"\" SRC=\"" + afp +
68       "/images/tree_plus.gif\" id='togglehead' onclick=\"javascript:editor_toggleHideShow('meshcmshead','togglehead');\" />\n");
69     w.write("<label for='meshcmshead'>" + bundle.getString("editorPageHead") + "</label></div>\n");
70     w.write("<div class='meshcmsfield'><textarea id='meshcmshead' name='meshcmshead' rows='5' cols='80' style='height: 5em; width: 100%; display: none;'>" +
71       Utils.noNull(((HTMLPage) getPage()).getHead()) + "</textarea></div>\n");
72
73     w.write("<div class='meshcmsfieldlabel'><label for='meshcmsbody'>" +
74       bundle.getString("editorPageBody") + "</label></div>\n");
75     w.write("<div class='meshcmsfield'><textarea id='meshcmsbody' name='meshcmsbody' rows='25' cols='80' style='height: 30em; width: 100%;'>");
76     w.write(Utils.encodeHTML(getPage().getBody(), true));
77     w.write("</textarea></div>\n");
78     w.write("<div class='meshcmsfield'><input type='checkbox' checked='checked' id='relch' \n");
79     w.write(" onclick=\"javascript:tinyMCE.settings['relative_urls']=this.checked;\" />\n");
80     w.write(" <label for='relch'>" + bundle.getString("editorRelative") + "</label></div>\n");
81
82     w.write("<div class='meshcmsbuttons'><input type='submit' value='" +
83         bundle.getString("genericSave") + "' /></div>\n");
84     w.write("</fieldset>");
85   }
86 }
87
Popular Tags