<?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">
	
    <!-- imports -->
	<xsl:import href="tmpl/default-layout.xsl"/>
	<xsl:import href="tmpl/display-meal.xsl"/>
	
	<!-- layout variables -->
	<xsl:variable name="layout.global.nav.page" select="''"/>
	
	<!-- helper vars -->
	<xsl:variable name="meal" select="xweb:x-data/xweb:x-model/eat:ui/eat:meal"/>
	
	<xsl:template match="xweb:x-data" mode="page-title">
		<xsl:value-of select="$meal/eat:name"/>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="action-links">
		<xsl:if test="$acting-user/@userId = $meal/eat:owner/@userId or 
				$acting-user/../@admin = 'true'">
			<a href="{$web-context}/editMeal.do?mealId={$meal/@mealId}" 
					title="{key('i18n','link.meal.edit.title')}">
				<xsl:value-of select="key('i18n','link.meal.edit')"/>
			</a>
			<xsl:text> - </xsl:text>
			<a href="{$web-context}/deleteMeal.do?mealId={$meal/@mealId}" 
					title="{key('i18n','link.meal.delete.title')}">
				<xsl:value-of select="key('i18n','link.meal.delete')"/>
			</a>
			<xsl:text> - </xsl:text>
			<a href="{$web-context}/mealShoppingList.do?mealId={$meal/@mealId}" 
					title="{key('i18n','link.meal.shoppingList.title')}">
				<xsl:value-of select="key('i18n','link.meal.shoppingList')"/>
			</a>
		</xsl:if>
	</xsl:template>
	
	<xsl:template match="xweb:x-data" mode="page-body">
		<div class="return-nav">
			<a class="back" href="{$web-context}/meals.do">
				<xsl:value-of select="key('i18n','back.to')"/>
				<xsl:text> </xsl:text>
				<xsl:value-of select="key('i18n','link.meals')"/>
			</a>
		</div>

		<p><xsl:value-of select="key('i18n','view-meal.intro')" disable-output-escaping="yes"/></p>
		
		<xsl:apply-templates select="$meal" mode="display-internal"/>
	</xsl:template>

</xsl:stylesheet>