cvs: phpweb / cal.php /include layout.inc
| From: | Gabor Hojtsy | Date: | Mon, 12 May 2003 11:48:36 +0000 |
| Subject: | cvs: phpweb / cal.php /include layout.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-17519@lists.php.net to get a copy of this message | ||
goba Mon May 12 07:48:36 2003 EDT
Modified files:
/phpweb cal.php
/phpweb/include layout.inc
Log:
Display local events in bold on the calendar page too
Also polish the display_event function and print out
the country information too about the event in brackets
Index: phpweb/cal.php
diff -u phpweb/cal.php:1.38 phpweb/cal.php:1.39
--- phpweb/cal.php:1.38 Wed Jan 15 12:04:21 2003
+++ phpweb/cal.php Mon May 12 07:48:36 2003
@@ -207,9 +207,8 @@
// Display a <div> for each of the events that are on a given day
function display_events_for_day($day, $events)
{
-
// For preservation of state in the links
- global $PHP_SELF, $cm, $cy;
+ global $PHP_SELF, $cm, $cy, $COUNTRY;
// For all events, try to find the events for this day
foreach ($events as $event) {
@@ -218,9 +217,12 @@
if (($event['type'] == 2 && $event['start'] <= $day
&& $event['end'] >= $day)
|| ($event['start'] == $day)) {
echo '<div class="event">',
+ ($COUNTRY == $event['country'] ? "<b>" : ""),
'<a
href="',$PHP_SELF,"?id=$event[id]&cm=$cm&cy=$cy",'">',
stripslashes(htmlentities($event['sdesc'])),
- '</a></div>';
+ '</a>',
+ ($COUNTRY == $event['country'] ? "</b>" : ""),
+ '</div>';
}
}
}
@@ -327,7 +329,7 @@
// Put the array elements into variables
list(
- , , , ,
+ $day, $month, $year, $country,
$sdesc, $id, $ldesc, $url, $recur, $tipo, $sdato, $edato
) = $linearr;
@@ -345,6 +347,7 @@
'sdesc' => $sdesc,
'url' => $url,
'ldesc' => base64_decode($ldesc),
+ 'country' => $country,
);
}
Index: phpweb/include/layout.inc
diff -u phpweb/include/layout.inc:1.147 phpweb/include/layout.inc:1.148
--- phpweb/include/layout.inc:1.147 Mon May 12 07:14:18 2003
+++ phpweb/include/layout.inc Mon May 12 07:48:36 2003
@@ -1,6 +1,6 @@
<?php
-/* $Id: layout.inc,v 1.147 2003/05/12 11:14:18 goba Exp $ */
+/* $Id: layout.inc,v 1.148 2003/05/12 11:48:36 goba Exp $ */
// Print an image for a sized spacer
function spacer($width = 1, $height = 1, $return = false, $align = false, $extras = false)
@@ -435,39 +435,80 @@
echo '</div>';
}
-function display_event($event,$include_date=1)
+// Displays an event. Used in event submission
+// previews and event information displays
+function display_event($event, $include_date = 1)
{
- for ($i = 1; $i <= 7; $i++) {
- $days[$i] = strftime('%A',mktime(12,0,0,4,$i,2001));
- }
-
- $re =
array(1=>'First',2=>'Second',3=>'Third',4=>'Fourth',-1=>'Last',-2=>'2nd
Last',-3=>'3rd Last');
-
- $sday = $event['start'] ? strtotime($event['start'])
- :
mktime(0,0,1,$event['smonth'],$event['sday'],$event['syear']);
- $eday = $event['end'] ? strtotime($event['end'])
- :
mktime(0,0,1,$event['emonth'],$event['eday'],$event['eyear']);
+ global $COUNTRIES;
+
+ // Weekday names array
+ for ($i = 1; $i <= 7; $i++) {
+ $days[$i] = strftime('%A', mktime(12, 0, 0, 4, $i, 2001));
+ }
+
+ // Recurring possibilities
+ $re = array(
+ 1 => 'First',
+ 2 => 'Second',
+ 3 => 'Third',
+ 4 => 'Fourth',
+ -1 => 'Last',
+ -2 => '2nd Last',
+ -3 => '3rd Last'
+ );
+
+ // Start and end day of this event
+ $sday = $event['start'] ? strtotime($event['start'])
+ : mktime(0, 0, 1, $event['smonth'], $event['sday'],
$event['syear']);
+ $eday = $event['end'] ? strtotime($event['end'])
+ : mktime(0, 0, 1, $event['emonth'], $event['eday'],
$event['eyear']);
?>
<table border="0" cellspacing="0" cellpadding="3"
width="100%">
<tr bgcolor="#dddddd"><td>
<?php
- if ($include_date && ($event['start'] || $event['smonth'])) echo
"<b>", date("F j, Y", $sday), "</b>\n";
- if ($event['url']) echo '<a href="',
htmlentities($event['url']),'">';
- echo "<b>", stripslashes(htmlentities($event['sdesc'])),
"</b>";
- if ($event['url']) echo "</a>";
- switch ($event['type']) {
- case 2:
- case 'multi':
- echo " (", date("Y-m-d",$sday), " to ",
date("Y-m-d",$eday), ")";
- break;
- case 3:
- case 'recur':
- echo " (Every ", $re[$event['recur']], " ",
$days[$event['recur_day']], " of the month)";
- break;
- }
+
+ // Print out date if needed
+ if ($include_date && ($event['start'] || $event['smonth'])) {
+ echo "<b>", date("F j, Y", $sday), "</b>\n";
+ }
+
+ // Print link in case we have one
+ if ($event['url']) { echo '<a href="',
htmlentities($event['url']),'">'; }
+ // Print event description
+ echo "<b>", stripslashes(htmlentities($event['sdesc'])),
"</b>";
+ // End link
+ if ($event['url']) { echo "</a>"; }
+
+ // Print extra date info for recurring and multiday events
+ switch ($event['type']) {
+ case 2:
+ case 'multi':
+ echo " (", date("Y-m-d",$sday), " to ",
date("Y-m-d",$eday), ")";
+ break;
+ case 3:
+ case 'recur':
+ echo " (Every ", $re[$event['recur']], " ",
+ $days[$event['recur_day']], " of the month)";
+ break;
+ }
+
+ // Print out country information
+ echo ' (' , $COUNTRIES[$event['country']] , ')';
+?>
+ </td></tr>
+ <tr bgcolor="#eeeeee"><td>
+<?php
+
+ // Print long description
+ echo preg_replace("/\r?\n\r?\n/", "<br /><br />",
trim($event['ldesc']));
+ // If we have an URL, print it out
+ if ($event['url']) {
+ echo '<br /><br /><b>URL:</b> ',
+ '<a href="', htmlentities($event['url']),
'">',
+ htmlentities($event['url']), '</a>';
+ }
?>
</td></tr>
- <tr bgcolor="#eeeeee"><td><?php echo
preg_replace("/\r?\n\r?\n/","<br /><br
/>",trim($event['ldesc'])); if ($event['url']) {?><br /><br
/><b>URL:</b> <?php echo '<a
href="',htmlentities($event['url']),'">',htmlentities($event['url']),'</a>';
}?></td></tr>
</table>
<?php
}