Created
January 11, 2013 19:41
-
-
Save anonymous/4513384 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE xsl:stylesheet [ | |
<!ENTITY nbsp " "> | |
<!ENTITY pound "£"> | |
<!ENTITY lsquo "‘"> | |
<!ENTITY rsquo "’"> | |
<!ENTITY cr "<xsl:text> | |
</xsl:text>"> | |
]> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxml="urn:schemas-microsoft-com:xslt" | |
xmlns:msxsl="urn:schemas-microsoft-com:xslt" | |
xmlns:umbraco.library="urn:umbraco.library" | |
xmlns:PS.XSLTsearch="urn:PS.XSLTsearch" | |
xmlns:XSLTHelper="urn:XSLTHelper" | |
xmlns:SearchHelper="urn:SearchHelper" | |
xmlns:SearchLog="urn:SearchLog" | |
xmlns:TwitterHelper="urn:TwitterHelper" | |
exclude-result-prefixes="msxml umbraco.library PS.XSLTsearch SearchHelper SearchLog TwitterHelper"> | |
<xsl:output method="xml" omit-xml-declaration="yes" /> | |
<!-- | |
====================================================================== | |
XSLTsearch.xslt | |
====================================================================== | |
Copyright 2006-2011 Percipient Studios. All rights reserved. | |
MIT License (http://www.opensource.org/licenses/mit-license.php) | |
Version 3.0.1 - For umbraco 4.5+ and new XML schema | |
Fixed xslt error when a previewed field had fewer than six characters | |
Changed default behavior to only search within current site if source node id is not specified (better for multiple sites in one installation) | |
Multi-site searching made easier. Now searches only within the current site if the source= parameter is not specified (better for multiple sites in one installation) | |
Version 3.0.2 - Fixed issue of PreviewMode="CONTEXT" in which the search term would not be highlighted if it were the last word in the content being searched | |
Version 3.0.3 - Removed extraneous whitespace and empty quotes from search term | |
Version 3.0.4 - Additional fix for PreviewMode="CONTEXT" in which the search term would not be displayed if it were the last word in the content being search and the search term were more than $maxChars from the beginning of the search field | |
Removed errant 'xmp' debug statement that appeared in v3.0.3 | |
www.percipientstudios.com | |
====================================================================== | |
--> | |
<xsl:param name="currentPage" /> | |
<xsl:variable name="startTime" select="PS.XSLTsearch:getTime()" /> | |
<xsl:variable name="currentID" select="$currentPage/@id" /> | |
<xsl:variable name="XSLTsearchVersion" select="'3.0.4'" /> | |
<!-- DICTIONARY parameters for localization. Use default (English) text if dictionary item does not exist or has no value --> | |
<!--<xsl:variable name="dictionaryButton-Search" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Button-Search')), 'Search')" /> | |
<xsl:variable name="dictionaryDescription-Context" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Description-Context')), 'Context')" /> | |
<xsl:variable name="dictionaryDescription-ContextUnavailable" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Description-ContextUnavailable')), 'unavailable')" /> | |
<xsl:variable name="dictionaryHeading-SearchResults" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Heading-SearchResults')), 'Search Results')" />--> | |
<xsl:variable name="dictionaryNavigation-Next" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Navigation-Next')), 'Next')" /> | |
<xsl:variable name="dictionaryNavigation-Previous" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Navigation-Previous')), 'Previous')" /> | |
<!--<xsl:variable name="dictionaryPageRange-ShowingResults" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]PageRange-ShowingResults')), 'Showing results')" /> | |
<xsl:variable name="dictionaryPageRange-To" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]PageRange-To')), 'to')" /> | |
<xsl:variable name="dictionaryScore-Score" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Score-Score')), 'score')" /> | |
<xsl:variable name="dictionaryStats-PagesIn" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Stats-PagesIn')), 'pages in')" /> | |
<xsl:variable name="dictionaryStats-Searched" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Stats-Searched')), 'Searched')" /> | |
<xsl:variable name="dictionaryStats-Seconds" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Stats-Seconds')), 'seconds')" /> | |
<xsl:variable name="dictionarySummary-Matches" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Summary-Matches')), 'matches')" /> | |
<xsl:variable name="dictionarySummary-NoMatchesWereFoundFor" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Summary-NoMatchesWereFoundFor')), 'No matches were found for')" /> | |
<xsl:variable name="dictionarySummary-Page" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Summary-Page')), 'page')" /> | |
<xsl:variable name="dictionarySummary-Pages" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Summary-Pages')), 'pages')" /> | |
<xsl:variable name="dictionarySummary-YourSearchFor" select="PS.XSLTsearch:getDictionaryParameter(string(umbraco.library:GetDictionaryItem('[XSLTsearch]Summary-YourSearchFor')), 'Your search for')" />--> | |
<!-- MACRO parameters get default values if not passed in from the macro --> | |
<!--<xsl:variable name="source" select="string(PS.XSLTsearch:getParameter(string(/macro/source), '-1'))"/>--> | |
<xsl:variable name="source" select="string($currentPage/ancestor-or-self::*[@isDoc] [@level=2]/@id)" /> | |
<xsl:variable name="sourceJobCategory" select="$source" /> | |
<xsl:variable name="resultsPerPage" select="string(PS.XSLTsearch:getParameter(string(/macro/resultsPerPage), '5'))" /> | |
<xsl:variable name="previewChars" select="string(PS.XSLTsearch:getParameter(string(/macro/previewChars), '255'))" /> | |
<xsl:variable name="searchBoxLocation" select="PS.XSLTsearch:uppercase(PS.XSLTsearch:getParameter(string(/macro/searchBoxLocation), 'bottom'))" /> | |
<!-- valid choices are: 'bottom' or 'top' or 'both' or 'none' --> | |
<xsl:variable name="previewType" select="PS.XSLTsearch:uppercase(PS.XSLTsearch:getParameter(string(/macro/previewType), 'beginning'))" /> | |
<!-- valid choices are: 'beginning' and 'context' --> | |
<xsl:variable name="showPageRange" select="PS.XSLTsearch:uppercase(PS.XSLTsearch:getParameter(string(/macro/showPageRange), '0'))" /> | |
<xsl:variable name="showOrdinals" select="PS.XSLTsearch:uppercase(PS.XSLTsearch:getParameter(string(/macro/showOrdinals), '0'))" /> | |
<xsl:variable name="showScores" select="PS.XSLTsearch:uppercase(PS.XSLTsearch:getParameter(string(/macro/showScores), '0'))" /> | |
<xsl:variable name="showStats" select="PS.XSLTsearch:uppercase(PS.XSLTsearch:getParameter(string(/macro/showStats), '0'))" /> | |
<xsl:variable name="showDebug" select="PS.XSLTsearch:uppercase(PS.XSLTsearch:getParameter(string(umbraco.library:RequestQueryString('umbDebugShowTrace')), '0'))" /> | |
<!-- which umbraco fields to search --> | |
<!-- Note: Comma-separated list of fields. The order of the search fields affects the search score and | |
order of the search results! Place the more important fields first, with bodyText last. | |
The reason is that if a search term appears in the page's title, there is a greater likelihood | |
that page discusses the search term at length, than it simply being mentioned in the bodyText in passing. | |
--> | |
<xsl:variable name="searchFields" select="PS.XSLTsearch:getListParameter(string(/macro/searchFields), '@nodeName,metaKeywords,metaDescription,bodyText,jobKeywords')" /> | |
<!-- which umbraco field to display for a found entry --> | |
<!-- Note: Comma-separated list of fields. The order of the preview fields is from most preferred | |
to least preferred. Put the most appropriate fields first (typically, bodyText). | |
Note: ONLY works for properties, not attributes | |
--> | |
<xsl:variable name="previewFields" select="PS.XSLTsearch:getListParameter(string(/macro/previewFields), 'bodyText,metaDescription')" /> | |
<!-- the search term to look for --> | |
<xsl:variable name="search"> | |
<xsl:value-of select="string(umbraco.library:Session('search'))" /> | |
</xsl:variable> | |
<xsl:variable name="unescapedSearch" select="PS.XSLTsearch:unescapeString($search)" /> | |
<!-- We have to calculate matching nodes before we can finish calculating the rest of the variables/parameters... --> | |
<!-- uppercase the search string for case-insensitive searching --> | |
<xsl:variable name="searchUpper" select="PS.XSLTsearch:uppercase(string($search))" /> | |
<xsl:variable name="pageQueryString" select="umbraco.library:RequestQueryString('page')" /> | |
<xsl:variable name="sortFormVariable" select="umbraco.library:RequestForm('sort')" /> | |
<!-- ============================================================= --> | |
<xsl:template match="/"> | |
<xsl:call-template name="search"> | |
<xsl:with-param name="items" select="SearchHelper:Search($source)"/> | |
</xsl:call-template> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="search"> | |
<!-- Perform the search on the appropriate nodeset and display the output --> | |
<xsl:param name="items" /> | |
<!-- reduce the number of nodes for applying all the functions in the next step --> | |
<xsl:variable name="possibleNodes" select="$items/descendant-or-self::*[@isDoc and string(umbracoNaviHide) != '1' and (umbraco.library:IsProtected(@id, @path) = false() or umbraco.library:HasAccess(@id, @path) = true()) and count(attribute::id)=1]" /> | |
<!-- generate a string of a semicolon-delimited list of all @id's of the matching nodes --> | |
<xsl:variable name="matchedNodesIdList"> | |
<xsl:call-template name="booleanAndMatchedNodes"> | |
<xsl:with-param name="yetPossibleNodes" select="$possibleNodes" /> | |
<xsl:with-param name="searchTermList" select="concat($searchUpper, ' ')" /> | |
</xsl:call-template> | |
</xsl:variable> | |
<!-- get the actual matching nodes as a nodeset --> | |
<xsl:variable name="matchedNodes" select="$possibleNodes[contains($matchedNodesIdList, concat(';', concat(@id, ';')))]" /> | |
<xsl:variable name="matchedNodesCount" select="count(matchedNodes)" /> | |
<!-- the current page --> | |
<xsl:variable name="page"> | |
<xsl:choose> | |
<!-- first page --> | |
<xsl:when test="number($pageQueryString) <=1 or string($pageQueryString) = '' or string(number($pageQueryString)) = 'NaN'">1</xsl:when> | |
<!-- last page --> | |
<xsl:when test="number($pageQueryString) > matchedNodesCount div $resultsPerPage"> | |
<xsl:value-of select="ceiling(matchedNodesCount div $resultsPerPage)" /> | |
</xsl:when> | |
<!-- the value specified in the querystring --> | |
<xsl:otherwise> | |
<xsl:value-of select="number($pageQueryString)" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<!-- calculate a few handy variables now, for easy access later --> | |
<xsl:variable name="startMatch" select="($page - 1) * $resultsPerPage + 1" /> | |
<xsl:variable name="endMatch"> | |
<xsl:choose> | |
<!-- all the rest (on the last page) --> | |
<xsl:when test="($page * $resultsPerPage) > matchedNodesCount"> | |
<xsl:value-of select="matchedNodesCount" /> | |
</xsl:when> | |
<!-- only the appropriate number for this page --> | |
<xsl:otherwise> | |
<xsl:value-of select="$page * $resultsPerPage" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<!-- Log the search --> | |
<xsl:if test="number($pageQueryString) <=1 or string($pageQueryString) = '' or string(number($pageQueryString)) = 'NaN'"> | |
<xsl:variable name="Log" select="SearchLog:AddSearchLog(count($matchedNodes [jobClosed !='1']),umbraco.library:RequestServerVariables('SERVER_NAME'))" /> | |
</xsl:if> | |
<!-- display results header information to the screen, if a search has been run; otherwise just show the search form --> | |
<h1> | |
<xsl:choose> | |
<xsl:when test="umbraco.library:Session('view') ='Browse'"> | |
<xsl:choose> | |
<xsl:when test="matchedNodesCount = 0"> | |
<xsl:value-of select="$currentPage/ancestor-or-self::*[@isDoc] [(@level= 2)]/SiteConfig/noJobsFound" disable-output-escaping="yes" /> | |
</xsl:when> | |
<xsl:when test="matchedNodesCount = 1"> | |
Found 1 | |
<xsl:choose> | |
<xsl:when test="umbraco.library:Session('jobRegion') !=''"> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobRegion'))/@nodeName" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:Session('jobEmployer') !=''"> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobEmployer'))/@nodeName" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:Session('jobDegree') !=''"> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobDegree'))/@nodeName" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:Session('jobSector') !=''"> | |
<xsl:text /> | |
<xsl:choose> | |
<xsl:when test="$sourceJobCategory='28188'"> <!-- Food Jobs --> | |
<xsl:value-of select="'Focus Management'" /> | |
<!--<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusManagement" />--> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31906'"> <!-- Chef Jobs --> | |
<xsl:value-of select="'Focus Chefs'" /> | |
<!--<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusChefs" />--> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31674'"> <!-- Interim --> | |
<xsl:value-of select="'Focus Interim'" /> | |
<!--<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusInterim" />--> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31554'"> <!-- Executive Food Jobs --> | |
<xsl:value-of select="'Focus Selet'" /> | |
<!--<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusSelect" />--> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31587'"> <!-- Graduates --> | |
<xsl:value-of select="'Focus Graduates'" /> | |
<!--<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusGraduates" />--> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='32037'"> <!-- International --> | |
<xsl:value-of select="'Focus International'" /> | |
<!--<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/foodJobsEU" />--> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='320371'"> <!-- UK --> | |
<xsl:value-of select="'Food Jobs UK'" /> | |
<!--<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/foodJobsUK" />--> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:when> | |
</xsl:choose> | |
job | |
</xsl:when> | |
<xsl:otherwise> | |
Found | |
<xsl:value-of select="count($matchedNodes [jobClosed !='1']) " /> | |
<xsl:value-of select="' '" /> | |
<xsl:choose> | |
<xsl:when test="umbraco.library:Session('jobRegion') !=''"> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobRegion'))/@nodeName" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:Session('jobEmployer') !=''"> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobEmployer'))/@nodeName" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:Session('jobDegree') !=''"> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobDegree'))/@nodeName" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:Session('jobSector') !=''"> | |
<xsl:text /> | |
<xsl:choose> | |
<xsl:when test="$sourceJobCategory='28188'"> <!-- Food Jobs --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusManagement" /> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31906'"> <!-- Chef Jobs --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusChefs" /> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31674'"> <!-- Interim --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusInterim" /> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31554'"> <!-- Executive Food Jobs --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusSelect" /> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31587'"> <!-- Graduates --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusGraduates" /> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='32037'"> <!-- International --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/foodJobsEU" /> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='320371'"> <!-- UK --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/foodJobsUK" /> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:when> | |
</xsl:choose> | |
jobs | |
</xsl:otherwise> | |
</xsl:choose> | |
<!-- show the page number range. Useful if you don't show the ordinal for the result --> | |
<xsl:if test="$showPageRange != '0'"> | |
<xsl:if test="count($matchedNodes) > 0"> | |
<br /> | |
<span id="xsltsearch_pagerange"> | |
Showing results | |
<xsl:value-of select="$startMatch" /> | |
<xsl:if test="$startMatch != $endMatch"> | |
to | |
<xsl:value-of select="$endMatch" /> | |
</xsl:if> | |
</span> | |
</xsl:if> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:choose> | |
<xsl:when test="count($matchedNodes) = 0"> | |
<xsl:value-of select="$currentPage/ancestor-or-self::*[@isDoc] [(@level= 2)]/SiteConfig/noJobsFound" disable-output-escaping="yes" /> | |
</xsl:when> | |
<xsl:when test="count($matchedNodes) = 1">Found 1 job matching your criteria</xsl:when> | |
<xsl:otherwise> | |
Found | |
<xsl:value-of select="count($matchedNodes [jobClosed !='1'])" /> | |
jobs matching your criteria | |
</xsl:otherwise> | |
</xsl:choose> | |
<!-- show the page number range. Useful if you don't show the ordinal for the result --> | |
<xsl:if test="$showPageRange != '0'"> | |
<xsl:if test="count($matchedNodes) > 0"> | |
<br /> | |
<span id="xsltsearch_pagerange"> | |
Showing results | |
<xsl:value-of select="$startMatch" /> | |
<xsl:if test="$startMatch != $endMatch"> | |
to | |
<xsl:value-of select="$endMatch" /> | |
</xsl:if> | |
</span> | |
</xsl:if> | |
</xsl:if> | |
</xsl:otherwise> | |
</xsl:choose> | |
</h1> | |
<!-- Find the domain URL.--> | |
<!-- This needs to change - need to go back up the tree (ancestor or self for jobs)--> | |
<xsl:if test="umbraco.library:Session('view') !='Browse' and count($matchedNodes) > 0 "> | |
<h2> | |
Listing all the latest jobs to view and apply for with | |
<xsl:choose> | |
<xsl:when test="$sourceJobCategory='28188'"> <!-- Food Jobs --> | |
Focus Management | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31906'"> <!-- Chef Jobs --> | |
Focus Chefs | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31674'"> <!-- Interim --> | |
Focus Interim | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31554'"> <!-- Executive Food Jobs --> | |
Focus Select | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='31587'"> <!-- Graduates --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/focusGraduates" /> | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='32037'"> <!-- International --> | |
Focus International | |
</xsl:when> | |
<xsl:when test="$sourceJobCategory='320371'"> <!-- UK --> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/foodJobsUK" /> | |
</xsl:when> | |
</xsl:choose> | |
</h2> | |
</xsl:if> | |
<!-- Now we need to sort the pages by score/relevance before sending them to the screen. | |
We'll cycle through matched nodes once to save their pageScore in a variable --> | |
<xsl:variable name="pageScoreList"> | |
<xsl:text>;</xsl:text> | |
<!--<xsl:for-each select="$matchedNodes"> | |
--><!-- unique id for this node --><!-- | |
<xsl:value-of select="generate-id(.)" /> | |
<xsl:text>=</xsl:text> | |
--><!-- weighted score for the matches --><!-- | |
<xsl:call-template name="pageScore"> | |
<xsl:with-param name="item" select="." /> | |
</xsl:call-template> | |
<xsl:text>;</xsl:text> | |
</xsl:for-each>--> | |
</xsl:variable> | |
<!-- display search results to the screen --> | |
<xsl:if test="count($matchedNodes) = 0"> | |
<xsl:text disable-output-escaping="yes" /> | |
</xsl:if> | |
<!-- display paging navigation links, if needed --> | |
<xsl:if test="$resultsPerPage < count($matchedNodes)"> | |
<xsl:call-template name="searchNavigationTop"> | |
<xsl:with-param name="page" select="$page" /> | |
<xsl:with-param name="matchedNodes" select="$matchedNodes" /> | |
</xsl:call-template> | |
</xsl:if> | |
<xsl:call-template name="feedLinks"> | |
<xsl:with-param name="page" select="$page" /> | |
<xsl:with-param name="matchedNodes" select="$matchedNodes" /> | |
</xsl:call-template> | |
<xsl:variable name="sorting"> | |
<xsl:choose> | |
<xsl:when test="$sortFormVariable!=''"> | |
<xsl:value-of select="$sortFormVariable" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('sort')!=''"> | |
<xsl:value-of select="umbraco.library:RequestQueryString('sort')" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('sort')='' and $sortFormVariable=''" /> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="sort"> | |
<xsl:choose> | |
<xsl:when test="$sorting = 'd-a'">id</xsl:when> | |
<xsl:when test="$sorting = 'd-d'">id</xsl:when> | |
<xsl:when test="$sorting = 's-a'">salary</xsl:when> | |
<xsl:when test="$sorting = 's-d'">salary</xsl:when> | |
<xsl:when test="$sorting = 'r'">jobRegion</xsl:when> | |
<xsl:when test="$sorting = 'c'">jobType</xsl:when> | |
<xsl:when test="$sorting = 'd'">jobSector</xsl:when> | |
<xsl:otherwise>id</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="direction"> | |
<xsl:choose> | |
<xsl:when test="$sorting = 'd-a'">ascending</xsl:when> | |
<xsl:when test="$sorting = 'd-d'">descending</xsl:when> | |
<xsl:when test="$sorting = 's-a'">ascending</xsl:when> | |
<xsl:when test="$sorting = 's-d'">descending</xsl:when> | |
<xsl:when test="$sorting = 'r'">ascending</xsl:when> | |
<xsl:when test="$sorting = 'c'">ascending</xsl:when> | |
<xsl:when test="$sorting = 'd'">ascending</xsl:when> | |
<xsl:otherwise>descending</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:call-template name="Display"> | |
<xsl:with-param name="matchedNodes" select="$matchedNodes" /> | |
<xsl:with-param name="startMatch" select="$startMatch" /> | |
<xsl:with-param name="endMatch" select="$endMatch" /> | |
<xsl:with-param name="pageScoreList" select="$pageScoreList" /> | |
<xsl:with-param name="sortBy" select="$sort" /> | |
<xsl:with-param name="dir" select="$direction" /> | |
</xsl:call-template> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="Display"> | |
<xsl:param name="matchedNodes" /> | |
<xsl:param name="startMatch" /> | |
<xsl:param name="endMatch" /> | |
<xsl:param name="pageScoreList" /> | |
<xsl:param name="sortBy" /> | |
<xsl:param name="dir" /> | |
<xsl:if test="count($matchedNodes) > 0"> | |
<xsl:for-each select="msxsl:node-set($matchedNodes)"> | |
<xsl:sort select="umbraco.library:GetXmlNodeById(./jobSector)/@nodeName [$sortBy='jobSector']" data-type="text" order="ascending" /> | |
<xsl:sort select="umbraco.library:GetXmlNodeById(./jobType)/@nodeName [$sortBy='jobType']" data-type="text" order="ascending" /> | |
<xsl:sort select="umbraco.library:GetXmlNodeById(./jobregion)/@nodeName [$sortBy='jobregion']" data-type="text" order="ascending" /> | |
<xsl:sort select="./salary [$sortBy='salary' and $dir='ascending']" data-type="number" order="ascending" /> | |
<xsl:sort select="./salary [$sortBy='salary' and $dir='descending']" data-type="number" order="descending" /> | |
<xsl:sort select="./@id [$sortBy='id' and $dir='ascending']" data-type="number" order="ascending" /> | |
<xsl:sort select="./@id [$sortBy='id' and $dir='descending']" data-type="number" order="descending" /> | |
<!-- sort on the page score of the node, within ALL the nodes to return (the sorting must happen before choosing the nodes for this page) --> | |
<!-- <xsl:sort select="@id" data-type="number" order="descending"/>--> | |
<!-- <xsl:sort select="substring-before(substring-after($pageScoreList, concat(';',generate-id(.),'=')),';')" data-type="number" order="descending"/>--> | |
<!-- only the nodes for this page --> | |
<xsl:if test="position() >= $startMatch and position() <= $endMatch"> | |
<div class="item-listing"> | |
<div class="item-listing-detail"> | |
<xsl:if test="./jobEmployer !='' and string(./jobEmployerHidden) !='1'"> | |
<xsl:variable name="image" select="string(umbraco.library:GetXmlNodeById(./jobEmployer)/employerLogo)" /> | |
<xsl:if test="string($image) !='' and (string(umbraco.library:RequestQueryString('jobEmployer')) = '' and string(umbraco.library:RequestForm('jobEmployer')) = '')"> | |
<div class="item-listing-image"> | |
<xsl:element name="img"> | |
<xsl:attribute name="src"> | |
<xsl:value-of select="umbraco.library:GetMedia($image, 'false')/umbracoFile" /> | |
</xsl:attribute> | |
<xsl:attribute name="alt"> | |
<xsl:value-of select="umbraco.library:GetMedia($image, 'false')/umbracoAltText" /> | |
</xsl:attribute> | |
<xsl:attribute name="title"> | |
<xsl:value-of select="umbraco.library:GetMedia($image, 'false')/umbracoTitle" /> | |
</xsl:attribute> | |
<xsl:attribute name="height"> | |
<xsl:value-of select="umbraco.library:GetMedia($image, 'false')/umbracoHeight" /> | |
</xsl:attribute> | |
<xsl:attribute name="width"> | |
<xsl:value-of select="umbraco.library:GetMedia($image, 'false')/umbracoWidth" /> | |
</xsl:attribute> | |
</xsl:element> | |
</div> | |
</xsl:if> | |
</xsl:if> | |
<h2> | |
<xsl:element name="a"> | |
<xsl:if test="./@id=$currentPage/ancestor-or-self::*[@isDoc] [@level=2]/@id"> | |
<xsl:attribute name="class">navselected</xsl:attribute> | |
</xsl:if> | |
<xsl:attribute name="href"> | |
<xsl:choose> | |
<xsl:when test="./linkType='10'"> | |
<xsl:if test="./internalLink !=''"> | |
<xsl:value-of select="umbraco.library:NiceUrl(./internalLink)" /> | |
</xsl:if> | |
</xsl:when> | |
<xsl:when test="./linkType='11'"> | |
<xsl:value-of select="./externalLink" /> | |
</xsl:when> | |
<xsl:when test="./linkType='12'"> | |
<xsl:if test="./mediaLink !=''"> | |
<xsl:value-of select="umbraco.library:GetMedia(./mediaLink, 'false')/umbracoFile " /> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="umbraco.library:NiceUrl(@id)" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:attribute> | |
<xsl:if test="(./linkFollowing) = 1"> | |
<xsl:attribute name="rel">nofollow</xsl:attribute> | |
</xsl:if> | |
<xsl:attribute name="title"> | |
<xsl:value-of select="./pageTitle" /> | |
</xsl:attribute> | |
<xsl:value-of select="./pageHeading" /> | |
</xsl:element> | |
</h2> | |
<div class="item-details2"> | |
<xsl:if test="./jobEmployer !='' and string(./jobEmployerHidden) !='1'"> | |
<p> | |
<strong>Employer:</strong> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(./jobEmployer)/@nodeName" /> | |
</p> | |
</xsl:if> | |
<p> | |
<xsl:if test="./jobRegion !=''"> | |
<strong>Location:</strong> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(./jobRegion)/@nodeName" /> | |
| | |
</xsl:if> | |
<xsl:if test="./jobCountry !=''"> | |
<strong>Country:</strong> | |
<xsl:text /> | |
<xsl:value-of select="./jobCountry" /> | |
</xsl:if> | |
<xsl:if test="./jobType !=''"> | |
<strong>Job Type:</strong> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(./jobType)/@nodeName" /> | |
| | |
</xsl:if> | |
<xsl:if test="./jobSector !=''"> | |
<strong>Discipline:</strong> | |
<xsl:text /> | |
<xsl:value-of select="umbraco.library:GetXmlNodeById(./jobSector)/@nodeName" /> | |
</xsl:if> | |
<xsl:if test="./jobStartDate !=''"> | |
<xsl:text>|</xsl:text> | |
<strong>Start Date:</strong> | |
<xsl:text /> | |
<xsl:value-of select="./jobStartDate" /> | |
</xsl:if> | |
</p> | |
</div> | |
<xsl:if test="./salaryText !=''"> | |
<div class="salaryamount"> | |
<p> | |
<strong>Salary:</strong> | |
<xsl:value-of select="./salaryText" /> | |
</p> | |
</div> | |
</xsl:if> | |
<p> | |
<xsl:value-of select="XSLTHelper:LeftString(umbraco.library:StripHtml(./bodyText),200)" disable-output-escaping="yes" /> | |
</p> | |
<xsl:choose> | |
<xsl:when test="./jobClosed='1'"> | |
<p class="closed">Applications are now closed</p> | |
<p class="applylinkclosed"> | |
<xsl:element name="a"> | |
<xsl:if test="./@id=$currentPage/ancestor-or-self::*[@isDoc] [@level=2]/@id"> | |
<xsl:attribute name="class">navselected</xsl:attribute> | |
</xsl:if> | |
<xsl:attribute name="href"> | |
<xsl:choose> | |
<xsl:when test="./linkType='10'"> | |
<xsl:if test="./internalLink !=''"> | |
<xsl:value-of select="umbraco.library:NiceUrl(./internalLink)" /> | |
</xsl:if> | |
</xsl:when> | |
<xsl:when test="./linkType='11'"> | |
<xsl:value-of select="./externalLink" /> | |
</xsl:when> | |
<xsl:when test="./linkType='12'"> | |
<xsl:if test="./mediaLink !=''"> | |
<xsl:value-of select="umbraco.library:GetMedia(./mediaLink, 'false')/umbracoFile " /> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="umbraco.library:NiceUrl(@id)" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:attribute> | |
<xsl:if test="(./linkFollowing) = 1"> | |
<xsl:attribute name="rel">nofollow</xsl:attribute> | |
</xsl:if> | |
<xsl:attribute name="title"> | |
<xsl:value-of select="./pageTitle" /> | |
</xsl:attribute> | |
view job details | |
</xsl:element> | |
</p> | |
</xsl:when> | |
<xsl:otherwise> | |
<p class="applylink"> | |
<xsl:element name="a"> | |
<xsl:if test="./@id=$currentPage/ancestor-or-self::*[@isDoc] [@level=2]/@id"> | |
<xsl:attribute name="class">navselected</xsl:attribute> | |
</xsl:if> | |
<xsl:attribute name="href"> | |
<xsl:choose> | |
<xsl:when test="./linkType='10'"> | |
<xsl:if test="./internalLink !=''"> | |
<xsl:value-of select="umbraco.library:NiceUrl(./internalLink)" /> | |
</xsl:if> | |
</xsl:when> | |
<xsl:when test="./linkType='11'"> | |
<xsl:value-of select="./externalLink" /> | |
</xsl:when> | |
<xsl:when test="./linkType='12'"> | |
<xsl:if test="./mediaLink !=''"> | |
<xsl:value-of select="umbraco.library:GetMedia(./mediaLink, 'false')/umbracoFile " /> | |
</xsl:if> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="umbraco.library:NiceUrl(@id)" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:attribute> | |
<xsl:if test="(./linkFollowing) = 1"> | |
<xsl:attribute name="rel">nofollow</xsl:attribute> | |
</xsl:if> | |
<xsl:attribute name="title"> | |
<xsl:value-of select="./pageTitle" /> | |
</xsl:attribute> | |
apply for this job / view job details | |
</xsl:element> | |
</p> | |
</xsl:otherwise> | |
</xsl:choose> | |
</div> | |
</div> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:if> | |
<!-- display XSLTsearch version information if in debug mode (that is, if the querystring contains umbDebugShowTrace=true) --> | |
<!-- don't let a collapsed div tag break the page layout --> | |
<xsl:if test="$unescapedSearch='' and $searchBoxLocation='NONE'"> | |
<xsl:text> </xsl:text> | |
</xsl:if> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="searchNavigation"> | |
<!-- navigation template (Note: we're just using hrefs with querystrings) --> | |
<xsl:param name="page" /> | |
<xsl:param name="matchedNodes" /> | |
<p id="xsltsearch_navigation"> | |
<!-- previous page --> | |
<a id="previous"> | |
<xsl:choose> | |
<xsl:when test="$page <= 1"> | |
<xsl:attribute name="class">disabled</xsl:attribute> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:attribute name="href"> | |
<xsl:text>?search=</xsl:text> | |
<xsl:value-of select="$search" /> | |
<xsl:text>&page=</xsl:text> | |
<xsl:value-of select="$page - 1" /> | |
</xsl:attribute> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:text><</xsl:text> | |
<xsl:value-of select="$dictionaryNavigation-Previous" /> | |
</a> | |
<xsl:text> </xsl:text> | |
<!-- each paged set of results is listed, with a link to that page set --> | |
<xsl:call-template name="pageNumbers"> | |
<xsl:with-param name="pageIndex" select="1" /> | |
<xsl:with-param name="page" select="$page" /> | |
<xsl:with-param name="matchedNodes" select="$matchedNodes" /> | |
</xsl:call-template> | |
<!-- next page --> | |
<xsl:text> </xsl:text> | |
<a id="next"> | |
<xsl:choose> | |
<xsl:when test="$page * $resultsPerPage >= count($matchedNodes)"> | |
<xsl:attribute name="class">disabled</xsl:attribute> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:attribute name="href"> | |
<xsl:text>?search=</xsl:text> | |
<xsl:value-of select="$search" /> | |
<xsl:text>&page=</xsl:text> | |
<xsl:value-of select="$page + 1" /> | |
</xsl:attribute> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:value-of select="$dictionaryNavigation-Next" /> | |
<xsl:text>></xsl:text> | |
</a> | |
</p> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="pageNumbers"> | |
<xsl:param name="page" /> | |
<xsl:param name="pageIndex" /> | |
<xsl:param name="matchedNodes" /> | |
<xsl:param name="resultsPerPage" /> | |
<xsl:variable name="distanceFromCurrent" select="$pageIndex - $page" /> | |
<span> | |
Page | |
<xsl:value-of select="$page" /> | |
of | |
<xsl:value-of select="ceiling(count($matchedNodes) div $resultsPerPage)" /> | |
| |
</span> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="pageScore"> | |
<xsl:param name="item" /> | |
<!-- sum up scores for each of the attributes --> | |
<xsl:variable name="scoreA"> | |
<xsl:call-template name="scoreAttributes"> | |
<xsl:with-param name="item" select="$item" /> | |
</xsl:call-template> | |
</xsl:variable> | |
<!-- sum up scores for each of the data nodes --> | |
<xsl:variable name="scoreD"> | |
<xsl:call-template name="scoreDataNodes"> | |
<xsl:with-param name="item" select="$item[@isDoc]/*[not(@isDoc) and contains($searchFields, concat(',',name(),','))]" /> | |
</xsl:call-template> | |
</xsl:variable> | |
<xsl:value-of select="number($scoreA) + number($scoreD)" /> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="scoreAttributes"> | |
<xsl:param name="item" /> | |
<xsl:param name="index" select="1" /> | |
<xsl:param name="score" select="0" /> | |
<!-- name of the attribute on which we're searching --> | |
<xsl:variable name="attributeName" select="name($item/attribute::*[position()=$index])" /> | |
<xsl:variable name="weighting"> | |
<xsl:if test="contains($searchFields, concat(',@',$attributeName,','))"> | |
<xsl:value-of select="PS.XSLTsearch:power(2, number(PS.XSLTsearch:hitCount(substring-after($searchFields,$attributeName), ','))-1)" /> | |
</xsl:if> | |
</xsl:variable> | |
<!-- calculate the final, cumulative, weighted score for this field --> | |
<xsl:variable name="thisScore"> | |
<xsl:choose> | |
<xsl:when test="contains($searchFields, concat(',@',$attributeName,','))"> | |
<!-- only calculate when this is a field actually being searched --> | |
<xsl:call-template name="scoreForBooleanSearch"> | |
<xsl:with-param name="weighting" select="$weighting" /> | |
<xsl:with-param name="toSearch" select="umbraco.library:StripHtml(string($item/attribute::*[name()=$attributeName]))" /> | |
<xsl:with-param name="searchTermList" select="concat($search, ' ')" /> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise>0</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="count(./attribute::*)=$index"> | |
<!-- all done; print out total weight score --> | |
<xsl:value-of select="$score + $thisScore" /> | |
</xsl:when> | |
<xsl:otherwise> | |
<!-- continue recursion for other fields --> | |
<xsl:call-template name="scoreAttributes"> | |
<xsl:with-param name="item" select="$item" /> | |
<xsl:with-param name="index" select="$index + 1" /> | |
<xsl:with-param name="score" select="$score + $thisScore" /> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="scoreForBooleanSearch"> | |
<xsl:param name="weighting" select="1" /> | |
<xsl:param name="toSearch" /> | |
<xsl:param name="searchTermList" /> | |
<xsl:param name="currentHitCount" select="0" /> | |
<!-- next search term --> | |
<xsl:variable name="searchTerm"> | |
<xsl:value-of select="PS.XSLTsearch:getFirstElement($searchTermList, ' ')" /> | |
</xsl:variable> | |
<!-- remaining search terms --> | |
<xsl:variable name="remainingSearchTermList"> | |
<xsl:value-of select="PS.XSLTsearch:removeFirstElement($searchTermList, ' ')" /> | |
</xsl:variable> | |
<!-- hit count for this search term --> | |
<xsl:variable name="thisHitCount"> | |
<xsl:value-of select="PS.XSLTsearch:hitCount($toSearch, string($searchTerm))" /> | |
</xsl:variable> | |
<xsl:choose> | |
<xsl:when test="string-length($remainingSearchTermList) > 1"> | |
<!-- continue to search the rest of the terms --> | |
<xsl:call-template name="scoreForBooleanSearch"> | |
<xsl:with-param name="weighting" select="$weighting" /> | |
<xsl:with-param name="toSearch" select="$toSearch" /> | |
<xsl:with-param name="searchTermList" select="$remainingSearchTermList" /> | |
<xsl:with-param name="currentHitCount" select="$currentHitCount + $thisHitCount" /> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<!-- finished searching: return the total hit count * weighting --> | |
<xsl:value-of select="number($currentHitCount + $thisHitCount) * $weighting" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="scoreDataNodes"> | |
<xsl:param name="item" /> | |
<xsl:param name="score" select="0" /> | |
<!-- the weighting to apply to hits in this search field --> | |
<xsl:variable name="weighting" select="PS.XSLTsearch:power(2, number(PS.XSLTsearch:hitCount(substring-after($searchFields,string(name($item))), ','))-1)" /> | |
<!-- calculate the final, cumulative, weighted score for this field --> | |
<xsl:variable name="thisScore"> | |
<xsl:choose> | |
<xsl:when test="contains($searchFields, concat(',',name($item),','))"> | |
<!-- only calculate when this is a field actually being searched --> | |
<xsl:call-template name="scoreForBooleanSearch"> | |
<xsl:with-param name="weighting" select="$weighting" /> | |
<xsl:with-param name="toSearch" select="umbraco.library:StripHtml(string($item))" /> | |
<xsl:with-param name="searchTermList" select="concat($search, ' ')" /> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise>0</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<!-- remaining data nodes whose hitCounts we need to tally; for recursion use --> | |
<xsl:variable name="remaining" select="$item/following-sibling::*[not(@isDoc) and contains($searchFields, concat(',',name(),','))]" /> | |
<xsl:choose> | |
<xsl:when test="count($remaining) = 0"> | |
<!-- all done; return the final score --> | |
<xsl:value-of select="number($thisScore) + number($score)" /> | |
</xsl:when> | |
<xsl:otherwise> | |
<!-- keep summing the hitCounts for all the fields for this page by calling the pageScore template recursively --> | |
<xsl:call-template name="scoreDataNodes"> | |
<xsl:with-param name="item" select="$remaining[position()=1]" /> | |
<xsl:with-param name="score" select="number($thisScore) + number($score)" /> | |
</xsl:call-template> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="displayFieldText"> | |
<xsl:param name="item" /> | |
<xsl:param name="fieldList" /> | |
<xsl:variable name="fieldName"> | |
<xsl:value-of select="PS.XSLTsearch:getFirstElement($fieldList, ',')" /> | |
</xsl:variable> | |
<xsl:variable name="remainingFields"> | |
<xsl:value-of select="PS.XSLTsearch:removeFirstElement($fieldList, ',')" /> | |
</xsl:variable> | |
<xsl:choose> | |
<!-- actually print out field, if it exists and has content --> | |
<xsl:when test="count($item/*[not(@isDoc) and name()=string($fieldName)]) = 1 and string($item/*[not(@isDoc) and name()=string($fieldName)]) != ''"> | |
<xsl:value-of select="string($item/*[not(@isDoc) and name()=string($fieldName)])" /> | |
</xsl:when> | |
<xsl:when test="$remainingFields != ''"> | |
<!-- if this element does not exist, go on to the next one --> | |
<xsl:call-template name="displayFieldText"> | |
<xsl:with-param name="item" select="$item" /> | |
<xsl:with-param name="fieldList" select="$remainingFields" /> | |
</xsl:call-template> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="booleanAndMatchedNodes"> | |
<xsl:param name="yetPossibleNodes" /> | |
<xsl:param name="searchTermList" /> | |
<xsl:variable name="searchTerm"> | |
<xsl:value-of select="PS.XSLTsearch:unescapeString(PS.XSLTsearch:getFirstElement($searchTermList, ' '))" /> | |
</xsl:variable> | |
<xsl:variable name="remainingSearchTermList"> | |
<xsl:value-of select="PS.XSLTsearch:removeFirstElement($searchTermList, ' ')" /> | |
</xsl:variable> | |
<xsl:variable name="searchFieldsAttribsOnly"> | |
<xsl:variable name="sf" select="umbraco.library:Split($searchFields, ',')" /> | |
<xsl:for-each select="$sf//value"> | |
<xsl:if test="substring(., 1, 1) = '@'"> | |
<xsl:text>,</xsl:text> | |
<xsl:value-of select="substring-after(., '@') " /> | |
<xsl:text>,</xsl:text> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:variable> | |
<xsl:variable name="attribNodes" select="$yetPossibleNodes[@isDoc and attribute::*[contains($searchFieldsAttribsOnly,concat(',', name(), ',')) and contains(PS.XSLTsearch:uppercase(PS.XSLTsearch:unescapeString(umbraco.library:StripHtml(string(.)))), $searchTerm)]]" /> | |
<xsl:variable name="propertyNodes" select="$yetPossibleNodes/*[count(@isDoc) = 0 and contains($searchFields,concat(',', name(), ',')) and contains(PS.XSLTsearch:uppercase(PS.XSLTsearch:unescapeString(umbraco.library:StripHtml(string(.)))), $searchTerm) ]/.." /> | |
<xsl:variable name="evenYetPossibleNodes" select="$attribNodes | $propertyNodes" /> | |
<xsl:choose> | |
<xsl:when test="string-length($remainingSearchTermList) > 1"> | |
<!-- continue to search the rest of the terms --> | |
<xsl:call-template name="booleanAndMatchedNodes"> | |
<xsl:with-param name="yetPossibleNodes" select="$evenYetPossibleNodes" /> | |
<xsl:with-param name="searchTermList" select="$remainingSearchTermList" /> | |
</xsl:call-template> | |
</xsl:when> | |
<xsl:otherwise> | |
<!-- finished searching: return a list of the attribute @id's of the currently possible nodes as the final set of matched nodes --> | |
<xsl:variable name="nodeIDList"> | |
<xsl:text>;</xsl:text> | |
<xsl:for-each select="$evenYetPossibleNodes"> | |
<!-- @id for this node --> | |
<xsl:choose> | |
<xsl:when test="@isDoc"> | |
<xsl:value-of select="@id" /> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="../@id" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:text>;</xsl:text> | |
</xsl:for-each> | |
</xsl:variable> | |
<!-- return the actual list of id's --> | |
<xsl:value-of select="$nodeIDList" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="searchNavigationTop"> | |
<xsl:param name="page" /> | |
<xsl:param name="matchedNodes" /> | |
<xsl:variable name="sorting"> | |
<xsl:choose> | |
<xsl:when test="$sortFormVariable!=''"> | |
<xsl:value-of select="$sortFormVariable" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('sort')!=''"> | |
<xsl:value-of select="umbraco.library:RequestQueryString('sort')" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('sort')='' and $sortFormVariable=''" /> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="sort"> | |
<xsl:choose> | |
<xsl:when test="$sorting = 'd-a'">id</xsl:when> | |
<xsl:when test="$sorting = 'd-d'">id</xsl:when> | |
<xsl:when test="$sorting = 's-a'">salary</xsl:when> | |
<xsl:when test="$sorting = 's-d'">salary</xsl:when> | |
<xsl:when test="$sorting = 'r'">jobRegion</xsl:when> | |
<xsl:when test="$sorting = 'c'">jobType</xsl:when> | |
<xsl:when test="$sorting = 'd'">jobSector</xsl:when> | |
<xsl:otherwise>id</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:variable name="direction"> | |
<xsl:choose> | |
<xsl:when test="$sorting = 'd-a'">ascending</xsl:when> | |
<xsl:when test="$sorting = 'd-d'">descending</xsl:when> | |
<xsl:when test="$sorting = 's-a'">ascending</xsl:when> | |
<xsl:when test="$sorting = 's-d'">descending</xsl:when> | |
<xsl:when test="$sorting = 'r'">ascending</xsl:when> | |
<xsl:when test="$sorting = 'c'">ascending</xsl:when> | |
<xsl:when test="$sorting = 'd'">ascending</xsl:when> | |
<xsl:otherwise>descending</xsl:otherwise> | |
</xsl:choose> | |
</xsl:variable> | |
<script type="text/javascript"> | |
function applySort() | |
{ | |
var url = location.href; | |
var url_parts = url.split('?'); | |
url_parts = url_parts[0].split('/page'); | |
var main_url = url_parts[0]; | |
main_url = main_url + "?sort=" + document.getElementById('sort').value; | |
window.location = main_url; | |
//alert(main_url); | |
} | |
</script> | |
<div id="paging-top"> | |
<form action="" method="post" enctype="multipart/form-data" id="sort-menu"> | |
<fieldset> | |
<legend> | |
<label for="sort">SORT BY:</label> | |
<select onchange="javascript:applySort();" name="sort" id="sort" class="text2"> | |
<xsl:element name="option"> | |
<xsl:attribute name="value">d-d</xsl:attribute> | |
<xsl:if test="$sorting='d-d'"> | |
<xsl:attribute name="selected">selected</xsl:attribute> | |
</xsl:if> | |
Date - Newest First | |
</xsl:element> | |
<xsl:element name="option"> | |
<xsl:attribute name="value">d-a</xsl:attribute> | |
<xsl:if test="$sorting='d-a'"> | |
<xsl:attribute name="selected">selected</xsl:attribute> | |
</xsl:if> | |
Date - Oldest First | |
</xsl:element> | |
<xsl:element name="option"> | |
<xsl:attribute name="value">s-a</xsl:attribute> | |
<xsl:if test="$sorting='s-a'"> | |
<xsl:attribute name="selected">selected</xsl:attribute> | |
</xsl:if> | |
Salary Ascending | |
</xsl:element> | |
<xsl:element name="option"> | |
<xsl:attribute name="value">s-d</xsl:attribute> | |
<xsl:if test="$sorting='s-d'"> | |
<xsl:attribute name="selected">selected</xsl:attribute> | |
</xsl:if> | |
Salary Descending | |
</xsl:element> | |
<xsl:element name="option"> | |
<xsl:attribute name="value">r</xsl:attribute> | |
<xsl:if test="$sorting='r'"> | |
<xsl:attribute name="selected">selected</xsl:attribute> | |
</xsl:if> | |
Location | |
</xsl:element> | |
<xsl:element name="option"> | |
<xsl:attribute name="value">c</xsl:attribute> | |
<xsl:if test="$sorting='c'"> | |
<xsl:attribute name="selected">selected</xsl:attribute> | |
</xsl:if> | |
Contract Type | |
</xsl:element> | |
<xsl:element name="option"> | |
<xsl:attribute name="value">d</xsl:attribute> | |
<xsl:if test="$sorting='d'"> | |
<xsl:attribute name="selected">selected</xsl:attribute> | |
</xsl:if> | |
Discipline | |
</xsl:element> | |
</select> | |
</legend> | |
</fieldset> | |
</form> | |
<xsl:choose> | |
<xsl:when test="$resultsPerPage < count($matchedNodes)"> | |
<p> | |
<!--each paged set of results is listed, with a link to that page set--> | |
<xsl:call-template name="pageNumbers"> | |
<xsl:with-param name="pageIndex" select="1" /> | |
<xsl:with-param name="page" select="$page" /> | |
<xsl:with-param name="matchedNodes" select="$matchedNodes" /> | |
<xsl:with-param name="resultsPerPage" select="$resultsPerPage" /> | |
</xsl:call-template> | |
<xsl:choose> | |
<xsl:when test="$page > 1"> | |
<a id="previous"> | |
<xsl:attribute name="href"> | |
<xsl:call-template name="FriendlyURL"> | |
<xsl:with-param name="page" select="$page - 1" /> | |
</xsl:call-template> | |
</xsl:attribute> | |
Previous | |
</a> | |
</xsl:when> | |
<xsl:otherwise>Previous</xsl:otherwise> | |
</xsl:choose> | |
| | |
<xsl:choose> | |
<xsl:when test="count($matchedNodes) > $page * $resultsPerPage"> | |
<!--next page--> | |
<a id="next"> | |
<xsl:attribute name="href"> | |
<xsl:call-template name="FriendlyURL"> | |
<xsl:with-param name="page" select="$page + 1" /> | |
</xsl:call-template> | |
</xsl:attribute> | |
Next | |
</a> | |
</xsl:when> | |
<xsl:otherwise>Next</xsl:otherwise> | |
</xsl:choose> | |
</p> | |
</xsl:when> | |
<xsl:otherwise> | |
<p> </p> | |
</xsl:otherwise> | |
</xsl:choose> | |
</div> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="FriendlyURL"> | |
<xsl:param name="page" /> | |
<xsl:value-of select="XSLTHelper:ServerVariable('PATH_INFO')" /> | |
<xsl:choose> | |
<xsl:when test="umbraco.library:RequestQueryString('jobSector') !=''">/sector/<xsl:value-of select="umbraco.library:RequestQueryString('jobSector')" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('jobRegion') !=''">/region/<xsl:value-of select="umbraco.library:RequestQueryString('jobRegion')" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('jobDegree') !=''">/degree/<xsl:value-of select="umbraco.library:RequestQueryString('jobDegree')" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('jobEmployer') !=''">/employer/<xsl:value-of select="umbraco.library:RequestQueryString('jobEmployer')" /> | |
</xsl:when> | |
</xsl:choose> | |
<xsl:variable name="sorting"> | |
<xsl:choose> | |
<xsl:when test="$sortFormVariable!=''"> | |
<xsl:value-of select="$sortFormVariable" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('sort')!=''"> | |
<xsl:value-of select="umbraco.library:RequestQueryString('sort')" /> | |
</xsl:when> | |
<xsl:when test="umbraco.library:RequestQueryString('sort')='' and $sortFormVariable=''" /> | |
</xsl:choose> | |
</xsl:variable> | |
<xsl:if test="$page !=1">/page/<xsl:value-of select="$page" /> | |
<xsl:choose> | |
<xsl:when test="$sorting = 'd-a'">?sort=d-a</xsl:when> | |
<xsl:when test="$sorting = 'd-d'">?sort=d-d</xsl:when> | |
<xsl:when test="$sorting = 's-a'">?sort=s-a</xsl:when> | |
<xsl:when test="$sorting = 's-d'">?sort=s-d</xsl:when> | |
<xsl:when test="$sorting = 'r'">?sort=r</xsl:when> | |
<xsl:when test="$sorting = 'c'">?sort=c</xsl:when> | |
<xsl:when test="$sorting = 'd'">?sort=d</xsl:when> | |
<xsl:otherwise /> | |
</xsl:choose> | |
</xsl:if> | |
</xsl:template> | |
<!-- ============================================================= --> | |
<xsl:template name="feedLinks"> | |
<xsl:param name="page" /> | |
<xsl:param name="matchedNodes" /> | |
<div id="feeds"> | |
<ul> | |
<li id="rssfeed"> | |
<xsl:element name="a"> | |
<xsl:attribute name="href"> | |
feed://www.focusmanagementconsultants.co.uk/search-rss?clearsearch=1 | |
<xsl:if test="string(umbraco.library:Session('search')) !=''"> | |
&search= | |
<xsl:value-of select="string(umbraco.library:Session('search'))" /> | |
</xsl:if> | |
<xsl:if test="string(umbraco.library:Session('jobSector')) !=''"> | |
&jobSector= | |
<xsl:value-of select="XSLTHelper:Lowercase(umbraco.library:Replace(umbraco.library:GetXmlNodeById(umbraco.library:Session('jobSector'))/@nodeName, ' ', '-'))" /> | |
</xsl:if> | |
<xsl:if test="string(umbraco.library:Session('jobRegion')) !=''"> | |
&jobRegion= | |
<xsl:value-of select="XSLTHelper:Lowercase(umbraco.library:Replace(umbraco.library:GetXmlNodeById(umbraco.library:Session('jobRegion'))/@nodeName, ' ', '-'))" /> | |
</xsl:if> | |
<xsl:if test="string(umbraco.library:Session('jobEmployer')) !=''"> | |
&jobEmployer= | |
<xsl:value-of select="XSLTHelper:Lowercase(umbraco.library:Replace(umbraco.library:GetXmlNodeById(umbraco.library:Session('jobEmployer'))/@nodeName, ' ', '-'))" /> | |
</xsl:if> | |
<xsl:if test="string(umbraco.library:Session('jobDegree')) !=''"> | |
&jobDegree= | |
<xsl:value-of select="XSLTHelper:Lowercase(umbraco.library:Replace(umbraco.library:GetXmlNodeById(umbraco.library:Session('jobDegree'))/@nodeName, ' ', '-'))" /> | |
</xsl:if> | |
</xsl:attribute> | |
RSS feed | |
</xsl:element> | |
</li> | |
<xsl:variable name="Twitter" select="TwitterHelper:GetTwitterUserName()" /> | |
<xsl:if test="$Twitter !=''"> | |
<li id="twitterfeed"> | |
<a href="http://twitter.com/#!/{$Twitter}">Twitter feed</a> | |
</li> | |
</xsl:if> | |
<xsl:if test="umbraco.library:IsLoggedOn()"> | |
<xsl:choose> | |
<xsl:when test="umbraco.library:RequestQueryString('keepsearch')= '1'"> | |
<li id="savesearch"> | |
<a href="/food-jobs/save-this-search">Search Saved</a> | |
</li> | |
</xsl:when> | |
<xsl:otherwise> | |
<li id="savesearch"> | |
<a href="/food-jobs/save-this-search">Save search</a> | |
</li> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:if> | |
<xsl:if test="umbraco.library:IsLoggedOn()"> | |
<xsl:choose> | |
<xsl:when test="umbraco.library:RequestQueryString('jobByEmail')= '1'"> | |
<li id="savejobbyemail"> | |
<a href="/food-jobs/job-by-email">Alert added</a> | |
</li> | |
</xsl:when> | |
<xsl:otherwise> | |
<li id="savejobbyemail"> | |
<a href="/food-jobs/job-by-email">Jobs by Email</a> | |
</li> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:if> | |
</ul> | |
</div> | |
</xsl:template> | |
<!-- ============================================================= --> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment