Esempio n. 1
0
 /**
  * Factory method for events
  *
  * @param string $data
  * @param string $instance
  *
  * @return Ai1ec_Event
  */
 public function create_event_instance(Ai1ec_Registry_Object $registry, $data = null, $instance = false)
 {
     $use_backward_compatibility = $registry->get('compatibility.check')->use_backward_compatibility();
     if ($use_backward_compatibility && true === $this->_legacy) {
         return new Ai1ec_Event_Legacy($registry, $data, $instance);
     }
     $class_name = 'Ai1ec_Event';
     if ($use_backward_compatibility && 'Ai1ec_Event' === $class_name) {
         $class_name = 'Ai1ec_Event_Compatibility';
     }
     return new $class_name($registry, $data, $instance);
 }
Esempio n. 2
0
 /**
  * Public constructor
  *
  * @param Ai1ec_Registry_Object $registry
  * @param Ai1ec_Request_Parser $request
  *
  * @return void
  */
 public function __construct(Ai1ec_Registry_Object $registry, Ai1ec_Request_Parser $request)
 {
     $this->add_command($registry->get('command.disable-gzip', $request));
     $this->add_command($registry->get('command.export-events', $request));
     $this->add_command($registry->get('command.render-event', $request));
     $this->add_command($registry->get('command.render-calendar', $request));
     $this->add_command($registry->get('command.change-theme', $request));
     $this->add_command($registry->get('command.save-settings', $request, array('action' => 'ai1ec_save_settings', 'nonce_action' => Ai1ec_View_Admin_Settings::NONCE_ACTION, 'nonce_name' => Ai1ec_View_Admin_Settings::NONCE_NAME)));
     $this->add_command($registry->get('command.save-theme-options', $request, array('action' => 'ai1ec_save_theme_options', 'nonce_action' => Ai1ec_View_Theme_Options::NONCE_ACTION, 'nonce_name' => Ai1ec_View_Theme_Options::NONCE_NAME)));
     $this->add_command($registry->get('command.clone', $request));
     $request->parse();
     $this->_registry = $registry;
     $this->_request = $request;
 }
Esempio n. 3
0
 /**
  * Export the events using the specified engine.
  *
  * @param string $engine
  * @param array $args
  *
  * @throws Ai1ec_Engine_Not_Set_Exception
  */
 public function export_events($engine, array $args)
 {
     if (!isset($this->_engines[$engine])) {
         throw new Ai1ec_Engine_Not_Set_Exception('The engine ' . $engine . 'is not registered.');
     }
     // external engines must register themselves into the registry.
     $engine = $this->_registry->get('import-export.' . $engine);
     return $engine->export($args, $this->_params);
 }
Esempio n. 4
0
 /**
  * Widget function.
  *
  * Outputs the given instance of the widget to the front-end.
  *
  * @param  array $args     Display arguments passed to the widget
  * @param  array $instance The settings for this widget instance
  * @return void
  */
 public function widget($args, $instance)
 {
     $defaults = $this->get_defaults();
     $instance = wp_parse_args($instance, $defaults);
     $this->add_js();
     $args['widget_html'] = $this->get_content($instance);
     if (!empty($args['widget_html'])) {
         $args['title'] = $instance['title'];
         $args = $this->_filter_widget_args($args);
         // Display theme
         $this->_registry->get('theme.loader')->get_file('widget.twig', $args)->render();
     }
 }
