<?php
/**
 * Main template for building the portfolio single page.
 *
 * This template can be overriden from theme layer by
 * creating templates/portfolio/portfolio-single.php
 * inside the theme folder.
 *
 * @variables
 *   These variables are available for use :
 *
 *   $meta                 = array of meta data
 *   $meta['hover']        = array of meta data from post hover configuration
 *   $meta['hovericons']   = array of meta data for the hover icons
 *   $meta['fotorama']     = array of meta data for the fotorama post configuration
 *   $meta['media']        = array of media contents
 *   $meta['project']      = array of project contents
 *
 *
 *   $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
 *
 * @see VTCore_Portfolio_Templates::showContent()
 * @see VTCore_Portfolio_Config::getOption();
 * @see VTCore_Bootstrap_Grid_Column();
 * @see VTCore_Wordpress_Utility();
 * @see VTCore_Wordpress_Templates();
 *
 * @author jason.xie@victheme.com
 */
?>
<div id="portfolio-single-content" <?php post_class('single') ?>>

  <?php if ($show['title']) : ?>
    <h2 class="post-title portfolio-single-title text-center element-title">
      <?php the_title(); ?>
    </h2>
  <?php endif; ?>

  <?php if ($show['tags']) : ?>
    <div class="post-tags text-center">
      <?php echo VTCore_Portfolio_Utility::buildTaxonomyLink($post); ?>
    </div>
  <?php endif; ?>

  <?php if ($show['content'] == TRUE) : ?>
    <?php // Don't use the_content() it will produce preformatted content not just the content itself.?>
    <article
      class="post-content text-center portfolio-content <?php echo VTCore_Wordpress_Utility::getBootstrapGrid($portfolioConfig['content_column']); ?>">
      <?php echo wp_kses_post($content); ?>
    </article>
  <?php endif; ?>

  <?php if ($meta['fotorama']['enable'] == TRUE && $show['image'] == TRUE) : ?>
    <section
      class="post-gallery <?php echo VTCore_Wordpress_Utility::getBootstrapGrid($portfolioConfig['gallery_column']); ?>">
      <?php include VTCore_Wordpress_Utility::locateTemplate('portfolio-gallery.php'); ?>
    </section>
  <?php endif; ?>

  <?php if ($meta['project']['enable'] == TRUE && $show['meta'] == TRUE) : ?>
    <h3 class="post-title element-title text-center clearboth">
      <?php echo __('Project Information', BASE_THEME); ?>
    </h3>

    <div class="portfolio-project clearboth row equalheightRow">
      <?php foreach ($meta['project']['contents'] as $delta => $project) : ?>

        <?php
        // Cleaning first and skip if empty
        $project = array_filter($project);
        if (empty($project)) {
          continue;
        }
        ?>


        <div
          class="items portfolio-project-item <?php echo VTCore_Wordpress_Utility::getBootstrapGrid($portfolioConfig['project_column']); ?>">
          <?php
          // Build icon using VTCore Fontawesome class
          if (!empty($project['icon'])) {
            $icon = new VTCore_Fontawesome_faIcon($project);
            $icon->render();
          }
          ?>

          <div class="portfolio-project-inner">
            <?php if (!empty($project['title'])) : ?>
              <h3
                class="portfolio-project-title"><?php echo wp_kses_post($project['title']); ?></h3>
            <?php endif; ?>

            <?php if (!empty($project['body'])) : ?>
              <div
                class="portfolio-project-body"><?php echo wp_kses_post($project['body']); ?></div>
            <?php endif; ?>
          </div>
        </div>

      <?php endforeach; ?>
    </div>
  <?php endif; ?>

</div>