/**
     * Generate the html for the "Back to calendar" button for this event.
     *
     * @return string
     */
    public function get_back_to_calendar_button_html()
    {
        global $ai1ec_calendar_controller;
        $class = '';
        $data_type = "";
        $href = Ai1ec_View_Factory::create_href_helper_instance(array());
        $text = __('Back to Calendar', AI1EC_PLUGIN_NAME);
        if (isset($this->request)) {
            $data_type = "data-type='jsonp'";
            $class = "ai1ec-load-view";
            $view_args = $ai1ec_calendar_controller->get_view_args_for_view($this->request);
            $href = Ai1ec_View_Factory::create_href_helper_instance($view_args);
        }
        $href = $href->generate_href();
        $html = <<<HTML
<a class="ai1ec-calendar-link btn btn-small pull-right {$class}"
\t href="{$href}"
\t {$data_type}>
\t<i class="icon-arrow-left"></i> {$text}
</a>
HTML;
        return apply_filters('ai1ec_get_back_to_calendar_html', $html, $href);
    }
 /**
  * Returns a link to a calendar page without the given arguments; does not
  * otherwise disturb current page state.
  *
  * @param array $args           Current arguments to the calendar
  * @param array $args_to_remove Names of arguments to remove from current args
  *
  * @return string
  */
 private function generate_href_without_arguments(array $args, array $args_to_remove)
 {
     $args_to_remove = array_flip($args_to_remove);
     $args = array_diff_key($args, $args_to_remove);
     $href = Ai1ec_View_Factory::create_href_helper_instance($args);
     return $href->generate_href();
 }
 /**
  * Initializes the URL router used by our plugin.
  *
  * @return void Method is not intended to return anything
  */
 public function initialize_router()
 {
     global $ai1ec_settings, $ai1ec_router, $ai1ec_localization_helper;
     if (!isset($ai1ec_settings->calendar_page_id) || $ai1ec_settings->calendar_page_id < 1) {
         // Routing may not be affected in any way if no calendar page exists.
         return NULL;
     }
     $ai1ec_router = Ai1ec_Router::instance();
     $page_base = '';
     $clang = '';
     if ($ai1ec_localization_helper->is_wpml_active()) {
         $trans = $ai1ec_localization_helper->get_wpml_translations_of_page($ai1ec_settings->calendar_page_id, true);
         $clang = $ai1ec_localization_helper->get_language();
         if (isset($trans[$clang])) {
             $ai1ec_settings->calendar_page_id = $trans[$clang];
         }
     }
     $page_base = get_page_link($ai1ec_settings->calendar_page_id);
     $page_base = Ai1ec_Wp_Uri_Helper::get_pagebase($page_base);
     $page_link = 'index.php?page_id=' . $ai1ec_settings->calendar_page_id;
     $pagebase_for_href = Ai1ec_Wp_Uri_Helper::get_pagebase_for_links(get_page_link($ai1ec_settings->calendar_page_id), $clang);
     // Add a trailing slash if it is missing and we are using permalinks.
     if (Ai1ec_Meta::get_option('permalink_structure')) {
         $pagebase_for_href = trailingslashit($pagebase_for_href);
     }
     // Set up the view factory.
     Ai1ec_View_Factory::set_page($pagebase_for_href);
     // If the calendar is set as the front page, disable permalinks.
     // They would not be legal under a Windows server. See:
     // https://issues.apache.org/bugzilla/show_bug.cgi?id=41441
     if (Ai1ec_Meta::get_option('permalink_structure') && (int) get_option('page_on_front') !== (int) $ai1ec_settings->calendar_page_id) {
         Ai1ec_View_Factory::set_pretty_permalinks_enabled(true);
     }
     // If we are requesting the calendar page and we have a saved cookie,
     // redirect the user. Do not redirect if the user saved the home page,
     // otherwise we enter a loop.
     $cookie_dto = $ai1ec_router->get_cookie_set_dto();
     if (true === $cookie_dto->get_is_cookie_set_for_calendar_page()) {
         $cookie = $cookie_dto->get_calendar_cookie();
         $href = Ai1ec_View_Factory::create_href_helper_instance($cookie);
         // wp_redirect sanitizes the url which strips out the |
         header('Location: ' . $href->generate_href(), true, '302');
         exit(0);
     }
     // We need to reset the cookie, it's to early for the is_page() call
     $ai1ec_router->set_cookie_set_dto();
     // Initialize SEO helper.
     Ai1ec_Seo_Helper::get_instance();
     $ai1ec_router = Ai1ec_Router::instance()->asset_base($page_base)->register_rewrite($page_link);
 }