1 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 com.opensymphony.module.sitemesh.*; 31 32 37 public class PageHead extends AbstractTag { 38 public void writeTag() throws IOException { 39 Writer w = getOut(); 40 ((HTMLPage) getPage()).writeHead(w); 41 Locale locale = (Locale) pageContext.getAttribute(HitFilter.LOCALE_ATTRIBUTE, 42 PageContext.REQUEST_SCOPE); 43 44 if (locale != null) { 45 w.write("\n<meta http-equiv=\"Content-Language\" content=\"" + locale + "\" />"); 46 } 47 48 String redir = (String ) request.getAttribute(SetLocale.REDIRECT_ATTRIBUTE); 49 50 if (redir != null) { 51 if (userInfo == null || userInfo.isGuest()) { 52 w.write("\n<meta http-equiv=\"refresh\" content=\"0; url=" + redir + "\" />"); 53 } else { 54 Locale pl = WebUtils.getPageLocale(pageContext); 55 ResourceBundle bundle = 56 ResourceBundle.getBundle("org/meshcms/webui/Locales", pl); 57 w.write("\n<script type='text/javascript'>alert(\"" + 58 bundle.getString("pageRedirectionAlert") + "\");</script>"); 59 } 60 } 61 } 62 63 public void writeEditTag() throws IOException { 64 Path linkListPath = new Path(ap, "tinymce_linklist.jsp"); 65 linkListPath = linkListPath.getRelativeTo(webSite.getDirectory(pagePath)); 66 Locale locale = WebUtils.getPageLocale(pageContext); 67 ResourceBundle bundle = ResourceBundle.getBundle("org/meshcms/webui/Locales", locale); 68 String langCode = bundle.getString("TinyMCELangCode"); 69 70 if (Utils.isNullOrEmpty(langCode)) { 71 langCode = locale.getLanguage(); 72 } 73 74 Writer w = getOut(); 75 ((HTMLPage) getPage()).writeHead(w); 76 w.write("\n<script type='text/javascript' SRC='" + 77 cp + '/' + (webSite.getFile(webSite.getCMSPath().add("tiny_mce")).exists() ? 78 webSite.getCMSPath() : webSite.getAdminScriptsPath()) + 79 "/tiny_mce/tiny_mce.js'></script>\n"); 80 w.write("<script type='text/javascript'>\n"); 81 w.write("// <![CDATA[\n"); 82 w.write(" var contextPath = \"" + cp + "\";\n"); 83 w.write(" var adminPath = \"" + webSite.getAdminPath() + "\";\n"); 84 w.write(" var languageCode = \"" + langCode + "\";\n"); 85 w.write(" var linkListPath = \"" + linkListPath + "\";\n"); 86 w.write(" var cssPath = \"" + WebUtils.getFullThemeCSS(request) + "\";\n"); 87 w.write("// ]]>\n"); 88 w.write("</script>\n"); 89 w.write("<script type='text/javascript' SRC='" + 90 cp + '/' + webSite.getAdminScriptsPath() + "/editor.js'></script>\n"); 91 92 w.write("<script type='text/javascript' SRC='" + cp + '/' + 93 (webSite.getFile(webSite.getCMSPath().add("tinymce_init.js")).exists() ? 94 webSite.getCMSPath() : webSite.getAdminScriptsPath()) + 95 "/tinymce_init.js'></script>"); 96 } 97 } 98 | Popular Tags |