aboutsummaryrefslogtreecommitdiffstats
path: root/rss
diff options
context:
space:
mode:
authorJim Hu <jimhu@users.sourceforge.net>2005-11-12 07:57:37 +0000
committerJim Hu <jimhu@users.sourceforge.net>2005-11-12 07:57:37 +0000
commit59e3ffb75995ad2849f0f10e74d5b9c071642d8e (patch)
tree38c9d5458d2583767cf64acff7e590d2bedc7dae /rss
parent49a414746193c16fc7c0183032333a69de575cf5 (diff)
downloadphpicalendar-59e3ffb75995ad2849f0f10e74d5b9c071642d8e.zip
phpicalendar-59e3ffb75995ad2849f0f10e74d5b9c071642d8e.tar.gz
phpicalendar-59e3ffb75995ad2849f0f10e74d5b9c071642d8e.tar.bz2
fix rss.php bugs and merge multiday events
Diffstat (limited to 'rss')
-rw-r--r--rss/rss.php63
1 files changed, 49 insertions, 14 deletions
diff --git a/rss/rss.php b/rss/rss.php
index c622745..185b466 100644
--- a/rss/rss.php
+++ b/rss/rss.php
@@ -9,16 +9,17 @@
* - used below to deal with undef?
*********************************************************************************/
define('BASE', '../');
-include(BASE.'functions/ical_parser.php');
-if ($enable_rss != 'yes') {
- die ("RSS feeds are not enabled on this site.");
-}
+include_once(BASE.'functions/date_functions.php');
+
//set the range of days to return based on the view chosen
$rssview = $_GET['rssview'];
-
-if (!$getdate){$getdate = date("Ymd");}
+if (isset($_GET['getdate'])){
+ $getdate = $_GET['getdate'];
+}else{
+ $getdate = date("Ymd");
+}
switch ($rssview){
case 'day':
@@ -26,6 +27,11 @@ switch ($rssview){
$todate = $getdate;
$theview = $lang['l_day'];
break;
+ case 'week':
+ $fromdate = dateOfWeek($getdate, $week_start_day);
+ $todate = $fromdate + 6;
+ $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate));
+ break;
case 'month':
$parse_month = date ("Ym", strtotime($getdate));
$fromdate = ($parse_month *100) + 1;
@@ -35,13 +41,13 @@ switch ($rssview){
break;
case 'daysfrom':
$fromdate = $getdate;
- $todate = $getdate + $_GET['days'];
+ $todate = date("Ymd", strtotime($getdate) + $_GET['days']*60*60*24);
#print "from:$fromdate to: $todate<br>";
$theview = $_GET['days']." days from ".date('n/d/Y',strtotime($fromdate));
break;
case 'daysto':
$todate = $getdate;
- $fromdate = $getdate - $_GET['days'];
+ $fromdate = date("Ymd", strtotime($getdate) - $_GET['days']*60*60*24);
#print "from:$fromdate to: $todate<br>";
$theview = $_GET['days']." days before ".date('n/d/Y',strtotime($todate));
break;
@@ -54,9 +60,17 @@ switch ($rssview){
#default to week
$fromdate = dateOfWeek($getdate, $week_start_day);
$todate = $fromdate + 6;
- $theview = $lang['l_week']." of ".date('n/d/Y',strtotime($fromdate));
+ $theview = "";
}
+#need to give ical_parser the most distant date to correctly set up master_array.
+$getdate = $todate;
+#echo "from:$fromdate to:$todate";
+include(BASE.'functions/ical_parser.php');
+if ($enable_rss != 'yes') {
+ die ("RSS feeds are not enabled on this site.");
+}
+
//Set calendar or calendar directory name for feed
//Note that this depends on other modifications I've made to
//allow phpicalendar to use calendar subdirectories - see bbs
@@ -95,7 +109,9 @@ $rss = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"."\n";
$rss .= '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">'."\n";
$rss .= '<rss version="0.91">'."\n";
$rss .= '<channel>'."\n";
-$rss .= '<title>'.$cal_displayname.' - '.$theview.'</title>'."\n";
+$rss .= '<title>'.$cal_displayname;
+if ($theview !=""){$rss .= ' - '.$theview;}
+$rss .= "</title>\n";
$rss .= '<link>'.htmlspecialchars ("$default_path").'</link>'."\n";
$rss .= '<description>'.$cal_displayname.' '.$lang['l_calendar'].' - '.$theview.'</description>'."\n";
$rss .= '<language>'.$rss_language.'</language>'."\n";
@@ -107,15 +123,21 @@ $thisdate = $fromdate; # start at beginning of date range,
# note that usage of $thisdate is different from distribution
# I use it as a date, dist uses it as a time
$i = 0; #day counter
-
+$uid_arr = array();
do {
$thisdate=date('Ymd', strtotime($thisdate));
- #echo "Date: $thisdate\n";
+ #echo "Date: $thisdate<br>\n";
$dayofweek = localizeDate ("%a %b %e %Y", strtotime($thisdate));
if (isset($master_array[($thisdate)]) && sizeof($master_array[($thisdate)]) > 0) {
foreach ($master_array[("$thisdate")] as $event_times) {
- foreach ($event_times as $val) {
+ foreach ($event_times as $uid=>$val) {
if(!$val["event_start"]){
+ if (isset($uid_arr[$uid])){
+ $uid_arr[$uid] .= "+$dayofweek" ;
+ continue;
+ }else{
+ $uid_arr[$uid] = "$dayofweek" ;
+ }
$event_start = "All Day";
}else{
$event_start = @$val["event_start"];
@@ -125,6 +147,7 @@ $i = 0; #day counter
$event_text = strip_tags($event_text, '<b><i><u>');
$event_text = str_replace('&','&amp;',$event_text);
$event_text = str_replace('&amp;amp;','&amp;',$event_text);
+ $event_text = urlencode($event_text);
#uncomment for shorter event text with ...
# $event_text = word_wrap($event_text, 21, $tomorrows_events_lines);
$description = stripslashes(urldecode($val["description"]));
@@ -135,10 +158,11 @@ $i = 0; #day counter
$rss_title = htmlspecialchars ("$dayofweek: $event_text");
$rss_link = htmlspecialchars ("$default_path/day.php?getdate=$thisdate&cal=$cal&cpath=$cpath");
- if ($description == '') $description = $event_text;
$rss_description = htmlspecialchars ("$dayofweek $event_start: $description");
$rss .= '<item>'."\n";
+ $rss .= '<uid>'.$uid.'</uid>'."\n";
+ $rss .= '<event_start>'.$event_start.'</event_start>'."\n";
$rss .= '<title>'.$rss_title.'</title>'."\n";
/*
$rss .= '<event_start>'.$event_start.'</event_start>'."\n";
@@ -173,6 +197,17 @@ $i = 0; #day counter
$rss .= '</channel>'."\n";
$rss .= '</rss>'."\n";
+foreach ($uid_arr as $uid=>$date_range){
+ #echo "date_range:$date_range<br>";
+
+ if(strpos($date_range,"+")>0){
+ #echo "+ in date_range<br>";
+ $temp = explode("+",$date_range);
+ $date_range = $temp[0].'-'.array_pop($temp);
+ }
+ $rss = str_replace("<uid>$uid</uid>\n<event_start>all day</event_start>","<uid>$uid</uid>\n<event_start>$date_range</event_start>", $rss);
+
+}
header ("Content-Type: text/xml");
echo "$rss";

© 2014-2020 Faster IT GmbH | imprint | privacy policy