﻿<?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='435' style='margin: 0px; padding: 0px; border: 0px; width: 727px;'>
				<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>
				<xsl:variable name="rawUrl">
					<xsl:value-of select='substring-before(@ows_EncodedAbsUrl, "_.")'/>
				</xsl:variable>
				<xsl:variable name="link">
					<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:variable>
				<td width="15" style="width: 11.25pt;">
					<img src="/_layouts/images/void.gif" width="15"/>
				</td>
				<TD valign="top" width="420" style="PADDING: 0cm; BACKGROUND: white; width: 420px;">
					<TABLE width="420" border="0" cellSpacing="0" cellPadding="0" style="margin: 0px; padding: 0px; border: 0px; width: 420px;">
						<TBODY>
							<tr>
								<td width="420" style="width: 420px; font-size: 9pt; line-height: 18px; font-family: Arial">
									<span>

										<table border="0" cellSpacing="0" cellPadding="0" width="100%" style="background-color: transparent; margin: 0px; padding: 0px; border: 0px;">
											<tr>
												<td>
													<xsl:if test="string-length(@ows_Categorie) &gt; 0">
														<span style="font-family: 'Century Gothic', 'Trebuchet MS', 'Arial'; text-transform: uppercase; color: #f7941d; font-size: 20px; border-bottom: white 6px solid;">
															<xsl:value-of select='@ows_Categorie' disable-output-escaping='yes'  />
														</span>
														<br/>
													</xsl:if>
													<span style="color: black; font-size: 16px; font-family: Arial; font-style: normal; border-bottom: white 4px solid">
														<a style="color: black; font-size: 16px; font-weight: bold; font-style: normal" target="_blank">
															<xsl:attribute name="href">
																<xsl:value-of select='$link'/>
															</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>
										<a style="color: #999;">
											<xsl:attribute name="href">
												<xsl:value-of select='source/@url'/>
											</xsl:attribute>
											<xsl:value-of select='source'/>
										</a>
										<xsl:text disable-output-escaping="yes"> </xsl:text>

										<!-- end actions -->
										<span name="NewsWebPartNewsBody" style="color: black; height: 85px; overflow: hidden;">
											<a style="color: black; text-decoration: none; font-weight: normal; font-size: 9pt; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">
												<xsl:choose>
													<xsl:when test="string-length(@ows_Inleiding_x0020_nieuwsbrief) &gt; 0">
														<xsl:call-template name="removeHtmlTags">
															<xsl:with-param name="html" select="@ows_Inleiding_x0020_nieuwsbrief" />
														</xsl:call-template>
													</xsl:when>
													<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>
												<br/>
											</a>
										</span>

										<span name="NewsWebPartCategoryLabel" style="display: none; color: white;">
											<xsl:value-of select="concat(@ows_Nieuwsbriefcategorie, ';#')" disable-output-escaping='yes'  />
										</span>
										<p style="margin: 0px;" align="right">
											<xsl:if test="string-length(@ows_Body) &gt; 0 and (string-length(@ows_Inleiding_x0020_nieuwsbrief) &gt; 0 or string-length(@ows_Inleiding) &gt; 0)">

												<a title="Klik voor het volledige bericht" target="_blank"
																	   style="background-color: #f7941d; font-family: 'Century Gothic', 'Trebuchet MS', 'Arial'; text-transform: uppercase; color: black; font-family: Arial; font-size: 10px;">
													<xsl:attribute name="href">
														<xsl:value-of select='$link'/>
													</xsl:attribute>
													&#160;LEES VERDER&#160;
												</a>
											</xsl:if>
										</p>
									</span>
								</td>
							</tr>
						</TBODY>
					</TABLE>
				</TD>
			</TR>
		</xsl:if>
	</xsl:template>

	<xsl:template name="removeHtmlTags">
		<xsl:param name="html"/>
		<xsl:if 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:when test="substring(substring-after($html, '&lt;'), 1, 2) = 'br'">
					<br />
					<!-- Recurse through HTML -->
					<xsl:call-template name="removeHtmlTags">
						<xsl:with-param name="html" select="substring-after($html, '&gt;')"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:when test="substring(substring-after($html, '&lt;'), 1, 2) = 'ul'">
					<xsl:value-of select="concat(substring-before($html, '&lt;/ul&gt;'), '&lt;/ul&gt;')" disable-output-escaping='yes'/>
					<!-- Recurse through HTML -->
					<xsl:call-template name="removeHtmlTags">
						<xsl:with-param name="html" select="substring-after($html, '&lt;/ul&gt;')"/>
					</xsl:call-template>
				</xsl:when>
				<xsl:when test="substring(substring-after($html, '&lt;'), 1, 2) = 'li'">
					<xsl:value-of select="concat(substring-before($html, '&lt;/li&gt;'), '&lt;/li&gt;')" disable-output-escaping='yes'/>
					<!-- Recurse through HTML -->
					<xsl:call-template name="removeHtmlTags">
						<xsl:with-param name="html" select="substring-after($html, '&lt;/li&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:if>
	</xsl:template>
</xsl:stylesheet>
