Commit be280193 authored by dawehner's avatar dawehner Committed by tim.plunkett

moved aggregator,book,comment

parent 684b4a03
......@@ -5,14 +5,23 @@
* Definition of views_handler_argument_aggregator_category_cid.
*/
namespace Drupal\aggregator\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept an aggregator category id.
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_aggregator_category_cid extends Numeric {
/**
* @Plugin(
* plugin_id = "aggregator_category_cid"
* )
*/
class CategoryCid extends Numeric {
/**
* Override the behavior of title(). Get the title of the category.
*/
......
......@@ -5,14 +5,23 @@
* Definition of views_handler_argument_aggregator_fid.
*/
namespace Drupal\aggregator\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept an aggregator feed id.
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_aggregator_fid extends Numeric {
/**
* @Plugin(
* plugin_id = "aggregator_fid"
* )
*/
class Fid extends Numeric {
/**
* Override the behavior of title(). Get the title of the feed.
*/
......
......@@ -5,13 +5,22 @@
* Definition of views_handler_argument_aggregator_iid.
*/
namespace Drupal\aggregator\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept an aggregator item id.
*
* @ingroup views_argument_handlers
*/
/**
* @Plugin(
* plugin_id = "aggregator_iid"
* )
*/
class views_handler_argument_aggregator_iid extends Numeric {
/**
* Override the behavior of title(). Get the title of the category.
......
<?php
/**
* @file
* Definition of views_handler_argument_aggregator_iid.
*/
use Drupal\views\Plugins\views\argument\Numeric;
/**
* Argument handler to accept an aggregator item id.
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_aggregator_iid extends 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;
}
}
......@@ -5,7 +5,10 @@
* Definition of views_handler_field_aggregator_category.
*/
namespace Drupal\aggregator\Plugin\views\field;
use Drupal\views\Plugins\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to provide simple renderer that allows linking to aggregator
......@@ -13,7 +16,13 @@
*
* @ingroup views_field_handlers
*/
class views_handler_field_aggregator_category extends FieldPluginBase {
/**
* @Plugin(
* plugin_id = "aggregator_category"
* )
*/
class Category extends FieldPluginBase {
/**
* Constructor to provide additional field to add.
*/
......
......@@ -5,7 +5,10 @@
* Definition of views_handler_field_aggregator_title_link.
*/
namespace Drupal\aggregator\Plugin\views\field;
use Drupal\views\Plugins\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler that turns an item's title into a clickable link to the original
......@@ -13,7 +16,13 @@
*
* @ingroup views_field_handlers
*/
class views_handler_field_aggregator_title_link extends FieldPluginBase {
/**
* @Plugin(
* plugin_id = "aggregator_title_link"
* )
*/
class TitleLink extends FieldPluginBase {
function construct() {
parent::construct();
$this->additional_fields['link'] = 'link';
......
......@@ -5,14 +5,23 @@
* Definition of views_handler_field_aggregator_xss.
*/
namespace Drupal\aggregator\Plugin\views\field;
use Drupal\views\Plugins\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Filters htmls tags from item.
*
* @ingroup views_field_handlers
*/
class views_handler_field_aggregator_xss extends FieldPluginBase {
/**
* @Plugin(
* plugin_id = "aggregator_xss"
* )
*/
class Xss extends FieldPluginBase {
function render($values) {
$value = $this->get_value($values);
return aggregator_filter_xss($value);
......
<?php
/**
* @file
* Definition of views_handler_field_aggregator_category.
*/
use Drupal\views\Plugins\views\field\FieldPluginBase;
/**
* Field handler to provide simple renderer that allows linking to aggregator
* category.
*
* @ingroup views_field_handlers
*/
class views_handler_field_aggregator_category extends FieldPluginBase {
/**
* 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);
}
}
<?php
/**
* @file
* Definition of views_handler_field_aggregator_xss.
*/
use Drupal\views\Plugins\views\field\FieldPluginBase;
/**
* Filters htmls tags from item.
*
* @ingroup views_field_handlers
*/
class views_handler_field_aggregator_xss extends FieldPluginBase {
function render($values) {
$value = $this->get_value($values);
return aggregator_filter_xss($value);
}
}
......@@ -5,14 +5,23 @@
* Definition of views_handler_filter_aggregator_category_cid.
*/
namespace Drupal\aggregator\Plugin\views\filter;
use Drupal\views\Plugins\views\filter\InOperator;
use Drupal\Core\Annotation\Plugin;
/**
* Filter by aggregator category cid
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_aggregator_category_cid extends InOperator {
/**
* @Plugin(
* plugin_id = "aggregator_category_cid"
* )
*/
class CategoryCid extends InOperator {
function get_value_options() {
if (isset($this->value_options)) {
return;
......
<?php
/**
* @file
* Definition of views_handler_filter_aggregator_category_cid.
*/
use Drupal\views\Plugins\views\filter\InOperator;
/**
* Filter by aggregator category cid
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_aggregator_category_cid extends InOperator {
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;
}
}
}
......@@ -5,12 +5,26 @@
* Contains the Aggregator Item RSS row style plugin.
*/
namespace Drupal\aggregator\Plugin\views\row;
use Drupal\views\Plugins\views\row\RowPluginBase;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Plugin which loads an aggregator item and formats it as an RSS item.
*
* @Plugin(
* plugin_id = "aggregator_rss",
* theme = "views_view_row_rss",
* title = @Translation("Aggregator item"),
* help = @Translation("Display the aggregator item using the data from the original source."),
* uses_options = TRUE,
* type = "feed",
* help_topic = "style-aggregator-rss"
* )
*/
class views_plugin_row_aggregator_rss extends RowPluginBase {
class Rss extends RowPluginBase {
var $base_table = 'aggregator_item';
var $base_field = 'iid';
......
......@@ -4,12 +4,23 @@
* Contains the book root from current node argument default plugin.
*/
use Drupal\views\Plugins\views\argument_default\Node;
namespace Drupal\book\Plugin\views\argument_default;
use Views\node\Plugin\views\argument_default\Node;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Default argument plugin to get the current node's book root.
*/
class views_plugin_argument_default_book_root extends Node {
/**
* @Plugin(
* plugin_id = "book_root",
* title = @Translation("Book root from current node")
* )
*/
class Root extends Node {
function get_argument() {
// Use the argument_default_node plugin to get the nid argument.
$nid = parent::get_argument();
......
......@@ -5,13 +5,24 @@
* Definition of views_handler_argument_comment_user_uid.
*/
namespace Drupal\comment\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\ArgumentPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept a user id to check for nodes that
* user posted or commented on.
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_comment_user_uid extends views_handler_argument {
/**
* @Plugin(
* plugin_id = "argument_comment_user_uid"
* )
*/
class UserUid extends ArgumentPluginBase {
function title() {
if (!$this->argument) {
$title = variable_get('anonymous', t('Anonymous'));
......
<?php
/**
* @file
* Definition of views_handler_argument_comment_user_uid.
*/
/**
* Argument handler to accept a user id to check for nodes that
* user posted or commented on.
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_comment_user_uid extends views_handler_argument {
function title() {
if (!$this->argument) {
$title = variable_get('anonymous', t('Anonymous'));
}
else {
$title = db_query('SELECT u.name FROM {users} u WHERE u.uid = :uid', array(':uid' => $this->argument))->fetchField();
}
if (empty($title)) {
return t('No user');
}
return check_plain($title);
}
function default_actions($which = NULL) {
// Disallow summary views on this argument.
if (!$which) {
$actions = parent::default_actions();
unset($actions['summary asc']);
unset($actions['summary desc']);
return $actions;
}
if ($which != 'summary asc' && $which != 'summary desc') {
return parent::default_actions($which);
}
}
function query($group_by = FALSE) {
$this->ensure_my_table();
$subselect = db_select('comment', 'c');
$subselect->addField('c', 'cid');
$subselect->condition('c.uid', $this->argument);
$subselect->where("c.nid = $this->table_alias.nid");
$condition = db_or()
->condition("$this->table_alias.uid", $this->argument, '=')
->exists($subselect);
$this->query->add_where(0, $condition);
}
function get_sort_name() {
return t('Numerical', array(), array('context' => 'Sort order'));
}
}
......@@ -5,14 +5,23 @@
* Definition of views_handler_field_comment.
*/
namespace Drupal\comment\Plugin\views\field;
use Drupal\views\Plugins\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to allow linking to a comment.
*
* @ingroup views_field_handlers
*/
class views_handler_field_comment extends FieldPluginBase {
/**
* @Plugin(
* plugin_id = "comment"
* )
*/
class Comment extends FieldPluginBase {
/**
* Override init function to provide generic option to link to comment.
*/
......
......@@ -5,12 +5,23 @@
* Definition of views_handler_field_comment_depth.
*/
namespace Drupal\comment\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugins\views\field\FieldPluginBase;
/**
* Field handler to display the depth of a comment.
*
* @ingroup views_field_handlers
*/
class views_handler_field_comment_depth extends views_handler_field {
/**
* @Plugin(
* plugin_id = "comment_depth"
* )
*/
class views_handler_field_comment_depth extends FieldPluginBase {
/**
* Work out the depth of this comment
*/
......
......@@ -5,12 +5,22 @@
* Definition of views_handler_field_comment_link_delete.
*/
namespace Drupal\comment\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to present a link to delete a node.
*
* @ingroup views_field_handlers
*/
class views_handler_field_comment_link_delete extends views_handler_field_comment_link {
/**
* @Plugin(
* plugin_id = "comment_link_delete"
* )
*/
class LinkDelete extends Link {
function access() {
//needs permission to administer comments in general
return user_access('administer comments');
......
......@@ -5,12 +5,23 @@
* Definition of views_handler_field_last_comment_timestamp.
*/
namespace Drupal\comment\Plugin\views\field;
use Drupal\views\Plugins\views\field\Date;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to display the timestamp of a comment with the count of comments.
*
* @ingroup views_field_handlers
*/
class views_handler_field_last_comment_timestamp extends views_handler_field_date {
/**
* @Plugin(
* plugin_id = "comment_last_timestamp"
* )
*/
class LastTimestamp extends Date {
function construct() {
parent::construct();
$this->additional_fields['comment_count'] = 'comment_count';
......
......@@ -5,12 +5,22 @@
* Definition of views_handler_field_comment_link.
*/
namespace Drupal\comment\Plugin\views\field;
use Drupal\views\Plugins\views\field\Entity;
/**
* Base field handler to present a link.
*
* @ingroup views_field_handlers
*/
class views_handler_field_comment_link extends views_handler_field_entity {
/**
* @Plugin(
* plugin_id = "comment_link"
* )
*/
class Link extends Entity {
function construct() {
parent::construct();
}
......
......@@ -5,12 +5,22 @@
* Definition of views_handler_field_comment_link_approve.
*/
namespace Drupal\comment\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
/**
* Provides a comment approve link.
*
* @ingroup views_field_handlers
*/
class views_handler_field_comment_link_approve extends views_handler_field_comment_link {
/**
* @Plugin(
* plugin_id = "comment_link_approve"
* )
*/
class views_handler_field_comment_link_approve extends Link {
function access() {
//needs permission to administer comments in general
return user_access('administer comments');
......
......@@ -5,12 +5,22 @@
* Definition of views_handler_field_comment_link_edit.
*/
namespace Drupal\comment\Plugin\views\field;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to present a link node edit.
*
* @ingroup views_field_handlers
*/
class views_handler_field_comment_link_edit extends views_handler_field_comment_link {
/**
* @Plugin(
* plugin_id = "comment_link_edit"
* )