/** * Renders the Facebook Graph Object that user has subscribed to. * * @param array $types the Type of Facebook Graph Objects to render * * @param $current_id The id of the currently logged on user which must be excluded from subscribers and multiselects * * @return string the HTML */ private function render_subscribers(array $types, $current_id) { $subscribers = $this->render_all_elements($types, FALSE, $current_id); $html = ''; foreach ($types as $type) { $text = Ai1ec_Facebook_Graph_Object_Collection::get_type_printable_text($type); $html .= <<<HTML <div class="ai1ec-facebook-items" data-type="{$type}"> \t<h2 class="ai1ec-facebook-header">{$text}</h2> \t{$subscribers[$type]} </div> HTML; } $keep_events = __("Keep Events", AI1EC_PLUGIN_NAME); $remove_events = __("Remove Events", AI1EC_PLUGIN_NAME); $body = __("Would you like to remove these events from your calendar, or preserve them?", AI1EC_PLUGIN_NAME); $removing = __("Removing the following subscription: ", AI1EC_PLUGIN_NAME); $header_text = $removing . '<span id="ai1ec-facebook-user-modal"></span>'; // Attach the modal for when you unsubscribe. $twitter_bootstrap_modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance($body); $twitter_bootstrap_modal->set_id('ai1ec-facebook-modal'); $twitter_bootstrap_modal->set_delete_button_text($remove_events); $twitter_bootstrap_modal->set_keep_button_text($keep_events); $twitter_bootstrap_modal->set_header_text($header_text); $html .= $twitter_bootstrap_modal->render_as_html(); return $html; }
/** * Creates the HTML to display on the "Add new event" page so that the user can choose to export the event to Facebook. * * @return string an empty string or the html to show */ public function render_export_box() { global $post; // We only want this for events. if ($post->post_type !== AI1EC_POST_TYPE) { return; } try { $event = new Ai1ec_Event($post->ID); } catch (Ai1ec_Event_Not_Found $e) { // Post exists, but event data hasn't been saved yet. Create new event // object. $event = NULL; } // If we have an event end the event was imported from facebook, return, we can't export it. if ($event !== NULL && $event->facebook_status === Ai1ecFacebookConnectorPlugin::FB_IMPORTED_EVENT) { return; } $facebook = $this->facebook_instance_factory(); // Let's check if we have a user in session if ($this->get_current_facebook_user_from_cache() === NULL) { // No user in session, let's see if we have a token and the user can login. $current_user = Ai1ec_Facebook_Factory::get_facebook_user_instance($facebook); $logged_in = $current_user->do_login(); // If the user couldn't login, do not print anything but return an hidden inpsave_current_facebook_user_in_sessionut, in this way the // plugin save post handler simply returns. if ($logged_in === FALSE) { $hidden_input_name = self::FB_HIDDEN_INPUT_NO_ACTIVE_TOKEN; echo "<input type='hidden' name='{$hidden_input_name}' value='1' />"; return; } // Save it in session. $this->save_facebook_user_in_cache($current_user); } $checked = ''; if ($event !== NULL && $event->facebook_status === Ai1ecFacebookConnectorPlugin::FB_EXPORTED_EVENT) { $checked = 'checked'; } $link = ''; $modal_html = ''; $pages_html = ''; $tokens = array(); $refresh_button = ''; if (isset($event->facebook_eid) && (int) $event->facebook_eid !== 0) { $link_label = __("Linked Facebook event", AI1EC_PLUGIN_NAME); $link = "<div id='ai1ec-facebook-linked-event'><a href='https://www.facebook.com/events/{$event->facebook_eid}'>{$link_label}</a></div>"; // We include the modal only when the event has been exported to facebook $twitter_bootstrap_modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance(__("Would you like to delete the linked Facebook event or keep it? If you choose to keep it and later you export this event again, a new one will be created.", AI1EC_PLUGIN_NAME)); $twitter_bootstrap_modal->set_header_text(__("Unpublish Facebook event?", AI1EC_PLUGIN_NAME)); $twitter_bootstrap_modal->set_id("ai1ec-facebook-export-modal"); $twitter_bootstrap_modal->set_delete_button_text(__("Delete event", AI1EC_PLUGIN_NAME)); $twitter_bootstrap_modal->set_keep_button_text(__("Keep event", AI1EC_PLUGIN_NAME)); $modal_html = $twitter_bootstrap_modal->render_as_html(); } else { // check if page tokens are set $pages = $this->get_plugin_variable(self::PAGE_TOKENS); if (false === $pages) { $pages = $this->set_token_for_pages($facebook); } $current_user = $this->get_current_facebook_user_from_cache(); if (!empty($pages)) { $pages_html = Ai1ec_Facebook_Factory::create_export_to_pages_html($pages, $current_user); } $refresh_button = Ai1ec_Facebook_Factory::create_refresh_token_button(); } $label = __('Export event to Facebook?', AI1EC_PLUGIN_NAME); $name = self::FB_EXPORT_CHKBX_NAME; $html = <<<HTML <div id="ai1ec-facebook-publish" class="misc-pub-section"> \t<div id="ai1ec-facebook-small-logo"></div> \t<label for="{$name}"> \t\t{$label} \t</label> \t<input type="checkbox" {$checked} name="{$name}" id="{$name}" value="1" /> \t{$link} \t{$pages_html} \t{$refresh_button} </div> <div class="timely"> {$modal_html} </div> HTML; echo $html; }
/** * (non-PHPdoc) * @see Ai1ec_Connector_Plugin::render_tab_content() */ public function render_tab_content() { // Render the opening div $this->render_opening_div_of_tab(); // Render the body of the tab global $ai1ec_view_helper, $ai1ec_settings_helper, $ai1ec_settings; $select2_cats = Ai1ec_View_Factory::create_select2_multiselect(array('name' => 'ai1ec_feed_category[]', 'id' => 'ai1ec_feed_category', 'use_id' => true, 'type' => 'category', 'placeholder' => __('Categories (optional)', AI1EC_PLUGIN_NAME)), get_terms('events_categories', array('hide_empty' => false))); $select2_tags = Ai1ec_View_Factory::create_select2_tags(array('id' => 'ai1ec_feed_tags')); $modal = Ai1ec_Helper_Factory::create_bootstrap_modal_instance(esc_html__("Do you want to keep the events imported from the calendar or remove them?", AI1EC_PLUGIN_NAME)); $modal->set_header_text(esc_html__("Removing ICS Feed", AI1EC_PLUGIN_NAME)); $modal->set_keep_button_text(esc_html__("Keep Events", AI1EC_PLUGIN_NAME)); $modal->set_delete_button_text(esc_html__("Remove Events", AI1EC_PLUGIN_NAME)); $modal->set_id('ai1ec-ics-modal'); $args = array('cron_freq' => $ai1ec_settings_helper->get_cron_freq_dropdown($ai1ec_settings->cron_freq), 'event_categories' => $select2_cats, 'event_tags' => $select2_tags, 'feed_rows' => $ai1ec_settings_helper->get_feed_rows(), 'modal' => $modal); $ai1ec_view_helper->display_admin('plugins/ics/display_feeds.php', $args); $this->render_closing_div_of_tab(); }
/** * 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); }