view-recipe.xsl 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <?xml version="1.0"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:eat="http://msqr.us/xsd/ieat"
  4. xmlns:xweb="http://msqr.us/xsd/jaxb-web"
  5. exclude-result-prefixes="eat xweb">
  6. <!-- imports -->
  7. <xsl:import href="tmpl/default-layout.xsl"/>
  8. <xsl:import href="tmpl/display-recipe.xsl"/>
  9. <!-- layout variables -->
  10. <xsl:variable name="layout.global.nav.page" select="'vew-recipe'"/>
  11. <!-- helper vars -->
  12. <xsl:variable name="index-section"
  13. select="xweb:x-data/xweb:x-model/eat:search-results/eat:ui-index/eat:index-section[@selected = 'true']"/>
  14. <xsl:variable name="recipe-criteria" select="xweb:x-data/xweb:x-model/eat:search-results/eat:recipe-criteria"/>
  15. <xsl:variable name="recipe" select="xweb:x-data/xweb:x-model/eat:search-results/eat:recipe"/>
  16. <xsl:template match="xweb:x-data" mode="page-title">
  17. <xsl:value-of select="$recipe/eat:name"/>
  18. </xsl:template>
  19. <xsl:template match="xweb:x-data" mode="page-head-content">
  20. <xsl:if test="$acting-user">
  21. <!-- include the rating JavaScript -->
  22. <script type="text/javascript" src="{$web-context}/js/jquery-1.3.2.js" xml:space="preserve"> </script>
  23. <script type="text/javascript" src="{$web-context}/js/jquery.ajaxQueue.js" xml:space="preserve"> </script>
  24. <script type="text/javascript" src="{$web-context}/js/xweb-locale.js" xml:space="preserve"> </script>
  25. <script type="text/javascript" src="{$web-context}/js/ieat-util.js" xml:space="preserve"> </script>
  26. <script type="text/javascript" src="{$web-context}/js/ratings.js"><xsl:text> </xsl:text></script>
  27. <script type="text/javascript" xml:space="preserve">
  28. <xsl:comment>
  29. var W3CDOM = (document.createElement &amp;&amp; document.getElementsByTagName);
  30. var STAR_SETS = new Array();
  31. function init() {
  32. if ( !W3CDOM ) {
  33. alert("Your browser does not support DOM: some features will not be available.");
  34. return;
  35. }
  36. popupWindows();
  37. STAR_SETS[0] = new StarSet('<xsl:value-of select="$web-context"/>/img/','<xsl:value-of
  38. select="$web-context"/>/setRating.do?recipeId=<xsl:value-of
  39. select="$recipe/@recipeId"/>&amp;rating=',0,<xsl:choose xml:space="default">
  40. <xsl:when test="$recipe/eat:rating[@userId=$acting-user/@userId]">
  41. <xsl:value-of select="$recipe/eat:rating[@userId=$acting-user/@userId]/@rating"/>
  42. </xsl:when>
  43. <xsl:otherwise>
  44. <xsl:text>0</xsl:text>
  45. </xsl:otherwise>
  46. </xsl:choose>,<xsl:value-of
  47. select="$recipe/@recipeId"/>);
  48. }
  49. window.onload = init;
  50. //</xsl:comment>
  51. </script>
  52. </xsl:if>
  53. </xsl:template>
  54. <xsl:template match="xweb:x-data" mode="action-links">
  55. <a title="{key('i18n','link.recipe.convertSystem.title')}">
  56. <xsl:attribute name="href">
  57. <xsl:value-of select="$web-context"/>
  58. <xsl:text>/convertRecipe.do?recipeId=</xsl:text>
  59. <xsl:value-of select="$recipe/@recipeId"/>
  60. <xsl:apply-templates select="$index-section" mode="href"/>
  61. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  62. </xsl:attribute>
  63. <xsl:value-of select="key('i18n','link.recipe.convertSystem')"/>
  64. </a>
  65. <xsl:text> - </xsl:text>
  66. <a title="{key('i18n','link.recipe.convertSize.title')}">
  67. <xsl:attribute name="href">
  68. <xsl:value-of select="$web-context"/>
  69. <xsl:text>/alterRecipe.do?recipeId=</xsl:text>
  70. <xsl:value-of select="$recipe/@recipeId"/>
  71. <xsl:apply-templates select="$index-section" mode="href"/>
  72. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  73. </xsl:attribute>
  74. <xsl:value-of select="key('i18n','link.recipe.convertSize')"/>
  75. </a>
  76. <xsl:text> - </xsl:text>
  77. <a title="{key('i18n','link.export.title')}">
  78. <xsl:attribute name="href">
  79. <xsl:value-of select="$web-context"/>
  80. <xsl:text>/exportRecipe.do?recipeId=</xsl:text>
  81. <xsl:value-of select="$recipe/@recipeId"/>
  82. <xsl:apply-templates select="$index-section" mode="href"/>
  83. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  84. </xsl:attribute>
  85. <xsl:value-of select="key('i18n','link.export')"/>
  86. </a>
  87. <xsl:if test="$acting-user">
  88. <xsl:text> - </xsl:text>
  89. <a title="{key('i18n','link.email.title')}">
  90. <xsl:attribute name="href">
  91. <xsl:value-of select="$web-context"/>
  92. <xsl:text>/emailRecipe.do?recipeId=</xsl:text>
  93. <xsl:value-of select="$recipe/@recipeId"/>
  94. <xsl:apply-templates select="$index-section" mode="href"/>
  95. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  96. </xsl:attribute>
  97. <xsl:value-of select="key('i18n','link.email')"/>
  98. </a>
  99. <xsl:text> - </xsl:text>
  100. <a href="{$web-context}/addRecipeToMeal.do?recipeId={$recipe/@recipeId}"
  101. title="{key('i18n','link.recipe.addToMeal.title')}">
  102. <xsl:value-of select="key('i18n','link.recipe.addToMeal')"/>
  103. </a>
  104. <xsl:if test="$acting-user/@userId = $recipe/eat:owner/@userId or
  105. $acting-user/../@admin = 'true'">
  106. <xsl:text> - </xsl:text>
  107. <a title="{key('i18n','link.recipe.edit.title')}">
  108. <xsl:attribute name="href">
  109. <xsl:value-of select="$web-context"/>
  110. <xsl:text>/editRecipe.do?recipeId=</xsl:text>
  111. <xsl:value-of select="$recipe/@recipeId"/>
  112. <xsl:apply-templates select="$index-section" mode="href"/>
  113. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  114. </xsl:attribute>
  115. <xsl:value-of select="key('i18n','link.recipe.edit')"/>
  116. </a>
  117. <xsl:text> - </xsl:text>
  118. <a title="{key('i18n','link.recipe.delete.title')}">
  119. <xsl:attribute name="href">
  120. <xsl:value-of select="$web-context"/>
  121. <xsl:text>/deleteRecipe.do?recipeId=</xsl:text>
  122. <xsl:value-of select="$recipe/@recipeId"/>
  123. <xsl:apply-templates select="$index-section" mode="href"/>
  124. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  125. </xsl:attribute>
  126. <xsl:value-of select="key('i18n','link.recipe.delete')"/>
  127. </a>
  128. </xsl:if>
  129. </xsl:if>
  130. </xsl:template>
  131. <xsl:template match="xweb:x-data" mode="action-links-2">
  132. <xsl:text> </xsl:text><!-- required so show up in output template -->
  133. <!-- Recipe comments link -->
  134. <xsl:if test="key('appenv','feature.comments') = 'true'">
  135. <a title="{key('i18n','link.recipe.comments.title')}">
  136. <xsl:attribute name="href">
  137. <xsl:value-of select="$web-context"/>
  138. <xsl:text>/recipeComments.do?recipeId=</xsl:text>
  139. <xsl:value-of select="$recipe/@recipeId"/>
  140. <xsl:apply-templates select="$index-section" mode="href"/>
  141. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  142. </xsl:attribute>
  143. <xsl:value-of select="key('i18n','link.recipe.comments')"/>
  144. </a>
  145. </xsl:if>
  146. <xsl:if test="$acting-user">
  147. <xsl:if test="key('appenv','feature.comments') = 'true'">
  148. <xsl:text> - </xsl:text>
  149. </xsl:if>
  150. <xsl:if test="key('appenv','feature.recipeimages') = 'true' and (
  151. $acting-user/@userId = $recipe/eat:owner/@userId or
  152. $acting-user/../@admin = 'true' )">
  153. <a title="{key('i18n','link.recipe.image.title')}">
  154. <xsl:attribute name="href">
  155. <xsl:value-of select="$web-context"/>
  156. <xsl:text>/editRecipeImage.do?recipeId=</xsl:text>
  157. <xsl:value-of select="$recipe/@recipeId"/>
  158. <xsl:apply-templates select="$index-section" mode="href"/>
  159. <xsl:apply-templates select="$recipe-criteria" mode="href"/>
  160. </xsl:attribute>
  161. <xsl:value-of select="key('i18n','link.recipe.image')"/>
  162. </a>
  163. <xsl:text> - </xsl:text>
  164. </xsl:if>
  165. <!-- Recipe rating widget -->
  166. <xsl:if test="count($recipe/eat:rating) &gt; 0">
  167. <span class="rating-overall">
  168. <!-- Display user average -->
  169. <xsl:variable name="tally" select="sum($recipe/eat:rating/@rating)"/>
  170. <xsl:variable name="cnt" select="count($recipe/eat:rating/@rating)"/>
  171. <xsl:text> (</xsl:text>
  172. <xsl:value-of select="format-number($tally div $cnt, '0.#')"/>
  173. <xsl:text> &#x2022; </xsl:text>
  174. <xsl:value-of select="$cnt"/>
  175. <xsl:text>)</xsl:text>
  176. </span>
  177. </xsl:if>
  178. <span class="rating-stars">
  179. <img class="star-rating" id="star.0.1" src="{$web-context}/img/star-off.png" alt="1" width="13" height="13" />
  180. <img class="star-rating" id="star.0.2" src="{$web-context}/img/star-off.png" alt="2" width="13" height="13" />
  181. <img class="star-rating" id="star.0.3" src="{$web-context}/img/star-off.png" alt="3" width="13" height="13" />
  182. <img class="star-rating" id="star.0.4" src="{$web-context}/img/star-off.png" alt="4" width="13" height="13" />
  183. <img class="star-rating" id="star.0.5" src="{$web-context}/img/star-off.png" alt="5" width="13" height="13" />
  184. </span>
  185. </xsl:if>
  186. </xsl:template>
  187. <xsl:template match="xweb:x-data" mode="page-body">
  188. <xsl:if test="$index-section">
  189. <div class="return-nav">
  190. <a class="back">
  191. <xsl:attribute name="href">
  192. <xsl:value-of select="$web-context"/>
  193. <xsl:text>/index.do?</xsl:text>
  194. <xsl:apply-templates select="$index-section" mode="href-direct"/>
  195. </xsl:attribute>
  196. <xsl:value-of select="key('i18n','back.to')"/>
  197. <xsl:text> </xsl:text>
  198. <span class="index-link">
  199. <xsl:value-of select="$index-section/@index-key"/>
  200. </span>
  201. </a>
  202. </div>
  203. </xsl:if>
  204. <xsl:if test="$recipe-criteria">
  205. <div class="return-nav">
  206. <a class="back">
  207. <xsl:attribute name="href">
  208. <xsl:value-of select="$web-context"/>
  209. <xsl:text>/search.do?</xsl:text>
  210. <xsl:apply-templates select="$recipe-criteria"
  211. mode="href"/>
  212. </xsl:attribute>
  213. <xsl:value-of select="key('i18n','back.to')"/>
  214. <xsl:text> </xsl:text>
  215. <xsl:value-of select="key('i18n','search.results')"/>
  216. </a>
  217. </div>
  218. </xsl:if>
  219. <div class="recipe-view">
  220. <xsl:apply-templates select="$recipe" mode="display-internal"/>
  221. </div>
  222. </xsl:template>
  223. </xsl:stylesheet>