function display_month() { global $phpc_month, $phpc_year, $phpc_home_url, $phpcid; $months = array(); for ($i = 1; $i <= 12; $i++) { $m = month_name($i); $months["{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$i}&year={$phpc_year}"] = $m; } $years = array(); for ($i = $phpc_year - 5; $i <= $phpc_year + 5; $i++) { $years["{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$phpc_month}&year={$i}"] = $i; } $next_month = $phpc_month + 1; $next_year = $phpc_year; if ($next_month > 12) { $next_month -= 12; $next_year++; } $prev_month = $phpc_month - 1; $prev_year = $phpc_year; if ($prev_month < 1) { $prev_month += 12; $prev_year--; } $heading = tag('', tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$prev_month}&year={$prev_year}\""), tag('span', attrs('class="fa fa-chevron-left"'), '')), create_dropdown_list(month_name($phpc_month), $months), create_dropdown_list($phpc_year, $years), tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_month&phpcid={$phpcid}&month={$next_month}&year={$next_year}\""), tag('span', attrs('class="fa fa-chevron-right"'), ''))); return create_display_table($heading, create_month($phpc_month, $phpc_year)); }
function display_form() { global $phpc_script, $phpc_token; $tbody = tag('tbody'); foreach (get_config_options() as $element) { $text = $element[1]; $input = create_config_input($element); $tbody->add(tag('tr', tag('th', $text), tag('td', $input))); } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('div', attrs('class="phpc-sub-title"'), __('Create Calendar')), tag('table', attributes('class="phpc-container form"'), tag('tfoot', tag('tr', tag('td', ''), tag('td', create_hidden('phpc_token', $phpc_token), create_hidden('action', 'calendar_form'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), $tbody)); }
function config_form() { global $phpc_script, $phpc_user_tz, $phpc_user_lang, $phpc_token; $tz_input = create_multi_select('timezone', get_timezone_list(), $phpc_user_tz); $languages = array("" => __("Default")); foreach (get_languages() as $lang) { $languages[$lang] = $lang; } $lang_input = create_select('language', $languages, $phpc_user_lang); $form = tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Settings')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'settings'), create_hidden('phpc_submit', 'settings'), create_submit(__('Submit'))))), tag('tbody', tag('tr', tag('th', __('Timezone')), tag('td', $tz_input)), tag('tr', tag('th', __('Language')), tag('td', $lang_input))))); return tag('div', attrs('id="phpc-config"'), $form); }
function display_form() { global $phpc_script, $phpc_token, $phpcdb; $groups = array(); foreach ($phpcdb->get_groups() as $group) { $groups[$group['gid']] = $group['name']; } $size = sizeof($groups); if ($size > 6) { $size = 6; } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Create User')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'user_create'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), tag('tbody', tag('tr', tag('th', __('User Name')), tag('td', create_text('user_name'))), tag('tr', tag('th', __('Password')), tag('td', create_password('password1'))), tag('tr', tag('th', __('Confirm Password')), tag('td', create_password('password2'))), tag('tr', tag('th', __('Make Admin')), tag('td', create_checkbox('make_admin', '1', false, __('Admin')))), tag('tr', tag('th', __('Groups')), tag('td', create_select('groups[]', $groups, false, attrs('multiple', "size=\"{$size}\""))))))); }
function message_redirect($message, $page) { global $phpc_prefix; if (empty($_SESSION["{$phpc_prefix}messages"])) { $_SESSION["{$phpc_prefix}messages"] = array(); } if (is_a($message, 'Html')) { $message = $message->toString(); } $_SESSION["{$phpc_prefix}messages"][] = $message; redirect($page); $continue_url = $page . '&clearmsg=1'; return tag('div', attrs('class="phpc-box"'), "{$message} ", tag('a', attrs("href=\"{$continue_url}\""), __("continue"))); }
function display_form() { global $phpc_script, $phpc_token, $phpcdb, $vars, $phpc_cal; $groups = array(); foreach ($phpc_cal->get_groups() as $group) { $groups[$group['gid']] = $group['name']; } $size = sizeof($groups); if ($size > 6) { $size = 6; } $user = $phpcdb->get_user($vars["uid"]); $user_groups = array(); foreach ($user->get_groups() as $group) { $user_groups[] = $group['gid']; } return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('div', attributes("class=\"phpc-container\""), tag('h2', __('Edit User Groups')), tag('div', create_select('groups[]', $groups, $user_groups, attrs('multiple', "size=\"{$size}\""))), tag('div', create_hidden('phpc_token', $phpc_token), create_hidden('uid', $vars['uid']), create_hidden('action', 'user_groups'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))); }
function create_day_menu() { global $phpc_month, $phpc_day, $phpc_year; $html = tag('div', attrs('class="phpc-bar ui-widget-content"')); $monthname = month_name($phpc_month); $lasttime = mktime(0, 0, 0, $phpc_month, $phpc_day - 1, $phpc_year); $lastday = date('j', $lasttime); $lastmonth = date('n', $lasttime); $lastyear = date('Y', $lasttime); $lastmonthname = month_name($lastmonth); $last_args = array('year' => $lastyear, 'month' => $lastmonth, 'day' => $lastday); menu_item_prepend($html, "{$lastmonthname} {$lastday}", 'display_day', $last_args); $nexttime = mktime(0, 0, 0, $phpc_month, $phpc_day + 1, $phpc_year); $nextday = date('j', $nexttime); $nextmonth = date('n', $nexttime); $nextyear = date('Y', $nexttime); $nextmonthname = month_name($nextmonth); $next_args = array('year' => $nextyear, 'month' => $nextmonth, 'day' => $nextday); menu_item_append($html, "{$nextmonthname} {$nextday}", 'display_day', $next_args); return $html; }
function display_week() { global $vars, $phpc_home_url, $phpcid, $phpc_year, $phpc_month, $phpc_day; if (!isset($vars['week'])) { $week_of_year = week_of_year($phpc_month, $phpc_day, $phpc_year); } else { if (!is_numeric($vars['week'])) { soft_error(__('Invalid date.')); } $week_of_year = $vars['week']; } $day_of_year = 1 + ($week_of_year - 1) * 7 - day_of_week(1, 1, $phpc_year); $from_stamp = mktime(0, 0, 0, 1, $day_of_year, $phpc_year); $start_day = date("j", $from_stamp); $start_month = date("n", $from_stamp); $start_year = date("Y", $from_stamp); $last_day = $day_of_year + 6; $to_stamp = mktime(23, 59, 59, 1, $last_day, $phpc_year); $end_day = date("j", $to_stamp); $end_month = date("n", $to_stamp); $end_year = date("Y", $to_stamp); $title = month_name($start_month) . " {$start_year}"; if ($end_month != $start_month) { $title .= " - " . month_name($end_month) . " {$end_year}"; } $prev_week = $week_of_year - 1; $prev_year = $phpc_year; if ($prev_week < 1) { $prev_year--; $prev_week = week_of_year($start_month, $start_day - 7, $start_year); } $next_week = $week_of_year + 1; $next_year = $phpc_year; if ($next_week > weeks_in_year($phpc_year)) { $next_week = week_of_year($end_month, $end_day + 1, $end_year); $next_year++; } $heading = tag('', tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_week&phpcid={$phpcid}&week={$prev_week}&year={$prev_year}\""), tag('span', attrs('class="fa fa-chevron-left"'), '')), $title, tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_week&phpcid={$phpcid}&week={$next_week}&year={$next_year}\""), tag('span', attrs('class="fa fa-chevron-right"'), ''))); return create_display_table($heading, create_week($from_stamp, $phpc_year, get_events($from_stamp, $to_stamp))); }
function config_form() { global $phpc_script, $phpc_user_tz, $phpc_user_lang, $phpc_token, $phpcdb, $phpc_user; $tz_input = create_multi_select('timezone', get_timezone_list(), $phpc_user_tz); $languages = array("" => __("Default")); foreach (get_languages() as $lang) { $languages[$lang] = $lang; } $lang_input = create_select('language', $languages, $phpc_user_lang); $calendars = array("" => __("None")); foreach ($phpcdb->get_calendars() as $calendar) { $calendars[$calendar->get_cid()] = $calendar->get_title(); } $default_input = create_select('default_cid', $calendars, $phpc_user->get_default_cid()); $table = tag('table', attrs('class="phpc-form"')); if (is_user()) { $table->add(tag('tr', tag('th', __('Default Calendar')), tag('td', $default_input))); } $table->add(tag('tr', tag('th', __('Timezone')), tag('td', $tz_input))); $table->add(tag('tr', tag('th', __('Language')), tag('td', $lang_input))); $form = tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('div', attrs('class="phpc-sub-title"'), __('Settings')), $table, create_hidden('phpc_token', $phpc_token), create_hidden('action', 'user_settings_submit'), create_submit(__('Submit'))); return tag('div', attrs('id="phpc-config"'), $form); }
function field_list() { global $phpc_script, $phpcid, $phpc_cal, $vars; $tbody = tag('tbody'); $have_contents = false; foreach ($phpc_cal->get_fields() as $field) { $have_contents = true; $name = empty($field['name']) ? __('No Name') : $field['name']; $fid = $field['fid']; $tbody->add(tag('tr', tag('td', $name), tag('td', escape_entities($field['required'])), tag('td', escape_entities($field['format'])), tag('td', create_action_link(__('Edit'), 'field_form', array('fid' => $fid)), " ", create_action_link(__('Delete'), 'field_delete', array('fid' => $fid), attrs('class="phpc-confirm-field"'))))); } if (!$have_contents) { $tbody->add(tag('tr', tag('td', attrs('colspan=4'), __('No fields.')))); } $table = tag('table', attrs('class="phpc-container"'), tag('thead', tag('tr', attrs('class="ui-widget-header"'), tag('th', __('Name')), tag('th', __('Required?')), tag('th', __('Format')), tag('th', __('Actions')))), $tbody); $dialog = tag('div', attrs('id="phpc-dialog-field"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this field?")); return tag('div', attrs('id="phpc-fields"'), tag('div', attrs('class="phpc-sub-title"'), __('Calendar Fields')), $dialog, $table, create_action_link(__('Create Field'), 'field_form', array('cid' => $phpcid), attrs('class="phpc-button"'))); }
function display_form() { global $phpc_script, $phpc_year, $phpc_month, $phpc_day, $vars, $phpcdb, $phpc_cal, $phpc_user, $phpc_token, $phpcid; $hour24 = $phpc_cal->hours_24; $date_format = $phpc_cal->date_format; $form = new Form($phpc_script, __('Event Form')); $cid_select = new FormDropdownQuestion('cid', __('Calendar')); foreach ($phpcdb->get_calendars() as $calendar) { if ($calendar->can_write()) { $cid_select->add_option($calendar->cid, $calendar->title); } } $form->add_part($cid_select); $subject_part = new FormFreeQuestion('subject', __('Subject'), false, $phpc_cal->subject_max, true); $subject_part->setAutocomplete("off"); $form->add_part($subject_part); $form->add_part(new FormLongFreeQuestion('description', tag('', __('Description'), tag('br'), tag('a', attrs('href="http://daringfireball.net/projects/markdown/syntax"', 'target="_new"'), __('syntax'))))); $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']); } foreach ($phpc_cal->get_fields() as $field) { $form->add_part(new FormFreeQuestion('phpc-field-' . $field['fid'], $field['name'])); } $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('cid' => $event->get_cid(), '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()); foreach ($event->get_fields() as $field) { $defaults["phpc-field-{$field['fid']}"] = $field['value']; } 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($phpc_year, $phpc_month, $phpc_day, $datefmt); $defaults = array('cid' => $phpcid, '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 display_event() { global $vars, $phpcdb, $phpc_year, $phpc_month, $phpc_day, $phpc_cal; if (!empty($vars['content']) && $vars['content'] == 'json') { return display_event_json(); } if (isset($vars['oid'])) { $entry = $phpcdb->get_event_by_oid($vars['oid']); if (!$entry) { return tag('p', __('There is no event for that OID.')); } $event = new PhpcEvent($entry); } elseif (isset($vars['eid'])) { $entry = $phpcdb->get_event_by_eid($vars['eid']); if (!$entry) { return tag('p', __('There is no event with that EID.')); } $event = new PhpcEvent($entry); } if (!isset($event)) { soft_error(__("Invalid arguments.")); } if (!$event->can_read()) { return tag('p', __("You do not have permission to read this event.")); } $event_header = tag('div', attributes('class="phpc-event-header"'), tag('div', __('created by') . ' ', tag('cite', $event->get_author()), ' ' . __('on') . ' ' . $event->get_ctime_string())); if (!empty($event->mtime)) { $event_header->add(tag('div', __('Last modified on '), $event->get_mtime_string())); } $category = $event->get_category(); if (!empty($category)) { $event_header->add(tag('div', __('Category') . ': ' . $category)); } // Add modify/delete links if this user has access to this event. $event_menu = ''; if ($event->can_modify()) { $event_menu = tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Modify'), 'event_form', $event->get_eid()), "\n", create_event_link(__('Delete'), 'event_delete', $event->get_eid(), attrs('class="phpc-confirm"'))); } $desc_tag = tag('div', attributes('class="phpc-desc"'), tag('h3', __("Description")), tag('p', $event->get_desc())); $occurrences_tag = tag('ul'); $occurrences = $phpcdb->get_occurrences_by_eid($event->get_eid()); $set_date = false; foreach ($occurrences as $occurrence) { if (!$set_date) { $phpc_year = $occurrence->get_start_year(); $phpc_month = $occurrence->get_start_month(); $phpc_day = $occurrence->get_start_day(); } $oid = $occurrence->get_oid(); $occ_tag = tag('li', attrs('class="ui-widget-content"'), $occurrence->get_date_string() . ' ' . __('at') . ' ' . $occurrence->get_time_span_string()); if ($event->can_modify()) { $occ_tag->add(" ", create_occurrence_link(__('Edit'), 'occur_form', $oid), " ", create_occurrence_link(__('Remove'), 'occurrence_delete', $oid, attrs('class="phpc-confirm-occ"'))); } $occurrences_tag->add($occ_tag); } // Add occurrence link if this user has access to this event. $occurrences_menu = ''; if ($event->can_modify()) { $occurrences_menu = tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Add Occurrence'), 'occur_form', $event->get_eid())); } foreach ($event->get_fields() as $field) { $def = $phpc_cal->get_field($field['fid']); $event_header->add(tag('div', $def['name'] . ": " . $field['value'])); } $dialog = tag('div', attrs('id="phpc-dialog"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this event?")); $dialog2 = tag('div', attrs('id="phpc-dialog-occ"', 'title="' . __("Confirmation required") . '"'), __("Permanently delete this occurrence?")); return tag('div', attributes('class="phpc-main phpc-event"'), $dialog, $dialog2, $event_menu, tag('h2', $event->get_subject()), $event_header, $desc_tag, tag('div', attrs('class="phpc-occ"'), tag('h3', __('Occurrences')), $occurrences_menu, $occurrences_tag)); }
<?php /** * @var string|null $name * @var string $__content * @var array $__attrs */ ?> <div class="component Hello-World" <?php echo attrs($__attrs); ?> > <h1>Hello<br/> <small>my name is</small> </h1> <div class="content"> <?php echo $__content; ?> </div> </div>
/* * Copyright 2012 Sean Proctor * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ if (!defined('IN_PHPC')) { die("Invalid setup"); } try { require_once "{$phpc_includes_path}/calendar.php"; require_once "{$phpc_includes_path}/setup.php"; $calendar_title = $phpc_cal->get_title(); $content = tag('div', attributes('class="php-calendar ui-widget"'), userMenu(), tag('br', attributes('style="clear:both;"')), tag('h1', attrs('class="ui-widget-header"'), tag('a', attributes("href='{$phpc_home_url}?phpcid={$phpc_cal->get_cid()}'"), $calendar_title)), display_phpc()); } catch (Exception $e) { $calendar_title = $e->getMessage(); $content = tag('div', attributes('class="php-calendar"'), $e->getMessage()); } $head = tag('div', attrs('class="phpc-head"'), get_header_tags("static")); echo $head->toString(); echo $content->toString();
function get_form($defaults = array()) { $form_attrs = attrs("action=\"{$this->action}\"", 'method="POST"'); if ($this->method !== false) { $form_attrs->add("method=\"{$this->method}\""); } $table = tag('table', attrs("class=\"{$this->class}\"")); foreach ($this->list as $child) { $table->add($child->get_html($this, $defaults)); } $form = tag('form', $form_attrs); $hidden_div = tag('div'); $have_hidden = false; foreach ($this->hidden as $name => $value) { $have_hidden = true; $hidden_div->add(tag('input', attrs('type="hidden"', "name=\"{$name}\"", "value=\"{$value}\"", "id=\"{$name}\""))); } if ($have_hidden) { $form->add($hidden_div); } $form->add($table); return $form; }
function translation_link() { global $phpc_script; return tag('div', attrs('id="phpc-admin-translate"'), tag('p', __('This script needs read access to your calendar directory in order to write the translation files. Alternatively, you could run translate.php from the command line or use msgfmt or any other gettext tool that can generate .mo files from .po files.')), tag('a', attrs('class="phpc-button"', "href=\"{$phpc_script}?action=translate\""), __('Generate Translations'))); }
/** * Convert attributes array into HTML representation * * @param array $attrs * @param array $except * @return string */ function attrs_except($attrs, $except) { $only = array_diff(array_keys($attrs), $except); return attrs($attrs, $only); }
function create_day($month, $day, $year, $days_events) { global $phpc_script, $phpc_cal; $date_class = 'ui-state-default'; if ($day <= 0) { $month--; if ($month < 1) { $month = 12; $year--; } $day += days_in_month($month, $year); $date_class .= ' phpc-shadow'; } elseif ($day > days_in_month($month, $year)) { $day -= days_in_month($month, $year); $month++; if ($month > 12) { $month = 1; $year++; } } else { $currentday = date('j'); $currentmonth = date('n'); $currentyear = date('Y'); // set whether the date is in the past or future/present if ($currentyear == $year && $currentmonth == $month && $currentday == $day) { $date_class .= ' ui-state-highlight'; } } $click = create_plain_link($day, 'display_day', $year, $month, $day); $date_tag = tag('div', attributes("class=\"phpc-date {$date_class}\"", "onclick=\"window.location.href='{$click}'\""), create_action_link_with_date($day, 'display_day', $year, $month, $day)); if ($phpc_cal->can_write()) { $date_tag->add(create_action_link_with_date('+', 'event_form', $year, $month, $day, array('class="phpc-add"'))); } $html_day = tag('td', $date_tag); $stamp = mktime(0, 0, 0, $month, $day, $year); $can_read = $phpc_cal->can_read(); $key = date('Y-m-d', $stamp); if (!$can_read || !array_key_exists($key, $days_events)) { return $html_day; } $results = $days_events[$key]; if (empty($results)) { return $html_day; } $html_events = tag('ul', attrs('class="phpc-event-list"')); $html_day->add($html_events); // Count the number of events foreach ($results as $event) { if ($event == false) { $event_html = tag('li', create_action_link_with_date(__("View Additional Events"), 'display_day', $year, $month, $day, array('class="phpc-date"'))); $html_events->add($event_html); break; } // TODO - make sure we have permission to read the event $subject = $event->get_subject(); if ($event->get_start_timestamp() >= $stamp) { $event_time = $event->get_time_string(); } else { $event_time = '(' . __('continued') . ')'; } if (!empty($event_time)) { $title = "{$event_time} - {$subject}"; } else { $title = $subject; } $style = ""; if (!empty($event->text_color)) { $style .= "color: {$event->get_text_color()} !important;"; } if (!empty($event->bg_color)) { $style .= "background: " . $event->get_bg_color() . " !important;"; } $event_html = tag('li', create_occurrence_link($title, "display_event", $event->get_oid(), array("style=\"{$style}\""))); $html_events->add($event_html); } return $html_day; }
function group_list() { global $phpc_script, $phpcid, $phpc_cal, $vars; $groups = $phpc_cal->get_groups(); $tbody = tag('tbody'); foreach ($groups as $group) { $name = empty($group['name']) ? __('No Name') : $group['name']; $id = $group['gid']; $tbody->add(tag('tr', tag('th', $name), tag('td', create_action_link(__('Edit'), 'group_form', array('gid' => $id)), " ", create_action_link(__('Delete'), 'group_delete', array('gid' => $id))))); } $create_link = create_action_link(__('Create group'), 'group_form', array('cid' => $phpcid)); $table = tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Calendar Groups')), tag('thead', tag('tr', tag('th', __('Name')), tag('th', __('Actions')))), $tbody, tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), $create_link)))); return tag('div', attrs('id="phpc-groups"'), $table); }
$name = $_SESSION['USER_LOGGED_IN']['Username']; $check = $phpcdb->get_user_by_name($name); $_SESSION['USER_LOGGED_IN']['calid'] = $check->uid; if ($check) { login_user($name); } else { $phpcdb->create_user($name, '123456', 0); login_user($name); } } $calendars = $phpcdb->get_calendars(); $list = array(); foreach ($calendars as $calendar) { $list["{$phpc_home_url}?phpcid={$calendar->get_cid()}"] = $calendar->get_title(); } $calendar_title = $phpc_cal->get_title(); $content = tag('div', attributes('class="php-calendar ui-widget"'), tag('br', attrs('style="clear:both;"')), tag('h1', attrs('class="ui-widget-header"'), create_dropdown_list(tag('a', attrs("href='{$phpc_home_url}?phpcid={$phpc_cal->get_cid()}'", 'class="phpc-dropdown-list-title"'), $calendar_title), $list)), display_phpc()); } catch (Exception $e) { $calendar_title = $e->getMessage(); $content = tag('div', attributes('class="php-calendar"'), $e->getMessage()); } $html = tag('html', attrs("lang=\"{$phpc_lang}\""), tag('head', tag('title', $calendar_title), tag('link', attrs('rel="icon"', "href=\"static/office-calendar.png\"")), get_header_tags("static"), tag('meta', attrs('http-equiv="Content-Type"', 'content="text/html; charset=UTF-8"'))), tag('body', $content)); echo '<!DOCTYPE html>', "\n", $html->toString(); ?> <?php include "../../../includes/scripts.php"; ?> <?php include "../../includes/endBody.php";
if (!isset($phpc_jq_file)) { $phpc_jq_file = "//ajax.googleapis.com/ajax/libs/jquery/{$jquery_version}/jquery{$phpc_min}.js"; } /* * Do not modify anything under this point */ define('IN_PHPC', true); require_once "{$phpc_includes_path}/calendar.php"; try { require_once "{$phpc_includes_path}/setup.php"; } catch (Exception $e) { header("Content-Type: text/html; charset=UTF-8"); echo "<!DOCTYPE html>\n"; echo display_exception($e)->toString(); exit; } if ($vars["content"] == "json") { header("Content-Type: application/json; charset=UTF-8"); echo do_action(); } else { header("Content-Type: text/html; charset=UTF-8"); // This sets global variables that determine the title in the header $content = display_phpc(); $embed_script = ''; if ($vars["content"] == "embed") { $underscore_version = "1.5.2"; $embed_script = array(tag("script", attrs('src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/' . "{$underscore_version}/underscore-min.js\""), ''), tag('script', attrs('src="static/embed.js"'), '')); } $html = tag('html', attrs("lang=\"{$phpc_lang}\""), tag('head', tag('title', $phpc_title), tag('link', attrs('rel="icon"', "href=\"{$phpc_url_path}/static/office-calendar.png\"")), tag('meta', attrs('http-equiv="Content-Type"', 'content="text/html; charset=UTF-8"')), tag('link', attrs('rel="stylesheet"', "href=\"{$phpc_static_path}/phpc.css\"")), tag('link', attrs('rel="stylesheet"', "href=\"{$phpc_jqui_path}/themes/{$phpc_theme}/jquery-ui{$phpc_min}.css\"")), tag('link', attrs('rel="stylesheet"', "href=\"{$phpc_static_path}/jquery-ui-timepicker.css\"")), tag('link', attrs('rel="stylesheet"', "href=\"{$phpc_fa_path}/css/font-awesome{$phpc_min}.css\"")), tag("script", attrs("src=\"{$phpc_jq_file}\""), ''), tag("script", attrs("src=\"{$phpc_jqui_path}/jquery-ui{$phpc_min}.js\""), ''), tag('script', attrs("src=\"{$phpc_static_path}/phpc.js\""), ''), tag("script", attrs("src=\"{$phpc_static_path}/jquery.ui.timepicker.js\""), ''), tag("script", attrs("src=\"{$phpc_static_path}/farbtastic.min.js\""), ''), tag('link', attrs('rel="stylesheet"', "href=\"{$phpc_static_path}/farbtastic.css\""))), tag('body', $embed_script, $content)); echo "<!DOCTYPE html>\n", $html->toString(); }
function display_exception($e, $navbar = false) { global $phpc_title; $phpc_title = $e->getMessage(); $results = tag(''); if ($navbar !== false) { $results->add($navbar); } $backtrace = tag("ol"); foreach ($e->getTrace() as $bt) { $filename = basename($bt["file"]); $args = array(); if (isset($bt["args"])) { foreach ($bt["args"] as $arg) { if (is_string($arg)) { $args[] = "'{$arg}'"; } else { $args[] = $arg; } } $args_string = implode(", ", $args); } else { $args_string = "..."; } $backtrace->add(tag("li", "{$filename}({$bt["line"]}): {$bt["function"]}({$args_string})")); } $results->add(tag('div', attrs('class="php-calendar"'), tag('h2', __('Error')), tag('p', $e->getMessage()), tag('h3', __('Backtrace')), $backtrace)); return $results; }
function create_display_table($heading, $contents) { $heading_html = tag('tr', attrs('class="ui-widget-header"')); $heading_html->add(tag('th', __p('Week', 'W'))); for ($i = 0; $i < 7; $i++) { $d = ($i + day_of_week_start()) % 7; $heading_html->add(tag('th', day_name($d))); } return tag('div', tag("div", attributes('id="phpc-summary-view"'), tag("div", attributes('id="phpc-summary-head"'), tag("div", attributes('id="phpc-summary-title"'), ''), tag("div", attributes('id="phpc-summary-author"'), ''), tag("div", attributes('id="phpc-summary-category"'), ''), tag("div", attributes('id="phpc-summary-time"'), '')), tag("div", attributes('id="phpc-summary-body"'), '')), tag('div', attrs('class="phpc-sub-title phpc-month-title ui-widget-content"'), $heading), tag('table', attrs('class="phpc-month-view"'), tag('colgroup', tag('col', attributes('class="phpc-week"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"')), tag('col', attributes('class="phpc-day"'))), tag('thead', $heading_html), tag('tbody', $contents))); }
function display_event_by_eid($eid) { global $phpcdb, $year, $month, $day; $event = new PhpcEvent($phpcdb->get_event_by_eid($eid)); if (!$event->can_read()) { return tag('p', __("You do not have permission to read this event.")); } $event_header = tag('div', attributes('class="phpc-event-header"'), tag('div', __('by') . ' ', tag('cite', $event->get_author()))); $event_header->add(tag('div', __('Created at: '), $event->get_ctime_string())); if (!empty($event->mtime)) { $event_header->add(tag('div', __('Last modified at: '), $event->get_mtime_string())); } $category = $event->get_category(); if (!empty($category)) { $event_header->add(tag('div', __('Category') . ': ' . $category)); } // Add modify/delete links if this user has access to this event. if ($event->can_modify()) { $event_header->add(tag('div', attrs('class="phpc-bar ui-widget-content"'), create_event_link(__('Modify'), 'event_form', $eid), "\n", create_event_link(__('Add Occurrence'), 'occur_form', $eid), "\n", create_event_link(__('Delete'), 'event_delete', $eid))); } $desc_tag = tag('div', attributes('class="phpc-desc"'), tag('h3', __("Description")), tag('p', $event->get_desc())); $occurrences_tag = tag('ul'); $occurrences = $phpcdb->get_occurrences_by_eid($eid); $set_date = false; foreach ($occurrences as $occurrence) { if (!$set_date) { $year = $occurrence->get_start_year(); $month = $occurrence->get_start_month(); $day = $occurrence->get_start_day(); } $oid = $occurrence->get_oid(); $occ_tag = tag('li', attrs('class="ui-widget-content"'), create_occurrence_link($occurrence->get_date_string() . ' ' . __('at') . ' ' . $occurrence->get_time_span_string(), 'display_event', $oid)); if ($event->can_modify()) { $occ_tag->add(" ", create_occurrence_link(__('Edit'), 'occur_form', $oid), " ", create_occurrence_link(__('Remove'), 'occurrence_delete', $oid)); } $occurrences_tag->add($occ_tag); } return tag('div', attributes('class="phpc-main phpc-event"'), tag('h2', $event->get_subject()), $event_header, $desc_tag, tag('div', attributes('class="phpc-occ"'), tag('h3', __('Occurrences')), $occurrences_tag)); }
function error_message_redirect($message, $page) { global $phpc_prefix; $tag = tag('div', attrs('class="phpc-message ui-state-error"'), $message); if (empty($_SESSION["{$phpc_prefix}messages"])) { $_SESSION["{$phpc_prefix}messages"] = array(); } $_SESSION["{$phpc_prefix}messages"][] = $tag; redirect($page); $continue_url = $page . '&clearmsg=1'; return tag('div', attrs('class="phpc-box"'), $tag, tag('a', attrs("href=\"{$continue_url}\""), __("continue"))); }
function create_multi_select($name, $option_lists, $default = false, $attrs = false) { if ($attrs === false) { $attrs = attrs(); } $attrs->add("name=\"{$name}\""); $attrs->add("id=\"{$name}\""); $attrs->add("class=\"phpc-multi-select\""); $select = tag('select', $attrs); foreach ($option_lists as $category => $options) { if (is_array($options)) { $group = tag('optgroup', attrs("label=\"{$category}\"")); $select->add($group); foreach ($options as $value => $text) { $attributes = attrs("value=\"{$value}\""); if ($value === $default) { $attributes->add('selected'); } $text = str_replace('_', ' ', $text); $group->add(tag('option', $attributes, $text)); } } else { $value = $options; $text = $category; $attributes = attrs("value=\"{$value}\""); if ($value === $default) { $attributes->add('selected'); } $select->add(tag('option', $attributes, $text)); } } return $select; }
function get_header_tags($path) { global $phpc_cal; if (defined('PHPC_DEBUG')) { $jq_min = ''; } else { $jq_min = '.min'; } $theme = $phpc_cal->theme; if (empty($theme)) { $theme = 'smoothness'; } $jquery_version = "1.10.2"; $jqueryui_version = "1.10.3"; $jpicker_version = "1.1.6"; return array(tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"{$path}/phpc.css\"")), tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"//ajax.googleapis.com/ajax/libs/jqueryui/{$jqueryui_version}/themes/{$theme}/jquery-ui{$jq_min}.css\"")), tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"{$path}/jquery-ui-timepicker.css\"")), tag("script", attrs('type="text/javascript"', "src=\"//ajax.googleapis.com/ajax/libs/jquery/{$jquery_version}/jquery{$jq_min}.js\""), ''), tag("script", attrs('type="text/javascript"', "src=\"//ajax.googleapis.com/ajax/libs/jqueryui/{$jqueryui_version}/jquery-ui{$jq_min}.js\""), ''), tag('script', attrs('type="text/javascript"'), "var imagePath='{$path}/images/'"), tag('script', attrs('type="text/javascript"', "src=\"{$path}/phpc.js\""), ''), tag("script", attrs('type="text/javascript"', "src=\"{$path}/jquery.ui.timepicker.js\""), ''), tag("script", attributes('type="text/javascript"', "src=\"{$path}/jquery.hoverIntent.minified.js\""), ''), tag("script", attrs('type="text/javascript"', "src=\"{$path}/jpicker-{$jpicker_version}{$jq_min}.js\""), ''), tag('link', attrs('rel="stylesheet"', 'type="text/css"', "href=\"{$path}/jPicker-{$jpicker_version}{$jq_min}.css\""))); }