Author: kevinshen
Date: 2010-03-17 09:23:00 +0100 (Wed, 17 Mar 2010)
New Revision: 41455

Added:
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/builders/sitemanagement/pageproperty.xml
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/pageproperty/
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/pageproperty/search_page_insrel_pageproperty.xml
   
CMSContainer/trunk/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/InsertPagePropertyTag.java
Modified:
   
CMSContainer/trunk/CMSContainer/cmsc/portal/src/java/com/finalist/cmsc/portalImpl/PageNavigationItemManager.java
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/applications/sitemanagement.xml
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/beans/om/Page.java
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/PagesUtil.java
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/edit_page.xml
   
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/load_page.xml
   CMSContainer/trunk/CMSContainer/cmsc/taglib/src/tld/cmsc.tld
Log:
CMSC-1641 Properties for pages, sites and newsletters

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/portal/src/java/com/finalist/cmsc/portalImpl/PageNavigationItemManager.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/portal/src/java/com/finalist/cmsc/portalImpl/PageNavigationItemManager.java
    2010-03-17 08:14:05 UTC (rev 41454)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/portal/src/java/com/finalist/cmsc/portalImpl/PageNavigationItemManager.java
    2010-03-17 08:23:00 UTC (rev 41455)
@@ -83,6 +83,7 @@
       loadLayout(node, page);
       loadStylesheet(node, page);
       loadPageImages(node, page);
+      loadPageProperties(node, page);
       return page;
    }
 
@@ -111,6 +112,11 @@
       page.setPageImages(pageImages);
    }
 
