123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?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:pui="http://developer.cognos.com/common/portal/logic/ui/1/"
- xmlns:layout="http://developer.cognos.com/common/layout"
- xmlns:valerr="http://developer.cognos.com/validation/errrormessages/1/"
- xmlns:java="java:com.cognos.portal.utils.CCLLocaleUtils"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xts xtsext layout">
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:variable name="meta" select="/root/fragment/meta"/>
- <xsl:variable name="useLocale">
- <xsl:choose>
- <xsl:when test="not(/root/customs/param[@name='title']/value)">
- <xsl:value-of select="/root/preferences/param[@name='contentLocale']"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="langs">
- <xsl:for-each select="/root/customs/param[@name='title']/value">
- <xsl:value-of select="@xml:lang"/>
- <xsl:if test="not(position() = last())">,</xsl:if>
- </xsl:for-each>
- </xsl:variable>
- <xsl:value-of select="java:getBestFitLocale(string(/root/preferences/param[@name='contentLocale']),string($langs))"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <layout:selectortemplates/>
- <xsl:template match="/">
- <div>
- <pui:aboutscript/>
- <pui:helpscript/>
- <layout:form name="_THIS_HTMLForm" action="_THIS?/THIS_" method="post">
- <layout:section format="header">
- <layout:text><xsl:value-of select="$meta/customProperties[@name='Description']/hint"/></layout:text>
- <layout:actionlist>
- <layout:action>
- <pui:aboutlink/>
- </layout:action>
- <layout:action>
- <pui:helplink/>
- </layout:action>
- </layout:actionlist>
- </layout:section>
- <layout:script>
- var _THIS_validationSuccess = "<xts:string id="IDS_PROP_VALIDATE_SUCCESSFUL" encode="javascript"/>";
- var _THIS_validationMessage = "<xts:string id="IDS_PROP_VALIDATE_DESCRIPTION" encode="javascript"/>";
- var _THIS_validationException = "<xts:string id="IDS_PROP_VALIDATE_EXCEPTION" encode="javascript"/>";
-
- function _THIS_refreshEdit(evt)
- {
- if(evt.eventPhase == evt.AT_TARGET)
- {
- checkToRefresh("_THIS_HTMLForm",evt,"<xts:string id="IDS_PROP_REFRESH_LANGUAGE_MSG" encode="javascript"/>");
- }
- }
-
- _THIS_.addEventListener("fragment.refresh","_THIS_refreshEdit",false);
-
- function _THIS_cancelEdit()
- {
- if (_THIS_.removeFragChildren)
- _THIS_.removeFragChildren();
- _THIS_.setMode('view');
- }
-
- function _THIS_processModeHTML(formaction,cur,sForm,content,select)
- {
-
- if (formaction == "save")
- {
- //first validate the title
- var titleErr = validateMultiLingualProperty("Selector", "title", "HTMLForm", "_THIS_", _THIS_, _THIS_itemList);
- if (titleErr != CValidator.RES_VALID)
- {
- var entryEl = document.getElementById("_THIS_title");
- alert(entryEl.getAttribute("valerr:message"));
- entryEl.focus();
- return false;
- }
-
- }
- cForm = document.forms[cur+sForm];
- elem = $(cur+content);
- if( formaction != 'edit' && formaction != 'cancel' )
- {
- if( elem && elem.value != '' )
- {
- formaction = _THIS_validateHTML(elem, formaction);
- var selector = $("_THIS_Selector");
- var languageSpecificPropertyName = "HTMLMarkup-" +(selector.options[selector.selectedIndex]).value;
- var currentLanguageItem = cForm.elements[languageSpecificPropertyName];
- currentLanguageItem.value = elem.value;
- }
- }
- if( formaction != "validate")
- {
- setHiddenItemValue(cForm,'formaction',formaction);
- cForm.submit();
- }
- }
-
- function _THIS_validateHTML(elem,formaction)
- {
- var bnchmrkVal = markup = elem.value;
- <!-- How to read this expression - find < optionally with / then one of these tags with anything before the >; make it global, case insensitive and mulitple lines -->
- var tagsList = /<(\/)?(html|script|body|form|head|frameset|frame).*?\>/gim;
- var hasTags = tagsList.test(bnchmrkVal);
- if(hasTags)
- {
- <!-- How to read these expressions - find any control characters, then < optionally with / then the tag name with anything before the >, -->
- <!-- then any control characters; make it global and case insensitive -->
- var removeTagsOnly = /(\0|\r|\n|\t|\v|\f)*<(\/)?(html|body|form).*?\>(\0|\r|\n)*/gi;
- if(removeTagsOnly.test(markup))
- markup = markup.replace(removeTagsOnly,"");
- <!-- How to read these expressions - find any control characters, then the < tag name with anything before the >, -->
- <!-- then any characters or control characters, then the </ tag name >, then any control characters; make it global, case insensitive and multiple lines -->
- <!-- ***** NOTE *****: the following conditions are not to be combined since doing so causes too much trimming of the input HTML code -->
- var regxHead = /(\0|\r|\n|\t|\v|\f)*<head.*?\>(?:(.|\n)*)<\/head\>(\0|\r|\n)*/gim;
- var regxScript = /(\0|\r|\n|\t|\v|\f)*<script.*?\>(?:(.|\n)*)<\/script\>(\0|\r|\n)*/gim;
- var regxFrameset = /(\0|\r|\n|\t|\v|\f)*<frameset.*?\>(?:(.|\n)*)<\/frameset\>(\0|\r|\n)*/gim;
- var regxFrame = /(\0|\r|\n|\t|\v|\f)*<frame.*?\>(?:(.|\n)*)<\/frame\>(\0|\r|\n)*/gim;
- <!-- look for the matching head tags -->
- if(markup.match(regxHead))
- markup = markup.replace(regxHead,"");
-
- <!-- look for the matching script tags -->
- if(markup.match(regxScript))
- markup = markup.replace(regxScript,"");
-
- <!-- look for the matching frameset tags -->
- if(markup.match(regxFrameset))
- markup = markup.replace(regxFrameset,"");
- <!-- look for the matching frame tags -->
- if(markup.match(regxFrame))
- markup = markup.replace(regxFrame,"");
- <!-- Clean up any orphaned head or frame* tags -->
- regxFrame = /(\0|\r|\n|\t|\v|\f)*<(\/)?(head|frame|script).*?\>/gi;
- if(markup.match(regxFrame))
- markup = markup.replace(regxFrame,"");
- }
- if(hasTags || !(markup === elem.value))
- {
- elem.value = markup;
- alert(_THIS_validationMessage);
- }
- else if(formaction=='validate')
- alert(_THIS_validationSuccess);
-
- return formaction;
- }
- </layout:script>
- <layout:localeselectorcontrol name="Selector">
- <layout:label>
- <layout:text><xts:string id="IDS_PROP_LANGUAGE_CAPTION"/></layout:text>
- </layout:label>
- <layout:controlparameters>
- <formname>_THIS_HTMLForm</formname>
- <contentlocales><xsl:copy-of select="/root/input[@name='configurationResponse']/config/param[@name='contentLocales']/*"/></contentlocales>
- <customs><xsl:copy-of select="/root/customs/*"/></customs>
- <fieldlist>title,HTMLMarkup</fieldlist>
- <preferences><xsl:copy-of select="/root/preferences/*"/></preferences>
- </layout:controlparameters>
- </layout:localeselectorcontrol>
- <layout:field id="title" type="text" size="40" maxlength="256" onblur="javascript:savelangitem('_THIS_','HTMLForm','Selector',this)" >
- <xsl:attribute name="message" namespace="http://developer.cognos.com/validation/errrormessages/1/" ><xts:string id="IDS_GEN_TITLE_VALIDATION_ERROR" /></xsl:attribute>
- <layout:label><layout:text><xsl:value-of select="$meta/customProperties[@name='title']/label"/></layout:text></layout:label>
- <layout:value>
- <xsl:choose>
- <xsl:when test="/root/customs/param[@name='title']/value[@xml:lang=$useLocale]">
- <xsl:value-of select="/root/customs/param[@name='title']/value[@xml:lang=$useLocale]"/>
- </xsl:when>
- <xsl:when test="/root/customs/param[@name='title']/value[1]">
- <xsl:value-of select="/root/customs/param[@name='title']/value[1]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="/root/fragment/meta/customProperties[@name='title']/default/value"/>
- </xsl:otherwise>
- </xsl:choose>
- </layout:value>
- </layout:field>
- <xsl:choose>
- <xsl:when test="string(/root/init/canEditHTML)='true'">
- <layout:field id="HTMLMarkup" type="textarea" rows="20" cols="100" onblur="javascript:savelangitem('_THIS_','HTMLForm','Selector',this)" >
- <xsl:attribute name="message" namespace="http://developer.cognos.com/validation/errrormessages/1/" ><xts:string id="IDS_PROP_VALIDATE_DESCRIPTION" encode="xml"/></xsl:attribute>
- <layout:label>
- <layout:text><xsl:value-of select="$meta/customProperties[@name='HTMLMarkup']/label"/></layout:text>
- <layout:hint><xsl:value-of select="$meta/customProperties[@name='HTMLMarkup']/hint"/></layout:hint>
- </layout:label>
- <layout:value>
- <xsl:choose>
- <xsl:when test="/root/customs/param[@name='HTMLMarkup']/value[@xml:lang=$useLocale]">
- <xsl:value-of select="/root/customs/param[@name='HTMLMarkup']/value[@xml:lang=$useLocale]"/>
- </xsl:when>
- <xsl:when test="/root/customs/param[@name='HTMLMarkup']/value[1]">
- <xsl:value-of select="/root/customs/param[@name='HTMLMarkup']/value[1]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="/root/fragment/meta/customProperties[@name='HTMLMarkup']/default/value"/>
- </xsl:otherwise>
- </xsl:choose>
- </layout:value>
- </layout:field>
- </xsl:when>
- <xsl:otherwise>
- <layout:section>
- <layout:label>
- <layout:text><xsl:value-of select="$meta/customProperties[@name='HTMLMarkup']/label"/></layout:text>
- <layout:hint><xsl:value-of select="$meta/customProperties[@name='HTMLMarkup']/hint"/></layout:hint>
- </layout:label>
- </layout:section>
- <layout:section class="cogstyle-layout-textmsg">
- <layout:text><xts:string id="IDS_PROP_HTML_CAPABILITY_TEXT"/></layout:text>
- </layout:section>
- </xsl:otherwise>
- </xsl:choose>
- <layout:section format="footer" divider="true">
- <layout:row>
- <layout:button onclick="_THIS_processModeHTML('save','_THIS_','HTMLForm','HTMLMarkup','Selector');">
- <layout:value><xts:string id="IDS_PROP_OK_BUTTON_TEXT"/></layout:value>
- </layout:button>
- <layout:button onclick="_THIS_cancelEdit()">
- <layout:value><xts:string id="IDS_PROP_CANCEL_BUTTON_TEXT"/></layout:value>
- </layout:button>
- </layout:row>
- </layout:section>
- </layout:form>
- </div>
- </xsl:template>
- </xsl:stylesheet>
|