<?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="ou xsl xs fn ouc"
				expand-text="yes">

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

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

	<xsl:template name="page-content">
		
		<xsl:variable name="search-root" select="if(ou:pcf-param('search-root') != '') then ou:pcf-param('search-root') else $dirname" />
		
		<xsl:variable name="filters">
			<!-- location filter is used so that only event posts that are located in a given folder and its subfolders are returned -->
			<xsl:text>[starts-with(@href,'{replace($search-root, '/[^/]+$', '/')}')]</xsl:text>
			<xsl:if test="string-length(ou:pcf-param('post-year'))=4">
				<xsl:text>[contains(date/text(), '{ou:pcf-param('post-year')}')]</xsl:text>
			</xsl:if>
			<xsl:if test="ou:pcf-param('post-location')!=''">
				<xsl:text>[location/text()='{ou:pcf-param('post-location')}']</xsl:text>
			</xsl:if>

			<xsl:if test="$tags!=''">
				<xsl:variable name="logical-operator" select="if(ou:pcf-param('filter-option') = 'all') then ' and ' else ' or '" />

				<xsl:text>[</xsl:text>
				<xsl:for-each select="tokenize($tags, ',')">
					<xsl:choose>
						<xsl:when test="contains(., '''')">
							<xsl:value-of select="'tags/tag=&quot;' || .=>normalize-space()=>replace('&quot;', '') || '&quot;'" />
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="'tags/tag=''' || normalize-space(.) || ''''" />
						</xsl:otherwise>
					</xsl:choose>
					<xsl:if test="position() != last()">
						<xsl:value-of select="$logical-operator" />
					</xsl:if>
				</xsl:for-each>
				<xsl:text>]</xsl:text>
			</xsl:if>

		</xsl:variable>
		
		<!-- see breadcrumbs xsl -->
		<div id="breadcrumb">
			<xsl:call-template name="breadcrumb">
				<xsl:with-param name="path" select="$ou:dirname"/>								
			</xsl:call-template>
		</div>

		<!-- <div id="page-title"> -->
		<!--BeginEditable Name="Page Title" Description="Users can edit."-->		
		<!-- <h1><xsl:value-of select="$page-title"/></h1> -->
		<!--EndEditable Name="Page Title"-->
		<!-- </div> -->

		<!-- Added for Ticket #36027 -->
		<div id="{div/@id}">
			<h1><xsl:value-of select='ouc:properties[@label="config"]/parameter[@name="heading"]'/></h1>
		</div>			


		<!-- If Sidebar is enabled - Edited sidebar editable region per ticket #41335 - OU Support-->
		<!-- 		<xsl:if test="count(ouc:div[@label='sidebar']/child::*) > 1 and ouc:div[@label='sidebar']/text() !='' and $sidebar = 'true'"> -->
		<xsl:if test="$sidebar = 'true'">
			<div id="sidebar-show">
				Show/Hide information in sidebar
			</div>

			<div id="sidebar">
				<!--BeginEditable Name="Sidebar" Description="Users can add links and other content to sidebar."-->
				<xsl:apply-templates select="ouc:div[@label='sidebar']" />	
				<!--EndEditable Name="Sidebar"-->
			</div>
		</xsl:if>



		<main>
			<!--<div id="content-wrap">
<xsl:apply-templates select="ouc:div[@label='maincontent']" />	
</div>-->
			<!-- begin edit -->
			<xsl:choose>
				<xsl:when test="$sidebar = 'true'">
					<div id="content-wrap-sidebar">
						<xsl:call-template name="dmc">
						<xsl:with-param name="options">
							<datasource>{ou:pcf-param('dsn')}</datasource>
							<xpath>item{$filters}</xpath>
							<type>listing</type>
							<items_per_page>{ou:pcf-param('items-per-page')}</items_per_page>
							<querystring_control>true</querystring_control>
							<search_columns>title,description,location,searchtags</search_columns>
							<sort>date(date) desc</sort>
							<form_filter_options>{ou:pcf-param('form-filter-options')}</form_filter_options>
						</xsl:with-param>

						<xsl:with-param name="script-name">events</xsl:with-param>
						<xsl:with-param name="debug" select="$dmc-debug" />
					</xsl:call-template>
						<xsl:apply-templates select="ouc:div[@label='maincontent']" />
					</div>
				</xsl:when>
				<xsl:otherwise>
					<div id="content-wrap">
						<xsl:call-template name="dmc">
						<xsl:with-param name="options">
							<datasource>{ou:pcf-param('dsn')}</datasource>
							<xpath>item{$filters}</xpath>
							<type>listing</type>
							<items_per_page>{ou:pcf-param('items-per-page')}</items_per_page>
							<querystring_control>true</querystring_control>
							<search_columns>title,description,location,searchtags</search_columns>
							<sort>date(date) desc</sort>
							<form_filter_options>{ou:pcf-param('form-filter-options')}</form_filter_options>
						</xsl:with-param>

						<xsl:with-param name="script-name">events</xsl:with-param>
						<xsl:with-param name="debug" select="$dmc-debug" />
					</xsl:call-template>
						<xsl:apply-templates select="ouc:div[@label='maincontent']" />
					</div>
				</xsl:otherwise>
			</xsl:choose>
			<!-- end edit -->
		</main>

		<div id="last-updated-bar">
			<!-- <script>
var date = new Date(document.lastModified)
document.writeln("Last Updated " + (date.getMonth() + 1) + "/" + date.getDate() + "/" + date.getFullYear())
</script> -->

			<!-- edited for ticket #36630 -->
			<p>Last Updated <xsl:value-of select="ou:dateFromDateTime($ou:modified,'/')" /></p>
		</div>

	</xsl:template>

</xsl:stylesheet>