Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

rssheadlines.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: articlelistrss.php,v 1.6.2.2 2003/07/22 09:55:52 vl Exp $
5 //
6 // Created on: <11-Dec-2000 09:44:51 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27
28 include_once( "classes/INIFile.php" );
29 include_once( "classes/ezlocale.php" );
30 include_once( "classes/eztexttool.php" );
31
32 include_once( "ezgroupeventcalendar/classes/ezgroupevent.php" );
33 include_once( "ezgroupeventcalendar/classes/ezgroupeventtype.php" );
34 include_once( "ezgroupeventcalendar/classes/ezgroupnoshow.php" );
35 include_once( "ezgroupeventcalendar/classes/ezgroupeditor.php" );
36
37 include_once( "classes/ezdatetime.php" );
38
39 include_once( "classes/ezvardump.php" );
40
41 // get ini variables
42 $ini =& eZINI::instance( 'site.ini' );
43 $Title = htmlspecialchars($ini->variable( "eZGroupEventCalendarRSS", "Title" ));
44 $Link = $ini->variable( "eZGroupEventCalendarRSS", "Link" );
45 $Description = htmlspecialchars($ini->variable( "eZGroupEventCalendarRSS", "Description" ));
46 $Language = $ini->variable( "eZGroupEventCalendarRSS", "Language" );
47 $Encoding = $ini->variable( "eZGroupEventCalendarRSS", "Encoding" );
48
49 $Image = $ini->variable( "eZGroupEventCalendarRSS", "Image" );
50 // $CategoryID = $ini->variable( "eZGroupEventCalendarRSS", "CategoryID" );
51 $GroupID = $ini->variable( "eZGroupEventCalendarRSS", "GroupID" );
52 $Limit = $ini->variable( "eZGroupEventCalendarRSS", "Limit" );
53 $LimitDirectionForward = true;
54 $RssVersion = $ini->variable( "eZGroupEventCalendarRSS", "RssVersion" );
55
56 $headerInfo = ( getallheaders() );
57 $Host = $headerInfo["Host"] ;
58
59 //debug : disable rss output
60 $Debug = false;
61
62 // clear what might be in the output buffer
63 ob_end_clean();
64
65 if (!$Debug){
66 if ( $RssVersion == "0.9" ){
67 // xml header
68 header( "Content-type: text/xml" );
69 print( "<?xml version=\"1.0\" encoding=\"$Encoding\"?>\n\n" );
70
71 // rss header
72 //print( "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\" \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n" );
73 print( "<rss version=\"0.92\">\n" );
74
75 print( "<channel>\n" );
76 print( "<title>$Title</title>\n" );
77 print( "<link>$Link</link>\n" );
78 print( "<description>$Description</description>\n" );
79 print( "<language>$Language</language>\n" );
80 //print( "<language/>");
81
82 // Print Channel Image Tag
83 print( "<image>\n" );
84 print( "<url>http://".$Host.$Image."</url>\n" );
85 print( "<link>http://".$Link."</link>\n" );
86 print( "<title>".Title."</title>\n" );
87 print( "</image>\n" );
88 }elseif ( $RssVersion == "1.0" ) {
89
90 // xml header
91 header( "Content-type: text/xml" );
92 print( "<?xml version=\"1.0\" encoding=\"$Encoding\"?>\n\n" );
93
94 // rss header
95 print( '<rdf:RDF
96 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
97 xmlns="http://purl.org/rss/1.0/"
98 xmlns:dc="http://purl.org/dc/elements/1.1/">'. "\n" );
99
100 print( '<channel rdf:about="http://'. $Host .'/groupcalendar/rss">'. "\n" );
101 print( "<title>$Title</title>\n" );
102 print( "<link>$Link</link>\n" );
103 print( "<description>$Description</description>\n" );
104
105 // print( "<language>$Language</language>\n" );
106 // Print Channel Image Tag
107 // print( "<image>\n" );
108 // print( "<url>http://".$Host.$Image."</url>\n" );
109 // print( "<link>http://".$Link."</link>\n" );
110 // print( "<title>".Title."</title>\n" );
111 // print( "</image>\n" );
112 }
113 } //end if(!$Debug)
114
115
116 // get articles. Always sort by date/time (newest first) + $Limit (5|7|30 days)
117 for ($i=0; $i<=$Limit; $i++){
118 if($Debug)
119 print("<br /> it - $i || ");
120
121 $currentDate = new eZDateTime();
122 $currentDate = $currentDate->date();
123
124 if($LimitDirectionForward){
125 $currentDate->move(0,0,"+$i");
126 }else{
127 $currentDate->move(0,0,"-$i");
128 }
129
130 $dateLimit = $currentDate;
131
132 $dateYear = $dateLimit->year();
133 $dateMonth = addZero( $dateLimit->month() );
134 $dateDay = addZero( $dateLimit->day() );
135 $date = $dateYear ."-". $dateMonth ."-". $dateDay ; //." ". $dateHour .":". $dateMinute;
136
137 if($Debug)
138 print "$date <br />";
139
140 if ( $GroupID == 0)
141 {
142 $event = new eZGroupEvent();
143 if($Limit){
144 $eventList = $event->getAllByDate($dateLimit);
145 }else {
146 $eventList = $event->getAll();
147 }
148 }
149 else
150 {
151 $event = new eZGroupEvent();
152 $eventList = $event->getByGroup($GroupID);
153 }
154
155 // build combined result set
156 if($Debug){
157 // Var_Dump::display($eventList);
158 print("EventListIterationCount: ". sizeof($eventList)."<br />");
159 }
160
161 for ($e=0; $e<sizeof($eventList); $e++){
162 $it = $eventList[$e];
163 if( $it != false)
164 $eventListLimited[] = $it;
165 if($Debug)
166 print "$e : EventListIterationObj: ". $eventList[$e] ."<br />";
167 }
168 }
169
170 if($Debug)
171 print("<br />|| ". sizeof($eventListLimited)." || <br />");
172
173 // Var_Dump::display($eventListLimited);
174
175 if ( $RssVersion != "0.9" ){
176 print("<items>\n");
177 print("<rdf:Seq>\n");
178 foreach( $eventListLimited as $event )
179 {
180 $eventID = $event->id();
181 print('<rdf:li resource="http://'. $Host .'/groupeventcalendar/eventview/'. $eventID .'/"/>'. "\n");
182 }
183 print("</rdf:Seq>\n");
184 print("</items>\n");
185 print("</channel>\n");
186 }
187
188 $locale = new eZLocale( $Language );
189
190 foreach( $eventListLimited as $event )
191 {
192 $eventID = $event->id();
193 $description = $event->description();
194
195 /*
196 prefix relative Links in href and src attributes with the Hostname,
197 so the feed does not contain relative links and feedreaders can parse the links and show the images.
198 */
199 $description = str_replace("href=\"/", "href=\"http://".$Host."/", $description);
200 $description = str_replace("src=\"/", "src=\"http://".$Host."/", $description);
201
202 $date = $event->dateTime();
203
204 /*
205 $date = $date->month() ."/". $date->day() ."/". $date->year() ." ". $date->hour()
206 .":". $date->minute() .":". $date->second();
207 */
208
209 $dateYear = $date->year();
210 $dateMonth = addZero( $date->month() );
211 $dateDay = addZero( $date->day() );
212 $dateHour = addZero( $date->hour() );
213 $dateMinute = addZero( $date->minute() );
214 $dateSecond = addZero( $date->second() );
215
216 // $date = $dateMonth ."/". $dateDay ."/". $date->year() ." ". $dateHour .":". $dateMinute .":". $dateSecond;
217 // $date = $date->year() ."-". $dateMonth ."-". $dateDay;
218 //" ". $dateHour .":". $dateMinute .":". $dateSecond;
219 // $date = $dateYear ."-". $dateMonth ."-". $dateDay;
220 $date = $dateYear ."-". $dateMonth ."-". $dateDay ." ". $dateHour .":". $dateMinute;
221 // $date = $dateYear ."-". $dateMonth ."-". $dateDay;
222
223 $isRepeat = "";
224 if($event->isRecurring())
225 $isRepeat = "(Repeat Event)";
226 // $isRepeat = "(Repeat Event : $eventDates)";
227
228 $description .= "\n". "Start: $date $isRepeat";
229 $description = strip_tags( $description );
230
231 $description = strip_tags( $description , "<a>");
232
233 // $description = htmlspecialchars( $description );
234
235
236 if ( $RssVersion == "0.9" ){
237
238 print( "<item>\n" );
239 print( "<title>" . htmlspecialchars($event->name()) . "</title>\n" );
240 print( "<link>http://" . $Host . "/groupeventcalendar/eventview/$eventID/</link>\n" );
241
242 // $published = $event->published();
243 // print( $locale->format( $published ) );
244
245 // encode HTML special character like < , > and " and print the tag
246 print( "<description>". $description ."</description>\n" );
247 print( "</item>\n" );
248 }elseif ( $RssVersion == "1.0" ) {
249 print('<item rdf:about="http://'. $Host .'/groupeventcalendar/eventview/'. $eventID .'/">'. "\n");
250 print("<title>". htmlspecialchars($event->name()) . "</title>\n" );
251 print( "<description>". $description ."</description>\n" );
252 print( "<link>http://" . $Host . "/groupeventcalendar/eventview/$eventID/</link>\n" );
253 print("<dc:date>".$date."</dc:date>\n");
254 print("</item>\n");
255 }
256 }
257
258 if ( $RssVersion == "0.9" ){
259 print( "\n</channel>\n" );
260 print( "\n</rss>\n" );
261 }elseif ( $RssVersion == "1.0" ) {
262 print("</rdf:RDF>\n");
263 }
264
265 //Adds a "0" in front of the value if it's below 10.
266 function addZero( $value )
267 {
268 settype( $value, "integer" );
269 $ret = $value;
270 if ( $ret < 10 )
271 {
272 $ret = "0". $ret;
273 }
274 return $ret;
275 }
276
277 exit();
278
279 ?>
280
$i
$i
Definition: admin/adlist.php:91
$date
$date
Definition: bugpreview.php:66
eZDateTime
Definition: ezdatetime.php:55
eZGroupEvent
Definition: ezgroupevent.php:85
eZLocale
Definition: ezlocale.php:119
$eventList
$eventList
Definition: cron_alerts.php:101
$event
if(isset( $Action) && $Action=="New") else $event
Definition: eventedit.php:189
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
exit
exit
Definition: folder.php:81
$Limit
$Limit
Definition: rssheadlines.php:52
addZero
foreach( $eventListLimited as $event) if( $RssVersion=="0.9") elseif( $RssVersion=="1.0") addZero( $value)
Definition: rssheadlines.php:266
$Description
$Description
Definition: rssheadlines.php:45
$locale
if( $RssVersion !="0.9") $locale
Definition: rssheadlines.php:188
$RssVersion
$RssVersion
Definition: rssheadlines.php:54
$GroupID
$GroupID
Definition: rssheadlines.php:51
$Title
$Title
Definition: rssheadlines.php:43
$Image
$Image
Definition: rssheadlines.php:49
$Encoding
$Encoding
Definition: rssheadlines.php:47
$Language
$Language
Definition: rssheadlines.php:46
$ini
$ini
Definition: rssheadlines.php:42
$Debug
$Debug
Definition: rssheadlines.php:60
$Host
$Host
Definition: rssheadlines.php:57
$LimitDirectionForward
$LimitDirectionForward
Definition: rssheadlines.php:53
$Link
$Link
Definition: rssheadlines.php:44
$headerInfo
$headerInfo
Definition: rssheadlines.php:56
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.