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

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

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

revision 1.1 by khoogheem, Mon May 29 01:42:36 2006 UTC revision 1.2 by khoogheem, Wed May 31 03:58:17 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id:  
3  ////////////////////////////////////////////////////////  // $Id:
4  //                                                    //  
5  //          by: Kevin A. Hoogheem                     //  ////////////////////////////////////////////////////////
6  //                   (kevin@hoogheem.net)             //  
7  //                                                    //  //                                                    //
8  // You can redistribute this software under the terms //  
9  // of the GNU General Public License as published by  //  //          by: Kevin A. Hoogheem                     //
10  // the Free Software Foundation; either version 2 of  //  
11  // the License, or (at your option) any later         //  //                   (kevin@hoogheem.net)             //
12  // version.                                           //  
13  //                                                    //  //                                                    //
14  // You should have received a copy of the GNU General //  
15  // Public License along with this program; if not,    //  // You can redistribute this software under the terms //
16  // write to the Free Software Foundation, Inc., 59    //  
17  // Temple Place, Suite 330, Boston, MA 02111-1307 USA //  // of the GNU General Public License as published by  //
18  //                                                    //  
19  //     Copyright 2004 by Kevin A. Hoogheem            //  // the Free Software Foundation; either version 2 of  //
20  //   Please keep this copyright information intact.   //  
21  ////////////////////////////////////////////////////////  // the License, or (at your option) any later         //
22    
23  My yahoo (http://add.my.yahoo.com/rss?url=FEEDURL)  // version.                                           //
24  Google (http://fusion.google.com/add?feedurl=FEEDURL)  
25  My MSN (http://my.msn.com/addtomymsn.armx?id=rss&ut= FEEDURL&ru=SITEURL)  //                                                    //
26  Technorati (http://technorati.com/faves?add=FEEDURL)  
27  Bloglines (http://www.bloglines.com/sub/FEEDURL')  // You should have received a copy of the GNU General //
28  NewsGator (http://www.newsgator.com/ngs/subscriber/subext.aspx?url= FEEDURL)  
29  Feedster (http://www.feedster.com/myfeedster.php?action=addrss&rssurl= FEEDURL&confirm=no)  // Public License along with this program; if not,    //
30  ROJO (http://www.rojo.com/add-subscription?resource= FEEDURL)  
31  NewsIsFree (http://www.newsisfree.com/user/sub/?url=FEEDURL)  // write to the Free Software Foundation, Inc., 59    //
32    
33    // Temple Place, Suite 330, Boston, MA 02111-1307 USA //
34  */  
35    //                                                    //
36    
37  function syndicate2_help($section) {  //     Copyright 2004 by Kevin A. Hoogheem            //
38    switch ($section) {  
39      case 'admin/modules#description':  //   Please keep this copyright information intact.   //
40        // This description is shown in the listing at admin/modules.  
41        return t('Adds Ability to Syndicate to popular aggregators.');  ////////////////////////////////////////////////////////
42    }  
43  }  /*
44    
45    
46  function syndicate2_block($op = 'list', $delta = 0, $edit = array()) {  
47  $aSupported_Aggregators = array (  My yahoo (http://add.my.yahoo.com/rss?url=FEEDURL)
48          "MyYahoo" => "My Yahoo!",  
49          "Google" => "Google",  Google (http://fusion.google.com/add?feedurl=FEEDURL)
50          "MyMSN" => "My MSN",  
51          "Technorati" => "Technorati",  My MSN (http://my.msn.com/addtomymsn.armx?id=rss&ut= FEEDURL&ru=SITEURL)
52          "Bloglines" => "Bloglines",  
53          "NewsGator" => "NewsGator",  Technorati (http://technorati.com/faves?add=FEEDURL)
54          "Feedster" => "Feedster",  
55          "ROJO" => "ROJO",  Bloglines (http://www.bloglines.com/sub/FEEDURL')
56          "NewsIsFree" => "NewsIsFree"  
57  );  NewsGator (http://www.newsgator.com/ngs/subscriber/subext.aspx?url= FEEDURL)
58    
59    // The $op parameter determines what piece of information is being requested.  Feedster (http://www.feedster.com/myfeedster.php?action=addrss&rssurl= FEEDURL&confirm=no)
60    switch ($op) {  
61      case 'list':  ROJO (http://www.rojo.com/add-subscription?resource= FEEDURL)
62        $blocks[0]['info'] = t('Syndicate2');  
63        return $blocks;  NewsIsFree (http://www.newsisfree.com/user/sub/?url=FEEDURL)
64      case 'configure':  
65            $output =  form_checkboxes('Supported Aggregators', 'syn2_butons', variable_get('syndicate2_string',  $edit['syn2_butons']), $aSupported_Aggregators, $description = NULL, $attributes = NULL, $required = FALSE) ;  
66    
67            return $output;  
68      case 'save':  
69        // If $op is "save", we need to save settings from the configuration form.  */
70        // Since the first block is the only one that allows configuration, we  
71        // need to check $delta to make sure we only save it.  
72        if ($delta == 0) {  
73          // Have Drupal save the string to the database.  
74          variable_set('syndicate2_string', $edit['syn2_butons']);  
75        }  function syndicate2_help($section) {
76            return;  
77      case 'view': default:    switch ($section) {
78        // If $op is "view", then we need to generate the block for display  
79        // purposes. The $delta parameter tells us which block is being requested.      case 'admin/modules#description':
80        switch ($delta) {  
81          case 0:        // This description is shown in the listing at admin/modules.
82            $block['subject'] = t('Read our feed');  
83            // The content of the block is typically generated by calling a custom        return t('Adds Ability to Syndicate to popular aggregators.');
84            // function.  
85            $block['content'] = block_contents(1);    }
86            break;  
87        }  }
88        return $block;  
89    }  
90  }  
91    
92  function block_contents($block){  
93          $sBlock = "<div class=\"xml-icon\">\n";  function syndicate2_block($op = 'list', $delta = 0, $edit = array()) {
94                  //Standard XML Feed  
95          $sBlock .= theme('xml_icon', url('node/feed'))."\n";  $aSupported_Aggregators = array (
96    
97                  //Add to aggregator sites          "MyYahoo" => "My Yahoo!",
98          $aSitesList = variable_get('syndicate2_string', $edit['syn2_butons']);  
99          foreach($aSitesList as $key=>$value) {          "Google" => "Google",
100                  $sBlock .= _get_aggregator_info($value)."\n";  
101          }          "MyMSN" => "My MSN",
102          $sBlock .= "\n</div>";  
103            "Technorati" => "Technorati",
104    
105  return $sBlock;          "Bloglines" => "Bloglines",
106  }  
107            "NewsGator" => "NewsGator",
108    
109  function _get_aggregator_info($site){          "Feedster" => "Feedster",
110  global $base_url;  
111            "ROJO" => "ROJO",
112          $_mod_base = drupal_get_path('module', 'syndicate2');  
113          $FEEDURL =  check_url("$base_url/node/feed");          "NewsIsFree" => "NewsIsFree"
114    
115          switch($site){  );
116                  case "MyYahoo":  
117                          //Yahoo  
118                          $agg_img = "$_mod_base/images/addtomyyahoo.gif";  
119                          $agg_url = "http://add.my.yahoo.com/rss?url=$FEEDURL";    // The $op parameter determines what piece of information is being requested.
120                          $Alt_Tag = "MyYahoo!";  
121                          $Title_Tag = "Add to MyYahoo!";    switch ($op) {
122    
123                          $site_info ="<a href=\"$agg_url\" target=\"_new\">".  _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";      case 'list':
124                  return $site_info;  
125          $blocks[0]['info'] = t('Syndicate2');
126                  case "Google":  
127                          $agg_img = "$_mod_base/images/addgoogle.gif";        return $blocks;
128                          $agg_url = "http://fusion.google.com/add?feedurl=$FEEDURL";  
129                          $Alt_Tag = "Google";      case 'configure':
130                          $Title_Tag = "Add to Google";  
131              $output =  form_checkboxes('Supported Aggregators', 'syn2_butons', variable_get('syndicate2_string',  $edit['syn2_butons']), $aSupported_Aggregators, $description = NULL, $attributes = NULL, $required = FALSE) ;
132                          $site_info ="<a href=\"$agg_url\" target=\"_new\">".  _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";  
133                  return $site_info;  
134    
135                  case "MyMSN":            return $output;
136                          $agg_img = "$_mod_base/images/myMSN.gif";  
137                          $agg_url = "http://my.msn.com/addtomymsn.armx?id=rss&ut=$FEEDURL&ru=$base_url";      case 'save':
138                          $Alt_Tag = "MyMSN";  
139                          $Title_Tag = "Add to MyMSN";        // If $op is "save", we need to save settings from the configuration form.
140    
141                          $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";        // Since the first block is the only one that allows configuration, we
142    
143                  return $site_info;        // need to check $delta to make sure we only save it.
144    
145                  case "Technorati":        if ($delta == 0) {
146                          $agg_img = "$_mod_base/images/technorati.gif";  
147                          $agg_url = "http://technorati.com/faves?add=$FEEDURL";          // Have Drupal save the string to the database.
148                          $Alt_Tag = "Technorati";  
149                          $Title_Tag = "Add to Technorati";          variable_set('syndicate2_string', $edit['syn2_butons']);
150    
151                          $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";        }
152    
153                  return $site_info;            return;
154    
155                  case "Bloglines":      case 'view': default:
156                          $agg_img = "$_mod_base/images/sub_bloglines3.gif";  
157                          $agg_url = "http://www.bloglines.com/sub/$FEEDURL";        // If $op is "view", then we need to generate the block for display
158                          $Alt_Tag = "Bloglines";  
159                          $Title_Tag = "Add to Bloglines";        // purposes. The $delta parameter tells us which block is being requested.
160    
161                          $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";        switch ($delta) {
162    
163                  return $site_info;          case 0:
164    
165                  case "NewsGator":            $block['subject'] = t('Read our feed');
166                          $agg_img = "$_mod_base/images/newsgator.gif";  
167                          $agg_url = "http://www.newsgator.com/ngs/subscriber/subext.aspx?url=$FEEDURL";            // The content of the block is typically generated by calling a custom
168                          $Alt_Tag = "NewsGator";  
169                          $Title_Tag = "Add to NewsGator";            // function.
170    
171                          $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";            $block['content'] = block_contents(1);
172    
173                  return $site_info;            break;
174    
175                  case "Feedster":        }
176                          $agg_img = "$_mod_base/images/addmyfeedster.gif";  
177                          $agg_url = "http://www.feedster.com/myfeedster.php?action=addrss&rssurl=$FEEDURL&confirm=no";        return $block;
178                          $Alt_Tag = "Feedster";  
179                          $Title_Tag = "Add to Feedster";    }
180    
181                          $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";  }
182    
183                  return $site_info;  
184    
185                  case "ROJO":  function block_contents($block){
186                          $agg_img = "$_mod_base/images/RojoWideRed.gif";  
187                          $agg_url = "http://www.rojo.com/add-subscription?resource=$FEEDURL";          $sBlock = "<div class=\"xml-icon\">\n";
188                          $Alt_Tag = "ROJO";  
189                          $Title_Tag = "Add to ROJO";                  //Standard XML Feed
190    
191                          $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";          $sBlock .= theme('xml_icon', url('node/feed'))."\n";
192    
193                  return $site_info;  
194    
195                  case "NewsIsFree":                  //Add to aggregator sites
196                          $agg_img = "$_mod_base/images/addnewsisfree.gif";  
197                          $agg_url = "http://www.newsisfree.com/user/sub/?url=$FEEDURL";          $aSitesList = variable_get('syndicate2_string', $edit['syn2_butons']);
198                          $Alt_Tag = "NewsIsFree";  
199                          $Title_Tag = "Add to NewsIsFree";          foreach($aSitesList as $key=>$value) {
200    
201                          $site_info ="<a href=\"$agg_url\" target=\"_new\">". _create_img_src($agg_img, $Alt_Tag, $Title_Tag)."</a>";                  $sBlock .= _get_aggregator_info($value)."\n";
202    
203                  return $site_info;          }
204    
205          }          $sBlock .= "\n</div>";
206    
207  }  
208    
209  function _create_img_src($img_url, $alt, $title){  
210    
211          if(($title == '') && ($alt == '')){  return $sBlock;
212                  $alt = "Add Feed";  
213                  $title = $alt;  }
214          }  
215          if($title == ''){  
216                  $title = $alt;  
217          }  
218          if ($alt == ''){  
219                  $alt = $title;  function _get_aggregator_info($site){
220          }  
221    global $base_url;
222          $img_src = "<img src=\"$img_url\" alt=\"$alt\" title=\"$title\" border=0 />";  
223    
224  return $img_src;  
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    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.6