Author: billyxie Date: 2009-10-28 08:09:47 +0100 (Wed, 28 Oct 2009) New Revision: 39398
Added: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/collectionchannel_available.png CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_chiefeditor_gray.gif CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_editor_gray.gif CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_webmaster_gray.gif CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_writer_gray.gif CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/collectionchannel/ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/collectionchannel/search_rssfeed_related_collectionchannel.xml Modified: CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/select/forms/SelectorAction.java CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/webapp/editors/repository/select/selectorpopup.jsp CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/editwizards_new/xsl/wizard.xsl CMSContainer/trunk/CMSContainer/cmsc/utilities/src/webapp/editors/utils/ajaxtree/ajaxtree.js CMSContainer/trunk/CMSContainer_Modules/rssfeed/config/applications/rssfeed.xml CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationItemManager.java CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationRenderer.java CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/beans/om/RssFeed.java CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/util/RssFeedUtil.java CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/contentchannel/search_rssfeed_related_contentchannel.xml CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/edit_rssfeed.xml CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/load_rssfeed.xml Log: CMSC-1150 - Cannot create RSS feed on collectionchannel / multiple channels Modified: CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/select/forms/SelectorAction.java =================================================================== --- CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/select/forms/SelectorAction.java 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/java/com/finalist/cmsc/repository/select/forms/SelectorAction.java 2009-10-28 07:09:47 UTC (rev 39398) @@ -9,18 +9,25 @@ */ package com.finalist.cmsc.repository.select.forms; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.mmbase.bridge.Cloud; +import org.mmbase.bridge.Node; +import org.mmbase.bridge.NodeList; -import org.apache.struts.action.*; -import org.mmbase.bridge.*; - import com.finalist.cmsc.mmbase.TreeUtil; -import com.finalist.cmsc.repository.*; +import com.finalist.cmsc.repository.RepositoryInfo; +import com.finalist.cmsc.repository.RepositoryTreeModel; +import com.finalist.cmsc.repository.RepositoryUtil; import com.finalist.cmsc.repository.select.SelectRenderer; import com.finalist.cmsc.util.bundles.JstlUtil; import com.finalist.tree.TreeInfo; @@ -38,6 +45,7 @@ String action = request.getParameter("action"); String portletId = request.getParameter("portletId"); + String from = request.getParameter("onlycollection"); if (StringUtils.isEmpty(action)) { RepositoryInfo info = new RepositoryInfo(RepositoryUtil.getRepositoryInfo(cloud)); cloud.setProperty("Selector" + RepositoryInfo.class.getName(), info); @@ -50,6 +58,7 @@ addToRequest(request, "actionname", mapping.getPath()); addToRequest(request, "portletId", portletId); + addToRequest(request, "onlycollection", from); JstlUtil.setResourceBundle(request, "cmsc-repository"); return super.execute(mapping, form, request, response, cloud); Modified: CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/webapp/editors/repository/select/selectorpopup.jsp =================================================================== --- CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/webapp/editors/repository/select/selectorpopup.jsp 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer/cmsc/contentrepository/src/webapp/editors/repository/select/selectorpopup.jsp 2009-10-28 07:09:47 UTC (rev 39398) @@ -18,12 +18,12 @@ ajaxTreeConfig.role = '${param.role}'; function selectItem(channel, path) { - opener.selectChannel(channel, path, '${param.fieldName}', '${param.fieldPathName}'); + opener.selectChannel(channel, path, '${param.fieldName}', '${param.fieldPathName}'); close(); } - function loadFunction() { + function loadFunction(show) { alphaImages(); - ajaxTreeLoader.initTree('', 'tree_div'); + ajaxTreeLoader.initTree('', 'tree_div', '', show); } </script> @@ -40,7 +40,7 @@ } </style> </cmscedit:head> -<body style="overflow: auto" onload="loadFunction();"> +<body style="overflow: auto" onload="loadFunction(${onlycollection});"> <cmscedit:sideblock title="selector.title"> <c:if test="${param.message != null}"><h2>${param.message}</h2></c:if> <mm:cloud jspvar="cloud" loginpage="../../login.jsp"> Modified: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/editwizards_new/xsl/wizard.xsl =================================================================== --- CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/editwizards_new/xsl/wizard.xsl 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/editwizards_new/xsl/wizard.xsl 2009-10-28 07:09:47 UTC (rev 39398) @@ -918,13 +918,25 @@ </xsl:template> <xsl:template match="comma...@name='channelselector']" mode="listnewbuttons"> - <td class="listnew"> - <a href="#" onclick="select_fid='{../@fid}';select_did='{../comma...@name='add-item']/@value}';window.open('../../../../editors/repository/select/SelectorContentChannel.do', 'channelselector', getPopupPositionProps(350,500)+',status=yes,toolbar=no,titlebar=no,scrollbars=yes,resizable=yes,menubar=no');" class="button"> - <xsl:call-template name="prompt_search"/> - </a> - </td> + <xsl:if test="not(../../li...@destination='collectionchannel']/item)"> + <td class="listnew" > + <a href="#" onclick="select_fid='{../@fid}';select_did='{../comma...@name='add-item']/@value}';window.open('../../../../editors/repository/select/SelectorContentChannel.do', 'channelselector', getPopupPositionProps(350,500)+',status=yes,toolbar=no,titlebar=no,scrollbars=yes,resizable=yes,menubar=no');" class="button"> + <xsl:call-template name="prompt_search"/> + </a> + </td> + </xsl:if> </xsl:template> + <xsl:template match="comma...@name='collectionselector']" mode="listnewbuttons"> + <xsl:if test="not(../../li...@destination='contentchannel']/item)"> + <td class="listnew" > + <a href="#" onclick="select_fid='{../@fid}';select_did='{../comma...@name='add-item']/@value}';window.open('../../../../editors/repository/select/SelectorChannel.do?onlycollection=true', 'collectionselector', getPopupPositionProps(350,500)+',status=yes,toolbar=no,titlebar=no,scrollbars=yes,resizable=yes,menubar=no');" class="button"> + <xsl:call-template name="prompt_search"/> + </a> + </td> + </xsl:if> + </xsl:template> + <xsl:template match="command" mode="listnewbuttons"> <td class="listnew">xslt template missing for command <xsl:value-of select="@name"/></td> </xsl:template> Added: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/collectionchannel_available.png =================================================================== (Binary files differ) Property changes on: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/collectionchannel_available.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_chiefeditor_gray.gif =================================================================== (Binary files differ) Property changes on: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_chiefeditor_gray.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_editor_gray.gif =================================================================== (Binary files differ) Property changes on: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_editor_gray.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_webmaster_gray.gif =================================================================== (Binary files differ) Property changes on: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_webmaster_gray.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_writer_gray.gif =================================================================== (Binary files differ) Property changes on: CMSContainer/trunk/CMSContainer/cmsc/edit-webapp/src/webapp/editors/gfx/icons/type/contentchannel_writer_gray.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: CMSContainer/trunk/CMSContainer/cmsc/utilities/src/webapp/editors/utils/ajaxtree/ajaxtree.js =================================================================== --- CMSContainer/trunk/CMSContainer/cmsc/utilities/src/webapp/editors/utils/ajaxtree/ajaxtree.js 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer/cmsc/utilities/src/webapp/editors/utils/ajaxtree/ajaxtree.js 2009-10-28 07:09:47 UTC (rev 39398) @@ -209,8 +209,10 @@ } }; +var onlyShowCollectionChannel = false; ajaxTreeLoader = { - initTree : function (persistentId, elementId, portletId) { + initTree : function (persistentId, elementId, portletId, show) { + onlyShowCollectionChannel = show; var treeAction = new AjaxTreeAction(); treeAction.elementId = elementId; treeAction.execute('inittree', persistentId, portletId); @@ -523,7 +525,14 @@ } AjaxTreeAbstractNode.prototype.openTreeItem = function() { - if (ajaxTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.openIcon; } + var newOpenIcon; + if(__isNeedShowCollectionChannel(this.openIcon)){ + newOpenIcon = this.openIcon.replace(".png","_gray.gif"); + } else { + newOpenIcon = this.openIcon; + } + + if (ajaxTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = newOpenIcon; } if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'block'; } this.open = true; try { @@ -535,7 +544,13 @@ } AjaxTreeAbstractNode.prototype.closeTreeItem = function() { - if (ajaxTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.icon; } + var newIcon; + if(__isNeedShowCollectionChannel(this.icon)){ + newIcon = this.icon.replace(".png","_gray.gif"); + } else { + newIcon = this.icon; + } + if (ajaxTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = newIcon; } if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'none'; } this.open = false; try { @@ -676,21 +691,44 @@ return true; } +function __isNeedShowCollectionChannel(icon) { + if(!icon) return false; + + return (onlyShowCollectionChannel && (icon.indexOf('contentchannel_webmaster.png') > -1 || icon.indexOf('contentchannel_chiefeditor.png') > -1 || icon.indexOf('contentchannel_editor.png') > -1 || icon.indexOf('contentchannel_writer.png') > -1)); +} + AjaxTree.prototype.toString = function() { var sbOption = []; for (var i = 0; i < this.options.length; i++) { sbOption[i] = this.options[i].toString(i,this.options.length); } var str = "<div id=\"" + this.id + "\" ondblclick=\"ajaxTreeHandler.toggle(this);\" class=\"ajax-tree-item\" style.position = 'absolute';" + - "onkeydown=\"return ajaxTreeHandler.keydown(this, event)\" oncontextmenu=\"ajaxTreeHandler.showContextMenu(this,event);return false\">" + - "<img id=\"" + this.id + "-icon\" class=\"ajax-tree-icon\" src=\"" + - ((ajaxTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) - + "\" onclick=\"ajaxTreeHandler.select(this);\" />"; + "onkeydown=\"return ajaxTreeHandler.keydown(this, event)\" oncontextmenu=\"ajaxTreeHandler.showContextMenu(this,event);return false\">"; + var newIcon, newOpenIcon; + if(__isNeedShowCollectionChannel(this.icon)){ + newIcon = this.icon.replace(".png","_gray.gif"); + } else { + newIcon = this.icon; + } + if(__isNeedShowCollectionChannel(this.openIcon)){ + newOpenIcon = this.openIcon.replace(".png","_gray.gif"); + } else { + newOpenIcon = this.openIcon; + } + str += "<img id=\"" + this.id + "-icon\" class=\"ajax-tree-icon\" src=\"" + + ((ajaxTreeHandler.behavior == 'classic' && this.open)?newOpenIcon:newIcon) + + "\" onclick=\"ajaxTreeHandler.select(this);\" />"; if(hasRights(this.icon)) { - str += "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"ajaxTreeHandler.focus(this);\" onmouseover=\"ajaxTreeHandler.imouseover(this); return true;\" " + - "onblur=\"ajaxTreeHandler.blur(this);\"" + (this.target ? " target=\"" + this.target + "\"" : "") + - ">" + this.text + "</a>" + if(__isNeedShowCollectionChannel(this.icon)){ + str += "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"ajaxTreeHandler.focus(this);\" onmouseover=\"ajaxTreeHandler.imouseover(this); return true;\" onclick=\"return false\" " + + "onblur=\"ajaxTreeHandler.blur(this);\"" + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + this.text + "</a>" + } else { + str += "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"ajaxTreeHandler.focus(this);\" onmouseover=\"ajaxTreeHandler.imouseover(this); return true;\" " + + "onblur=\"ajaxTreeHandler.blur(this);\"" + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + this.text + "</a>" + } } else { str += "<font style='color:#777'>"+this.text+"</font>" @@ -967,15 +1005,36 @@ var str = "<div id=\"" + this.id + "\" ondblclick=\"ajaxTreeHandler.toggle(this);\" class=\"ajax-tree-item\" style.position = 'absolute';" + "onkeydown=\"return ajaxTreeHandler.keydown(this, event)\" oncontextmenu=\"ajaxTreeHandler.showContextMenu(this,event);return false;\">" + indent + - "<img id=\"" + this.id + "-plus\" src=\"" + treeIcon + "\" onclick=\"ajaxTreeHandler.toggle(this);\" />" + - "<img id=\"" + this.id + "-icon\" class=\"ajax-tree-icon\" src=\"" + - ((ajaxTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + - "\" onclick=\"ajaxTreeHandler.isclick(this);ajaxTreeHandler.select(this);\" onmousedown=\"ajaxTreeHandler.makeDraggable(this);\" />"; + "<img id=\"" + this.id + "-plus\" src=\"" + treeIcon + "\" onclick=\"ajaxTreeHandler.toggle(this);\" />"; + var newIcon, newOpenIcon; + if(__isNeedShowCollectionChannel(this.icon)){ + newIcon = this.icon.replace(".png","_gray.gif"); + } else if(onlyShowCollectionChannel && this.icon && this.icon.indexOf('collectionchannel.png') > -1){ + newIcon = this.openIcon.replace(".png","_available.png") + } else { + newIcon = this.icon; + } + if(__isNeedShowCollectionChannel(this.openIcon)){ + newOpenIcon = this.openIcon.replace(".png","_gray.gif"); + } else if(onlyShowCollectionChannel && this.openIcon && this.openIcon.indexOf('collectionchannel.png') > -1){ + newOpenIcon = this.openIcon.replace(".png","_available.png") + } else { + newOpenIcon = this.openIcon; + } + str += "<img id=\"" + this.id + "-icon\" class=\"ajax-tree-icon\" src=\"" + + ((ajaxTreeHandler.behavior == 'classic' && this.open)?newOpenIcon:newIcon) + + "\" onclick=\"ajaxTreeHandler.isclick(this);ajaxTreeHandler.select(this);\" onmousedown=\"ajaxTreeHandler.makeDraggable(this);\" />"; if(hasRights(this.icon)) { - str += "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"ajaxTreeHandler.focus(this);\" onmouseover=\"ajaxTreeHandler.imouseover(this); return true;\" " + - "onblur=\"ajaxTreeHandler.blur(this);\"" + (this.target ? " target=\"" + this.target + "\"" : "") + - ">" + this.text + "</a>" + if(__isNeedShowCollectionChannel(this.icon)){ + str += "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"ajaxTreeHandler.focus(this);\" onmouseover=\"ajaxTreeHandler.imouseover(this); return true;\" onclick=\"return false\" " + + "onblur=\"ajaxTreeHandler.blur(this);\"" + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + this.text + "</a>" + } else { + str += "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"ajaxTreeHandler.focus(this);\" onmouseover=\"ajaxTreeHandler.imouseover(this); return true;\" " + + "onblur=\"ajaxTreeHandler.blur(this);\"" + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + this.text + "</a>" + } } else { str += "<font style='color:#777'>"+this.text+"</font>" Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/config/applications/rssfeed.xml =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/config/applications/rssfeed.xml 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/config/applications/rssfeed.xml 2009-10-28 07:09:47 UTC (rev 39398) @@ -1,6 +1,6 @@ <?xml version="1.0"?> <!DOCTYPE application PUBLIC "-//MMBase/DTD application config 1.1//EN" "http://www.mmbase.org/dtd/application_1_1.dtd"> -<application name="rssfeed" maintainer="finalist.com" version="1" auto-deploy="true"> +<application name="rssfeed" maintainer="finalist.com" version="2" auto-deploy="true"> <requirements> <requires name="contentrepository" maintainer="finalist.com" version="4" type="application"/> <requires name="sitemanagement" maintainer="finalist.com" version="1" type="application"/> @@ -17,6 +17,7 @@ <allowedrelationlist> <relation from="page" to="rssfeed" type="navrel" /> <relation from="rssfeed" to="contentchannel" type="related" /> + <relation from="rssfeed" to="collectionchannel" type="related" /> <relation from="rssfeed" to="typedef" type="allowrel" /> <relation from="mmbasegroups" to="rssfeed" type="rolerel" /> </allowedrelationlist> Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationItemManager.java =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationItemManager.java 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationItemManager.java 2009-10-28 07:09:47 UTC (rev 39398) @@ -9,7 +9,9 @@ import com.finalist.cmsc.beans.MMBaseNodeMapper; import com.finalist.cmsc.beans.om.NavigationItem; -import com.finalist.cmsc.navigation.*; +import com.finalist.cmsc.navigation.NavigationItemManager; +import com.finalist.cmsc.navigation.NavigationItemRenderer; +import com.finalist.cmsc.navigation.NavigationTreeItemRenderer; import com.finalist.cmsc.rssfeed.beans.om.RssFeed; import com.finalist.cmsc.rssfeed.publish.RssFeedPublisher; import com.finalist.cmsc.rssfeed.tree.RssFeedTreeItemRenderer; @@ -70,8 +72,13 @@ Node contentChannel = RssFeedUtil.getContentChannel(node); if (contentChannel != null) { - rssFeed.setContentChannel(contentChannel.getNumber()); + rssFeed.setChannel(contentChannel.getNumber()); } + + Node collectionChannel = RssFeedUtil.getCollectionChannel(node); + if (collectionChannel != null) { + rssFeed.setChannel(collectionChannel.getNumber()); + } return rssFeed; } Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationRenderer.java =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationRenderer.java 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/RssFeedNavigationRenderer.java 2009-10-28 07:09:47 UTC (rev 39398) @@ -2,7 +2,12 @@ import java.io.IOException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; import javax.servlet.ServletConfig; import javax.servlet.http.HttpServletRequest; @@ -12,7 +17,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.mmbase.bridge.*; +import org.mmbase.bridge.Cloud; +import org.mmbase.bridge.Node; +import org.mmbase.bridge.NodeIterator; +import org.mmbase.bridge.NodeList; +import org.mmbase.bridge.NodeQuery; import org.mmbase.bridge.util.SearchUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -23,8 +32,11 @@ import com.finalist.cmsc.repository.ContentElementUtil; import com.finalist.cmsc.repository.RepositoryUtil; import com.finalist.cmsc.rssfeed.beans.om.RssFeed; +import com.finalist.cmsc.rssfeed.util.RssFeedUtil; import com.finalist.cmsc.services.sitemanagement.SiteManagement; -import com.finalist.cmsc.util.*; +import com.finalist.cmsc.util.HttpUtil; +import com.finalist.cmsc.util.ServerUtil; +import com.finalist.cmsc.util.XmlUtil; public class RssFeedNavigationRenderer implements NavigationItemRenderer { @@ -62,7 +74,10 @@ XmlUtil.createChildText(channel, "docs", "http://www.rssboard.org/rss-specification"); List<String> contentTypesList = rssFeed.getContenttypes(); - int contentChannelNumber = rssFeed.getContentChannel(); + int channelNumber = rssFeed.getChannel(); + + Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud(); + Node contentNode = cloud.getNode(channelNumber); int maxAgeInDays = rssFeed.getMax_age_in_days(); @@ -71,65 +86,23 @@ if (maxNumber <= 0) { maxNumber = -1; } + + Set<Node> channelSet = new HashSet<Node>(); + if(RepositoryUtil.isCollectionChannel(Integer.toString(rssFeed.getChannel()))){ + channelSet.addAll(RssFeedUtil.getChildrenChannelsForCollection(contentNode)); + } else { + channelSet.add(contentNode); + } Date lastChange = null; boolean first = true; - if (contentChannelNumber > 0) { - Cloud cloud = CloudProviderFactory.getCloudProvider().getCloud(); - Node contentChannel = cloud.getNode(contentChannelNumber); - - NodeQuery query = RepositoryUtil.createLinkedContentQuery(contentChannel, contentTypesList, - ContentElementUtil.PUBLISHDATE_FIELD, "down", useLifecycle, null, 0, maxNumber, -1, -1, -1); - //Add constraint: max age in days - if (maxAgeInDays > 0) { - SearchUtil.addDayConstraint(query, cloud.getNodeManager(RepositoryUtil.CONTENTELEMENT), ContentElementUtil.PUBLISHDATE_FIELD, "-" + maxAgeInDays); + if (channelSet.size() > 0) { + for(Node node : channelSet){ + lastChange = buildItemsPerChannel(request, channel, contentTypesList, cloud, + node, maxAgeInDays, useLifecycle, maxNumber, lastChange, first); + if(first) first = false; } - NodeList results = query.getNodeManager().getList(query); - for (NodeIterator ni = results.nodeIterator(); ni.hasNext();) { - Node resultNode = ni.nextNode(); - Element itemE = XmlUtil.createChild(channel, "item"); - XmlUtil.createChildText(itemE, "title", resultNode.getStringValue("title")); - - String uniqueUrl = makeAbsolute(getContentUrl(resultNode), request); - XmlUtil.createChildText(itemE, "link", uniqueUrl); - - String description = null; - if (resultNode.getNodeManager().hasField("intro")) { - description = resultNode.getStringValue("intro"); - } - if ((description == null || description.length() == 0) && resultNode.getNodeManager().hasField("body")) { - description = resultNode.getStringValue("body"); - if (description.indexOf("<br/>") != -1) { - description = description.substring(0, description.indexOf("<br/>")); - } - } - if (description != null) { - description = description.replaceAll("<.*?>", ""); - } - XmlUtil.createChildText(itemE, "description", description); - XmlUtil.createChildText(itemE, "pubDate", formatRFC822Date.format(resultNode.getDateValue("publishdate"))); - XmlUtil.createChildText(itemE, "guid", uniqueUrl); - - if (first) { - NodeList images = resultNode.getRelatedNodes("images", "imagerel", "destination"); - if (images.size() > 0) { - Node image = ResourcesUtil.getImageNode(images.getNode(0), 160, 120); //height by width - String imageUrl = image.getFunctionValue("servletpath", null).toString(); - - Element imageE = XmlUtil.createChild(channel, "image"); - XmlUtil.createChildText(imageE, "url", imageUrl); - XmlUtil.createChild(imageE, "title"); - XmlUtil.createChildText(imageE, "link", uniqueUrl); - } - } - first = false; - - Date change = resultNode.getDateValue("lastmodifieddate"); - if (lastChange == null || change.getTime() > lastChange.getTime()) { - lastChange = change; - } - } } if (lastChange != null) { @@ -149,6 +122,71 @@ } } + private Date buildItemsPerChannel(HttpServletRequest request, Element channel, + List<String> contentTypesList, Cloud cloud, Node contentNode, int maxAgeInDays, + boolean useLifecycle, int maxNumber, Date lastChange, boolean first) { + NodeQuery query = RepositoryUtil.createLinkedContentQuery(contentNode, contentTypesList, + ContentElementUtil.PUBLISHDATE_FIELD, "down", useLifecycle, null, 0, maxNumber, -1, -1, + -1); + // Add constraint: max age in days + if (maxAgeInDays > 0) { + SearchUtil.addDayConstraint(query, cloud.getNodeManager(RepositoryUtil.CONTENTELEMENT), + ContentElementUtil.PUBLISHDATE_FIELD, "-" + maxAgeInDays); + } + NodeList results = query.getNodeManager().getList(query); + for (NodeIterator ni = results.nodeIterator(); ni.hasNext();) { + Node resultNode = ni.nextNode(); + Element itemE = XmlUtil.createChild(channel, "item"); + XmlUtil.createChildText(itemE, "title", resultNode.getStringValue("title")); + + String uniqueUrl = makeAbsolute(getContentUrl(resultNode), request); + XmlUtil.createChildText(itemE, "link", uniqueUrl); + + String description = null; + if (resultNode.getNodeManager().hasField("intro")) { + description = resultNode.getStringValue("intro"); + } + if ((description == null || description.length() == 0) + && resultNode.getNodeManager().hasField("body")) { + description = resultNode.getStringValue("body"); + if (description.indexOf("<br/>") != -1) { + description = description.substring(0, description.indexOf("<br/>")); + } + } + if (description != null) { + description = description.replaceAll("<.*?>", ""); + } + XmlUtil.createChildText(itemE, "description", description); + XmlUtil.createChildText(itemE, "pubDate", formatRFC822Date.format(resultNode + .getDateValue("publishdate"))); + XmlUtil.createChildText(itemE, "guid", uniqueUrl); + + if (first) { + NodeList images = resultNode.getRelatedNodes("images", "imagerel", null); + if (images.size() > 0) { + Node image = images.getNode(0); + List<String> arguments = new ArrayList<String>(); + arguments.add("160x100"); + int iCacheNodeNumber = image.getFunctionValue("cache", arguments).toInt(); + String imageUrl = image.getFunctionValue("servletpath", null).toString() + + iCacheNodeNumber; + + Element imageE = XmlUtil.createChild(channel, "image"); + XmlUtil.createChildText(imageE, "url", imageUrl); + XmlUtil.createChild(imageE, "title"); + XmlUtil.createChildText(imageE, "link", uniqueUrl); + } + } + + Date change = resultNode.getDateValue("lastmodifieddate"); + if (lastChange == null || change.getTime() > lastChange.getTime()) { + lastChange = change; + } + } + return lastChange; + } + + private String getSiteUrl(HttpServletRequest request, RssFeed rss) { if (ServerUtil.useServerName()) { return getServerDocRoot(request); Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/beans/om/RssFeed.java =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/beans/om/RssFeed.java 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/beans/om/RssFeed.java 2009-10-28 07:09:47 UTC (rev 39398) @@ -1,6 +1,8 @@ package com.finalist.cmsc.rssfeed.beans.om; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import com.finalist.cmsc.beans.om.NavigationItem; @@ -16,7 +18,7 @@ private String email_webmaster; private List<String> contenttypes = new ArrayList<String>(); - private int contentChannel = -1; + private int channel = -1; public int getMaximum() { return maximum; @@ -74,20 +76,20 @@ this.email_webmaster = email_webmaster; } - public List<String> getContenttypes() { - return Collections.unmodifiableList(contenttypes); - } + public List<String> getContenttypes() { + return Collections.unmodifiableList(contenttypes); + } - public void addContenttype(String contenttypes) { - this.contenttypes.add(contenttypes); - } + public void addContenttype(String contenttypes) { + this.contenttypes.add(contenttypes); + } - public int getContentChannel() { - return contentChannel; - } - - public void setContentChannel(int contentChannel) { - this.contentChannel = contentChannel; - } + public int getChannel() { + return channel; + } + public void setChannel(int channel) { + this.channel = channel; + } + } Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/util/RssFeedUtil.java =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/util/RssFeedUtil.java 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/java/com/finalist/cmsc/rssfeed/util/RssFeedUtil.java 2009-10-28 07:09:47 UTC (rev 39398) @@ -1,6 +1,8 @@ package com.finalist.cmsc.rssfeed.util; -import java.util.*; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import org.mmbase.bridge.Node; import org.mmbase.bridge.NodeList; @@ -24,17 +26,29 @@ } public static List<String> getAllowedTypes(Node node) { - List<String> types = new ArrayList<String>(); - NodeList typedefs = node.getRelatedNodes(TYPEDEF, ALLOWREL, DESTINATION); - for (Iterator<Node> iter = typedefs.iterator(); iter.hasNext();) { - Node typedef = iter.next(); - types.add(typedef.getStringValue("name")); - } - return types; - } + List<String> types = new ArrayList<String>(); + NodeList typedefs = node.getRelatedNodes(TYPEDEF, ALLOWREL, DESTINATION); + for (Iterator<Node> iter = typedefs.iterator(); iter.hasNext();) { + Node typedef = iter.next(); + types.add(typedef.getStringValue("name")); + } + return types; + } - public static Node getContentChannel(Node node) { - return SearchUtil.findRelatedNode(node, RepositoryUtil.CONTENTCHANNEL, "related"); - } + public static Node getContentChannel(Node node) { + return SearchUtil.findRelatedNode(node, RepositoryUtil.CONTENTCHANNEL, "related"); + } + public static Node getCollectionChannel(Node node) { + NodeList list = RepositoryUtil.getCollectionChannels(node); + if(list.size() > 0) { + return list.getNode(0); + } + return null; + } + + public static NodeList getChildrenChannelsForCollection(Node node) { + return RepositoryUtil.getContentChannelsForCollection(node); + } + } Added: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/collectionchannel/search_rssfeed_related_collectionchannel.xml =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/collectionchannel/search_rssfeed_related_collectionchannel.xml (rev 0) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/collectionchannel/search_rssfeed_related_collectionchannel.xml 2009-10-28 07:09:47 UTC (rev 39398) @@ -0,0 +1,26 @@ +<?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="collectionchannel" minoccurs="0" maxoccurs="1"> + <title xml:lang="nl">Collection channel</title> + <title xml:lang="en">Collection channel</title> + <title xml:lang="zh">内容频道</title> + + <item> + <field ftype="data" name="pathfragment"> + <prompt xml:lang="en">URL-fragment</prompt> + <prompt xml:lang="nl">URL-fragment</prompt> + <prompt xml:lang="zh">URL-片段</prompt> + </field> + <field ftype="data" name="name"> + <prompt xml:lang="en">Name</prompt> + <prompt xml:lang="nl">Naam</prompt> + <prompt xml:lang="zh">名称</prompt> + </field> + </item> + + <command name="collectionselector" /> + + <action type="create"> + <relation destinationtype="collectionchannel" role="related"></relation> + </action> +</list> \ No newline at end of file Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/contentchannel/search_rssfeed_related_contentchannel.xml =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/contentchannel/search_rssfeed_related_contentchannel.xml 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/contentchannel/search_rssfeed_related_contentchannel.xml 2009-10-28 07:09:47 UTC (rev 39398) @@ -1,6 +1,6 @@ <?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="contentchannel" minoccurs="1" maxoccurs="1"> +<list role="related" destination="contentchannel" minoccurs="0" maxoccurs="1"> <title xml:lang="nl">Rubriek</title> <title xml:lang="en">Content channel</title> <title xml:lang="zh">内容频道</title> Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/edit_rssfeed.xml =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/edit_rssfeed.xml 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/edit_rssfeed.xml 2009-10-28 07:09:47 UTC (rev 39398) @@ -65,5 +65,6 @@ <optionlist select="boolean" /> </field> <list include="config/contentchannel/search_rssfeed_related_contentchannel.xml" /> + <list include="config/collectionchannel/search_rssfeed_related_collectionchannel.xml" /> <list include="config/typedef/search_site_allowrel_typedef.xml" /> </form-schema> \ No newline at end of file Modified: CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/load_rssfeed.xml =================================================================== --- CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/load_rssfeed.xml 2009-10-27 22:02:51 UTC (rev 39397) +++ CMSContainer/trunk/CMSContainer_Modules/rssfeed/src/webapp/editors/config/rssfeed/load_rssfeed.xml 2009-10-28 07:09:47 UTC (rev 39398) @@ -22,5 +22,6 @@ <field name="email_webmaster" /> <relation destination="contentchannel" role="related" /> + <relation destination="collectionchannel" role="related" /> <relation destination="typedef" role="allowrel" /> </action> \ No newline at end of file _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs