first import

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2013-01-09 10:53:26 +01:00
commit b20b38f514
526 changed files with 76993 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* Definition of views_handler_argument_aggregator_category_cid.
*/
/**
* Argument handler to accept an aggregator category id.
*
* @ingroup views_argument_handlers
*/
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();
$result = db_query("SELECT c.title FROM {aggregator_category} c WHERE c.cid IN (:cid)", array(':cid' => $this->value));
foreach ($result as $term) {
$titles[] = check_plain($term->title);
}
return $titles;
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* Definition of views_handler_argument_aggregator_fid.
*/
/**
* Argument handler to accept an aggregator feed id.
*
* @ingroup views_argument_handlers
*/
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();
$result = db_query("SELECT f.title FROM {aggregator_feed} f WHERE f.fid IN (:fids)", array(':fids' => $this->value));
foreach ($result as $term) {
$titles[] = check_plain($term->title);
}
return $titles;
}
}

View File

@@ -0,0 +1,30 @@
<?php
/**
* @file
* Definition of views_handler_argument_aggregator_iid.
*/
/**
* Argument handler to accept an aggregator item id.
*
* @ingroup views_argument_handlers
*/
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_select('aggregator_item')
->condition('iid', $this->value, 'IN')
->fields(array('title'))
->execute();
foreach ($result as $term) {
$titles[] = check_plain($term->title);
}
return $titles;
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* @file
* Definition of views_handler_field_aggregator_category.
*/
/**
* Field handler to provide simple renderer that allows linking to aggregator
* category.
*
* @ingroup views_field_handlers
*/
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, 'bool' => TRUE);
return $options;
}
/**
* Provide link to category option
*/
function 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']),
);
parent::options_form($form, $form_state);
}
/**
* 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) {
$cid = $this->get_value($values, 'cid');
if (!empty($this->options['link_to_category']) && !empty($cid) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "aggregator/category/$cid";
}
return $data;
}
function render($values) {
$value = $this->get_value($values);
return $this->render_link($this->sanitize_value($value), $values);
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* @file
* Definition of views_handler_field_aggregator_title_link.
*/
/**
* Field handler that turns an item's title into a clickable link to the original
* source article.
*
* @ingroup views_field_handlers
*/
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, 'bool' => TRUE);
return $options;
}
/**
* Provide link to the page being visited.
*/
function 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']),
);
parent::options_form($form, $form_state);
}
function render($values) {
$value = $this->get_value($values);
return $this->render_link($this->sanitize_value($value), $values);
}
function render_link($data, $values) {
$link = $this->get_value($values, 'link');
if (!empty($this->options['display_as_link'])) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $link;
$this->options['alter']['html'] = TRUE;
}
return $data;
}
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* @file
* Definition of views_handler_field_aggregator_xss.
*/
/**
* Filters htmls tags from item.
*
* @ingroup views_field_handlers
*/
class views_handler_field_aggregator_xss extends views_handler_field {
function render($values) {
$value = $this->get_value($values);
return aggregator_filter_xss($value);
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* Definition of views_handler_filter_aggregator_category_cid.
*/
/**
* Filter by aggregator category cid
*
* @ingroup views_filter_handlers
*/
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');
foreach ($result as $category) {
$this->value_options[$category->cid] = $category->title;
}
}
}

View File

@@ -0,0 +1,74 @@
<?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 {
var $base_table = 'aggregator_item';
var $base_field = 'iid';
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) {
$iid = $row->{$this->field_alias};
$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 = :iid";
$item = db_query($sql, array(':iid' => $iid))->fetchObject();
$item->elements = array(
array(
'key' => 'pubDate',
'value' => gmdate('r', $item->timestamp),
),
array(
'key' => 'dc:creator',
'value' => $item->author,
),
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(), array(
'view' => $this->view,
'options' => $this->options,
'row' => $item
));
}
}