<?
  // Set up page title:
  $lookfor = $this->results->getUrlQuery()->isQuerySuppressed() ? '' : $this->params->getDisplayQuery();
  if (isset($this->overrideTitle)) {
      $this->headTitle($this->overrideTitle);
  } else {
      $this->headTitle($this->translate('Search Results') . (empty($lookfor) ? '' : " - {$lookfor}"));
  }

  // Set up search box:
  $this->layout()->searchbox = $this->context($this)->renderInContext(
      'search/searchbox.phtml',
      [
        'lookfor' => $lookfor,
        'searchIndex' => $this->params->getSearchHandler(),
        'searchType' => $this->params->getSearchType(),
        'searchId' => $this->results->getSearchId(),
        'searchClassId' => $this->params->getSearchClassId(),
        'checkboxFilters' => $this->params->getCheckboxFacets(),
        'filterList' => $this->params->getFilters(),
        'hasDefaultsApplied' => $this->params->hasDefaultsApplied(),
        'selectedShards' => $this->params->getSelectedShards(),
        'ignoreHiddenFiltersInRequest' => isset($this->ignoreHiddenFiltersInRequest) ? $this->ignoreHiddenFiltersInRequest : false,
        'ignoreHiddenFilterMemory' => isset($this->ignoreHiddenFilterMemory) ? $this->ignoreHiddenFilterMemory : false,
      ]
  );

    // Set up breadcrumbs:
    if (isset($this->overrideTitle)) {
        $this->layout()->breadcrumbs .= '<li class="active">' . $this->escapeHtml($this->overrideTitle) . '</li>';
    } else {
        $this->layout()->breadcrumbs .= '<li class="active">' . $this->transEsc('Search') . ': ' . $this->escapeHtml($lookfor) . '</li>';
    }


// Enable cart if appropriate:
  $this->showBulkOptions = $this->params->getOptions()->supportsCart() && $this->showBulkOptions;
  // Checkboxes if appropriate:
  $this->showCartControls = $this->params->getOptions()->supportsCart() && $this->cart()->isActive()
    && ($this->showBulkOptions || !$this->cart()->isActiveInSearch());
  // Enable bulk options if appropriate:
  $this->showCheckboxes = $this->showCartControls || $this->showBulkOptions;

  // Load Javascript only if list view parameter is NOT full:
  if ($this->params->getOptions()->getListViewOption() != "full") {
    $this->headScript()->appendFile("record.js");
    $this->headScript()->appendFile("embedded_record.js");
  }

  // Load Javascript dependencies into header:
  $this->headScript()->appendFile("check_item_statuses.js");
  $this->headScript()->appendFile("check_save_statuses.js");
  $this->headScript()->appendFile("accordion.js");
?>

