<?php
namespace formsio;

class AdminForms
{
    public static $class = __CLASS__;

    /**
     * @param $action_id
     * loading appropriate content when user clicks on particular menu
     */
    public static function loadFormsContents($action_id){
        global $settingsforms;
        if ($action_id == 'forms') {            
            // $forms_contents = $settingsforms['wp']['forms'];
            $forms_url = "https://infinity.500apps.com/forms?show_tab_only=forms&menu=false";
            include 'formsio_infinity.php';
        }
        if ($action_id == 'Responses') {            
            $forms_url = "https://infinity.500apps.com/forms?show_tab_only=response&menu=false";
            include 'formsio_infinity.php';
        }
        if ($action_id == 'Settings') {            
             $forms_url = "https://infinity.500apps.com/forms?show_tab_only=Settings&menu=false";
            include 'formsio_infinity.php';
        }
        if ($action_id == 'Other') {            
              $forms_contents = $settingsforms['wp']['Other'];
            include 'formsio_infinity.php';
        }
    }

    public static function action_1(){
        self::loadFormsContents('forms');
    }
    public static function action_2(){
        self::loadFormsContents('Responses');
    }
    public static function action_3(){
        self::loadFormsContents('Settings');
    }
    public static function action_4(){
        self::loadFormsContents('Other');
    }

    public static function init()
    {
        add_action('admin_menu', array(__CLASS__, 'register_formsio_menu'));
    }

    public static function register_formsio_menu(){
        global $settingsforms;
        add_menu_page($settingsforms['menus']['menu'], $settingsforms['menus']['menu'], 'manage_options', __FILE__, array(__CLASS__, 'action_1'),plugins_url('formsio/classes/images/forms-symbol.png'));
        add_submenu_page(__FILE__, $settingsforms['menus']['sub_menu_title_1'], $settingsforms['menus']['sub_menu_title_1'], 'manage_options', $settingsforms['menus']['sub_menu_url_1'], array(__CLASS__, 'action_2'));
        add_submenu_page(__FILE__, $settingsforms['menus']['sub_menu_title_2'], $settingsforms['menus']['sub_menu_title_2'], 'manage_options', $settingsforms['menus']['sub_menu_url_2'], array(__CLASS__, 'action_3'));
        add_submenu_page(__FILE__, $settingsforms['menus']['sub_menu_title_3'], $settingsforms['menus']['sub_menu_title_3'], 'manage_options', $settingsforms['menus']['sub_menu_url_3'], array(__CLASS__, 'action_4'));
    }
}
