<?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 <?php echo esc_attr($teasercolumn); ?>"
    data-id="<?php echo esc_attr(implode(' ', $slug)); ?>">

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

    <?php if ($show['image']) : ?>
      <a class="teaser-hover"
         href="<?php echo esc_url(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 class="hover-title">
                <?php the_title(); ?>
              </div>
            </div>
          </div>

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


    <?php if ($show['title'] || $show['date'] || $show['social'] || $show['tags']) : ?>
      <div class="portfolio-info">

        <?php if ($show['title']) : ?>
          <h4 class="post-title">
            <a
              href="<?php echo esc_url(get_post_permalink($post->ID)); ?>"><?php the_title(); ?></a>
          </h4>
        <?php endif; ?>

        <?php if ($show['date']) : ?>
          <div class="post-date">
            <?php echo wp_kses_post(get_the_date()); ?>
          </div>
        <?php endif; ?>

        <?php $tags = VTCore_Portfolio_Utility::buildTaxonomyLink($post); ?>
        <?php if ($show['tags'] && !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; ?>

        <?php if ($show['excerpt']) : ?>
          <div class="hidden-xs view-content"><?php the_excerpt(); ?></div>
        <?php endif; ?>

        <?php if ($show['social']) : ?>
          <div class="post-social text-center">
            <?php
            $social = new VTCore_Wordpress_Element_WpSocialShare();
            $social->render();
            ?>
          </div>
        <?php endif; ?>

        <?php if ($show['readmore']) : ?>
          <a class="btn" href="<?php echo esc_url(get_post_permalink($post->ID)); ?>">
            <?php echo __('more..', BASE_THEME); ?>
          </a>
        <?php endif; ?>


      </div>
    <?php endif; ?>


  </div>
</li>