123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:pui="http://developer.cognos.com/common/portal/logic/ui/1/"
- xmlns:exsl="http://exslt.org/common"
- xmlns:layout="http://developer.cognos.com/common/layout"
- extension-element-prefixes="exsl"
- exclude-result-prefixes="xts bus xtsext SOAP-ENV nav pui exsl layout">
- <!--
- the following imports requires these variables to be defined:
- $metaData, $interactions, $logic, $userPreferences, $navRequest, $navResponse
- -->
- <xsl:import href="/common/propeditor/types/xsdtypes.xslt"/>
- <xsl:import href="/common/propeditor/types/fragextTypes.xslt"/>
- <xsl:import href="/common/propeditor/types/cmtypes.xslt"/>
- <xsl:import href="/common/propeditor/types/cmmtypes.xslt"/>
- <xsl:import href="/common/propeditor/types/generictypes.xslt"/>
- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
- <!--
- Variable declarations. The xpath "/*[false()]" provides an empty node set result.
- -->
- <xsl:variable name="interactions" select="/root/interactions"/>
- <xsl:variable name="state" select="/root/state"/>
- <xsl:variable name="userPreferences" select="/root/preferences"/>
- <xsl:variable name="logic" select="/root/logic"/>
- <xsl:variable name="metaData" select="$logic/targetMeta/meta"/>
- <xsl:variable name="fragMeta" select="/root/fragment/meta"/>
- <xsl:variable name="navRequest" select="/root/input[@name='request']/*/SOAP-ENV:Envelope/SOAP-ENV:Body/nav:request/nav:queries"/>
- <xsl:variable name="navResponse" select="/root/input[@name='response']/*/*"/>
- <xsl:variable name="config" select="/root/input[@name='configurationResponse']/config"/>
- <xsl:key name="env-param" match="/root/interactions/param" use="@name"/>
- <layout:selectortemplates/>
- <xsl:template match="/">
- <xsl:choose>
- <xsl:when test="$interactions/param[@name='privateAction' and (.='save' or .='cancel')]">
- <script type="text/javascript">_THIS_.setOnloadHandler( function() { window.setTimeout("_THIS_.setMode('view')", 1); } );</script>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="generateMarkupForFullPage"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="generateMarkupForFullPage">
- <!-- generate global variables -->
- <layout:script>
- var _THIS_dependencyCleanup = new Array();
- var _THIS_validationFunctionArray = new Array();
- _THIS_validationFunctionArray.form = "_THIS_form";
- _THIS_validationFunctionArray.multiLingualSelector = "Selector";
- _THIS_validationFunctionArray.localFormName = "form";
- var _THIS_defaultPickerAction = "_THIS?frag-urlType=gateway/THIS_";
- </layout:script>
- <pui:aboutscript/>
- <pui:delegatehelpscript/>
- <layout:form name="_THIS_form" id="_THIS_form" action="_THIS?/THIS_" method="post">
- <layout:hidden name="privateAction" value=""/>
- <layout:section format="header">
- <layout:text>
- <xsl:choose>
- <xsl:when test="$fragMeta/description"><xsl:value-of select="$fragMeta/description"/></xsl:when>
- <xsl:otherwise><xts:string id="IDS_PROP_GENERICEDITOR_INTRO"/></xsl:otherwise>
- </xsl:choose>
- </layout:text>
- <layout:actionlist>
- <layout:action>
- <pui:aboutlink/>
- </layout:action>
- <layout:action>
- <pui:helplink/>
- </layout:action>
- </layout:actionlist>
- </layout:section>
- <!-- first itterate over all the properties and see if they want to add soemthing to the top of the page -->
- <layout:section id="_THIS_header">
- <layout:row>
- <xsl:apply-templates select="$metaData/customProperties" mode="markup-header"/>
- </layout:row>
- </layout:section>
- <layout:section id="_THIS_properties">
- <xsl:for-each select="$metaData/customProperties[control/group]">
- <xsl:sort select="control/group/@order"/>
- <xsl:variable name="propname" select="@name"/>
- <xsl:variable name="name" select="string(./control/group)"/>
- <xsl:if test="not(preceding-sibling::*[string(control/group) = $name])">
- <xsl:if test="$name !=''">
- <layout:label divider="true">
- <layout:text>
- <xsl:value-of select="$name"/>
- </layout:text>
- </layout:label>
- </xsl:if>
- <xsl:for-each select="$metaData/customProperties[control/group = $name and string(control/@order)!='']">
- <xsl:sort select="number(control/@order)" data-type="number" order="ascending"/>
- <layout:section>
- <xsl:apply-templates select="." mode="markup">
- <xsl:with-param name="propSiblings" select="$metaData/customProperties[not(@name=$propname)]"/>
- </xsl:apply-templates>
- </layout:section>
- </xsl:for-each>
- <xsl:for-each select="$metaData/customProperties[control/group = $name and string(control/@order)='']">
- <layout:section>
- <xsl:apply-templates select="." mode="markup">
- <xsl:with-param name="propSiblings" select="$metaData/customProperties[not(@name=$propname)]"/>
- </xsl:apply-templates>
- </layout:section>
- </xsl:for-each>
- </xsl:if>
- </xsl:for-each>
- <xsl:choose>
- <xsl:when test="$metaData/customProperties[control/@relatesTo]"/>
- <xsl:otherwise>
- <xsl:if test="($metaData/customProperties[not(control/group) and control/@order]) or ($metaData/customProperties[not(control/group) and not(control/@order)])">
- <layout:section divider="true">
- <xsl:for-each select="$metaData/customProperties[not(control/group) and control/@order]">
- <xsl:sort select="control/@order"/>
- <xsl:variable name="propname" select="@name"/>
- <xsl:apply-templates select="." mode="markup" >
- <xsl:with-param name="propSiblings" select="$metaData/customProperties[not(@name=$propname)]"/>
- </xsl:apply-templates>
- </xsl:for-each>
- <xsl:for-each select="$metaData/customProperties[not(control/group) and not(control/@order)]">
- <xsl:variable name="propname" select="@name"/>
- <xsl:apply-templates select="." mode="markup">
- <xsl:with-param name="propSiblings" select="$metaData/customProperties[not(@name=$propname)]"/>
- </xsl:apply-templates>
- </xsl:for-each>
- </layout:section>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </layout:section>
- <!--render the button bar -->
- <layout:section format="footer" divider="true" id="_THIS_footer">
- <layout:row>
- <layout:button id="_THIS_okButton" onclick="_THIS_okClicked();">
- <layout:value><xts:string id="IDS_PROP_OK_BUTTON_TEXT"/></layout:value>
- </layout:button>
- <layout:button onclick="_THIS_cancelClicked();">
- <layout:value><xts:string id="IDS_PROP_CANCEL_BUTTON_TEXT"/></layout:value>
- </layout:button>
- </layout:row>
- </layout:section>
- </layout:form>
- <xsl:call-template name="generateScript"/>
- </xsl:template>
- <xsl:template match="customProperties" mode="markup">
- <xsl:param name="propSiblings"/>
- <xsl:param name="matchControlId" select="''"/>
- <xsl:variable name="usePCI">
- <xsl:choose>
- <xsl:when test="$matchControlId='' and string(./control/@relatesTo)!=''">
- <xsl:value-of select="concat('_',./control/@relatesTo)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$matchControlId"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="propname" select="@name"/>
- <xsl:variable name="prefix" select="substring-before(datatype, ':')"/>
- <xsl:variable name="type" select="substring-after(datatype, ':')"/>
- <xsl:variable name="namespaceSpecificCustomProps">
- <xsl:element name="{$prefix}:{$type}" namespace="{datatype/namespace::*[name() = $prefix]}">
- <xsl:copy-of select="self::node()"/>
- </xsl:element>
- </xsl:variable>
- <xsl:if test="$type = 'multilingualString' and count(preceding-sibling::*[local-name()='customProperties']/*[local-name()='datatype' and contains(string(.),$type)])=0">
- <xsl:apply-templates select="$namespaceSpecificCustomProps/*" mode="selector">
- <xsl:with-param name="propSiblings" select="$propSiblings"/>
- <xsl:with-param name="matchControlId" select="$usePCI"/>
- </xsl:apply-templates>
- </xsl:if>
- <xsl:apply-templates select="$namespaceSpecificCustomProps/*">
- <xsl:with-param name="propSiblings" select="$propSiblings"/>
- <xsl:with-param name="matchControlId" select="$usePCI"/>
- </xsl:apply-templates>
- </xsl:template>
- <xsl:template match="customProperties" mode="markup-scripting">
- <xsl:variable name="prefix" select="substring-before(datatype, ':')"/>
- <xsl:variable name="type" select="substring-after(datatype, ':')"/>
- <xsl:variable name="namespaceSpecificCustomProps">
- <xsl:element name="{$prefix}:{$type}" namespace="{datatype/namespace::*[name() = $prefix]}">
- <xsl:copy-of select="self::node()"/>
- </xsl:element>
- </xsl:variable>
- <xsl:apply-templates select="$namespaceSpecificCustomProps/*" mode="scripting"/>
- </xsl:template>
- <xsl:template match="customProperties" mode="markup-header">
- <xsl:variable name="prefix" select="substring-before(datatype, ':')"/>
- <xsl:variable name="type" select="substring-after(datatype, ':')"/>
- <xsl:variable name="namespaceSpecificCustomProps">
- <xsl:element name="{$prefix}:{$type}" namespace="{datatype/namespace::*[name() = $prefix]}">
- <xsl:copy-of select="self::node()"/>
- </xsl:element>
- </xsl:variable>
- <xsl:apply-templates select="$namespaceSpecificCustomProps/*" mode="header"/>
- </xsl:template>
- <!-- used in markup mode only -->
- <xsl:template name="getPropertyValue">
- <xsl:param name="propertyName"/>
- <xsl:variable name="formProp" select="concat('p_',$propertyName)"/>
- <xsl:choose>
- <xsl:when test="$interactions/param[@name= $formProp]">
- <xsl:value-of select="$interactions/param[@name= $formProp]"/>
- </xsl:when>
- <xsl:when test="$interactions/param[@name= $propertyName]">
- <xsl:value-of select="$interactions/param[@name= $propertyName]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="default/value"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <!-- used in markup mode only -->
- <xsl:template name="createLanguageSelector">
- <xsl:param name="name"/>
- <xsl:param name="fieldList"/>
-
- <layout:localeselectorcontrol name="Selector">
- <layout:config><xsl:copy-of select="$config/param[@name='contentLocales']/*"/></layout:config>
- <layout:label>
- <layout:text><xts:string id="IDS_PROP_LANGUAGE_CAPTION"/></layout:text>
- </layout:label>
- <layout:controlparameters>
- <formname>form</formname>
- <contentlocales><xsl:copy-of select="$config/param[@name='contentLocales']/*"/></contentlocales>
- <customs>
- <xsl:variable name="fields" select="substring($fieldList,0,string-length($fieldList) )"/>
- <!-- render all the languages for which there are value for above the line -->
- <xsl:copy-of select="$state/param[contains($fields, @name)]"/>
- </customs>
- <fieldlist><xsl:value-of select="substring($fieldList,0,string-length($fieldList) )"/></fieldlist>
- <preferences>
- <xsl:copy-of select="$userPreferences/*"/>
- </preferences>
- </layout:controlparameters>
- </layout:localeselectorcontrol>
- </xsl:template>
- <xsl:template name="generateScript">
- <layout:script>
- var _THIS_currentForm="_THIS_form";
- function _THIS_refreshEdit(evt)
- {
- if(evt.eventPhase == evt.AT_TARGET)
- {
- checkToRefresh("_THIS_form",evt,"<xts:string id="IDS_PROP_REFRESH_LANGUAGE_MSG" encode="javascript"/>");
- }
- }
- _THIS_.addEventListener("fragment.refresh","_THIS_refreshEdit",false);
- function _THIS_getValue(formElement)
- {
- return formElement.value;
- }
- function _THIS_cancelClicked(){
- document._THIS_form.reset();
- document._THIS_form.privateAction.value='cancel';
- document._THIS_form.submit();
- }
- function _THIS_okClicked()
- {
- if (_THIS_validateFields())
- {
- document._THIS_form.privateAction.value='save';
- document._THIS_form.submit();
- document._THIS_form._THIS_okButton.disabled=true;
- }
- }
- function _THIS_validateFields()
- {
- for(var index=0;index < _THIS_validationFunctionArray.length;index++)
- {
- if ( !_THIS_validationFunctionArray[index].validateFunction(_THIS_validationFunctionArray[index].propertyName, _THIS_validationFunctionArray[index].inputName))
- return false;
- }
- return true;
- }
- function _THIS_multiLingualGenericEditValidate(propertyName)
- {
- var cForm = document.forms[_THIS_validationFunctionArray.form];
- var res = validateMultiLingualProperty(_THIS_validationFunctionArray.multiLingualSelector, propertyName, _THIS_validationFunctionArray.localFormName, "_THIS_", _THIS_, _THIS_validationFunctionArray.multiLingualItemList);
- if (res == CValidator.RES_VALID)
- {
- return true;
- }
- else
- {
- var entryEl = document.getElementById("_THIS_" + propertyName);
- alert(entryEl.getAttribute("valerr:message"));
- entryEl.focus();
- return false;
- }
- }
- function _THIS_genericEditValidate(propertyName, inputName)
- {
- var cForm = document.forms[_THIS_validationFunctionArray.form];
- var el = cForm.elements[inputName];
- var valErr = _THIS_.validate(propertyName, el.value);
- var message = "";
- if (valErr ==CValidator.RES_VALID)
- return true;
- switch(valErr)
- {
- case CValidator.RES_NUMERIC_NAN:
- message = "<xts:string id='IDS_GEN_CLIENT_VALIDATION_ERROR_INVALID_NUMBER' encode='javascript'/>";
- break;
- case CValidator.RES_NUMERIC_MIN:
- message = "<xts:string id='IDS_GEN_CLIENT_VALIDATION_ERROR_NUMBER_MIN' encode='javascript'/>";
- break;
- case CValidator.RES_NUMERIC_MAX:
- message = "<xts:string id='IDS_GEN_CLIENT_VALIDATION_ERROR_NUMBER_MAX' encode='javascript'/>";
- break;
- case CValidator.RES_TYPE_INT:
- message = "<xts:string id='IDS_GEN_CLIENT_VALIDATION_ERROR_NUMBER_INT' encode='javascript'/>";
- break;
- case CValidator.RES_TYPE_LONG:
- message = "<xts:string id='IDS_GEN_CLIENT_VALIDATION_ERROR_NUMBER_LONG' encode='javascript'/>";
- break;
- case CValidator.RES_TYPE_UNSIGNED_INT:
- message = "<xts:string id='IDS_GEN_CLIENT_VALIDATION_ERROR_NUMBER_UNSIGNEDINT' encode='javascript'/>";
- break;
- case CValidator.RES_INTEGRAL:
- message = "<xts:string id='IDS_GEN_CLIENT_VALIDATION_ERROR_NUMBER_INTEGRAL' encode='javascript'/>";
- break;
- default:
- message =el.getAttribute("valerr:message");
- break;
- }
- alert(message);
- el.focus();
- return false;
- }
- function _THIS_isValidURL(url, mandatory)
- {
- if (url.length == 0 && mandatory == false) {
- // a blank is fine only if the option is not selected
- return true;
- }
- var sep = url.indexOf("//");
- var protocol = url.substring(0, sep).toLowerCase();
- var badChars = false;
- for (i = 0; i < url.length; i++)
- {
- var n = url.charCodeAt(i);
- if ( n <= 32 || n > 127 )
- {
- badChars = true;
- break;
- }
- }
- return ( ( (protocol == "http:") || (protocol == "https:") ) && (!badChars) && (url.length > sep + 2) );
- }
- <xsl:apply-templates select="$metaData/customProperties" mode="markup-scripting"/>
- </layout:script>
- </xsl:template>
-
- <xsl:template name="relatedControl">
- <xsl:param name="relControlCustomProperties"/>
- <xsl:param name="propSiblings" select="/*[false()]"/>
- <xsl:param name="matchControlId" select="''"/>
- <!-- render layout of ordered customProperties followed by any non-ordered ones -->
- <xsl:for-each select="$relControlCustomProperties[control/@order]">
- <xsl:sort select="number(./control/@order)" data-type="number" order="ascending"/>
- <xsl:apply-templates select="." mode="markup">
- <xsl:with-param name="propSiblings" select="$propSiblings"/>
- <xsl:with-param name="matchControlId" select="$matchControlId"/>
- </xsl:apply-templates>
- </xsl:for-each>
- <xsl:if test="$relControlCustomProperties[not(control/@order)]">
- <xsl:apply-templates select="$relControlCustomProperties[not(control/@order)]" mode="markup">
- <xsl:with-param name="propSiblings" select="$propSiblings"/>
- <xsl:with-param name="matchControlId" select="$matchControlId"/>
- </xsl:apply-templates>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="keyScript">
- <xsl:param name="matchControl" select="''"/>
- <xsl:param name="resetControl" select="''"/>
- <xsl:param name="setControl" select="''"/>
- <xsl:param name="currentControl" select="''"/>
- <xsl:if test="$matchControl != '' or $resetControl != '' or $setControl != ''">
- <xsl:text>javascript:if(event.keyCode==9)return true;</xsl:text>
- </xsl:if>
- <xsl:if test="$matchControl != ''">
- <xsl:if test="$currentControl != ''">
- <xsl:text>if(document.getElementById("_THIS_</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(string($currentControl))"/>
- <xsl:text>").checked==true)</xsl:text>
- </xsl:if>
- <xsl:text>document.getElementById("_THIS_</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(string($matchControl))"/>
- <xsl:text>").checked=true;</xsl:text>
- </xsl:if>
- <xsl:if test="$setControl!='' and $setControl=$resetControl">
- <xsl:variable name="setencoded" select="xtsext:javascriptencode($setControl)"/>
- <xsl:text>if(!document.getElementById("_THIS_p_</xsl:text>
- <xsl:value-of select="$setencoded"/>
- <xsl:text>") || document.getElementById("_THIS_p_</xsl:text>
- <xsl:value-of select="$setencoded"/>
- <xsl:text>").value=="")_THIS_chooseSelection(_THIS_control</xsl:text>
- <xsl:value-of select="$setencoded"/>
- <xsl:text>);</xsl:text>
- </xsl:if>
- <xsl:if test="$resetControl!='' and $setControl != $resetControl">
- <xsl:variable name="resetencoded" select="xtsext:javascriptencode($resetControl)"/>
- <xsl:text>if(document.getElementById("_THIS_p_</xsl:text>
- <xsl:value-of select="$resetencoded"/>
- <xsl:text>"))_THIS_clearSelection(_THIS_control</xsl:text>
- <xsl:value-of select="$resetencoded"/>
- <xsl:text>);</xsl:text>
- </xsl:if>
- </xsl:template>
-
- </xsl:stylesheet>
- <!-- $Header: //cpscrn/main/src/java/etc/webapps/cps/WEB-INF/fragments/producers/common/propeditor/propedit.xslt#1 $ -->
- <!-- $DateTime: 2008/10/22 11:12:04 $ -->
- <!-- $Change: 25109 $ -->
|