Exemplo n.º 1
0
 public function set_render_strategy(Ai1ec_Request_Parser $request)
 {
     $type = $request->get('request_type');
     if (empty($type)) {
         $type = 'html';
     }
     $this->_render_strategy = $this->_registry->get('http.response.render.strategy.' . $type);
 }
Exemplo n.º 2
0
 public function set_render_strategy(Ai1ec_Request_Parser $request)
 {
     try {
         $this->_request_type = $request->get('request_type');
         $this->_render_strategy = $this->_registry->get('http.response.render.strategy.' . $this->_request_type);
     } catch (Ai1ec_Bootstrap_Exception $e) {
         $this->_request_type = 'html';
         $this->_render_strategy = $this->_registry->get('http.response.render.strategy.' . $this->_request_type);
     }
 }
 /**
  * Get the content if the calendar page
  *
  * @param Ai1ec_Request_Parser $request
  */
 public function get_content(Ai1ec_Request_Parser $request)
 {
     // Are we loading a shortcode?
     $shortcode = $request->get('shortcode');
     // Get args for the current view; required to generate HTML for views
     // dropdown list, categories, tags, subscribe buttons, and of course the
     // view itself.
     $view_args = $this->get_view_args_for_view($request);
     try {
         $action = $this->_registry->get('model.settings-view')->get_configured($view_args['action']);
     } catch (Ai1ec_Settings_Exception $exception) {
         // short-circuit and return error message
         return '<div id="ai1ec-container"><div class="timely"><p>' . Ai1ec_I18n::__('There was an error loading calendar. Please contact site administrator and inform him to configure calendar views.') . '</p></div></div>';
     }
     $type = $request->get('request_type');
     // Add view-specific args to the current view args.
     $exact_date = $this->get_exact_date($request);
     $view_obj = $this->_registry->get('view.calendar.view.' . $action, $request);
     $view_args = $view_obj->get_extra_arguments($view_args, $exact_date);
     // Get HTML for views dropdown list.
     $dropdown_args = $view_args;
     if (isset($dropdown_args['time_limit']) && false !== $exact_date) {
         $dropdown_args['exact_date'] = $exact_date;
     }
     $views_dropdown = $this->get_html_for_views_dropdown($dropdown_args, $view_obj);
     // Add views dropdown markup to view args.
     $view_args['views_dropdown'] = $views_dropdown;
     // Get HTML for categories and for tags
     $taxonomy = $this->_registry->get('view.calendar.taxonomy');
     $categories = $taxonomy->get_html_for_categories($view_args);
     $tags = $taxonomy->get_html_for_tags($view_args, true);
     // Get HTML for subscribe buttons.
     $subscribe_buttons = $this->get_html_for_subscribe_buttons($view_args);
     // Get HTML for view itself.
     $view = $view_obj->get_content($view_args);
     if (($view_args['no_navigation'] || $type !== 'html') && 'true' !== $shortcode) {
         $router = $this->_registry->get('routing.router');
         $are_filters_set = $router->is_at_least_one_filter_set_in_request($view_args);
         // send data both for json and jsonp as shortcodes are jsonp
         return array('html' => $view, 'categories' => $categories, 'tags' => $tags, 'views_dropdown' => $views_dropdown, 'subscribe_buttons' => $subscribe_buttons, 'are_filters_set' => $are_filters_set);
     } else {
         $loader = $this->_registry->get('theme.loader');
         $empty = $loader->get_file('empty.twig', array(), false);
         // Define new arguments for overall calendar view
         $filter_args = array('views_dropdown' => $views_dropdown, 'categories' => $categories, 'tags' => $tags, 'contribution_buttons' => apply_filters('ai1ec_contribution_buttons', ''), 'show_dropdowns' => apply_filters('ai1ec_show_dropdowns', true), 'show_select2' => apply_filters('ai1ec_show_select2', false), 'span_for_select2' => apply_filters('ai1ec_span_for_select2', ''), 'authors' => apply_filters('ai1ec_authors', ''), 'save_view_btngroup' => apply_filters('ai1ec_save_view_btngroup', $empty));
         $filter_menu = $loader->get_file('filter-menu.twig', $filter_args, false);
         $calendar_args = array('version' => AI1EC_VERSION, 'filter_menu' => $filter_menu, 'view' => $view, 'subscribe_buttons' => $subscribe_buttons, 'disable_standard_filter_menu' => apply_filters('ai1ec_disable_standard_filter_menu', false));
         $calendar = $loader->get_file('calendar.twig', $calendar_args, false);
         return $calendar->get_content();
     }
 }