From 9e6bd9d5b6aeb89673942bc952d765bf273fe987 Mon Sep 17 00:00:00 2001
From: Eniko Tot <eniko.tot@codebrewery.hu>
Date: Mon, 5 Feb 2024 10:51:38 +0100
Subject: [PATCH] [BUGFIX] Apply missing fixes to new bootstrap 5 templates

---
 .../Private/Partials/Bootstrap5/Job.html      |  2 +-
 .../Bootstrap5/PageBrowser/Index.html         | 89 ++++++++++++++-----
 2 files changed, 69 insertions(+), 22 deletions(-)

diff --git a/Resources/Private/Partials/Bootstrap5/Job.html b/Resources/Private/Partials/Bootstrap5/Job.html
index 02dc7cbf..1a42309f 100644
--- a/Resources/Private/Partials/Bootstrap5/Job.html
+++ b/Resources/Private/Partials/Bootstrap5/Job.html
@@ -21,7 +21,7 @@
                         </f:if>
                     </li>
                     <li>
-                        <f:for each="{job.companies}" as="company" iteration="iterator">
+                        <f:for each="{job.company}" as="company" iteration="iterator">
                             {company.city}{f:if(condition: '!{iterator.isLast} || {iterator.isLast} && {job.telecommutePossible} ', then: ', ')}
                         </f:for>
                         <f:if condition="{job.telecommutePossible}">
diff --git a/Resources/Private/Templates/Bootstrap5/PageBrowser/Index.html b/Resources/Private/Templates/Bootstrap5/PageBrowser/Index.html
index becf1986..cd90f4fd 100644
--- a/Resources/Private/Templates/Bootstrap5/PageBrowser/Index.html
+++ b/Resources/Private/Templates/Bootstrap5/PageBrowser/Index.html
@@ -8,45 +8,92 @@
             <ul class="pagination">
                 <li class="page-item {f:if(condition: '!{prevPageExist}', then: 'disabled')}">
                     <f:variable name="prevPage" value="{currentPage - 1}" />
-                    <f:link.action addQueryString="1" class="page-link"
-                        additionalParams="{tx_sgjobs_pagebrowser: {currentPage: prevPage}}"
-                        additionalAttributes="{aria-label: 'Previous'}">
-                        &laquo;
-                    </f:link.action>
+                    <f:if condition="{prevPage} == 0">
+                        <f:then>
+                            <f:link.action addQueryString="untrusted" class="page-link"
+                                argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}"
+                                additionalAttributes="{aria-label: 'Previous'}">
+                                &laquo;
+                            </f:link.action>
+                        </f:then>
+                        <f:else>
+                            <f:link.action addQueryString="untrusted" class="page-link"
+                                argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}"
+                                additionalParams="{tx_sgjobs_pagebrowser: {currentPage: prevPage}}"
+                                additionalAttributes="{aria-label: 'Previous'}">
+                                &laquo;
+                            </f:link.action>
+                        </f:else>
+                    </f:if>
                 </li>
 
                 <f:if condition="{enableLessPages} && {showLessPages}">
                     <li class="page-item">
-                        <f:variable name="lessPage" value="{currentPage - 2}" />
-                        <f:link.action addQueryString="1" class="page-link"
-                            additionalParams="{tx_sgjobs_pagebrowser: {currentPage: lessPage}}">
-                            ...
-                        </f:link.action>
+                        <f:variable name="lessPage" value="{currentPage - 2}"/>
+						<f:if condition="{lessPage} == 0">
+							<f:then>
+								<f:link.action addQueryString="untrusted" class="page-link"
+                                    argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}">
+									...
+								</f:link.action>
+							</f:then>
+							<f:else>
+								<f:link.action addQueryString="untrusted" class="page-link"
+                                    argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}"
+                                    additionalParams="{tx_sgjobs_pagebrowser: {currentPage: lessPage}}">
+									...
+								</f:link.action>
+							</f:else>
+						</f:if>
                     </li>
                 </f:if>
 
                 <f:for each="{pageLinks}" as="pageLink">
-                    <li class="page-item {f:if(condition: '{pageLink.isCurrentPage}', then: 'active')}">
-                        <f:link.action addQueryString="1" class="page-link"
-                            additionalParams="{tx_sgjobs_pagebrowser: {currentPage: pageLink.page}}">
-                            {pageLink.number}
-                        </f:link.action>
-                    </li>
+                    <f:if condition="{pageLink.isCurrentPage}">
+						<f:then>
+							<li class="page-item active">
+								<a href="#" class="page-link">
+									{pageLink.number}
+								</a>
+							</li>
+						</f:then>
+						<f:else>
+							<li class="tx-pagebrowse-page">
+								<f:if condition="{pageLink.page} == 0">
+									<f:then>
+										<f:link.action addQueryString="untrusted" class="page-link"
+                                            argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}">
+											{pageLink.number}
+										</f:link.action>
+									</f:then>
+									<f:else>
+										<f:link.action addQueryString="untrusted" class="page-link"
+                                            argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}"
+                                            additionalParams="{tx_sgjobs_pagebrowser: {currentPage: pageLink.page}}">
+											{pageLink.number}
+										</f:link.action>
+									</f:else>
+								</f:if>
+							</li>
+						</f:else>
+					</f:if>
                 </f:for>
 
                 <f:if condition="{enableMorePages} && {showNextPages}">
                     <li class="page-item">
                         <f:variable name="morePage" value="{currentPage + 2}" />
-                        <f:link.action addQueryString="1" class="page"
+                        <f:link.action addQueryString="untrusted" class="page-link"
+                            argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}"
                             additionalParams="{tx_sgjobs_pagebrowser: {currentPage: morePage}}">
-                            ...
-                        </f:link.action>
+							...
+						</f:link.action>
                     </li>
                 </f:if>
 
                 <li class="page-item {f:if(condition: '!{nextPageExist}', then: 'disabled')}">
-                    <f:variable name="nextPage" value="{currentPage + 1}" />
-                    <f:link.action addQueryString="1" class="page-link"
+                    <f:variable name="nextPage" value="{currentPage + 1}"/>
+                    <f:link.action addQueryString="untrusted" class="page-link"
+                        argumentsToBeExcludedFromQueryString="{0: 'tx_sgjobs_pagebrowser'}"
                         additionalParams="{tx_sgjobs_pagebrowser: {currentPage: nextPage}}"
                         additionalAttributes="{aria-label: 'Next'}">
                         &raquo;
-- 
GitLab