コード例 #1
0
 /**
  * @return Ai1ec_Generic_Html_Tag
  */
 public static function create_save_filtered_view_buttongroup(array $view_args, $shortcode)
 {
     $btn_group = Ai1ec_Helper_Factory::create_generic_html_tag('div');
     $btn_group->add_class('btn-group');
     $btn = Ai1ec_Helper_Factory::create_bootstrap_button_instance();
     $btn->add_class('btn-mini ai1ec-tooltip-trigger');
     $btn->set_id('save_filtered_views');
     $icon = Ai1ec_Helper_Factory::create_generic_html_tag('icon');
     $icon->add_class('icon-pushpin');
     $btn->add_renderable_children($icon);
     $ai1ec_router = Ai1ec_Router::instance();
     $cookie_dto = $ai1ec_router->get_cookie_set_dto();
     $cookie_set = $cookie_dto->get_is_a_cookie_set_for_this_page();
     // if there are no filter set, but the cookie is set i need to show the button so that the cookie can be removed
     if (false === Ai1ec_Router::is_at_least_one_filter_set_in_request($view_args) && !$cookie_set) {
         $btn->add_class('hide');
     }
     $cookie = false;
     if (true === $cookie_set) {
         $cookie = 'true' === $shortcode ? $cookie_dto->get_shortcode_cookie() : $cookie_dto->get_calendar_cookie();
     }
     // If we have a cookie and the filters are in the same state of the cookie, show the remove version
     // Saving the same state again would not make sense
     // if we have a cookie and no filters are set, show the remove button, the user can't save the
     // standard calendar view
     if ($cookie_set && (self::check_if_saved_cookie_and_requested_page_match($view_args, $cookie) || false === Ai1ec_Router::is_at_least_one_filter_set_in_request($view_args))) {
         $btn->add_class('active');
         $text = __("Remove default filter", AI1EC_PLUGIN_NAME);
     } else {
         $text = __("Save this filter as default", AI1EC_PLUGIN_NAME);
     }
     // Add a span to hold text
     $btn->set_attribute('title', $text);
     $btn_group->add_renderable_children($btn);
     return $btn_group;
 }