/[drupal]/contributions/modules/syndication/syndication.module
ViewVC logotype

Diff of /contributions/modules/syndication/syndication.module

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

revision 1.58.2.12, Tue May 19 01:08:58 2009 UTC revision 1.58.2.13, Mon Jul 6 08:11:34 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: syndication.module,v 1.58.2.11 2009/04/17 10:21:07 aaron1234nz Exp $  // $Id: syndication.module,v 1.58.2.12 2009/05/19 01:08:58 aaron1234nz Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 26  function syndication_menu() { Line 26  function syndication_menu() {
26      'page arguments' => array('syndication_admin_settings'),      'page arguments' => array('syndication_admin_settings'),
27    );    );
28    $items['syndication/builder'] = array(    $items['syndication/builder'] = array(
29      'title' => 'RSS feed builder',      'title' => 'RSS feed builder for taxonomy',
30      'access arguments' => array('access content'),      'access arguments' => array('access content'),
31      'page callback' => 'drupal_get_form',      'page callback' => 'drupal_get_form',
32      'page arguments' => array('syndication_taxonomy_builder'),      'page arguments' => array('syndication_taxonomy_builder'),
33    );    );
34      $items['syndication/blogbuilder'] = array(
35        'title' => 'RSS feed builder for blogs',
36        'access arguments' => array('access content'),
37        'page callback' => 'drupal_get_form',
38        'page arguments' => array('syndication_blog_builder'),
39      );
40    $items['syndication/all'] = array(    $items['syndication/all'] = array(
41      'title' => 'All feeds',      'title' => 'All feeds',
42      'access arguments' => array('access content'),      'access arguments' => array('access content'),
43      'page callback' => 'syndication_taxonomy_all_feeds',      'page callback' => 'syndication_taxonomy_all_feeds',
44      'type' => MENU_CALLBACK      'type' => MENU_CALLBACK
45    );    );
46      $items['syndication/blogs/%'] = array(
47        'title' => 'Combined blog feeds',
48        'access arguments' => array('access content'),
49        'page callback' => 'syndication_blog_feed_user',
50        'page arguments' => array(2),
51        'type' => MENU_CALLBACK
52      );
53    return $items;    return $items;
54  }  }
55    
# Line 165  function syndication_blogs() { Line 178  function syndication_blogs() {
178    }    }
179    
180    $output .= drupal_get_form('syndication_users');    $output .= drupal_get_form('syndication_users');
181      $output .= l('Combine blogs', 'syndication/blogbuilder');
182    
183    if ($name = $_POST['name']) {    if ($name = $_POST['name']) {
184      $result = db_query("SELECT uid, name FROM {users} WHERE uid > 0 and name LIKE '%%%s%%' ORDER BY access DESC", $name);      $result = db_query("SELECT uid, name FROM {users} WHERE uid > 0 and name LIKE '%%%s%%' ORDER BY access DESC", $name);
# Line 325  function syndication_taxonomy_builder_su Line 339  function syndication_taxonomy_builder_su
339    }    }
340  }  }
341    
342    
343    /**
344     * Menu callback for syndication_blog_builder.
345     */
346    function syndication_blog_builder() {
347      $form['intro'] = array(
348        '#type' => 'markup',
349        '#value' => t('You can subscribe to more than one blog in a single RSS feed.  Please select the blogs you would like to subscribe to then press the "Generate feed" button.'),
350      );
351    
352      $result = db_query_range("SELECT DISTINCT(u.uid), u.name FROM {users} u INNER JOIN {node} n ON u.uid = n.uid WHERE n.type = 'blog' AND n.status = 1", 0, 16);
353      while ($account = db_fetch_object($result)) {
354        $authors[$account->uid] = $account->name;
355      }
356    
357      if ($authors) {
358        $form['blogs'] = array(
359          '#type' => 'checkboxes',
360          '#options' => $authors,
361          '#columns' => variable_get('syndication_columns', 3),
362          '#theme' => 'syndication_taxonomy_builder_columns_checkboxes',
363        );
364    
365        $form['submit'] = array(
366          '#type' => 'submit',
367          '#value' => t('Generate feed'),
368        );
369      }
370      return $form;
371    }
372    
373    /**
374     * Implementation of hook_submit
375     */
376    function syndication_blog_builder_submit($form, &$form_state) {
377      foreach ($form_state['values']['blogs'] as $uid) {
378        if ($uid > 0) {
379          $feed[] = $uid;
380        }
381      }
382      if (!empty($feed)) {
383        drupal_goto("syndication/blogs/". implode("+", $feed));
384      }
385    }
386    
387  /**  /**
388   * Build a fresh feed containing all enabled terms   * Build a fresh feed containing all enabled terms
389   */   */
# Line 358  function syndication_users_validate($for Line 417  function syndication_users_validate($for
417  }  }
418    
419  /**  /**
420     * Displays an RSS feed containing recent blog entries of a given set of users.
421     * @param $user_id_string, string of user_ids seperated by a "+"
422     */
423    function syndication_blog_feed_user($user_id_string) {
424      $user_ids = explode(' ', $user_id_string);
425      foreach ($user_ids as $uid) {
426        if (is_numeric($uid)) {
427          $user = user_load(array('uid' => $uid));
428          $uids[] = $uid;
429          $names[] = $user->name;
430        }
431      }
432    
433      $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid IN (%s) AND n.status = 1 ORDER BY n.created DESC"), implode(',', $uids) , 0, variable_get('feed_default_items', 10));
434      $channel['title'] = implode("'s blog, ", $names) ."'s blog";
435      $channel['link'] = url('syndication/blogs/'. implode('+', $uids), array('absolute' => TRUE));
436    
437      $items = array();
438      while ($row = db_fetch_object($result)) {
439        $items[] = $row->nid;
440      }
441      node_feed($items, $channel);
442    }
443    
444    /**
445   * Generates a link to aggregator.module OPML file.   * Generates a link to aggregator.module OPML file.
446   */   */
447  function syndication_opml() {  function syndication_opml() {
# Line 636  function theme_syndication_taxonomy_buil Line 720  function theme_syndication_taxonomy_buil
720   * @return HTML   * @return HTML
721   */   */
722  function theme_syndication_columns($data = array()) {  function theme_syndication_columns($data = array()) {
723    $cols = count($data);    $cols = count($data) + 1;
724    $width = (int)((100/$cols) - 1); // make this a fraction smaller so the percentages won't add up to more than 100%    $width = (int)((100/$cols) - 1); // make this a fraction smaller so the percentages won't add up to more than 100%
725    foreach ($data as $col) {    foreach ($data as $col) {
726      $output .= "<div class='syndication-column' style='width:$width%'>";      $output .= "<div class='syndication-column' style='width:$width%'>";

Legend:
Removed from v.1.58.2.12  
changed lines
  Added in v.1.58.2.13

  ViewVC Help
Powered by ViewVC 1.1.2