Пример #1
0
 /**
  * main class constructor
  * @param $global_config
  */
 public function __construct($global_config = '')
 {
     HW_HOANGWEB::load_class('HW_Ajax');
     if ($global_config) {
         $this->config = $global_config;
     }
     $this->setup_actions();
     $reset_logs = hw__get('clear', true);
     if (class_exists('HWIE_Logger', false)) {
         $this->logger = HWIE_Logger::get_instance($reset_logs);
     }
     //run first
 }
 /**
  * custom HTML content around metabox content
  * @param $sContent
  * @return string
  */
 public function replyToInsertContents($sContent)
 {
     //$_aOptions  = get_option( 'APF_Tabs', array() );
     $edit_menu_page = self::get_edit_menu_setting_page_link();
     $class_navname = hw__get('menu_type') == 'name' ? 'button-primary' : 'button';
     $class_navloca = hw__get('menu_type') == 'location' ? 'button-primary' : 'button';
     $btn = '<a href="javascript:void(0)" onclick="location.href=\'' . $edit_menu_page . '&menu_type=name&menu=\'+jQuery(select_menu__0).val();" class="button ' . $class_navname . '">Sửa menu (name)</a>';
     $btn .= '<a href="javascript:void(0)" onclick="location.href=\'' . $edit_menu_page . '&menu_type=location&menu=\'+jQuery(select_menu1__0).val();" class="button ' . $class_navloca . '">Sửa menu (Location)</a>';
     return $sContent . $btn;
 }
 /**
  * setup form fields
  */
 public function setUp()
 {
     $current_module_tab = hw__get('module');
     //get current module setting tab $_GET['tab']==$_GET['module']
     if (HW_HOANGWEB::is_current_screen(self::PAGE_SLUG) && hw__get('tab') && $current_module_tab && (!HW_Module::is_active($current_module_tab) || isset(self::$modules[$current_module_tab]) && !self::$modules[$current_module_tab]->option('enable_tab_settings'))) {
         wp_die('Xin lỗi: Module này chưa kích hoạt hoặc không có form cài đặt.');
     }
     // Set the root menu (http://admin-page-framework.michaeluno.jp/en/v2/classes/AdminPageFramework_Menu.html)
     #$this->setRootMenuPage( 'Settings' );        // specifies to which parent menu to add.
     $this->setRootMenuPage('(H) Cấu hình modules', HW_HOANGWEB_URL . '/images/ie-gear-icon.png');
     // Add the sub menus and the pages/ addSubMenuItems
     $this->addSubMenuItem(array('title' => 'Cấu hình modules', 'page_slug' => self::PAGE_SLUG));
     /*$this->addSubMenuItem(array(
           'title' => 'sdf',
           'href' =>  self::get_module_setting_page('abc'),
           #'page_slug'    =>    self::PAGE_SLUG
       ));*/
     //define tabs
     $this->addInPageTabs(self::PAGE_SLUG, array('tab_slug' => 'modules-config', 'title' => __('Cấu hình chung')));
     //add more tabs
     foreach (self::$modules as $name => $inst) {
         $info = HW_Plugins_Manager::get_module($name);
         if (!empty($info) && $inst->option('enable_tab_settings')) {
             $this->addInPageTab(array('tab_slug' => $name, 'title' => $info['name']));
             // load + page slug + tab slug
             add_action('load_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, '_replyToAddFormElements'));
             //triggered before rendering the page.
             add_action('do_before_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'do_before_tab_hook'));
             // triggered in the middle of rendering the page.
             add_action('do_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'do_tab_hook'));
             //triggered after rendering the page
             add_action('do_after_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'do_after_tab_hook'));
             /**
              * filters
              */
             //receives the output of the middle part of the page including form input fields.
             add_filter('content_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'content_tab_filter'));
             /*
                            ==> find in : hw-hoangweb\lib\admin-page-framework\development
                             //receives the output of the top part of the page.
                             add_filter('head_'. self::PAGE_SLUG  . '_' . self::valid_tab_slug($name), array($inst, 'head_tab_filter'));
             
                             // receives the output of the bottom part of the page.
                             add_filter('foot_'. self::PAGE_SLUG  . '_' . self::valid_tab_slug($name), array($inst, 'foot_tab_filter'));
             
                             //receives the exporting array sent from the tab page.
                             add_filter('export_'. self::PAGE_SLUG  . '_' . self::valid_tab_slug($name), array($inst, 'export_tab_filter'));
                             //receives the importing array submitted from the tab page.
                             add_filter('import_'. self::PAGE_SLUG  . '_' . self::valid_tab_slug($name), array($inst, 'import_tab_filter'));
             */
             #add_filter(''. self::PAGE_SLUG  . '_' . self::valid_tab_slug($name), array($inst, 'tab_filter'));
             //receives the output of the CSS rules applied to the tab page of the slug.
             add_filter('style_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'print_styles'));
             //receives the output of the JavaScript script applied to the tab page of the slug.
             add_filter('script_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, 'print_scripts'));
             //receives the form submission values as array. The first parameter: submitted input array. The second parameter: the original array stored in the database.
             add_filter('validation_' . self::PAGE_SLUG . '_' . self::valid_tab_slug($name), array($inst, '_validation_tab_filter'));
         }
     }
     $this->setInPageTabTag('h2');
     // sets the tag used for in-page tabs
     //submit button
     /*$this->addSettingFields(
           array(
               'field_id' => 'submit_button',
               'type' => 'submit',
               'show_title_column' => false,
           )
       );*/
 }
Пример #4
0
 /**
  * whether in current module setting page
  * @return bool
  */
 public function is_module_setting_page()
 {
     if (HW_HOANGWEB::is_current_screen(HW_Module_Settings_page::PAGE_SLUG) && hw__get('tab') == HW_Module_Settings_page::valid_tab_slug($this->option('module_name'))) {
         return true;
     }
     return false;
 }