/** * 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; }
/** * A GMT-version of PHP getdate(). * * @param int $timestamp UNIX timestamp * * @return array Same result as getdate(), but based in GMT time. */ function gmgetdate($timestamp = null) { return Ai1ec_Time_Utility::gmgetdate($timestamp); }
/** * 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); }
/** * A GMT-version of PHP getdate(). * * @param int $timestamp UNIX timestamp * * @return array Same result as getdate(), but based in GMT time. */ public function gmgetdate($timestamp = NULL) { return Ai1ec_Time_Utility::gmgetdate($timestamp); }