<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php $viewer = Engine_Api::_()->user()->getViewer(); ?>
<h2><?php echo $this->translate('Search') ?></h2>
<div class="search_container">
  <?php if( empty($this->paginator) ): ?>
    <div class="no_result_tip">
      <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="No Result"></i>
      <?php echo $this->translate('Please enter a search query.') ?>
    </div>
  <?php elseif( $this->paginator->getTotalItemCount() <= 0 ): ?>
    <div class="no_result_tip">
      <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="No Result"></i>
      <p><?php echo $this->translate('No results were found.') ?></p>
    </div>

  <?php else: ?>
    <?php foreach( $this->paginator as $item ):
      $item = $this->item($item->type, $item->id);
      if( !$item ) continue; 
      $canView = $item->authorization()->isAllowed($viewer, 'view');
      if(!$canView) break;
      ?>
      <div class="search_result">
        <div class="search_photo">
          <?php echo $this->htmlLink($item->getHref(), $this->itemBackgroundPhoto($item, 'thumb.icon')) ?>
        </div>
        <div class="search_info">
          <?php if( '' != $this->query ): ?>
            <?php echo $this->htmlLink($item->getHref(), $this->highlightText(strip_tags($item->getTitle()), $this->query), array('class' => 'search_title')) ?>
          <?php else: ?>
            <?php echo $this->htmlLink($item->getHref(), $item->getTitle(), array('class' => 'search_title')) ?>
          <?php endif; ?>
          <p class="search_description">
            <?php if( '' != $this->query ): ?>
              <?php echo $this->highlightText($this->viewMore(strip_tags($item->getDescription())), $this->query); ?>
            <?php else: ?>
              <?php echo $this->viewMore($item->getDescription()); ?>
            <?php endif; ?>
          </p>
        </div>
      </div>
    <?php endforeach; ?>
    <div>
      <?php echo $this->paginationControl($this->paginator, null, null, array('query' => array('query' => $this->query, 'type' => $this->type))); ?>
    </div>
  <?php endif; ?>
</div>
<script type="application/javascript">
  en4.core.shutdown.add(function() {
    scriptJquery('#global_search_field').val('');
  });
</script>