<?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;">
]>
<!-- 
Implementations Skeleton - 01/10/2017

STANDARD TEMPLATE MATCHES
Identity templates that recursively copies all content, or applies other applicable templates.

Contributors: A. Schwenkenberg
Last Updated: 10/2017
-->
<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">
	
    <!-- Identity Matches -->
    <!-- The following mode will match all items except processing instructions, copies them, then processes any children. -->
    <xsl:mode on-no-match="shallow-copy" />
    <!-- match the pcf-sheet to make the editable region function -->
    <xsl:template match="processing-instruction('pcf-stylesheet')" mode="#all" />

    <!-- MISC -->
    <!-- don't output ouc tags on publish. -->
    <xsl:template match="ouc:*[$ou:action !='edt']" mode="#all">
        <xsl:apply-templates mode="#current"/>
    </xsl:template>  
          
    <!-- Visual warning for broken dependencies tags -->
    <xsl:template match="a[contains(@href,'*** Broken')]" mode="#all">
        <a href="{@href}" style="color: red;"><xsl:value-of select="."/></a> <span style="color: red;">[BROKEN LINK]</span>
    </xsl:template>
    
    <!-- The following template matches processing instructions, outputs the proper syntax with the code escaped properly. -->
    <!-- Remove closing '?' mark if not HTML5 output. -->
    <xsl:template match="processing-instruction('php')" mode="#all">
        <xsl:processing-instruction name="php">
			<xsl:value-of select="." disable-output-escaping="yes" />
		?</xsl:processing-instruction>
    </xsl:template>  
	
	<!-- Button -->
	<xsl:template match="ouc:div[not($ou:action='edt')]" mode="button"/>
	<xsl:template match="ouc:div[$ou:action='edt']" mode="button">
		<ouc:div>
			<xsl:apply-templates select="attribute()|ouc:editor"/>
		</ouc:div>
	</xsl:template>
	
	<xsl:template match="ouc:div" mode="nobutton">
		<xsl:apply-templates select="node()"/>
	</xsl:template>
	
	<!-- News / Events match -->
	<xsl:template match="news-events" mode="#all">
		<section id="news-events" class="gray">
			<div class="container">
				<div class="row">					
					<xsl:if test="string-length(normalize-space(@events-title)) gt 1">
						<div>
							<xsl:attribute name="class" select="if (string-length(normalize-space(@news-title)) lt 1) then 'col-xs-12 col-md-12 events-wrapper' else 'col-xs-12 col-md-6 events-wrapper'"/>
							<header>
								<h2><xsl:value-of select="@events-title"/></h2>
								<a class="learn-more white" aria-label="View All Events" href="{@events-link}"><xsl:value-of select="@events-link-text"/></a>
							</header>
							<xsl:choose>
								<xsl:when test="$is-pub">
									<!-- script call / parsing -->
									<xsl:text disable-output-escaping="yes" expand-text="no">&lt;%</xsl:text>
										Response.Write(OUC.WnlDisplayMethods.displayPageEvents("<xsl:value-of select="@events-feed"/>", "", <xsl:value-of select="@events-quantity"/>))
									<xsl:text disable-output-escaping="yes" expand-text="no">%&gt;</xsl:text>								
								</xsl:when>
								<xsl:otherwise>
									<div class="event row">
										<div class="date col-xs-3">
											<h3>Month <span>XX</span></h3>
										</div>
										<div class="summary col-xs-9">
											<h3>Column</h3>
											<p>Feed: <a href="{@events-feed}" class="click-more">feed url</a></p>
										</div>
									</div>
								</xsl:otherwise>
							</xsl:choose>									
						</div>
					</xsl:if>					
					<!--<div class="col-md-2 vertical-line"></div>-->
					<xsl:if test="string-length(normalize-space(@news-title)) gt 1">						
						<div>
							<xsl:attribute name="class" select="if (string-length(normalize-space(@events-title)) lt 1) then 'col-xs-12 col-md-12 news-wrapper' else 'col-xs-12 col-md-6 news-wrapper'"/>
							<header>
								<h2><xsl:value-of select="@news-title"/></h2>
								<a class="learn-more white" aria-label="View All News" href="{@news-link}"><xsl:value-of select="@news-link-text"/></a>
							</header>
							<xsl:choose>
							<xsl:when test="$is-pub">
								<!-- script call / parsing -->
								<xsl:text disable-output-escaping="yes" expand-text="no">&lt;%</xsl:text>
									Response.Write(OUC.WnlDisplayMethods.displayPageNews("<xsl:value-of select="@news-feed"/>", "", <xsl:value-of select="@news-quantity"/>))
								<xsl:text disable-output-escaping="yes" expand-text="no">%&gt;</xsl:text>	
							</xsl:when>
							<xsl:otherwise>
								<article class="news-story row">
									<div class="img-container col-xs-4">
										<img src="https://www.ttuhsc.edu/_resources/images/news-thumb.jpg" alt="News Article Photo"/>
									</div>
									<div class="summary col-xs-8">
										<h3>Column</h3>
										<p>Feed: <a href="{@news-feed}" class="click-more">feed url</a></p>
									</div>
								</article>		
							</xsl:otherwise>
						</xsl:choose>									
						</div>
					</xsl:if>									
				</div>
			</div>
		</section>
	</xsl:template>
	
	<!-- matches the DMProfile configuration table and renders out an asp.net tag -->
	<xsl:template match="table[@id='dmprofile']" priority="1">
		<xsl:choose>
			<xsl:when test="$ou:action = 'pub'">
				<xsl:text disable-output-escaping="yes">&lt;form runat="server" id="form1"&gt; </xsl:text>
				<xsl:text disable-output-escaping="yes">&lt;HSC:DMProfile runat="server" </xsl:text>
				<xsl:for-each select="tbody/tr">
					<xsl:if test="position() &gt; 0">						
						<xsl:if test="string-length(normalize-space(td[2])) &gt; 0">
							<xsl:value-of select="td[1]" />="<xsl:value-of select="normalize-space(td[2])"/>"
						</xsl:if>
					</xsl:if>
				</xsl:for-each>
				<xsl:text disable-output-escaping="yes">/&gt;</xsl:text>
				<xsl:text disable-output-escaping="yes">&lt;/form&gt; </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<h2>DM Profile are active for this page.</h2>
				<xsl:copy-of select="." />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
</xsl:stylesheet>