<?php
/**
 * Template for portfolio teasers grid content
 *
 * This template must be called inside a loop.
 * and the loop must be related to portfolio post
 * items.
 *
 * See portfolio-loop.php on how to create custom
 * loop and pass them into this template.
 *
 * @variables
 *
 * $this                 = depending on how this theme is called
 * $post                 = the item post object
 * $portfolioConfig               = array of global configurations specially for the full page one.
 * $show                 = array of configured what to show or hide
 * $portfolioConfigObject         = the configuration object that can be used for retrieving
 *                           single configured settings via getOption($type, $key, $subkey) method
 *
 *
 * All variables will be available if this template is called via :
 *    $templates = new VTCore_Portfolio_Templates()
 *    include $templates->getTemplatePart('portfolio-grid');
 *
 * and from portfolio-content.php or other parent template
 * that perform the same booting process as portfolio-content.php
 *
 * @see portfolio-loop.php
 * @author jason.xie@victheme.com
 */
?>
<?php

// Precaution if user didn't load this template properly.
if (!isset($post)) {
  global $post;
}

if (!isset($portfolioConfigObject)) {
  $portfolioConfigObject = new VTCore_Portfolio_Config();
  $portfolioConfig = $portfolioConfigObject->get('grid');
  $show = $portfolioConfig['show'];
}

$meta = get_post_meta($post->ID, '_portfolio_data', array());
$meta = array_pop($meta);
?>
<li class="isotope-item items <?php echo esc_attr($teasercolumn); ?>"
    data-id="<?php echo esc_attr(implode(' ', $slug)); ?>"
    data-rowmode="min-height">

  <div id="post-<?php the_ID(); ?>"
    <?php post_class('list-mode clearfix'); ?>>

    <div class="portfolio-list-left col-xs-12 col-sm-4 col-md-4 col-lg-4">

      <?php if ($show['image']) : ?>
        <a class="teaser-hover"
           href="<?php echo esc_attr(get_post_permalink($post->ID)); ?>">
          <figure
            class="post-thumbnail vertical-center"
            data-aspect="true"
            data-vertical-force="true">

            <?php echo wp_kses_post(VTCore_Portfolio_Utility::processThumbnail($post, $meta)); ?>

            <div class="mask">
              <div class="vertical-target">
                <i class="fa fa-search"></i>
                <i class="fa fa-link"></i>
              </div>
            </div>

          </figure>
        </a>
      <?php endif; ?>
    </div>


    <div class="portfolio-info text-left col-xs-12 col-sm-8 col-md-8 col-lg-8">

      <h3 class="post-title">
        <a
          href="<?php echo esc_url(get_post_permalink($post->ID)); ?>"><?php the_title(); ?></a>
      </h3>

      <?php $tags = VTCore_Portfolio_Utility::buildTaxonomyLink($post); ?>
      <?php if (!empty($tags)) : ?>
        <div class="post-portfolio-tags">
          <?php
          $icon = new VTCore_Fontawesome_faIcon(array(
            'icon' => 'tag',
            'flip' => 'horizontal',
          ));

          $icon->render();
          ?>
          <?php echo wp_kses_post($tags); ?>
        </div>
      <?php endif; ?>

      <div class="post-date">
        <?php echo wp_kses_post(get_the_date()); ?>
      </div>

      <div class="post-excerpt"><?php the_excerpt(); ?></div>

      <div class="row post-bottom">
        <div class="post-social text-left col-sm-6">
          <?php
          $social = new VTCore_Wordpress_Element_WpSocialShare();
          $social->render();
          ?>
        </div>

        <div class="post-button clearfix col-sm-6">
          <?php if ($show['readmore']) : ?>
            <a class="btn pull-right"
               href="<?php echo get_post_permalink($post->ID); ?>">
              <?php echo __('Read More', BASE_THEME); ?>
            </a>
          <?php endif; ?>
        </div>
      </div>

    </div>


  </div>
</li>