<?php
/* "Copyright 2012 A3 Revolution Web Design" This software is distributed under the terms of GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 */

namespace A3Rev\WCCompare\FrameWork\Pages {

use A3Rev\WCCompare\FrameWork;

// File Security Check
if ( ! defined( 'ABSPATH' ) ) exit; 

/*-----------------------------------------------------------------------------------
WC Compare Settings Page

TABLE OF CONTENTS

- var menu_slug
- var page_data

- __construct()
- page_init()
- page_data()
- add_admin_menu()
- tabs_include()
- admin_settings_page()

-----------------------------------------------------------------------------------*/

class WC_Compare extends FrameWork\Admin_UI
{	
	/**
	 * @var string
	 */
	private $menu_slug = 'woo-compare-settings';
	
	/**
	 * @var array
	 */
	private $page_data;
	
	/*-----------------------------------------------------------------------------------*/
	/* __construct() */
	/* Settings Constructor */
	/*-----------------------------------------------------------------------------------*/
	public function __construct() {
		$this->page_init();

		if ( did_action( 'after_setup_theme' ) ) {
			$this->tabs_include();
		} else {
			add_action( 'after_setup_theme', array( $this, 'tabs_include' ) );
		}
	}
	
	/*-----------------------------------------------------------------------------------*/
	/* page_init() */
	/* Page Init */
	/*-----------------------------------------------------------------------------------*/
	public function page_init() {
		
		add_filter( $this->plugin_name . '_add_admin_menu', array( $this, 'add_admin_menu' ) );
	}
	
	/*-----------------------------------------------------------------------------------*/
	/* page_data() */
	/* Get Page Data */
	/*-----------------------------------------------------------------------------------*/
	public function page_data() {
		
		$page_data = array(
			'type'				=> 'submenu',
			'parent_slug'		=> 'woo-compare-features',
			'page_title'		=> __( 'Compare Settings & Style', 'woocommerce-compare-products' ),
			'menu_title'		=> __( 'Settings & Style', 'woocommerce-compare-products' ),
			'capability'		=> 'manage_options',
			'menu_slug'			=> $this->menu_slug,
			'function'			=> 'wc_compare_settings_page_show',
			'admin_url'			=> 'admin.php',
			'callback_function' => '',
			'script_function' 	=> '',
			'view_doc'			=> '',
		);
		
		if ( $this->page_data ) return $this->page_data;
		return $this->page_data = $page_data;
		
	}
	
	/*-----------------------------------------------------------------------------------*/
	/* add_admin_menu() */
	/* Add This page to menu on left sidebar */
	/*-----------------------------------------------------------------------------------*/
	public function add_admin_menu( $admin_menu ) {
		
		if ( ! is_array( $admin_menu ) ) $admin_menu = array();
		$admin_menu[] = $this->page_data();
		
		return $admin_menu;
	}
	
	/*-----------------------------------------------------------------------------------*/
	/* tabs_include() */
	/* Include all tabs into this page
	/*-----------------------------------------------------------------------------------*/
	public function tabs_include() {

		global $wc_compare_global_tab;
		$wc_compare_global_tab = new FrameWork\Tabs\Global_Settings();

		global $wc_compare_product_page_tab;
		$wc_compare_product_page_tab = new FrameWork\Tabs\Product_Page();

		global $wc_compare_widget_style_tab;
		$wc_compare_widget_style_tab = new FrameWork\Tabs\Widget_Style();

		global $wc_compare_gridview_style_tab;
		$wc_compare_gridview_style_tab = new FrameWork\Tabs\GridView_Style();

		global $wc_comparison_page_tab;
		$wc_comparison_page_tab = new FrameWork\Tabs\Comparison_Page();
		
	}
	
	/*-----------------------------------------------------------------------------------*/
	/* admin_settings_page() */
	/* Show Settings Page */
	/*-----------------------------------------------------------------------------------*/
	public function admin_settings_page() {		
		$GLOBALS[$this->plugin_prefix.'admin_init']->admin_settings_page( $this->page_data() );
	}
	
}

}

// global code
namespace {

/** 
 * wc_compare_settings_page_show()
 * Define the callback function to show page content
 */
function wc_compare_settings_page_show() {
	global $wc_compare_settings_page;
	$wc_compare_settings_page->admin_settings_page();
}

}
