﻿<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:rs='urn:schemas-microsoft-com:rowset'
 	 xmlns:z='#RowsetSchema'
	xmlns:date="http://www.ora.com/XSLTCookbook/NS/dates"
   xml:space="default"
	version="1.0">

	<xsl:param name="limit" select="100"/>
	<xsl:param name="titleLimit" select="30"/>
	<xsl:strip-space elements="true"/>
	<xsl:output omit-xml-declaration="yes" />

	<xsl:template match='//rs:data'>
		<div style='display: none;'>
			<h3 class="ms-standardheader ms-WPTitle'">
				<xsl:value-of select='title' disable-output-escaping='yes'  />
			</h3>
			<table border='0' cellpadding='0' cellspacing='0' width='650' style='border-bottom: 0px; border-left: 0px; padding-bottom: 0px; background-color: #ed1c24; margin: 0px; padding-left: 0px; width: 650px; padding-right: 0px; font-family: Arial, Helvetica, Sans-Serif; color: white; font-size: 12px; border-top: 0px; border-right: 0px; padding-top: 0px;'>
				<tbody>
					<xsl:apply-templates select='z:row'>
						<xsl:sort select="@ows_Datum" order="descending"/>
					</xsl:apply-templates>
					<xsl:variable name="rows" select="z:row" />
					<xsl:if test="count($rows) &lt; 1">
						<div style="padding:10px;">Er zijn geen kandidaat-nieuwsberichten aanwezig in deze categorie.</div>
					</xsl:if>
				</tbody>
			</table>
		</div>
	</xsl:template>

	<xsl:template match='z:row'>
		<xsl:if test="@ows_Nieuwsbriefopname = 'Kandidaat'">
			<TR style="height: 141px;">
				<xsl:variable name="rawUrl">
					<xsl:value-of select='substring-before(@ows_EncodedAbsUrl, "_.")'/>
				</xsl:variable>
				<td width="435" style="width: 435px;">
					<a style="color: white; font-size: 15px; font-weight: bold; text-decoration: none;">
						<xsl:attribute name="href">
							<xsl:choose>
								<xsl:when test="string-length(@ows_Alternatieve_x0020_Link) &gt; 0">
									<xsl:value-of select='substring-before(@ows_Alternatieve_x0020_Link, ",")'/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select='concat(substring($rawUrl, 1, string-length($rawUrl) - string-length(string(@ows_ID))), "DispFormWindexCC.aspx?ID=", @ows_ID, "&amp;Source=/")'/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:attribute>
						<img border="0" width="435" height="141" style="width: 435px; height: 141px;">
							<xsl:attribute name="src">
								<xsl:value-of select='substring-before(@ows_Afbeelding2, ",")'/>
							</xsl:attribute>
						</img>
					</a>
				</td>
				<td width="10" style="background-color: #ed1c24; width: 10px;">
					<img src="/_layouts/images/void.gif" width="10"/>
				</td>
				<TD width="205" style="background-color: #ed1c24; width: 205px;">
					<TABLE width="205" border="0" cellSpacing="0" cellPadding="0" style="border-bottom: 0px; border-left: 0px; padding-bottom: 0px; line-height: 17px; margin: 0px; padding-left: 0px; width: 205px; padding-right: 0px; font-family: Arial, Helvetica, Sans-Serif; color: white; font-size: 12px; border-top: 0px; border-right: 0px; padding-top: 0px;">
						<TBODY>
							<tr>
								<td width="205" style="border-bottom: #ed1c24 4px solid;">
									<span>
										<table border="0" cellSpacing="0" cellPadding="0" width="100%" style="background-color: #ed1c24; margin: 0px; padding 0px; border: 0px;">
											<tr>
												<td>
													<span>
														<a style="color: white; font-size: 15px; font-weight: bold; text-decoration: none; font-family: Arial;">
															<xsl:attribute name="href">
																<xsl:choose>
																	<xsl:when test="string-length(@ows_Alternatieve_x0020_Link) &gt; 0">
																		<xsl:value-of select='substring-before(@ows_Alternatieve_x0020_Link, ",")'/>
																	</xsl:when>
																	<xsl:otherwise>
																		<xsl:value-of select='concat(substring($rawUrl, 1, string-length($rawUrl) - string-length(string(@ows_ID))), "DispFormWindexCC.aspx?ID=", @ows_ID, "&amp;Source=/")'/>
																	</xsl:otherwise>
																</xsl:choose>
															</xsl:attribute>
															<xsl:choose>
																<xsl:when test="string-length(@ows_Titel_x0020_nieuwsbrief) &gt; 0">
																	<xsl:value-of select="@ows_Titel_x0020_nieuwsbrief" disable-output-escaping='yes'/>
																</xsl:when>
																<xsl:when test="string-length(@ows_LinkTitle) &lt; 1">
																	<xsl:value-of select="substring(@ows_Body,0,$titleLimit)" disable-output-escaping='yes'/>
																</xsl:when>
																<xsl:otherwise>
																	<xsl:value-of select='@ows_LinkTitle' disable-output-escaping='yes'  />
																</xsl:otherwise>
															</xsl:choose>
														</a>
													</span>
												</td>
												<td align="right">
													<select id="NewsWebPartOrderingSelector">
													</select>

													<select id="NewsWebPartCandidateSelector">
														<option value="Kandidaat">Kandidaat</option>
														<option value="Geplaatst" selected="selected">Plaatsen</option>
														<option value="Niet geplaatst">Niet plaatsen</option>
													</select>
												</td>
											</tr>
										</table>

										<!-- end actions -->
										<span name="NewsWebPartNewsBody" style="color: white; height: 85px; overflow: hidden; font-family: Arial;">
											<a style="color: white; text-decoration: none; font-family: Arial;">
												<xsl:choose>
													<xsl:when test="string-length(@ows_Inleiding) &lt; 1">
														<xsl:call-template name="removeHtmlTags">
															<xsl:with-param name="html" select="@ows_Body" />
														</xsl:call-template>
													</xsl:when>
													<xsl:otherwise>
														<xsl:call-template name="removeHtmlTags">
															<xsl:with-param name="html" select="@ows_Inleiding" />
														</xsl:call-template>
													</xsl:otherwise>
												</xsl:choose>
											</a>
										</span>

										<span name="NewsWebPartCategoryLabel" style="display: none; color: ed1c24;">
											<xsl:value-of select="concat(@ows_Nieuwsbriefcategorie, ';#')" disable-output-escaping='yes'  />
										</span>
									</span>
								</td>
							</tr>
						</TBODY>
					</TABLE>
				</TD>
			</TR>
		</xsl:if>
	</xsl:template>

	<xsl:template name="removeHtmlTags">
		<xsl:param name="html"/>
		<xsl:choose>
			<xsl:when test="contains($html, '&lt;')">
				<xsl:choose>
					<xsl:when test="substring(substring-after($html, '&lt;'), 1, 2) = 'a '">
						<xsl:value-of select="concat(substring-before($html, '&lt;/a&gt;'), '&lt;/a&gt;')" disable-output-escaping='yes'/>
						<!-- Recurse through HTML -->
						<xsl:call-template name="removeHtmlTags">
							<xsl:with-param name="html" select="substring-after($html, '&lt;/a&gt;')"/>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="substring-before($html, '&lt;')"/>
						<!-- Recurse through HTML -->
						<xsl:call-template name="removeHtmlTags">
							<xsl:with-param name="html" select="substring-after($html, '&gt;')"/>
						</xsl:call-template>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
