Ejemplo n.º 1
0
 public function do_execute()
 {
     $ai1ec_cat_ids = $this->_params['cat_ids'];
     $ai1ec_tag_ids = $this->_params['tag_ids'];
     $ai1ec_post_ids = $this->_params['post_ids'];
     if (!empty($this->_params['lang'])) {
         $loc_helper = $this->_registry->get('p28n.wpml');
         $loc_helper->set_language($this->_params['lang']);
     }
     $args = array('do_not_export_as_calendar' => false);
     $filter = array();
     if ($ai1ec_cat_ids) {
         $filter['cat_ids'] = Ai1ec_Primitive_Int::convert_to_int_list(',', $ai1ec_cat_ids);
     }
     if ($ai1ec_tag_ids) {
         $filter['tag_ids'] = Ai1ec_Primitive_Int::convert_to_int_list(',', $ai1ec_tag_ids);
     }
     if ($ai1ec_post_ids) {
         $args['do_not_export_as_calendar'] = true;
         $filter['post_ids'] = Ai1ec_Primitive_Int::convert_to_int_list(',', $ai1ec_post_ids);
     }
     $filter = apply_filters('ai1ec_export_filter', $filter);
     // when exporting events by post_id, do not look up the event's start/end date/time
     $start = $ai1ec_post_ids !== false ? $this->_registry->get('date.time', '-3 years') : $this->_registry->get('date.time', time() - 24 * 60 * 60);
     // Include any events ending today
     $end = $this->_registry->get('date.time', '+3 years');
     $search = $this->_registry->get('model.search');
     $params = array('no_html' => $this->_params['no_html'], 'xml' => $this->_params['xml']);
     $export_controller = $this->_registry->get('controller.import-export', array('ics'), $params);
     $args['events'] = $this->unique_events($search->get_events_between($start, $end, $filter));
     $ics = $export_controller->export_events('ics', $args);
     return array('data' => $ics);
 }