<input type="text" name="title" id="field-title" maxlength="250" value="<?php echo $this->escape(html_entity_decode(stripslashes($this->row->title))); ?> " /></td> </div> <div class="input-wrap"> <label for="catid"><?php echo Lang::txt('COM_EVENTS_CAL_LANG_EVENT_CATEGORY'); ?> :<span class="required"><?php echo Lang::txt('JOPTION_REQUIRED'); ?> </span></label><br /> <?php echo \Components\Events\Helpers\Html::buildCategorySelect($this->row->catid, '', 0, $this->option); ?> </td> </div> <div class="input-wrap"> <label for="field-econtent"><?php echo Lang::txt('COM_EVENTS_CAL_LANG_EVENT_ACTIVITY'); ?> :</label><br /> <?php echo $this->editor('econtent', $this->row->content, '45', '10', 'field-econtent'); ?> </td> </div>
} } else { echo '<p>' . Lang::txt('EVENTS_CAL_LANG_NO_EVENTS') . '</p>' . "\n"; } ?> </div> </li> <?php } ?> </ul> <?php } else { ?> <p class="warning"><?php echo Lang::txt('EVENTS_CAL_LANG_NO_EVENTFOR') . ' <strong>' . \Components\Events\Helpers\Html::getDateFormat($this->year, $this->month, '', 3) . '</strong>'; ?> </p> <?php } ?> </div><!-- / .subject --> <div class="aside"> <form action="<?php echo Route::url('index.php?option=' . $this->option . '&year=' . $this->year . '&month=' . $this->month . '&day=' . $this->day . '&task=week'); ?> " method="get" id="event-categories"> <fieldset> <select name="category"> <option value=""><?php echo Lang::txt('EVENTS_ALL_CATEGORIES');
} //get a DateTime for one month after currently viewed and disable URL if required $this_datetime->add(new DateInterval("P1M")); if ($this_datetime <= $last_event_time) { $next = JRoute::_('index.php?option=' . $this->option . '&' . $next_month->toDateURL($this->task)); $next_text = JText::_('EVENTS_CAL_LANG_NEXTMONTH'); } else { $next = "javascript:void(0);"; $next_text = JText::_('EVENTS_CAL_LANG_NO_EVENTFOR') . ' ' . JText::_('EVENTS_CAL_LANG_NEXTMONTH'); } $content = '<table class="ecalendar">' . "\n"; $content .= ' <caption>'; if ($this->shownav) { $content .= '<a class="prv" href="' . $prev . '" title="' . $prev_text . '">‹</a> <a class="nxt" href="' . $next . '" title="' . $next_text . '">›</a> '; } $content .= \Components\Events\Helpers\Html::getMonthName($cal_month) . '</caption>' . "\n"; $content .= ' <thead>' . "\n"; $content .= ' <tr>' . "\n"; for ($i = 0; $i < 7; $i++) { $content .= ' <th scope="col">' . $day_name[($i + $startday) % 7] . '</th>' . "\n"; } $content .= ' </tr>' . "\n"; $content .= ' </thead>' . "\n"; $content .= ' <tbody>' . "\n"; $content .= ' <tr>' . "\n"; // dmcd May 7/04 fix to fill in end days out of month correctly $dayOfWeek = $startday; $start = (date("w", mktime(0, 0, 0, $cal_month, 1, $cal_year)) - $startday + 7) % 7; $d = date("t", mktime(0, 0, 0, $cal_month, 0, $cal_year)) - $start + 1; $kownt = 0; for ($a = $start; $a > 0; $a--) {
/** * View details of an event * * @return void */ public function detailsTask() { // Get some needed info $offset = $this->offset; $year = $this->year; $month = $this->month; $day = $this->day; $option = $this->_option; // Incoming $id = Request::getInt('id', 0, 'request'); // Load event $row = new Event($this->database); $row->load($id); // Ensure we have an event if (!$row || !$row->id) { App::abort(404, Lang::txt('EVENTS_CAL_LANG_NO_EVENTFOR') . ' ' . Lang::txt('EVENTS_CAL_LANG_THIS_DAY')); } //is this a group rescricted event if ($row->scope == 'group') { $group = \Hubzero\User\Group::getInstance($row->scope_id); //if we have a group and we are a member if (is_object($group)) { //redirect to group calendar $redirect = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=calendar&action=details&event_id=' . $row->id, false); App::redirect($redirect); return; } else { App::abort(404, Lang::txt('EVENTS_CAL_LANG_NO_EVENTFOR') . ' ' . Lang::txt('EVENTS_CAL_LANG_THIS_DAY')); return; } } $event_up = new EventsDate($row->publish_up); $row->start_date = Html::getDateFormat($event_up->year, $event_up->month, $event_up->day, 0); $row->start_time = defined('_CAL_USE_STD_TIME') && _CAL_USE_STD_TIME == 'YES' ? $event_up->get12hrTime() : $event_up->get24hrTime(); $event_down = new EventsDate($row->publish_down); $row->stop_date = Html::getDateFormat($event_down->year, $event_down->month, $event_down->day, 0); $row->stop_time = defined('_CAL_USE_STD_TIME') && _CAL_USE_STD_TIME == 'YES' ? $event_down->get12hrTime() : $event_down->get24hrTime(); // Kludge for overnight events, advance the displayed stop_date by 1 day when an overnighter is detected if ($row->stop_time < $row->start_time) { $event_down->addDays(1); } // Get time zone name (i.e. not just offset - ex: '-5') //$row->time_zone = Html::getTimeZoneName($row->time_zone); // Parse http and mailto $alphadigit = "([a-z]|[A-Z]|[0-9])"; // Adresse $row->adresse_info = preg_replace("/(mailto:\\/\\/)?((-|{$alphadigit}|\\.)+)@((-|{$alphadigit}|\\.)+)(\\.{$alphadigit}+)/i", "<a href=\"mailto:\$2@\$5\$8\">\$2@\$5\$8</a>", $row->adresse_info); $row->adresse_info = preg_replace("/(http:\\/\\/|https:\\/\\/)((-|{$alphadigit}|\\.)+)(\\.{$alphadigit}+)/i", "<a href=\"\$1\$2\$5\$8\">\$1\$2\$5\$8</a>", $row->adresse_info); // Contact $row->contact_info = stripslashes(strip_tags($row->contact_info)); if (substr($row->contact_info, 0, strlen('mailto:')) == 'mailto:') { $row->contact_info = '<a href="mailto:' . $this->obfuscate(substr($row->contact_info, strlen('mailto:'))) . '">' . $this->obfuscate(substr($row->contact_info, strlen('mailto:'))) . '</a>'; } else { if (preg_match("/^[_\\.\\%0-9a-zA-Z-]+@([0-9a-zA-Z-]+\\.)+[a-zA-Z]{2,6}\$/i", $row->contact_info)) { $row->contact_info = '<a href="mailto:' . $this->obfuscate($row->contact_info) . '">' . $this->obfuscate($row->contact_info) . '</a>'; } } //$row->contact_info = preg_replace("/(mailto:\/\/)?((-|$alphadigit|\.)+)@((-|$alphadigit|\.)+)(\.$alphadigit+)/i", "<a href=\"mailto:$2@$5$8\">$2@$5$8</a>", $row->contact_info); $row->contact_info = preg_replace("/(http:\\/\\/|https:\\/\\/)((-|{$alphadigit}|\\.)+)(\\.{$alphadigit}+)/i", "<a href=\"\$1\$2\$5\$8\">\$1\$2\$5\$8</a>", $row->contact_info); $fields = $this->config->getCfg('fields'); if (!empty($fields)) { for ($i = 0, $n = count($fields); $i < $n; $i++) { // Explore the text and pull out all matches array_push($fields[$i], self::parseTag($row->content, $fields[$i][0])); // Clean the original text of any matches $row->content = str_replace('<ef:' . $fields[$i][0] . '>' . end($fields[$i]) . '</ef:' . $fields[$i][0] . '>', '', $row->content); } $row->content = trim($row->content); } $bits = explode('-', $row->publish_up); $eyear = $bits[0]; $emonth = $bits[1]; $edbits = explode(' ', $bits[2]); $eday = $edbits[0]; // Everyone has access unless restricted to admins in the configuration $authorized = true; $auth = true; if (User::isGuest()) { $auth = false; } if ($this->config->getCfg('adminlevel')) { $auth = $this->_authorize(); } // Get a list of categories $categories = $this->_getCategories(); // Get tags on this event $rt = new Tags($row->id); $tags = $rt->render(); // Set the page title Document::setTitle(Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt(strtoupper($this->_name) . '_' . strtoupper($this->_task)) . ': ' . stripslashes($row->title)); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option); } Pathway::append($eyear, 'index.php?option=' . $this->_option . '&year=' . $eyear); Pathway::append($emonth, 'index.php?option=' . $this->_option . '&year=' . $eyear . '&month=' . $emonth); Pathway::append($eday, 'index.php?option=' . $this->_option . '&year=' . $eyear . '&month=' . $emonth . '&day=' . $eday); Pathway::append(stripslashes($row->title), 'index.php?option=' . $this->_option . '&task=details&id=' . $row->id); // Incoming $alias = Request::getVar('page', ''); // Load the current page $page = new Page($this->database); if ($alias) { $page->loadFromAlias($alias, $row->id); } // Get the pages for this workshop $pages = $page->loadPages($row->id); if ($alias) { Pathway::append(stripslashes($page->title), 'index.php?option=' . $this->_option . '&task=details&id=' . $row->id . '&page=' . $page->alias); } // Build the HTML $this->view->setLayout('default')->setName('details'); if (Request::getVar('no_html', 0)) { $this->view->setLayout('modal'); } $this->view->option = $this->_option; $this->view->title = Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt(strtoupper($this->_name) . '_' . strtoupper($this->_task)); $this->view->task = $this->_task; $this->view->year = $eyear; $this->view->month = $emonth; $this->view->day = $eday; $this->view->row = $row; $this->view->authorized = $authorized; $this->view->fields = $fields; $this->view->config = $this->config; $this->view->categories = $categories; $this->view->offset = $offset; $this->view->tags = $tags; $this->view->auth = $auth; $this->view->page = $page; $this->view->pages = $pages; foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }
/** * Build a time zone select list for events * * @param $tzselected - currently selected time zone * @param $args - styles for field * @return Return - select list of time zones, with current time zone selected (if applicable) */ public static function buildTimeZoneSelect($tzselected, $args) { $timezones = array(\Html::select('option', -12, Lang::txt('EVENTS_TIME_UTC_-12')), \Html::select('option', -11, Lang::txt('EVENTS_TIME_UTC_-11')), \Html::select('option', -10, Lang::txt('EVENTS_TIME_UTC_-10')), \Html::select('option', -9.5, Lang::txt('EVENTS_TIME_UTC_-930')), \Html::select('option', -9, Lang::txt('EVENTS_TIME_UTC_-9')), \Html::select('option', -8, Lang::txt('EVENTS_TIME_UTC_-8')), \Html::select('option', -7, Lang::txt('EVENTS_TIME_UTC_-7')), \Html::select('option', -6, Lang::txt('EVENTS_TIME_UTC_-6')), \Html::select('option', -5, Lang::txt('EVENTS_TIME_UTC_-5')), \Html::select('option', -4, Lang::txt('EVENTS_TIME_UTC_-4')), \Html::select('option', -4.5, Lang::txt('EVENTS_TIME_UTC_-430')), \Html::select('option', -3.5, Lang::txt('EVENTS_TIME_UTC_-330')), \Html::select('option', -3, Lang::txt('EVENTS_TIME_UTC_-3')), \Html::select('option', -2, Lang::txt('EVENTS_TIME_UTC_-2')), \Html::select('option', -1, Lang::txt('EVENTS_TIME_UTC_-1')), \Html::select('option', 0, Lang::txt('EVENTS_TIME_UTC_0')), \Html::select('option', 1, Lang::txt('EVENTS_TIME_UTC_1')), \Html::select('option', 2, Lang::txt('EVENTS_TIME_UTC_2')), \Html::select('option', 3, Lang::txt('EVENTS_TIME_UTC_3')), \Html::select('option', 3.5, Lang::txt('EVENTS_TIME_UTC_330')), \Html::select('option', 4, Lang::txt('EVENTS_TIME_UTC_4')), \Html::select('option', 4.5, Lang::txt('EVENTS_TIME_UTC_430')), \Html::select('option', 5, Lang::txt('EVENTS_TIME_UTC_5')), \Html::select('option', 5.5, Lang::txt('EVENTS_TIME_UTC_530')), \Html::select('option', 5.75, Lang::txt('EVENTS_TIME_UTC_545')), \Html::select('option', 6, Lang::txt('EVENTS_TIME_UTC_6')), \Html::select('option', 6.5, Lang::txt('EVENTS_TIME_UTC_630')), \Html::select('option', 7, Lang::txt('EVENTS_TIME_UTC_7')), \Html::select('option', 8, Lang::txt('EVENTS_TIME_UTC_8')), \Html::select('option', 8.75, Lang::txt('EVENTS_TIME_UTC_845')), \Html::select('option', 9, Lang::txt('EVENTS_TIME_UTC_9')), \Html::select('option', 9.5, Lang::txt('EVENTS_TIME_UTC_930')), \Html::select('option', 10, Lang::txt('EVENTS_TIME_UTC_10')), \Html::select('option', 10.5, Lang::txt('EVENTS_TIME_UTC_1030')), \Html::select('option', 11, Lang::txt('EVENTS_TIME_UTC_11')), \Html::select('option', 11.5, Lang::txt('EVENTS_TIME_UTC_1130')), \Html::select('option', 12, Lang::txt('EVENTS_TIME_UTC_12')), \Html::select('option', 12.75, Lang::txt('EVENTS_TIME_UTC_1245')), \Html::select('option', 13, Lang::txt('EVENTS_TIME_UTC_13')), \Html::select('option', 14, Lang::txt('EVENTS_TIME_UTC_14'))); return \Html::select('genericlist', $timezones, 'time_zone', $args, 'value', 'text', $tzselected); }
if ($this->times['end_pm']) { echo 'checked="checked"'; } ?> /><small>PM</small> <?php } ?> </p> <label> <?php echo Lang::txt('EVENTS_CAL_TIME_ZONE'); ?> <?php echo \Components\Events\Helpers\Html::buildTimeZoneSelect($this->times['time_zone'], ''); ?> </label> </fieldset> <input type="hidden" name="state" value="<?php echo $this->escape($this->row->state); ?> " /> </fieldset><div class="clear"></div> <input type="hidden" name="email" value="<?php echo $this->escape(stripslashes($this->row->email)); ?> " /> <input type="hidden" name="restricted" value="<?php echo $this->escape(stripslashes($this->row->restricted));
/** * Short description for '_calendar' * * Long description (if any) ... * * @param unknown $timeWithOffset Parameter description (if any) ... * @param number $startday Parameter description (if any) ... * @param unknown $time Parameter description (if any) ... * @param unknown $linkString Parameter description (if any) ... * @param array &$day_name Parameter description (if any) ... * @param boolean $monthMustHaveEvent Parameter description (if any) ... * @return string Return description (if any) ... */ private function _calendar($timeWithOffset, $startday, $time, $linkString, &$day_name, $monthMustHaveEvent = false) { $database = App::get('db'); $cal_year = date("Y", $time); $cal_month = date("m", $time); $calmonth = date("n", $time); $to_day = date("Y-m-d", $timeWithOffset); // Start building the table $content = '<table class="mod_events_calendar">' . "\n"; $content .= ' <caption>' . "\n"; if ($this->params->get('show_nav_prev_month')) { $content .= ' <a class="prev month" href="' . Route::url('index.php?option=com_events&year=' . ($cal_month == 1 ? $cal_year - 1 : $cal_year) . '&month=' . ($cal_month == 1 ? 12 : $cal_month - 1)) . '">' . Html::getMonthName($cal_month == 1 ? 12 : $cal_month - 1) . '</a>' . "\n"; } $content .= ' <a class="current month" href="' . Route::url('index.php?option=com_events&year=' . $cal_year . '&month=' . $cal_month) . '">' . Html::getMonthName($cal_month) . '</a>' . "\n"; if ($this->params->get('show_nav_next_month')) { $content .= ' <a class="next month" href="' . Route::url('index.php?option=com_events&year=' . ($cal_month == 12 ? $cal_year + 1 : $cal_year) . '&month=' . ($cal_month == 12 ? 1 : $cal_month + 1)) . '">' . Html::getMonthName($cal_month == 12 ? 1 : $cal_month + 1) . '</a>' . "\n"; } $content .= ' </caption>' . "\n"; $content .= ' <thead>' . "\n"; $content .= ' <tr>' . "\n"; // Days name rows for ($i = 0; $i < 7; $i++) { $content .= ' <th>' . $day_name[($i + $startday) % 7] . '</th>' . "\n"; } $content .= ' </tr>' . "\n"; $content .= ' </thead>' . "\n"; $content .= ' <tbody>' . "\n"; $content .= ' <tr>' . "\n"; // Fix to fill in end days out of month correctly $dayOfWeek = $startday; $start = (date("w", mktime(0, 0, 0, $cal_month, 1, $cal_year)) - $startday + 7) % 7; $d = date("t", mktime(0, 0, 0, $cal_month, 0, $cal_year)) - $start + 1; $kownt = 0; for ($a = $start; $a > 0; $a--) { $content .= ' <td class="daylink"> </td>' . "\n"; $dayOfWeek++; $kownt++; } $monthHasEvent = false; $lastDayOfMonth = date("t", mktime(0, 0, 0, $cal_month, 1, $cal_year)); $rd = 0; for ($d = 1; $d <= $lastDayOfMonth; $d++) { $do = $d < 10 ? "0{$d}" : "{$d}"; $selected_date = "{$cal_year}-{$cal_month}-{$do}"; $sql = "SELECT `#__events`.* FROM `#__events`, `#__categories` as b" . " WHERE #__events.catid = b.id " . " AND ((publish_up >= '{$selected_date} 00:00:00' AND publish_up <= '{$selected_date} 23:59:59')" . " OR (publish_down >= '{$selected_date} 00:00:00' AND publish_down <= '{$selected_date} 23:59:59')" . " OR (publish_up <= '{$selected_date} 00:00:00' AND publish_down >= '{$selected_date} 23:59:59')) AND state='1'" . " AND (#__events.scope IS NULL OR #__events.scope=" . $database->quote('event') . ")" . " ORDER BY publish_up ASC"; $database->setQuery($sql); $rows = $database->loadObjectList(); $mark_bold = ''; $mark_close_bold = ''; $class = $selected_date == $to_day ? 'todaynoevents' : 'daynoevents'; // do we have events if (count($rows) > 0) { $class = 'daywithevents'; if ($selected_date == $to_day) { $class = 'todaywithevents'; } } // Only adds link if event scheduled that day $content .= ' <td class="' . $class . '">'; if ($class == 'todaywithevents' || $class == 'daywithevents') { $content .= '<a class="mod_events_daylink" href="' . Route::url('index.php?option=com_events&year=' . $cal_year . '&month=' . $cal_month . '&day=' . $do) . '">' . $d . '</a>'; } else { $content .= "{$d}"; } $content .= '</td>' . "\n"; $rd++; // Check if Next week row if ((1 + $dayOfWeek++) % 7 == $startday) { $content .= ' </tr>' . "\n" . ' <tr>' . "\n"; $rd = $rd >= 7 ? 0 : $rd; } } // Fill in any blank days for the rest of the row for ($d = $rd; $d <= 6; $d++) { $content .= ' <td> </td>' . "\n"; } // Finish off the table $content .= ' </tr>' . "\n"; $content .= ' </tbody>' . "\n"; $content .= '</table>' . "\n"; // Now check to see if this month needs to have at least 1 event in order to display if (!$monthMustHaveEvent || $monthHasEvent) { return $content; } else { return ''; } }
/** * Save an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); //$offset = Config::get('offset'); // Bind the posted data to an event object $row = new Event($this->database); if (!$row->bind($_POST)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error'); } // New entry or existing? if ($row->id) { // Existing - update modified info $row->modified = Date::toSql(); $row->modified_by = User::get('id'); } else { // New - set created info $row->created = Date::toSql(); $row->created_by = User::get('id'); } // Set some fields and do some cleanup work if ($row->catid) { $row->catid = intval($row->catid); } elseif (!$row->catid) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('EVENT_CAL_LANG_EVENT_REQUIRED'), 'error'); } //$row->title = $this->view->escape($row->title); //$row->content = Request::getVar('econtent', '', 'post'); $row->content = $_POST['econtent']; $row->content = $this->_clean($row->content); // Get the custom fields defined in the events configuration $fields = Request::getVar('fields', array(), 'post'); $fields = array_map('trim', $fields); // Wrap up the content of the field and attach it to the event content $fs = $this->config->fields; foreach ($fields as $param => $value) { if (trim($value) != '') { $row->content .= '<ef:' . $param . '>' . $this->_clean($value) . '</ef:' . $param . '>'; } else { foreach ($fs as $f) { if ($f[0] == $param && end($f) == 1) { echo Html::alert(Lang::txt('EVENTS_REQUIRED_FIELD_CHECK', $f[1])); exit; } } } } // Clean adresse $row->adresse_info = $this->_clean($row->adresse_info); // Clean contact $row->contact_info = $this->_clean($row->contact_info); // Clean extra $row->extra_info = $this->_clean($row->extra_info); // Prepend http:// to URLs without it if ($row->extra_info != NULL) { if (substr($row->extra_info, 0, 7) != 'http://' && substr($row->extra_info, 0, 8) != 'https://') { $row->extra_info = 'http://' . $row->extra_info; } } // make sure we have a start date if (!$row->publish_up) { $row->publish_up = \Date::toSql(); } // If this is a new event, publish it, otherwise retain its state if (!$row->id) { $row->state = 1; } // Get parameters $params = Request::getVar('params', '', 'post'); if (is_array($params)) { //email is reaquired $params['show_email'] = 1; $p = new \Hubzero\Config\Registry($params); $row->params = $p->toString(); } if (!$row->check()) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error'); } if (!$row->store()) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error'); } $row->checkin(); // Incoming tags $tags = Request::getVar('tags', '', 'post'); // Save the tags $rt = new Tags($row->id); $rt->setTags($tags, User::get('id')); // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_CAL_LANG_SAVED')); }
</fieldset> <fieldset> <legend> <?php echo Lang::txt('Timezone Settings'); ?> </legend> <label> <?php echo Lang::txt('Timezone:'); ?> <span class="optional">Optional</span> <?php $timezone = $this->event->get('time_zone'); $timezone = isset($timezone) ? $timezone : -5; echo \Components\Events\Helpers\Html::buildTimeZoneSelect($timezone, ''); ?> </label> </fieldset> <?php $repeating = $this->event->parseRepeatingRule(); $freqs = array('' => '- None —', 'daily' => 'Daily', 'weekly' => 'Weekly', 'monthly' => 'Monthy', 'yearly' => 'Yearly'); ?> <fieldset class="reccurance"> <legend> <?php echo Lang::txt('Repeating Settings'); ?> </legend> <label>