| 1 | <?xml version="1.0" encoding="utf-8"?> |
|---|
| 2 | <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp " "> ]> |
|---|
| 3 | <xsl:stylesheet |
|---|
| 4 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|---|
| 5 | version="1.0"> |
|---|
| 6 | |
|---|
| 7 | <xsl:output method="html" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/> |
|---|
| 8 | <xsl:decimal-format name="GBP" decimal-separator="." grouping-separator=","/> |
|---|
| 9 | |
|---|
| 10 | <!-- Match the root of the XML render the three views --> |
|---|
| 11 | <xsl:template match="/"> |
|---|
| 12 | <xsl:choose> |
|---|
| 13 | <xsl:when test="$view='html'"> |
|---|
| 14 | <!-- Should return HTML as you see fit --> |
|---|
| 15 | <xsl:call-template name="html"/> |
|---|
| 16 | </xsl:when> |
|---|
| 17 | <xsl:when test="$view='images'"> |
|---|
| 18 | <!-- |
|---|
| 19 | Should return a list of images to embed in the following format: |
|---|
| 20 | |
|---|
| 21 | <images> |
|---|
| 22 | <img id="myimage" src="/local/path/to/image"/> |
|---|
| 23 | </images> |
|---|
| 24 | |
|---|
| 25 | Where "myimage" is references in your HTML image as <img src="cid:myimage" /> |
|---|
| 26 | --> |
|---|
| 27 | <xsl:call-template name="images"/> |
|---|
| 28 | </xsl:when> |
|---|
| 29 | <xsl:otherwise> |
|---|
| 30 | <!-- The plain text portion of the email --> |
|---|
| 31 | <xsl:call-template name="plain"/> |
|---|
| 32 | </xsl:otherwise> |
|---|
| 33 | </xsl:choose> |
|---|
| 34 | </xsl:template> |
|---|
| 35 | |
|---|
| 36 | <!-- Simple (cop-out) implementation of a plain text message --> |
|---|
| 37 | <xsl:template name="plain"> |
|---|
| 38 | <xsl:text> |
|---|
| 39 | This message contains HTML content for a rich display. |
|---|
| 40 | |
|---|
| 41 | Please enable the HTML view or use an HTML compatible email client. |
|---|
| 42 | </xsl:text> |
|---|
| 43 | </xsl:template> |
|---|
| 44 | |
|---|
| 45 | <!-- This HTML version does not contain any images --> |
|---|
| 46 | <xsl:template name="images"/> |
|---|
| 47 | |
|---|
| 48 | <xsl:template name="html"> |
|---|
| 49 | <!-- The root element needs to be created with xsl:element to prevent namespaces sneaking in. --> |
|---|
| 50 | <xsl:element name="html"> |
|---|
| 51 | <head> |
|---|
| 52 | <title>Ticket Summary for <xsl:value-of select="/clientsplugin/client/name"/></title> |
|---|
| 53 | <style type="text/css"> |
|---|
| 54 | body { |
|---|
| 55 | background: #f3f3f3; |
|---|
| 56 | } |
|---|
| 57 | .ticket { |
|---|
| 58 | background: #eee; |
|---|
| 59 | padding: 0; |
|---|
| 60 | margin: 2px; |
|---|
| 61 | margin-bottom: 20px; |
|---|
| 62 | border: 1px solid #222; |
|---|
| 63 | } |
|---|
| 64 | .id { |
|---|
| 65 | float: left; |
|---|
| 66 | margin: 0; |
|---|
| 67 | padding: 5px; |
|---|
| 68 | text-align: center; |
|---|
| 69 | background: #222; |
|---|
| 70 | color: #eee; |
|---|
| 71 | width: 5em; |
|---|
| 72 | font-weight: bold; |
|---|
| 73 | } |
|---|
| 74 | .summary { |
|---|
| 75 | float: left; |
|---|
| 76 | margin: 0 0 0 1em; |
|---|
| 77 | padding: 5px; |
|---|
| 78 | font-style: italic; |
|---|
| 79 | } |
|---|
| 80 | .description { |
|---|
| 81 | clear: both; |
|---|
| 82 | margin: 2em; |
|---|
| 83 | margin-top: 3em; |
|---|
| 84 | padding: 1em; |
|---|
| 85 | border: 1px solid #222; |
|---|
| 86 | background: #fff; |
|---|
| 87 | } |
|---|
| 88 | .due { |
|---|
| 89 | clear: both; |
|---|
| 90 | float: right; |
|---|
| 91 | margin: 4px; |
|---|
| 92 | padding: 0; |
|---|
| 93 | font-variant: small-caps; |
|---|
| 94 | } |
|---|
| 95 | .due:before { |
|---|
| 96 | content: "Expected Delivery Date: "; |
|---|
| 97 | } |
|---|
| 98 | .fin { |
|---|
| 99 | clear: both; |
|---|
| 100 | } |
|---|
| 101 | </style> |
|---|
| 102 | </head> |
|---|
| 103 | <body> |
|---|
| 104 | <h1>Ticket Summary for <xsl:value-of select="/clientsplugin/client/name"/></h1> |
|---|
| 105 | <xsl:choose> |
|---|
| 106 | <xsl:when test="/clientsplugin/changes/ticket"> |
|---|
| 107 | <xsl:for-each select="/clientsplugin/changes/ticket"> |
|---|
| 108 | <div class="ticket"> |
|---|
| 109 | <div class="id">#<xsl:value-of select="id"/></div> |
|---|
| 110 | <div class="summary"><xsl:value-of select="summary"/></div> |
|---|
| 111 | <div class="description"> |
|---|
| 112 | <xsl:if test="description!=''"> |
|---|
| 113 | <xsl:copy-of select="description"/> |
|---|
| 114 | </xsl:if> |
|---|
| 115 | <xsl:for-each select="changelog/detail"> |
|---|
| 116 | <hr /> |
|---|
| 117 | <xsl:copy-of select="."/> |
|---|
| 118 | </xsl:for-each> |
|---|
| 119 | </div> |
|---|
| 120 | <div class="due"><xsl:value-of select="due"/></div> |
|---|
| 121 | <div class="fin"></div> |
|---|
| 122 | </div> |
|---|
| 123 | </xsl:for-each> |
|---|
| 124 | </xsl:when> |
|---|
| 125 | <xsl:otherwise> |
|---|
| 126 | <p>You do not currently have any active tickets</p> |
|---|
| 127 | </xsl:otherwise> |
|---|
| 128 | </xsl:choose> |
|---|
| 129 | </body> |
|---|
| 130 | </xsl:element> |
|---|
| 131 | </xsl:template> |
|---|
| 132 | </xsl:stylesheet> |
|---|