New module 'Views'
This commit is contained in:
parent
31c0889471
commit
740f7d7f30
353 changed files with 44217 additions and 0 deletions
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Argument handler to accept an aggregator category id.
|
||||
*/
|
||||
class views_handler_argument_aggregator_category_cid extends views_handler_argument_numeric {
|
||||
/**
|
||||
* Override the behavior of title(). Get the title of the category.
|
||||
*/
|
||||
function title_query() {
|
||||
$titles = array();
|
||||
$placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
|
||||
|
||||
$result = db_query("SELECT c.title FROM {aggregator_category} c WHERE c.cid IN ($placeholders)", $this->value);
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$titles[] = check_plain($term->title);
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Argument handler to accept an aggregator feed id.
|
||||
*/
|
||||
class views_handler_argument_aggregator_fid extends views_handler_argument_numeric {
|
||||
/**
|
||||
* Override the behavior of title(). Get the title of the feed.
|
||||
*/
|
||||
function title_query() {
|
||||
$titles = array();
|
||||
$placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
|
||||
|
||||
$result = db_query("SELECT f.title FROM {aggregator_feed} f WHERE f.fid IN ($placeholders)", $this->value);
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$titles[] = check_plain($term->title);
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Argument handler to accept an aggregator item id.
|
||||
*/
|
||||
class views_handler_argument_aggregator_iid extends views_handler_argument_numeric {
|
||||
/**
|
||||
* Override the behavior of title(). Get the title of the category.
|
||||
*/
|
||||
function title_query() {
|
||||
$titles = array();
|
||||
$placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
|
||||
|
||||
$result = db_query("SELECT i.title FROM {aggregator_item} i WHERE i.iid IN ($placeholders)", $this->value);
|
||||
while ($term = db_fetch_object($result)) {
|
||||
$titles[] = check_plain($term->title);
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Field handler to provide simple renderer that allows linking to aggregator
|
||||
* category.
|
||||
*/
|
||||
class views_handler_field_aggregator_category extends views_handler_field {
|
||||
/**
|
||||
* Constructor to provide additional field to add.
|
||||
*/
|
||||
function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['cid'] = 'cid';
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['link_to_category'] = array('default' => FALSE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide link to category option
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['link_to_category'] = array(
|
||||
'#title' => t('Link this field to its aggregator category page'),
|
||||
'#description' => t('This will override any other link you have set.'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => !empty($this->options['link_to_category']),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render whatever the data is as a link to the category.
|
||||
*
|
||||
* Data should be made XSS safe prior to calling this function.
|
||||
*/
|
||||
function render_link($data, $values) {
|
||||
if (!empty($this->options['link_to_category']) && !empty($values->{$this->aliases['cid']}) && $data !== NULL && $data !== '') {
|
||||
$cid = $values->{$this->aliases['cid']};
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
$this->options['alter']['path'] = "aggregator/category/$cid";
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
return $this->render_link(check_plain($values->{$this->field_alias}), $values);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Field handler that turns an item's title into a clickable link to the original
|
||||
* source article.
|
||||
*/
|
||||
class views_handler_field_aggregator_title_link extends views_handler_field {
|
||||
function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['link'] = 'link';
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['display_as_link'] = array('default' => TRUE);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide link to the page being visited.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['display_as_link'] = array(
|
||||
'#title' => t('Display as link'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => !empty($this->options['display_as_link']),
|
||||
);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
$link = $values->{$this->table_alias . '_link'};
|
||||
if (!empty($this->options['display_as_link'])) {
|
||||
return l(check_plain($value), $link, array('html' => TRUE));
|
||||
}
|
||||
else {
|
||||
return check_plain($value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Filters htmls tags from item.
|
||||
*/
|
||||
|
||||
class views_handler_field_aggregator_xss extends views_handler_field {
|
||||
function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
return aggregator_filter_xss($value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Filter by aggregator category cid
|
||||
*/
|
||||
class views_handler_filter_aggregator_category_cid extends views_handler_filter_in_operator {
|
||||
function get_value_options() {
|
||||
if (isset($this->value_options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->value_options = array();
|
||||
|
||||
$result = db_query('SELECT * FROM {aggregator_category} ORDER BY title');
|
||||
while ($category = db_fetch_object($result)) {
|
||||
$this->value_options[$category->cid] = $category->title;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains the Aggregator Item RSS row style plugin.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin which loads an aggregator item and formats it as an RSS item.
|
||||
*/
|
||||
class views_plugin_row_aggregator_rss extends views_plugin_row {
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['item_length'] = array('default' => 'default');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
$form['item_length'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Display type'),
|
||||
'#options' => array(
|
||||
'fulltext' => t('Full text'),
|
||||
'teaser' => t('Title plus teaser'),
|
||||
'title' => t('Title only'),
|
||||
'default' => t('Use default RSS settings'),
|
||||
),
|
||||
'#default_value' => $this->options['item_length'],
|
||||
);
|
||||
}
|
||||
|
||||
function render($row) {
|
||||
$sql = "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, ";
|
||||
$sql .= "ai.timestamp, ai.guid, af.title AS feed_title, ai.link AS feed_LINK ";
|
||||
$sql .= "FROM {aggregator_item} ai LEFT JOIN {aggregator_feed} af ON ai.fid = af.fid ";
|
||||
$sql .= "WHERE ai.iid = %d";
|
||||
|
||||
$item = db_fetch_object(db_query($sql, $row->iid));
|
||||
|
||||
$item->elements = array(
|
||||
array('key' => 'pubDate', 'value' => gmdate('r', $item->timestamp)),
|
||||
array(
|
||||
'key' => 'dc:creator',
|
||||
'value' => $item->author,
|
||||
'namespace' => array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/'),
|
||||
),
|
||||
array(
|
||||
'key' => 'guid',
|
||||
'value' => $item->guid,
|
||||
'attributes' => array('isPermaLink' => 'false')
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($item->elements as $element) {
|
||||
if (isset($element['namespace'])) {
|
||||
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
|
||||
}
|
||||
}
|
||||
|
||||
return theme($this->theme_functions(), $this->view, $this->options, $item);
|
||||
}
|
||||
}
|
||||
|
Reference in a new issue