/** * Create the array needed for translation and passing other settings to JS. * * @return $data array the dynamic data array */ private function get_translation_data() { global $ai1ec_importer_plugin_helper; $lang = $this->events_helper->get_lang(); $data = array('select_one_option' => __('Select at least one user/group/page to subscribe to.', AI1EC_PLUGIN_NAME), 'error_no_response' => __('An unexpected error occurred. Try reloading the page.', AI1EC_PLUGIN_NAME), 'no_more_subscription' => __('No subscriptions yet!', AI1EC_PLUGIN_NAME), 'no_more_than_ten' => __('Please select no more than ten users/groups/pages at a time to avoid overloading Facebook requests.', AI1EC_PLUGIN_NAME), 'duplicate_feed_message' => esc_html__('This feed is already being imported.', AI1EC_PLUGIN_NAME), 'invalid_url_message' => esc_html__('Please enter a valid iCalendar URL.', AI1EC_PLUGIN_NAME), 'invalid_email_message' => esc_html__('Please enter a valid e-mail address.', AI1EC_PLUGIN_NAME), 'now' => $this->events_helper->gmt_to_local(Ai1ec_Time_Utility::current_time()), 'date_format' => $this->settings->input_date_format, 'month_names' => $this->ai1ec_locale->get_localized_month_names(), 'day_names' => $this->ai1ec_locale->get_localized_week_names(), 'week_start_day' => $this->settings->week_start_day, 'twentyfour_hour' => $this->settings->input_24h_time, 'region' => $this->settings->geo_region_biasing ? $this->events_helper->get_region() : '', 'disable_autocompletion' => $this->settings->disable_autocompletion, 'error_message_not_valid_lat' => __('Please enter a valid latitude. A valid latitude is comprised between +90 and -90.', AI1EC_PLUGIN_NAME), 'error_message_not_valid_long' => __('Please enter a valid longitude. A valid longitude is comprised between +180 and -180.', AI1EC_PLUGIN_NAME), 'error_message_not_entered_lat' => __('When the "Input coordinates" checkbox is checked, "Latitude" is a required field.', AI1EC_PLUGIN_NAME), 'error_message_not_entered_long' => __('When the "Input coordinates" checkbox is checked, "Longitude" is a required field.', AI1EC_PLUGIN_NAME), 'language' => $lang, 'page' => '', 'page_on_front_description' => __('This setting cannot be changed in Event Platform mode.', AI1EC_PLUGIN_NAME), 'strict_mode' => $this->settings->event_platform_strict, 'platform_active' => $this->settings->event_platform_active, 'facebook_logged_in' => $ai1ec_importer_plugin_helper->check_if_we_have_a_valid_facebook_access_token(), 'app_id_and_secret_are_required' => __("You must specify both an app ID and app secret to connect to Facebook.", AI1EC_PLUGIN_NAME), 'ajax_url' => admin_url('admin-ajax.php'), 'url_not_valid' => __("The URL you have entered seems to be invalid. Please remember that URLs must start with either 'http://' or 'https://'.", AI1EC_PLUGIN_NAME), 'mail_url_required' => __("Both the <em>calendar URL</em> and <em>e-mail address</em> fields are required.", AI1EC_PLUGIN_NAME), 'confirm_reset_theme' => __("Are you sure you want to reset your theme options to their default values?", AI1EC_PLUGIN_NAME)); return $data; }
/** * get_instance function * * Return singleton instance * * @return object **/ static function get_instance() { if (self::$_instance === NULL) { self::$_instance = new self(); } return self::$_instance; }
/** * Create the array needed for translation and passing other settings to JS. * * @return $data array the dynamic data array */ private function get_translation_data() { global $ai1ec_importer_plugin_helper; $force_ssl_admin = force_ssl_admin(); if ($force_ssl_admin && !is_ssl()) { force_ssl_admin(false); } $ajax_url = admin_url('admin-ajax.php'); force_ssl_admin($force_ssl_admin); $data = array('select_one_option' => __('Select at least one user/group/page to subscribe to.', AI1EC_PLUGIN_NAME), 'is_calendar_page' => isset($_GET[self::IS_CALENDAR_PAGE]) && $_GET[self::IS_CALENDAR_PAGE] === self::TRUE_PARAM, 'error_no_response' => __('An unexpected error occurred. Try reloading the page.', AI1EC_PLUGIN_NAME), 'no_more_subscription' => __('No subscriptions yet!', AI1EC_PLUGIN_NAME), 'no_more_than_ten' => __('Please select no more than ten users/groups/pages at a time to avoid overloading Facebook requests.', AI1EC_PLUGIN_NAME), 'duplicate_feed_message' => esc_html__('This feed is already being imported.', AI1EC_PLUGIN_NAME), 'invalid_url_message' => esc_html__('Please enter a valid iCalendar URL.', AI1EC_PLUGIN_NAME), 'invalid_email_message' => esc_html__('Please enter a valid e-mail address.', AI1EC_PLUGIN_NAME), 'now' => $this->events_helper->gmt_to_local(Ai1ec_Time_Utility::current_time()), 'date_format' => $this->settings->input_date_format, 'month_names' => $this->ai1ec_locale->get_localized_month_names(), 'day_names' => $this->ai1ec_locale->get_localized_week_names(), 'week_start_day' => $this->settings->week_start_day, 'twentyfour_hour' => $this->settings->input_24h_time, 'region' => $this->settings->geo_region_biasing ? $this->events_helper->get_region() : '', 'disable_autocompletion' => $this->settings->disable_autocompletion, 'error_message_not_valid_lat' => __('Please enter a valid latitude. A valid latitude is comprised between +90 and -90.', AI1EC_PLUGIN_NAME), 'error_message_not_valid_long' => __('Please enter a valid longitude. A valid longitude is comprised between +180 and -180.', AI1EC_PLUGIN_NAME), 'error_message_not_entered_lat' => __('When the "Input coordinates" checkbox is checked, "Latitude" is a required field.', AI1EC_PLUGIN_NAME), 'error_message_not_entered_long' => __('When the "Input coordinates" checkbox is checked, "Longitude" is a required field.', AI1EC_PLUGIN_NAME), 'language' => $this->events_helper->get_lang(), 'page' => '', 'page_on_front_description' => __('This setting cannot be changed in Event Platform mode.', AI1EC_PLUGIN_NAME), 'strict_mode' => $this->settings->event_platform_strict, 'platform_active' => $this->settings->event_platform_active, 'facebook_logged_in' => $ai1ec_importer_plugin_helper->check_if_we_have_a_valid_facebook_access_token(), 'app_id_and_secret_are_required' => __('You must specify both an app ID and app secret to connect to Facebook.', AI1EC_PLUGIN_NAME), 'file_upload_required' => __('You must specify a valid file to upload or paste your data into the text field.', AI1EC_PLUGIN_NAME), 'file_upload_not_permitted' => __('Only .ics and .csv files are supported.', AI1EC_PLUGIN_NAME), 'ajax_url' => $ajax_url, 'url_not_valid' => __('The URL you have entered seems to be invalid. Please remember that URLs must start with either "http://" or "https://".', AI1EC_PLUGIN_NAME), 'mail_url_required' => __('Both the <em>calendar URL</em> and <em>e-mail address</em> fields are required.', AI1EC_PLUGIN_NAME), 'confirm_reset_theme' => __('Are you sure you want to reset your theme options to their default values?', AI1EC_PLUGIN_NAME), 'license_key' => $this->settings->get_license_key(), 'reset_saved_filter_text' => __('Save this filter as default', AI1EC_PLUGIN_NAME), 'clear_saved_filter_text' => __('Remove default filter', AI1EC_PLUGIN_NAME), 'save_filter_text_ok' => __('The active filter has been saved as your default for this calendar.', AI1EC_PLUGIN_NAME), 'remove_filter_text_ok' => __('Your default calendar filter has been removed.', AI1EC_PLUGIN_NAME), 'size_less_variable_not_ok' => __('The value you have entered is not a valid CSS length.', AI1EC_PLUGIN_NAME), 'week_view_starts_at' => $this->settings->week_view_starts_at, 'week_view_ends_at' => $this->settings->week_view_ends_at, 'end_must_be_after_start' => __('The end date can\'t be earlier than the start date.', AI1EC_PLUGIN_NAME), 'show_at_least_six_hours' => __('For week and day view, you must select an interval of at least 6 hours.', AI1EC_PLUGIN_NAME), 'label_buy_tickets_url' => __('Buy tickets URL (optional)', AI1EC_PLUGIN_NAME), 'label_rsvp_url' => __('Registration URL (optional)', AI1EC_PLUGIN_NAME), 'label_a_buy_tickets_url' => __('Buy Tickets URL:', AI1EC_PLUGIN_NAME), 'label_a_rsvp_url' => __('Registration URL:', AI1EC_PLUGIN_NAME), 'event_price_not_entered' => __('Please enter an event cost, or mark the event as free.', AI1EC_PLUGIN_NAME), 'blog_timezone' => Ai1ec_Meta::get_option('gmt_offset'), 'use_select2' => $this->settings->use_select2_widgets, 'require_desclaimer' => __('If you choose to require a disclaimer on the front-end event creation form, you must provide the disclaimer text (HTML allowed) in the appropriate field.', AI1EC_PLUGIN_NAME)); return $data; }
/** * 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();