Esempio n. 5
0
 /**
  * Echoes the Javascript if not cached.
  *
  * Echoes the javascript with the correct content.
  * Since the content is dinamic, i use the hash function.
  *
  * @param string $javascript
  *
  * @return void
  */
 private function _echo_javascript($javascript)
 {
     $conditional_get = new HTTP_ConditionalGet(array('contentHash' => md5($javascript)));
     $conditional_get->sendHeaders();
     if (!$conditional_get->cacheIsValid) {
         $http_encoder = $this->_registry->get('http.encoder', array('content' => $javascript, 'type' => 'text/javascript'));
         $compression_level = null;
         if ($this->_registry->get('model.settings')->get('disable_gzip_compression')) {
             // set the compression level to 0 to disable it.
             $compression_level = 0;
         }
         $http_encoder->encode($compression_level);
         $http_encoder->sendAll();
     }
     Ai1ec_Http_Response_Helper::stop(0);
 }
 /**
  * Add the link to render the javascript
  *
  * @param string $page
  * @param boolean $backend
  *
  * @return void
  */
 public function add_link_to_render_js($page, $backend)
 {
     $load_backend_script = 'false';
     if (true === $backend) {
         $load_backend_script = self::TRUE_PARAM;
     }
     $is_calendar_page = false;
     if (true === is_page($this->_settings->get('calendar_page_id')) || self::CALENDAR_PAGE_JS === $page) {
         $is_calendar_page = self::TRUE_PARAM;
     }
     $url = add_query_arg(array(self::LOAD_JS_PARAMETER => $page, self::IS_BACKEND_PARAMETER => $load_backend_script, self::IS_CALENDAR_PAGE => $is_calendar_page), trailingslashit(ai1ec_get_site_url()));
     if ($this->_settings->get('cache_dynamic_js') && $is_calendar_page && '1' === $this->_registry->get('model.option')->get('calendarjsupdated') && $this->_registry->get('filesystem.checker')->check_file_exists(AI1EC_PATH . self::CALENDAR_JS_CACHE_FILE, true)) {
         $url = plugin_dir_url('all-in-one-event-calendar/public/js_cache/.') . $page;
     }
     if (true === $backend) {
         $this->_scripts_helper->enqueue_script(self::JS_HANDLE, $url, array('postbox'), true);
     } else {
         $this->_scripts_helper->enqueue_script(self::JS_HANDLE, $url, array(), false);
     }
 }
 /**
  * Generate a timespan HTML block for an event.
  *
  * @param Ai1ec_Event $event              Event to generate timespan for.
  * @param string      $start_date_display Start date display format.
  *
  * @return string Rendered HTML timespan block.
  */
 public function timespan(Ai1ec_Event $event, $start_date_display = 'long')
 {
     return $this->_registry->get('view.event.time')->get_timespan_html($event, $start_date_display);
 }
 /**
  * Constructor
  *
  * @param Ai1ec_Registry_Object $registry
  *
  * @return void
  */
 public function __construct(Ai1ec_Registry_Object $registry)
 {
     $this->_db = $registry->get('dbi.dbi');
     $this->_prefixes = array($this->_db->get_table_name('ai1ec_'), $this->_db->get_table_name(), '');
 }
Esempio n. 9
0
 /**
  * Hooks into the_content filter to disable its output.
  *
  * @return void Method does not return.
  */
 public function ai1ec_disable_content_output()
 {
     $this->_registry->get('calendar.state')->set_append_content(false);
 }
 /**
  * Retrieve current theme display name.
  *
  * If the 'current_theme' option has already been set, then it will be returned
  * instead. If it is not set, then each theme will be iterated over until both
  * the current stylesheet and current template name.
  *
  * @since 1.5.0
  *
  * @return string
  */
 public function get_current_ai1ec_theme()
 {
     $option = $this->_registry->get('model.option');
     $theme = $option->get('ai1ec_current_theme', array());
     return $theme['stylesheet'];
 }
Esempio n. 11
0
 /**
  * Add cache instance to object scope.
  *
  * @param Ai1ec_Registry_Object $registry Registry object.
  *
  * @return Ai1ec_Option
  */
 public function __construct(Ai1ec_Registry_Object $registry)
 {
     $this->_registry = $registry;
     $this->_cache = $registry->get('cache.memory');
 }
 /**
  * Check if the schema needs to be updated
  * 
  * @param Ai1ec_Registry_Object $registry
  * @throws Ai1ec_Database_Update_Exception
  */
 protected function _install_schema(Ai1ec_Registry_Object $registry)
 {
     $option = $registry->get('model.option');
     $schema = self::$_schema;
     if (is_admin() && !empty($schema['schema'])) {
         $db_version_variable = 'ai1ec_' . $this->get_machine_name() . '_db_version';
         $version = sha1($schema['schema']);
         if ($option->get($db_version_variable) !== $version) {
             if ($registry->get('database.helper')->apply_delta($schema['schema'])) {
                 $option->set($db_version_variable, $version);
             } else {
                 throw new Ai1ec_Database_Update_Exception('Database upgrade for ' . $this->get_name() . ' failed');
             }
         }
     }
 }
