Projet

Général

Profil

Paste
Télécharger (1,99 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / aggregator / views_plugin_row_aggregator_rss.inc @ 7547bb19

1
<?php
2

    
3
/**
4
 * @file
5
 * Contains the Aggregator Item RSS row style plugin.
6
 */
7

    
8
/**
9
 * Plugin which loads an aggregator item and formats it as an RSS item.
10
 */
11
class views_plugin_row_aggregator_rss extends views_plugin_row {
12
  var $base_table = 'aggregator_item';
13
  var $base_field = 'iid';
14

    
15
  function option_definition() {
16
    $options = parent::option_definition();
17

    
18
    $options['item_length'] = array('default' => 'default');
19

    
20
    return $options;
21
  }
22

    
23
  function options_form(&$form, &$form_state) {
24
    $form['item_length'] = array(
25
      '#type' => 'select',
26
      '#title' => t('Display type'),
27
      '#options' => array(
28
        'fulltext' => t('Full text'),
29
        'teaser' => t('Title plus teaser'),
30
        'title' => t('Title only'),
31
        'default' => t('Use default RSS settings'),
32
      ),
33
      '#default_value' => $this->options['item_length'],
34
    );
35
  }
36

    
37
  function render($row) {
38
    $iid =  $row->{$this->field_alias};
39
    $sql =  "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, ";
40
    $sql .= "ai.timestamp, ai.guid, af.title AS feed_title, ai.link AS feed_LINK ";
41
    $sql .= "FROM {aggregator_item} ai LEFT JOIN {aggregator_feed} af ON ai.fid = af.fid ";
42
    $sql .= "WHERE ai.iid = :iid";
43

    
44
    $item = db_query($sql, array(':iid' => $iid))->fetchObject();
45

    
46
    $item->elements = array(
47
      array(
48
        'key' => 'pubDate',
49
        'value' => gmdate('r', $item->timestamp),
50
      ),
51
      array(
52
        'key' => 'dc:creator',
53
        'value' => $item->author,
54
      ),
55
      array(
56
        'key' => 'guid',
57
        'value' => $item->guid,
58
        'attributes' => array('isPermaLink' => 'false')
59
      ),
60
    );
61

    
62
    foreach ($item->elements as $element) {
63
      if (isset($element['namespace'])) {
64
        $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
65
      }
66
    }
67

    
68
    return theme($this->theme_functions(), array(
69
      'view' => $this->view,
70
      'options' => $this->options,
71
      'row' => $item
72
    ));
73
  }
74
}