Author: apevec Date: 2005-09-22 07:39:04 +0200 (Thu, 22 Sep 2005) New Revision: 901 Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties trunk/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java trunk/ccm-cms/src/com/arsdigita/cms/ui/CategoryForm.java trunk/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java trunk/ccm-core/web/packages/bebop/xsl/DHTMLEditor.xsl Log: SF patch [ 1177590 ] Option to remove buttons from HTMLArea patch was against older version of HTMLArea, hopefuly it works with the upgraded version we have now This patch also includes: CategoryForm fix from [ 1165196 ] Linked Cat Form - bug fix and ordering change and "give-a-chance-to-login" fix in ItemDispatcher Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java 2005-09-22 04:57:12 UTC (rev 900) +++ trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java 2005-09-22 05:39:04 UTC (rev 901) @@ -84,6 +84,7 @@ private final Parameter m_useStreamlinedCreation; private final Parameter m_dhtmlEditorConfig; private final Parameter m_dhtmlEditorPlugins; + private final Parameter m_dhtmlEditorHiddenButtons; private final Parameter m_hideTemplatesTab; private final Parameter m_hideAdminTabs; private final Parameter m_hideTimezone; @@ -195,6 +196,11 @@ Parameter.OPTIONAL, null); + m_dhtmlEditorHiddenButtons = new StringArrayParameter + ("com.arsdigita.cms.dhtml_editor_hidden_buttons", + Parameter.OPTIONAL, + null); + m_hideTemplatesTab = new BooleanParameter ("com.arsdigita.cms.hide_templates_tab", Parameter.REQUIRED, new Boolean(false)); @@ -270,6 +276,7 @@ register(m_useStreamlinedCreation); register(m_dhtmlEditorConfig); register(m_dhtmlEditorPlugins); + register(m_dhtmlEditorHiddenButtons); register(m_hideTemplatesTab); register(m_hideAdminTabs); register(m_hideTimezone); @@ -354,6 +361,10 @@ return (String[])get(m_dhtmlEditorPlugins); } + public final String[] getDHTMLEditorHiddenButtons() { + return (String[])get(m_dhtmlEditorHiddenButtons); + } + public final boolean getHideTemplatesTab() { return ((Boolean) get(m_hideTemplatesTab)).booleanValue(); } Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties 2005-09-22 04:57:12 UTC (rev 900) +++ trunk/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig_parameter.properties 2005-09-22 05:39:04 UTC (rev 901) @@ -103,6 +103,11 @@ com.arsdigita.cms.dhtml_editor_plugins.example=TableOperations,CSS com.arsdigita.cms.dhtml_editor_plugins.format=[string,string,string] +com.arsdigita.cms.dhtml_editor_hidden_buttons.title=DHTML Editor buttons to hide +com.arsdigita.cms.dhtml_editor_hidden_buttons.purpose=Prevent undesirable functions from being made available, eg images should only be added through the cms, not the html area +com.arsdigita.cms.dhtml_editor_hidden_buttons.example=insertimage +com.arsdigita.cms.dhtml_editor_hidden_buttons.format=[string,string,string] + com.arsdigita.cms.default_notification_time.title=Default Notification Time (Hours) com.arsdigita.cms.default_notification_time.purpose=Amount of time (in hours) before the expiration of a content item that users in the Alert Recipient role are alerted via email com.arsdigita.cms.default_notification_time.example=0 Modified: trunk/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java 2005-09-22 04:57:12 UTC (rev 900) +++ trunk/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java 2005-09-22 05:39:04 UTC (rev 901) @@ -26,9 +26,12 @@ import com.arsdigita.dispatcher.ChainedDispatcher; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.dispatcher.RequestContext; +import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.ACSObjectCache; +import com.arsdigita.kernel.Party; import com.arsdigita.kernel.User; import com.arsdigita.versioning.Transaction; +import com.arsdigita.web.LoginSignal; import java.io.IOException; import java.util.Collections; import java.util.Date; @@ -243,7 +246,11 @@ item); } } - + // chr...@we... - if user is not logged in, give them a chance to do that, else show them the door + Party user = Kernel.getContext().getParty(); + if (!hasPermission && user == null) { + throw new LoginSignal(request); + } if( !hasPermission ) throw new com.arsdigita.dispatcher.AccessDeniedException(); Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java 2005-09-22 04:57:12 UTC (rev 900) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/CMSDHTMLEditor.java 2005-09-22 05:39:04 UTC (rev 901) @@ -29,19 +29,20 @@ public CMSDHTMLEditor(String name) { super(new StringParameter(name), ContentSection.getConfig().getDHTMLEditorConfig()); + addPlugins(); + hideButtons(); - String[] plugins = ContentSection.getConfig().getDHTMLEditorPlugins(); - if (plugins != null) { - for (int i = 0 ; i < plugins.length ; i++) { - addPlugin(plugins[i]); - } - } } public CMSDHTMLEditor(ParameterModel model) { super(model, ContentSection.getConfig().getDHTMLEditorConfig()); + addPlugins(); + hideButtons(); + } + + private void addPlugins() { String[] plugins = ContentSection.getConfig().getDHTMLEditorPlugins(); if (plugins != null) { for (int i = 0 ; i < plugins.length ; i++) { @@ -50,4 +51,13 @@ } } + private void hideButtons() { + String[] hiddenButtons = ContentSection.getConfig().getDHTMLEditorHiddenButtons(); + if (hiddenButtons != null) { + for (int i = 0 ; i < hiddenButtons.length ; i++) { + hideButton(hiddenButtons[i]); + } + } + } + } Modified: trunk/ccm-cms/src/com/arsdigita/cms/ui/CategoryForm.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ui/CategoryForm.java 2005-09-22 04:57:12 UTC (rev 900) +++ trunk/ccm-cms/src/com/arsdigita/cms/ui/CategoryForm.java 2005-09-22 05:39:04 UTC (rev 901) @@ -62,7 +62,10 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; +import java.util.Map; +import java.util.SortedMap; import java.util.TooManyListenersException; +import java.util.TreeMap; /** * This is an abstract class which displays the category assignment UI. @@ -212,75 +215,76 @@ } // A print listener which populates the listbox with all - // unassigned categories + // unassigned categories, apart from result of getExcludedCategory() + // (if not null), and the root category. + // Ordering is alphabetical based on qualified path, so entries are + // ordered like a tree with all nodes expanded. + // Ideally ordering should be like an expanded tree but based on + // the sortkey order of the categories. However, I don't know + // if it would be possible to write a comparison function that + // could do this efficiently, and I'm not even going to try + // chr...@we... // - // WARNING: This method is currently slow. It should be - // optimized to do a connect by query that excludes all - // categories which are already assigned. private class FreePrintListener implements PrintListener { public void prepare(PrintEvent e) { - OptionGroup o = (OptionGroup)e.getTarget(); + + OptionGroup target = (OptionGroup) e.getTarget(); PageState state = e.getPageState(); Category root = getRootCategory(state); - if(root == null) + if (root == null) { return; - Category excluded = getExcludedCategory(state); + } - // Breadth-first traversal of the teee - CategoryTreeModelLite model = new CategoryTreeModelLite(root); - CategoryMap assigned = getAssignedCategories(state); - LinkedList queue = new LinkedList(), nameQueue = new LinkedList(); - - if (root.isAbstract()) { - queue.addLast(model.getRoot(state)); - nameQueue.addLast(""); - } else { - queue.addLast(new DataQueryTreeNode - (root.getID(), root.getName(), true)); - nameQueue.addLast(root.getName()); - } - while(!queue.isEmpty()) { - DataQueryTreeNode node = (DataQueryTreeNode)queue.removeFirst(); - String name = (String)nameQueue.removeFirst(); - - // Process the node - String id = (String)node.getKey(); - - // Process the node unless: - // The category is assigned - // The category's name is empty (meaning that it's the root) - // The category should be excluded - if(excluded == null || - !excluded.getID().toString().equals(id)) { - if(!assigned.containsKey(id) && name.length() > 0 && - !Boolean.TRUE.equals((Boolean)node.getValue - (Category.IS_ABSTRACT)) && - !id.equals(root.getID().toString())) { - o.addOption(new Option(id, name)); - } - - if (model.hasChildren(node, state)) { - // Append children - for(Iterator i = model.getChildren(node, state); i.hasNext(); ) { - TreeNode n = (TreeNode)i.next(); - queue.addLast(n); - StringBuffer nameBuf = new StringBuffer(name); - if(name.length() > 0) { - nameBuf.append(SEPARATOR); + // exclude children of the excluded category (as per javadoc on + // getExcludedCategory() method. This prevents attempts + // to create circular category graph (which causes + // exception in Category during addMapping if not checked here + Category excludedCat = getExcludedCategory(state); + CategoryMap excluded = new CategoryMap(); + if (excludedCat != null) + {CategoryCollection excludedSubTree =getExcludedCategory(state).getDescendants(); + while (excludedSubTree.next()) { + excluded.add(excludedSubTree.getCategory()); } - nameBuf.append(n.getElement()); - nameQueue.addLast(nameBuf.toString()); } + CategoryMap assigned = getAssignedCategories(state); + SortedMap sortedCats = new TreeMap(); + CategoryCollection children = root.getDescendants(); + while (children.next()) { + Category cat = children.getCategory(); + sortedCats.put(cat.getQualifiedName(SEPARATOR, true),cat.getID().toString()); + } + + Iterator it = sortedCats.entrySet().iterator(); + Map.Entry entry; + String path; + String id; + boolean notExcluded; + boolean notAlreadyAssigned; + boolean notRoot; + + while (it.hasNext()) { + entry = (Map.Entry)it.next(); + path = (String) entry.getKey(); + id = (String) entry.getValue(); + + notExcluded = (excluded == null || !excluded.containsKey(id)); + notAlreadyAssigned = !assigned.containsKey(id); + notRoot = !id.equals(root.getID().toString()); + + if (notExcluded && notAlreadyAssigned && notRoot) { + target.addOption(new Option(id, path)); } } - addFillerOption(o); + addFillerOption(target); } } + /** * Populate a {@link CategoryMap} with all categories which are assigned to * the item. Child classes should override this method to do the right thing. Modified: trunk/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java 2005-09-22 04:57:12 UTC (rev 900) +++ trunk/ccm-core/src/com/arsdigita/bebop/form/DHTMLEditor.java 2005-09-22 05:39:04 UTC (rev 901) @@ -114,6 +114,7 @@ private Config m_config; private Set m_plugins; + private Set m_hiddenButtons; public DHTMLEditor(String name) { this(new StringParameter(name)); @@ -128,6 +129,7 @@ super(model); m_config = config; m_plugins = new HashSet(); + m_hiddenButtons = new HashSet(); } /** @@ -144,6 +146,14 @@ public void addPlugin(String name) { m_plugins.add(name); } + /** + * Prevent the specified button from being displayed in the editor toolbar + * @param name name of the button, as specified in the btnList of the htmlarea.js file + * + */ + public void hideButton(String name) { + m_hiddenButtons.add(name); + } /** * Sets the <tt>ROWS</tt> attribute for the <tt>TEXTAREA</tt> tag. @@ -217,7 +227,18 @@ if (m_config.getPath() != null) { config.addAttribute("path", m_config.getPath()); } + if (m_hiddenButtons.size() > 0) { + StringBuffer hiddenButtons = new StringBuffer(); + // list must start and end with a space + hiddenButtons.append(" "); + Iterator hidden = m_hiddenButtons.iterator(); + while (hidden.hasNext()) { + hiddenButtons.append(hidden.next()); + hiddenButtons.append(" "); + } + config.addAttribute("hidden-buttons", hiddenButtons.toString()); + } Iterator plugins = m_plugins.iterator(); while (plugins.hasNext()) { String name = (String)plugins.next(); Modified: trunk/ccm-core/web/packages/bebop/xsl/DHTMLEditor.xsl =================================================================== --- trunk/ccm-core/web/packages/bebop/xsl/DHTMLEditor.xsl 2005-09-22 04:57:12 UTC (rev 900) +++ trunk/ccm-core/web/packages/bebop/xsl/DHTMLEditor.xsl 2005-09-22 05:39:04 UTC (rev 901) @@ -73,6 +73,9 @@ "inserthorizontalrule", "insertlink", "insertimage", "inserttable", "htmlmode", "separator", "popupeditor", "separator" ] ]; + <xsl:if test="bebop:config/@hidden-buttons"> + config_<xsl:value-of select="@name"/>.hideSomeButtons("<xsl:value-of select="bebop:config/@hidden-buttons"/>"); + </xsl:if> editor_<xsl:value-of select="@name"/>.config.pageStyle = "@import url(/assets/htmlarea/htmlarea.css);"; <xsl:for-each select="bebop:plugin"> |