<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ou="http://omniupdate.com/XSL/Variables"
xmlns:ouc="http://omniupdate.com/XSL/Variables"
exclude-result-prefixes="ou xsl ouc">

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

	<xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes" />

	<xsl:param name="colSizeNames" select="('twelve','six','four','three','two','two')" />

	<xsl:template name="footer-display">
		<xsl:param name="context" select="." /> <!-- This allows us to set the context item for all of the XPATHs used later. This is so we can use this footer from an external staging page. -->
		<table class="footer row">
			<tr>
				<td>
					<!-- Footer Logo -->
					<table class="row">
						<tr>
							<td class="center" aligner="center">
								<table class="container">
									<tr>
										<td class="wrapper last">
											<table class="twelve columns">
												<tr>
													<td>
														<p class="center"><a href="{$context/ouc:properties/parameter[@name='logo-link']}"><img class="center" src="{$context/ouc:properties/parameter[@name='footer-logo']}" alt="Footer Logo" /></a></p>
													</td>
													<td class="expander">&#160;</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
					<!-- END Footer logo -->
					<table class="row">
						<tr>
							<td class="center" aligner="center">
								<table class="container">
									<tr>
										<td class="wrapper last">
											<!-- Social Media Text -->
											<xsl:if test="$context/ouc:properties/parameter[@name='social-text'] != ''">
												<table class="twelve columns">
													<tr>
														<td>
															<h4 class="center"><xsl:value-of select="$context/ouc:properties/parameter[@name='social-text']"/></h4>
														</td>
														<td class="expander">&#160;</td>
													</tr>
												</table>
											</xsl:if>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
					<!-- END Social Media Text -->

					<!-- Social Media Icons -->
					<xsl:for-each-group select="$context/ouc:properties[@label='social-media']/parameter[. != '']" group-by="position() lt 7">
						<xsl:variable name="colSize" select="$colSizeNames[count(current-group())]" />
						<table class="row">
							<tr>
								<td class="center" aligner="center">
									<table class="container">
										<tr>
											<td class="wrapper{if(position() = last()) then ' last' else ''}">
												<table class="twelve columns">
													<tr>
														<xsl:for-each select="current-group()">
															<td class="{$colSize} sub-columns{if(position() = last()) then ' last' else ''}">
																<p class="center">
																	<a href="{@prompt/..}"><img class="center" src="{concat($ou:httproot, '_resources/images/email/icons/', substring-before(@name,'-link'), '.jpg')}" alt="{@prompt}" /></a>
																</p>
															</td>
														</xsl:for-each>
														<td class="expander">&#160;</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
						</table>
					</xsl:for-each-group>
					<!-- END Social Media Icons -->

					<!-- Copyright and links -->
					<table class="row">
						<tr>
							<td class="center" aligner="center">
								<table class="container">
									<tr>
										<td class="wrapper last">
											<table class="twelve columns">
												<tr>
													<td>
														<p style="text-align:center;"><xsl:value-of select="$context/ouc:properties/parameter[@name='copyright']"/> | <a href="{$context/ouc:properties/parameter[@name='terms']}">Terms of Use</a> | <a href="{$context/ouc:properties/parameter[@name='privacy']}">Privacy Policy</a> | <unsubscribe>Unsubscribe</unsubscribe></p>
													</td>
													<td class="expander">&#160;</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>
								<!-- END Copyright and links -->
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template match="/document">
		<!--For the page preview only, basic properties file set up-->
		<xsl:choose>
			<xsl:when test="$ou:action != 'pub'">
				<html lang="en">

					<head>
						<link href="//netdna.bootstrapcdn.com/bootswatch/3.1.0/cerulean/bootstrap.min.css" rel="stylesheet"/>
						<style>
							body{ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
							.ox-regioneditbutton { display: none; }
						</style>
					</head>

					<body id="properties">

						<div class="container">
							<h1>Footer Properties</h1>
							To edit the following section footer propeties, please check out this page and go to the Page Properties screen.<br/>
							Changes will take effect immmediately in OUCampus - this file does not need to be published. <br/>
							However, the PCF files in this folder must be republished for changes to appear on '<xsl:value-of select="concat($domain,$dirname)"/>'.<br/>
							<br/>

							<h2>Properties for the Footer Template</h2>
							<!--Loop through both the config label, and the social-media label for the page preview-->
							<dl>
								<xsl:for-each select="ouc:properties/parameter">
									<dt><xsl:value-of select="@prompt"/></dt>
									<dd>
										<xsl:choose>
											<xsl:when test=". = ''">
												<p style="color:red;"><strong>This value is empty and the <xsl:value-of select="@prompt"/> will not display.</strong></p>
											</xsl:when>
											<xsl:otherwise>
												<p><xsl:value-of select="."/></p>
											</xsl:otherwise>
										</xsl:choose>
									</dd>
									<br/>
								</xsl:for-each>
							</dl>
						</div>

						<!-- To disable OU Campus from going straight to WYSIWYG when in edit mode. -->
						<div style="display:none;"><ouc:div label="fake" group="fake" button="hide"/></div>
					</body>
				</html>
			</xsl:when>
			<xsl:otherwise>
				<!--Displays the footer-->
				<xsl:call-template name="footer-display" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
