/** * instance method * * Singleton creation method, to allow saving resources and having single * object instance throughout system. * * @return Ai1ec_Time_Utility Single instance of self */ public static function instance() { if (!self::$_instance instanceof Ai1ec_Time_Utility) { self::$_instance = new Ai1ec_Time_Utility(); } return self::$_instance; }
/** * Create the html element used as the UI control for the datepicker button. * The href must keep only active filters. * * @param array $args Populated args for the view * @param int|string|null $initial_date The datepicker's initially set date * @return Ai1ec_Generic_Html_Tag */ public static function create_datepicker_link(array $args, $initial_date = null) { global $ai1ec_settings, $ai1ec_view_helper; $link = Ai1ec_Helper_Factory::create_generic_html_tag('a'); $date_format_pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($ai1ec_settings->input_date_format); if ($initial_date == null) { // If exact_date argument was provided, use its value to initialize // datepicker. if (isset($args['exact_date']) && $args['exact_date'] !== false && $args['exact_date'] !== null) { $initial_date = $args['exact_date']; } else { $initial_date = Ai1ec_Time_Utility::gmt_to_local(Ai1ec_Time_Utility::current_time()); } } // Convert initial date to formatted date if required. if (Ai1ec_Validation_Utility::is_valid_time_stamp($initial_date)) { $initial_date = Ai1ec_Time_Utility::format_date(Ai1ec_Time_Utility::gmt_to_local($initial_date), $ai1ec_settings->input_date_format); } $link->add_class('ai1ec-minical-trigger btn'); $link->set_attribute('data-date', $initial_date); $link->set_attribute('data-date-format', $date_format_pattern); $link->set_attribute('data-date-weekstart', $ai1ec_settings->week_start_day); $link->set_attribute_expr($args['data_type']); $text = '<img src="' . esc_attr($ai1ec_view_helper->get_theme_img_url('date-icon.png')) . '" class="ai1ec-icon-datepicker" />'; $link->set_text($text); $href_args = array('action' => $args['action'], 'cat_ids' => $args['cat_ids'], 'tag_ids' => $args['tag_ids'], 'exact_date' => "__DATE__"); $data_href = self::create_href_helper_instance($href_args); $link->set_attribute('data-href', $data_href->generate_href()); $link->set_attribute('href', '#'); return $link; }
/** * Creates the output of the RSS feed. * * @param boolean $comment ( ignored ) */ public function create_feed_output($comment) { global $ai1ec_calendar_helper, $ai1ec_view_helper, $ai1ec_events_helper, $ai1ec_settings; $number_of_posts = Ai1ec_Meta::get_option('posts_per_rss'); // Get the request parser $request = new Ai1ec_Arguments_Parser(NULL, 'ai1ec_' . $ai1ec_settings->default_calendar_view); $request->parse(); // Create the filter $filter = array('cat_ids' => $request->get('cat_ids'), 'tag_ids' => $request->get('tag_ids'), 'post_ids' => $request->get('post_ids')); $event_results = $ai1ec_calendar_helper->get_events_relative_to($ai1ec_events_helper->gmt_to_local(Ai1ec_Time_Utility::current_time()), $number_of_posts, 0, $filter, 0); require_once AI1EC_VIEW_PATH . '/event-feed-rss2.php'; }
/** * Check if the date supplied is valid. It validates date in the format given * by $pattern, which matches one of the supported date patterns. * @see Ai1ec_Time_Utility::get_date_patterns() * * @param string $date Date string to parse * @param string $pattern Key of date pattern (@see * Ai1ec_Time_Utility::get_date_patterns()) to * match date string against * @return array|boolean An array with the parsed date or false if the date * is not valid */ public static function validate_date_and_return_parsed_date($date, $pattern = 'def') { // Convert pattern to regex. $pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($pattern); $pattern = preg_quote($pattern, '/'); $pattern = str_replace(array('dd', 'd', 'mm', 'm', 'yyyy', 'yy'), array('(?P<d>\\d{2})', '(?P<d>\\d{1,2})', '(?P<m>\\d{2})', '(?P<m>\\d{1,2})', '(?P<y>\\d{4})', '(?P<y>\\d{2})'), $pattern); // Accept hyphens and dots in place of forward slashes (for URLs). $pattern = str_replace('\\/', '[\\/\\-\\.]', $pattern); $pattern = "/^{$pattern}\$/"; if (preg_match($pattern, $date, $matches)) { if (checkdate($matches['m'], $matches['d'], $matches['y'])) { return array("month" => $matches['m'], "day" => $matches['d'], "year" => $matches['y']); } } return false; }
/** * get_repeat_box function * * @return string **/ function get_repeat_box() { global $ai1ec_view_helper; $repeat = (int) $_REQUEST["repeat"]; $repeat = $repeat == 1 ? 1 : 0; $post_id = (int) $_REQUEST["post_id"]; $count = 100; $end = null; $until = Ai1ec_Time_Utility::current_time(true); // try getting the event try { $event = new Ai1ec_Event($post_id); $rule = ''; if ($repeat) { $rule = empty($event->recurrence_rules) ? '' : $event->recurrence_rules; } else { $rule = empty($event->exception_rules) ? '' : $event->exception_rules; } $rc = new SG_iCal_Recurrence(new SG_iCal_Line('RRULE:' . $rule)); if ($until = $rc->getUntil()) { $until = is_numeric($until) ? $until : strtotime($until); } else { if ($count = $rc->getCount()) { $count = is_numeric($count) ? $count : 100; } } } catch (Ai1ec_Event_Not_Found $e) { /* event wasn't found, keep defaults */ } $args = array('row_daily' => $this->row_daily(), 'row_weekly' => $this->row_weekly(), 'row_monthly' => $this->row_monthly(), 'row_yearly' => $this->row_yearly(), 'count' => $this->create_count_input('ai1ec_count', $count) . __('times', AI1EC_PLUGIN_NAME), 'end' => $this->create_end_dropdown($end), 'until' => $until, 'repeat' => $repeat); $output = array("error" => false, "message" => $ai1ec_view_helper->get_admin_view('box_repeat.php', $args), "repeat" => $repeat); echo json_encode($output); exit; }
/** * export_events function * * Export events * * @return void **/ function export_events() { global $ai1ec_events_helper, $ai1ec_exporter_helper, $ai1ec_localization_helper; $ai1ec_cat_ids = !empty($_REQUEST['ai1ec_cat_ids']) ? $_REQUEST['ai1ec_cat_ids'] : false; $ai1ec_tag_ids = !empty($_REQUEST['ai1ec_tag_ids']) ? $_REQUEST['ai1ec_tag_ids'] : false; $ai1ec_post_ids = !empty($_REQUEST['ai1ec_post_ids']) ? $_REQUEST['ai1ec_post_ids'] : false; if (!empty($_REQUEST['lang'])) { $ai1ec_localization_helper->set_language($_REQUEST['lang']); } $filter = array(); if ($ai1ec_cat_ids) { $filter['cat_ids'] = explode(',', $ai1ec_cat_ids); } if ($ai1ec_tag_ids) { $filter['tag_ids'] = explode(',', $ai1ec_tag_ids); } if ($ai1ec_post_ids) { $filter['post_ids'] = explode(',', $ai1ec_post_ids); } // when exporting events by post_id, do not look up the event's start/end date/time $start = $ai1ec_post_ids !== false ? false : Ai1ec_Time_Utility::current_time(true) - 24 * 60 * 60; // Include any events ending today $end = false; $c = new vcalendar(); $c->setProperty('calscale', 'GREGORIAN'); $c->setProperty('method', 'PUBLISH'); $c->setProperty('X-WR-CALNAME', get_bloginfo('name')); $c->setProperty('X-WR-CALDESC', get_bloginfo('description')); $c->setProperty('X-FROM-URL', home_url()); // Timezone setup $tz = Ai1ec_Meta::get_option('timezone_string'); if ($tz) { $c->setProperty('X-WR-TIMEZONE', $tz); $tz_xprops = array('X-LIC-LOCATION' => $tz); iCalUtilityFunctions::createTimezone($c, $tz, $tz_xprops); } $events = $ai1ec_events_helper->get_matching_events($start, $end, $filter); foreach ($events as $event) { $ai1ec_exporter_helper->insert_event_in_calendar($event, $c, $export = true); } $str = ltrim($c->createCalendar()); header('Content-type: text/calendar; charset=utf-8'); echo $str; exit; }
echo Ai1ec_Time_Utility::date_i18n('M', $timestamp, true); ?> </div> <div class="ai1ec-day"><?php echo Ai1ec_Time_Utility::date_i18n('j', $timestamp, true); ?> </div> <div class="ai1ec-weekday"><?php echo Ai1ec_Time_Utility::date_i18n('D', $timestamp, true); ?> </div> <?php if ($show_year_in_agenda_dates) { ?> <div class="ai1ec-year"><?php echo Ai1ec_Time_Utility::date_i18n('Y', $timestamp, true); ?> </div> <?php } ?> </a><!--/.ai1ec-date-title--> <div class="ai1ec-date-events"> <?php foreach ($date_info['events'] as $category) { ?> <?php foreach ($category as $event) { ?> <div class="ai1ec-event ai1ec-event-id-<?php
/** * Displays the General Settings meta box. * * @return void */ public function general_settings_meta_box($object, $box) { global $ai1ec_view_helper, $ai1ec_settings; $calendar_page = $this->wp_pages_dropdown('calendar_page_id', $ai1ec_settings->calendar_page_id, __('Calendar', AI1EC_PLUGIN_NAME)); $week_start_day_val = Ai1ec_Meta::get_option('start_of_week'); $week_start_day = $this->get_week_dropdown($week_start_day_val); $exact_date = $ai1ec_settings->exact_date; $posterboard_events_per_page = $ai1ec_settings->posterboard_events_per_page; $posterboard_tile_min_width = $ai1ec_settings->posterboard_tile_min_width; $stream_events_per_page = $ai1ec_settings->stream_events_per_page; $agenda_events_per_page = $ai1ec_settings->agenda_events_per_page; $agenda_include_entire_last_day = $ai1ec_settings->agenda_include_entire_last_day ? 'checked="checked"' : ''; $include_events_in_rss = '<input type="checkbox" name="include_events_in_rss"' . ' id="include_events_in_rss" value="1"' . ($ai1ec_settings->include_events_in_rss ? ' checked="checked"' : '') . '/>'; $exclude_from_search = $ai1ec_settings->exclude_from_search ? 'checked="checked"' : ''; $show_publish_button = $ai1ec_settings->show_publish_button ? 'checked="checked"' : ''; $hide_maps_until_clicked = $ai1ec_settings->hide_maps_until_clicked ? 'checked="checked"' : ''; $agenda_events_expanded = $ai1ec_settings->agenda_events_expanded ? 'checked="checked"' : ''; $turn_off_subscription_buttons = $ai1ec_settings->turn_off_subscription_buttons ? 'checked="checked"' : ''; $show_create_event_button = $ai1ec_settings->show_create_event_button ? 'checked="checked"' : ''; $show_front_end_create_form = $ai1ec_settings->show_front_end_create_form ? 'checked="checked"' : ''; $allow_anonymous_submissions = $ai1ec_settings->allow_anonymous_submissions ? 'checked="checked"' : ''; $allow_anonymous_uploads = $ai1ec_settings->allow_anonymous_uploads ? 'checked="checked"' : ''; $show_add_calendar_button = $ai1ec_settings->show_add_calendar_button ? 'checked="checked"' : ''; $recaptcha_public_key = $ai1ec_settings->recaptcha_public_key; $recaptcha_private_key = $ai1ec_settings->recaptcha_private_key; $inject_categories = $ai1ec_settings->inject_categories ? 'checked="checked"' : ''; $geo_region_biasing = $ai1ec_settings->geo_region_biasing ? 'checked="checked"' : ''; $input_date_format = $this->get_date_format_dropdown($ai1ec_settings->input_date_format); $input_24h_time = $ai1ec_settings->input_24h_time ? 'checked="checked"' : ''; $default_calendar_view = $this->get_view_options($ai1ec_settings->default_calendar_view); $timezone_control = $this->get_timezone_dropdown($ai1ec_settings->timezone); $disable_autocompletion = $ai1ec_settings->disable_autocompletion ? 'checked="checked"' : ''; $show_location_in_title = $ai1ec_settings->show_location_in_title ? 'checked="checked"' : ''; $show_year_in_agenda_dates = $ai1ec_settings->show_year_in_agenda_dates ? 'checked="checked"' : ''; $tax_options = array('type' => 'categories', 'selected' => $ai1ec_settings->default_categories); $default_categories = $this->taxonomy_selector($tax_options); $tax_options = array('type' => 'tags', 'selected' => $ai1ec_settings->default_tags); $default_tags = $this->taxonomy_selector($tax_options); $show_timezone = $ai1ec_settings->is_timezone_open_for_change(); $date_format_pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($ai1ec_settings->input_date_format); $ajaxify_events_in_web_widget = $ai1ec_settings->ajaxify_events_in_web_widget ? 'checked="checked"' : ''; $event_platform = $ai1ec_settings->event_platform_active ? 'checked="checked"' : ''; $event_platform_disabled = AI1EC_EVENT_PLATFORM ? 'disabled="disabled"' : ''; $event_platform_strict = $ai1ec_settings->event_platform_strict ? 'checked="checked"' : ''; $args = array('calendar_page' => $calendar_page, 'default_calendar_view' => $default_calendar_view, 'week_start_day_val' => $week_start_day_val, 'week_start_day' => $week_start_day, 'default_categories' => $default_categories, 'default_tags' => $default_tags, 'exact_date' => $exact_date, 'posterboard_events_per_page' => $posterboard_events_per_page, 'posterboard_tile_min_width' => $posterboard_tile_min_width, 'stream_events_per_page' => $stream_events_per_page, 'agenda_events_per_page' => $agenda_events_per_page, 'agenda_include_entire_last_day' => $agenda_include_entire_last_day, 'exclude_from_search' => $exclude_from_search, 'show_publish_button' => $show_publish_button, 'hide_maps_until_clicked' => $hide_maps_until_clicked, 'agenda_events_expanded' => $agenda_events_expanded, 'turn_off_subscription_buttons' => $turn_off_subscription_buttons, 'show_create_event_button' => $show_create_event_button, 'show_front_end_create_form' => $show_front_end_create_form, 'allow_anonymous_submissions' => $allow_anonymous_submissions, 'allow_anonymous_uploads' => $allow_anonymous_uploads, 'show_add_calendar_button' => $show_add_calendar_button, 'recaptcha_public_key' => $recaptcha_public_key, 'recaptcha_private_key' => $recaptcha_private_key, 'inject_categories' => $inject_categories, 'input_date_format' => $input_date_format, 'input_24h_time' => $input_24h_time, 'show_timezone' => $show_timezone, 'timezone_control' => $timezone_control, 'geo_region_biasing' => $geo_region_biasing, 'disable_autocompletion' => $disable_autocompletion, 'show_location_in_title' => $show_location_in_title, 'show_year_in_agenda_dates' => $show_year_in_agenda_dates, 'date_format_pattern' => $date_format_pattern, 'calendar_css_selector' => $ai1ec_settings->calendar_css_selector, 'ajaxify_events_in_web_widget' => $ajaxify_events_in_web_widget, 'event_platform' => $event_platform, 'event_platform_disabled' => $event_platform_disabled, 'event_platform_strict' => $event_platform_strict, 'display_event_platform' => is_super_admin(), 'user_mail_subject' => $ai1ec_settings->user_mail_subject, 'user_mail_body' => $ai1ec_settings->user_mail_body, 'admin_mail_subject' => $ai1ec_settings->admin_mail_subject, 'admin_mail_body' => $ai1ec_settings->admin_mail_body); $ai1ec_view_helper->display_admin('box_general_settings.php', $args); }
/** * 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; }
/** * Displays the General Settings meta box. * * @return void */ public function general_settings_meta_box($object, $box) { global $ai1ec_view_helper, $ai1ec_settings; $calendar_page = $this->wp_pages_dropdown('calendar_page_id', $ai1ec_settings->calendar_page_id, __('Calendar', AI1EC_PLUGIN_NAME)); $week_start_day_val = Ai1ec_Meta::get_option('start_of_week'); $week_start_day = $this->get_week_dropdown($week_start_day_val); $exact_date = $ai1ec_settings->exact_date; $posterboard_events_per_page = $ai1ec_settings->posterboard_events_per_page; $posterboard_tile_min_width = $ai1ec_settings->posterboard_tile_min_width; $stream_events_per_page = $ai1ec_settings->stream_events_per_page; $agenda_events_per_page = $ai1ec_settings->agenda_events_per_page; $disable_standard_filter_menu = $ai1ec_settings->disable_standard_filter_menu ? 'checked="checked"' : ''; $use_authors_filter = $ai1ec_settings->use_authors_filter ? 'checked="checked"' : ''; $disable_gzip_compression = $ai1ec_settings->disable_gzip_compression ? 'checked="checked"' : ''; $agenda_include_entire_last_day = $ai1ec_settings->agenda_include_entire_last_day ? 'checked="checked"' : ''; $include_events_in_rss = '<input type="checkbox" name="include_events_in_rss"' . ' id="include_events_in_rss" value="1"' . ($ai1ec_settings->include_events_in_rss ? ' checked="checked"' : '') . '/>'; $exclude_from_search = $ai1ec_settings->exclude_from_search ? 'checked="checked"' : ''; $show_publish_button = $ai1ec_settings->show_publish_button ? 'checked="checked"' : ''; $hide_maps_until_clicked = $ai1ec_settings->hide_maps_until_clicked ? 'checked="checked"' : ''; $agenda_events_expanded = $ai1ec_settings->agenda_events_expanded ? 'checked="checked"' : ''; $turn_off_subscription_buttons = $ai1ec_settings->turn_off_subscription_buttons ? 'checked="checked"' : ''; $show_create_event_button = $ai1ec_settings->show_create_event_button ? 'checked="checked"' : ''; $show_front_end_create_form = $ai1ec_settings->show_front_end_create_form ? 'checked="checked"' : ''; $allow_anonymous_submissions = $ai1ec_settings->allow_anonymous_submissions ? 'checked="checked"' : ''; $allow_anonymous_uploads = $ai1ec_settings->allow_anonymous_uploads ? 'checked="checked"' : ''; $show_add_calendar_button = $ai1ec_settings->show_add_calendar_button ? 'checked="checked"' : ''; $recaptcha_public_key = $ai1ec_settings->recaptcha_public_key; $recaptcha_private_key = $ai1ec_settings->recaptcha_private_key; $inject_categories = $ai1ec_settings->inject_categories ? 'checked="checked"' : ''; $geo_region_biasing = $ai1ec_settings->geo_region_biasing ? 'checked="checked"' : ''; $input_date_format = $this->get_date_format_dropdown($ai1ec_settings->input_date_format); $input_24h_time = $ai1ec_settings->input_24h_time ? 'checked="checked"' : ''; $default_calendar_view = $this->get_view_options($ai1ec_settings->default_calendar_view); $timezone_control = $this->get_timezone_dropdown($ai1ec_settings->timezone); $disable_autocompletion = $ai1ec_settings->disable_autocompletion ? 'checked="checked"' : ''; $show_location_in_title = $ai1ec_settings->show_location_in_title ? 'checked="checked"' : ''; $show_year_in_agenda_dates = $ai1ec_settings->show_year_in_agenda_dates ? 'checked="checked"' : ''; $enable_user_event_notifications = $ai1ec_settings->enable_user_event_notifications ? 'checked="checked"' : ''; $oauth_twitter_id = $ai1ec_settings->oauth_twitter_id; $oauth_twitter_pass = $ai1ec_settings->oauth_twitter_pass; $twitter_notice_interval = $ai1ec_settings->twitter_notice_interval; $calendar_base_url_for_permalinks = $ai1ec_settings->calendar_base_url_for_permalinks ? 'checked="checked"' : ''; $use_select2_widgets = $ai1ec_settings->use_select2_widgets ? 'checked="checked"' : ''; $require_disclaimer = $ai1ec_settings->require_disclaimer ? 'checked="checked"' : ''; $disclaimer = $ai1ec_settings->disclaimer; $tax_options = array('type' => 'categories', 'selected' => $ai1ec_settings->default_categories); $default_categories = $this->taxonomy_selector($tax_options); $tax_options = array('type' => 'tags', 'selected' => $ai1ec_settings->default_tags); $default_tags = $this->taxonomy_selector($tax_options); $show_timezone = $ai1ec_settings->is_timezone_open_for_change(); $date_format_pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($ai1ec_settings->input_date_format); $checkboxes_to_check = array('skip_in_the_loop_check', 'ajaxify_events_in_web_widget', 'event_platform', 'event_platform_strict'); foreach ($checkboxes_to_check as $field) { ${$field} = ''; if ($ai1ec_settings->{$field}) { ${$field} = 'checked="checked"'; } } $event_platform_disabled = AI1EC_EVENT_PLATFORM ? 'disabled="disabled"' : ''; $args = array('calendar_page' => $calendar_page, 'default_calendar_view' => $default_calendar_view, 'week_start_day_val' => $week_start_day_val, 'week_start_day' => $week_start_day, 'default_categories' => $default_categories, 'default_tags' => $default_tags, 'exact_date' => $exact_date, 'posterboard_events_per_page' => $posterboard_events_per_page, 'posterboard_tile_min_width' => $posterboard_tile_min_width, 'stream_events_per_page' => $stream_events_per_page, 'agenda_events_per_page' => $agenda_events_per_page, 'disable_standard_filter_menu' => $disable_standard_filter_menu, 'agenda_include_entire_last_day' => $agenda_include_entire_last_day, 'week_view_starts_at' => $ai1ec_settings->week_view_starts_at, 'week_view_ends_at' => $ai1ec_settings->week_view_ends_at, 'exclude_from_search' => $exclude_from_search, 'show_publish_button' => $show_publish_button, 'hide_maps_until_clicked' => $hide_maps_until_clicked, 'agenda_events_expanded' => $agenda_events_expanded, 'turn_off_subscription_buttons' => $turn_off_subscription_buttons, 'show_create_event_button' => $show_create_event_button, 'show_front_end_create_form' => $show_front_end_create_form, 'allow_anonymous_submissions' => $allow_anonymous_submissions, 'allow_anonymous_uploads' => $allow_anonymous_uploads, 'show_add_calendar_button' => $show_add_calendar_button, 'recaptcha_public_key' => $recaptcha_public_key, 'recaptcha_private_key' => $recaptcha_private_key, 'inject_categories' => $inject_categories, 'input_date_format' => $input_date_format, 'input_24h_time' => $input_24h_time, 'show_timezone' => $show_timezone, 'timezone_control' => $timezone_control, 'geo_region_biasing' => $geo_region_biasing, 'disable_autocompletion' => $disable_autocompletion, 'show_location_in_title' => $show_location_in_title, 'show_year_in_agenda_dates' => $show_year_in_agenda_dates, 'date_format_pattern' => $date_format_pattern, 'calendar_css_selector' => $ai1ec_settings->calendar_css_selector, 'skip_in_the_loop_check' => $skip_in_the_loop_check, 'calendar_base_url_for_permalinks' => $calendar_base_url_for_permalinks, 'ajaxify_events_in_web_widget' => $ajaxify_events_in_web_widget, 'event_platform' => $event_platform, 'event_platform_disabled' => $event_platform_disabled, 'event_platform_strict' => $event_platform_strict, 'require_disclaimer' => $require_disclaimer, 'disclaimer' => $disclaimer, 'display_event_platform' => is_super_admin(), 'user_mail_subject' => $ai1ec_settings->user_mail_subject, 'user_mail_body' => $ai1ec_settings->user_mail_body, 'admin_mail_subject' => $ai1ec_settings->admin_mail_subject, 'admin_mail_body' => $ai1ec_settings->admin_mail_body, 'view_cache_refresh_interval' => $ai1ec_settings->view_cache_refresh_interval, 'admin_add_new_event_mail_body' => $ai1ec_settings->admin_add_new_event_mail_body, 'admin_add_new_event_mail_subject' => $ai1ec_settings->admin_add_new_event_mail_subject, 'user_upcoming_event_mail_body' => $ai1ec_settings->user_upcoming_event_mail_body, 'user_upcoming_event_mail_subject' => $ai1ec_settings->user_upcoming_event_mail_subject, 'license_key' => $ai1ec_settings->license_key, 'enable_user_event_notifications' => $enable_user_event_notifications, 'oauth_twitter_id' => $oauth_twitter_id, 'oauth_twitter_pass' => $oauth_twitter_pass, 'use_select2_widgets' => $use_select2_widgets, 'twitter_notice_interval' => $twitter_notice_interval, 'use_authors_filter' => $use_authors_filter, 'disable_gzip_compression' => $disable_gzip_compression); $ai1ec_view_helper->display_admin('box_general_settings.php', $args); }
/** * post_updated_messages function * * Filter success messages returned by WordPress when an event post is * updated/saved. */ function post_updated_messages($messages) { global $post, $post_ID; $messages[AI1EC_POST_TYPE] = array(0 => '', 1 => sprintf(__('Event updated. <a href="%s">View event</a>', AI1EC_PLUGIN_NAME), esc_url(get_permalink($post_ID))), 2 => __('Custom field updated.', AI1EC_PLUGIN_NAME), 3 => __('Custom field deleted.', AI1EC_PLUGIN_NAME), 4 => __('Event updated.', AI1EC_PLUGIN_NAME), 5 => isset($_GET['revision']) ? sprintf(__('Event restored to revision from %s', AI1EC_PLUGIN_NAME), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Event published. <a href="%s">View event</a>', AI1EC_PLUGIN_NAME), esc_url(get_permalink($post_ID))), 7 => __('Event saved.'), 8 => sprintf(__('Event submitted. <a target="_blank" href="%s">Preview event</a>', AI1EC_PLUGIN_NAME), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('Event scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview event</a>', AI1EC_PLUGIN_NAME), Ai1ec_Time_Utility::date_i18n(__('M j, Y @ G:i', AI1EC_PLUGIN_NAME), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('Event draft updated. <a target="_blank" href="%s">Preview event</a>', AI1EC_PLUGIN_NAME), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))))); return $messages; }
/** * install_schedule method * * Update/install, if necessary CRON. * Return name of CRON action (hook) executed. * * @return string Name of CRON action */ public function install_schedule() { $cron_key = 'ai1ec_logging_cron'; $optn_key = $cron_key . '_version'; if (Ai1ec_Meta::get_option($optn_key) != self::CRON_VERSION) { wp_clear_scheduled_hook($cron_key); wp_schedule_event(Ai1ec_Time_Utility::current_time(), 'daily', $cron_key); update_option($optn_key, self::CRON_VERSION); } return $cron_key; }
/** * widget function * * Outputs the given instance of the widget to the front-end. * * @param array $args Display arguments passed to the widget * @param array $instance The settings for this widget instance */ function widget($args, $instance) { global $ai1ec_view_helper, $ai1ec_events_helper, $ai1ec_calendar_helper, $ai1ec_settings, $ai1ec_themes_controller, $ai1ec_requirejs_controller; if ($ai1ec_themes_controller->frontend_outdated_themes_notice()) { return; } $ai1ec_requirejs_controller->add_link_to_render_js(Ai1ec_Requirejs_Controller::LOAD_ONLY_FRONTEND_SCRIPTS, false); $defaults = array('hide_on_calendar_page' => true, 'event_cat_ids' => array(), 'event_tag_ids' => array(), 'event_post_ids' => array(), 'events_per_page' => 10, 'days_per_page' => 10, 'events_seek_type' => 'events'); $instance = wp_parse_args($instance, $defaults); if ($instance['hide_on_calendar_page'] && is_page($ai1ec_settings->calendar_page_id)) { return; } // Add params to the subscribe_url for filtering by Limits (category, tag) $subscribe_filter = ''; $subscribe_filter .= $instance['event_cat_ids'] ? '&ai1ec_cat_ids=' . join(',', $instance['event_cat_ids']) : ''; $subscribe_filter .= $instance['event_tag_ids'] ? '&ai1ec_tag_ids=' . join(',', $instance['event_tag_ids']) : ''; $subscribe_filter .= $instance['event_post_ids'] ? '&ai1ec_post_ids=' . join(',', $instance['event_post_ids']) : ''; // Get localized time $timestamp = $ai1ec_events_helper->gmt_to_local(Ai1ec_Time_Utility::current_time()); // Set $limit to the specified category/tag $limit = array('cat_ids' => $instance['event_cat_ids'], 'tag_ids' => $instance['event_tag_ids'], 'post_ids' => $instance['event_post_ids']); // Get events, then classify into date array // JB: apply seek check here $seek_days = 'days' === $instance['events_seek_type']; $seek_count = $instance['events_per_page']; $last_day = false; if ($seek_days) { $seek_count = $instance['days_per_page'] * 5; $last_day = strtotime('+' . $instance['days_per_page'] . ' days'); } $event_results = $ai1ec_calendar_helper->get_events_relative_to($timestamp, $seek_count, 0, $limit); if ($seek_days) { foreach ($event_results['events'] as $ek => $event) { if ($event->start >= $last_day) { unset($event_results['events'][$ek]); } } } $dates = $ai1ec_calendar_helper->get_agenda_like_date_array($event_results['events']); $args['title'] = $instance['title']; $args['show_subscribe_buttons'] = $instance['show_subscribe_buttons']; $args['show_calendar_button'] = $instance['show_calendar_button']; $args['dates'] = $dates; $args['show_location_in_title'] = $ai1ec_settings->show_location_in_title; $args['show_year_in_agenda_dates'] = $ai1ec_settings->show_year_in_agenda_dates; $args['calendar_url'] = $ai1ec_calendar_helper->get_calendar_url($limit); $args['subscribe_url'] = AI1EC_EXPORT_URL . $subscribe_filter; $args['is_ticket_button_enabled'] = $ai1ec_calendar_helper->is_buy_ticket_enabled_for_view('agenda'); $ai1ec_view_helper->display_theme('agenda-widget.php', $args); }
/** * This function tells if less than the notification interval is missing from the event start time * * @param Ai1ec_Event $event * @return boolean */ public function check_if_notification_should_be_sent_for_event(Ai1ec_Event $event) { $how_much_before_event_start = $event->start - Ai1ec_Time_Utility::current_time(true); if ($how_much_before_event_start < self::NOTIFICATION_INTERVAL) { return true; } return false; }
/** * Returns a non-associative array of four links for the day view of the * calendar: * previous day, and next day. * Each element is an associative array containing the link's enabled status * ['enabled'], CSS class ['class'], text ['text'] and value to assign to * link's href ['href']. * * @param array $args Current request arguments * * @return array Array of links */ function get_oneday_pagination_links($args) { $links = array(); $orig_date = $args['exact_date']; $local_date = Ai1ec_Time_Utility::gmt_to_local($args['exact_date']); $bits = Ai1ec_Time_Utility::gmgetdate($local_date); // ================ // = Previous day = // ================ $local_date = gmmktime(0, 0, 0, $bits['mon'], $bits['mday'] + $args['oneday_offset'] - 1, $bits['year']); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-prev-day', 'text' => '<i class="icon-chevron-left"></i>', 'href' => $href->generate_href()); // ====================== // = Minical datepicker = // ====================== $args['exact_date'] = $orig_date; $links[] = Ai1ec_View_Factory::create_datepicker_link($args, $args['exact_date']); // ============= // = Next week = // ============= $local_date = gmmktime(0, 0, 0, $bits['mon'], $bits['mday'] + $args['oneday_offset'] + 1, $bits['year']); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-next-day', 'text' => '<i class="icon-chevron-right"></i>', 'href' => $href->generate_href()); return $links; }
/** * Initialize the registry object. * * @param Ai1ec_Loader $ai1ec_loader Instance of Ai1EC classes loader * * @return void Method does not return */ protected function _initialize_registry($ai1ec_loader) { global $ai1ec_registry; $this->_registry = new Ai1ec_Registry_Object($ai1ec_loader); Ai1ec_Time_Utility::set_registry($this->_registry); $ai1ec_registry = $this->_registry; }
/** * save function * * Saves the current event data to the database. If $this->post_id exists, * but $update is false, creates a new record in the ai1ec_events table of * this event data, but does not try to create a new post. Else if $update * is true, updates existing event record. If $this->post_id is empty, * creates a new post AND record in the ai1ec_events table for this event. * * @param bool $update Whether to update an existing event or create a * new one * @return int The post_id of the new or existing event. **/ function save($update = false) { global $wpdb, $ai1ec_events_helper, $ai1ec_exporter_controller; // =========================== // = Insert events meta data = // =========================== // Set facebook user and eid to 0 if they are not set, otherwise they will be set to '' since we use %s for big ints $facebook_eid = isset($this->facebook_eid) ? $this->facebook_eid : 0; $facebook_user = isset($this->facebook_user) ? $this->facebook_user : 0; $columns = array('post_id' => $this->post_id, 'start' => Ai1ec_Time_Utility::to_mysql_date($this->start), 'end' => Ai1ec_Time_Utility::to_mysql_date($this->end), 'allday' => $this->allday, 'instant_event' => $this->instant_event, 'recurrence_rules' => $this->recurrence_rules, 'exception_rules' => $this->exception_rules, 'recurrence_dates' => $this->recurrence_dates, 'exception_dates' => $this->exception_dates, 'venue' => $this->venue, 'country' => $this->country, 'address' => $this->address, 'city' => $this->city, 'province' => $this->province, 'postal_code' => $this->postal_code, 'show_map' => $this->show_map, 'contact_name' => $this->contact_name, 'contact_phone' => $this->contact_phone, 'contact_email' => $this->contact_email, 'contact_url' => $this->contact_url, 'cost' => $this->cost, 'ticket_url' => $this->ticket_url, 'ical_feed_url' => $this->ical_feed_url, 'ical_source_url' => $this->ical_source_url, 'ical_uid' => $this->ical_uid, 'show_coordinates' => $this->show_coordinates, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'facebook_eid' => $facebook_eid, 'facebook_user' => $facebook_user, 'facebook_status' => $this->facebook_status); $format = array('%d', '%s', '%s', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%d', '%f', '%f', '%s', '%s', '%s'); $table_name = $wpdb->prefix . 'ai1ec_events'; if ($this->post_id) { if (!$update) { // ========================= // = Insert new event data = // ========================= $wpdb->query($wpdb->prepare("INSERT INTO {$table_name} ( " . join(', ', array_keys($columns)) . " ) VALUES ( " . join(', ', $format) . " )", $columns)); $ai1ec_exporter_controller->export_location($columns, false); } else { // ============================== // = Update existing event data = // ============================== $where = array('post_id' => $this->post_id); $where_escape = array('%d'); $wpdb->update($table_name, $columns, $where, $format, $where_escape); $ai1ec_exporter_controller->export_location($columns, true); } } else { // =================== // = Insert new post = // =================== $this->post_id = wp_insert_post($this->post); $columns['post_id'] = $this->post_id; wp_set_post_terms($this->post_id, $this->categories, 'events_categories'); wp_set_post_terms($this->post_id, $this->tags, 'events_tags'); if (isset($this->feed) && isset($this->feed->feed_id)) { $feed_name = $this->feed->feed_url; // If the feed is not from an imported file, parse the url. if (!isset($this->feed->feed_imported_file)) { $url_components = parse_url($this->feed->feed_url); $feed_name = $url_components["host"]; } $term = term_exists($feed_name, 'events_feeds'); if (!$term) { // term doesn't exist, create it $term = wp_insert_term($feed_name, 'events_feeds', array('description' => $this->feed->feed_url)); } // term_exists returns object, wp_insert_term returns array $term = (object) $term; if (isset($term->term_id)) { // associate the event with the feed only if we have term id set $a = wp_set_object_terms($this->post_id, (int) $term->term_id, 'events_feeds', false); } } // ========================= // = Insert new event data = // ========================= $wpdb->query($wpdb->prepare("INSERT INTO {$table_name} ( " . join(', ', array_keys($columns)) . " ) VALUES ( " . join(', ', $format) . " )", $columns)); $ai1ec_exporter_controller->export_location($columns, false); } return $this->post_id; }
/** * @param Ai1ec_Registry_Object $registry */ public static function set_registry(Ai1ec_Registry_Object $registry) { self::$_registry = $registry; }
?> " <?php echo $data_type; ?> > <?php if ($show_year_in_agenda_dates) { ?> <?php echo Ai1ec_Time_Utility::date_i18n('F j, Y (l)', $timestamp); ?> <?php } else { ?> <?php echo Ai1ec_Time_Utility::date_i18n('F j (l)', $timestamp); ?> <?php } ?> </a><!--/.ai1ec-load-view--> </div><!--/.ai1ec-date-title--> <div class="ai1ec-date-events"> <?php foreach ($date_info['events'] as $category) { ?> <?php foreach ($category as $event) { ?> <div class="clearfix ai1ec-event ai1ec-event-id-<?php
/** * Save the compile time to the db so that we can use it to build the link */ private function save_less_parse_time() { $this->db_adapter->write_data_to_config(self::GET_VARIBALE_NAME, Ai1ec_Time_Utility::current_time()); }
/** * Refreshes the events from facebook for the currently loaded ids * * @throws WP_FacebookApiException if something goes wrong with the Facebook calls * * @return array an array with the results. */ public function refresh_events() { $timestamp = Ai1ec_Time_Utility::current_time(); // I use the strategy pattern for this, the common interface assure us that this method is present. try { $events = $this->_query_events_strategy->query_events($this->_facebook, $this->_ids, $timestamp); } catch (WP_FacebookApiException $e) { throw $e; } $result = $this->save_events($events, $timestamp); return $result; }
/** * Handle AJAX request to display front-end create event form content. * * @return null */ public function get_front_end_create_event_form() { global $ai1ec_view_helper, $ai1ec_settings; $date_format_pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($ai1ec_settings->input_date_format); $week_start_day = get_option('start_of_week'); $input_24h_time = $ai1ec_settings->input_24h_time; $cat_select = $this->get_html_for_category_selector(); $tag_select = $this->get_html_for_tag_selector(); $form_action = admin_url('admin-ajax.php?action=ai1ec_front_end_submit_event'); $default_image = $ai1ec_view_helper->get_theme_img_url('default-event-avatar.png'); if (!is_user_logged_in() && $ai1ec_settings->allow_anonymous_submissions && $ai1ec_settings->recaptcha_key !== '') { $recaptcha_key = $ai1ec_settings->recaptcha_public_key; } else { $recaptcha_key = false; } $allow_uploads = is_user_logged_in() || $ai1ec_settings->allow_anonymous_submissions && $ai1ec_settings->allow_anonymous_uploads; $args = array('date_format_pattern' => $date_format_pattern, 'week_start_day' => $week_start_day, 'input_24h_time' => $input_24h_time, 'cat_select' => $cat_select, 'tag_select' => $tag_select, 'form_action' => $form_action, 'interactive_gmaps' => !$ai1ec_settings->disable_autocompletion, 'default_image' => $default_image, 'recaptcha_key' => $recaptcha_key, 'allow_uploads' => $allow_uploads); $ai1ec_view_helper->display_theme('create-event-form.php', $args); exit; }
/** * install_u_cron function * * This function sets up the cron job that checks for available updates * * @return void **/ function install_u_cron() { // If existing CRON version is not consistent with current plugin's version, // or does not exist, then create/update cron using if (Ai1ec_Meta::get_option('ai1ec_u_cron_version') != AI1EC_U_CRON_VERSION) { // delete our scheduled crons wp_clear_scheduled_hook('ai1ec_u_cron'); // reset flags update_option('ai1ec_update_available', 0); update_option('ai1ec_update_message', ''); update_option('ai1ec_package_url', ''); // set the new cron wp_schedule_event(Ai1ec_Time_Utility::current_time(), AI1EC_U_CRON_FREQ, 'ai1ec_u_cron'); // update the cron version update_option('ai1ec_u_cron_version', AI1EC_U_CRON_VERSION); } }
?> <div class="ai1ec-grid-container"> <?php for ($hour = 0; $hour < 24; $hour++) { ?> <div class="ai1ec-hour-marker <?php if ($hour >= 8 && $hour < 18) { echo 'ai1ec-business-hour'; } ?> " style="top: <?php echo $hour * 60; ?> px;"> <div><?php echo esc_html(Ai1ec_Time_Utility::date_i18n($time_format, gmmktime($hour, 0), true)); ?> </div> </div> <?php for ($quarter = 1; $quarter < 4; $quarter++) { ?> <div class="ai1ec-quarter-marker" style="top: <?php echo $hour * 60 + $quarter * 15; ?> px;"></div> <?php } ?> <?php }
/** * Return the current timestamp to make correct queries using restrictions * for starting time. * * This works as follows, it takes the time on the current server. Imagine * i'm at 22.30 on GMT + 2. * Facebook treats this as Pacific Time so i calculate the offset between * PST and UTC ( -7 ), i take into account the offset from GMT ( that's 2 i * subtract from -7 so i get -9) and then i subtract the offset of the * server from my starting time. * * @return number */ public static function get_facebook_actual_time($timestamp = NULL) { if ($timestamp === NULL) { $timestamp = Ai1ec_Time_Utility::current_time(); } global $ai1ec_events_helper; $offset = $ai1ec_events_helper->get_timezone_offset('UTC', 'PST', $timestamp); $offset -= $ai1ec_events_helper->get_gmt_offset() * 3600; return $timestamp - $offset; }
/** * 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; }
/** * parse method * * Parse given timestamp into I18n date/time values map. * * @param int $timestamp Timestamp to parse * @param bool $is_gmt Set to true, to treat value as present in GMT * * @return array Map of date format keys and corresponding time values */ public function parse($timestamp = false, $is_gmt = false) { $timestamp = Ai1ec_Time_Utility::normalize_timestamp($timestamp, $is_gmt); $cache_key = $timestamp . "" . $is_gmt; if (NULL === ($record = $this->_memory->get($cache_key))) { $record = array_combine($this->_keys, explode($this->_separator, date_i18n($this->_format, $timestamp, $is_gmt))); $this->_memory->set($cache_key, $record); } return $record; }
/** * Return the embedded day view of the calendar, optionally filtered by * event categories and tags. * * @param array $args associative array with any of these elements: * int oneday_offset => specifies which day to display relative to the * current day * array cat_ids => restrict events returned to the given set of * event category slugs * array tag_ids => restrict events returned to the given set of * event tag names * array post_ids => restrict events returned to the given set of * post IDs * * @return string returns string of view output */ function get_oneday_view($args) { global $ai1ec_view_helper, $ai1ec_events_helper, $ai1ec_calendar_helper, $ai1ec_settings; $defaults = array('oneday_offset' => 0, 'cat_ids' => array(), 'tag_ids' => array(), 'post_ids' => array(), 'exact_date' => Ai1ec_Time_Utility::current_time()); $args = wp_parse_args($args, $defaults); // Localize requested date and get components. $local_date = Ai1ec_Time_Utility::gmt_to_local($args['exact_date']); $bits = Ai1ec_Time_Utility::gmgetdate($local_date); // Apply day offset. $day_shift = 0 + $args['oneday_offset']; // Now align date to start of day (midnight). $local_date = gmmktime(0, 0, 0, $bits['mon'], $bits['mday'] + $day_shift, $bits['year']); $cell_array = $ai1ec_calendar_helper->get_oneday_cell_array($local_date, array('cat_ids' => $args['cat_ids'], 'tag_ids' => $args['tag_ids'], 'post_ids' => $args['post_ids'])); // Create pagination links. $pagination_links = $ai1ec_calendar_helper->get_oneday_pagination_links($args); $pagination_links = $ai1ec_view_helper->get_theme_view('pagination.php', array('links' => $pagination_links, 'data_type' => $args['data_type'])); $date_format = Ai1ec_Meta::get_option('date_format', 'l, M j, Y'); $title = Ai1ec_Time_Utility::date_i18n($date_format, $local_date, true); $time_format = Ai1ec_Meta::get_option('time_format', 'g a'); // Calculate today marker's position. $now = Ai1ec_Time_Utility::current_time(); $now = Ai1ec_Time_Utility::gmt_to_local($now); $now_text = $ai1ec_events_helper->get_short_time($now, false); $now = Ai1ec_Time_Utility::gmgetdate($now); $now = $now['hours'] * 60 + $now['minutes']; $view_args = array('title' => $title, 'type' => 'oneday', 'cell_array' => $cell_array, 'show_location_in_title' => $ai1ec_settings->show_location_in_title, 'now_top' => $now, 'now_text' => $now_text, 'pagination_links' => $pagination_links, 'post_ids' => join(',', $args['post_ids']), 'time_format' => $time_format, 'done_allday_label' => false, 'done_grid' => false, 'data_type' => $args['data_type'], 'data_type_events' => ''); if ($ai1ec_settings->ajaxify_events_in_web_widget) { $view_args['data_type_events'] = $args['data_type']; } // Add navigation if requested. $view_args['navigation'] = $args['no_navigation'] ? '' : $ai1ec_view_helper->get_theme_view('navigation.php', $view_args); return apply_filters('ai1ec_get_oneday_view', $ai1ec_view_helper->get_theme_view('oneday.php', $view_args), $view_args); }
/** * Check if given event must be treated as all-day event * * Event instances that span 24 hours are treated as all-day * * @param array $event Event data returned from database * * @return bool True if event is all-day event */ protected function _is_all_day(array $event) { if (isset($event['event_allday']) && $event['event_allday']) { return true; } if (!isset($event['start']) || !isset($event['end'])) { return false; } $start_plus_day = Ai1ec_Time_Utility::instance()->modify_timestamp('+1 day', $event['start']); return (int) $start_plus_day === (int) $event['end']; }
/** * Run designated hook in background thread * * So far it is just re-scheduling the hook to be run at earliest * time possible. * * @param string $hook Name of registered schedulable hook * * @return void Method does not return */ public function background($hook) { return $this->_install($hook, Ai1ec_Time_Utility::current_time()); }