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

Diff of /contributions/modules/news_page/news_page.module

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

revision 1.13, Sun Jan 14 03:37:34 2007 UTC revision 1.14, Tue Jul 24 00:54:07 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2    
3  /* $Id: news_page.module,v 1.12 2006/07/01 15:40:24 MegaGrunt Exp $ */  /* $Id: news_page.module,v 1.12.2.2 2007/01/14 03:22:34 MegaGrunt Exp $ */
4    
5    
6  // Implementation of hook_help().  // Implementation of hook_help().
7  function news_page_help($section) {  function news_page_help($section) {
8    switch ($section) {    switch ($section) {
9      case 'admin/modules#description':      case 'node/add#news_page':
10      // This description is shown in the listing at admin/modules.      // This description shows up when users click "create content."
11      return t('Creates a page of keyword filtered news items from an aggregator category.');      return t('Creates a page of keyword filtered news items from an <a href="!aggregator">aggregator</a> category.', array('!aggregator' => url('admin/content/aggregator')) );
12    
13      case 'node/add#news_page':      case 'admin/content/news_page':
14      // This description shows up when users click "create content."      return t('A News Page provides a way to only include items from an <a href="!aggregator">aggregator</a> category which match your keywords. The majority of settings are entered when you create a new news page node.', array('!aggregator' => url('admin/content/aggregator')) );
15      return t('Creates a page of keyword filtered news items from an <a href="%aggregator">aggregator</a> category.', array('%aggregator' => url('admin/aggregator')) );  
16      }
17      case 'admin/settings/news_page':  }
18      return t('A News Page provides a way to only include items from an <a href="%aggregator">aggregator</a> category which match your keywords. The majority of settings are entered when you create a new news_page node.', array('%aggregator' => url('admin/aggregator')) );  
19    // Implementation of hook_node_info().
20    }  function news_page_node_info() {
21  }    return array('news_page' => array(
22        'name' => t('News page'),
23  // Implementation of hook_node_info().      'module' => 'news_page'),
24  function news_page_node_info() {      'description' => 'Enables creation of pages displaying filtered syndicated news items from aggregator categories.'
25    return array('news_page' => array('name' => t('news page'), 'base' => 'news_page') );    );
26  }  }
27    
28    
29  // Implementation of hook_access().  // Implementation of hook_access().
30  function news_page_access($op, $node) {  function news_page_access($op, $node) {
31    global $user;    global $user;
32    
33    switch($op) {    switch($op) {
34      case 'create':      case 'create':
35        return user_access('create news page');        return user_access('create news page');
36        break;        break;
37    
38      case 'view':      case 'view':
39        return user_access('access news page');        return user_access('access news page');
40        break;        break;
41    
42      case 'update':      case 'update':
43      case 'delete':      case 'delete':
44        if (user_access('edit own news page') && ($user->uid == $node->uid)) {        if (user_access('edit own news page') && ($user->uid == $node->uid)) {
45          return TRUE;          return TRUE;
46        }        }
47        break;        break;
48    
49    
50    }    }
51  }  }
52    
53    
54  // Implementation of hook_perm().  // Implementation of hook_perm().
55  function news_page_perm() {  function news_page_perm() {
56    return array('access news page', 'access news page feed', 'create news page', 'edit own news page');    return array('access news page', 'access news page feed', 'create news page', 'edit own news page');
57  }  }
58    
59    
60  // Implementation of hook_link().  // Implementation of hook_link().
61  function news_page_link($type, $node = 0, $main) {  function news_page_link($type, $node = 0, $main) {
62    $links = array();    $links = array();
63    
64    if ($type == 'node' && $node->type == 'news_page') {    if ($type == 'node' && $node->type == 'news_page') {
65      if (news_page_access('update', $node) && !user_access('administer nodes')) {      if (news_page_access('update', $node) && !user_access('administer nodes')) {
66        $links[] = l(t('edit this news page node'), "node/$node->nid/edit");        $links['news_page_edit_page_node'] = array (
67      }          'title' => t('edit this news page node'),
68    }          'href' => 'node/'. $node->nid . '/edit',
69          );
70    return $links;      }
71  }    }
72    
73      return $links;
74  // Implementation of hook_menu().  }
75  function news_page_menu($may_cache) {  
76    $items = array();  
77    // Implementation of hook_menu().
78    if ($may_cache) {  function news_page_menu($may_cache) {
79      $items[] = array('path' => 'node/add/news_page',    $items = array();
80                                'title' => t('news page'),  
81                                'access' => user_access('create news page'));    if ($may_cache) {
82    }      $items[] = array('path' => 'node/add/news_page',
83                                  'title' => t('news page'),
84    if ( is_numeric( arg(2) ) ) {                                'access' => user_access('create news page'));
85      }
86      $account = NULL;  
87      if ( is_numeric( arg(2) ) ) {
88      // Check if an external source wants to read this feed. The url must containe authentication information.  
89      if ( arg(3) && arg(4) ) {      $account = NULL;
90    
91        // Authenticate user      // Check if an external source wants to read this feed. The url must containe authentication information.
92        $account = user_load(array('name' => arg(3), 'pass' => arg(4), 'status' => 1));      if ( arg(3) && arg(4) ) {
93         if ( $account === FALSE ) {  
94              $account = NULL;        // Authenticate user
95          }        $account = user_load(array('name' => arg(3), 'pass' => arg(4), 'status' => 1));
96      }         if ( $account === FALSE ) {
97                $account = NULL;
98      $items[] = array('path' => 'news_page/feed',          }
99                                'title' => t('News page feed'),      }
100                                'callback' => '_news_page_feed',  
101                                'callback arguments' => array('nid' => arg(2)),      $items[] = array('path' => 'news_page/feed',
102                                'access' => user_access('access news page feed', $account),                                'title' => t('News page feed'),
103                                'type' => MENU_CALLBACK);                                'callback' => '_news_page_feed',
104    }                                'callback arguments' => array('nid' => arg(2)),
105                                  'access' => user_access('access news page feed', $account),
106    return $items;                                'type' => MENU_CALLBACK);
107  }    }
108    
109      $items[] = array(
110  // Implementation of hook_form().      'path' => 'admin/content/news_page',
111  function news_page_form(&$node) {      'title' => t('News Page'),
112        'description' => t('News Page settings'),
113    $form['title'] = array(      'callback' => 'drupal_get_form',
114      '#type' => 'textfield',      'callback arguments' => 'news_page_admin_settings',
115      '#title' => t('Title'),      'access' => user_access('administer site configuration'),
116      '#default_value' => $node->title,      'type' => MENU_NORMAL_ITEM,
117      '#required' => TRUE,    );
118    );  
119      return $items;
120  /* CRUFT ??  }
121    $form['validate'] = array(  
122      '#type' => 'hidden',  
123      '#value' => 'validate',  // Implementation of hook_form().
124    );  function news_page_form(&$node) {
125    
126    */    $form['title'] = array(
127        '#type' => 'textfield',
128    $form['body_filter']['body'] = array(      '#title' => t('Title'),
129      '#type' => 'textarea',      '#default_value' => $node->title,
130      '#title' => t('Body'),      '#required' => TRUE,
131      '#default_value' => $node->body,    );
132      '#required' => FALSE,  
133      '#cols' => 60,  /* CRUFT ??
134      '#rows' => 20,    $form['validate'] = array(
135    );      '#type' => 'hidden',
136        '#value' => 'validate',
137    $form['body_filter']['filter'] = filter_form($node->format);    );
138    
139    $results = db_query("SELECT cid, title FROM {aggregator_category}");    */
140    $row_count = db_num_rows($results);  
141      $form['body_filter']['body'] = array(
142    if ($row_count == 0) form_set_error('cid', t('You must create at least 1 aggregator category before creating a news page.'));      '#type' => 'textarea',
143        '#title' => t('Body'),
144    $categories[0] = t('--none--');      '#default_value' => $node->body,
145        '#required' => FALSE,
146    for ($counter = 1; $counter <=  $row_count; $counter++) {      '#cols' => 60,
147      $category= db_fetch_object ($results);      '#rows' => 20,
148      $categories[$category->cid] = $category->title;    );
149    }  
150      $form['body_filter']['filter'] = filter_form($node->format);
151    $form['cid'] = array(  
152      '#type' => 'select',    $results = db_query("SELECT cid, title FROM {aggregator_category}");
153      '#title' => t('Aggregator Category'),    $row_count = db_num_rows($results);
154      '#default_value' => $node->cid,  
155      '#options' => $categories,    if ($row_count == 0) form_set_error('cid', t('You must create at least 1 aggregator category before creating a news page.'));
156      '#description' => t('Category to include on this page'),  
157      '#extra' => '',    $categories[0] = t('--none--');
158      '#multiple' => '',  
159      '#required' => TRUE,    for ($counter = 1; $counter <=  $row_count; $counter++) {
160    );      $category= db_fetch_object ($results);
161        $categories[$category->cid] = $category->title;
162    $form['include'] = array(    }
163      '#type' => 'textfield',  
164      '#title' => t('Include Words'),    $form['cid'] = array(
165      '#default_value' => $node->include,      '#type' => 'select',
166      '#size' => 60,      '#title' => t('Aggregator Category'),
167      '#maxlength' => 128,      '#default_value' => $node->cid,
168      '#description' => t('Keywords that must be included in a news item for it to be displayed - e.g. "butter,jam,eggs"'),      '#options' => $categories,
169      '#attributes' => '',      '#description' => t('Category to include on this page'),
170      '#required' => TRUE,      '#extra' => '',
171    );      '#multiple' => '',
172        '#required' => TRUE,
173    $form['max_items'] = array(    );
174      '#type' => 'textfield',  
175      '#title' => t('Maximum Items'),    $form['include'] = array(
176      '#default_value' => is_numeric($node->max_items) ? $node->max_items : 25,      '#type' => 'textfield',
177      '#size' => 5,      '#title' => t('Include Words'),
178      '#maxlength' => 5,      '#default_value' => $node->include,
179      '#description' => t('Maximum number of news items to include on a page'),      '#size' => 60,
180      '#attributes' => '',      '#maxlength' => 128,
181      '#required' => TRUE,      '#description' => t('Keywords that must be included in a news item for it to be displayed - e.g. "iPhone, +battery, -problem"'),
182    );      '#attributes' => '',
183        '#required' => TRUE,
184    return $form;    );
185  }  
186      $form['max_items'] = array(
187        '#type' => 'textfield',
188  // Implementation of hook_validate().      '#title' => t('Maximum Items'),
189  function news_page_validate(&$node) {      '#default_value' => is_numeric($node->max_items) ? $node->max_items : 25,
190        '#size' => 5,
191      if ($node->validate) {      '#maxlength' => 5,
192        '#description' => t('Maximum number of news items to include on a page'),
193          if (is_numeric($node->cid) == FALSE OR $node->cid == 0) {      '#attributes' => '',
194            form_set_error('cid', t('Please select an aggregator category.'));      '#required' => TRUE,
195          }    );
196    
197          if (!$node->include) {    return $form;
198            form_set_error('include', t('Please add at least one word to the list of include words.'));  }
199          }  
200    
201          if (is_numeric($node->max_items) == FALSE OR $node->max_items == 0) {  // Implementation of hook_validate().
202            $node->max_items = 25;  function news_page_validate(&$node) {
203            form_set_error('max_items', t('Maximum items must have a value, field has been reset to the default (25).'));  
204          }      if ($node->validate) {
205    
206      }          if (is_numeric($node->cid) == FALSE OR $node->cid == 0) {
207              form_set_error('cid', t('Please select an aggregator category.'));
208    return;          }
209  }  
210            if (!$node->include) {
211  function news_page_settings() {            form_set_error('include', t('Please add at least one word to the list of include words.'));
212            }
213    $form['RSS'] = array(  
214      '#type' => 'fieldset',          if (is_numeric($node->max_items) == FALSE OR $node->max_items == 0) {
215      '#title' => t('RSS Feed'),            $node->max_items = 25;
216      '#description' => t('Users must have the "access news page feeds" <a href="%permission">permission</a> granted in order to use the News Page RSS feeds.', array('%permission' => url('admin/user/configure/permission')) ),            form_set_error('max_items', t('Maximum items must have a value, field has been reset to the default (25).'));
217    );          }
218    
219    $form['RSS']['news_page_link_prepend'] = array(      }
220      '#type' => 'textfield',  
221      '#title' => t('RSS Link prepend'),    return;
222      '#default_value' => check_url( variable_get('news_page_link_prepend', '') ),  }
223      '#size' => 80,  
224      '#maxlength' => 255,  function news_page_admin_settings() {
225      '#description' => t('All item links generated will have this URL prepended to them. For example: "/jump.php?url=". If unsure, specify nothing. Note: the url is relative to the base url of this drupal site, the page cannot reside on a remote host.'),  
226    );    $form['RSS'] = array(
227        '#type' => 'fieldset',
228    $form['RSS']['news_page_channel_description'] = array(      '#title' => t('RSS Feed'),
229      '#type' => 'textarea',      '#description' => t('Users must have the "access news page feeds" <a href="!permission">permission</a> granted in order to use the News Page RSS feeds.', array('!permission' => url('admin/user/access')) ),
230      '#title' => t('Global channel description'),    );
231      '#default_value' => filter_xss_admin( variable_get('news_page_channel_description', '') ),  
232      '#cols' => 60,    $form['RSS']['news_page_link_prepend'] = array(
233      '#rows' => 4,      '#type' => 'textfield',
234      '#description' => t('This text will precede the News Page nodes body text for the feed description, for every News page feed. If no body text is set the global settings <a href="%mission">mission statement</a> is used; if this is empty - nothing will be displayed.', array('%mission' => url('admin/settings')) ),      '#title' => t('RSS Link prepend'),
235      '#attributes' => '',      '#default_value' => check_url( variable_get('news_page_link_prepend', '') ),
236      '#required' => FALSE,      '#size' => 80,
237    );      '#maxlength' => 255,
238        '#description' => t('All item links generated will have this URL prepended to them. For example: "/jump.php?url=". If unsure, specify nothing. Note: the url is relative to the base url of this drupal site, the page cannot reside on a remote host.'),
239    return $form;    );
240  }  
241      $form['RSS']['news_page_channel_description'] = array(
242        '#type' => 'textarea',
243  function _news_page_feed($nid) {      '#title' => t('Global channel description'),
244    global $base_url, $locale;      '#default_value' => filter_xss_admin( variable_get('news_page_channel_description', '') ),
245        '#cols' => 60,
246    // get node      '#rows' => 4,
247    $node = node_load($nid);      '#description' => t('This text will precede the News Page nodes body text for the feed description, for every News page feed. If no body text is set the global settings <a href="!mission">mission statement</a> is used; if this is empty - nothing will be displayed.', array('!mission' => url('admin/settings/site-information')) ),
248        '#attributes' => '',
249    // Define RSS channel header      '#required' => FALSE,
250    $channel = array(    );
251      'version'     => '0.92',  
252      'title'       => check_plain($node->title) . ' | ' . check_plain( variable_get('site_name', 'drupal') ) .' - '. check_plain( variable_get('site_slogan', '') ),    return system_settings_form($form);
253      'description' => $node->body ? variable_get('news_page_channel_description', '') . check_markup($node->body, $node->format, FALSE) : check_plain( variable_get('site_mission', '') ),  }
254      'link'        => $base_url,  
255      'language'    => $locale  
256    );  
257    function _news_page_feed($nid) {
258    // --- Collect items associated with this node    global $base_url, $locale;
259    $nodes = news_page_items($node);  
260      // get node
261    $link_prepend = variable_get('news_page_link_prepend', '') ? $base_url . variable_get('news_page_link_prepend', '') : '';    $node = node_load($nid);
262    
263    while ($item = db_fetch_object($nodes)) {    // Define RSS channel header
264      $channel = array(
265      $link = url( $link_prepend . $item->link, NULL, NULL, FALSE);      'version'     => '0.92',
266      $items .= format_rss_item($item->title, $link, $item->description, array('pubDate' => date('r', $item->timestamp)));      'title'       => check_plain($node->title) . ' | ' . check_plain( variable_get('site_name', 'drupal') ) .' - '. check_plain( variable_get('site_slogan', '') ),
267        'description' => $node->body ? variable_get('news_page_channel_description', '') . check_markup($node->body, $node->format, FALSE) : check_plain( variable_get('site_mission', '') ),
268   }      'link'        => $base_url,
269        'language'    => $locale
270    // Output RSS feed    );
271    theme('news_page_rss', $channel, $base_url, $items);  
272      // --- Collect items associated with this node
273    return;    $nodes = news_page_items($node);
274  }  
275      $link_prepend = variable_get('news_page_link_prepend', '') ? $base_url . variable_get('news_page_link_prepend', '') : '';
276    
277  // Implementation of hook_insert().    while ($item = db_fetch_object($nodes)) {
278  function news_page_insert($node) {  
279    $search = news_page_search_criteria($node->include, $node->cid);      $link = url( $link_prepend . $item->link, NULL, NULL, FALSE);
280    db_query("INSERT INTO {news_page} (nid, include, search, cid, max_items) VALUES (%d, '%s', '%s', %d, %d)", $node->nid, $node->include, $search, $node->cid, $node->max_items);      $items .= format_rss_item($item->title, $link, $item->description, array('pubDate' => date('r', $item->timestamp)));
281  }  
282     }
283    
284  // Implementation of hook_update().    // Output RSS feed
285  function news_page_update($node) {    theme('news_page_rss', $channel, $base_url, $items);
286    $search = news_page_search_criteria($node->include, $node->cid);  
287    db_query("UPDATE {news_page} SET include = '%s', search = '%s', cid = %d, max_items = %d WHERE nid = %d", $node->include, $search, $node->cid, $node->max_items, $node->nid);    return;
288  }  }
289    
290  // Implementation of hook_delete().  
291    // Implementation of hook_insert().
292  function news_page_delete($node) {  function news_page_insert($node) {
293    db_query('DELETE FROM {news_page} WHERE nid = %d', $node->nid);    $search = news_page_search_criteria($node->include, $node->cid);
294  }    db_query("INSERT INTO {news_page} (nid, include, search, cid, max_items) VALUES (%d, '%s', '%s', %d, %d)", $node->nid, $node->include, $search, $node->cid, $node->max_items);
295    }
296  // Implementation of hook_load().  
297  function news_page_load($node) {  
298    $additions = db_fetch_object(db_query('SELECT include, search, cid, max_items FROM {news_page} WHERE nid = %d', $node->nid));  // Implementation of hook_update().
299    return $additions;  function news_page_update($node) {
300  }    $search = news_page_search_criteria($node->include, $node->cid);
301      db_query("UPDATE {news_page} SET include = '%s', search = '%s', cid = %d, max_items = %d WHERE nid = %d", $node->include, $search, $node->cid, $node->max_items, $node->nid);
302    }
303  function news_page_items(&$node) {  
304    // Implementation of hook_delete().
305    if (isset($node->max_items) == FALSE OR $node->max_items == 0) $node->max_items = 25;  
306    function news_page_delete($node) {
307    if ($node->include && $node->cid) {    db_query('DELETE FROM {news_page} WHERE nid = %d', $node->nid);
308      $search = ($node->search) ? $node->search : news_page_search_criteria($node->include, $node->cid);  }
309      $result = db_query_range($search, 0, $node->max_items);  
310    }  // Implementation of hook_load().
311    function news_page_load($node) {
312    return $result;    $additions = db_fetch_object(db_query('SELECT include, search, cid, max_items FROM {news_page} WHERE nid = %d', $node->nid));
313  }    return $additions;
314    }
315    
316  // Implementation of hook_view().  
317  function news_page_view(&$node, $teaser = FALSE, $page = FALSE) {  function news_page_items(&$node) {
318    global $user;  
319      if (isset($node->max_items) == FALSE OR $node->max_items == 0) $node->max_items = 25;
320    $blog_support = module_exist('blog') && user_access('edit own blog');  
321      if ($node->include && $node->cid) {
322    $items = '';      $search = ($node->search) ? $node->search : news_page_search_criteria($node->include, $node->cid);
323    $result = news_page_items($node);      $result = db_query_range($search, 0, $node->max_items);
324      }
325    while ($item = db_fetch_object($result)) {  
326            $items .= theme('news_page_item', $item, $blog_support);    return $result;
327    }  }
328    
329    $news = theme('news_page_feed', $items);  
330    // Implementation of hook_view().
331    // Add RSS feed link if user has correct permission  function news_page_view(&$node, $teaser = FALSE, $page = FALSE) {
332    if (user_access('access news page feed')) {    global $user;
333    
334      // $authenticated =  '/' . $user->name . '/' . $user->pass;    $blog_support = module_exists('blog') && user_access('edit own blog');
335      //$feed_url = url('news_page/feed/' . $node->nid . $authenticated);  
336      $items = '';
337      $feed_url = url('news_page/feed/' . $node->nid);    $result = news_page_items($node);
338      $news .= theme('xml_icon', $feed_url);  
339      drupal_set_html_head("\n".'<link rel="alternate" type="application/rss+xml" title="' . check_plain($node->title) . '" href="' . $feed_url . '" />');    while ($item = db_fetch_object($result)) {
340    }            $items .= theme('news_page_item', $item, $blog_support);
341      }
342    $node = node_prepare($node, $teaser);    // Add RSS feed link if user has correct permission
343    $node->body .= $news;    if (user_access('access news page feed')) {
344    return;      // $authenticated =  '/' . $user->name . '/' . $user->pass;
345  }      //$feed_url = url('news_page/feed/' . $node->nid . $authenticated);
346        drupal_set_html_head("\n".'<link rel="alternate" type="application/rss+xml" title="' . check_plain($node->title) . '" href="' . $feed_url . '" />');
347  function news_page_search_criteria($keywords, $cid) {    }
348    
349      $words = explode(",", $keywords);    $node = node_prepare($node, $teaser);
350      $node->content['news_page_feed'] = array(
351      foreach ($words as $word) {      '#value' => theme('news_page_feed', $items),
352        $word = trim($word);      '#weight' => 0,
353        if (preg_match("/^-/", $word)) {    );
354        $word = preg_replace('/^-/','', $word);    $node->content['feed_icon'] = array(
355        $not_title_filter[] = "lower(i.title) NOT LIKE '%%" . $word . "%%'";      '#value' => theme('xml_icon', url('news_page/feed/' . $node->nid)),
356        $not_content_filter[] = "lower(i.description) NOT LIKE '%%" . $word . "%%'";      '#weight' => 1,
357        $not_filter_query = implode(" AND ", $not_title_filter) . ' AND ' . implode(" AND ", $not_content_filter);    );
358        } elseif (preg_match("/^\+/", $word)) {    return $node;
359        $word = preg_replace('/^\+/','', $word);  }
360        $and_title_filter[] = "lower(i.title) LIKE '%%" . $word . "%%'";  
361        $and_content_filter[] = "lower(i.description) LIKE '%%" . $word . "%%'";  function news_page_search_criteria($keywords, $cid) {
362        $and_filter_query = implode(" AND ", $and_title_filter) . ' OR ' . implode(" AND ", $and_content_filter);  
363        } else {      $words = explode(",", $keywords);
364        $title_filter[] = "lower(i.title) LIKE '%%" . $word . "%%'";  
365        $content_filter[] = "lower(i.description) LIKE '%%" . $word . "%%'";      foreach ($words as $word) {
366        $filter_query = implode(" OR ", $title_filter) . ' OR ' . implode(" OR ", $content_filter);        $word = trim($word);
367        }        if (preg_match("/^-/", $word)) {
368      }        $word = preg_replace('/^-/','', $word);
369      $news_queries = array($not_filter_query, $and_filter_query, $filter_query);        $not_title_filter[] = "lower(i.title) NOT LIKE '%%" . $word . "%%'";
370      $i = 0;        $not_content_filter[] = "lower(i.description) NOT LIKE '%%" . $word . "%%'";
371      foreach ($news_queries as $query) {        $not_filter_query = implode(" AND ", $not_title_filter) . ' AND ' . implode(" AND ", $not_content_filter);
372        if ($i>0 && drupal_strlen($query) > 0) {        } elseif (preg_match("/^\+/", $word)) {
373          $news_query .= "AND " ;        $word = preg_replace('/^\+/','', $word);
374        }        $and_title_filter[] = "lower(i.title) LIKE '%%" . $word . "%%'";
375        if (drupal_strlen($query)) {        $and_content_filter[] = "lower(i.description) LIKE '%%" . $word . "%%'";
376        $news_query .= "(". $query .")";        $and_filter_query = implode(" AND ", $and_title_filter) . ' OR ' . implode(" AND ", $and_content_filter);
377        $i++;        } else {
378        }        $title_filter[] = "lower(i.title) LIKE '%%" . $word . "%%'";
379      }        $content_filter[] = "lower(i.description) LIKE '%%" . $word . "%%'";
380          $filter_query = implode(" OR ", $title_filter) . ' OR ' . implode(" OR ", $content_filter);
381      $filter_query =        }
382      "SELECT i.*, f.link AS flink, f.title AS ftitle      }
383      FROM {aggregator_item} i      $news_queries = array($not_filter_query, $and_filter_query, $filter_query);
384      LEFT JOIN {aggregator_feed} f      $i = 0;
385      ON i.fid = f.fid      foreach ($news_queries as $query) {
386      LEFT JOIN {aggregator_category_feed} c        if ($i>0 && drupal_strlen($query) > 0) {
387      ON c.fid = f.fid          $news_query .= "AND " ;
388      WHERE c.cid = '$cid'        }
389      AND ( $news_query )        if (drupal_strlen($query)) {
390      ORDER BY timestamp DESC";        $news_query .= "(". $query .")";
391          $i++;
392      return $filter_query;        }
393  }      }
394    
395  // A custom theme function.      $filter_query =
396  function theme_news_page_feed($items) {      "SELECT i.*, f.link AS flink, f.title AS ftitle
397        FROM {aggregator_item} i
398    $output = '<div id="news-page">' . $items . '</div>';      LEFT JOIN {aggregator_feed} f
399    return $output;      ON i.fid = f.fid
400  }      LEFT JOIN {aggregator_category_feed} c
401        ON c.fid = f.fid
402  function theme_news_page_item($item, $blogit) {      WHERE c.cid = '$cid'
403        AND ( $news_query )
404          $output .= '<div class="feed-item">';      ORDER BY timestamp DESC";
405    
406          if ($item->title) {      return $filter_query;
407            $output .= '<h3 class="feed-item-title">' . check_plain($item->title) . '</h3>';  }
408          }  
409    // A custom theme function.
410          $output .= '<p>';  function theme_news_page_feed($items) {
411    
412          if ($item->description) {    $output = '<div id="news-page">' . $items . '</div>';
413            $output .= '<span class="feed-item-body">' . aggregator_filter_xss($item->description) . '</span>';    return $output;
414          }  }
415    
416          if ($blogit) {  function theme_news_page_item($item, $blogit) {
417            $blog_icon = '<a href="' . url('node/add/blog', "iid=$item->iid") . '"><img src="/misc/blog.png" alt="' . t('Blog this') . '" title="' . t('blog it') . '" class="blog-it"/></a>' ;  
418          }          $output .= '<div class="feed-item">';
419    
420          $output .= '<br /><span class="feed-item-link"><a href="' . check_url($item->link) . '">' .t('Read more') . '</a></span> <span class="feed-item-source">[<a href="' . check_url($item->flink) . '">' . check_plain($item->ftitle) . '</a>] ' . $blog_icon . '</span>';          if ($item->title) {
421              $output .= '<h3 class="feed-item-title">' . check_plain($item->title) . '</h3>';
422          $output .= '</p>';          }
423          $output .= '</div>';  
424            $output .= '<p>';
425    return $output;  
426  }          if ($item->description) {
427              $output .= '<span class="feed-item-body">' . aggregator_filter_xss($item->description) . '</span>';
428  function theme_news_page_rss($channel, $base_url, $items) {          }
429    
430      // Output RSS feed          if ($blogit) {
431      $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";            $blog_icon = '<a href="' . url('node/add/blog', "iid=$item->iid") . '"><img src="'. base_path() .'/misc/blog.png" alt="'. t('Blog this') . '" title="' . t('blog it') . '" class="blog-it"/></a>' ;
432      $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";          }
433      $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\">\n";  
434      $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);          $output .= '<br /><span class="feed-item-link"><a href="' . check_url($item->link) . '">' .t('Read more') . '</a></span> <span class="feed-item-source">[<a href="' . check_url($item->flink) . '">' . check_plain($item->ftitle) . '</a>] ' . $blog_icon . '</span>';
435      $output .= "</rss>\n";  
436            $output .= '</p>';
437      drupal_set_header('Content-Type: text/xml; charset=utf-8');          $output .= '</div>';
438      print $output;  
439  }    return $output;
440  ?>  }
441    
442    function theme_news_page_rss($channel, $base_url, $items) {
443    
444        // Output RSS feed
445        $output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
446        $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
447        $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\">\n";
448        $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
449        $output .= "</rss>\n";
450    
451        drupal_set_header('Content-Type: text/xml; charset=utf-8');
452        print $output;
453    }
454    ?>

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.2