function display_form() { global $phpc_script, $phpc_year, $phpc_month, $phpc_day, $vars, $phpcdb, $phpc_cal, $phpc_token; $hour24 = $phpc_cal->hours_24; $date_format = $phpc_cal->date_format; $form = new Form($phpc_script, __('Occurrence Form')); $when_group = new FormGroup(__('When')); $when_group->add_part(new FormDateTimeQuestion('start', __('From'), $hour24, $date_format)); $when_group->add_part(new FormDateTimeQuestion('end', __('To'), $hour24, $date_format)); $time_type = new FormDropDownQuestion('time-type', __('Time Type')); $time_type->add_option('normal', __('Normal')); $time_type->add_option('full', __('Full Day')); $time_type->add_option('tba', __('To Be Announced')); $when_group->add_part($time_type); $form->add_part($when_group); if (isset($vars['phpcid'])) { $form->add_hidden('phpcid', $vars['phpcid']); } if (isset($vars['oid'])) { $form->add_hidden('oid', $vars['oid']); $occ = $phpcdb->get_occurrence_by_oid($vars['oid']); $datefmt = $phpc_cal->date_format; $start_date = format_short_date_string($occ->get_start_year(), $occ->get_start_month(), $occ->get_start_day(), $datefmt); $end_date = format_short_date_string($occ->get_end_year(), $occ->get_end_month(), $occ->get_end_day(), $datefmt); $start_time = $occ->get_start_time(); if ($start_time == NULL) { $start_time = format_time_string(17, 0, $hour24); } $end_time = $occ->get_end_time(); if ($end_time == NULL) { $end_time = format_time_string(18, 0, $hour24); } $defaults = array('start-date' => $start_date, 'end-date' => $end_date, 'start-time' => $start_time, 'end-time' => $end_time); switch ($occ->get_time_type()) { case 0: $defaults['time-type'] = 'normal'; break; case 1: $defaults['time-type'] = 'full'; break; case 2: $defaults['time-type'] = 'tba'; break; } } else { $form->add_hidden('eid', $vars['eid']); $defaults = array('start-date' => "{$phpc_month}/{$phpc_day}/{$phpc_year}", 'end-date' => "{$phpc_month}/{$phpc_day}/{$phpc_year}", 'start-time' => format_time_string(17, 0, $hour24), 'end-time' => format_time_string(18, 0, $hour24)); } $form->add_hidden('phpc_token', $phpc_token); $form->add_hidden('action', 'occur_form'); $form->add_hidden('submit_form', 'submit_form'); $form->add_part(new FormSubmitButton(__("Submit Occurrence"))); return $form->get_form($defaults); }
function display_form() { global $phpc_script, $year, $month, $day, $vars, $phpcdb, $phpc_cal, $phpc_user, $phpc_token; $hour24 = $phpc_cal->hours_24; $date_format = $phpc_cal->date_format; $form = new Form($phpc_script, __('Event Form')); $form->add_part(new FormFreeQuestion('subject', __('Subject'), false, $phpc_cal->subject_max, true)); $form->add_part(new FormLongFreeQuestion('description', __('Description'))); $when_group = new FormGroup(__('When'), 'phpc-when'); if (isset($vars['eid'])) { $when_group->add_part(new FormCheckBoxQuestion('phpc-modify', false, __('Change the event date and time'))); } $when_group->add_part(new FormDateTimeQuestion('start', __('From'), $hour24, $date_format)); $when_group->add_part(new FormDateTimeQuestion('end', __('To'), $hour24, $date_format)); $time_type = new FormDropDownQuestion('time-type', __('Time Type')); $time_type->add_option('normal', __('Normal')); $time_type->add_option('full', __('Full Day')); $time_type->add_option('tba', __('To Be Announced')); $when_group->add_part($time_type); $form->add_part($when_group); $repeat_type = new FormDropdownQuestion('repeats', __('Repeats'), array(), true, 'never'); $repeat_type->add_option('never', __('Never')); $daily_group = new FormGroup(); $repeat_type->add_option('daily', __('Daily'), NULL, $daily_group); $weekly_group = new FormGroup(); $repeat_type->add_option('weekly', __('Weekly'), NULL, $weekly_group); $monthly_group = new FormGroup(); $repeat_type->add_option('monthly', __('Monthly'), NULL, $monthly_group); $yearly_group = new FormGroup(); $repeat_type->add_option('yearly', __('Yearly'), NULL, $yearly_group); $every_day = new FormDropdownQuestion('every-day', __('Every'), __('Repeat every how many days?')); $every_day->add_options(create_sequence(1, 30)); $daily_group->add_part($every_day); $daily_group->add_part(new FormDateQuestion('daily-until', __('Until'), $date_format)); $every_week = new FormDropdownQuestion('every-week', __('Every'), __('Repeat every how many weeks?')); $every_week->add_options(create_sequence(1, 30)); $weekly_group->add_part($every_week); $weekly_group->add_part(new FormDateQuestion('weekly-until', __('Until'), $date_format)); $every_month = new FormDropdownQuestion('every-month', __('Every'), __('Repeat every how many months?')); $every_month->add_options(create_sequence(1, 30)); $monthly_group->add_part($every_month); $monthly_group->add_part(new FormDateQuestion('monthly-until', __('Until'), $date_format)); $every_year = new FormDropdownQuestion('every-year', __('Every'), __('Repeat every how many years?')); $every_year->add_options(create_sequence(1, 30)); $yearly_group->add_part($every_year); $yearly_group->add_part(new FormDateQuestion('yearly-until', __('Until'), $date_format)); $when_group->add_part($repeat_type); if ($phpc_cal->can_create_readonly()) { $form->add_part(new FormCheckBoxQuestion('readonly', false, __('Read-only'))); } $categories = new FormDropdownQuestion('catid', __('Category')); $categories->add_option('', __('None')); $have_categories = false; foreach ($phpc_cal->get_visible_categories($phpc_user->get_uid()) as $category) { $categories->add_option($category['catid'], $category['name']); $have_categories = true; } if ($have_categories) { $form->add_part($categories); } if (isset($vars['phpcid'])) { $form->add_hidden('phpcid', $vars['phpcid']); } $form->add_hidden('phpc_token', $phpc_token); $form->add_hidden('action', 'event_form'); $form->add_hidden('submit_form', 'submit_form'); $form->add_part(new FormSubmitButton(__("Submit Event"))); if (isset($vars['eid'])) { $form->add_hidden('eid', $vars['eid']); $occs = $phpcdb->get_occurrences_by_eid($vars['eid']); $event = $occs[0]; $defaults = array('subject' => $event->get_raw_subject(), 'description' => $event->get_raw_desc(), 'start-date' => $event->get_short_start_date(), 'end-date' => $event->get_short_end_date(), 'start-time' => $event->get_start_time(), 'end-time' => $event->get_end_time(), 'readonly' => $event->is_readonly()); if (!empty($event->catid)) { $defaults['catid'] = $event->catid; } switch ($event->get_time_type()) { case 0: $defaults['time-type'] = 'normal'; break; case 1: $defaults['time-type'] = 'full'; break; case 2: $defaults['time-type'] = 'tba'; break; } add_repeat_defaults($occs, $defaults); } else { $hour24 = $phpc_cal->hours_24; $datefmt = $phpc_cal->date_format; $date_string = format_short_date_string($year, $month, $day, $datefmt); $defaults = array('start-date' => $date_string, 'end-date' => $date_string, 'start-time' => format_time_string(17, 0, $hour24), 'end-time' => format_time_string(18, 0, $hour24), 'daily-until-date' => $date_string, 'weekly-until-date' => $date_string, 'monthly-until-date' => $date_string, 'yearly-until-date' => $date_string); } return $form->get_form($defaults); }
function format_timestamp_string($timestamp, $date_format, $hours24) { $year = date('Y', $timestamp); $month = date('n', $timestamp); $day = date('j', $timestamp); $hour = date('H', $timestamp); $minute = date('i', $timestamp); return format_date_string($year, $month, $day, $date_format) . ' ' . __('at') . ' ' . format_time_string($hour, $minute, $hours24); }
function get_end_time() { if ($this->end_hour == NULL || $this->end_minute == NULL) { return NULL; } return format_time_string($this->end_hour, $this->end_minute, $this->cal->hours_24); }