示例#1
0
 /**
  * Renders the html of the page and returns it.
  *
  * @param Ai1ec_Event $event
  *
  * @return string the html of the page
  */
 public function get_content(Ai1ec_Event $event)
 {
     $settings = $this->_registry->get('model.settings');
     $rrule = $this->_registry->get('recurrence.rule');
     $taxonomy = $this->_registry->get('view.event.taxonomy');
     $location = $this->_registry->get('view.event.location');
     $ticket = $this->_registry->get('view.event.ticket');
     $content = $this->_registry->get('view.event.content');
     $time = $this->_registry->get('view.event.time');
     $subscribe_url = AI1EC_EXPORT_URL . '&ai1ec_post_ids=' . $event->get('post_id');
     $event->set_runtime('tickets_url_label', $ticket->get_tickets_url_label($event, false));
     $event->set_runtime('content_img_url', $content->get_content_img_url($event));
     $extra_buttons = apply_filters('ai1ec_rendering_single_event_actions', '', $event);
     $venues_html = apply_filters('ai1ec_rendering_single_event_venues', nl2br($location->get_location($event)), $event);
     $timezone_info = array('show_timezone' => false, 'text_timezone_title' => null, 'event_timezone' => null);
     $default_tz = $this->_registry->get('date.timezone')->get_default_timezone();
     /**
      * Only display the timezone information if:
      *     -) local timezone is not enforced -- because if it is enforced
      *        then site owner knows that it's clear, from event contents,
      *        where event happens and what time means;
      *     -) the timezone is different from the site timezone because if
      *        they do match then it is likely obvious when and wheere the
      *        event is about to take place.
      */
     if ($this->_registry->get('model.settings')->get('always_use_calendar_timezone') && $event->get('timezone_name') !== $default_tz) {
         $timezone_info = array('show_timezone' => true, 'event_timezone' => $event->get('timezone_name'), 'text_timezone_title' => sprintf(Ai1ec_I18n::__('Event was created in the %s time zone'), $event->get('start')->get_gmt_offset_as_text()));
     }
     $banner_image_meta = get_post_meta($event->get('post_id'), 'ai1ec_banner_image');
     $banner_image = $banner_image_meta ? $banner_image_meta[0] : '';
     // objects are passed by reference so an action is ok
     do_action('ai1ec_single_event_page_before_render', $event);
     $filter_groups_html = apply_filters('ai1ec_get_filter_groups_html', $event);
     $args = array('event' => $event, 'recurrence' => $rrule->rrule_to_text($event->get('recurrence_rules')), 'exclude' => $time->get_exclude_html($event, $rrule), 'categories' => $taxonomy->get_categories_html($event), 'tags' => $taxonomy->get_tags_html($event), 'location' => html_entity_decode($venues_html), 'filter_groups' => $filter_groups_html, 'map' => $location->get_map_view($event), 'contact' => $ticket->get_contact_html($event), 'back_to_calendar' => $content->get_back_to_calendar_button_html(), 'subscribe_url' => $subscribe_url, 'subscribe_url_no_html' => $subscribe_url . '&no_html=true', 'edit_instance_url' => null, 'edit_instance_text' => null, 'google_url' => 'http://www.google.com/calendar/render?cid=' . urlencode($subscribe_url), 'show_subscribe_buttons' => !$settings->get('turn_off_subscription_buttons'), 'hide_featured_image' => $settings->get('hide_featured_image'), 'extra_buttons' => $extra_buttons, 'show_get_calendar' => !$settings->get('disable_get_calendar_button'), 'text_add_calendar' => __('Add to Calendar', AI1EC_PLUGIN_NAME), 'subscribe_buttons_text' => $this->_registry->get('view.calendar.subscribe-button')->get_labels(), 'text_get_calendar' => Ai1ec_I18n::__('Get a Timely Calendar'), 'text_when' => __('When:', AI1EC_PLUGIN_NAME), 'text_where' => __('Where:', AI1EC_PLUGIN_NAME), 'text_cost' => __('Cost:', AI1EC_PLUGIN_NAME), 'text_contact' => __('Contact:', AI1EC_PLUGIN_NAME), 'text_tickets' => __('Tickets:', AI1EC_PLUGIN_NAME), 'text_free' => __('Free', AI1EC_PLUGIN_NAME), 'text_categories' => __('Categories', AI1EC_PLUGIN_NAME), 'text_tags' => __('Tags', AI1EC_PLUGIN_NAME), 'buy_tickets_text' => __('Buy Tickets', AI1EC_PLUGIN_NAME), 'timezone_info' => $timezone_info, 'banner_image' => $banner_image, 'content_img_url' => $event->get_runtime('content_img_url'), 'post_id' => $event->get('post_id'), 'ticket_url' => $event->get('ticket_url'), 'tickets_url_label' => $event->get_runtime('tickets_url_label'), 'start' => $event->get('start'), 'end' => $event->get('end'), 'cost' => $event->get('cost'), 'instance_id' => $event->get('instance_id'));
     if (!empty($args['recurrence']) && $event->get('instance_id') && current_user_can('edit_ai1ec_events')) {
         $args['edit_instance_url'] = ai1ec_admin_url('post.php?post=' . $event->get('post_id') . '&action=edit&instance=' . $event->get('instance_id'));
         $args['edit_instance_text'] = sprintf(Ai1ec_I18n::__('Edit this occurrence (%s)'), $event->get('start')->format_i18n('M j'));
     }
     $loader = $this->_registry->get('theme.loader');
     $api = $this->_registry->get('model.api.api-ticketing');
     if (false === ai1ec_is_blank($event->get('ical_feed_url'))) {
         $args['ticket_url'] = $api->get_api_event_buy_ticket_url($event->get('post_id'));
     } else {
         $api_event_id = $api->get_api_event_id($event->get('post_id'));
         if ($api_event_id) {
             $api = $this->_registry->get('model.api.api-ticketing');
             $ticket_types = json_decode($api->get_ticket_types($event->get('post_id'), false));
             $args['has_tickets'] = true;
             $args['API_URL'] = AI1EC_API_URL;
             $args['tickets_block'] = $loader->get_file('tickets.twig', array('tickets_checkout_url' => $api->get_api_event_buy_ticket_url($event->get('post_id')), 'tickets' => $ticket_types->data, 'text_tickets' => $args['text_tickets'], 'buy_tickets_text' => $args['buy_tickets_text'], 'api_event_id' => $api_event_id), false)->get_content();
         }
     }
     return $loader->get_file('event-single.twig', $args, false)->get_content();
 }
 /**
  * Renders the html of the page and returns it.
  *
  * @param Ai1ec_Event $event
  *
  * @return string the html of the page
  */
 public function get_content(Ai1ec_Event $event)
 {
     $settings = $this->_registry->get('model.settings');
     $rrule = $this->_registry->get('recurrence.rule');
     $taxonomy = $this->_registry->get('view.event.taxonomy');
     $location = $this->_registry->get('view.event.location');
     $ticket = $this->_registry->get('view.event.ticket');
     $content = $this->_registry->get('view.event.content');
     $time = $this->_registry->get('view.event.time');
     $subscribe_url = AI1EC_EXPORT_URL . '&ai1ec_post_ids=' . $event->get('post_id');
     $event->set_runtime('tickets_url_label', $ticket->get_tickets_url_label($event, false));
     $event->set_runtime('content_img_url', $content->get_content_img_url($event));
     $extra_buttons = apply_filters('ai1ec_rendering_single_event_actions', '', $event);
     $venues_html = apply_filters('ai1ec_rendering_single_event_venues', nl2br($location->get_location($event)), $event);
     // objects are passed by reference so an action is ok
     do_action('ai1ec_single_event_page_before_render', $event);
     $args = array('event' => $event, 'recurrence' => $rrule->rrule_to_text($event->get('recurrence_rules')), 'exclude' => $time->get_exclude_html($event, $rrule), 'categories' => $taxonomy->get_categories_html($event), 'tags' => $taxonomy->get_tags_html($event), 'location' => $venues_html, 'map' => $location->get_map_view($event), 'contact' => $ticket->get_contact_html($event), 'back_to_calendar' => $content->get_back_to_calendar_button_html(), 'subscribe_url' => $subscribe_url, 'subscribe_url_no_html' => $subscribe_url . '&no_html=true', 'edit_instance_url' => null, 'edit_instance_text' => null, 'google_url' => 'http://www.google.com/calendar/render?cid=' . urlencode($subscribe_url), 'show_subscribe_buttons' => !$settings->get('turn_off_subscription_buttons'), 'hide_featured_image' => $settings->get('hide_featured_image'), 'extra_buttons' => $extra_buttons, 'text_add_calendar' => __('Add to Calendar', AI1EC_PLUGIN_NAME), 'subscribe_buttons_text' => $this->_registry->get('view.calendar.subscribe-button')->get_labels(), 'text_when' => __('When:', AI1EC_PLUGIN_NAME), 'text_where' => __('Where:', AI1EC_PLUGIN_NAME), 'text_cost' => __('Cost:', AI1EC_PLUGIN_NAME), 'text_contact' => __('Contact:', AI1EC_PLUGIN_NAME), 'text_free' => __('Free', AI1EC_PLUGIN_NAME), 'text_categories' => __('Categories', AI1EC_PLUGIN_NAME), 'text_tags' => __('Tags', AI1EC_PLUGIN_NAME));
     if (!empty($args['recurrence']) && $event->get('instance_id') && current_user_can('edit_ai1ec_events')) {
         $args['edit_instance_url'] = admin_url('post.php?post=' . $event->get('post_id') . '&action=edit&instance=' . $event->get('instance_id'));
         $args['edit_instance_text'] = sprintf(Ai1ec_I18n::__('Edit this occurrence (%s)'), $event->get('start')->format_i18n('M j'));
     }
     $loader = $this->_registry->get('theme.loader');
     return $loader->get_file('event-single.twig', $args, false)->get_content();
 }
