/** * 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(); } }
public function do_execute() { // get the event html $instance = false; if (isset($_REQUEST['instance_id'])) { $instance = (int) $_REQUEST['instance_id']; } $event = $this->_registry->get('model.event', get_the_ID(), $instance); $event_page = null; $footer_html = ''; if (is_single()) { $event_page = $this->_registry->get('view.event.single'); $footer_html = $event_page->get_footer($event); } else { // return nothing for now return array('data' => '', 'is_event' => true); } $css = $this->_registry->get('css.frontend')->add_link_to_html_for_frontend(); $js = $this->_registry->get('controller.javascript')->load_frontend_js(false); if ('html' !== $this->_request_type) { return array('data' => array('html' => $event_page->get_full_article($event)), 'callback' => Ai1ec_Request_Parser::get_param('callback', null)); } $to_return = array('data' => $event_page->get_content($event), 'is_event' => true); if (!empty($footer_html)) { $to_return['footer'] = $event_page->get_footer($event); } return $to_return; }
public function do_execute() { // get the calendar html $calendar = $this->_registry->get('view.calendar.page'); $css = $this->_registry->get('css.frontend')->add_link_to_html_for_frontend(); $js = $this->_registry->get('controller.javascript')->load_frontend_js(true); return array('data' => $calendar->get_content($this->_request), 'callback' => Ai1ec_Request_Parser::get_param('callback', null), 'caller' => 'calendar'); }
/** * Gets parameters from the request object. * * @return array|boolean */ public function get_parameters() { $plugin = $controller = $action = null; $plugin = Ai1ec_Request_Parser::get_param('plugin', $plugin); $controller = Ai1ec_Request_Parser::get_param('controller', $controller); $action = Ai1ec_Request_Parser::get_param('action', $action); if ((string) AI1EC_PLUGIN_NAME === (string) $plugin && null !== $controller && null !== $action) { return array('controller' => $controller, 'action' => $action); } return false; }
public function is_this_to_execute() { $params = $this->get_parameters(); if (false === $params) { return false; } if ($params['action'] === self::EXPORT_METHOD && $params['controller'] === self::EXPORT_CONTROLLER) { $params['tag_ids'] = Ai1ec_Request_Parser::get_param('ai1ec_tag_ids', false); $params['cat_ids'] = Ai1ec_Request_Parser::get_param('ai1ec_cat_ids', false); $params['post_ids'] = Ai1ec_Request_Parser::get_param('ai1ec_post_ids', false); $params['lang'] = Ai1ec_Request_Parser::get_param('lang', false); $params['no_html'] = (bool) Ai1ec_Request_Parser::get_param('no_html', false); $this->_params = $params; return true; } return false; }
public function do_execute() { // If not on the single event page, return nothing. if (!is_single()) { return array('data' => '', 'is_event' => true); } // Else proceed with rendering valid event. Fetch all relevant details. $instance = false; if (isset($_REQUEST['instance_id'])) { $instance = (int) $_REQUEST['instance_id']; } $event = $this->_registry->get('model.event', get_the_ID(), $instance); $event_page = $this->_registry->get('view.event.single'); $footer_html = $event_page->get_footer($event); $css = $this->_registry->get('css.frontend')->add_link_to_html_for_frontend(); $js = $this->_registry->get('controller.javascript')->load_frontend_js(false); // If requesting event by JSON (remotely), return fully rendered event. if ('html' !== $this->_request_type) { return array('data' => array('html' => $event_page->get_full_article($event, $footer_html)), 'callback' => Ai1ec_Request_Parser::get_param('callback', null)); } // Else return event details as components. return array('data' => $event_page->get_content($event), 'is_event' => true, 'footer' => $footer_html); }
/** * set_current_page method * * Set ID of currently open page * * @param int $page_id ID of page currently open * * @return void Method does not return */ public static function set_current_page($page_id) { self::$current_page = $page_id; }