Author: thomas.heute(a)jboss.com
Date: 2007-03-06 12:04:55 -0500 (Tue, 06 Mar 2007)
New Revision: 6556
Added:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSEditorConstants.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
Modified:
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml
Log:
CMS Content Editor
Added:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
(rev 0)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-06
17:04:55 UTC (rev 6556)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.cms.ui.admin;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.jboss.portal.cms.CMS;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.core.admin.ui.content.ContentEditors;
+import org.jboss.portal.core.model.content.ContentType;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CMSContentEditorPortlet extends GenericPortlet
+{
+
+ private CMS cmsService;
+
+
+ public void init() throws PortletException
+ {
+ cmsService = (CMS)getPortletContext().getAttribute("CMS");
+ ContentEditors.getInstance().registerEditor(ContentType.CMS,
"CMSContentEditorInstance");
+ }
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ String uri = req.getParameter("uri");
+ String path = req.getParameter("path");
+ if (uri != null)
+ {
+ resp.setRenderParameter("uri", uri);
+ }
+ if (path != null)
+ {
+ resp.setRenderParameter("path", path);
+ }
+ }
+
+ public void render(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+
+ String sPath = req.getParameter("path");
+ if (sPath == null)
+ {
+ sPath = "/";
+ }
+
+ Command listCMD =
cmsService.getCommandFactory().createFolderGetListCommand(sPath);
+ Folder mainFolder = (Folder)cmsService.execute(listCMD);
+ List folders = mainFolder.getFolders();
+ List files = mainFolder.getFiles();
+
+ resp.setContentType("text/html");
+ req.setAttribute("folders", folders);
+ req.setAttribute("files", files);
+ req.setAttribute("currpath", sPath);
+
+
+ javax.portlet.PortletRequestDispatcher prd =
getPortletContext().getRequestDispatcher(CMSEditorConstants.CMS_EDITOR_JSP_PATH +
"/main.jsp");
+ prd.include(req, resp);
+
+ }
+
+
+}
Added: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSEditorConstants.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSEditorConstants.java
(rev 0)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSEditorConstants.java 2007-03-06
17:04:55 UTC (rev 6556)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.cms.ui.admin;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CMSEditorConstants
+{
+ /** Our path to jsp pages * */
+ public static final String CMS_EDITOR_JSP_PATH = "/WEB-INF/jsp/cms/editor";
+
+}
Added: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
(rev 0)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp 2007-03-06
17:04:55 UTC (rev 6556)
@@ -0,0 +1,127 @@
+<%@ page import="org.jboss.portal.cms.model.File" %>
+<%@ page import="org.jboss.portal.cms.model.Folder" %>
+<%@ page import="org.jboss.portal.core.cms.ui.admin.CMSAdminConstants"
%>
+<%@ page import="java.text.Format" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="java.util.List" %>
+<%@ page import="java.util.StringTokenizer" %>
+<%@ page language="java"
extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
+<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
+<%@ taglib
uri="http://java.sun.com/portlet" prefix="portlet"
%>
+<%@ page isELIgnored="false" %>
+
+<portlet:defineObjects/>
+
+<%
+ String sCurrPath = (String)request.getAttribute("currpath");
+ List folders = (List)request.getAttribute("folders");
+ List files = (List)request.getAttribute("files");
+ String uri = (String)renderRequest.getParameter("uri");
+%>
+
+<!-- Currently browsing -->
+Browsing: <a href="<portlet:renderURL>
+<portlet:param name="op" value="<%= CMSAdminConstants.OP_MAIN
%>"/>
+<portlet:param name="path" value="/"/>
+ </portlet:renderURL>">Home</a>
+<%
+ StringTokenizer parser = new StringTokenizer(sCurrPath, "/");
+ String sPathBuilder = "";
+ while (parser.hasMoreTokens())
+ {
+ String sPathChunk = parser.nextToken();
+ sPathBuilder += "/" + sPathChunk;
+ if (parser.hasMoreTokens())
+ {
+%>
+> <a href="
+<portlet:renderURL>
+ <portlet:param name="op" value="<%= CMSAdminConstants.OP_MAIN
%>"/>
+ <portlet:param name="path" value="<%= sPathBuilder
%>"/>
+</portlet:renderURL>
+"><%= sPathChunk %>
+</a>
+<%
+}
+else
+{
+%>
+> <%= sPathChunk %>
+<%
+ }
+ }
+%>
+
+<br/><br/>
+
+<%
+
+ if (folders.size() > 0 || files.size() > 0)
+ {
+
+%>
+
+<table width="100%" border="0" cellspacing="2"
cellpadding="2">
+<tr>
+ <td
class="portlet-section-header">${n:i18n("CMS_NAME")}</td>
+</tr>
+
+<%
+ if (folders.size() > 0)
+ {
+ for (int i = 0; i < folders.size(); i++)
+ {
+ Folder folder = (Folder)folders.get(i);
+%>
+<tr onmouseover="this.className='portlet-section-alternate';"
onmouseout="this.className='portlet-section-body';">
+ <td><img
+ src="<%= renderRequest.getContextPath() +
CMSAdminConstants.DEFAULT_IMAGES_PATH%>/folder.gif"
+ alt="${n:i18n("CMS_FOLDER")}"
+ border="0"> <a href="<portlet:renderURL>
+ <portlet:param name="op" value="<%=
CMSAdminConstants.OP_MAIN %>"/>
+ <portlet:param name="path" value="<%= folder.getBasePath()
%>"/>
+ </portlet:renderURL>"><%=
+ folder.getBasePath().substring(folder.getBasePath().lastIndexOf("/") + 1,
folder.getBasePath().length()) %>
+ </a>
+ </td>
+</tr>
+<%
+ }
+ }
+%>
+<%
+ if (files.size() > 0)
+ {
+ for (int j = 0; j < files.size(); j++)
+ {
+ File file = (File)files.get(j);
+
+ if ((uri!=null) && (uri.equals(file.getBasePath())))
+ {
+ out.println("<tr
class=\"portlet-section-selected\">");
+ }
+ else
+ {
+ out.println("<tr
onmouseover=\"this.className='portlet-section-alternate';\"
onmouseout=\"this.className='portlet-section-body';\">");
+ }
+%>
+ <td><img src="<%= renderRequest.getContextPath() +
CMSAdminConstants.DEFAULT_IMAGES_PATH%>/file.gif"
+ alt="${n:i18n("CMS_FILE")}"
+ border="0"> <a href="<portlet:actionURL>
+ <portlet:param name="uri" value="<%= file.getBasePath()
%>"/>
+ <portlet:param name="path" value="<%= sCurrPath
%>"/>
+ </portlet:actionURL>"><%=
+ file.getBasePath().substring(file.getBasePath().lastIndexOf("/") + 1,
file.getBasePath().length()) %>
+ </a>
+ </td>
+</tr>
+<%
+ }
+ }
+%>
+</table>
+<%
+
+ }
+
+%>
Property changes on:
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/editor/main.jsp
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml 2007-03-06
16:51:17 UTC (rev 6555)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml 2007-03-06
17:04:55 UTC (rev 6556)
@@ -47,4 +47,10 @@
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>CMSContentEditorInstance</instance-id>
+ <portlet-ref>CMSContentEditorPortlet</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml 2007-03-06 16:51:17
UTC (rev 6555)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet.xml 2007-03-06 17:04:55
UTC (rev 6556)
@@ -68,4 +68,24 @@
<title>CMS Administration</title>
</portlet-info>
</portlet>
+
+ <portlet>
+ <description>CMS Content Editor</description>
+ <portlet-name>CMSContentEditorPortlet</portlet-name>
+ <display-name>CMS Content Editort</display-name>
+
+
<portlet-class>org.jboss.portal.core.cms.ui.admin.CMSContentEditorPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <supported-locale>en</supported-locale>
+ <supported-locale>fr</supported-locale>
+ <supported-locale>es</supported-locale>
+ <resource-bundle>Resource</resource-bundle>
+ <portlet-info>
+ <title>CMS Content Type</title>
+ </portlet-info>
+ </portlet>
+
</portlet-app>