示例#3
0
 /**
  * Adds runtime properties to the event.
  *
  * @param Ai1ec_Event $event
  */
 protected function _add_runtime_properties(Ai1ec_Event $event)
 {
     global $post;
     $original_post = $post;
     $post = $event->get('post');
     $instance_permalink = get_permalink($event->get('post_id'));
     $instance_permalink = add_query_arg('instance_id', $event->get('instance_id'), $instance_permalink);
     $event->set_runtime('instance_permalink', $instance_permalink);
     $event->set_runtime('filtered_title', apply_filters('the_title', $event->get('post')->post_title, $event->get('post_id'), true));
     $calendar_state = $this->_registry->get('calendar.state');
     $calendar_state->set_append_content(false);
     $event->set_runtime('filtered_content', apply_filters('ai1ec_the_content', apply_filters('the_content', $event->get('post')->post_content)));
     $calendar_state->set_append_content(true);
     $taxonomy = $this->_registry->get('view.event.taxonomy');
     $ticket = $this->_registry->get('view.event.ticket');
     $event->set_runtime('color_style', $taxonomy->get_color_style($event));
     $event->set_runtime('category_colors', $taxonomy->get_category_colors($event));
     $event->set_runtime('ticket_url_label', $ticket->get_tickets_url_label($event, false));
     $event->set_runtime('edit_post_link', get_edit_post_link($event->get('post_id')));
     $event_post = $this->_registry->get('view.event.post');
     $event->set_runtime('post_excerpt', $event_post->trim_excerpt($event));
     $color = $this->_registry->get('view.event.color');
     $event->set_runtime('faded_color', $color->get_faded_color($event));
     $event->set_runtime('rgba_color', $color->get_rgba_color($event));
     $event->set_runtime('short_start_time', $this->_registry->get('view.event.time')->get_short_time($event->get('start')));
     $this->_add_view_specific_runtime_properties($event);
     $post = $original_post;
 }
示例#4
0
文件: agenda.php 项目: zhebiewang/WP
 protected function _add_view_specific_runtime_properties(Ai1ec_Event $event)
 {
     $taxonomy = $this->_registry->get('view.event.taxonomy');
     $avatar = $this->_registry->get('view.event.avatar');
     $event->set_runtime('categories_html', $taxonomy->get_categories_html($event));
     $event->set_runtime('tags_html', $taxonomy->get_tags_html($event));
     $event->set_runtime('content_img_url', $avatar->get_content_img_url($event));
 }
示例#5
0
 protected function _add_view_specific_runtime_properties(Ai1ec_Event $event)
 {
     $event->set_runtime('multiday', $event->get('_orig')->is_multiday());
 }
 protected function _add_view_specific_runtime_properties(Ai1ec_Event $event)
 {
     $end_day = $this->_registry->get('date.time', $event->get('end'))->adjust(-1, 'second')->format_i18n('d');
     $event->set_runtime('multiday_end_day', $end_day);
 }