📄 calendar-box.php3
字号:
$j = 0; for( $i = 0; $i < $num_rows ; $i++ ) { $stuff = pg_fetch_array( $result_id, $i ); if( $stuff["timestamp"] != $currentstamp ) { $found[$currentstamp] = $events; $currentstamp = $stuff["timestamp"]; $j = 0; unset($events); } $events[$j++] = $stuff["event_id"]; } $found[$currentstamp] = $events; pg_close( $my_conn ); return $found; }// this function is pretty simple, just checks the index for event IDs function outputDayView( $num_days=1 ) {// we've got a timestamp, a number of days, and whether or not to display// unapproved stuff. global $timestamp; $today = mktime( 0,0,0 ); if (! isSet( $timestamp ) ) { $timestamp = mktime(); } if (! $my_conn = connectROToCalendar() ) { $during = "while connecting to the calendar database"; reportError( $php_errormsg, $during ); return; }// for each day... for ( $i = 0; $i < $num_days; $i++ ) { if( !$GLOBALS["text_only"] ) if ($i) echo( "<HR>\n" ); $current_stamp = mktime( 0, 0, 0, date( "m", $timestamp ), ( date( "j", $timestamp) + $i ), date( "Y", $timestamp ) ); $date = date( "l, F j, Y", $current_stamp ); $use_red = ($current_stamp == $today);// we only need the event_id, title, and starting time to display the short info// in text-only we only need the event_id, since we create an event object from that// but there's no point in pulling out the other stuff if( isSet($this->event_index[$current_stamp] )) { $events = $this->event_index[$current_stamp]; $my_query = "SELECT event_id, title, start_time "; $my_query .= " FROM srcEvent WHERE "; for( $q=0; $q<count($events); $q++ ){ if( $q ) $my_query .= " OR "; $my_query .= " event_id = " . $events[$q]; } $my_query .= " ORDER BY start_time ASC";//echo "Debug: $my_query<BR>"; if (! $result_id = @pg_exec( $my_conn, $my_query ) ) { $during = "while searching the event database"; reportError( $php_errormsg, $during ); return; } $num_rows = pg_NumRows( $result_id ); if (! $num_rows ) {reportError( "The event index listed events, but none were found." ); return; } if( !$GLOBALS["text_only"] ) { echo( "<BIG CLASS=\"" . ($use_red ? "red" : "green" ) . "\">" . $date . "</BIG><BR>\n" ); echo( "<EM>$num_rows event" . ($num_rows > 1 ? "s " : " ") . " found.</EM><BR>" ); echo( "<UL>\n" ); } else { echo( "<BIG>$date</BIG>\n" ); }// fetch the results and output the short info,// or if in text-only, create a new event object and output the text-only form for ( $j = 0; $j < $num_rows; $j++ ) { $current_event = pg_fetch_object( $result_id, $j ); if( $GLOBALS["text_only"] ) {$event = new SRCEventWithStringsFromEventID( $current_event->event_id );$event->outputTextOnly(); } else { echo( "<LI>\n" ."<A HREF=\"$this->action_url" . "&timestamp=$timestamp&cal_view=detail&" ."event_id=$current_event->event_id\">" . $current_event->title . "</A>\n" . "</LI>\n" ); } } if( !$GLOBALS["text_only"] ) echo( "</UL>\n" ); } else { if( !$GLOBALS["text_only"] ) echo( "<BIG" . ($use_red ? " CLASS=\"red\">" : ">" ) . $date . "</BIG><BR>\n" . "<EM>No events for today</EM><BR>\n" ); } } pg_close( $my_conn ); }// here we only want a certain day of the week function outputWeekdayView( $weekday=0 ) { $current_stamp = $this->month_begin;// Get us to the first day of the month of the given weekday $year = date( "Y", $current_stamp ); $month = date( "m", $current_stamp ); $date = 1 + $weekday - date( "w", $current_stamp ) +(date("w", $current_stamp)>$weekday ? 7 : 0 ); $current_stamp = mktime(0,0,0, $month, $date, $year ); // Header echo( "<BIG>Events on " . date( "l", $current_stamp ) . "s in " . date( "F", $current_stamp) . "</BIG><BR>\n" );// Searching the index $j = 0; while( checkdate( $month, $date, $year ) ) { $current_stamp = mktime(0,0,0, $month, $date, $year ); if( isSet( $this->event_index[$current_stamp] ) ){ $events = $this->event_index[$current_stamp]; for( $i=0; $i<count($events); $i++ ) { $found[$j++] = $events[$i]; } } $date += 7; }// No events listed in the index if (! $j ) { echo( "<EM>No events found.</EM><BR>\n" ); return; }// There were some events. Lets sort them and get rid of duplicates sort( $found ); $j = 0; for( $i=0; $i< count($found); $i++ ) { if( $found[$i] != $found[$i+1] ) $unique[$j++] = $found[$i]; } $unique[$j] = $found[$i++]; if (! $my_conn = connectROToCalendar() ) { $during = "while connecting to the calendar database"; reportError( $php_errormsg, $during ); return; } $my_query = "SELECT event_id, title, start_time "; $my_query .= " FROM srcEvent WHERE event_id IN ("; for( $q=0; $q<count($unique); $q++ ){ if( $q ) $my_query .= ", "; $my_query .= $unique[$q]; } $my_query .= ") ORDER BY start_time ASC";//echo "Debug: $my_query<BR>"; if (! $result_id = @pg_exec( $my_conn, $my_query ) ) { $during = "while searching the event database"; reportError( $php_errormsg, $during ); return; } $num_rows = pg_NumRows( $result_id ); if (! $num_rows ) {reportError( "The event index listed events, but none were found." ); return; } echo( "<EM>$num_rows event" . ($num_rows > 1 ? "s " : " ") . " found.</EM><BR>" ); echo( "<UL>\n" ); for ( $j = 0; $j < $num_rows; $j++ ) {// fetch some results and output the short info $current_event = pg_fetch_object( $result_id, $j ); echo( "<LI>\n" ."<A HREF=\"$this->action_url" . "&timestamp=" . $GLOBALS["timestamp"]. "&cal_view=detail&event_id=$current_event->event_id\">" .$current_event->title . "</A>\n" . "</LI>\n" ); } echo( "</UL>\n" ); pg_close( $my_conn ); }// let's look at the whole month function outputMonthView( $month_stamp = 0 ) { if( !$month_stamp ) $month_stamp = $this->month_begin; $year = date( "Y", $month_stamp ); $month = date( "m", $month_stamp ); $date = 1;// Header echo( "<BIG>Events in " . date( "F, Y", $month_stamp) . "</BIG><BR>\n" );// Searching the index $j = 0; while( checkdate( $month, $date, $year ) ) { $current_stamp = mktime(0,0,0, $month, $date, $year ); if( isSet( $this->event_index[$current_stamp] ) ){ $events = $this->event_index[$current_stamp]; for( $i=0; $i<count($events); $i++ ) { $found[$j++] = $events[$i]; } } $date++; }// No events listed in the index if (! $j ) { echo( "<EM>No events found.</EM><BR>\n" ); return; }// There were some events. Lets sort them and get rid of duplicates sort( $found ); $j = 0; for( $i=0; $i< count($found); $i++ ) { if( $found[$i] != $found[$i+1] ) $unique[$j++] = $found[$i]; } $unique[$j] = $found[$i++]; if (! $my_conn = connectROToCalendar() ) { $during = "while connecting to the calendar database"; reportError( $php_errormsg, $during ); return; } $my_query = "SELECT event_id, title, start_time "; $my_query .= " FROM srcEvent WHERE event_id IN ("; for( $q=0; $q<count($unique); $q++ ){ if( $q ) $my_query .= ", "; $my_query .= $unique[$q]; } $my_query .= ") ORDER BY start_time ASC";//echo "Debug: $my_query<BR>"; if (! $result_id = @pg_exec( $my_conn, $my_query ) ) { $during = "while searching the event database"; reportError( $php_errormsg, $during ); return; } $num_rows = pg_NumRows( $result_id ); if (! $num_rows ) {reportError( "The event index listed events, but none were found." ); return; } echo( "<EM>$num_rows event" . ($num_rows > 1 ? "s " : " ") . " found.</EM><BR>" ); echo( "<UL>\n" ); for ( $j = 0; $j < $num_rows; $j++ ) {// fetch some results and output the short info $current_event = pg_fetch_object( $result_id, $j ); echo( "<LI>\n" ."<A HREF=\"$this->action_url" . "&timestamp=" . $GLOBALS["timestamp"]. "&cal_view=detail&" . "event_id=$current_event->event_id\">" .$current_event->title . "</A>\n" . "</LI>\n" ); } echo( "</UL>\n" ); pg_close( $my_conn ); }// this is basically just a wrapper function outputDetailView( $event_id, $prev_link ) { $event = new SRCEventWithStringsFromEventID( $event_id ); $event->outputDetailView( $prev_link ); }// lots of html goes here function outputHelp() {?><BIG><?php echo $this->help_topic ?></BIG><P>The "Calendar" box displays a month at a time. You can browsethrough these months by following the "Previous month" and "Nextmonth" links beneath it. While in the desired month, you can view theevents for a given day, by clicking on that date, or a week at a time, byfollowing the "Week <I>n</I>" links. (Actually, the week view viewsseven days at a time, so if some week of the month has less than seven days,you'll see some from the next week or month.) You can also look at the eventsthat occur on a given day of the week in a month by clicking on the columntitle for that day of the week ("S", "M", etc)</P><P>If you're using a computer in the <I><?php echo $GLOBALS["config_domain"]; ?></I> domain, you alsohave the option to "View unapproved events." If you follow this,link, you will be able to see events that have been submitted, but not yet beenapproved for general viewing. This does not necessarily mean the events arebad, just that nobody has gotten around to approving them yet. You can hideunapproved events by following the "Hide unapproved events" link,which replaces the "View unapproved events" link.</P><P>Some approved events may still be hidden from browsers outside the<?php echo $GLOBALS["config_shortname"] . " "; ?>network. This is an option that can be selected while submitting anevent, if it's something that only <?php echo $GLOBALS["config_shortname"]; ?> Community members need to knowabout (for instance, if a certain well-known band is putting on a show for <?php echo $GLOBALS["config_abbrvname"]; ?> people, and outsiders are not invited).</P><?php } }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -