Language switching now works for the list of countries in the Address content type (#1764)

git-svn-id: https://svn.libreccm.org/ccm/trunk@2876 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-09-25 13:15:45 +00:00
parent e8a69ca7fb
commit fc7ce33b0a
5 changed files with 253 additions and 26 deletions

View File

@ -43,6 +43,7 @@ import com.arsdigita.cms.contenttypes.GenericAddress;
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil; import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
import com.arsdigita.cms.ui.authoring.BasicPageForm; import com.arsdigita.cms.ui.authoring.BasicPageForm;
import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.cms.util.GlobalizationUtil;
import com.arsdigita.globalization.GlobalizationHelper;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@ -98,7 +99,7 @@ public class GenericAddressPropertyForm extends BasicPageForm
address.setRows(5); address.setRows(5);
address.setCols(30); address.setCols(30);
add(address); add(address);
ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE); ParameterModel postalCodeParam = new StringParameter(POSTAL_CODE);
TextField postalCode = new TextField(postalCodeParam); TextField postalCode = new TextField(postalCodeParam);
postalCode.setLabel(ContenttypesGlobalizationUtil postalCode.setLabel(ContenttypesGlobalizationUtil
@ -124,7 +125,7 @@ public class GenericAddressPropertyForm extends BasicPageForm
SingleSelect country = new SingleSelect(countryParam); SingleSelect country = new SingleSelect(countryParam);
country.setLabel(ContenttypesGlobalizationUtil country.setLabel(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.iso_country_code")); .globalize("cms.contenttypes.ui.address.iso_country_code"));
try { try {
country.addPrintListener(new PrintListener() { country.addPrintListener(new PrintListener() {
@ -133,12 +134,13 @@ public class GenericAddressPropertyForm extends BasicPageForm
final SingleSelect target = (SingleSelect) event.getTarget(); final SingleSelect target = (SingleSelect) event.getTarget();
target.clearOptions(); target.clearOptions();
final Iterator countries = GenericAddress.getSortedListOfCountries(null) final Iterator countries = GenericAddress.getSortedListOfCountries(
GlobalizationHelper.getNegotiatedLocale())
.entrySet().iterator(); .entrySet().iterator();
target.addOption(new Option("", target.addOption(new Option("",
new Label(GlobalizationUtil new Label(GlobalizationUtil
.globalize("cms.ui.select_one")))); .globalize("cms.ui.select_one"))));
while (countries.hasNext()) { while (countries.hasNext()) {
Map.Entry<String, String> elem = (Map.Entry<String, String>) countries Map.Entry<String, String> elem = (Map.Entry<String, String>) countries
.next(); .next();
@ -163,7 +165,7 @@ public class GenericAddressPropertyForm extends BasicPageForm
if (isoCode == null || isoCode.length() == 0) { if (isoCode == null || isoCode.length() == 0) {
data.addError(ContenttypesGlobalizationUtil data.addError(ContenttypesGlobalizationUtil
.globalize("cms.contenttypes.ui.address.error_iso_country") .globalize("cms.contenttypes.ui.address.error_iso_country")
); );
} }
} }

View File

@ -60,8 +60,8 @@
</foundry:doc-see-also> </foundry:doc-see-also>
</foundry:doc> </foundry:doc>
<xsl:template match="a"> <xsl:template match="a">
<xsl:with-param name="href" select="''"/> <xsl:param name="href" select="''"/>
<xsl:with-param name="title" select="''"/> <xsl:param name="title" select="''"/>
<a> <a>
<xsl:if test="./@download"> <xsl:if test="./@download">

View File

@ -49,9 +49,7 @@
<xsl:value-of select="$data-tree//nav:categoryMenu[@id=$navigation-id]/nav:category/@title"/> <xsl:value-of select="$data-tree//nav:categoryMenu[@id=$navigation-id]/nav:category/@title"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="foundry:get-static-text('navigation', <xsl:value-of select="foundry:get-static-text('navigation', $data-tree//nav:categoryMenu[@id=$navigation-id]/@navigation-id, 'false')"/>
$data-tree//nav:categoryMenu[@id=$navigation-id]/@navigation-id,
'false')"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:when> </xsl:when>
@ -68,7 +66,146 @@
<xsl:value-of select="foundry:shying($data-tree//nav:categoryMenu[@id=$navigation-id]/nav:category/@title)"/> <xsl:value-of select="foundry:shying($data-tree//nav:categoryMenu[@id=$navigation-id]/nav:category/@title)"/>
</xsl:template> </xsl:template>
<xsl:template match="navigation-layout"> <xsl:template match="navigation">
<apply-templates/>
<xsl:apply-templates select=".//navigation-links">
<xsl:with-param name="navigation-id"
select="foundry:get-attribute-value('navigation-id', 'categoryMenu')"/>
<xsl:with-param name="with-colorset"
select="foundry:get-attribute-value('with-colorset', 'false')"/>
<xsl:with-param name="min-level"
select="foundry:get-attribute-value('min-level', 1)"/>
<xsl:with-param name="max-level"
select="foundry:get-attribute-value('max-level', 999)"/>
<xsl:with-param name="show-description-text"
select="foundry:get-attribute-value('show-description-text', 'true')"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="navigation//navigation-links">
<xsl:param name="navigation-id"/>
<xsl:param name="with-colorset"/>
<xsl:param name="min-level"/>
<xsl:param name="max-level"/>
<xsl:param name="show-description-text"/>
<xsl:param name="current-level" select="1"/>
<xsl:param name="current-level-tree" select="$data-tree//nav:categoryMenu[@id=$navigation-id]/nav:category/nav:category"/>
<dl>
<dt>navigation-id</dt>
<dd><xsl:value-of select="$navigation-id"/></dd>
<dt>with-colorset</dt>
<dd><xsl:value-of select="$with-colorset"/></dd>
<dt>min-level</dt>
<dd><xsl:value-of select="$min-level"/></dd>
<dt>max-level</dt>
<dd><xsl:value-of select="$max-level"/></dd>
<dt>current-level</dt>
<dd><xsl:value-of select="$current-level"/></dd>
</dl>
<xsl:choose>
<xsl:when test="($current-level &gt;= $min-level) and ($current-level &lt;= $max-level)">
<xsl:apply-templates>
<xsl:with-param name="navigation-id" select="$navigation-id"/>
<xsl:with-param name="with-colorset" select="$with-colorset"/>
<xsl:with-param name="min-level" select="$min-level"/>
<xsl:with-param name="max-level" select="$max-level"/>
<xsl:with-param name="show-description-text" select="$show-description-text"/>
<xsl:with-param name="current-level" select="1"/>
<xsl:with-param name="current-level-tree" select="$current-level-tree"/>
<xsl:with-param name="navigation-links-tree" select="."/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="($current-level &lt; $min-level) and $current-level-tree/nav:category">
<xsl:apply-templates select=".">
<xsl:with-param name="navigation-id" select="$navigation-id"/>
<xsl:with-param name="with-colorset" select="$with-colorset"/>
<xsl:with-param name="min-level" select="$min-level"/>
<xsl:with-param name="max-level" select="$max-level"/>
<xsl:with-param name="show-description-text" select="$show-description-text"/>
<xsl:with-param name="current-level" select="$current-level + 1"/>
<xsl:with-param name="current-level-tree"
select="$current-level-tree/nav:category"/>
<xsl:with-param name="navigation-links-tree" select="."/>
</xsl:apply-templates>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="navigationlinks//navigation-link">
<xsl:param name="navigation-id"/>
<xsl:param name="with-colorset"/>
<xsl:param name="min-level"/>
<xsl:param name="max-level"/>
<xsl:param name="show-description-text"/>
<xsl:param name="current-level"/>
<xsl:param name="current-level-tree"/>
<xsl:param name="navigation-links-tree"/>
<xsl:variable name="link-tree" select="."/>
<xsl:for-each select="$current-level-tree">
<xsl:apply-templates select="$link-tree">
<xsl:with-param name="navigation-id" select="$navigation-id"/>
<xsl:with-param name="with-colorset" select="$with-colorset"/>
<xsl:with-param name="min-level" select="$min-level"/>
<xsl:with-param name="max-level" select="$max-level"/>
<xsl:with-param name="show-description-text"
select="show-description-text"/>
<xsl:with-param name="current-level" select="$current-level"/>
<xsl:with-param name="current-level-tree" select="$current-level-tree"/>
<xsl:with-param name="navigation-links-tree" select="$navigation-links-tree"/>
<xsl:with-param name="href" select="./@url"/>
<xsl:with-param name="title">
<xsl:choose>
<xsl:when test="$show-description-text and ./@description">
<xsl:value-of select="./@description"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./@title"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="link-label" select="./@title"/>
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>
<xsl:template match="navigation-link//navigation-link-label">
<xsl:param name="link-label"/>
<xsl:value-of select="$link-label"/>
</xsl:template>
<xsl:template match="navigation-link//navigation-sublinks">
<xsl:param name="navigation-id"/>
<xsl:param name="with-colorset"/>
<xsl:param name="min-level"/>
<xsl:param name="max-level"/>
<xsl:param name="show-description-text"/>
<xsl:param name="current-level"/>
<xsl:param name="current-level-tree"/>
<xsl:param name="navigation-links-tree"/>
<xsl:if test="($current-level &lt;= $max-level) and $current-level-tree/nav:category">
<xsl:apply-templates select="$navigation-links-tree">
<xsl:with-param name="navigation-id" select="$navigation-id"/>
<xsl:with-param name="with-colorset" select="$with-colorset"/>
<xsl:with-param name="min-level" select="$min-level"/>
<xsl:with-param name="max-level" select="$max-level"/>
<xsl:with-param name="show-description-text" select="$show-description-text"/>
<xsl:with-param name="current-level" select="$current-level + 1"/>
<xsl:with-param name="navigation-links-tree" select="$navigation-links-tree"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<!--<xsl:template match="navigation-layout">
<xsl:apply-templates> <xsl:apply-templates>
<xsl:with-param name="navigation-id" <xsl:with-param name="navigation-id"
select="foundry:get-attribute-value('navigation-id', 'categoryMenu')"/> select="foundry:get-attribute-value('navigation-id', 'categoryMenu')"/>
@ -219,6 +356,6 @@
<xsl:value-of select="$title"/> <xsl:value-of select="$title"/>
</a> </a>
</xsl:template> </xsl:template>-->
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -34,6 +34,91 @@ EXSLT functions.
version="1.0"> version="1.0">
<foundry:doc section="devel">
<foundry:doc-param name="value" mandatory="yes">
The value to evaluate.
</foundry:doc-param>
<foundry:doc-desc>
<p>
A helper function for evaluating certain string values to boolean. This function has two
two purposes. First it simplifies some expressions. for example if you have a
template tag with a attribute containing a (pseudo) boolean value (attribute values
are always treated as strings) you would have to write something like:
</p>
<pre>
...
<xsl:if test="./@attr = 'true'">
...
</xsl:if>
...
</pre>
<p>
Using <code>foundry:boolean</code> this can be simplified to
</p>
<pre>
...
<xsl:if test="foundry:boolean(./@attr)">
...
</xsl:if>
...
</pre>
<p>
The more important purpose is to make the usage of boolean values more user
friendly, especially in the templates. Using <code>foundry:boolean</code> no only
<code>true</code> is evaluated to boolean <code>true</code>. A number of other
strings is also evaluated to <code>true</code>:
</p>
<ul>
<li>
<code>true</code>
</li>
<li>
<code>TRUE</code>
</li>
<li>
<code>yes</code>
</li>
<li>
<code>YES</code>
</li>
<li>
<code>t</code>
</li>
<li>
<code>T</code>
</li>
<li>
<code>y</code>
</li>
<li>
<code>Y</code>
</li>
</ul>
<p>
All other values are evaluated to <code>false</code>.
</p>
</foundry:doc-desc>
</foundry:doc>
<func:function name="foundry:boolean">
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="$value = 'true'
or $value = 'TRUE'
or $value = 'yes'
or $value = 'YES'
or $value = 't'
or $value = 'T'
or $value = 'y'
or $value = 'Y'">
<func:result select="true()"/>
</xsl:when>
<xsl:otherwise>
<func:result select="false()"/>
</xsl:otherwise>
</xsl:choose>
</func:function>
<foundry:doc section="devel"> <foundry:doc section="devel">
<foundry:doc-param name="level" <foundry:doc-param name="level"
mandatory="yes"> mandatory="yes">

View File

@ -9,18 +9,21 @@
</head> </head>
<body> <body>
<nav> <nav>
<navigation-layout> <navigation-home-link/>
<navigation-home-link/> <navigation>
<navigation-link-list> <div class="nav-wrapper">
<ul> <navigation-links>
<navigation-link-layout> <ul>
<li> <navigation-link>
<navigation-link/> <li>
</li> <a><navigation-link-label/></a>
</navigation-link-layout> <navigation-sublinks/>
</ul> </li>
</navigation-link-list> </navigation-link>
</navigation-layout> </ul>
</navigation-links>
</div>
</navigation>
</nav> </nav>
<main> <main>
<div> <div>