Commit 49b44b5f authored by tim.plunkett's avatar tim.plunkett

Remove migrated module plugins.

parent 15eaff39
......@@ -88,7 +88,7 @@ function render($row) {
$item_length = $this->options['item_length'];
if ($item_length == 'default') {
$item_length = variable_get('feed_item_length', 'teaser');
$item_length = config('system.rss')->get('items.view_mode');
}
// Load the specified comment and its associated node:
......
......@@ -98,7 +98,7 @@ function validate_argument($argument) {
}
// Save the title() handlers some work.
$this->argument->validated_title = check_plain($node->title);
$this->argument->validated_title = check_plain($node->label());
if (empty($types)) {
return TRUE;
......@@ -117,8 +117,8 @@ function validate_argument($argument) {
$test = drupal_map_assoc($nids->value);
$titles = array();
$result = db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids->value));
foreach ($result as $node) {
$nodes = node_load_multiple($nids->value);
foreach ($nodes as $node) {
if ($types && empty($types[$node->type])) {
return FALSE;
}
......@@ -129,7 +129,7 @@ function validate_argument($argument) {
}
}
$titles[] = check_plain($node->title);
$titles[] = check_plain($node->label());
unset($test[$node->nid]);
}
......
......@@ -98,7 +98,7 @@ function render($row) {
$display_mode = $this->options['item_length'];
if ($display_mode == 'default') {
$display_mode = variable_get('feed_item_length', 'teaser');
$display_mode = config('system.rss')->get('items.view_mode');
}
// Load the specified node:
......
......@@ -50,7 +50,7 @@ function options_form(&$form, &$form_state) {
$form['limit'] = array(
'#type' => 'checkbox',
'#title' => t('Limit terms by vocabulary'),
'#default_value'=> $this->options['limit'],
'#default_value' => $this->options['limit'],
'#states' => array(
'visible' => array(
':input[name="options[argument_default][taxonomy_tid][node]"]' => array('checked' => TRUE),
......@@ -80,7 +80,7 @@ function options_form(&$form, &$form_state) {
$form['anyall'] = array(
'#type' => 'radios',
'#title' => t('Multiple-value handling'),
'#default_value'=> $this->options['anyall'],
'#default_value' => $this->options['anyall'],
'#process' => array('form_process_radios', 'ctools_dependent_process'),
'#options' => array(
',' => t('Filter to items that share all terms'),
......
<?php
/**
* @file
* Contains the Aggregator Item RSS row style plugin.
*/
use Drupal\views\Plugins\views\row\RowPluginBase;
/**
* Plugin which loads an aggregator item and formats it as an RSS item.
*/
class views_plugin_row_aggregator_rss extends RowPluginBase {
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
));
}
}
<?php
/**
* @file
* Contains the book root from current node argument default plugin.
*/
use Drupal\views\Plugins\views\argument_default\Node;
/**
* Default argument plugin to get the current node's book root.
*/
class views_plugin_argument_default_book_root extends Node {
function get_argument() {
// Use the argument_default_node plugin to get the nid argument.
$nid = parent::get_argument();
if (!empty($nid)) {
$node = node_load($nid);
if (isset($node->book['bid'])) {
return $node->book['bid'];
}
}
}
}
<?php
/**
* @file
* Contains the comment RSS row style plugin.
*/
use Drupal\views\Plugins\views\row\RowPluginBase;
/**
* Plugin which formats the comments as RSS items.
*/
class views_plugin_row_comment_rss extends RowPluginBase {
var $base_table = 'comment';
var $base_field = 'cid';
function option_definition() {
$options = parent::option_definition();
$options['item_length'] = array('default' => 'default');
$options['links'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['item_length'] = array(
'#type' => 'select',
'#title' => t('Display type'),
'#options' => $this->options_form_summary_options(),
'#default_value' => $this->options['item_length'],
);
$form['links'] = array(
'#type' => 'checkbox',
'#title' => t('Display links'),
'#default_value' => $this->options['links'],
);
}
function pre_render($result) {
$cids = array();
$nids = array();
foreach ($result as $row) {
$cids[] = $row->cid;
}
$this->comments = comment_load_multiple($cids);
foreach ($this->comments as &$comment) {
$comment->depth = count(explode('.', $comment->thread)) - 1;
$nids[] = $comment->nid;
}
$this->nodes = node_load_multiple($nids);
}
/**
* Return the main options, which are shown in the summary title
*
* @see views_plugin_row_node_rss::options_form_summary_options()
* @todo: Maybe provide a views_plugin_row_rss_entity and reuse this method
* in views_plugin_row_comment|node_rss.inc
*/
function options_form_summary_options() {
$entity_info = entity_get_info('node');
$options = array();
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $mode => $settings) {
$options[$mode] = $settings['label'];
}
}
$options['title'] = t('Title only');
$options['default'] = t('Use site default RSS settings');
return $options;
}
function render($row) {
global $base_url;
$cid = $row->{$this->field_alias};
if (!is_numeric($cid)) {
return;
}
$item_length = $this->options['item_length'];
if ($item_length == 'default') {
$item_length = config('system.rss')->get('items.view_mode');
}
// Load the specified comment and its associated node:
$comment = $this->comments[$cid];
if (empty($comment) || empty($this->nodes[$comment->nid])) {
return;
}
$item_text = '';
$uri = $comment->uri();
$comment->link = url($uri['path'], $uri['options'] + array('absolute' => TRUE));
$comment->rss_namespaces = array();
$comment->rss_elements = array(
array(
'key' => 'pubDate',
'value' => gmdate('r', $comment->created),
),
array(
'key' => 'dc:creator',
'value' => $comment->name,
),
array(
'key' => 'guid',
'value' => 'comment ' . $comment->cid . ' at ' . $base_url,
'attributes' => array('isPermaLink' => 'false'),
),
);
// The comment gets built and modules add to or modify
// $comment->rss_elements and $comment->rss_namespaces.
$build = comment_view($comment, $this->nodes[$comment->nid], 'rss');
unset($build['#theme']);
if (!empty($comment->rss_namespaces)) {
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $comment->rss_namespaces);
}
// Hide the links if desired.
if (!$this->options['links']) {
hide($build['links']);
}
if ($item_length != 'title') {
// We render comment contents and force links to be last.
$build['links']['#weight'] = 1000;
$item_text .= drupal_render($build);
}
$item = new stdClass();
$item->description = $item_text;
$item->title = $comment->subject;
$item->link = $comment->link;
$item->elements = $comment->rss_elements;
$item->cid = $comment->cid;
return theme($this->theme_functions(), array(
'view' => $this->view,
'options' => $this->options,
'row' => $item
));
}
}
<?php
/**
* @file
* Contains the node RSS row style plugin.
*/
use Drupal\views\Plugins\views\row\RowPluginBase;
/**
* Plugin which performs a comment_view on the resulting object.
*/
class views_plugin_row_comment_view extends RowPluginBase {
var $base_field = 'cid';
var $base_table = 'comment';
/**
* Stores all comments which are preloaded.
*/
var $comments = array();
/**
* Stores all nodes of all comments which are preloaded.
*/
var $nodes = array();
function summary_title() {
return t('Settings');
}
function option_definition() {
$options = parent::option_definition();
$options['links'] = array('default' => TRUE, 'bool' => TRUE);
$options['view_mode'] = array('default' => 'full');
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$options = $this->options_form_summary_options();
$form['view_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#title' => t('View mode'),
'#default_value' => $this->options['view_mode'],
);
$form['links'] = array(
'#type' => 'checkbox',
'#title' => t('Display links'),
'#default_value' => $this->options['links'],
);
}
/**
* Return the main options, which are shown in the summary title.
*/
function options_form_summary_options() {
$entity_info = entity_get_info('comment');
$options = array();
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $mode => $settings) {
$options[$mode] = $settings['label'];
}
}
if (empty($options)) {
$options = array(
'full' => t('Full content')
);
}
return $options;
}
function pre_render($result) {
$cids = array();
foreach ($result as $row) {
$cids[] = $row->cid;
}
// Load all comments.
$cresult = comment_load_multiple($cids);
$nids = array();
foreach ($cresult as $comment) {
$comment->depth = count(explode('.', $comment->thread)) - 1;
$this->comments[$comment->cid] = $comment;
$nids[] = $comment->nid;
}
// Load all nodes of the comments.
$nodes = node_load_multiple(array_unique($nids));
foreach ($nodes as $node) {
$this->nodes[$node->nid] = $node;
}
}
}
<?php
/**
* @file
* Contains the node from URL argument default plugin.
*/
use Drupal\views\Plugins\views\argument_default\ArgumentDefaultPluginBase;
/**
* Default argument plugin to extract a node via menu_get_object
*
* This plugin actually has no options so it odes not need to do a great deal.
*/
class views_plugin_argument_default_node extends ArgumentDefaultPluginBase {
function get_argument() {
foreach (range(1, 3) as $i) {
$node = menu_get_object('node', $i);
if (!empty($node)) {
return $node->nid;
}
}
if (arg(0) == 'node' && is_numeric(arg(1))) {
return arg(1);
}
}
}
<?php
/**
* @file
* Contains the 'node' argument validator plugin.
*/
use Drupal\views\Plugins\views\argument_validator\ArgumentValidatorPluginBase;
/**
* Validate whether an argument is an acceptable node.
*/
class views_plugin_argument_validate_node extends ArgumentValidatorPluginBase {
function option_definition() {
$options = parent::option_definition();
$options['types'] = array('default' => array());
$options['access'] = array('default' => FALSE, 'bool' => TRUE);
$options['access_op'] = array('default' => 'view');
$options['nid_type'] = array('default' => 'nid');
return $options;
}
function options_form(&$form, &$form_state) {
$types = node_type_get_types();
$options = array();
foreach ($types as $type => $info) {
$options[$type] = check_plain(t($info->name));
}
$form['types'] = array(
'#type' => 'checkboxes',
'#title' => t('Content types'),
'#options' => $options,
'#default_value' => $this->options['types'],
'#description' => t('Choose one or more content types to validate with.'),
);
$form['access'] = array(
'#type' => 'checkbox',
'#title' => t('Validate user has access to the content'),
'#default_value' => $this->options['access'],
);
$form['access_op'] = array(
'#type' => 'radios',
'#title' => t('Access operation to check'),
'#options' => array('view' => t('View'), 'update' => t('Edit'), 'delete' => t('Delete')),
'#default_value' => $this->options['access_op'],
'#states' => array(
'visible' => array(
':input[name="options[validate][options][node][access]"]' => array('checked' => TRUE),
),
),
);
$form['nid_type'] = array(
'#type' => 'select',
'#title' => t('Filter value format'),
'#options' => array(
'nid' => t('Node ID'),
'nids' => t('Node IDs separated by , or +'),
),
'#default_value' => $this->options['nid_type'],
);
}
function options_submit(&$form, &$form_state, &$options = array()) {
// filter trash out of the options so we don't store giant unnecessary arrays
$options['types'] = array_filter($options['types']);
}
function convert_options(&$options) {
if (!isset($options['types']) && !empty($this->argument->options['validate_argument_node_type'])) {
$options['types'] = isset($this->argument->options['validate_argument_node_type']) ? $this->argument->options['validate_argument_node_type'] : array();
$options['access'] = !empty($this->argument->options['validate_argument_node_access']);
$options['access_op'] = isset($this->argument->options['validate_argument_node_access_op']) ? $this->argument->options['validate_argument_node_access_op'] : 'view';
$options['nid_type'] = isset($this->argument->options['validate_argument_nid_type']) ? $this->argument->options['validate_argument_nid_type'] : array();
}
}
function validate_argument($argument) {
$types = $this->options['types'];
switch ($this->options['nid_type']) {
case 'nid':
if (!is_numeric($argument)) {
return FALSE;
}
$node = node_load($argument);
if (!$node) {
return FALSE;
}
if (!empty($this->options['access'])) {
if (!node_access($this->options['access_op'], $node)) {
return FALSE;
}
}
// Save the title() handlers some work.
$this->argument->validated_title = check_plain($node->label());
if (empty($types)) {
return TRUE;
}
return isset($types[$node->type]);
break;
case 'nids':
$nids = new stdClass();
$nids->value = array($argument);
$nids = views_break_phrase($argument, $nids);
if ($nids->value == array(-1)) {
return FALSE;
}
$test = drupal_map_assoc($nids->value);
$titles = array();
$nodes = node_load_multiple($nids->value);
foreach ($nodes as $node) {
if ($types && empty($types[$node->type])) {
return FALSE;
}
if (!empty($this->options['access'])) {
if (!node_access($this->options['access_op'], $node)) {
return FALSE;
}
}
$titles[] = check_plain($node->label());
unset($test[$node->nid]);
}
$this->argument->validated_title = implode($nids->operator == 'or' ? ' + ' : ', ', $titles);
// If this is not empty, we did not find a nid.
return empty($test);
}
}
}
<?php
/**
* @file
* Contains the node RSS row style plugin.
*/
use Drupal\views\Plugins\views\row\RowPluginBase;
/**
* Plugin which performs a node_view on the resulting object
* and formats it as an RSS item.
*/
class views_plugin_row_node_rss extends RowPluginBase {
// Basic properties that let the row style follow relationships.
var $base_table = 'node';
var $base_field = 'nid';
// Stores the nodes loaded with pre_render.
var $nodes = array();
function option_definition() {
$options = parent::option_definition();
$options['item_length'] = array('default' => 'default');
$options['links'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
/**
* Override init function to convert fulltext view-mode to full.
*/
function init(&$view, &$display, $options = NULL) {
parent::init($view, $display, $options);
if ($this->options['item_length'] == 'fulltext') {
$this->options['item_length'] = 'full';
}
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['item_length'] = array(
'#type' => 'select',
'#title' => t('Display type'),
'#options' => $this->options_form_summary_options(),
'#default_value' => $this->options['item_length'],
);
$form['links'] = array(
'#type' => 'checkbox',
'#title' => t('Display links'),
'#default_value' => $this->options['links'],
);
}
/**
* Return the main options, which are shown in the summary title.
*/
function options_form_summary_options() {
$entity_info = entity_get_info('node');
$options = array();
if (!empty($entity_info['view modes'])) {
foreach ($entity_info['view modes'] as $mode => $settings) {
$options[$mode] = $settings['label'];
}
}
$options['title'] = t('Title only');
$options['default'] = t('Use site default RSS settings');
return $options;
}
function summary_title() {
$options = $this->options_form_summary_options();
return check_plain($options[$this->options['item_length']]);
}
function pre_render($values) {
$nids = array();
foreach ($values as $row) {
$nids[] = $row->{$this->field_alias};
}
if (!empty($nids)) {
$this->nodes = node_load_multiple($nids);
}
}
function render($row) {
// For the most part, this code is taken from node_feed() in node.module
global $base_url;
$nid = $row->{$this->field_alias};
if (!is_numeric($nid)) {
return;
}
$display_mode = $this->options['item_length'];
if ($display_mode == 'default') {
$display_mode = config('system.rss')->get('items.view_mode');
}
// Load the specified node:
$node = $this->nodes[$nid];
if (empty($node)) {
return;