You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by gr...@apache.org on 2004/11/06 02:55:12 UTC
svn commit: rev 56722 - in incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya: . pubs/default pubs/default/lenya/xslt/authoring resources/javascript xslt/authoring xslt/bxeng
Author: gregor
Date: Fri Nov 5 17:55:11 2004
New Revision: 56722
Added:
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/resources/javascript/javascript.xsl
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/resources/javascript/validation.xml
Modified:
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/lenya.xmap
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create-language.xsl
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create.xsl
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset-upload.xsl
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset.xsl
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/create.xsl
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/asset.xsl
incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/image.xsl
Log:
factor out js validation
add check for empty title to all asset / image upload screens
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/lenya.xmap
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/lenya.xmap (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/lenya.xmap Fri Nov 5 17:55:11 2004
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<!-- $Id: lenya.xmap,v 1.14 2004/04/29 09:21:00 andreas Exp $ -->
+<!-- $Id$ -->
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<!-- =========================== Components ================================ -->
@@ -48,22 +48,23 @@
<map:pipeline>
-
- <!-- lenya/{file} -->
- <!--
- <map:match pattern="**">
- <map:act type="resource-exists">
- <map:parameter name="url" value="lenya/resources/{1}"/>
- <map:mount uri-prefix="" src="lenya/resources.xmap" check-reload="true" reload-method="synchron"/>
- </map:act>
- </map:match>
- -->
-
<!-- Lenya Core -->
<!-- matches lenya/**.js -->
<map:match pattern="**.js">
- <map:read src="resources/{1}.js" mime-type="application/x-javascript" />
+ <map:select type="resource-exists">
+ <map:when test="resources/{1}.xml">
+ <map:generate src="resources/{1}.xml"/>
+ <map:transform type="i18n">
+ <map:parameter name="locale" value="{request:locale}"/>
+ </map:transform>
+ <map:transform src="resources/javascript/javascript.xsl"/>
+ <map:serialize type="text" mime-type="application/x-javascript"/>
+ </map:when>
+ <map:otherwise>
+ <map:read src="resources/{1}.js" mime-type="application/x-javascript" />
+ </map:otherwise>
+ </map:select>
</map:match>
<!-- matches lenya/**.jpg -->
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create-language.xsl
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create-language.xsl (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create-language.xsl Fri Nov 5 17:55:11 2004
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<!-- $Id: create-language.xsl,v 1.6 2004/03/13 14:42:38 gregor Exp $ -->
+<!-- $Id$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -26,6 +26,7 @@
<xsl:output version="1.0" indent="yes" encoding="UTF-8"/>
<xsl:param name="lenya.usecase" select="'create-language'"/>
+ <xsl:param name="contextprefix"/>
<xsl:template match="/">
<page:page xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0">
@@ -66,21 +67,8 @@
<div class="lenya-box">
<div class="lenya-box-title"><i18n:text>New language for existing Document</i18n:text></div>
<div class="lenya-box-body">
+ <script type="text/javascript" src="{$contextprefix}/lenya/javascript/validation.js"> </script>
<script Language="JavaScript">
-function validRequired(formField,fieldLabel)
-{
- var result = true;
-
- if (formField.value == "")
- {
- alert('<i18n:text key="failmessage.createdoc.required"/>');
- formField.focus();
- result = false;
- }
-
- return result;
-}
-
function validateForm(theForm)
{
if (!validRequired(theForm["properties.create.child-name"],"Navigation Title"))
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create.xsl
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create.xsl (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/lenya/xslt/authoring/create.xsl Fri Nov 5 17:55:11 2004
@@ -27,6 +27,7 @@
<xsl:param name="status"/>
<xsl:param name="lenya.usecase" select="'create'"/>
+ <xsl:param name="contextprefix"/>
<xsl:template match="/">
<page:page xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0">
@@ -45,35 +46,8 @@
<div class="lenya-box">
<div class="lenya-box-title"><i18n:text>New Document</i18n:text></div>
<div class="lenya-box-body">
+ <script type="text/javascript" src="{$contextprefix}/lenya/javascript/validation.js"> </script>
<script Language="JavaScript">
-function validRequired(formField,fieldLabel)
-{
- var result = true;
-
- if (formField.value == "")
- {
- alert('<i18n:text key="failmessage.createdoc.required"/>');
- formField.focus();
- result = false;
- }
-
- return result;
-}
-
-function validContent(formField,fieldLabel)
-{
- var result = true;
-
- if (formField.value.match("[^a-zA-Z0-9\\-]+"))
- {
- alert('<i18n:text key="failmessage.createdoc.invalidformat"/>');
- formField.focus();
- result = false;
- }
-
- return result;
-}
-
function validateForm(theForm)
{
if (!validContent(theForm["properties.create.child-id"],"Document ID"))
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap Fri Nov 5 17:55:11 2004
@@ -66,6 +66,7 @@
<map:generate src="../../content/{serverpage}" type="serverpages"/>
<map:transform src="../../xslt/{stylesheet}">
<map:parameter name="use-request-parameters" value="true"/>
+ <map:parameter name="contextprefix" value="{request:contextPath}"/>
</map:transform>
</map:resource>
Added: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/resources/javascript/javascript.xsl
==============================================================================
--- (empty file)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/resources/javascript/javascript.xsl Fri Nov 5 17:55:11 2004
@@ -0,0 +1,8 @@
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="script">
+ <xsl:apply-templates/>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
Added: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/resources/javascript/validation.xml
==============================================================================
--- (empty file)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/resources/javascript/validation.xml Fri Nov 5 17:55:11 2004
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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: image.xsl 56062 2004-10-30 19:20:06Z gregor $ -->
+
+<script xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ /* check files to be uploaded against a list of valid extensions, required title and no whitespace in filenames */
+ function check_upload(fileinput, ext) {
+ var i = 0;
+ var delimiter = ' ';
+ var thefile = fileinput["properties.asset.data"].value;
+ var title = fileinput["properties.asset.title"].value;
+ if (title == "") {
+ alert("<i18n:translate><i18n:text key="upload-with-missing-title"/></i18n:translate>");
+ return false;
+ }
+ var _tempArray = new Array();
+ _tempArray = ext.split(delimiter);
+ for(i in _tempArray) {
+ if(thefile.indexOf('.' + _tempArray[i]) != -1) { // file has one of the accepted extensions.
+ return true;
+ }
+ } // file does not have one of the accepted extensions.
+ alert("<i18n:translate><i18n:text key="upload-with-invalid-extension"/><i18n:param>:\n\n"+ext+"\n</i18n:param></i18n:translate>");
+ return false;
+ }
+function validRequired(formField,fieldLabel)
+{
+ var result = true;
+
+ if (formField.value == "")
+ {
+ alert('<i18n:text key="failmessage.createdoc.required"/>');
+ formField.focus();
+ result = false;
+ }
+
+ return result;
+}
+
+function validContent(formField,fieldLabel)
+{
+ var result = true;
+
+ if (formField.value.match("[^a-zA-Z0-9\\-]+"))
+ {
+ alert('<i18n:text key="failmessage.createdoc.invalidformat"/>');
+ formField.focus();
+ result = false;
+ }
+
+ return result;
+}
+
+</script>
\ No newline at end of file
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecase.xmap Fri Nov 5 17:55:11 2004
@@ -258,6 +258,7 @@
<map:generate type="serverpages" src="{fallback:content/authoring/create.xsp}"/>
<map:transform src="{fallback:xslt/authoring/create.xsl}">
<map:parameter name="use-request-parameters" value="true"/>
+ <map:parameter name="contextprefix" value="{request:contextPath}"/>
</map:transform>
<map:call resource="style-cms-page"/>
</map:match>
@@ -273,6 +274,7 @@
<map:generate type="serverpages" src="{fallback:content/authoring/create.xsp}"/>
<map:transform src="{fallback:xslt/authoring/create.xsl}">
<map:parameter name="use-request-parameters" value="true"/>
+ <map:parameter name="contextprefix" value="{request:contextPath}"/>
</map:transform>
<map:call resource="style-cms-page"/>
</map:act>
@@ -289,6 +291,7 @@
<map:generate type="serverpages" src="{fallback:content/authoring/create-language.xsp}"/>
<map:transform src="{fallback:xslt/authoring/create-language.xsl}">
<map:parameter name="use-request-parameters" value="true"/>
+ <map:parameter name="contextprefix" value="{request:contextPath}"/>
</map:transform>
<map:call resource="style-cms-page"/>
</map:match>
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset-upload.xsl
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset-upload.xsl (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset-upload.xsl Fri Nov 5 17:55:11 2004
@@ -62,7 +62,7 @@
<div class="lenya-box">
<div class="lenya-box-title"><i18n:text key="lenya.assetupload.subtitle"/></div>
<div class="lenya-box-body">
- <form name="fileinput" action="" method="post" enctype="multipart/form-data" onsubmit="return check(fileinput)">
+ <form name="fileinput" action="" method="post" enctype="multipart/form-data" onsubmit="return check_upload(fileinput, ext)">
<input type="hidden" name="lenya.usecase" value="{$lenya.usecase}"/>
<input type="hidden" name="lenya.step" value="asset-upload"/>
<input type="hidden" name="task-id" value="insert-asset"/>
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset.xsl
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset.xsl (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/asset.xsl Fri Nov 5 17:55:11 2004
@@ -29,6 +29,7 @@
exclude-result-prefixes="lenya-info wf rc dc lenya-info"
>
+ <xsl:param name="contextprefix"/>
<xsl:param name="lenya.usecase" select="'asset'"/>
<xsl:param name="lenya.step"/>
<xsl:param name="insert"/>
@@ -85,43 +86,11 @@
</xsl:otherwise>
</xsl:choose>
<div class="lenya-box-body">
-<script>
-function validContent(formField,fieldLabel)
-{
- var result = true;
-
- if (formField.value.match("[ ]*"))
- {
- alert('Filenames cannot contain spaces.');
- formField.focus();
- result = false;
- }
-
- return result;
-}
-
-function check(fileinput) {
- var i = 0;
- var ext = '<xsl:value-of select="$extensions"/>';
- var delimiter = ' ';
- var thefile = fileinput["properties.asset.data"].value;
- var _tempArray = new Array();
- _tempArray = ext.split(delimiter);
- for(i in _tempArray)
- {
- if(thefile.indexOf('.' + _tempArray[i]) != -1)
- {
- // file has one of the accepted extensions.
- // now check for spaces in the filename
- return true;
- }
- }
- // file does not have one of the accepted extensions.
- alert("<i18n:translate><i18n:text key="upload-with-invalid-extension"/><i18n:param>:\n\n<xsl:value-of select="$extensions"/></i18n:param></i18n:translate>");
- return false;
-}
-</script>
- <form name="fileinput" action="{/lenya-info:info/lenya-info:assets/lenya-info:request-uri}" method="post" enctype="multipart/form-data" onsubmit="return check(fileinput)">
+ <script type="text/javascript" src="{$contextprefix}/lenya/javascript/validation.js"> </script>
+ <script>
+ var ext = '<xsl:value-of select="$extensions"/>';
+ </script>
+ <form name="fileinput" action="{/lenya-info:info/lenya-info:assets/lenya-info:request-uri}" method="post" enctype="multipart/form-data" onsubmit="return check_upload(fileinput, ext)">
<input type="hidden" name="lenya.usecase" value="{$lenya.usecase}"/>
<input type="hidden" name="lenya.event" value="edit"/>
<xsl:choose>
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/create.xsl
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/create.xsl (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/authoring/create.xsl Fri Nov 5 17:55:11 2004
@@ -15,7 +15,7 @@
limitations under the License.
-->
-<!-- $Id: create.xsl,v 1.8 2004/03/13 14:33:31 gregor Exp $ -->
+<!-- $Id$ -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@@ -26,6 +26,7 @@
<xsl:output version="1.0" indent="yes" encoding="UTF-8"/>
<xsl:param name="lenya.usecase" select="'create'"/>
+ <xsl:param name="contextprefix"/>
<xsl:template match="/">
<page:page xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0">
@@ -44,35 +45,8 @@
<div class="lenya-box">
<div class="lenya-box-title"><i18n:text>New Document</i18n:text></div>
<div class="lenya-box-body">
+ <script type="text/javascript" src="{$contextprefix}/lenya/javascript/validation.js"> </script>
<script Language="JavaScript">
-function validRequired(formField,fieldLabel)
-{
- var result = true;
-
- if (formField.value == "")
- {
- alert('<i18n:text key="failmessage.createdoc.required"/>');
- formField.focus();
- result = false;
- }
-
- return result;
-}
-
-function validContent(formField,fieldLabel)
-{
- var result = true;
-
- if (formField.value.match("[^a-zA-Z0-9\\-]+"))
- {
- alert('<i18n:text key="failmessage.createdoc.invalidformat"/>');
- formField.focus();
- result = false;
- }
-
- return result;
-}
-
function validateForm(theForm)
{
if (!validContent(theForm["properties.create.child-id"],"Document ID"))
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/asset.xsl
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/asset.xsl (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/asset.xsl Fri Nov 5 17:55:11 2004
@@ -32,41 +32,20 @@
<xsl:import href="../authoring/asset-upload.xsl"/>
+<xsl:param name="contextprefix"/>
<xsl:template name="pre-body">
+ <script type="text/javascript" src="{$contextprefix}/lenya/javascript/validation.js"> </script>
<script>
- function insertAsset(src, size, title) {
-
+ var ext = '<xsl:value-of select="$extensions"/>';
+
+ function insertAsset(src, size, title) {
<![CDATA[
window.opener.bxe_insertContent('<asset xmlns="http://apache.org/cocoon/lenya/page-envelope/1.0" src="'+src+'" size="'+size+'" type="">'+title+'</asset>',window.opener.BXE_SELECTION,window.opener.BXE_SPLIT_IF_INLINE);
]]>
window.close();
}
- function check(fileinput) {
- var i = 0;
- var ext = '<xsl:value-of select="$extensions"/>';
- var delimiter = ' ';
- var thefile = fileinput["properties.asset.data"].value;
- var title = fileinput["properties.asset.title"].value;
- if (title == "") {
- alert("<i18n:translate><i18n:text key="upload-with-missing-title"/></i18n:translate>");
- return false;
- }
- var _tempArray = new Array();
- _tempArray = ext.split(delimiter);
- for(i in _tempArray)
- {
- if(thefile.indexOf('.' + _tempArray[i]) != -1)
- {
- // file has one of the accepted extensions.
- return true;
- }
- }
- // file does not have one of the accepted extensions.
- alert("<i18n:translate><i18n:text key="upload-with-invalid-extension"/><i18n:param>:\n\n<xsl:value-of select="$extensions"/></i18n:param></i18n:translate>");
- return false;
- }
</script>
</xsl:template>
Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/image.xsl
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/image.xsl (original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/xslt/bxeng/image.xsl Fri Nov 5 17:55:11 2004
@@ -33,6 +33,7 @@
<xsl:param name="error"/>
<xsl:param name="extensions" select="'gif jpg png'"/>
+ <xsl:param name="contextprefix"/>
<xsl:template match="lenya-info:assets">
<page:page>
@@ -40,8 +41,12 @@
<i18n:text key="lenya.imageupload.title"/>
</page:title>
<page:body >
+ <script type="text/javascript" src="{$contextprefix}/lenya/javascript/validation.js"> </script>
<script>
window.onload = insertCaption
+
+ ext = '<xsl:value-of select="$extensions"/>';
+
function insertImage(src) {
var nodeid = '<xsl:value-of select="lenya-info:documentnodeid"/>/';
var link = document.forms["image"].link.value;
@@ -61,33 +66,13 @@
}
focus();
}
- function check(fileinput) {
- var i = 0;
- var ext = '<xsl:value-of select="$extensions"/>';
- var delimiter = ' ';
- var thefile = fileinput["properties.asset.data"].value;
- var title = fileinput["properties.asset.title"].value;
- if (title == "") {
- alert("<i18n:translate><i18n:text key="upload-with-missing-title"/></i18n:translate>");
- return false;
- }
- var _tempArray = new Array();
- _tempArray = ext.split(delimiter);
- for(i in _tempArray) {
- if(thefile.indexOf('.' + _tempArray[i]) != -1) { // file has one of the accepted extensions.
- return true;
- }
- } // file does not have one of the accepted extensions.
- alert("<i18n:translate><i18n:text key="upload-with-invalid-extension"/><i18n:param>:\n\n<xsl:value-of select="$extensions"/>\n</i18n:param></i18n:translate>");
- return false;
- }
</script>
<div class="lenya-box">
<div class="lenya-box-title"><i18n:text key="lenya.assetupload.subtitle"/></div>
<form name="fileinput"
action=""
method="post" enctype="multipart/form-data"
- onsubmit="return check(fileinput)">
+ onsubmit="return check_upload(fileinput, ext)">
<input type="hidden" name="lenya.usecase"
value="{$lenya.usecase}"/>
<input type="hidden" name="lenya.step"
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org