| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- <?xml version="1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:eat="http://msqr.us/xsd/ieat"
- xmlns:xweb="http://msqr.us/xsd/jaxb-web"
- exclude-result-prefixes="eat xweb">
-
- <xsl:import href="global-variables.xsl"/>
- <xsl:import href="util.xsl"/>
-
- <xsl:output method="html" omit-xml-declaration="yes"/>
- <xsl:template name="error-intro">
- <xsl:param name="errors-node"/>
- <xsl:if test="$errors-node/xweb:error">
- <div class="error-intro">
- <xsl:if test="$errors-node/xweb:error[not(@field)]">
- <!--<xsl:value-of select="$messages[@key='global.error.intro']"/>
- <xsl:text> </xsl:text>-->
- <xsl:apply-templates select="$errors-node/xweb:error[not(@field)]"/>
- </xsl:if>
- <xsl:if test="$errors-node/xweb:error[@field]">
- <xsl:value-of select="key('i18n','field.error.intro')"/>
- <ul>
- <xsl:for-each select="$errors-node/xweb:error[@field]">
- <li><xsl:value-of select="."/></li>
- </xsl:for-each>
- </ul>
- </xsl:if>
- </div>
- </xsl:if>
- </xsl:template>
-
- <!--
- Global Nav template
-
- Global vars:
- acting-user: the logged in user, if logged in
- web-context: the web context
- -->
- <xsl:template name="global-nav">
- <xsl:param name="page"/>
- <div class="nav-banner">
- <xsl:if test="$acting-user or key('appenv','feature.anonymous') = 'true'">
- <xsl:choose>
- <xsl:when test="$page = 'home'">
- <xsl:value-of select="key('i18n','link.home')"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="{$web-context}/home.do" title="{key('i18n','link.home.title')}">
- <xsl:value-of select="key('i18n','link.home')"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text> - </xsl:text>
- <xsl:choose>
- <xsl:when test="$page = 'index'">
- <xsl:value-of select="key('i18n','link.recipe.index')"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="{$web-context}/index.do" title="{key('i18n','link.recipe.index.title')}">
- <xsl:value-of select="key('i18n','link.recipe.index')"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text> - </xsl:text>
- <xsl:choose>
- <xsl:when test="$page = 'search'">
- <xsl:value-of select="key('i18n','link.recipe.search')"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="{$web-context}/search.do" title="{key('i18n','link.recipe.search.title')}">
- <xsl:value-of select="key('i18n','link.recipe.search')"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="$acting-user">
- <xsl:text> - </xsl:text>
- <xsl:choose>
- <xsl:when test="$page = 'add-recipe'">
- <xsl:value-of select="key('i18n','link.recipe.add')"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="{$web-context}/addRecipe.do" title="{key('i18n','link.recipe.add.title')}">
- <xsl:value-of select="key('i18n','link.recipe.add')"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text> - </xsl:text>
- <xsl:choose>
- <xsl:when test="$page = 'meals'">
- <xsl:value-of select="key('i18n','link.meals')"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="{$web-context}/meals.do" title="{key('i18n','link.meals.title')}">
- <xsl:value-of select="key('i18n','link.meals')"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="$acting-user or key('appenv','feature.anonymous') = 'true'">
- <xsl:text> - </xsl:text>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="$acting-user">
- <xsl:if test="$acting-user/../@admin = 'true'">
- <xsl:choose>
- <xsl:when test="$page = 'admin-home'">
- <xsl:value-of select="key('i18n','link.admin')"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="{$web-context}/admin.do" title="{key('i18n','link.admin.title')}">
- <xsl:value-of select="key('i18n','link.admin')"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text> - </xsl:text>
- </xsl:if>
- <a href="{$web-context}/logoff.do" title="{key('i18n','link.logout.title')}">
- <xsl:value-of select="key('i18n','link.logout')"/>
- </a>
- <xsl:text> (</xsl:text>
- <xsl:value-of select="$acting-user/eat:name"/>
- <xsl:text>)</xsl:text>
- </xsl:when>
- <xsl:when test="$page = 'logon'">
- <xsl:value-of select="key('i18n','link.logon')"/>
- </xsl:when>
- <xsl:otherwise>
- <a href="{$web-context}/logon.do" title="{key('i18n','link.logon.title')}">
- <xsl:value-of select="key('i18n','link.logon')"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- </div>
- </xsl:template>
- <!--
- Search results hidden form element templates.
- -->
- <xsl:template match="eat:search-results" mode="search-results-contextual-navigation">
- <xsl:if test="@pageSize > 0">
- <input type="hidden" name="searchResults.pageSize" value="{@pageSize}"/>
- </xsl:if>
- <xsl:if test="@pageStart > 0">
- <input type="hidden" name="searchResults.pageStart" value="{@pageStart}"/>
- </xsl:if>
- <xsl:apply-templates select="eat:ui-index/eat:index-section[@selected='true']"
- mode="search-results-contextual-navigation"/>
- <xsl:apply-templates select="eat:recipe-criteria"
- mode="search-results-contextual-navigation"/>
- </xsl:template>
- <xsl:template match="eat:ui-index/eat:index-section" mode="search-results-contextual-navigation">
- <input type="hidden" name="searchResults.uiIndex.indexSection[{position() - 1}].indexKey"
- value="{@index-key}"/>
- </xsl:template>
- <xsl:template match="eat:recipe-criteria" mode="search-results-contextual-navigation">
- <input type="hidden" name="searchResults.criteria.mode" value="{@mode}"/>
- <xsl:if test="eat:simpleQuery">
- <input type="hidden" name="searchResults.criteria.simpleQuery"
- value="{eat:simpleQuery}"/>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="eat:search-results" mode="contextual-navigation">
- <xsl:if test="@pageSize > 0">
- <input type="hidden" name="index.pageSize" value="{@pageSize}"/>
- </xsl:if>
- <xsl:if test="@pageStart > 0">
- <input type="hidden" name="index.pageStart" value="{@pageStart}"/>
- </xsl:if>
- <xsl:apply-templates select="eat:ui-index/eat:index-section[@selected='true']"
- mode="contextual-navigation"/>
- <xsl:apply-templates select="eat:recipe-criteria" mode="contextual-navigation"/>
- </xsl:template>
- <xsl:template match="eat:ui-index/eat:index-section" mode="contextual-navigation">
- <input type="hidden" name="index.displaySection" value="{@index-key}"/>
- </xsl:template>
- <xsl:template match="eat:recipe-criteria" mode="contextual-navigation">
- <input type="hidden" name="criteria.mode" value="{@mode}"/>
- <xsl:if test="eat:simpleQuery">
- <input type="hidden" name="criteria.simpleQuery" value="{eat:simpleQuery}"/>
- </xsl:if>
- </xsl:template>
-
- <!--
- Render index page navigation
- -->
- <xsl:template name="render-ui-index">
- <xsl:param name="ui-index"/>
- <xsl:param name="link"/>
- <table class="recipe-index">
- <tbody>
- <tr>
- <xsl:for-each select="$ui-index/eat:index-section">
- <xsl:call-template name="render-index-section">
- <xsl:with-param name="index-section" select="."/>
- <xsl:with-param name="link" select="$link"/>
- </xsl:call-template>
- </xsl:for-each>
- </tr>
- </tbody>
- </table>
- </xsl:template>
- <xsl:template name="render-index-section">
- <xsl:param name="index-section"/>
- <xsl:param name="link"/>
- <td>
- <xsl:if test="$index-section/@selected">
- <xsl:attribute name="class">selected</xsl:attribute>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="$index-section/@selected">
- <xsl:value-of select="$index-section/@index-key"/>
- </xsl:when>
- <xsl:otherwise>
- <a>
- <xsl:attribute name="href">
- <xsl:value-of select="$web-context"/>
- <xsl:value-of select="$link"/>
- <xsl:text>?displaySection=</xsl:text>
- <xsl:value-of select="$index-section/@index-key"/>
- <xsl:if test="not($index-section/../../@pageSize = $index-section/../../eat:pagination/@defaultPageSize)">
- <xsl:text>&pageSize=</xsl:text>
- <xsl:value-of select="$index-section/../../@pageSize"/>
- </xsl:if>
- </xsl:attribute>
- <xsl:value-of select="$index-section/@index-key"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text> (</xsl:text>
- <xsl:value-of select="$index-section/@count"/>
- <xsl:text>)</xsl:text>
- </td>
- </xsl:template>
- <xsl:template name="render-index-navigation">
- <xsl:param name="search-results"/>
- <xsl:param name="curr-page" select="0"/>
- <xsl:param name="max-page"/>
- <xsl:param name="link"/>
- <xsl:if test="$curr-page > 0">
- <xsl:text> - </xsl:text>
- </xsl:if>
- <xsl:choose>
- <xsl:when test="$search-results/@pageStart = $curr-page">
- <span class="selected-page">
- <xsl:value-of select="$curr-page + 1"/>
- </span>
- </xsl:when>
- <xsl:otherwise>
- <a>
- <xsl:attribute name="href">
- <xsl:value-of select="$web-context"/>
- <xsl:value-of select="$link"/>
- <xsl:text>?displaySection=</xsl:text>
- <xsl:value-of select="$search-results/eat:ui-index/eat:index-section[@selected]/@index-key"/>
- <xsl:text>&pageSize=</xsl:text>
- <xsl:value-of select="$search-results/@pageSize"/>
- <xsl:if test="$curr-page > 0">
- <xsl:text>&pageStart=</xsl:text>
- <xsl:value-of select="$curr-page"/>
- </xsl:if>
- </xsl:attribute>
- <xsl:value-of select="$curr-page + 1"/>
- </a>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="$curr-page < ($max-page - 1)">
- <xsl:call-template name="render-index-navigation">
- <xsl:with-param name="search-results" select="$search-results"/>
- <xsl:with-param name="curr-page" select="$curr-page + 1"/>
- <xsl:with-param name="max-page" select="$max-page"/>
- <xsl:with-param name="link" select="$link"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="eat:search-results" mode="render-index-pagination-menu">
- <xsl:if test="eat:pagination/eat:allowablePageSize">
- <div class="pagination">
- <form action="{$web-context}{$ctx/xweb:path}" method="post">
- <xsl:value-of select="key('i18n','pagination.size.displayName')"/>
- <xsl:text>: </xsl:text>
- <select name="pageSize" id="pagination-select">
- <xsl:for-each select="eat:pagination/eat:allowablePageSize">
- <option value="{.}">
- <xsl:if test="string(.) = ../../@pageSize">
- <xsl:attribute name="selected">selected</xsl:attribute>
- </xsl:if>
- <xsl:value-of select="."/>
- </option>
- </xsl:for-each>
- <xsl:if test="eat:pagination/@allowUnlimited = 'true'">
- <option value="-1">
- <xsl:if test="'-1' = ../../@pageSize">
- <xsl:attribute name="selected">selected</xsl:attribute>
- </xsl:if>
- <xsl:value-of select="key('i18n','unlimited')"/>
- </option>
- </xsl:if>
- <xsl:apply-templates select="eat:allowablePageSize"></xsl:apply-templates>
- </select>
- <input type="hidden" name="pageStart" value="0"/>
- <input type="hidden" name="displaySection"
- value="{eat:ui-index/eat:index-section[@selected='true']/@index-key}"/>
- </form>
- </div>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="eat:index-section" mode="href">
- <xsl:text>&index.displaySection=</xsl:text>
- <xsl:value-of select="@index-key"/>
- <xsl:if test="../../@pageSize">
- <xsl:text>&index.pageSize=</xsl:text>
- <xsl:value-of select="../../@pageSize"/>
- </xsl:if>
- <xsl:if test="../../@pageStart > 0">
- <xsl:text>&index.pageStart=</xsl:text>
- <xsl:value-of select="../../@pageStart"/>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="eat:index-section" mode="href-direct">
- <xsl:text>&displaySection=</xsl:text>
- <xsl:value-of select="@index-key"/>
- <xsl:if test="../../@pageSize">
- <xsl:text>&pageSize=</xsl:text>
- <xsl:value-of select="../../@pageSize"/>
- </xsl:if>
- <xsl:if test="../../@pageStart > 0">
- <xsl:text>&pageStart=</xsl:text>
- <xsl:value-of select="../../@pageStart"/>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="eat:recipe-criteria" mode="href">
- <xsl:text>&criteria.mode=</xsl:text>
- <xsl:value-of select="@mode"/>
- </xsl:template>
-
- <!--
- Search for recipes form template
- -->
- <xsl:template match="xweb:x-data" mode="search-for-recipes">
- <xsl:variable name="rCriteria" select="xweb:x-model/eat:search-results/eat:recipe-criteria"/>
- <form method="post" action="{$web-context}{$ctx/xweb:path}">
- <table class="form">
- <tr>
- <th>
- <xsl:value-of select="key('i18n','name.displayName')"/>
- </th>
- <td colspan="3">
- <input type="text" name="criteria.name" value="{$rCriteria/eat:name}"/>
- </td>
- </tr>
- <tr>
- <th/>
- <td>
- <input type="submit" value="{key('i18n','search.displayName')}"/>
- <xsl:text> </xsl:text>
- <input type="submit" name="_cancel" value="{key('i18n','cancel.displayName')}"/>
- </td>
- </tr>
- </table>
- <input type="hidden" name="mode" value="{xweb:x-model/eat:search-results/@mode}"/>
- </form>
- <script type="text/javascript" xml:space="preserve">
- document.forms[0].elements['criteria.name'].focus();
- </script>
- <xsl:if test="xweb:x-model/eat:search-results/eat:recipe-criteria">
- <xsl:apply-templates select="xweb:x-model/eat:search-results" mode="search-for-recipes"/>
- </xsl:if>
- </xsl:template>
- <xsl:template match="eat:search-results" mode="search-for-recipes">
- <hr />
- <xsl:choose>
- <xsl:when test="@totalResults > 0">
- <table class="recipe-index">
- <tbody>
- <tr>
- <th>
- <xsl:value-of select="key('i18n','search.results.results')"/>
- <xsl:text>: </xsl:text>
- <xsl:value-of select="@totalResults"/>
- <xsl:text> </xsl:text>
- <xsl:choose>
- <xsl:when test="@totalResults > 1">
- <xsl:value-of select="key('i18n','search.results.match.plural')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="key('i18n','search.results.match')"/>
- </xsl:otherwise>
- </xsl:choose>
- </th>
- </tr>
- </tbody>
- </table>
- <ol>
- <xsl:apply-templates select="eat:recipe" mode="search-for-recipes"/>
- </ol>
- </xsl:when>
- <xsl:otherwise>
- <p>
- <xsl:value-of select="key('i18n','search.noresults')"/>
- </p>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="eat:recipe" mode="search-for-recipes">
- <li>
- <a>
- <xsl:attribute name="href">
- <xsl:text>javascript:chooseRecipe(</xsl:text>
- <xsl:value-of select="@recipeId"/>
- <xsl:text>,'</xsl:text>
- <xsl:call-template name="single-quote-string">
- <xsl:with-param name="output-string" select="eat:name"/>
- </xsl:call-template>
- <xsl:text>')</xsl:text>
- </xsl:attribute>
- <xsl:value-of select="eat:name"/>
- </a>
- <p>
- <xsl:call-template name="truncate-at-word">
- <xsl:with-param name="text" select="eat:excerpt"/>
- <xsl:with-param name="max-length" select="100"/>
- </xsl:call-template>
- </p>
- </li>
- </xsl:template>
-
-
- </xsl:stylesheet>
|