/**
  *
  * @see Ai1ec_Connector_Plugin::render_tab_content()
  *
  */
 public function render_tab_content()
 {
     global $ai1ec_view_helper;
     $this->render_opening_div_of_tab();
     $file_input = Ai1ec_Helper_Factory::create_input_instance();
     $file_input->set_type('file');
     $file_input->set_id(self::NAME_OF_FILE_INPUT);
     $file_input->set_name(self::NAME_OF_FILE_INPUT);
     $submit = Ai1ec_Helper_Factory::create_input_instance();
     $submit->set_type('submit');
     $submit->add_class('button-primary');
     $submit->set_name(self::NAME_OF_SUBMIT);
     $submit->set_id(self::NAME_OF_SUBMIT);
     $submit->set_value(__('Submit Events', AI1EC_PLUGIN_NAME));
     $textarea = Ai1ec_Helper_Factory::create_generic_html_tag('textarea');
     $textarea->set_attribute('name', self::NAME_OF_TEXTAREA);
     $textarea->set_attribute('rows', 6);
     $textarea->set_id(self::NAME_OF_TEXTAREA);
     $facebook_tab = Ai1ec_Facebook_Factory::get_facebook_tab_instance();
     $category_select = $facebook_tab->create_select_category('ai1ec_file_upload_feed_category');
     $message = false;
     if (isset($this->count)) {
         $text = __('No events were found', AI1EC_PLUGIN_NAME);
         if ($this->count > 0) {
             $text = sprintf(_n('Imported %s event', 'Imported %s events', $this->count, AI1EC_PLUGIN_NAME), $this->count);
         }
         $message = Ai1ec_Helper_Factory::create_bootstrap_message_instance($text);
     }
     $args = array("category_select" => $category_select, "submit" => $submit, "file_input" => $file_input, "textarea" => $textarea);
     if (false !== $message) {
         $args['message'] = $message;
     }
     $ai1ec_view_helper->display_admin('plugins/file_upload/file_upload.php', $args);
     $this->render_closing_div_of_tab();
 }
 /**
  * Create the html element used as the UI control for the datepicker button.
  * The href must keep only active filters.
  *
  * @param array           $args         Populated args for the view
  * @param int|string|null $initial_date The datepicker's initially set date
  * @return Ai1ec_Generic_Html_Tag
  */
 public static function create_datepicker_link(array $args, $initial_date = null)
 {
     global $ai1ec_settings, $ai1ec_view_helper;
     $link = Ai1ec_Helper_Factory::create_generic_html_tag('a');
     $date_format_pattern = Ai1ec_Time_Utility::get_date_pattern_by_key($ai1ec_settings->input_date_format);
     if ($initial_date == null) {
         // If exact_date argument was provided, use its value to initialize
         // datepicker.
         if (isset($args['exact_date']) && $args['exact_date'] !== false && $args['exact_date'] !== null) {
             $initial_date = $args['exact_date'];
         } else {
             $initial_date = Ai1ec_Time_Utility::gmt_to_local(Ai1ec_Time_Utility::current_time());
         }
     }
     // Convert initial date to formatted date if required.
     if (Ai1ec_Validation_Utility::is_valid_time_stamp($initial_date)) {
         $initial_date = Ai1ec_Time_Utility::format_date(Ai1ec_Time_Utility::gmt_to_local($initial_date), $ai1ec_settings->input_date_format);
     }
     $link->add_class('ai1ec-minical-trigger btn');
     $link->set_attribute('data-date', $initial_date);
     $link->set_attribute('data-date-format', $date_format_pattern);
     $link->set_attribute('data-date-weekstart', $ai1ec_settings->week_start_day);
     $link->set_attribute_expr($args['data_type']);
     $text = '<img src="' . esc_attr($ai1ec_view_helper->get_theme_img_url('date-icon.png')) . '" class="ai1ec-icon-datepicker" />';
     $link->set_text($text);
     $href_args = array('action' => $args['action'], 'cat_ids' => $args['cat_ids'], 'tag_ids' => $args['tag_ids'], 'exact_date' => "__DATE__");
     $data_href = self::create_href_helper_instance($href_args);
     $link->set_attribute('data-href', $data_href->generate_href());
     $link->set_attribute('href', '#');
     return $link;
 }
 /**
  * 
  * @return Ai1ec_Generic_Html_Tag
  */
 public static function create_refresh_token_button()
 {
     $timely = Ai1ec_Helper_Factory::create_generic_html_tag('div');
     $timely->add_class('timely ai1ec_refresh_tokens');
     $refresh_tokens = Ai1ec_Helper_Factory::create_generic_html_tag('button');
     $refresh_tokens->set_id('ai1ec_refresh_tokens');
     $refresh_tokens->add_class('btn');
     $refresh_tokens->set_text(__("Refresh page tokens", AI1EC_PLUGIN_NAME));
     $timely->add_renderable_children($refresh_tokens);
     return $timely;
 }
 /**
  * Adds al the elements to the page.
  * I took this out of the factory so that it's done only if the page is clicked
  */
 private function add_renderables_to_page()
 {
     // These are the tabs
     $tabs_ids_description = array('general' => __('General', AI1EC_PLUGIN_NAME), 'table' => __('Tables', AI1EC_PLUGIN_NAME), 'buttons' => __('Buttons', AI1EC_PLUGIN_NAME), 'forms' => __('Forms', AI1EC_PLUGIN_NAME), 'calendar' => __('Calendar general', AI1EC_PLUGIN_NAME), 'posterboard' => __('Posterboard view', AI1EC_PLUGIN_NAME), 'stream' => __('Stream view', AI1EC_PLUGIN_NAME), 'month' => __('Month/week/day view', AI1EC_PLUGIN_NAME), 'agenda' => __('Agenda view', AI1EC_PLUGIN_NAME));
     // Create the tab layout
     $bootstrap_tabs_layout = Ai1ec_Helper_Factory::create_bootstrap_tabs_layout_instance();
     $bootstrap_tabs_layout->set_layout('left');
     $less_variables = Ai1ec_Lessphp_Controller::get_saved_variables(Ai1ec_Adapters_Factory::create_db_adapter_instance());
     // Inizialize the array of tabs that will be added to the layout
     $bootstrap_tabs_to_add = array();
     // initialize the array of tab bodyes that will be added to the tabs
     $tabs_bodies = array();
     foreach ($tabs_ids_description as $id => $description) {
         $bootstrap_tabs_to_add["ai1ec-{$id}"] = Ai1ec_Helper_Factory::create_bootstrap_tab_instance($id, $description);
         $bootstrap_tabs_to_add["ai1ec-{$id}"]->add_class('form-horizontal');
         // create the main div that will hold all the variables
         $div = Ai1ec_Helper_Factory::create_generic_html_tag('div');
         $tabs_bodies["ai1ec-{$id}"] = $div;
     }
     foreach ($less_variables as $variable_id => $variable_attributes) {
         $variable_attributes['id'] = $variable_id;
         $less_variable = Ai1ec_Less_Factory::create_less_variable($variable_attributes['type'], $variable_attributes);
         $tabs_bodies["ai1ec-{$variable_attributes['tab']}"]->add_renderable_children($less_variable);
     }
     foreach ($tabs_bodies as $tab => $div) {
         $bootstrap_tabs_to_add[$tab]->add_renderable_children($div);
     }
     foreach ($bootstrap_tabs_to_add as $tab) {
         $bootstrap_tabs_layout->add_renderable_children($tab);
     }
     $this->add_renderable_children($bootstrap_tabs_layout);
     $input = Ai1ec_Helper_Factory::create_input_instance();
     $input->set_type('submit');
     $input->set_value(__('Save Options', AI1EC_PLUGIN_NAME));
     $input->set_name(Ai1ec_Less_Variables_Editing_Page::FORM_SUBMIT_NAME);
     $input->add_class("button-primary");
     $reset_theme = Ai1ec_Helper_Factory::create_input_instance();
     $reset_theme->set_type('submit');
     $reset_theme->set_value(__('Reset to defaults', AI1EC_PLUGIN_NAME));
     $reset_theme->set_name(Ai1ec_Less_Variables_Editing_Page::FORM_SUBMIT_RESET_THEME);
     $reset_theme->add_class("button");
     $reset_theme->set_id('ai1ec-reset-variables');
     $this->add_renderable_children($input);
     $this->add_renderable_children($reset_theme);
 }
 /**
  *
  * @see Ai1ec_Renderable::render()
  *
  */
 public function render()
 {
     $label = Ai1ec_Helper_Factory::create_generic_html_tag('label');
     $label->set_attribute('for', $this->id);
     $label->add_class('radio');
     $label->set_text($this->label);
     $label->set_prepend_text(false);
     $radio = Ai1ec_Helper_Factory::create_input_instance();
     $radio->set_type('radio');
     $radio->set_id($this->id);
     $radio->set_value($this->id);
     $radio->set_name($this->name);
     if (isset($this->args['checked'])) {
         $radio->set_attribute('checked', 'checked');
     }
     $label->add_renderable_children($radio);
     $label->render();
 }
 /**
  *
  * @see Ai1ec_Renderable::render()
  *
  */
 public function render()
 {
     $select = Ai1ec_Helper_Factory::create_generic_html_tag('select');
     $select->set_id($this->id);
     foreach ($this->attributes as $name => $value) {
         $select->set_attribute($name, $value);
     }
     foreach ($this->classes as $class) {
         $select->add_class($class);
     }
     foreach ($this->options as $option) {
         $value = $option->get_attribute('value');
         if (isset($this->values[$value[0]])) {
             $option->set_attribute('selected', 'selected');
         }
         $select->add_renderable_children($option);
     }
     $select->render();
 }
 public function render()
 {
     $close = Ai1ec_Helper_Factory::create_generic_html_tag('a');
     $close->set_attribute('data-dismiss', 'alert');
     $close->add_class('close');
     $close->set_attribute('href', '#');
     $close->set_text('x');
     $container = Ai1ec_Helper_Factory::create_generic_html_tag('div');
     $container->add_class('alert');
     switch ($this->type) {
         case "success":
             $container->add_class('alert-success');
             break;
         case "error":
             $container->add_class('alert-error');
             break;
         default:
             break;
     }
     $container->set_prepend_text(false);
     $container->set_text($this->message);
     $container->add_renderable_children($close);
     $container->render();
 }
 /**
  * @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;
 }
 /**
  * Create the modal for the event subscription
  *
  * @param $event Ai1ec_Event
  */
 private function add_modal_for_email_subscription(Ai1ec_Event $event)
 {
     $current_user = wp_get_current_user();
     $user_email = $current_user->user_email;
     unset($current_user);
     // Create containing div
     $div = Ai1ec_Helper_Factory::create_generic_html_tag('div');
     $div->add_class('ai1ec_email_container form-horizontal');
     $div->set_attribute('data-event_id', $event->post_id);
     $div->set_attribute('data-event_instance', $event->instance_id);
     // Add alert container to containing div
     $div_alerts = Ai1ec_Helper_Factory::create_generic_html_tag('div');
     $div_alerts->add_class('alerts');
     // Add paragraph to containing div
     $paragraph = Ai1ec_Helper_Factory::create_generic_html_tag('p');
     $paragraph->set_text(__('Enter your email address below to receive a notification about the event 6 hours before it starts.', AI1EC_PLUGIN_NAME));
     $div->add_renderable_children($paragraph);
     // Add div.control-group to containing div
     $control_group = Ai1ec_Helper_Factory::create_generic_html_tag('div');
     $control_group->add_class('control-group');
     $div->add_renderable_children($control_group);
     // Add label to div.control-group
     $label = Ai1ec_Helper_Factory::create_generic_html_tag('label');
     $label->add_class('control-label');
     $label->set_attribute('for', 'ai1ec_email_subscribe');
     $label->set_text(__('Email:', AI1EC_PLUGIN_NAME));
     $control_group->add_renderable_children($label);
     // Add div.controls to div.control-group
     $controls = Ai1ec_Helper_Factory::create_generic_html_tag('div');
     $controls->add_class('controls');
     $control_group->add_renderable_children($controls);
     // Add input to div.controls
     $input = Ai1ec_Helper_Factory::create_input_instance();
     $input->set_id('ai1ec_email_subscribe');
     $input->set_name('ai1ec_email_subscribe');
     if (!empty($user_email)) {
         $input->set_value($user_email);
     }
     $input->set_attribute('placeholder', __('Email', AI1EC_PLUGIN_NAME));
     $controls->add_renderable_children($input);
     // Create modal and add our enclosing div to it
     $bootstrap_modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance($div_alerts->render_as_html() . $div->render_as_html());
     $bootstrap_modal->set_header_text(__('Get notified about this event', AI1EC_PLUGIN_NAME));
     $bootstrap_modal->set_id('ai1ec_subscribe_email_modal');
     $bootstrap_modal->add_class('fade');
     $bootstrap_modal->set_keep_button_text('<i class="icon-ok"></i> ' . __('Subscribe', AI1EC_PLUGIN_NAME));
     $bootstrap_modal->set_delete_button_text('<i class="icon-remove"></i> ' . __('Close', AI1EC_PLUGIN_NAME));
     $ai1ec_deferred_helper = Ai1ec_Deferred_Rendering_Helper::get_instance();
     $ai1ec_deferred_helper->add_renderable_children($bootstrap_modal);
 }