当前位置: 首页>>代码示例>>PHP>>正文


PHP Reminder::createFrom方法代码示例

本文整理汇总了PHP中Reminder::createFrom方法的典型用法代码示例。如果您正苦于以下问题:PHP Reminder::createFrom方法的具体用法?PHP Reminder::createFrom怎么用?PHP Reminder::createFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Reminder的用法示例。


在下文中一共展示了Reminder::createFrom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: modify

 /**
  * Creates or modifies an existing event
  * TODO: detect if we are defining a new recurrence-id
  */
 function modify()
 {
     // Important data to be filled later
     $etag = '';
     $href = '';
     $calendar = '';
     $resource = null;
     // Default new properties. To be cleaned
     // on Icshelper library
     $p = $this->input->post(null, TRUE);
     // XSS
     $this->load->library('form_validation');
     $this->form_validation->set_rules('calendar', $this->i18n->_('labels', 'calendar'), 'required');
     $this->form_validation->set_rules('summary', $this->i18n->_('labels', 'summary'), 'required');
     $this->form_validation->set_rules('start_date', $this->i18n->_('labels', 'startdate'), 'required|callback__valid_date');
     $this->form_validation->set_rules('end_date', $this->i18n->_('labels', 'enddate'), 'required|callback__valid_date');
     $this->form_validation->set_rules('recurrence_count', $this->i18n->_('labels', 'repeatcount'), 'callback__empty_or_natural_no_zero');
     $this->form_validation->set_rules('recurrence_until', $this->i18n->_('labels', 'repeatuntil'), 'callback__empty_or_valid_date');
     if ($this->form_validation->run() === FALSE) {
         $this->_throw_exception(validation_errors());
     }
     $this->load->library('caldav');
     // DateTime objects
     $start = null;
     $end = null;
     $tz = isset($p['timezone']) ? $this->timezonemanager->getTz($p['timezone']) : $this->timezonemanager->getTz($this->config->item('default_timezone'));
     // Additional validations
     // 1. All day? If all day, require start_time, end_date and end_time
     // If not, generate our own values
     if (isset($p['allday']) && $p['allday'] == 'true') {
         // Start and end days, 00:00
         $start = $this->dates->frontend2datetime($p['start_date'] . ' ' . date($this->time_format, mktime(0, 0)), $this->tz_utc);
         $end = $this->dates->frontend2datetime($p['end_date'] . ' ' . date($this->time_format, mktime(0, 0)), $this->tz_utc);
         // Add 1 day (iCalendar needs this)
         $end->add(new DateInterval('P1D'));
     } else {
         // Create new form validation rules
         $this->form_validation->set_rules('start_time', $this->i18n->_('labels', 'starttime'), 'required|callback__valid_time');
         $this->form_validation->set_rules('end_time', $this->i18n->_('labels', 'endtime'), 'required|callback__valid_time');
         if ($this->form_validation->run() === FALSE) {
             $this->_throw_exception(validation_errors());
         }
         // 2. Check if start date <= end date
         $start = $this->dates->frontend2datetime($p['start_date'] . ' ' . $p['start_time'], $tz);
         $end = $this->dates->frontend2datetime($p['end_date'] . ' ' . $p['end_time'], $tz);
         if ($end->getTimestamp() < $start->getTimestamp()) {
             $this->_throw_exception($this->i18n->_('messages', 'error_startgreaterend'));
         }
     }
     $p['dtstart'] = $start;
     $p['dtend'] = $end;
     // Recurrence checks
     unset($p['rrule']);
     if (isset($p['recurrence_type'])) {
         if ($p['recurrence_type'] != 'none') {
             if (isset($p['recurrence_until']) && !empty($p['recurrence_until'])) {
                 $p['recurrence_until'] .= date($this->time_format, mktime(0, 0));
                 // Tricky
             }
             $rrule = $this->recurrence->build($p, $rrule_err);
             if (FALSE === $rrule) {
                 // Couldn't build rrule
                 $this->extended_logs->message('ERROR', 'Error building RRULE (' . $rrule_err . ')');
                 $this->_throw_exception($this->i18n->_('messages', 'error_bogusrepeatrule') . ': ' . $rrule_err);
             }
         } else {
             // Deleted RRULE
             // TODO in the future, consider recurrence-id and so
             $rrule = '';
         }
         $p['rrule'] = $rrule;
     }
     // Reminders
     $reminders = array();
     // Contains a list of old parseable (visible on UI) reminders.
     // Used to remove reminders that were deleted by user
     $visible_reminders = isset($p['visible_reminders']) ? $p['visible_reminders'] : array();
     if (isset($p['reminders']) && is_array($p['reminders'])) {
         $data_reminders = $p['reminders'];
         $num_reminders = count($data_reminders['is_absolute']);
         for ($i = 0; $i < $num_reminders; $i++) {
             $this_reminder = null;
             $data_reminders['is_absolute'][$i] = $data_reminders['is_absolute'][$i] == 'true' ? TRUE : FALSE;
             if ($data_reminders['is_absolute'][$i]) {
                 $when = $this->dates->frontend2datetime($data_reminders['tdate'][$i] . ' ' . $data_reminders['ttime'][$i], $this->tz);
                 $when->setTimezone($this->tz_utc);
                 $this_reminder = Reminder::createFrom($when);
             } else {
                 $when = array('before' => $data_reminders['before'][$i] == 'true', 'relatedStart' => $data_reminders['relatedStart'][$i] == 'true');
                 $interval = $data_reminders['interval'][$i];
                 $when[$interval] = $data_reminders['qty'][$i];
                 $this_reminder = Reminder::createFrom($when);
             }
             if (!empty($data_reminders['order'][$i])) {
                 $this_reminder->order = $data_reminders['order'][$i];
             }
//.........这里部分代码省略.........
开发者ID:julien2512,项目名称:agendav,代码行数:101,代码来源:event.php

示例2: parse_valarms

 /**
  * Parses a VEVENT resource VALARM definitions
  * 
  * Returns an associative array ('n1#' => new Reminder, 'n2#' => new
  * Reminder...), where 'n#' is the order where this VALARM was found
  */
 function parse_valarms($vevent, $timezones = array())
 {
     $parsed_reminders = array();
     $order = 0;
     while ($valarm = $vevent->getComponent('valarm')) {
         $order++;
         // TODO parse more actions
         $action = $valarm->getProperty('action');
         if ($action == 'DISPLAY') {
             $trigger = $valarm->getProperty('trigger');
             $reminder = null;
             if (isset($trigger['before'])) {
                 // Related to event start/end
                 $reminder = Reminder::createFrom($trigger);
             } else {
                 // Absolute date-time trigger
                 $tz = $this->detect_tz($valarm, $timezones, 'trigger');
                 $datetime = $this->CI->dates->idt2datetime($trigger, $tz);
                 // Use default timezone
                 $datetime->setTimezone($this->tz);
                 $reminder = Reminder::createFrom($datetime);
                 $reminder->tdate = $datetime->format($this->date_frontend_format);
                 $reminder->ttime = $datetime->format($this->time_frontend_format);
             }
             if ($reminder !== null) {
                 $reminder->order = $order;
                 $parsed_reminders[$order] = $reminder;
             }
         }
     }
     return $parsed_reminders;
 }
开发者ID:julien2512,项目名称:agendav,代码行数:38,代码来源:Icshelper.php


注:本文中的Reminder::createFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。