function display_page_content() { $event_id = getRequestVarAtIndex(4); $event = Events::FindById($event_id); $event_types = EventTypes::FindAll(); $event_periods = EventPeriods::FindAll(); $year = getRequestVarAtIndex(2); $month = getRequestVarAtIndex(3); $recurrences = Recurrence::FindForEvent($event_id); $days = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $user = Users::GetCurrentUser(); ?> <script type="text/javascript"> //<![CDATA[ $().ready(function() { setupDateFields("<?php echo $event->eventperiod_id; ?> "); $.datepicker.setDefaults({ showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true }); $( "#date_start" ).datepicker(); $( "#time_start" ).timepicker({timeFormat: 'hh:mm:ss tt',stepMinute: 5}); $( "#date_end" ).datepicker(); $( "#time_end" ).timepicker({timeFormat: 'hh:mm:ss tt',stepMinute: 5}); $( "#not_date" ).datepicker(); $("a#notdate_add").click(function() { var date = $("input[name='not_date']").val(); if (date != "") { $("input[name='not_date']").val(''); var all_dates_vis = $("span#notdates").html(); $("span#notdates").html("<label for=\"notdates[]\">"+date+" <a href=\"javascript:;\" onClick=\"$(this).parent().remove();\">X</a><input type=\"hidden\" name=\"notdates[]\" value=\""+date+"\" /></label>"+all_dates_vis); } }); $("#eventperiod_id").change(function() { var selected = $(this).val(); setupDateFields(selected); }); $("#edit_event").validate({ rules: { title: "required", date_start: "required", }, messages: { title: "Please enter a title for this event", date_start: "Please at least a start date for this event", } }); }); //]]> </script> <div id="edit-header" class="event"> <h1>Edit Event</h1> </div> <div id="calendar_div"></div> <form method="POST" id="edit_event"> <p class="display_name"> <label for="title">Title</label> <?php textField("title", $event->title, "required: true"); ?> </p> <?php if (ALLOW_EVENT_TYPES && count($event_types) > 1) { ?> <p> <label for="eventtype_id">Event Type</label> <select name="eventtype_id" id="eventtype_id"> <?php foreach ($event_types as $event_type) { echo "<option value='{$event_type->id}' "; if ($event_type->id == $event->eventtype_id) { echo " selected "; } echo ">{$event_type->name}</option>\r\n"; } ?> </select> </p> <?php } ?> <div id="eventdateselects" class="dropslide"> <p><label for="eventperiod_id">Event Period:</label> <select name="eventperiod_id" id="eventperiod_id"> <?php foreach ($event_periods as $event_period) { echo "<option value='{$event_period->id}' "; if ($event_period->id == $event->eventperiod_id) { echo " selected "; } echo ">{$event_period->name}</option>\r\n"; } ?> </select> </p> <p> <label for="date_start">Start Date / Time</label> <input type="text" name="date_start" id="date_start" style="width: 6.5em;" value="<?php echo $event->getDateStart("date"); ?> " class="required: true" /> <input type="text" name="time_start" id="time_start" style="width: 6.5em;" value="<?php echo $event->getDateStart("time"); ?> " /> <label for="date_start">End Date / Time</label> <input type="text" name="date_end" id="date_end" style="width: 6.5em;" value="<?php echo $event->getDateEnd("date"); ?> " /> <input type="text" name="time_end" id="time_end" style="width: 6.5em;" value="<?php echo $event->getDateEnd("time"); ?> " /> </p> <div id="recurrence_rules" <?php if ($event->eventperiod_id != 3) { echo "style=\"display: none; \""; } ?> > <p><label for="not_date">Exclusion Date(s)</label> <input type="text" name="not_date" id="not_date" style="width: 6.5em;"/> <a href="javascript:;" id="notdate_add">Add to list→</a> <span id="notdates"> <?php foreach (explode(",", $event->getNotDates()) as $date) { if ($date != "") { echo "<label for=\"{$date}\">{$date} <a href=\"javascript:;\" onClick=\"\$(this).parent().remove();\">×</a><input type=\"hidden\" name=\"notdates[]\" value=\"{$date}\" /></label>"; } } ?> </span> </p> <label>Recurrence Rules</label> <table> <tbody> <tr> <th> </th> <th>Sunday</th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> </tr> <tr> <td>Every</td> <?php foreach ($days as $day) { echo "<td>"; get_recurrence_tag($recurrences, $day, 0); echo "</td>"; } ?> </tr> <tr> <td>First</td> <?php foreach ($days as $day) { echo "<td>"; get_recurrence_tag($recurrences, $day, 1); echo "</td>"; } ?> </tr> <tr> <td>Second</td> <?php foreach ($days as $day) { echo "<td>"; get_recurrence_tag($recurrences, $day, 2); echo "</td>"; } ?> </tr> <tr> <td>Third</td> <?php foreach ($days as $day) { echo "<td>"; get_recurrence_tag($recurrences, $day, 3); echo "</td>"; } ?> </tr> <tr> <td>Fourth</td> <?php foreach ($days as $day) { echo "<td>"; get_recurrence_tag($recurrences, $day, 4); echo "</td>"; } ?> </tr> <tr> <td>Last</td> <?php foreach ($days as $day) { echo "<td>"; get_recurrence_tag($recurrences, $day, 5); echo "</td>"; } ?> </tr> </tbody> </table> </div> </div> <p> <label for="name">Event Description</label><br /> <?php textArea("description", $event->description, 98, EDIT_WINDOW_HEIGHT); ?> </p> <?php require_once snippetPath("admin-insert_configs"); ?> <div id="edit-footer" class="eventnav clearfix"> <div class="column half"> <p> <input type="submit" class="submitbutton" name="submit" value="Edit Event" /> <br /> <input type="submit" class="submitbuttonsmall" name="submit" value="Edit and Return to List" /> </p> </div> <div class="column half last"> <?php if ($user->has_role()) { ?> <p><label for="delete">Delete this Event? <input name="delete" id="delete" class="boxes" type="checkbox" value="<?php echo $event->id; ?> "></label> <span class="hint">Check the box and click “Save” to delete this event from the database</span></p> <?php } ?> </div> </div> </form> <?php }
function formatSpecialRecurrence() { // DO NOT USE THIS FUNCTION ON ITS OWN... it is called from ->getDateRangeStringWithRecurrence() // This function tries to deal with a few special instances... it calls ->formatRecurrence() when needed $event_recurrence = Recurrence::FindForEvent($this->id); $firstrecurrence_mod = ""; $firstrecurrence_day = ""; $recurrence_string = ""; $counter = 1; $countupto = count($event_recurrence); $daysofweek = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $recurrence_def = array("Every", "First", "Second", "Third", "Fourth", "Last"); if (substr($this->getDateStart("date"), 0, 5) == "01/01" && substr($this->getDateEnd("date"), 0, 5) == "12/31") { // This date range encompasses the entire year return $recurrence_string = "All Year"; } else { // Ok, start the recurrence checking if ($countupto == "7") { return $recurrence_string = "All Week"; } else { if ($countupto == "6") { $first_event_recurrence = array_shift($event_recurrence); if ($first_event_recurrence->modifier == 0) { // Try to figure out which day this event is NOT on $recur_array = array(); // Turn the recurrence object into an array... foreach ($event_recurrence as $recurrence) { array_push($recur_array, $recurrence->day); } // Get the difference between the two $difference = array_difference($recur_array, $daysofweek); // What we have is in an array, so a foreach gets it out foreach ($difference as $theday) { $recurrence_string = "Every day but {$theday}"; } } else { // Not an "Every" instance, so use the normal recurrence function return $recurrence_string = $this->formatRecurrence(); } } else { if ($countupto == "2") { foreach ($event_recurrence as $recurrence) { if ($counter == 1) { // This is the first loop... // Just set some variables that will be checked on the second loop $firstrecurrence_mod = $recurrence->modifier; $firstrecurrence_day = $recurrence->day; $counter++; } else { // Now, check the variables before adding to the string if ($firstrecurrence_mod == $recurrence->modifier) { // The modifier is the same if ($firstrecurrence_day == $recurrence->day) { // The days are the same, like "First & Third Tuesdays" $recurrence_string .= $recurrence_def[$firstrecurrence_mod] . " & " . $recurrence_def[$recurrence->modifier] . " " . $recurrence->day . "s"; } else { // The days are not the same if ($recurrence->modifier == 0) { // Like "Every Monday & Wednesday" $recurrence_string .= "Every {$firstrecurrence_day} & {$recurrence->day}"; } else { // Make the days plural, like "Second Mondays & Wednesdays" $recurrence_string .= $recurrence_def[$recurrence->modifier] . " " . $firstrecurrence_day . "s & " . $recurrence->day . "s"; } } } else { // The modifer is different if ($firstrecurrence_day == $recurrence->day) { // The days are the same, like "First & Third Tuesdays" $recurrence_string .= $recurrence_def[$firstrecurrence_mod] . " & " . $recurrence_def[$recurrence->modifier] . " " . $recurrence->day . "s"; } else { // The days are not the same, like "First Tuesdays & Third Thursdays" $recurrence_string .= $recurrence_def[$firstrecurrence_mod] . " " . $firstrecurrence_day . "s & " . $recurrence_def[$recurrence->modifier] . " " . $recurrence->day . "s"; } } $counter++; } } // Clean up a few special instances this function may create if ($recurrence_string == "Every Sunday & Saturday") { return $recurrence_string = "Every Weekend"; } } else { return $recurrence_string = $this->formatRecurrence(); } } } } return $recurrence_string; }