123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <?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:out="dummy-uri"
- xmlns:layout="http://developer.cognos.com/common/layout"
- exclude-result-prefixes="layout">
-
- <xsl:output method="xml" encoding="UTF-8" indent="no"/>
- <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
- <xsl:template match="layout:localeselectorcontrol">
-
- <xsl:variable name="lscFormname">
- <xsl:choose>
- <xsl:when test="./layout:controlparameters/formname">
- <xsl:value-of select="./layout:controlparameters/formname"/></xsl:when>
- <xsl:when test="ancestor::layout:form/@name">
- <xsl:value-of select="ancestor::layout:form/@name"/>
- </xsl:when>
- <xsl:otherwise>pform</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="lscShortFormname">
- <xsl:choose>
- <xsl:when test="contains($lscFormname,'_THIS_')">
- <xsl:value-of select="substring-after($lscFormname,'_THIS_')"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="$lscFormname"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="lscSelectorname" select="@name"/>
-
- <xsl:variable name="lscExtendremovefunction">
- <xsl:if test="./layout:controlparameters/extendremovefunction"><xsl:value-of select="./layout:controlparameters/extendremovefunction"/></xsl:if>
- </xsl:variable>
- <out:variable name="useLscItemlist">
- <xsl:copy-of select="./layout:controlparameters/fieldlist"/><xsl:text>,</xsl:text>
- </out:variable>
- <out:variable name="useLscItemlistarray">
- <out:call-template name="createItemList">
- <out:with-param name="items"><out:value-of select="$useLscItemlist"/></out:with-param>
- </out:call-template>
- </out:variable>
-
- <out:variable name="useLscContentLocales">
- <xsl:choose>
- <xsl:when test="./layout:controlparameters/contentlocales"><xsl:copy-of select="./layout:controlparameters/contentlocales/*"/></xsl:when>
- <xsl:otherwise><out:copy-of select="/root/input[@name='configurationResponse']/config/param[@name='contentLocales']/*"/></xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:variable name="useLscItemlistfirstitem"><out:value-of select="substring-before($useLscItemlist,',')"/></out:variable>
-
- <out:variable name="useLscCustoms">
- <xsl:choose>
- <xsl:when test="./layout:controlparameters/customs"><xsl:copy-of select="./layout:controlparameters/customs/*"/></xsl:when>
- <xsl:otherwise><out:copy-of select="/root/customs/param[@name=$useLscItemlistfirstitem]/*"/></xsl:otherwise>
- </xsl:choose>
- </out:variable>
-
- <out:variable name="useLscPreferences">
- <xsl:choose>
- <xsl:when test="./layout:controlparameters/preferences"><xsl:copy-of select="./layout:controlparameters/preferences/*"/></xsl:when>
- <xsl:otherwise><out:copy-of select="/root/preferences/param[@name='contentLocale']"/></xsl:otherwise>
- </xsl:choose>
- </out:variable>
-
- <out:variable name="useLscPreferencesLocale" select="$useLscPreferences/param[@name='contentLocale']"/>
- <out:variable name="useLscSelection">
- <out:choose>
- <out:when test="not($useLscCustoms/param[@name=$useLscItemlistfirstitem]/value)">
- <out:value-of select="$useLscPreferencesLocale"/>
- </out:when>
- <out:otherwise>
- <out:variable name="lscLangs">
- <out:for-each select="$useLscCustoms/param[@name=$useLscItemlistfirstitem]/value">
- <out:value-of select="@xml:lang"/>
- <out:if test="not(position() = last())">,</out:if>
- </out:for-each>
- </out:variable>
- <out:if test="$lscLangs != ''">
- <out:value-of select="java:getBestFitLocale(string($useLscPreferencesLocale),string($lscLangs))" xmlns:java="java:com.cognos.portal.utils.CCLLocaleUtils"/>
- </out:if>
- </out:otherwise>
- </out:choose>
- </out:variable>
-
-
- <layout:section format="select-locale">
- <xsl:apply-templates select="./*[not(name()='layout:fieldlist' or name()='layout:label')]"/>
- <xsl:call-template name="localeselectorFields"/>
- <layout:hidden name="LocaleSelect" value="{'{$useLscSelection}'}"/>
- <layout:hidden name="removeLang" value=""/>
- <layout:script>
- var _THIS_gArrRemovedLocale = new Array();
- var _THIS_itemList = new Array(<out:value-of select="$useLscItemlistarray"/>);
- </layout:script>
- <xsl:if test="./layout:label">
- <layout:label for="_THIS_{$lscSelectorname}">
- <xsl:copy-of select="./layout:label/*"/>
- </layout:label>
- </xsl:if>
- <layout:select id="_THIS_{$lscSelectorname}" class="cogstyle-render-selector" name="_THIS_{$lscSelectorname}">
- <xsl:attribute name="onchange">javascript:adjustSelection('_THIS_','<xsl:value-of select="$lscShortFormname"/>','<xsl:value-of select="$lscSelectorname"/>',_THIS_itemList,'create')</xsl:attribute>
- <out:choose>
- <out:when test="not($useLscCustoms/param[@name=$useLscItemlistfirstitem]/value)">
- <layout:option value="{'{$useLscSelection}'}" selected="selected">
- <out:value-of select="$useLscContentLocales/locale[@id=$useLscSelection]"/>
- </layout:option>
- </out:when>
- <out:otherwise>
- <out:variable name="localeList">
- <out:for-each select="$useLscCustoms/param[@name=$useLscItemlistfirstitem]/value">
- <out:variable name="vLang" select="@xml:lang"/>
- <locale id="{'{$vLang}'}"><out:value-of select="$useLscContentLocales/locale[@id=$vLang]"/></locale>
- </out:for-each>
- </out:variable>
- <out:for-each select="$localeList/locale">
- <out:sort select="."/>
- <layout:option value="{'{@id}'}" id="{'{.}'}">
- <out:if test="@id=$useLscSelection">
- <out:attribute name="selected">selected</out:attribute>
- </out:if>
- <out:value-of select="."/>
- </layout:option>
- </out:for-each>
- </out:otherwise>
- </out:choose>
- <layout:option value="-"><out:value-of select="'--------------------'"/></layout:option>
- <out:for-each select="$useLscContentLocales/locale">
- <out:variable name="cId" select="@id"/>
- <out:variable name="displayName" select="string(.)"/>
- <out:choose>
- <out:when test="not($useLscCustoms/param[@name=$useLscItemlistfirstitem]/value)">
- <out:if test="$cId != $useLscSelection">
- <layout:option value="{'{$cId}'}">
- <out:value-of select="$displayName"/>
- </layout:option>
- </out:if>
- </out:when>
- <out:otherwise>
- <out:if test="not($useLscCustoms/param[@name=$useLscItemlistfirstitem]/value/@xml:lang=$cId)">
- <layout:option value="{'{$cId}'}">
- <out:value-of select="$displayName"/>
- </layout:option>
- </out:if>
- </out:otherwise>
- </out:choose>
- </out:for-each>
- </layout:select>
- <layout:removelocaleaction>adjustSelection('_THIS_','<xsl:value-of select="$lscShortFormname"/>','<xsl:value-of select="$lscSelectorname"/>',_THIS_itemList,'remove');<xsl:value-of select="$lscExtendremovefunction"/></layout:removelocaleaction>
- </layout:section>
- </xsl:template>
-
- <xsl:template match="layout:label">
- <xsl:copy-of select="."/>
- </xsl:template>
-
- <xsl:template name="localeselectorFields">
- <out:for-each select="$useLscCustoms/param">
- <out:variable name="pname" select="@name"/>
- <out:if test="./value">
- <out:for-each select="./value">
- <layout:hidden>
- <out:attribute name="name"><out:value-of select="concat($pname,'-',string(@xml:lang))"/></out:attribute>
- <out:attribute name="value"><out:value-of select="string(.)"/></out:attribute>
- </layout:hidden>
- </out:for-each>
- </out:if>
- </out:for-each>
- </xsl:template>
-
- <xsl:template match="layout:selectortemplates">
- <out:template name="createItemList">
- <out:param name="items" select="''"/>
- <out:variable name="curritem" select="substring-before($items,',')"/>
- <out:variable name="nextitems" select="substring-after($items,',')"/>
- <out:value-of select="concat('"',$curritem,'"')"/>
- <out:if test="$nextitems!=''">
- <out:text/><xsl:value-of select="','"/><xsl:text/>
- <out:call-template name="createItemList">
- <out:with-param name="items" select="$nextitems"/>
- </out:call-template>
- </out:if>
- </out:template>
- </xsl:template>
-
- <xsl:template match="*">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates/>
- </xsl:copy>
- </xsl:template>
- </xsl:stylesheet>
- <!-- $Header: //cpscrn/main/src/java/etc/webapps/cps/WEB-INF/fragments/producers/utilities/common/logic/localeSelector.xslt#1 $ -->
- <!-- $DateTime: 2008/10/22 11:12:04 $ -->
- <!-- $Change: 25109 $ -->
|