Skip to content

Commit

Permalink
Use null coalescing to simplify combined search templates. (#3118)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz authored Sep 22, 2023
1 parent 3c7b1ab commit c07a8b9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions themes/bootstrap3/templates/combined/results-list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
? $this->url($advancedSearchAction, [], ['query' => ['edit' => $results->getSearchId()]])
: false;
?>
<?php if (isset($currentSearch['more_link']) && $currentSearch['more_link']): ?>
<?php if ($currentSearch['more_link'] ?? false): ?>
<div class="pull-right flip">
<a href="<?=$moreUrl?>" class="btn btn-link icon-link">
<?=$this->icon('options', 'icon-link__icon') ?>
Expand Down Expand Up @@ -85,7 +85,7 @@
];
?>
<?=$this->render('search/list-' . $viewType . '.phtml', $viewParams)?>
<?php if (isset($currentSearch['more_link']) && $currentSearch['more_link']): ?>
<?php if ($currentSearch['more_link'] ?? false): ?>
<p class="more_link_bottom">
<a class="icon-link" href="<?=$moreUrl?>">
<span class="icon-link__label"><?=$this->transEsc($currentSearch['more_link'])?></span>
Expand Down
8 changes: 4 additions & 4 deletions themes/bootstrap3/templates/combined/stack-distributed.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<?php foreach ($this->combinedResults as $searchClassId => $currentSearch): ?>
<?php
if (
(!isset($currentSearch['ajax']) || !$currentSearch['ajax']) // AJAX column
&& (isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty']) // set to hide when empty
&& $currentSearch['view']->results->getResultTotal() == 0 // and empty
!($currentSearch['ajax'] ?? false) // AJAX column
&& ($currentSearch['hide_if_empty'] ?? false) // set to hide when empty
&& $currentSearch['view']->results->getResultTotal() == 0 // and empty
) {
continue;
}
Expand Down Expand Up @@ -36,7 +36,7 @@
<div class="combined-column">
<?php foreach ($currColumn as $colParams): ?>
<div id="<?=$this->escapeHtmlAttr($colParams['domId'])?>" class="combined-list">
<?php $templateSuffix = (isset($colParams['ajax']) && $colParams['ajax']) ? 'ajax' : 'list'; ?>
<?php $templateSuffix = ($colParams['ajax'] ?? false) ? 'ajax' : 'list'; ?>
<?=$this->render('combined/results-' . $templateSuffix . '.phtml', $colParams)?>
</div>
<?php endforeach; ?>
Expand Down
10 changes: 5 additions & 5 deletions themes/bootstrap3/templates/combined/stack-left.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
?>
<?php
if (
(!isset($currentSearch['ajax']) || !$currentSearch['ajax']) // AJAX column
&& (isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty']) // set to hide when empty
&& $currentSearch['view']->results->getResultTotal() == 0 // and empty
!($currentSearch['ajax'] ?? false) // AJAX column
&& ($currentSearch['hide_if_empty'] ?? false) // set to hide when empty
&& $currentSearch['view']->results->getResultTotal() == 0 // and empty
) {
continue;
}
Expand All @@ -34,15 +34,15 @@
}
?>
<div id="<?=$this->escapeHtmlAttr($currentSearch['domId'])?>" class="combined-list">
<?php $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
<?php $templateSuffix = ($currentSearch['ajax'] ?? false) ? 'ajax' : 'list'; ?>
<?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
</div>
<?php endforeach; ?>
</div>
<?php foreach ($rightColumns as $colParams): ?>
<div class="combined-column">
<div id="<?=$this->escapeHtmlAttr($colParams['domId'])?>" class="combined-list">
<?php $templateSuffix = (isset($colParams['ajax']) && $colParams['ajax']) ? 'ajax' : 'list'; ?>
<?php $templateSuffix = ($colParams['ajax'] ?? false) ? 'ajax' : 'list'; ?>
<?=$this->render('combined/results-' . $templateSuffix . '.phtml', $colParams)?>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions themes/bootstrap3/templates/combined/stack-right.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
?>
<?php
if (
(!isset($currentSearch['ajax']) || !$currentSearch['ajax']) // AJAX column
&& (isset($currentSearch['hide_if_empty']) && $currentSearch['hide_if_empty']) // set to hide when empty
&& $currentSearch['view']->results->getResultTotal() == 0 // and empty
!($currentSearch['ajax'] ?? false) // AJAX column
&& ($currentSearch['hide_if_empty'] ?? false) // set to hide when empty
&& $currentSearch['view']->results->getResultTotal() == 0 // and empty
) {
continue;
}
?>
<div id="<?=$this->escapeHtmlAttr($currentSearch['domId'])?>" class="combined-list">
<?php $templateSuffix = (isset($currentSearch['ajax']) && $currentSearch['ajax']) ? 'ajax' : 'list'; ?>
<?php $templateSuffix = ($currentSearch['ajax'] ?? false) ? 'ajax' : 'list'; ?>
<?=$this->render('combined/results-' . $templateSuffix . '.phtml', $viewParams)?>
</div>
<?php $columnIndex ++; ?>
Expand Down

0 comments on commit c07a8b9

Please sign in to comment.