function search_form() { global $day, $month, $year, $phpc_script, $month_names, $sort_options, $order_options, $phpcid, $phpc_cal; $date_format = $phpc_cal->date_format; $form = new Form($phpc_script, __('Search'), 'post'); $form->add_part(new FormFreeQuestion('searchstring', __('Phrase'), false, 32, true)); $form->add_hidden('action', 'search'); $form->add_hidden('phpcid', $phpcid); $form->add_part(new FormDateQuestion('search-from', __('From'), $date_format)); $form->add_part(new FormDateQuestion('search-to', __('To'), $date_format)); $sort = new FormDropdownQuestion('sort', __('Sort By')); $sort->add_options($sort_options); $form->add_part($sort); $order = new FormDropdownQuestion('order', __('Order')); $order->add_options($order_options); $form->add_part($order); $form->add_part(new FormSubmitButton(__("Search"))); return $form->get_form(); }
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); }