ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

rss.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class rss_2_0_0{
27
38 var $AutoMarkup = false;
39 var $CachedMultyFS = false;
40 var $Database = false;
41 var $PageComposer = false;
42 var $Security = false;
43 var $Settings = false;
44 var $String = false;
45
60 function __construct()
61 {
62 try
63 {
64 $this->AutoMarkup = get_package( 'page::page_parts' , 'last' , __FILE__ );
65 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
66 $this->Database = get_package( 'database' , 'last' , __FILE__ );
67 $this->PageComposer = get_package( 'page::page_composer' , 'last' , __FILE__ );
68 $this->Security = get_package( 'security' , 'last' , __FILE__ );
69 $this->Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
70 $this->String = get_package( 'string' , 'last' , __FILE__ );
71 }
72 catch( Exception $e )
73 {
74 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
75 }
76 }
77
96 function get_feed_records()
97 {
98 try
99 {
100 if( $this->Security->get_gp( 'feed' , 'set' ) === false )
101 {
102 return( false );
103 }
104
105 $Feed = $this->Security->get_gp( 'feed' , 'command' );
106
107 $FeedScript = $this->CachedMultyFS->get_data( __FILE__ , "$Feed.sql" );
108 $FeedScript = $this->AutoMarkup->compile_string( $FeedScript );
109
110 $this->Database->query_as( DB_OBJECT );
111
112 $Result = $this->Database->query( $FeedScript );
113
114 return( $this->Database->fetch_results( $Result ) );
115 }
116 catch( Exception $e )
117 {
118 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
119 }
120 }
121
144 private function compile_records( &$Records )
145 {
146 try
147 {
148 $FeedXml = $this->CachedMultyFS->get_template( __FILE__ , 'rss20_feed.tpl' );
149
150 foreach( $Records as $Record )
151 {
152 $FeedItem = $this->CachedMultyFS->get_template( __FILE__ , 'rss20_item.tpl' );
153
154 $FeedItem = $this->String->print_record( $FeedItem , $Record );
155
156 $FeedXml = str_replace( '{items}' , $FeedItem.'{items}' , $FeedXml );
157 }
158
159 return( $FeedXml );
160 }
161 catch( Exception $e )
162 {
163 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
164 }
165 }
166
189 function compile_feed( &$Records )
190 {
191 try
192 {
193 $FeedXml = $this->compile_records( $Records );
194
195 $FeedXml = str_replace( '{last_build_date}' , date( 'r' ) , $FeedXml );
196 $FeedXml = str_replace( '{package_path}' , _get_package_path( 'rss' , '2.0.0' ) , $FeedXml );
197
198 $this->Settings->load_file( dirname( __FILE__ ).'/conf/cf_default' );
199 $FeedXml = $this->String->print_record( $FeedXml , $this->Settings->get_raw_settings() );
200
201 $FeedXml = $this->AutoMarkup->compile_string( $FeedXml );
202
203 return( $FeedXml );
204 }
205 catch( Exception $e )
206 {
207 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
208 }
209 }
210
229 function view( $Options )
230 {
231 try
232 {
233 $Records = $this->get_feed_records();
234
235 if( $Records === false )
236 {
237 return( false );
238 }
239
240 $Feed = $this->compile_feed( $Records );
241
242 $Feed = $this->Security->get( $Feed , 'unsafe_string' );
243
244 header( "Content-Type: application/rss+xml" );
245
246 return( $Feed );
247 }
248 catch( Exception $e )
249 {
250 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
251 }
252 }
253
280 function compile_rss_button( &$Settings )
281 {
282 try
283 {
284 $Type = $Settings->get_setting( 'type' , 'small' );
285
286 $Code = $this->CachedMultyFS->get_template( __FILE__ , $Type.'_rss_button.tpl' );
287
288 $Code = $this->String->print_record( $Code , $Settings );
289
290 $Code = str_replace( '{package_path}' , _get_package_relative_path_ex( 'rss' , '2.0.0' ) , $Code );
291
292 return( $Code );
293 }
294 catch( Exception $e )
295 {
296 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
297 }
298 }
299 }
300
301 ?>