Esempio n. 13
0
 /**
  * Legacy function needed for theme compatibility
  * 
  * @param string $format
  * @param int    $timestamp
  * @param bool   $is_gmt
  */
 public static function date_i18n($format, $timestamp = false, $is_gmt = true)
 {
     $timezone = $is_gmt ? 'UTC' : 'sys.default';
     return self::$_registry->get('date.time', $timestamp, $timezone)->format_i18n($format);
 }
Esempio n. 14
0
 public function __construct(Ai1ec_Registry_Object $registry)
 {
     $this->_registry = $registry;
     $this->template_adapter = $registry->get('html.helper');
 }
Esempio n. 15
0
 /**
  * Public constructor
  *
  * @param Ai1ec_Registry_Object $registry
  * @param Ai1ec_Request_Parser $request
  *
  * @return void
  */
 public function __construct(Ai1ec_Registry_Object $registry, Ai1ec_Request_Parser $request)
 {
     $this->add_command($registry->get('command.compile-themes', $request));
     $this->add_command($registry->get('command.disable-gzip', $request));
     $this->add_command($registry->get('command.export-events', $request));
     $this->add_command($registry->get('command.render-event', $request));
     $this->add_command($registry->get('command.render-calendar', $request));
     $this->add_command($registry->get('command.change-theme', $request));
     $this->add_command($registry->get('command.save-settings', $request, array('action' => 'ai1ec_save_settings', 'nonce_action' => Ai1ec_View_Admin_Settings::NONCE_ACTION, 'nonce_name' => Ai1ec_View_Admin_Settings::NONCE_NAME)));
     $this->add_command($registry->get('command.save-ticketing-invitation', $request, array('action' => 'ai1ec_ticketing_invitation_save', 'nonce_action' => Ai1ec_View_Admin_Ticketing_Invitation::NONCE_ACTION, 'nonce_name' => Ai1ec_View_Admin_Ticketing_Invitation::NONCE_NAME)));
     $this->add_command($registry->get('command.save-theme-options', $request, array('action' => 'ai1ec_save_theme_options', 'nonce_action' => Ai1ec_View_Theme_Options::NONCE_ACTION, 'nonce_name' => Ai1ec_View_Theme_Options::NONCE_NAME)));
     $this->add_command($registry->get('command.api-ticketing-signup', $request, array('action' => 'ai1ec_api_ticketing_signup', 'nonce_action' => Ai1ec_View_Tickets::NONCE_ACTION, 'nonce_name' => Ai1ec_View_Tickets::NONCE_NAME)));
     $this->add_command($registry->get('command.clone', $request));
     $this->add_command($registry->get('command.compile-core-css', $request));
     if (is_admin() && current_user_can('activate_plugins')) {
         $this->add_command($registry->get('command.check-updates', $request));
     }
     $request->parse();
     $this->_registry = $registry;
     $this->_request = $request;
 }
