/**
  * get_repeat_box function
  *
  * @return string
  **/
 public function get_repeat_box()
 {
     $time_system = $this->_registry->get('date.system');
     $loader = $this->_registry->get('theme.loader');
     $repeat = (int) $_REQUEST["repeat"];
     $repeat = $repeat == 1 ? 1 : 0;
     $post_id = (int) $_REQUEST["post_id"];
     $count = 100;
     $end = NULL;
     $until = $time_system->current_time(true);
     // try getting the event
     try {
         $event = $this->_registry->get('model.event', $post_id);
         $rule = '';
         if ($repeat) {
             $rule = $event->get('recurrence_rules') ? '' : $event->get('recurrence_rules');
         } else {
             $rule = $event->get('exception_rules') ? '' : $event->get('exception_rules');
         }
         $rc = new SG_iCal_Recurrence(new SG_iCal_Line('RRULE:' . $rule));
         if ($until = $rc->getUntil()) {
             $until = is_numeric($until) ? $until : strtotime($until);
         } elseif ($count = $rc->getCount()) {
             $count = is_numeric($count) ? $count : 100;
         }
     } catch (Ai1ec_Event_Not_Found_Exception $e) {
         /* event wasn't found, keep defaults */
     }
     $args = array('row_daily' => $this->row_daily(), 'row_weekly' => $this->row_weekly(), 'row_monthly' => $this->row_monthly(), 'row_yearly' => $this->row_yearly(), 'count' => $this->create_count_input('ai1ec_count', $count) . Ai1ec_I18n::__('times'), 'end' => $this->create_end_dropdown($end), 'until' => $until, 'repeat' => $repeat);
     $output = array('error' => false, 'message' => $loader->get_file('box_repeat.php', $args, true)->get_content(), 'repeat' => $repeat);
     $json_strategy = $this->_registry->get('http.response.render.strategy.json');
     $json_strategy->render(array('data' => $output));
 }
Example #2
0
 /**
  * get_repeat_box function
  *
  * @return string
  **/
 public function get_repeat_box()
 {
     $time_system = $this->_registry->get('date.system');
     $loader = $this->_registry->get('theme.loader');
     $repeat = (int) $_REQUEST["repeat"];
     $repeat = $repeat == 1 ? 1 : 0;
     $post_id = (int) $_REQUEST["post_id"];
     $count = 100;
     $end = 0;
     $until = $time_system->current_time(true);
     // try getting the event
     try {
         $event = $this->_registry->get('model.event', $post_id);
         $rule = '';
         if ($repeat) {
             $rule = $event->get('recurrence_rules') ? $event->get('recurrence_rules') : '';
         } else {
             $rule = $event->get('exception_rules') ? $event->get('exception_rules') : '';
         }
         $rule = $this->_registry->get('recurrence.rule')->filter_rule($rule);
         $rc = new SG_iCal_Recurrence(new SG_iCal_Line('RRULE:' . $rule));
         if ($until = $rc->getUntil()) {
             $until = is_numeric($until) ? $until : strtotime($until);
             $end = 2;
         } elseif ($count = $rc->getCount()) {
             $count = is_numeric($count) ? $count : 100;
             $end = 1;
         }
     } catch (Ai1ec_Event_Not_Found_Exception $e) {
         $rule = '';
         $rc = new SG_iCal_Recurrence(new SG_iCal_Line('RRULE:'));
     }
     $args = array('row_daily' => $this->row_daily(false, $rc->getInterval() ? $rc->getInterval() : 1), 'row_weekly' => $this->row_weekly(false, $rc->getInterval() ? $rc->getInterval() : 1, is_array($rc->getByDay()) ? $rc->getByDay() : array()), 'row_monthly' => $this->row_monthly(false, $rc->getInterval() ? $rc->getInterval() : 1, !$this->_is_monthday_empty($rc), $rc->getByMonthDay() ? $rc->getByMonthDay() : array(), $rc->getByDay() ? $rc->getByDay() : array()), 'row_yearly' => $this->row_yearly(false, $rc->getInterval() ? $rc->getInterval() : 1, is_array($rc->getByMonth()) ? $rc->getByMonth() : array()), 'row_custom' => $this->row_custom(false, $this->get_date_array_from_rule($rule)), 'count' => $this->create_count_input('ai1ec_count', $count) . Ai1ec_I18n::__('times'), 'end' => $this->create_end_dropdown($end), 'until' => $until, 'repeat' => $repeat, 'ending_type' => $end, 'selected_tab' => $rc->getFreq() ? strtolower($rc->getFreq()) : 'custom');
     $output = array('error' => false, 'message' => $loader->get_file('box_repeat.php', $args, true)->get_content(), 'repeat' => $repeat);
     $json_strategy = $this->_registry->get('http.response.render.strategy.json');
     $json_strategy->render(array('data' => $output));
 }
 /**
  * get_repeat_box function
  *
  * @return string
  **/
 function get_repeat_box()
 {
     global $ai1ec_view_helper;
     $repeat = (int) $_REQUEST["repeat"];
     $repeat = $repeat == 1 ? 1 : 0;
     $post_id = (int) $_REQUEST["post_id"];
     $count = 100;
     $end = null;
     $until = Ai1ec_Time_Utility::current_time(true);
     // try getting the event
     try {
         $event = new Ai1ec_Event($post_id);
         $rule = '';
         if ($repeat) {
             $rule = empty($event->recurrence_rules) ? '' : $event->recurrence_rules;
         } else {
             $rule = empty($event->exception_rules) ? '' : $event->exception_rules;
         }
         $rc = new SG_iCal_Recurrence(new SG_iCal_Line('RRULE:' . $rule));
         if ($until = $rc->getUntil()) {
             $until = is_numeric($until) ? $until : strtotime($until);
         } else {
             if ($count = $rc->getCount()) {
                 $count = is_numeric($count) ? $count : 100;
             }
         }
     } catch (Ai1ec_Event_Not_Found $e) {
         /* event wasn't found, keep defaults */
     }
     $args = array('row_daily' => $this->row_daily(), 'row_weekly' => $this->row_weekly(), 'row_monthly' => $this->row_monthly(), 'row_yearly' => $this->row_yearly(), 'count' => $this->create_count_input('ai1ec_count', $count) . __('times', AI1EC_PLUGIN_NAME), 'end' => $this->create_end_dropdown($end), 'until' => $until, 'repeat' => $repeat);
     $output = array("error" => false, "message" => $ai1ec_view_helper->get_admin_view('box_repeat.php', $args), "repeat" => $repeat);
     echo json_encode($output);
     exit;
 }
 public function testGetCountWithCountNotSetReturnsFalse()
 {
     $line = new SG_iCal_Line('RRULE:FREQ=DAILY;UNTIL=19971224T000000Z');
     $recurrence = new SG_iCal_Recurrence($line);
     $this->assertSame(false, $recurrence->getCount());
 }