+   protected void loadPageProperties(Node pageNode, Page page) {
+      Map<String, String> pageProperties = 
PagesUtil.getPageProperties(pageNode);
+      page.setPageProperties(pageProperties);
+   }
+   
    /**
     * publishing of sites and pages is done by the publish module
     *

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/applications/sitemanagement.xml
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/applications/sitemanagement.xml
  2010-03-17 08:14:05 UTC (rev 41454)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/applications/sitemanagement.xml
  2010-03-17 08:23:00 UTC (rev 41455)
@@ -66,6 +66,7 @@
       <relation from="contentelement" to="page" type="inlinerel" />
        
          <relation from="page" to="pagegroup" type="related" />
+         <relation from="page" to="pageproperty" type="related" />
    </allowedrelationlist>
 
 

Added: 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/builders/sitemanagement/pageproperty.xml
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/builders/sitemanagement/pageproperty.xml
                         (rev 0)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/config/builders/sitemanagement/pageproperty.xml
 2010-03-17 08:23:00 UTC (rev 41455)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<builder extends="object" maintainer="finalist.com" name="pageproperty" 
version="1"
+    xmlns="http://www.mmbase.org/xmlns/builder";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://www.mmbase.org/xmlns/builder 
http://www.mmbase.org/xmlns/builder.xsd";>
+    <names>
+        <singular xml:lang="nl">Page Property</singular>
+        <singular xml:lang="en">Page Property</singular>
+        <singular xml:lang="zh">页面属性</singular>
+        <plural xml:lang="nl">Page Property</plural>
+        <plural xml:lang="en">Page Property</plural>
+        <plural xml:lang="zh">页面属性</plural>
+    </names>
+    <fieldlist>       
+        <!-- Page property fields -->
+        <field name="key">
+            <gui>
+                <guiname xml:lang="nl">Sleutel</guiname>
+                <guiname xml:lang="en">Key</guiname>
+                <guiname xml:lang="zh">属性关键字</guiname>
+            </gui>
+            <editor>
+                <positions/>
+            </editor>
+            <datatype base="line" 
xmlns="http://www.mmbase.org/xmlns/datatypes";>
+                <maxLength value="100"/>
+            </datatype>
+        </field>
+        <field name="value">
+            <gui>
+                <guiname xml:lang="en">Waarde</guiname>
+                <guiname xml:lang="nl">Value</guiname>
+                <guiname xml:lang="zh">属性值</guiname>
+            </gui>
+            <editor>
+                <positions/>
+            </editor>
+            <datatype base="line" 
xmlns="http://www.mmbase.org/xmlns/datatypes";>
+                <maxLength value="100"/>
+            </datatype>
+        </field>
+    </fieldlist>
+</builder>

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/beans/om/Page.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/beans/om/Page.java
   2010-03-17 08:14:05 UTC (rev 41454)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/beans/om/Page.java
   2010-03-17 08:23:00 UTC (rev 41455)
@@ -23,18 +23,24 @@
    private int layout;
    private List<Integer> stylesheet = new ArrayList<Integer>();
    private Map<String,List<Integer>> pageImages = new 
HashMap<String,List<Integer>>();
+   private Map<String,String> pageProperties = new HashMap<String,String>();
 
-
    public int getLayout() {
       return layout;
    }
-
-
+   
    public void setLayout(int layout) {
       this.layout = layout;
    }
 
+   public Map<String, String> getPageProperties() {
+      return pageProperties;
+   }
 
+   public void setPageProperties(Map<String, String> pageProperties) {
+      this.pageProperties = pageProperties;
+   }
+
    public List<Integer> getStylesheet() {
       return stylesheet;
    }

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/PagesUtil.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/PagesUtil.java
    2010-03-17 08:14:05 UTC (rev 41454)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/java/com/finalist/cmsc/navigation/PagesUtil.java
    2010-03-17 08:23:00 UTC (rev 41455)
@@ -66,7 +66,10 @@
 
    public static final String POS_FIELD = "pos";
 
-
+   public static final String PAGEPROPERTY = "pageproperty";
+   public static final String KEY_FIELD = "key";
+   public static final String VALUE_FIELD = "value";
+   
    private PagesUtil() {
       // utility
    }
@@ -561,4 +564,15 @@
       }
    }
 
+   public static Map<String, String> getPageProperties(Node pageNode) {
+      NodeList propertyNodes = pageNode.getRelatedNodes(PAGEPROPERTY, RELATED, 
DESTINATION);
+      Map<String,String> pageProperties = new HashMap<String,String>();
+      if (propertyNodes != null && propertyNodes.size() > 0) {
+         for (Node node: propertyNodes) {
+            pageProperties.put(node.getStringValue(KEY_FIELD), 
node.getStringValue(VALUE_FIELD));
+         }
+      }
+      return pageProperties;
+  }
+   
 }

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/edit_page.xml
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/edit_page.xml
    2010-03-17 08:14:05 UTC (rev 41454)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/edit_page.xml
    2010-03-17 08:23:00 UTC (rev 41455)
@@ -42,6 +42,7 @@
    <list include="config/layout/search_page_layoutrel_layout.xml" />
    <list include="config/stylesheet/search_page_stylerel_stylesheet.xml" />
    <list include="config/images/search_page_namedrel_images.xml" />
+   <list include="config/pageproperty/search_page_insrel_pageproperty.xml" />
    <!--If using sso
    <list include="config/pagegroup/search_page_related_pagegroup.xml" />-->
 </form-schema>
\ No newline at end of file

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/load_page.xml
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/load_page.xml
    2010-03-17 08:14:05 UTC (rev 41454)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/page/load_page.xml
    2010-03-17 08:23:00 UTC (rev 41455)
@@ -18,7 +18,7 @@
        <relation destination="images" role="namedrel" />
        <relation destination="layout" role="layoutrel" />
        <relation destination="stylesheet" role="stylerel" />
-       
+       <relation destination="pageproperty" role="related" />
 <!--<relation destination="pagegroup" role="related" />
        <relation destination="page" role="navrel" />
        <relation destination="portlet" role="portletrel" />

Added: 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/pageproperty/search_page_insrel_pageproperty.xml
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/pageproperty/search_page_insrel_pageproperty.xml
                              (rev 0)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/sitemanagement/src/webapp/editors/config/pageproperty/search_page_insrel_pageproperty.xml
      2010-03-17 08:23:00 UTC (rev 41455)
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!DOCTYPE list PUBLIC "-//MMBase/DTD editwizard 1.0//EN" 
"http://www.mmbase.org/dtd/wizard-schema_1_0.dtd";>
+<list role="related" destination="pageproperty" minoccurs="0" maxoccurs="*" 
ordertype="string" >
+       
+       <title xml:lang="nl">Properties</title>
+       <title xml:lang="en">Properties</title>
+       <title xml:lang="zh">页面属性</title>
+
+       <item>
+               <field ftype="line" name="key" dtmaxlength="100">
+                       <prompt xml:lang="en">Key</prompt>
+                       <prompt xml:lang="nl">Sleutel</prompt>
+                       <prompt xml:lang="zh">属性</prompt>
+               </field>
+               <field ftype="line" name="value" dtmaxlength="100">
+                       <prompt xml:lang="en">Value</prompt>
+                       <prompt xml:lang="nl">Waarde</prompt>
+                       <prompt xml:lang="zh">属性值</prompt>
+               </field>
+       </item> 
+
+       <command name="insert" objectnumber="new">
+               <prompt xml:lang="en">New</prompt>
+               <prompt xml:lang="nl">Nieuw</prompt>
+               <prompt xml:lang="zh">新建</prompt>
+       </command>
+
+       <action type="create">
+               <relation role="related">
+                       <object type="pageproperty" />
+               </relation>
+       </action>
+</list>
\ No newline at end of file

Added: 
CMSContainer/trunk/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/InsertPagePropertyTag.java
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/InsertPagePropertyTag.java
                            (rev 0)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/taglib/src/java/com/finalist/cmsc/taglib/InsertPagePropertyTag.java
    2010-03-17 08:23:00 UTC (rev 41455)
@@ -0,0 +1,141 @@
+package com.finalist.cmsc.taglib;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.PageContext;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.finalist.cmsc.beans.om.Page;
+import com.finalist.cmsc.services.sitemanagement.SiteManagement;
+
+public class InsertPagePropertyTag extends CmscTag {
+
+   private static Log log = LogFactory.getLog(InsertPagePropertyTag.class);
+
+   // tag parameters
+   private String var;
+   private String key;
+   private String inherit;
+   private String page;
+   
+   
+   public String getKey() {
+      return key;
+   }
+
+
+   public void setKey(String key) {
+      this.key = key;
+   }
+
+
+   public String getPage() {
+      return page;
+   }
+
+
+   public void setPage(String page) {
+      this.page = page;
+   }
+
+
+   public String getVar() {
+      return var;
+   }
+
+
+   public String getInherit() {
+      return inherit;
+   }
+
+   public void setVar(String var) {
+      this.var = var;
+   }
+
+
+   public void setInherit(String inherit) {
+      this.inherit = inherit;
+   }
+
+   @Override
+   public void doTag() {
+      PageContext ctx = (PageContext) getJspContext();
+      HttpServletRequest request = (HttpServletRequest) ctx.getRequest();
+
+      String value = null;
+      Map<String,String> properties = null;
+      if (StringUtils.isNotEmpty(page)) {
+         properties = getPagePropertiesForPage(page);
+      }
+      else {
+         properties = getPagePropertiesFromPath(getPath());
+      }
+      if (properties != null && !properties.isEmpty()) {
+         value = properties.get(key);
+      }
+      // handle result
+      if (value != null) {
+         if (var != null) {
+            request.setAttribute(var, value);
+         }
+         else {
+            try {
+               ctx.getOut().print(value);
+            }
+            catch (IOException e) {
+               log.error("Unable to write property value to the output: " + e);
+            }
+         }
+      }
+      else {
+         log.debug("property with name " + key + " not found for path: " + 
getPath());
+      }
+   }
+   
+   private Map<String,String> getPagePropertiesForPage(String pageId) {
+
+      String path = SiteManagement.getPath(Integer.parseInt(pageId), true);
+      return getPagePropertiesFromPath(path);
+   }
+   
+   private Map<String,String> getPagePropertiesFromPath(String path) {
+      boolean directly = StringUtils.equals(this.inherit, "directly");
+      boolean override = StringUtils.equals(this.inherit, "override");
+      boolean noInherit = StringUtils.equals(this.inherit, "false");
+      Map<String,String> properties = getCurrentPageProperties(path);
+      
+      if (!noInherit &&((override && properties.size() == 0) || directly)) { 
// inherit from parent.
+         properties.putAll(getPropertiesOfParent(path));
+      }
+      return properties;
+   }
+   
+   /**
+    * Search for images of parent pages and return an image when found.
+    * @return the image of a parent page
+    */
+   private Map<String,String> getPropertiesOfParent(String path) {
+      List<Page> pages = SiteManagement.getPagesFromPath(path);
+      Map<String, String> properties =  new HashMap<String, String>();
+      if (pages.size() > 1) {
+         for (int i = pages.size() - 2; i >= 0; i--) {
+            if (pages.get(i).getPageProperties().size() > 0)
+               properties.putAll(pages.get(i).getPageProperties());
+         }
+      }
+      return properties;
+   }
+
+
+   private Map<String,String> getCurrentPageProperties(String path) {
+      List<Page> pages = SiteManagement.getPagesFromPath(path);
+      return (pages.get(pages.size() - 1)).getPageProperties();
+   }
+}

