<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY amp   "&#38;">
<!ENTITY copy   "&#169;">
<!ENTITY gt   "&#62;">
<!ENTITY hellip "&#8230;">
<!ENTITY laquo  "&#171;">
<!ENTITY lsaquo   "&#8249;">
<!ENTITY lsquo   "&#8216;">
<!ENTITY lt   "&#60;">
<!ENTITY nbsp   "&#160;">
<!ENTITY quot   "&#34;">
<!ENTITY raquo  "&#187;">
<!ENTITY rsaquo   "&#8250;">
<!ENTITY rsquo   "&#8217;">
]>
<!--

-->
<xsl:stylesheet version="3.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns:ou="http://omniupdate.com/XSL/Variables"
	xmlns:fn="http://omniupdate.com/XSL/Functions"
	xmlns:ouc="http://omniupdate.com/XSL/Variables"
	exclude-result-prefixes="xs ou fn ouc"
	expand-text="yes">

	<xsl:template match="news-events" expand-text="yes">
		<xsl:variable name="mode" select="if (not(@mode)) then'newslist' else @mode" />

		<xsl:if test="@heading != ''">
			<h3>{@heading}</h3>
		</xsl:if>

		<xsl:call-template name="news-events">
			<xsl:with-param name="rss-feed" select="@rss-feed" />
			<xsl:with-param name="count" select="@count" />
			<xsl:with-param name="tags" select="@tags" />
			<xsl:with-param name="mode" select="$mode" />
		</xsl:call-template>

	</xsl:template>

	<xsl:template name="news-events" expand-text="no">
		<xsl:param name="script" select="'/_resources/php/news-events.php'" />
		<xsl:param name="rss-feed" select="''" />
		<xsl:param name="count" select="'3'" />
		<xsl:param name="mode" select="'newslist'" />
		<xsl:param name="tags" select="ou:get-tags-string($ou:stagingpath)" />

		<xsl:variable name="feed" select="replace($rss-feed, $domain, '')" />
		<xsl:variable name="request" select="concat($domain, $script, '?feed=', $feed, '&amp;count=', $count, '&amp;mode=', $mode, '&amp;cat=', $tags)" />

		<xsl:choose>
			<xsl:when test="$feed != '' and doc-available(concat($domain, $feed))">
				<xsl:choose>
					<xsl:when test="$is-pub">

						<xsl:processing-instruction name="php">
							require_once($_SERVER['DOCUMENT_ROOT'] . "<xsl:value-of select="$script" />");
						?</xsl:processing-instruction>

						<xsl:choose>
							<xsl:when test="$mode = 'newshome'">

								<xsl:processing-instruction name="php">
									display_news_home("<xsl:value-of select="$feed" />", <xsl:value-of select="$count" />, "<xsl:value-of select="$tags" />");
								?</xsl:processing-instruction>

							</xsl:when>
							<xsl:when test="$mode = 'eventhome'">

								<xsl:processing-instruction name="php">
									display_event_home("<xsl:value-of select="$feed" />", <xsl:value-of select="$count" />, "<xsl:value-of select="$tags" />");
								?</xsl:processing-instruction>

							</xsl:when>
							<xsl:when test="$mode = 'newslisting'">

								<xsl:processing-instruction name="php">
									if ( !isset($cat) )
			                			$cat = isset($_GET['cat'])? $_GET['cat'] : "<xsl:value-of select="$tags" />";

									display_news_listing("<xsl:value-of select="$feed" />", <xsl:value-of select="$count" />, $cat);
								?</xsl:processing-instruction>

							</xsl:when>
							<xsl:when test="$mode = 'eventlisting'">

								<xsl:processing-instruction name="php">
									if ( !isset($cat) )
				            			$cat = isset($_GET['cat'])? $_GET['cat'] : "<xsl:value-of select="$tags" />";

									display_event_listing("<xsl:value-of select="$feed" />", <xsl:value-of select="$count" />, $cat);
								?</xsl:processing-instruction>

							</xsl:when>
							<xsl:when test="$mode = 'newslist' or $mode = 'eventlist'">

								<xsl:processing-instruction name="php">
									display_list("<xsl:value-of select="$feed" />", <xsl:value-of select="$count" />, "<xsl:value-of select="$tags" />");
								?</xsl:processing-instruction>

							</xsl:when>
							<xsl:otherwise/>
						</xsl:choose>

					</xsl:when>
					<xsl:otherwise>

						<xsl:if test="unparsed-text-available($request)">
							<xsl:value-of disable-output-escaping="yes" select="unparsed-text($request)" />
						</xsl:if>

					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>

				<xsl:if test="$is-edt">

					<div class="alert alert-warning">Invalid feed specified: <a target="_blank" href="{$feed}"><xsl:value-of select="concat($domain, $feed)" /></a></div>

				</xsl:if>

			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


</xsl:stylesheet>
