<?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 - 08/24/2018

Interior XSL
Defines the basic interior page
-->

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

<xsl:import href="common.xsl"/>

<xsl:template name="template-headcode"/>
<xsl:template name="template-footcode"/>

<xsl:template name="page-content">
<xsl:param name="heading" select="normalize-space($page-heading)"/>
<xsl:param name="hero-src" select="ou:pcf-param('hero-image') => normalize-space()"/>

<xsl:if test="$hero-src != ''">
	<div class="hero has-image">
		<!-- section nav is in the hero on pages with a hero image -->
		<xsl:call-template name="mobile-sidebar"></xsl:call-template>
		<picture>
			<source media="(min-width:1024px)" srcset="/_resources/images/pattern-hero-lg.jpg"/>
			<source media="(min-width:700px)" srcset="/_resources/images/pattern-hero-md.jpg"/>
			<source srcset="/_resources/images/pattern-hero-sm.jpg"/>
			<img src="{$hero-src}" alt="hero image"/>
		</picture>
		
		<h1>{$heading}</h1>
	</div>
	<div class="content-wrapper">
		
		<xsl:call-template name="output-breadcrumbs" /> 
<!-- 		<xsl:call-template name="desktop-sidebar"/> -->
	
		
		<div class="container">
			
			<div class="news news--listing">
				
			
				<xsl:call-template name="news-list"/>
				
				<!--</section>-->
				
				<!-- <div class="pagination">
<a href="#" class="pagination__button pagination__prev disabled"><span class="visually-hidden">previous news list page</span></a>
<ul class="pagination__list">
  <li class="pagination__item"><a class="active" title="page 1" aria-current="true">1</a></li>
  <li class="pagination__item"><a href="#" title="page 2">2</a></li>
  <li class="pagination__item"><span class="separator">...</span></li>
  <li class="pagination__item"><a href="#" title="page 9">9</a></li>
  <li class="pagination__item"><a href="#" title="page 10">10</a></li>
</ul>
<a href="#" class="pagination__button pagination__next"><span class="visually-hidden">next news list page</span></a>
</div>-->
				
			</div>
			
			<xsl:apply-templates select="ouc:div[@label='maincontent']"/>
		</div>
	</div>
</xsl:if>
<xsl:if test="$hero-src = ''">
	
	<div class="page-header">
		<xsl:call-template name="mobile-sidebar" />
		<div class="hero no-image">
			<h1>{$heading}</h1>
			<img class="no-bg-image" src="/_resources/images/banner-image.jpg" alt=""/>
		</div>
		
	</div>
	<xsl:call-template name="output-breadcrumbs" /> 

	<div class="container">
		<div class="news news--listing">
			
			<!--<section class="news__list">-->
			<xsl:call-template name="news-list"/>
		</div>
		<xsl:apply-templates select="ouc:div[@label='maincontent']" />
	</div>
</xsl:if>
</xsl:template>

<xsl:template name="footer-top">
	<div class="container">
		
		<div class="footer-top">
			<!-- Footer w/o sock should still incluude back to top button -->
			<div class="footer-sock">
				<div class="section__header">
					<span>Pioneer Forward</span>
					<h2>Start Your Journey Today.</h2>
				</div>
				<div class="cta-list__holder">
					<ul class="cta-list">
						<li class="cta-list__item">
							<a class="cta cta--button" href="#">Contact</a>
						</li>
						<li class="cta-list__item">
							<a class="cta cta--button" href="#">Visit</a>
						</li>
						<li class="cta-list__item">
							<a class="cta cta--button" href="#">Apply</a>
						</li>
					</ul>
				</div>
				
			</div>
			<button class="go-to-top-button" type="button"><span>Back to Top</span></button>
		</div>
	</div>
	
</xsl:template>

<xsl:template name="news-list">
<xsl:param name="items-per-page" select="(ou:pcf-param('items-per-page') => number(), 10)[boolean(.)][1]"/>
<xsl:param name="filter-tags" select="ou:pcf-param('filter-tags') => normalize-space() => tokenize('\s*,\s*')"/>
<xsl:param name="filter-strength" select="ouc:pcf-param('filter-strength')"/>		
<xsl:variable name="filtering_tags" select="ouc:pcf-param('filter-strength')"/>
<!-- New Way with predicate function that uses one parameter -->
<!-- 		<xsl:variable name="logical-operator" select="
if (ou:pcf-param('filter-strength') = 'and') then
true()
else
false()"/>

<xsl:variable name="filter-predicate" select="ou:get-filter-predicate(ou:pcf-param('filter-tags'), 'category', $logical-operator, false())"/>


<xsl:variable name="xpath">
<xsl:text>items/item</xsl:text>
<xsl:apply-templates select="$filter-predicate"/>
</xsl:variable> -->

<!-- New Way with Predicate that uses multiple parameters --> 
<xsl:variable name="logical-operator" select="
	if (ou:pcf-param('filter-strength') = 'and') then
	true()
	else
	false()"/>
<xsl:variable name="filter-predicate" select="ou:get-filter-predicate-multi(ou:pcf-param('filter-tags'), 'tags/tag', $logical-operator, false())"/>
<xsl:variable name="dept-predicate" select="ou:get-filter-predicate-multi(ou:pcf-param('department'), 'department', false(), false())"/>
<xsl:variable name="year-predicate" select="ou:get-filter-predicate-multi(ou:pcf-param('year-filter'), 'year/year', false(), false())"/>
<xsl:variable name="xpath">
	<xsl:text>items/item</xsl:text>
	<xsl:if test="$filter-predicate or $dept-predicate or $year-predicate">
		<xsl:text>[</xsl:text>
		<xsl:if test="$filter-predicate"> (<xsl:apply-templates select="$filter-predicate"/>) </xsl:if>
		<xsl:if test="$filter-predicate and $dept-predicate"> and </xsl:if>
		<xsl:if test="$dept-predicate"> (<xsl:apply-templates select="$dept-predicate"/>) </xsl:if>
		<xsl:if test="$filter-predicate and $year-predicate or $dept-predicate and $year-predicate"> and </xsl:if>
		<xsl:if test="$year-predicate"> (<xsl:apply-templates select="$year-predicate"/>) </xsl:if>
		<xsl:text>]</xsl:text>
	</xsl:if>
</xsl:variable>


<xsl:variable name="sort">date(item_date) desc</xsl:variable>

<xsl:call-template name="dmc">
	<xsl:with-param name="options">
		<datasource>news</datasource>
		<xpath>
			<xsl:text>items/item</xsl:text>
			<xsl:if test="$tags != ''">
				<xsl:text>[</xsl:text>
				<xsl:for-each select="tokenize($tags, ',')">
					<xsl:if test="position() != 1">
						{ou:pcf-param('tag-filter')}
					</xsl:if>
					<xsl:text>tags/tag='{.}'</xsl:text>
				</xsl:for-each>
				<xsl:text>]</xsl:text>
			</xsl:if>
		</xpath>
		<type>listing</type>
		<items_per_page>{ou:pcf-param('items-per-page')}</items_per_page>
		<sort>date(item_date) desc</sort>
		<querystring_control>true</querystring_control>
	</xsl:with-param>
	
	<xsl:with-param name="script-name">news</xsl:with-param>
	<xsl:with-param name="debug" select="true()"/>
</xsl:call-template>
</xsl:template>


</xsl:stylesheet>