svnno****@sourc*****
svnno****@sourc*****
2008年 6月 4日 (水) 18:09:48 JST
Revision: 950 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=950 Author: sone Date: 2008-06-04 18:09:47 +0900 (Wed, 04 Jun 2008) Log Message: ----------- change to open new window and edit Modified Paths: -------------- pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/PALWcmConstants.java pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/portlet/PALWcmPortlet.java pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FilesaveServlet.java pal-wcm/trunk/src/main/webapp/index.jsp pal-wcm/trunk/src/main/webapp/view/wcm/wcmEdit.jsp Added Paths: ----------- pal-wcm/trunk/src/main/webapp/view/wcm/wcmViewAndEdit.jsp -------------- next part -------------- Modified: pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/PALWcmConstants.java =================================================================== --- pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/PALWcmConstants.java 2008-06-03 10:05:47 UTC (rev 949) +++ pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/PALWcmConstants.java 2008-06-04 09:09:47 UTC (rev 950) @@ -71,5 +71,7 @@ public static final String MESSAGE = PREFIX + "Message"; public static final String ACTION_TYPE = PREFIX + "ActionType"; + + public static final String CONTENT_FILE_NAME = "content_jp.html"; } Modified: pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/portlet/PALWcmPortlet.java =================================================================== --- pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/portlet/PALWcmPortlet.java 2008-06-03 10:05:47 UTC (rev 949) +++ pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/portlet/PALWcmPortlet.java 2008-06-04 09:09:47 UTC (rev 950) @@ -15,6 +15,9 @@ */ package jp.sf.pal.wcm.portlet; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -79,6 +82,7 @@ } } + /* (non-Javadoc) * @see javax.portlet.GenericPortlet#doDispatch(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ @@ -100,13 +104,13 @@ String language = currentLocale.getLanguage(); String country = currentLocale.getCountry(); String variant = currentLocale.getVariant(); - if (localeList.contains(language + "_" + country + "_" - + variant)) { - localeName = PALWcmConstants.LOCALE_SEPARETER + language - + "_" + country + "_" + variant; + if (localeList.contains(language + "_" + country + "_" + + variant)) { + localeName = PALWcmConstants.LOCALE_SEPARETER + language + + "_" + country + "_" + variant; } else if (localeList.contains(language + "_" + country)) { - localeName = PALWcmConstants.LOCALE_SEPARETER + language - + "_" + country; + localeName = PALWcmConstants.LOCALE_SEPARETER + language + + "_" + country; } else if (localeList.contains(language)) { localeName = PALWcmConstants.LOCALE_SEPARETER + language; } @@ -134,11 +138,11 @@ String country = currentLocale.getCountry(); String variant = currentLocale.getVariant(); if (localeList.contains(language + "_" + country + "_" + variant)) { - localeName = PALWcmConstants.LOCALE_SEPARETER + language + "_" - + country + "_" + variant; + localeName = PALWcmConstants.LOCALE_SEPARETER + language + "_" + + country + "_" + variant; } else if (localeList.contains(language + "_" + country)) { - localeName = PALWcmConstants.LOCALE_SEPARETER + language + "_" - + country; + localeName = PALWcmConstants.LOCALE_SEPARETER + language + "_" + + country; } else if (localeList.contains(language)) { localeName = PALWcmConstants.LOCALE_SEPARETER + language; } @@ -149,8 +153,10 @@ PALWcmConstants.CONTENT + localeName, ""); request.setAttribute(PALWcmConstants.TITLE, title); - request.setAttribute(PALWcmConstants.CONTENT, content); - + //request.setAttribute(PALWcmConstants.CONTENT, content); + request.setAttribute(PALWcmConstants.CONTENT, + getContentByFlagId(fragment.getId())); + PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher( "/view/wcm/wcmView.jsp"); rd.include(request, response); @@ -184,6 +190,7 @@ protected void doContentEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException { + String localeName = getEditLocaleName(request); String selectedLocale = localeName; if (!localeName.equals("")) { @@ -193,11 +200,12 @@ Fragment fragment = getCurrentFragment(request); String title = getFragmentPreferenceValue(fragment, PALWcmConstants.TITLE + localeName, ""); - String content = getFragmentPreferenceValue(fragment, - PALWcmConstants.CONTENT + localeName, ""); + //String content = getFragmentPreferenceValue(fragment, + //PALWcmConstants.CONTENT + localeName, ""); + String localeOptions = getLocaleOptionString(fragment, selectedLocale); String fragmentId = fragment.getId(); - + String content = getContentByFlagId(fragmentId); response.setTitle(title); request.setAttribute(PALWcmConstants.TITLE, title); request.setAttribute(PALWcmConstants.CONTENT, StringEscapeUtils @@ -206,10 +214,11 @@ request.setAttribute(PALWcmConstants.FRAGMENT_ID, fragmentId); request.setAttribute(PALWcmConstants.PORTAL_CONTEXT_PATH, getPortalContextPath(request)); - + PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher( - "/view/wcm/wcmEdit.jsp"); - rd.include(request, response); + "/view/wcm/wcmViewAndEdit.jsp"); + rd.include(request, response); + } @@ -347,8 +356,8 @@ setFragmentPreferenceValue(fragment, PALWcmConstants.TITLE + localeName, title); - setFragmentPreferenceValue(fragment, PALWcmConstants.CONTENT - + localeName, content); + setFragmentPreferenceValue(fragment, PALWcmConstants.CONTENT + + localeName, content); try { pageManager.updatePage(page); @@ -466,10 +475,10 @@ } setFragmentPreferenceValue(fragment, PALWcmConstants.LOCALE_LIST, localeNames.toString()); - removeFragmentPreferenceValue(fragment, PALWcmConstants.TITLE - + PALWcmConstants.LOCALE_SEPARETER + selectedLocale); - removeFragmentPreferenceValue(fragment, PALWcmConstants.CONTENT - + PALWcmConstants.LOCALE_SEPARETER + selectedLocale); + removeFragmentPreferenceValue(fragment, PALWcmConstants.TITLE + + PALWcmConstants.LOCALE_SEPARETER + selectedLocale); + removeFragmentPreferenceValue(fragment, PALWcmConstants.CONTENT + + PALWcmConstants.LOCALE_SEPARETER + selectedLocale); try { pageManager.updatePage(page); @@ -566,4 +575,33 @@ } } + private String getContentByFlagId(String flagId) { + String contents = ""; + String filePath = getPortletContext().getRealPath( + "/WEB-INF/data/" + flagId + "/" + + PALWcmConstants.CONTENT_FILE_NAME); + File contentsFile = new File(filePath); + if (contentsFile.exists()) { + try { + String line = ""; + FileReader fr = new FileReader(filePath); + BufferedReader reader = new BufferedReader(fr); + while ((line = reader.readLine()) != null) { + contents += line; + } + fr.close(); + return contents; + } catch (Exception e) { + // TODO: handle exception + log.error(e); + return "error"; + } + } else { + // TODO: change message + //return "portlet:" + flagId + ":" + filePath; + return "portlet"; + } + + } + } Modified: pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FilesaveServlet.java =================================================================== --- pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FilesaveServlet.java 2008-06-03 10:05:47 UTC (rev 949) +++ pal-wcm/trunk/src/main/java/jp/sf/pal/wcm/servlet/FilesaveServlet.java 2008-06-04 09:09:47 UTC (rev 950) @@ -27,31 +27,30 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import jp.sf.pal.wcm.PALWcmConstants; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - /** * @author takaaki * */ -public class FilesaveServlet extends HttpServlet { +public class FilesaveServlet extends HttpServlet { private static final Log log = LogFactory.getLog(FilesaveServlet.class); - - @Override + + @Override protected void doGet(HttpServletRequest request, - HttpServletResponse response) throws ServletException, IOException { + HttpServletResponse response) throws ServletException, IOException { Enumeration params = request.getParameterNames(); String parameter = null; String reqParam = null; while (params.hasMoreElements()) { parameter = (String) params.nextElement(); reqParam = request.getParameter(parameter); - ServletContext servletContext = getServletContext(); - //String fragID = request.getParameter(PALWcmConstants.FRAGMENT_ID); - String fragID = request.getParameter("fragID"); - //String fragID = "test123"; + ServletContext servletContext = getServletContext(); + String fragID = (String)servletContext.getAttribute(PALWcmConstants.FRAGMENT_ID); String outputFileName = "/content_jp.html"; String outputFilePath = servletContext .getRealPath("/WEB-INF/data/" + fragID); @@ -72,11 +71,13 @@ e.printStackTrace(); } } - response.sendRedirect("/pal-wcm"); + //destroy(); + response.sendRedirect("/palportal"); + } - + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - doGet(request,response); + doGet(request, response); } } Modified: pal-wcm/trunk/src/main/webapp/index.jsp =================================================================== --- pal-wcm/trunk/src/main/webapp/index.jsp 2008-06-03 10:05:47 UTC (rev 949) +++ pal-wcm/trunk/src/main/webapp/index.jsp 2008-06-04 09:09:47 UTC (rev 950) @@ -53,11 +53,11 @@ } fr.close(); } -} catch (Exception e){ +} Catch (Exception e){ e.printStackTrace(); } %> - <FCK:editor id="EditorDefault" basePath="fckeditor/" + <FCK:editor id="EditorDefault" basePath="/fckeditor/editor/" imageBrowserURL="/pal-wcm/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" linkBrowserURL="/pal-wcm/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" flashBrowserURL="/pal-wcm/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" Modified: pal-wcm/trunk/src/main/webapp/view/wcm/wcmEdit.jsp =================================================================== --- pal-wcm/trunk/src/main/webapp/view/wcm/wcmEdit.jsp 2008-06-03 10:05:47 UTC (rev 949) +++ pal-wcm/trunk/src/main/webapp/view/wcm/wcmEdit.jsp 2008-06-04 09:09:47 UTC (rev 950) @@ -1,72 +1,59 @@ -<%-- -Licensed to the Apache Software Foundation (ASF) under one or more -contributor license agreements. See the NOTICE file distributed with -this work for additional information regarding copyright ownership. -The ASF licenses this file to You under the Apache License, Version 2.0 -(the "License"); you may not use this file except in compliance with -the License. You may obtain a copy of the License at +<%@ taglib uri="/WEB-INF/tld/FCKeditor.tld" prefix="FCK" %> +<%@ page language="java" import="jp.sf.pal.wcm.*, java.util.*, java.io.File, java.io.FileReader, java.io.BufferedReader, javax.servlet.ServletContext,jp.sf.pal.wcm.PALWcmConstants" %> +<!-- + * FCKeditor - The text editor for internet + * Copyright (C) 2003-2005 Frederico Caldeira Knabben + * + * Licensed under the terms of the GNU Lesser General Public License: + * http://www.opensource.org/licenses/lgpl-license.php + * + * For further information visit: + * http://www.fckeditor.net/ + * + * File Name: sample01.jsp + * FCKeditor sample file 1. + * + * Version: 2.1 + * Modified: 2005-03-29 21:30:00 + * + * File Authors: + * Simone Chiaretta (simo****@users*****) +--> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> +<html> + <head> + <title>PAL-WCM</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta name="robots" content="noindex, nofollow"> + <script type="text/javascript"> - http://www.apache.org/licenses/LICENSE-2.0 +function FCKeditor_OnComplete( editorInstance ) +{ + window.status = editorInstance.Description ; +} -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. ---%> -<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %> -<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %> -<%@ page import="jp.sf.pal.wcm.PALWcmConstants"%> -<portlet:defineObjects/> -<portlet:renderURL var="closeUrl" portletMode="view"></portlet:renderURL> -<portlet:renderURL var="preferencesEditUrl" portletMode="edit"> - <portlet:param name="jp.sf.pal.wcm.EditType" value="jp.sf.pal.wcm.PreferencesEditType"/> -</portlet:renderURL> + </script> + </head> + <body> + <form action="/pal-wcm/filesave" method="post"> +<% +ServletContext servletContext = getServletContext(); +String content = (String)request.getParameter("content"); +String fragID = (String)request.getParameter("fragID"); +servletContext.setAttribute(PALWcmConstants.FRAGMENT_ID,fragID); +servletContext.setAttribute(PALWcmConstants.CONTENT,content); +%> + <FCK:editor id="EditorDefault" basePath="/pal-wcm/fckeditor/" + imageBrowserURL="/pal-wcm/fckeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" + linkBrowserURL="/pal-wcm/fckeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" + flashBrowserURL="/pal-wcm/fckeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" + imageUploadURL="/pal-wcm/fckeditor/editor/filemanager/upload/simpleuploader?Type=Image" + linkUploadURL="/pal-wcm/fckeditor/editor/filemanager/upload/simpleuploader?Type=File" + flashUploadURL="/pal-wcm/fckeditor/editor/filemanager/upload/simpleuploader?Type=Flash"> + <%= content %> + </FCK:editor> -<div style="z-index:10000;border-left:1px solid #999999;border-top:1px solid #999999;border-bottom:4px solid #999999;border-right:4px solid #999999;width:750px;height:500px;position:absolute; top:30px; left:30px;background-color:white;"> - <form id="<portlet:namespace/>FCKeditorForm" action="<portlet:actionURL />" method="POST"><input type="hidden" name="<%= PALWcmConstants.ACTION_TYPE %>"/> - <input type="hidden" name="<%= PALWcmConstants.EDIT_TYPE %>" value="<%= PALWcmConstants.CONTENT_EDIT_TYPE %>"/> - <input type="hidden" name="<%= PALWcmConstants.FRAGMENT_ID %>" - value="<%= renderRequest.getAttribute(PALWcmConstants.FRAGMENT_ID) %>"/> - <div style="width:100%;height:25px;background-color:#efefde;"> - <div style="float:left;height:25px;font-size:10pt;font-family:sans-serif;color:#666666;padding-left:5px;"> - Title: - <input type="text" name="<%= PALWcmConstants.TITLE %>" - value="<%= renderRequest.getAttribute(PALWcmConstants.TITLE) %>" /> - <select size="1" name="<%= PALWcmConstants.EDIT_LOCALE %>"> - <option value="">DEFAULT</option> - <%= renderRequest.getAttribute(PALWcmConstants.LOCALE_LIST) %> - </select> - <button style="height:22px;font-size:9px;" type="submit" onclick="this.form.firstChild.value='<%= PALWcmConstants.CHANGE_LOCALE %>'"><img style="vertical-align:middle;" src="<%= renderRequest.getContextPath() %>/images/icons/arrow_refresh.png"/>Reload</button> - <span><%= renderRequest.getAttribute(PALWcmConstants.MESSAGE) %></span> - </div> - <div style="float:right;height:25px"> - <a href="<%= preferencesEditUrl %>"><img src="<%= renderRequest.getContextPath() %>/images/icons/cog.png" alt="Preferences" style="border: 0px;"/></a> - <a href="<%= closeUrl %>"><img src="<%= renderRequest.getContextPath() %>/images/icons/cross.png" alt="Close" style="border: 0px;"/></a> - </div> - </div> - - <div style="clear:both;"> -<script type="text/javascript" src="<%= renderRequest.getContextPath() %>/fckeditor/fckeditor.js"></script> -<script type="text/javascript"> -<!-- -var <portlet:namespace/>FCKeditor = new FCKeditor("<%= PALWcmConstants.CONTENT %>"); -<portlet:namespace/>FCKeditor.BasePath = "<%= renderRequest.getContextPath() %>/fckeditor/"; -<portlet:namespace/>FCKeditor.Value = "<%= renderRequest.getAttribute(PALWcmConstants.CONTENT) %>"; -<portlet:namespace/>FCKeditor.Height = 475; -var url = '<%= renderRequest.getContextPath() %>/fckeditor/editor/filemanager/browser/default/browser.html'; -var connector = '<%= renderRequest.getContextPath() %>/fileconnector%3fnamespace=<portlet:namespace/>'; -<portlet:namespace/>FCKeditor.Config['LinkBrowserURL'] = url + '?Connector=' + connector + '&Type=Link'; -<portlet:namespace/>FCKeditor.Config['ImageBrowserURL'] = url + '?Connector=' + connector + '&Type=Image'; -<portlet:namespace/>FCKeditor.Config['FlashBrowserURL'] = url + '?Connector=' + connector + '&Type=Flash'; -url = '<%= renderRequest.getContextPath() %>/fileupload?namespace=<portlet:namespace/>'; -<portlet:namespace/>FCKeditor.Config['LinkUploadURL'] = url + '&type=Link'; -<portlet:namespace/>FCKeditor.Config['ImageUploadURL'] = url + '&type=Image'; -<portlet:namespace/>FCKeditor.Config['FlashUploadURL'] = url + '&type=Flash'; -<portlet:namespace/>FCKeditor.Create(); -//--> -</script> - </div> - - </form> -</div> + <br> + </form> + </body> +</html> Added: pal-wcm/trunk/src/main/webapp/view/wcm/wcmViewAndEdit.jsp =================================================================== --- pal-wcm/trunk/src/main/webapp/view/wcm/wcmViewAndEdit.jsp (rev 0) +++ pal-wcm/trunk/src/main/webapp/view/wcm/wcmViewAndEdit.jsp 2008-06-04 09:09:47 UTC (rev 950) @@ -0,0 +1,29 @@ +<%@ page language="java" import="jp.sf.pal.wcm.*, java.util.*,javax.servlet.*" %> +<%-- +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--%> +<script type="text/javascript" language="javascript"> +<!-- +window.onload = function(){ + var tmp = '<%=request.getContextPath()%>' + "/view/wcm/wcmEdit.jsp"; + tmp += '?content=' + encodeURI('<%=request.getAttribute(PALWcmConstants.CONTENT)%>'); + tmp += '&fragID=' + '<%=request.getAttribute(PALWcmConstants.FRAGMENT_ID)%>' + w = window.open(tmp,null); +} +--> +</script> + +<%=request.getAttribute(jp.sf.pal.wcm.PALWcmConstants.CONTENT)%>