You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by jo...@apache.org on 2006/04/11 15:05:48 UTC
svn commit: r393210 - in /lenya/branches/BRANCH_1_2_X/src:
java/org/apache/lenya/cms/ant/
java/org/apache/lenya/cms/cocoon/components/modules/input/ webapp/lenya/
webapp/lenya/pubs/default/config/menus/
webapp/lenya/pubs/default/config/tasks/ webapp/le...
Author: josias
Date: Tue Apr 11 06:05:45 2006
New Revision: 393210
URL: http://svn.apache.org/viewcvs?rev=393210&view=rev
Log:
allow to edit the href attribute of a sitetree label in the GUI (Site area, Edit Navigation Link). fixes bug #39237
Added:
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/ant/ChangeHrefTask.java (with props)
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/info/change-href.xsl (with props)
Modified:
lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/menus/generic.xsp
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/targets.xml
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/tasks.xconf
lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap
Added: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/ant/ChangeHrefTask.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/ant/ChangeHrefTask.java?rev=393210&view=auto
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/ant/ChangeHrefTask.java (added)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/ant/ChangeHrefTask.java Tue Apr 11 06:05:45 2006
@@ -0,0 +1,171 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ */
+
+/* $Id: RenameLabelTask.java 160149 2005-04-05 09:51:54Z michi $ */
+
+package org.apache.lenya.cms.ant;
+
+import org.apache.lenya.cms.publication.SiteTree;
+import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.publication.Label;
+import org.apache.lenya.cms.publication.SiteTreeException;
+import org.apache.lenya.cms.publication.SiteTreeNode;
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Ant task to change the href attribute of a label element in the sitetree.
+ */
+public class ChangeHrefTask extends PublicationTask {
+ private String documentid;
+ private String href;
+ private String area;
+ private String language;
+
+ /**
+ * Creates a new instance of ChangeHrefTask
+ */
+ public ChangeHrefTask() {
+ super();
+ }
+
+ /**
+ * Get the area of the site tree.
+ *
+ * @return the area of the tree.
+ */
+ protected String getArea() {
+ return area;
+ }
+
+ /**
+ * Set the area.
+ *
+ * @param area the area.
+ */
+ public void setArea(String area) {
+ this.area = area;
+ }
+
+ /**
+ * Return the document-id corresponding to the node to delete.
+ *
+ * @return string The document-id.
+ */
+ protected String getDocumentid() {
+ return documentid;
+ }
+
+ /**
+ * Set the value of the document-id corresponding to the node to delete.
+ *
+ * @param string The document-id.
+ */
+ public void setDocumentid(String string) {
+ documentid = string;
+ }
+
+ /**
+ * Get the href.
+ *
+ * @return the href
+ */
+ public String getHref() {
+ return href;
+ }
+
+ /**
+ * Set the href.
+ *
+ * @param value of the href
+ */
+ public void setHref(String href) {
+ this.href = href;
+ }
+
+ /**
+ * Get the language.
+ *
+ * @return the language
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ /**
+ * Set the language.
+ *
+ * @param language the language
+ */
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ /**
+ * Change the href attribute of an existing node in the tree.
+ *
+ * @param documentid the document-id of the document.
+ * @param language the language of the label that is to be renamed.
+ * @param area determines in which sitetree the label is to be renamed
+ * @param href the new href value
+ *
+ * @throws SiteTreeException if an error occurs.
+ */
+ public void changeHref (
+ String documentid,
+ String language,
+ String area,
+ String href)
+ throws SiteTreeException, DocumentException {
+
+ SiteTree tree = getPublication().getTree(area);
+ SiteTreeNode node = tree.getNode(documentid);
+ if (node == null) {
+ throw new DocumentException(
+ "Document-id " + documentid + " not found.");
+ }
+ Label label = node.getLabel(language);
+ if (label == null) {
+ throw new DocumentException(
+ "Label for language " + language + " not found.");
+ }
+ if (href.equals("")) href = null;
+ // FIXME: This is somewhat of a hack. See also RenameLabelTask.java
+ tree.removeLabel(documentid, label);
+ label.setHref(href);
+ tree.addLabel(documentid, label);
+ tree.save();
+ }
+
+ /** (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() throws BuildException {
+ try {
+ log("document-id corresponding to the node: " + getDocumentid());
+ log("language: " + getLanguage());
+ log("area: " + getArea());
+ log("href: " + getHref());
+ changeHref(
+ getDocumentid(),
+ getLanguage(),
+ getArea(),
+ getHref());
+ } catch (Exception e) {
+ throw new BuildException(e);
+ }
+ }
+}
Propchange: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/ant/ChangeHrefTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java?rev=393210&r1=393209&r2=393210&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java (original)
+++ lenya/branches/BRANCH_1_2_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/SitetreeModule.java Tue Apr 11 06:05:45 2006
@@ -26,6 +26,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.cocoon.components.modules.input.AbstractInputModule;
+import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
import org.apache.lenya.cms.publication.Publication;
@@ -39,8 +40,9 @@
public static final String TRASH_NODE = "trash-node";
public static final String ARCHIVE_NODE = "archive-node";
public static final String FIRST_CHILD_ID = "first-child-id";
+ public static final String LABEL_HREF = "label-href";
- protected static final String[] PARAMETER_NAMES = { AUTHORING_NODE, LIVE_NODE, TRASH_NODE, ARCHIVE_NODE, FIRST_CHILD_ID };
+ protected static final String[] PARAMETER_NAMES = { AUTHORING_NODE, LIVE_NODE, TRASH_NODE, ARCHIVE_NODE, FIRST_CHILD_ID, LABEL_HREF };
/**
* @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String, org.apache.avalon.framework.configuration.Configuration, java.util.Map)
@@ -83,6 +85,13 @@
} else {
value = null;
}
+ }
+
+ if (name.equals(LABEL_HREF)) {
+ Document document = envelope.getDocument();
+ SiteTree siteTree = publication.getTree(document.getArea());
+ value = siteTree.getNode(document.getId()).getLabel(document.getLanguage()).getHref();
+ if (value == null) value = "";
}
} catch (Exception e) {
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/menus/generic.xsp
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/menus/generic.xsp?rev=393210&r1=393209&r2=393210&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/menus/generic.xsp (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/menus/generic.xsp Tue Apr 11 06:05:45 2006
@@ -193,6 +193,12 @@
<item>Edit Navigation Title</item>
}
if (isDocument) {
+ <item wf:event="edit" uc:usecase="change-href" uc:step="showscreen" href="?"><i18n:text>Edit Navigation Link</i18n:text></item>
+ }
+ else {
+ <item>Edit Navigation Link</item>
+ }
+ if (isDocument) {
<item wf:event="edit" uc:usecase="change-visibility" uc:step="showscreen" href="?"><i18n:text>Change node visibility</i18n:text></item>
}
else {
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/targets.xml
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/targets.xml?rev=393210&r1=393209&r2=393210&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/targets.xml (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/targets.xml Tue Apr 11 06:05:45 2006
@@ -643,6 +643,23 @@
/>
</target>
+ <taskdef name="changeHref" classname="org.apache.lenya.cms.ant.ChangeHrefTask"/>
+
+ <target name = "change-href">
+ <property name="change.href.document-id" value=""/>
+ <property name="change.href.language" value=""/>
+ <property name="change.href.area" value=""/>
+ <property name="change.href.href" value=""/>
+
+ <echo>Change Href</echo>
+ <changeHref
+ documentid="${change.href.document-id}"
+ language="${change.href.language}"
+ area="${change.href.area}"
+ href="${change.href.href}"
+ />
+ </target>
+
<taskdef name="changeVisibility" classname="org.apache.lenya.cms.ant.ChangeVisibilityTask"/>
<target name = "change-visibility">
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/tasks.xconf
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/tasks.xconf?rev=393210&r1=393209&r2=393210&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/tasks.xconf (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/config/tasks/tasks.xconf Tue Apr 11 06:05:45 2006
@@ -74,6 +74,11 @@
<parameter name="target" value="rename-label"/>
</task>
+ <task id="change-href" class="org.apache.lenya.cms.task.AntTask">
+ <label>Change Navigation Link</label>
+ <parameter name="target" value="change-href"/>
+ </task>
+
<task id="change-visibility" class="org.apache.lenya.cms.task.AntTask">
<label>Change Node Visibility</label>
<parameter name="target" value="change-visibility"/>
Modified: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap?rev=393210&r1=393209&r2=393210&view=diff
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap (original)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap Tue Apr 11 06:05:45 2006
@@ -820,6 +820,31 @@
</map:match>
+ <!-- Change the href attribute -->
+ <map:match pattern="change-href" type="usecase">
+
+ <map:match pattern="showscreen" type="step">
+ <map:generate src="content/util/empty.xml"/>
+ <map:transform src="xslt/info/change-href.xsl">
+ <map:parameter name="use-request-parameters" value="true"/>
+ <map:parameter name="requesturi" value="{request:requestURI}"/>
+ <map:parameter name="area" value="{page-envelope:area}"/>
+ <map:parameter name="language" value="{page-envelope:document-language}"/>
+ <map:parameter name="href" value="{sitetree:label-href}"/>
+ <map:parameter name="documentid" value="{page-envelope:document-id}"/>
+ <map:parameter name="taskid" value="change-href"/>
+ </map:transform>
+ <map:call resource="style-cms-page"/>
+ </map:match>
+
+ <map:match pattern="change-href" type="step">
+ <map:act type="task">
+ <map:redirect-to session="true" uri="{request:requestURI}"/>
+ </map:act>
+ </map:match>
+
+ </map:match>
+
<!-- Change visibility of a node in navigation -->
<map:match pattern="change-visibility" type="usecase">
Added: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/info/change-href.xsl
URL: http://svn.apache.org/viewcvs/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/info/change-href.xsl?rev=393210&view=auto
==============================================================================
--- lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/info/change-href.xsl (added)
+++ lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/info/change-href.xsl Tue Apr 11 06:05:45 2006
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed 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.
+-->
+
+<xsl:stylesheet version="1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0">
+
+ <xsl:param name="requesturi"/>
+ <xsl:param name="area"/>
+ <xsl:param name="language"/>
+ <xsl:param name="href"/>
+ <xsl:param name="documentid"/>
+ <xsl:param name="taskid"/>
+ <xsl:param name="lenya.event"/>
+
+ <xsl:template match="/">
+ <page:page>
+ <page:title>
+ <i18n:text>Edit Navigation Link</i18n:text>
+ </page:title>
+ <page:body>
+ <div class="lenya-box">
+ <div class="lenya-box-title">
+ <i18n:text>Edit Navigation Link</i18n:text>
+ </div>
+ <div class="lenya-box-body">
+ <form method="get" name="rename-label-form">
+ <xsl:attribute name="action"></xsl:attribute>
+ <input type="hidden" name="task-id" value="{$taskid}"/>
+ <input type="hidden" name="properties.change.href.document-id" value="{$documentid}"/>
+ <input type="hidden" name="properties.change.href.language" value="{$language}"/>
+ <input type="hidden" name="properties.change.href.area" value="{$area}"/>
+ <input type="hidden" name="lenya.usecase" value="change-href"/>
+ <input type="hidden" name="lenya.step" value="change-href"/>
+ <input type="hidden" name="lenya.event" value="{$lenya.event}"/>
+
+ <table class="lenya-table-noborder">
+ <tr>
+ <td class="lenya-entry-caption">
+ <i18n:text>New Navigation Link</i18n:text>:</td>
+ <td>
+ <input type="text" class="lenya-form-element" name="properties.change.href.href" value="{$href}"/>
+ </td>
+ </tr>
+ <tr>
+ <td/>
+ <td>
+ <br/>
+ <input i18n:attr="value" type="submit" value="Save" name="Save"/> 
+ <input i18n:attr="value" type="button" onClick="location.href='{$requesturi}';" value="Cancel" name="Cancel"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ </div>
+ </div>
+ </page:body>
+ </page:page>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Propchange: lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/info/change-href.xsl
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org