Modified: CMSContainer/trunk/CMSContainer/cmsc/taglib/src/tld/cmsc.tld
===================================================================
--- CMSContainer/trunk/CMSContainer/cmsc/taglib/src/tld/cmsc.tld        
2010-03-17 08:14:05 UTC (rev 41454)
+++ CMSContainer/trunk/CMSContainer/cmsc/taglib/src/tld/cmsc.tld        
2010-03-17 08:23:00 UTC (rev 41455)
@@ -1670,6 +1670,36 @@
             <rtexprvalue>true</rtexprvalue>
         </attribute>
     </tag>
+    <tag>
+        <description>Insert one of the property of a page</description>
+        <name>insert-page-property</name>
+        <tag-class>com.finalist.cmsc.taglib.InsertPagePropertyTag</tag-class>
+        <body-content>empty</body-content>
+        <attribute>
+            <description>JSP variable to set property value.</description>
+            <name>var</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+        </attribute>
+        <attribute>
+            <description>The number of a page/site/newsletter</description>
+            <name>page</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+        </attribute>
+        <attribute>
+            <description>The method of inherit properties from parent page, 
options: "override" (to override the parent options), "directly" (to merge all 
the parent images) and "false" (for no inheritance, default)</description>
+            <name>inherit</name>
+            <required>false</required>
+            <rtexprvalue>false</rtexprvalue>
+        </attribute>
+        <attribute>
+            <description>Key of the property of a page</description>
+            <name>key</name>
+            <required>true</required>
+            <rtexprvalue>false</rtexprvalue>
+        </attribute>
+    </tag>
 
     <tag-file>
         <name>flash</name>

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to