Skip to content

Instantly share code, notes, and snippets.

@JoshyPHP
Created August 17, 2013 21:19
Show Gist options
  • Save JoshyPHP/6258742 to your computer and use it in GitHub Desktop.
Save JoshyPHP/6258742 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" encoding="utf-8" indent="no"/>
<xsl:param name="L_CODE"/>
<xsl:param name="L_COLON"/>
<xsl:param name="L_IMAGE"/>
<xsl:param name="L_SELECT_ALL_CODE"/>
<xsl:param name="L_WROTE"/>
<xsl:param name="S_VIEWFLASH"/>
<xsl:param name="S_VIEWIMG"/>
<xsl:param name="S_VIEWSMILIES"/>
<xsl:param name="T_SMILIES_PATH"/>
<xsl:template match="p">
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="br">
<br/>
</xsl:template>
<xsl:template match="et|i|st"/>
<xsl:template match="B">
<span style="font-weight: bold">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="CODE">
<dl class="codebox">
<dt>
<xsl:value-of select="$L_CODE"/>
<xsl:value-of select="$L_COLON"/>
<xsl:text> </xsl:text>
<a href="#" onclick="selectCode(this); return false;">
<xsl:value-of select="$L_SELECT_ALL_CODE"/>
</a>
</dt>
<dd>
<code>
<xsl:apply-templates/>
</code>
</dd>
</dl>
</xsl:template>
<xsl:template match="COLOR">
<span style="color: {@color}">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="EMAIL">
<a href="mailto:{@email}">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="FLASH">
<a href="{@url}" class="postlink">
<xsl:value-of select="@url"/>
</a>
</xsl:template>
<xsl:template match="FLASH[$S_VIEWFLASH]">
<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0" width="{@width}" height="{@height}">
<param name="movie" value="{@url}"/>
<param name="play" value="false"/>
<param name="loop" value="false"/>
<param name="quality" value="high"/>
<param name="allowScriptAccess" value="never"/>
<param name="allowNetworking" value="internal"/>
<embed src="{@url}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="{@width}" height="{@height}" play="false" loop="false" quality="high" allowscriptaccess="never" allownetworking="internal"/>
</object>
</xsl:template>
<xsl:template match="FLASH[not($S_VIEWFLASH)]|IMG[not($S_VIEWIMG)]">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="I">
<span style="font-style: italic">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="IMG[$S_VIEWIMG]">
<img src="{@src}" alt="{$L_IMAGE}"/>
</xsl:template>
<xsl:template match="LIST">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="LIST[@type]">
<ul style="list-style-type: {@type}">
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="LIST[@type and contains('upperlowerdecim',substring(@type,1,5))]">
<ol style="list-style-type: {@type}">
<xsl:apply-templates/>
</ol>
</xsl:template>
<xsl:template match="LI">
<li>
<xsl:apply-templates/>
</li>
</xsl:template>
<xsl:template match="QUOTE[@author]">
<blockquote>
<div>
<cite>
<xsl:value-of select="@author"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$L_WROTE"/>
<xsl:value-of select="$L_COLON"/>
</cite>
<xsl:apply-templates/>
</div>
</blockquote>
</xsl:template>
<xsl:template match="QUOTE[not(@author)]">
<blockquote class="uncited">
<div>
<xsl:apply-templates/>
</div>
</blockquote>
</xsl:template>
<xsl:template match="SIZE">
<span style="font-size: {@size}%; line-height: 116%;">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="U">
<span style="text-decoration: underline">
<xsl:apply-templates/>
</span>
</xsl:template>
<xsl:template match="URL">
<a href="{@url}" class="postlink">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="MYEMAIL">
<a href="mailto:{@myemail}">
<xsl:apply-templates/>
</a>
</xsl:template>
<xsl:template match="E[not($S_VIEWSMILIES)]">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="E">
<xsl:choose>
<xsl:when test=".=':ugeek:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_ugeek.gif" alt=":ugeek:" title="Uber Geek"/>
</xsl:when>
<xsl:when test=".=':cry:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_cry.gif" alt=":cry:" title="Crying or Very Sad"/>
</xsl:when>
<xsl:when test=".=':oops:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed"/>
</xsl:when>
<xsl:when test=".=':razz:'or.=':-P'or.=':P'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_razz.gif" alt="{.}" title="Razz"/>
</xsl:when>
<xsl:when test=".=':mad:'or.=':-x'or.=':x'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_mad.gif" alt="{.}" title="Mad"/>
</xsl:when>
<xsl:when test=".=':evil:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_evil.gif" alt=":evil:" title="Evil or Very Mad"/>
</xsl:when>
<xsl:when test=".=':twisted:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_twisted.gif" alt=":twisted:" title="Twisted Evil"/>
</xsl:when>
<xsl:when test=".=':roll:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes"/>
</xsl:when>
<xsl:when test=".=':geek:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_geek.gif" alt=":geek:" title="Geek"/>
</xsl:when>
<xsl:when test=".=':mrgreen:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_mrgreen.gif" alt=":mrgreen:" title="Mr. Green"/>
</xsl:when>
<xsl:when test=".=':-|'or.=':|'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_neutral.gif" alt="{.}" title="Neutral"/>
</xsl:when>
<xsl:when test=".=':arrow:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_arrow.gif" alt=":arrow:" title="Arrow"/>
</xsl:when>
<xsl:when test=".=':idea:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_idea.gif" alt=":idea:" title="Idea"/>
</xsl:when>
<xsl:when test=".=':?:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_question.gif" alt=":?:" title="Question"/>
</xsl:when>
<xsl:when test=".=':!:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_exclaim.gif" alt=":!:" title="Exclamation"/>
</xsl:when>
<xsl:when test=".=':lol:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing"/>
</xsl:when>
<xsl:when test=".=':cool:'or.='8-)'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_cool.gif" alt="{.}" title="Cool"/>
</xsl:when>
<xsl:when test=".=':wink:'or.=';-)'or.=';)'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_wink.gif" alt="{.}" title="Wink"/>
</xsl:when>
<xsl:when test=".=':smile:'or.=':-)'or.=':)'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_smile.gif" alt="{.}" title="Smile"/>
</xsl:when>
<xsl:when test=".=':grin:'or.=':-D'or.=':D'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_biggrin.gif" alt="{.}" title="Very Happy"/>
</xsl:when>
<xsl:when test=".=':('or.=':-('or.=':sad:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_sad.gif" alt="{.}" title="Sad"/>
</xsl:when>
<xsl:when test=".=':???:'or.=':-?'or.=':?'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_confused.gif" alt="{.}" title="Confused"/>
</xsl:when>
<xsl:when test=".=':shock:'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_eek.gif" alt=":shock:" title="Shocked"/>
</xsl:when>
<xsl:when test=".=':eek:'or.=':-o'or.=':o'">
<img class="smilies" src="{$T_SMILIES_PATH}/icon_e_surprised.gif" alt="{.}" title="Surprised"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment