<?php
/**
 * Class for defining the theme regions.
 *
 * @author jason.xie@victheme.com
 * @see VTCore_Wordpress_Layout_Region
 *
 */
class VTCore_Zeus_Layout_Regions {

  private $regions = array();

  public function getRegions() {

    // Set theme default regions
    $this->regions = array(

      // Always put sidebar on top of the array
      // simply because Wordpress is not smart enough
      // to assign default widget to proper region
      // when theme is initialized at the first time.
      'sidebar' => array(
        'parent' => 'maincontent',
        'mode' => 'dynamic',
        'weight' => 1,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '3',
            'small' => '3',
            'large' => '3',
          ),
        ),
        'arguments' => array(
          'name' => __('Sidebar', BASE_THEME),
          'id' => 'sidebar',
          'description' => __('This region can be repositioned from left to right using the theme configurations.', BASE_THEME),
          'before_title'  => '<h2 class="widgettitle element-title">',
        ),
      ),

      'logo' => array(
        'parent' => 'header',
        'mode' => 'static',
        'weight' => 0,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '3',
            'small' => '3',
            'large' => '3',
          ),
        ),
        'arguments' => array(
          'name' => __('Logo', BASE_THEME),
          'id' => 'logo',
          'description' => __('A Static region for building logo element in the header', BASE_THEME),
        ),
      ),
      'navigation' => array(
        'parent' => 'header',
        'mode' => 'static',
        'weight' => 1,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '9',
            'small' => '9',
            'large' => '9',
          ),
        ),
        'arguments' => array(
          'name' => __('Navigation', BASE_THEME),
          'id' => 'navigation',
          'description' => __('A Static region for building main navigation element in the header', BASE_THEME),
        ),
      ),
      'slider' => array(
        'parent' => 'slider',
        'mode' => 'dynamic',
        'weight' => 0,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '12',
            'small' => '12',
            'large' => '12',
          ),
        ),
        'arguments' => array(
          'name' => __('Slider', BASE_THEME),
          'id' => 'slider',
          'description' => __('Slider Region on top of the main content, suitable for slider elements.', BASE_THEME),
        ),
      ),
      'content' => array(
        'parent' => 'maincontent',
        'mode' => 'static',
        'weight' => 0,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '8',
            'small' => '8',
            'large' => '8',
          ),
        ),
        'arguments' => array(
          'name' => __('Content', BASE_THEME),
          'id' => 'content',
          'description' => __('A Static region for building content element in the main content', BASE_THEME),
        ),
      ),
      'content_bottom' => array(
        'parent' => 'content_bottom',
        'mode' => 'dynamic',
        'weight' => 0,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '12',
            'small' => '12',
            'large' => '12',
          ),
        ),
        'arguments' => array(
          'name' => __('Content Bottom', BASE_THEME),
          'id' => 'content_bottom',
          'description' => __('Full width region under the main content area', BASE_THEME),
        ),
      ),
      'footerone' => array(
        'parent' => 'footer',
        'mode' => 'dynamic',
        'weight' => 0,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '3',
            'small' => '3',
            'large' => '3',
          ),
        ),
        'arguments' => array(
          'name' => __('Footer One', BASE_THEME),
          'id' => 'footerone',
          'description' => __('First footer region, located on the left side of the footer.', BASE_THEME),
        ),
      ),
      'footertwo' => array(
        'parent' => 'footer',
        'mode' => 'dynamic',
        'weight' => 1,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '3',
            'small' => '3',
            'large' => '3',
          ),
        ),
        'arguments' => array(
          'name' => __('Footer Two', BASE_THEME),
          'id' => 'footertwo',
          'description' => __('Second footer region, located after the footer one region.', BASE_THEME),
        ),
      ),
      'footerthree' => array(
        'parent' => 'footer',
        'mode' => 'dynamic',
        'weight' => 2,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '3',
            'small' => '3',
            'large' => '3',
          ),
        ),
        'arguments' => array(
          'name' => __('Footer Three', BASE_THEME),
          'id' => 'footerthree',
          'description' => __('Third footer region, located after the footer two region.', BASE_THEME),
        ),
      ),
      'footerfour' => array(
        'parent' => 'footer',
        'mode' => 'dynamic',
        'weight' => 3,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '3',
            'small' => '3',
            'large' => '3',
          ),
        ),
        'arguments' => array(
          'name' => __('Footer Four', BASE_THEME),
          'id' => 'footerfour',
          'description' => __('Fourth footer region, located after the footer two region.', BASE_THEME),
        ),
      ),
      'copyright' => array(
        'parent' => 'fullfooter',
        'mode' => 'static',
        'weight' => 0,
        'grids' => array(
          'columns' => array(
            'mobile' => '12',
            'tablet' => '12',
            'small' => '12',
            'large' => '12',
          ),
        ),
        'arguments' => array(
          'name' => __('Copyright', BASE_THEME),
          'id' => 'copyright',
          'description' => __('Full footer copyright notice.', BASE_THEME),
        ),
      ),
    );

    // Inject user configured regions from database
    $regions = get_theme_mod('regions', array());
    $this->regions = VTCore_Utility::arrayMergeRecursiveDistinct($regions, $this->regions);

    do_action('vtcore_zeus_alter_regions', $this);

    return $this->regions;
  }


  public function setGrid($region, $grids) {
    $this->regions[$region]['grids'] = $grids;
  }

}