<?php
/**
 * Simple class for integrating with TGMP script
 *
 * @author jason.xie@victheme.com
 *
 */
class VTCore_Zeus_Library_Registry {

  private $plugins = array();
  private $config;
  private $defaultPath;



  /**
   * Automatic booting
   */
  public function registerPlugin() {

    $this->defaultPath =  VTCORE_ZEUS_PLUGIN_SOURCE_PATH . DIRECTORY_SEPARATOR;
    $this->loadPlugin();
    $this->loadConfig();
    $this->activate();

  }


  /**
   * Load the plugin configuration data
   */
  private function loadPlugin() {

    $this->plugins = array(

      // VicTheme Core
      array(
        'name'               => 'VicTheme Core',
        'slug'               => 'victheme_core',
        'source'             => $this->defaultPath . 'victheme_core.zip',
        'required'           => true,
        'version'            => '1.7.5',
        'force_activation'   => true,
        'force_deactivation' => false,
        'force_install'      => true,
      ),

      // VicTheme Core
      array(
        'name'               => 'VicTheme Demo',
        'slug'               => 'victheme_demo',
        'source'             => $this->defaultPath . 'victheme_demo.zip',
        'required'           => true,
        'version'            => '1.1.1',
        'force_activation'   => true,
        'force_deactivation' => false,
        'force_install'      => true,
      ),

      // VicTheme Headline
      array(
        'name'               => 'VicTheme Headline',
        'slug'               => 'victheme_headline',
        'source'             => $this->defaultPath . 'victheme_headline.zip',
        'required'           => true,
        'version'            => '1.7.0',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),

      // Visual Composer
      array(
        'name'               => 'Visual Composer',
        'slug'               => 'js_composer',
        'source'             => $this->defaultPath .  'js_composer.zip',
        'required'           => true,
        'version'            => '4.4.4',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),

      // VicTheme Portfolio
      array(
        'name'               => 'VicTheme Portfolio',
        'slug'               => 'victheme_portfolio',
        'source'             => $this->defaultPath . 'victheme_portfolio.zip',
        'required'           => true,
        'version'            => '1.6.6',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),

      // VicTheme Maps
      array(
        'name'               => 'VicTheme Maps',
        'slug'               => 'victheme_maps',
        'source'             => $this->defaultPath . 'victheme_maps.zip',
        'required'           => false,
        'version'            => '1.6.2',
        'force_activation'   => false,
        'force_deactivation' => false,
      ),


      // VicTheme Visual Candy
      array(
        'name'               => 'VicTheme Visual Candy',
        'slug'               => 'victheme_visualcandy',
        'source'             => $this->defaultPath . 'victheme_visualcandy.zip',
        'required'           => false,
        'version'            => '1.7.1',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),


      // VicTheme Visual Bootstrap
      array(
        'name'               => 'VicTheme Visual Bootstrap',
        'slug'               => 'victheme_visualbootstrap',
        'source'             => $this->defaultPath . 'victheme_visualbootstrap.zip',
        'required'           => false,
        'version'            => '1.7.1',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),


      // VicTheme Visualplus
      array(
        'name'               => 'VicTheme VisualPlus',
        'slug'               => 'victheme_visualplus',
        'source'             => $this->defaultPath . 'victheme_visualplus.zip',
        'required'           => false,
        'version'            => '1.3.2',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),

      // VicTheme Timeline
      array(
        'name'               => 'VicTheme Timeline',
        'slug'               => 'victheme_timeline',
        'source'             => $this->defaultPath . 'victheme_timeline.zip',
        'required'           => false,
        'version'            => '1.4.0',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),


      // Revolution slider
      array(
        'name'               => 'Revolution Slider',
        'slug'               => 'revslider',
        'source'             => $this->defaultPath . 'revslider.zip',
        'required'           => false,
        'version'            => '4.6.9',
        'force_activation'   => true,
        'force_deactivation' => false,
      ),


      // Display Widget
      array(
        'name'               => 'Display Widgets',
        'slug'               => 'display-widgets',
        'source'             => $this->defaultPath . 'display-widgets.zip',
        'required'           => false,
        'force_activation'   => true,
      ),


      // Contact Form 7
      array(
        'name'               => 'Contact Form 7',
        'slug'               => 'contact-form-7',
        'source'             => $this->defaultPath . 'contact-form-7.zip',
        'required'           => false,
        'force_activation'   => true,
      ),

      // Easy Theme Upgrade
      array(
        'name'               => 'Easy Theme And Plugin Upgrade',
        'slug'               => 'easy-theme-and-plugin-upgrades',
        'source'             => $this->defaultPath . 'easy-theme-and-plugin-upgrades.zip',
        'required'           => false,
        'force_activation'   => false,
      ),

    );
  }




  /**
   * Load all the configuration data
   */
  private function loadConfig() {

    $this->config = array(
      'id'           => BASE_THEME,
      'default_path' => '',
      'menu'         => 'tgmpa-install-plugins',
      'has_notices'  => true,
      'dismissable'  => true,
      'dismiss_msg'  => '',
      'is_automatic' => true,
      'message'      => '',
      'strings'      => array(
        'page_title'                      => __( 'Install Required Plugins', BASE_THEME ),
        'menu_title'                      => __( 'Install Plugins', BASE_THEME ),
        'installing'                      => __( 'Installing Plugin: %s', BASE_THEME ), // %s = plugin name.
        'oops'                            => __( 'Something went wrong with the plugin API.', BASE_THEME ),
        'notice_can_install_required'     => _n_noop( 'This theme requires the following plugin: %1$s.', 'This theme requires the following plugins: %1$s.', BASE_THEME ), // %1$s = plugin name(s).
        'notice_can_install_recommended'  => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', BASE_THEME ), // %1$s = plugin name(s).
        'notice_cannot_install'           => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', BASE_THEME ), // %1$s = plugin name(s).
        'notice_can_activate_required'    => _n_noop( 'The following required plugin is currently inactive: %1$s.', 'The following required plugins are currently inactive: %1$s.', BASE_THEME ), // %1$s = plugin name(s).
        'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', BASE_THEME ), // %1$s = plugin name(s).
        'notice_cannot_activate'          => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', BASE_THEME ), // %1$s = plugin name(s).
        'notice_ask_to_update'            => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', BASE_THEME ), // %1$s = plugin name(s).
        'notice_cannot_update'            => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', BASE_THEME ), // %1$s = plugin name(s).
        'install_link'                    => _n_noop( 'Begin installing plugin', 'Begin installing plugins', BASE_THEME ),
        'activate_link'                   => _n_noop( 'Begin activating plugin', 'Begin activating plugins', BASE_THEME ),
        'return'                          => __( 'Return to Required Plugins Installer', BASE_THEME ),
        'plugin_activated'                => __( 'Plugin activated successfully.', BASE_THEME ),
        'complete'                        => __( 'All plugins installed and activated successfully. %s', BASE_THEME ), // %s = dashboard link.
        'nag_type'                        => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
      )
    );
  }



  /**
   * Activates the plugin dependencies
   */
  private function activate() {
    tgmpa( $this->plugins, $this->config );
  }

}