function ai1ec_csv_feed(Ai1ec_Registry_Object $registry)
{
    $registry->extension_acknowledge(AI1ECCF_PLUGIN_NAME, AI1ECCF_PATH);
    load_plugin_textdomain(AI1ECCF_PLUGIN_NAME, false, basename(AI1ECCF_PATH) . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR);
    $registry->get('controller.ai1eccf')->init($registry);
}
Esempio n. 17
0
 /**
  * Acquire references of global variables and define non-scalar values.
  *
  * @return void
  */
 public function __construct(Ai1ec_Registry_Object $registry)
 {
     $this->_dbi = $registry->get('dbi.dbi');
     $this->_tables = array($this->_dbi->get_table_name('ai1ec_events') => array('start', 'end'), $this->_dbi->get_table_name('ai1ec_event_instances') => array('start', 'end'), $this->_dbi->get_table_name('ai1ec_facebook_users_events') => array('start'));
     $this->_indices = array($this->_dbi->get_table_name('ai1ec_event_instances') => array('evt_instance' => array('unique' => true, 'columns' => array('post_id', 'start'), 'name' => 'evt_instance')));
 }
 /**
  * Widget function.
  *
  * Outputs the given instance of the widget to the front-end.
  *
  * @param  array $args     Display arguments passed to the widget
  * @param  array $instance The settings for this widget instance
  * @return void
  */
 public function widget($args, $instance)
 {
     $type = $this->get_name();
     $agenda = $this->_registry->get('view.calendar.view.agenda', $this->_registry->get('http.request.parser'));
     $time = $this->_registry->get('date.time');
     $search = $this->_registry->get('model.search');
     $settings = $this->_registry->get('model.settings');
     $html = $this->_registry->get('factory.html');
     $javascript = $this->_registry->get('controller.javascript');
     $javascript->add_link_to_render_js(Ai1ec_Javascript_Controller::LOAD_ONLY_FRONTEND_SCRIPTS, false);
     $defaults = array('hide_on_calendar_page' => true, 'event_cat_ids' => array(), 'event_tag_ids' => array(), 'events_per_page' => 10, 'days_per_page' => 10, 'events_seek_type' => 'events');
     $instance = wp_parse_args($instance, $defaults);
     if ($instance['hide_on_calendar_page'] && is_page($settings->get('calendar_page_id'))) {
         return;
     }
     // Add params to the subscribe_url for filtering by Limits (category, tag)
     $subscribe_filter = '';
     $subscribe_filter .= $instance['event_cat_ids'] ? '&ai1ec_cat_ids=' . join(',', $instance['event_cat_ids']) : '';
     $subscribe_filter .= $instance['event_tag_ids'] ? '&ai1ec_tag_ids=' . join(',', $instance['event_tag_ids']) : '';
     // Get localized time
     $timestamp = $time->format_to_gmt();
     // Set $limit to the specified category/tag
     $limit = array('cat_ids' => $instance['event_cat_ids'], 'tag_ids' => $instance['event_tag_ids']);
     // Get events, then classify into date array
     // JB: apply seek check here
     $seek_days = 'days' === $instance['events_seek_type'];
     $seek_count = $instance['events_per_page'];
     $last_day = false;
     if ($seek_days) {
         $seek_count = $instance['days_per_page'] * 5;
         $last_day = strtotime('+' . $instance['days_per_page'] . ' days');
     }
     $event_results = $search->get_events_relative_to($timestamp, $seek_count, 0, $limit);
     if ($seek_days) {
         foreach ($event_results['events'] as $ek => $event) {
             if ($event->get('start')->format() >= $last_day) {
                 unset($event_results['events'][$ek]);
             }
         }
     }
     $dates = $agenda->get_agenda_like_date_array($event_results['events']);
     $is_ticket_button_enabled = apply_filters('ai1ec_' . $type . '_ticket_button', false);
     $args['title'] = $instance['title'];
     $args['show_subscribe_buttons'] = $instance['show_subscribe_buttons'];
     $args['show_calendar_button'] = $instance['show_calendar_button'];
     $args['dates'] = $dates;
     $args['show_location_in_title'] = $settings->get('show_location_in_title');
     $args['show_year_in_agenda_dates'] = $settings->get('show_year_in_agenda_dates');
     $args['calendar_url'] = $html->create_href_helper_instance($limit)->generate_href();
     $args['subscribe_url'] = AI1EC_EXPORT_URL . $subscribe_filter;
     $args['subscribe_url_no_html'] = AI1EC_EXPORT_URL . '&no_html=true' . $subscribe_filter;
     $args['is_ticket_button_enabled'] = $is_ticket_button_enabled;
     $args['text_upcoming_events'] = __('There are no upcoming events.', AI1EC_PLUGIN_NAME);
     $args['text_all_day'] = __('all-day', AI1EC_PLUGIN_NAME);
     $args['text_view_calendar'] = __('View Calendar', AI1EC_PLUGIN_NAME);
     $args['text_edit'] = __('Edit', AI1EC_PLUGIN_NAME);
     $args['text_venue_separator'] = __('@ %s', AI1EC_PLUGIN_NAME);
     $args['text_subscribe_label'] = __('Add', AI1EC_PLUGIN_NAME);
     $args['subscribe_buttons_text'] = $this->_registry->get('view.calendar.subscribe-button')->get_labels();
     // Display theme
     $this->_registry->get('theme.loader')->get_file('agenda-widget.twig', $args)->render();
 }