<div class="<?=$this->layoutClass('mainbody')?>">


  <? if (($recordTotal = $this->results->getResultTotal()) > 0): // only display these at very top if we have results ?>

      <nav class="search-header hidden-print">
          <div class="search-stats">
              <? if ($recordTotal > 0): ?>
                  <?=$this->context()->renderInContext('search/controls/showing.phtml', ['lookfor' => $lookfor, 'recordTotal' => $recordTotal]) ?>
              <? else: ?>
                  <h2><?=$this->transEsc('nohit_heading')?></h2>
              <? endif; ?>
          </div>
      </nav>

        <div class="sortierung"> 
          <? if ($recordTotal > 0): ?>
              <div class="search-controls"> 
                  <?=$this->render('search/controls/limit.phtml')?>
                  <?=$this->render('search/controls/sort.phtml')?>
                  <?=$this->render('search/controls/view.phtml')?>
	      </div>
          <? endif; ?>
       </div> 

  <? endif; ?>
  <?=$this->flashmessages()?>

  <? /* End Listing Options */ ?>

  <? if ($recordTotal < 1): ?>
    <p>
      <? if (isset($this->overrideEmptyMessage)): ?>
        <?=$this->overrideEmptyMessage?>
      <? else: ?>
        <? $this->layout()->srmessage = $this->translate('nohit_lookfor_html', ['%%lookfor%%' => $this->escapeHtml($lookfor)]); ?>
        <?=$this->layout()->srmessage ?>
      <? endif; ?>
    </p>
    <? if (isset($this->parseError)): ?>
      <p class="alert alert-danger"><?=$this->transEsc('nohit_parse_error')?></p>
    <? endif; ?>
    <? foreach (($top = $this->results->getRecommendations('top')) as $current): ?>
      <?=$this->recommend($current)?>
    <? endforeach; ?>
    <? foreach ($this->results->getRecommendations('noresults') as $current): ?>
      <? if (!in_array($current, $top)): ?>
        <?=$this->recommend($current)?>
      <? endif; ?>
    <? endforeach; ?>
  <? else: ?>
      <div class="ergebnisse">
        <span id="ergebnisliste"><?=$this->transEsc("Resultlist")?></span>
      </div>
      <div id="ergebnisfunktion" class="ergebnisfunktion">
        <span><?=$this->transEsc("Result Selection")?></span>
      </div>
      <div id="suchauswahl" class="show-content suchauswahl">   
        <form id="search-cart-form" method="get" name="bulkActionForm" action="<?=$this->url('cart-searchresultsbulk')?>" data-lightbox data-lightbox-onsubmit="bulkFormHandler">
          <?=$this->context($this)->renderInContext('search/bulk-action-buttons.phtml', ['idPrefix' => ''])?>
        </form>
      </div>  
        <?=$this->render('search/list-' . $this->params->getView() . '.phtml')?>
        <?=$this->paginationControl($this->results->getPaginator(), 'Sliding', 'search/pagination.phtml', ['results' => $this->results, 'options' => isset($this->paginationOptions) ? $this->paginationOptions : []])?>
      <div class="clear"></div>
      <div id="ergebnisfunktion2" class="ergebnisfunktion">
              <span><?=$this->transEsc("Result Selection")?></span>
            </div>
      <div id="suchauswahl2" class="show-content suchauswahl">
          <form id="search-cart-form" method="get" name="bulkActionForm" action="<?=$this->url('cart-searchresultsbulk')?>" data-lightbox data-lightbox-onsubmit="bulkFormHandler">
              <?=$this->context($this)->renderInContext('search/bulk-action-buttons.phtml', ['idPrefix' => 'bottom_'])?>
          </form>
      </div>

      <div class="searchtools hidden-print">
      <strong><?=$this->transEsc('Search Tools')?>:</strong>
      <a href="<?=$this->results->getUrlQuery()->setViewParam('rss')?>"><i class="fa fa-bell" aria-hidden="true"></i> <?=$this->transEsc('Get RSS Feed')?></a>
          |
      <a href="<?=$this->url('search-email')?>" class="mailSearch" data-lightbox id="mailSearch<?=$this->escapeHtmlAttr($this->results->getSearchId())?>">
        <i class="fa fa-envelope" aria-hidden="true"></i> <?=$this->transEsc('Email this Search')?>
      </a>
      <? if ($this->accountCapabilities()->getSavedSearchSetting() === 'enabled'): ?>
          |
        <? if (is_numeric($this->results->getSearchId())): ?>
          <? if ($this->results->isSavedSearch()): ?>
            <a href="<?=$this->url('myresearch-savesearch')?>?delete=<?=urlencode($this->results->getSearchId())?>"><i class="fa fa-remove" aria-hidden="true"></i> <?=$this->transEsc('save_search_remove')?></a>
          <? else: ?>
            <a href="<?=$this->url('myresearch-savesearch')?>?save=<?=urlencode($this->results->getSearchId())?>"><i class="fa fa-save" aria-hidden="true"></i> <?=$this->transEsc('save_search')?></a>
          <? endif; ?>
        <? endif; ?>
      <? endif; ?>
    </div>
  <? endif; ?>
</div>
<? /* End Main Listing */ ?>

<? /* Narrow Search Options */ ?>
<div class="<?=$this->layoutClass('sidebar')?>">
  <? foreach ($this->results->getRecommendations('side') as $current): ?>
    <?=$this->recommend($current)?>
  <? endforeach; ?>
</div>
<? /* End Narrow Search Options */ ?>
