<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
?>
<?php if( $this->tag ): ?>
  <div class="browse_result_top">
    <p>
      <?php echo $this->translate('Videos using the tag') ?>
      #
      <?php echo $this->tag ?>
      <a href="<?php echo $this->url(array('module' => 'video', 'controller' => 'index', 'action' => 'browse'), 'default', true) ?>">(x)
      </a>
    </p>
  </div>
<?php endif; ?>
<?php if( $this->paginator->getTotalItemCount() > 0 ): ?>
<div class="container no-padding video_listing">
  <div class="grid_listing">
    <?php foreach( $this->paginator as $item ): ?>
      <div class="grid_listing_item">
        <article>
          <div class="grid_listing_item_thumb">
            <?php if( $item->duration ): ?>
              <span class="item_length">
                <?php
                  if( $item->duration >= 3600 ) {
                  $duration = gmdate("H:i:s", $item->duration);
                  } else {
                  $duration = gmdate("i:s", $item->duration);
                  }
                  //$duration = ltrim($duration, '0:');
                  //              if( $duration[0] == '0' ) {
                  //                $duration= substr($duration, 1);
                  //              }
                  echo $duration;
                  ?>
              </span>
            <?php endif ?>
            <?php echo $this->htmlLink($item->getHref(), $this->itemBackgroundPhoto($item, 'thumb.normal')) ?>
          </div>
          <div class="grid_listing_item_info">
            <div class="grid_listing_item_title">
              <?php echo $this->htmlLink($item->getHref(), $item->getTitle(), array("area-label"=>$item->getTitle())) ?>
            </div>
            <div class="grid_listing_item_owner">
              <span><?php echo $this->translate('By') ?> <?php echo $this->htmlLink($item->getOwner()->getHref(), $item->getOwner()->getTitle()) ?></span>
              <span><?php echo $this->translate(array('%s view', '%s views', $item->view_count), $this->locale()->toNumber($item->view_count)) ?></span>
            </div>
          </div>
        </article>
      </div>
    <?php endforeach; ?>
  </div>
</div>
<?php elseif( $this->category || $this->tag || $this->text ):?>
  <div class="no_result_tip">
    <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="<?php echo $this->translate("No Result")?>"></i>
    <p><?php echo $this->translate('No one has posted a video with that criteria.');?></p>
    <?php if ($this->can_create):?>
      <p><?php echo $this->translate('Be the first to %1$spost%2$s one!', '<a href="'.$this->url(array('action' => 'create'), "video_general").'">', '</a>'); ?></p>
    <?php endif; ?>
  </div>
<?php else:?>
  <div class="no_result_tip">
    <i><img src="application/modules/Core/externals/images/no-results.png" height="100" width="100" alt="<?php echo $this->translate("No Result")?>"></i>
    <p><?php echo $this->translate('No one has created a video yet.');?></p>
    <?php if ($this->can_create):?>
      <p><?php echo $this->translate('Be the first to %1$spost%2$s one!', '<a href="'.$this->url(array('action' => 'create'), "video_general").'">', '</a>'); ?></p>
    <?php endif; ?>
  </div>
<?php endif; ?>
<?php echo $this->paginationControl($this->paginator, null, null, array('query' => $this->formValues, 'pageAsQuery' => true)); ?>
