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

Convert node to annotations and PSR0

parent 20edb75f
<?php
namespace Drupal\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugins\views\argument\Date;
/**
* Argument handler for a day (DD)
*/
/**
* @Plugin(
* plugin_id = "node_created_day"
* )
*/
class CreatedDay extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->formula = views_date_sql_extract('DAY', "***table***.$this->real_field");
$this->format = 'j';
$this->arg_format = 'd';
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
// strtotime respects server timezone, so we need to set the time fixed as utc time
return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
$day = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
function summary_argument($data) {
// Make sure the argument contains leading zeroes.
return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
}
}
<?php
namespace Drupal\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugins\views\argument\Date;
/**
* Argument handler for a full date (CCYYMMDD)
*/
/**
* @Plugin(
* plugin_id = "node_created_fulldate"
* )
*/
class CreatedFullDate extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->format = 'F j, Y';
$this->arg_format = 'Ymd';
$this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$created = $data->{$this->name_alias};
return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
return format_date(strtotime($this->argument . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
}
<?php
namespace Drupal\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugins\views\argument\Date;
/**
* Argument handler for a month (MM)
*/
/**
* @Plugin(
* plugin_id = "node_created_month"
* )
*/
class CreatedMonth extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->formula = views_date_sql_extract('MONTH', "***table***.$this->real_field");
$this->format = 'F';
$this->arg_format = 'm';
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
$month = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
function summary_argument($data) {
// Make sure the argument contains leading zeroes.
return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
}
}
<?php
namespace Drupal\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugins\views\argument\Date;
/**
* Argument handler for a week.
*/
/**
* @Plugin(
* plugin_id = "node_created_week"
*/
class CreatedWeek extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->arg_format = 'w';
$this->formula = views_date_sql_extract('WEEK', "***table***.$this->real_field");
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$created = $data->{$this->name_alias};
return t('Week @week', array('@week' => $created));
}
}
<?php
namespace Drupal\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugins\views\argument\Date;
/**
* Argument handler for a year (CCYY)
*/
/**
* @Plugin(
* plugin_id = "node_created_year"
*/
class CreatedYear extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->arg_format = 'Y';
$this->formula = views_date_sql_extract('YEAR', "***table***.$this->real_field");
}
}
<?php
namespace Drupal\node\Plugin\views\argument;
use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugins\views\argument\Date;
/**
* Argument handler for a year plus month (CCYYMM)
*/
/**
* @Plugin(
* plugin_id = "node_created_year_month"
*/
class CreatedYearMonth extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->format = 'F Y';
$this->arg_format = 'Ym';
$this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$created = $data->{$this->name_alias};
return format_date(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
return format_date(strtotime($this->argument . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
}
......@@ -5,10 +5,21 @@
* Definition of views_handler_argument_node_language.
*/
namespace Drupal\node\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\ArgumentPluginBase;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept a language.
*/
class views_handler_argument_node_language extends views_handler_argument {
/**
* @Plugin(
* plugin_id = "node_language"
* )
*/
class Language extends ArgumentPluginBase {
function construct() {
parent::construct('language');
}
......
......@@ -5,10 +5,21 @@
* Provide node nid argument handler.
*/
namespace Drupal\node\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept a node id.
*/
class views_handler_argument_node_nid extends views_handler_argument_numeric {
/**
* @Plugin(
* plugin_id = "node_nid"
* )
*/
class Nid extends Numeric {
/**
* Override the behavior of title(). Get the title of the node.
*/
......
......@@ -5,10 +5,21 @@
* Definition of views_handler_argument_node_type.
*/
namespace Drupal\node\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\String;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept a node type.
*/
class views_handler_argument_node_type extends views_handler_argument_string {
/**
* @Plugin(
* plugin_id = "node_type"
* )
*/
class Type extends String {
function construct() {
parent::construct('type');
}
......
......@@ -5,11 +5,22 @@
* Defintion of views_handler_argument_node_uid_revision.
*/
namespace Drupal\node\Plugin\views\argument;
use Drupal\user\Plugin\views\argument\UserUid;
use Drupal\Core\Annotation\Plugin;
/**
* Filter handler to accept a user id to check for nodes that
* user posted or created a revision on.
*/
class views_handler_argument_node_uid_revision extends UserUid {
/**
* @Plugin(
* plugin_id = "node_uid_revision"
* )
*/
class UidRevision extends UserUid {
function query($group_by = FALSE) {
$this->ensure_my_table();
$placeholder = $this->placeholder();
......
......@@ -5,10 +5,21 @@
* Provide node vid argument handler.
*/
namespace Drupal\node\Plugin\views\argument;
use Drupal\views\Plugins\views\argument\Numeric;
use Drupal\Core\Annotation\Plugin;
/**
* Argument handler to accept a node revision id.
*/
class views_handler_argument_node_vid extends views_handler_argument_numeric {
/**
* @Plugin(
* plugin_id = "node_vid"
* )
*/
class Vid extends Numeric {
// No constructor is necessary.
/**
......
<?php
/**
* @file
* Handlers for various date arguments.
*
* @ingroup views_argument_handlers
*/
use Drupal\views\Plugins\views\argument\Date;
/**
* Argument handler for a full date (CCYYMMDD)
*/
class views_handler_argument_node_created_fulldate extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->format = 'F j, Y';
$this->arg_format = 'Ymd';
$this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$created = $data->{$this->name_alias};
return format_date(strtotime($created . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
return format_date(strtotime($this->argument . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
}
/**
* Argument handler for a year (CCYY)
*/
class views_handler_argument_node_created_year extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->arg_format = 'Y';
$this->formula = views_date_sql_extract('YEAR', "***table***.$this->real_field");
}
}
/**
* Argument handler for a year plus month (CCYYMM)
*/
class views_handler_argument_node_created_year_month extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->format = 'F Y';
$this->arg_format = 'Ym';
$this->formula = views_date_sql_format($this->arg_format, "***table***.$this->real_field");
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$created = $data->{$this->name_alias};
return format_date(strtotime($created . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
return format_date(strtotime($this->argument . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
}
/**
* Argument handler for a month (MM)
*/
class views_handler_argument_node_created_month extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->formula = views_date_sql_extract('MONTH', "***table***.$this->real_field");
$this->format = 'F';
$this->arg_format = 'm';
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$month = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC" ), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
$month = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
return format_date(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
function summary_argument($data) {
// Make sure the argument contains leading zeroes.
return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
}
}
/**
* Argument handler for a day (DD)
*/
class views_handler_argument_node_created_day extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->formula = views_date_sql_extract('DAY', "***table***.$this->real_field");
$this->format = 'j';
$this->arg_format = 'd';
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$day = str_pad($data->{$this->name_alias}, 2, '0', STR_PAD_LEFT);
// strtotime respects server timezone, so we need to set the time fixed as utc time
return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
/**
* Provide a link to the next level of the view
*/
function title() {
$day = str_pad($this->argument, 2, '0', STR_PAD_LEFT);
return format_date(strtotime("2005" . "05" . $day . " 00:00:00 UTC"), 'custom', $this->format, 'UTC');
}
function summary_argument($data) {
// Make sure the argument contains leading zeroes.
return str_pad($data->{$this->base_alias}, 2, '0', STR_PAD_LEFT);
}
}
/**
* Argument handler for a week.
*/
class views_handler_argument_node_created_week extends Date {
/**
* Constructor implementation
*/
function construct() {
parent::construct();
$this->arg_format = 'w';
$this->formula = views_date_sql_extract('WEEK', "***table***.$this->real_field");
}
/**
* Provide a link to the next level of the view
*/
function summary_name($data) {
$created = $data->{$this->name_alias};
return t('Week @week', array('@week' => $created));
}
}
......@@ -5,6 +5,10 @@
* Contains the node from URL argument default plugin.
*/
namespace Drupal\node\Plugin\views\argument_default;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
use Drupal\views\Plugins\views\argument_default\ArgumentDefaultPluginBase;
/**
......@@ -12,7 +16,14 @@
*
* This plugin actually has no options so it odes not need to do a great deal.
*/
class views_plugin_argument_default_node extends ArgumentDefaultPluginBase {
/**
* @Plugin(
* plugin_id = "node",
* title = @Translation("Content ID from URL")
* )
*/
class Node extends ArgumentDefaultPluginBase {
function get_argument() {
foreach (range(1, 3) as $i) {
$node = menu_get_object('node', $i);
......
......@@ -5,12 +5,23 @@
* Contains the 'node' argument validator plugin.
*/
namespace Drupal\node\Plugin\views\argument_validator;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
use Drupal\views\Plugins\views\argument_validator\ArgumentValidatorPluginBase;
/**
* Validate whether an argument is an acceptable node.
*/
class views_plugin_argument_validate_node extends ArgumentValidatorPluginBase {
/**
* @Plugin(
* plugin_id = "node",
* title = @Translation("Content")
* )
*/
class Node extends ArgumentValidatorPluginBase {
function option_definition() {
$options = parent::option_definition();
$options['types'] = array('default' => array());
......
......@@ -5,6 +5,11 @@
* Definition of views_handler_field_history_user_timestamp.
*/
namespace Drupal\node\Plugin\views\field;
use Drupal\node\Plugin\views\field\Node;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to display the marker for new content.
*
......@@ -13,7 +18,7 @@
*
* @ingroup views_field_handlers
*/
class views_handler_field_history_user_timestamp extends views_handler_field_node {
class HistoryUserTimestamp extends Node {
function init(&$view, &$options) {
parent::init($view, $options);
global $user;
......
......@@ -5,12 +5,23 @@
* Definition of views_handler_field_node_link.
*/
namespace Drupal\node\Plugin\views\field;
use Drupal\views\Plugins\views\field\Entity;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to present a link to the node.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_link extends views_handler_field_entity {
/**
* @Plugin(
* plugin_id = "node_link"
* )
*/
class Link extends Entity {
function option_definition() {
$options = parent::option_definition();
......
......@@ -5,12 +5,23 @@
* Definition of views_handler_field_node_link_delete.
*/
namespace Drupal\node\Plugin\views\field;
use Drupal\node\Plugin\views\field\Link;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to present a link to delete a node.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_link_delete extends views_handler_field_node_link {
/**
* @Plugin(
* plugin_id = "node_link_delete"
* )
*/
class LinkDelete extends Link {
/**
* Renders the link.
......
......@@ -5,12 +5,23 @@
* Definition of views_handler_field_node_link_edit.
*/
namespace Drupal\node\Plugin\views\field;
use Drupal\node\Plugin\views\field\Link;
use Drupal\Core\Annotation\Plugin;
/**
* Field handler to present a link node edit.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_link_edit extends views_handler_field_node_link {
/**
* @Plugin(
* plugin_id = "node_link_edit"
* )
*/
class LinkEdit extends Link {
/**
* Renders the link.
......
......@@ -5,7 +5,10 @@
* Contains the basic 'node' field handler.
*/
namespace Drupal\node\Plugin\views\field;
use Drupal\views\Plugins\views\field\FieldPluginBase;
use Drupal\Core\Annotation\Plugin;