/** * Creates a multiselect for use with Select2 widget. * * @return Ai1ec_Html_Element */ public static function create_select2_multiselect(array $args, array $options, array $view_args = null) { // if no data is present and we are in the frontend, return a blank element. if (empty($options) && null !== $view_args) { return self::create_blank_html_element(); } $ai1ec_events_helper = Ai1ec_Events_Helper::get_instance(); static $cached_flips = array(); $select2 = Ai1ec_Helper_Factory::create_select_instance($args['id'], $args['name']); $use_id = isset($args['use_id']); foreach ($options as $term) { $option_arguments = array(); $color = false; if ($args['type'] === 'category') { $color = $ai1ec_events_helper->get_category_color($term->term_id); } if ($color) { $option_arguments["data-color"] = $color; } if (null !== $view_args) { // create the href for ajax loading $href = self::create_href_helper_instance($view_args, $args['type']); $href->set_term_id($term->term_id); $option_arguments["data-href"] = $href->generate_href(); // check if the option is selected $type_to_check = ''; // first let's check the correct type switch ($args['type']) { case 'category': $type_to_check = 'cat_ids'; break; case 'tag': $type_to_check = 'tag_ids'; break; case 'author': $type_to_check = 'auth_ids'; break; } // let's flip the array. Just once for performance sake, // the categories doesn't change in the same request if (!isset($cached_flips[$type_to_check])) { $cached_flips[$type_to_check] = array_flip($view_args[$type_to_check]); } if (isset($cached_flips[$type_to_check][$term->term_id])) { $option_arguments["selected"] = 'selected'; } } if (true === $use_id) { $select2->add_option($term->name, $term->term_id, $option_arguments); } else { $select2->add_option($term->name, $term->name, $option_arguments); } } $select2->set_attribute("multiple", "multiple"); $select2->set_attribute("data-placeholder", $args['placeholder']); $select2->add_class('ai1ec-select2-multiselect-selector span12'); $container = Ai1ec_Helper_Factory::create_generic_html_tag('div'); if (isset($args['type'])) { $container->add_class('ai1ec-' . $args['type'] . '-filter'); } $container->add_renderable_children($select2); return $container; }
// there and i might break things if (isset($_POST['ai1ec_save_settings'])) { $ai1ec_settings->event_platform = isset($_POST['event_platform']); $ai1ec_settings->event_platform_strict = isset($_POST['event_platform_strict']); } // Set up the Routing Factory Ai1ec_Routing_Factory::set_ai1ec_settings($ai1ec_settings); // ================================ // = Initialize and setup HELPERS = // ================================ global $ai1ec_view_helper, $ai1ec_settings_helper, $ai1ec_calendar_helper, $ai1ec_app_helper, $ai1ec_events_helper, $ai1ec_importer_helper, $ai1ec_exporter_helper, $ai1ec_platform_helper, $ai1ec_localization_helper, $ai1ec_importer_plugin_helper, $ai1ec_events_list_helper; $ai1ec_view_helper = Ai1ec_View_Helper::get_instance(); $ai1ec_settings_helper = Ai1ec_Settings_Helper::get_instance(); $ai1ec_calendar_helper = Ai1ec_Calendar_Helper::get_instance(); $ai1ec_app_helper = Ai1ec_App_Helper::get_instance(); $ai1ec_events_helper = Ai1ec_Events_Helper::get_instance(); $ai1ec_importer_helper = Ai1ec_Importer_Helper::get_instance(); $ai1ec_exporter_helper = Ai1ec_Exporter_Helper::get_instance(); $ai1ec_platform_helper = Ai1ec_Platform_Helper::get_instance(); $ai1ec_localization_helper = Ai1ec_Localization_Helper::get_instance(); $ai1ec_importer_plugin_helper = Ai1ec_Importer_Plugin_Helper::get_instance(); $ai1ec_events_list_helper = Ai1ec_Events_List_Helper::get_instance(); if ('admin-ajax.php' === basename($_SERVER['SCRIPT_NAME']) && isset($_REQUEST['lang'])) { $ai1ec_localization_helper->set_language($_REQUEST['lang']); } // ==================================== // = Initialize and setup CONTROLLERS = // ==================================== global $ai1ec_app_controller, $ai1ec_settings_controller, $ai1ec_events_controller, $ai1ec_calendar_controller, $ai1ec_importer_controller, $ai1ec_exporter_controller, $ai1ec_platform_controller, $ai1ec_duplicate_controller, $ai1ec_oauth_controller, $ai1ec_logging_controller; $ai1ec_settings_controller = Ai1ec_Settings_Controller::get_instance(); $ai1ec_events_controller = Ai1ec_Events_Controller::get_instance();