/[drupal]/contributions/modules/Syndicate2/syndicate2.module
ViewVC logotype

Contents of /contributions/modules/Syndicate2/syndicate2.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed May 31 03:58:17 2006 UTC (3 years, 5 months ago) by khoogheem
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +454 -226 lines
File MIME type: text/x-php
fixed a comment
1 <?php
2
3 // $Id:
4
5 ////////////////////////////////////////////////////////
6
7 // //
8
9 // by: Kevin A. Hoogheem //
10
11 // (kevin@hoogheem.net) //
12
13 // //
14
15 // You can redistribute this software under the terms //
16
17 // of the GNU General Public License as published by //
18
19 // the Free Software Foundation; either version 2 of //
20
21 // the License, or (at your option) any later //
22
23 // version. //
24
25 // //
26
27 // You should have received a copy of the GNU General //
28
29 // Public License along with this program; if not, //
30
31 // write to the Free Software Foundation, Inc., 59 //
32
33 // Temple Place, Suite 330, Boston, MA 02111-1307 USA //
34
35 // //
36
37 // Copyright 2004 by Kevin A. Hoogheem //
38
39 // Please keep this copyright information intact. //
40
41 ////////////////////////////////////////////////////////
42
43 /*
44
45
46
47 My yahoo (http://add.my.yahoo.com/rss?url=FEEDURL)
48
49 Google (http://fusion.google.com/add?feedurl=FEEDURL)
50
51 My MSN (http://my.msn.com/addtomymsn.armx?id=rss&ut= FEEDURL&ru=SITEURL)
52
53 Technorati (http://technorati.com/faves?add=FEEDURL)
54
55 Bloglines (http://www.bloglines.com/sub/FEEDURL')
56
57 NewsGator (http://www.newsgator.com/ngs/subscriber/subext.aspx?url= FEEDURL)
58
59 Feedster (http://www.feedster.com/myfeedster.php?action=addrss&rssurl= FEEDURL&confirm=no)
60
61 ROJO (http://www.rojo.com/add-subscription?resource= FEEDURL)
62
63 NewsIsFree (http://www.newsisfree.com/user/sub/?url=FEEDURL)
64
65
66
67
68
69 */
70
71
72
73
74
75 function syndicate2_help($section) {
76
77 switch ($section) {
78
79 case 'admin/modules#description':
80
81 // This description is shown in the listing at admin/modules.
82
83 return t('Adds Ability to Syndicate to popular aggregators.');
84
85 }
86
87 }
88
89
90
91
92
93 function syndicate2_block($op = 'list', $delta = 0, $edit = array()) {
94
95 $aSupported_Aggregators = array (
96
97 "MyYahoo" => "My Yahoo!",
98
99 "Google" => "Google",
100
101 "MyMSN" => "My MSN",
102
103 "Technorati" => "Technorati",
104
105 "Bloglines" => "Bloglines",
106
107 "NewsGator" => "NewsGator",
108
109 "Feedster" => "Feedster",
110
111 "ROJO" => "ROJO",
112
113 "NewsIsFree" => "NewsIsFree"
114
115 );
116
117
118
119 // The $op parameter determines what piece of information is being requested.
120
121 switch ($op) {
122
123 case 'list':
124
125 $blocks[0]['info'] = t('Syndicate2');
126
127 return $blocks;
128
129 case 'configure':
130
131 $output = form_checkboxes('Supported Aggregators', 'syn2_butons', variable_get('syndicate2_string', $edit['syn2_butons']), $aSupported_Aggregators, $description = NULL, $attributes = NULL, $required = FALSE) ;
132
133
134
135 return $output;
136
137 case 'save':
138
139 // If $op is "save", we need to save settings from the configuration form.
140
141 // Since the first block is the only one that allows configuration, we
142
143 // need to check $delta to make sure we only save it.
144
145 if ($delta == 0) {
146
147 // Have Drupal save the string to the database.
148
149 variable_set('syndicate2_string', $edit['syn2_butons']);
150
151 }
152
153 return;
154
155 case 'view': default:
156
157 // If $op is "view", then we need to generate the block for display
158
159 // purposes. The $delta parameter tells us which block is being requested.
160
161 switch ($delta) {
162
163 case 0:
164
165 $block['subject'] = t('Read our feed');
166
167 // The content of the block is typically generated by calling a custom
168
169 // function.
170
171 $block['content'] = block_contents(1);
172
173 break;
174
175 }
176
177 return $block;
178
179 }
180
181 }
182
183
184
185 function block_contents($block){
186
187 $sBlock = "<div class=\"xml-icon\">\n";
188
189 //Standard XML Feed
190
191 $sBlock .= theme('xml_icon', url('node/feed'))."\n";
192
193
194
195 //Add to aggregator sites
196
197 $aSitesList = variable_get('syndicate2_string', $edit['syn2_butons']);
198
199 foreach($aSitesList as $key=>$value) {
200
201 $sBlock .= _get_aggregator_info($value)."\n";
202
203 }
204
205 $sBlock .= "\n</div>";
206
207
208
209
210
211 return $sBlock;
212
213 }
214
215
216
217
218
219 function _get_aggregator_info($site){
220
221 global $base_url;
222
223
224
225 $_mod_base = drupal_get_path('module', 'syndicate2');
226
227 $FEEDURL = check_url("$base_url/node/feed");
228
229
230
231 switch($site){
232
233 case "MyYahoo":
234
235 //Yahoo
236
237 $agg_img = "$_mod_base/images/addtomyyahoo.gif";
238
239 $agg_url = "http://add.my.yahoo.com/rss?url=$FEEDURL";
240
241 $Alt_Tag = "MyYahoo!";
242
243 $Title_Tag = "Add to MyYahoo!";
244
245
246
247 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
248
249 return $site_info;
250
251
252
253 case "Google":
254
255 $agg_img = "$_mod_base/images/addgoogle.gif";
256
257 $agg_url = "http://fusion.google.com/add?feedurl=$FEEDURL";
258
259 $Alt_Tag = "Google";
260
261 $Title_Tag = "Add to Google";
262
263
264
265 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
266
267 return $site_info;
268
269
270
271 case "MyMSN":
272
273 $agg_img = "$_mod_base/images/myMSN.gif";
274
275 $agg_url = "http://my.msn.com/addtomymsn.armx?id=rss&ut=$FEEDURL&ru=$base_url";
276
277 $Alt_Tag = "MyMSN";
278
279 $Title_Tag = "Add to MyMSN";
280
281
282
283 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
284
285
286
287 return $site_info;
288
289
290
291 case "Technorati":
292
293 $agg_img = "$_mod_base/images/technorati.gif";
294
295 $agg_url = "http://technorati.com/faves?add=$FEEDURL";
296
297 $Alt_Tag = "Technorati";
298
299 $Title_Tag = "Add to Technorati";
300
301
302
303 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
304
305
306
307 return $site_info;
308
309
310
311 case "Bloglines":
312
313 $agg_img = "$_mod_base/images/sub_bloglines3.gif";
314
315 $agg_url = "http://www.bloglines.com/sub/$FEEDURL";
316
317 $Alt_Tag = "Bloglines";
318
319 $Title_Tag = "Add to Bloglines";
320
321
322
323 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
324
325
326
327 return $site_info;
328
329
330
331 case "NewsGator":
332
333 $agg_img = "$_mod_base/images/newsgator.gif";
334
335 $agg_url = "http://www.newsgator.com/ngs/subscriber/subext.aspx?url=$FEEDURL";
336
337 $Alt_Tag = "NewsGator";
338
339 $Title_Tag = "Add to NewsGator";
340
341
342
343 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
344
345
346
347 return $site_info;
348
349
350
351 case "Feedster":
352
353 $agg_img = "$_mod_base/images/addmyfeedster.gif";
354
355 $agg_url = "http://www.feedster.com/myfeedster.php?action=addrss&rssurl=$FEEDURL&confirm=no";
356
357 $Alt_Tag = "Feedster";
358
359 $Title_Tag = "Add to Feedster";
360
361
362
363 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
364
365
366
367 return $site_info;
368
369
370
371 case "ROJO":
372
373 $agg_img = "$_mod_base/images/RojoWideRed.gif";
374
375 $agg_url = "http://www.rojo.com/add-subscription?resource=$FEEDURL";
376
377 $Alt_Tag = "ROJO";
378
379 $Title_Tag = "Add to ROJO";
380
381
382
383 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
384
385
386
387 return $site_info;
388
389
390
391 case "NewsIsFree":
392
393 $agg_img = "$_mod_base/images/addnewsisfree.gif";
394
395 $agg_url = "http://www.newsisfree.com/user/sub/?url=$FEEDURL";
396
397 $Alt_Tag = "NewsIsFree";
398
399 $Title_Tag = "Add to NewsIsFree";
400
401
402
403 $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";
404
405
406
407 return $site_info;
408
409
410
411 }
412
413
414
415 }
416
417
418
419 function _create_img_src($img_url, $alt, $title){
420
421
422
423 if(($title == '') && ($alt == '')){
424
425 $alt = "Add Feed";
426
427 $title = $alt;
428
429 }
430
431 if($title == ''){
432
433 $title = $alt;
434
435 }
436
437 if ($alt == ''){
438
439 $alt = $title;
440
441 }
442
443
444
445 $img_src = "<img src=\"$img_url\" alt=\"$alt\" title=\"$title\" border=0 />";
446
447
448
449 return $img_src;
450
451 }
452
453 ?>
454

  ViewVC Help
Powered by ViewVC 1.1.2