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,177 @@
<?php
/**
* @file
* Handlers for various date arguments.
*
* @ingroup views_argument_handlers
*/
/**
* Argument handler for a full date (CCYYMMDD)
*/
class views_handler_argument_node_created_fulldate extends views_handler_argument_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 views_handler_argument_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 views_handler_argument_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 views_handler_argument_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 views_handler_argument_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 views_handler_argument_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));
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* @file
* Definition of views_handler_argument_node_language.
*/
/**
* Argument handler to accept a language.
*/
class views_handler_argument_node_language extends views_handler_argument {
function construct() {
parent::construct('language');
}
/**
* Override the behavior of summary_name(). Get the user friendly version
* of the language.
*/
function summary_name($data) {
return $this->node_language($data->{$this->name_alias});
}
/**
* Override the behavior of title(). Get the user friendly version of the
* node type.
*/
function title() {
return $this->node_language($this->argument);
}
function node_language($langcode) {
$languages = views_language_list();
return isset($languages[$langcode]) ? $languages[$langcode] : t('Unknown language');
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* @file
* Provide node nid argument handler.
*/
/**
* Argument handler to accept a node id.
*/
class views_handler_argument_node_nid extends views_handler_argument_numeric {
/**
* Override the behavior of title(). Get the title of the node.
*/
function title_query() {
$titles = array();
$result = db_query("SELECT n.title FROM {node} n WHERE n.nid IN (:nids)", array(':nids' => $this->value));
foreach ($result as $term) {
$titles[] = check_plain($term->title);
}
return $titles;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* @file
* Definition of views_handler_argument_node_type.
*/
/**
* Argument handler to accept a node type.
*/
class views_handler_argument_node_type extends views_handler_argument_string {
function construct() {
parent::construct('type');
}
/**
* Override the behavior of summary_name(). Get the user friendly version
* of the node type.
*/
function summary_name($data) {
return $this->node_type($data->{$this->name_alias});
}
/**
* Override the behavior of title(). Get the user friendly version of the
* node type.
*/
function title() {
return $this->node_type($this->argument);
}
function node_type($type) {
$output = node_type_get_name($type);
if (empty($output)) {
$output = t('Unknown content type');
}
return check_plain($output);
}
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* @file
* Defintion of views_handler_argument_node_uid_revision.
*/
/**
* 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 views_handler_argument_comment_user_uid {
function query($group_by = FALSE) {
$this->ensure_my_table();
$placeholder = $this->placeholder();
$this->query->add_where_expression(0, "$this->table_alias.uid = $placeholder OR ((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid = $placeholder AND nr.nid = $this->table_alias.nid) > 0)", array($placeholder => $this->argument));
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* Provide node vid argument handler.
*/
/**
* Argument handler to accept a node revision id.
*/
class views_handler_argument_node_vid extends views_handler_argument_numeric {
// No constructor is necessary.
/**
* Override the behavior of title(). Get the title of the revision.
*/
function title_query() {
$titles = array();
$result = db_query("SELECT n.title FROM {node_revision} n WHERE n.vid IN (:vids)", array(':vids' => $this->value));
foreach ($result as $term) {
$titles[] = check_plain($term->title);
}
return $titles;
}
}

View File

@@ -0,0 +1,82 @@
<?php
/**
* @file
* Definition of views_handler_field_history_user_timestamp.
*/
/**
* Field handler to display the marker for new content.
*
* The handler is named history_user, because of compability reasons, the table
* is history.
*
* @ingroup views_field_handlers
*/
class views_handler_field_history_user_timestamp extends views_handler_field_node {
function init(&$view, &$options) {
parent::init($view, $options);
global $user;
if ($user->uid) {
$this->additional_fields['created'] = array('table' => 'node', 'field' => 'created');
$this->additional_fields['changed'] = array('table' => 'node', 'field' => 'changed');
if (module_exists('comment') && !empty($this->options['comments'])) {
$this->additional_fields['last_comment'] = array('table' => 'node_comment_statistics', 'field' => 'last_comment_timestamp');
}
}
}
function option_definition() {
$options = parent::option_definition();
$options['comments'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
if (module_exists('comment')) {
$form['comments'] = array(
'#type' => 'checkbox',
'#title' => t('Check for new comments as well'),
'#default_value' => !empty($this->options['comments']),
'#fieldset' => 'more',
);
}
}
function query() {
// Only add ourselves to the query if logged in.
global $user;
if (!$user->uid) {
return;
}
parent::query();
}
function render($values) {
// Let's default to 'read' state.
// This code shadows node_mark, but it reads from the db directly and
// we already have that info.
$mark = MARK_READ;
global $user;
if ($user->uid) {
$last_read = $this->get_value($values);
$changed = $this->get_value($values, 'changed');
$last_comment = module_exists('comment') && !empty($this->options['comments']) ? $this->get_value($values, 'last_comment') : 0;
if (!$last_read && $changed > NODE_NEW_LIMIT) {
$mark = MARK_NEW;
}
elseif ($changed > $last_read && $changed > NODE_NEW_LIMIT) {
$mark = MARK_UPDATED;
}
elseif ($last_comment > $last_read && $last_comment > NODE_NEW_LIMIT) {
$mark = MARK_UPDATED;
}
return $this->render_link(theme('mark', array('type' => $mark)), $values);
}
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* @file
* Contains the basic 'node' field handler.
*/
/**
* Field handler to provide simple renderer that allows linking to a node.
* Definition terms:
* - link_to_node default: Should this field have the checkbox "link to node" enabled by default.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node extends views_handler_field {
function init(&$view, &$options) {
parent::init($view, $options);
// Don't add the additional fields to groupby
if (!empty($this->options['link_to_node'])) {
$this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');
if (module_exists('translation')) {
$this->additional_fields['language'] = array('table' => 'node', 'field' => 'language');
}
}
}
function option_definition() {
$options = parent::option_definition();
$options['link_to_node'] = array('default' => isset($this->definition['link_to_node default']) ? $this->definition['link_to_node default'] : FALSE, 'bool' => TRUE);
return $options;
}
/**
* Provide link to node option
*/
function options_form(&$form, &$form_state) {
$form['link_to_node'] = array(
'#title' => t('Link this field to the original piece of content'),
'#description' => t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_node']),
);
parent::options_form($form, $form_state);
}
/**
* Render whatever the data is as a link to the node.
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
if (!empty($this->options['link_to_node']) && !empty($this->additional_fields['nid'])) {
if ($data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "node/" . $this->get_value($values, 'nid');
if (isset($this->aliases['language'])) {
$languages = language_list();
$language = $this->get_value($values, 'language');
if (isset($languages[$language])) {
$this->options['alter']['language'] = $languages[$language];
}
else {
unset($this->options['alter']['language']);
}
}
}
else {
$this->options['alter']['make_link'] = FALSE;
}
}
return $data;
}
function render($values) {
$value = $this->get_value($values);
return $this->render_link($this->sanitize_value($value), $values);
}
}

View File

@@ -0,0 +1,48 @@
<?php
/**
* @file
* Definition of views_handler_field_node_link.
*/
/**
* Field handler to present a link to the node.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_link extends views_handler_field_entity {
function option_definition() {
$options = parent::option_definition();
$options['text'] = array('default' => '', 'translatable' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
$form['text'] = array(
'#type' => 'textfield',
'#title' => t('Text to display'),
'#default_value' => $this->options['text'],
);
parent::options_form($form, $form_state);
// The path is set by render_link function so don't allow to set it.
$form['alter']['path'] = array('#access' => FALSE);
$form['alter']['external'] = array('#access' => FALSE);
}
function render($values) {
if ($entity = $this->get_value($values)) {
return $this->render_link($entity, $values);
}
}
function render_link($node, $values) {
if (node_access('view', $node)) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "node/$node->nid";
$text = !empty($this->options['text']) ? $this->options['text'] : t('view');
return $text;
}
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* @file
* Definition of views_handler_field_node_link_delete.
*/
/**
* 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 {
/**
* Renders the link.
*/
function render_link($node, $values) {
// Ensure user has access to delete this node.
if (!node_access('delete', $node)) {
return;
}
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "node/$node->nid/delete";
$this->options['alter']['query'] = drupal_get_destination();
$text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
return $text;
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* @file
* Definition of views_handler_field_node_link_edit.
*/
/**
* 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 {
/**
* Renders the link.
*/
function render_link($node, $values) {
// Ensure user has access to edit this node.
if (!node_access('update', $node)) {
return;
}
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = "node/$node->nid/edit";
$this->options['alter']['query'] = drupal_get_destination();
$text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
return $text;
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* @file
* Handler for node path field.
*/
/**
* Field handler to present the path to the node.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_path extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['absolute'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
function construct() {
parent::construct();
$this->additional_fields['nid'] = 'nid';
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['absolute'] = array(
'#type' => 'checkbox',
'#title' => t('Use absolute link (begins with "http://")'),
'#default_value' => $this->options['absolute'],
'#description' => t('Enable this option to output an absolute link. Required if you want to use the path as a link destination (as in "output this field as a link" above).'),
'#fieldset' => 'alter',
);
}
function query() {
$this->ensure_my_table();
$this->add_additional_fields();
}
function render($values) {
$nid = $this->get_value($values, 'nid');
return url("node/$nid", array('absolute' => $this->options['absolute']));
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* @file
* Definition of views_handler_field_node_revision.
*/
/**
* Contains the basic 'node_revision' field handler.
*/
/**
* A basic node_revision handler.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_revision extends views_handler_field_node {
function init(&$view, &$options) {
parent::init($view, $options);
if (!empty($this->options['link_to_node_revision'])) {
$this->additional_fields['vid'] = 'vid';
$this->additional_fields['nid'] = 'nid';
if (module_exists('translation')) {
$this->additional_fields['language'] = array('table' => 'node', 'field' => 'language');
}
}
}
function option_definition() {
$options = parent::option_definition();
$options['link_to_node_revision'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
/**
* Provide link to revision option.
*/
function options_form(&$form, &$form_state) {
$form['link_to_node_revision'] = array(
'#title' => t('Link this field to its content revision'),
'#description' => t('This will override any other link you have set.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_node_revision']),
);
parent::options_form($form, $form_state);
}
/**
* Render whatever the data is as a link to the node.
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
if (!empty($this->options['link_to_node_revision']) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$nid = $this->get_value($values, 'nid');
$vid = $this->get_value($values, 'vid');
$this->options['alter']['path'] = 'node/' . $nid;
if ($nid != $vid) {
$this->options['alter']['path'] .= "/revisions/$vid/view";
}
if (module_exists('translation')) {
$language = $this->get_value($values, 'language');
$languages = language_list();
if (isset($languages[$language])) {
$this->options['alter']['language'] = $languages[$language];
}
}
}
else {
return parent::render_link($data, $values);
}
return $data;
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* @file
* Definition of views_handler_field_node_revision_link.
*/
/**
* Field handler to present a link to a node revision.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_revision_link extends views_handler_field_node_link {
function construct() {
parent::construct();
$this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid');
}
function access() {
return user_access('view revisions') || user_access('administer nodes');
}
function render_link($data, $values) {
list($node, $vid) = $this->get_revision_entity($values, 'view');
if (!isset($vid)) {
return;
}
// Current revision uses the node view path.
$path = 'node/' . $node->nid;
if ($node->vid != $vid) {
$path .= "/revisions/$vid/view";
}
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $path;
$this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : t('view');
}
/**
* Returns the revision values of a node.
*
* @param object $values
* An object containing all retrieved values.
* @param string $op
* The operation being performed.
*
* @return array
* A numerically indexed array containing the current node object and the
* revision ID for this row.
*/
function get_revision_entity($values, $op) {
$vid = $this->get_value($values, 'node_vid');
$node = $this->get_value($values);
// Unpublished nodes ignore access control.
$node->status = 1;
// Ensure user has access to perform the operation on this node.
if (!node_access($op, $node)) {
return array($node, NULL);
}
return array($node, $vid);
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* @file
* Definition of views_handler_field_node_revision_link_delete.
*/
/**
* Field handler to present link to delete a node revision.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_revision_link_delete extends views_handler_field_node_revision_link {
function access() {
return user_access('delete revisions') || user_access('administer nodes');
}
function render_link($data, $values) {
list($node, $vid) = $this->get_revision_entity($values, 'delete');
if (!isset($vid)) {
return;
}
// Current revision cannot be deleted.
if ($node->vid == $vid) {
return;
}
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->nid . "/revisions/$vid/delete";
$this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : t('delete');
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* @file
* Definition of views_handler_field_node_revision_link_revert.
*/
/**
* Field handler to present a link to revert a node to a revision.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_revision_link_revert extends views_handler_field_node_revision_link {
function access() {
return user_access('revert revisions') || user_access('administer nodes');
}
function render_link($data, $values) {
list($node, $vid) = $this->get_revision_entity($values, 'update');
if (!isset($vid)) {
return;
}
// Current revision cannot be reverted.
if ($node->vid == $vid) {
return;
}
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->nid . "/revisions/$vid/revert";
$this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : t('revert');
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* @file
* Definition of views_handler_field_node_type.
*/
/**
* Field handler to translate a node type into its readable form.
*
* @ingroup views_field_handlers
*/
class views_handler_field_node_type extends views_handler_field_node {
function option_definition() {
$options = parent::option_definition();
$options['machine_name'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
/**
* Provide machine_name option for to node type display.
*/
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['machine_name'] = array(
'#title' => t('Output machine name'),
'#description' => t('Display field as the content type machine name.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['machine_name']),
);
}
/**
* Render node type as human readable name, unless using machine_name option.
*/
function render_name($data, $values) {
if ($this->options['machine_name'] != 1 && $data !== NULL && $data !== '') {
return t($this->sanitize_value(node_type_get_name($data)));
}
return $this->sanitize_value($data);
}
function render($values) {
$value = $this->get_value($values);
return $this->render_link($this->render_name($value, $values), $values);
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* @file
* Definition of views_handler_filter_history_user_timestamp.
*/
/**
* Filter for new content.
*
* The handler is named history_user, because of compability reasons, the table
* is history.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_history_user_timestamp extends views_handler_filter {
// Don't display empty space where the operator would be.
var $no_operator = TRUE;
function expose_form(&$form, &$form_state) {
parent::expose_form($form, $form_state);
// @todo There are better ways of excluding required and multiple (object flags)
unset($form['expose']['required']);
unset($form['expose']['multiple']);
unset($form['expose']['remember']);
}
function value_form(&$form, &$form_state) {
// Only present a checkbox for the exposed filter itself. There's no way
// to tell the difference between not checked and the default value, so
// specifying the default value via the views UI is meaningless.
if (!empty($form_state['exposed'])) {
if (isset($this->options['expose']['label'])) {
$label = $this->options['expose']['label'];
}
else {
$label = t('Has new content');
}
$form['value'] = array(
'#type' => 'checkbox',
'#title' => $label,
'#default_value' => $this->value,
);
}
}
function query() {
global $user;
// This can only work if we're logged in.
if (!$user || !$user->uid) {
return;
}
// Don't filter if we're exposed and the checkbox isn't selected.
if ((!empty($this->options['exposed'])) && empty($this->value)) {
return;
}
// Hey, Drupal kills old history, so nodes that haven't been updated
// since NODE_NEW_LIMIT are bzzzzzzzt outta here!
$limit = REQUEST_TIME - NODE_NEW_LIMIT;
$this->ensure_my_table();
$field = "$this->table_alias.$this->real_field";
$node = $this->query->ensure_table('node', $this->relationship);
$clause = '';
$clause2 = '';
if (module_exists('comment')) {
$ncs = $this->query->ensure_table('node_comment_statistics', $this->relationship);
$clause = ("OR $ncs.last_comment_timestamp > (***CURRENT_TIME*** - $limit)");
$clause2 = "OR $field < $ncs.last_comment_timestamp";
}
// NULL means a history record doesn't exist. That's clearly new content.
// Unless it's very very old content. Everything in the query is already
// type safe cause none of it is coming from outside here.
$this->query->add_where_expression($this->options['group'], "($field IS NULL AND ($node.changed > (***CURRENT_TIME*** - $limit) $clause)) OR $field < $node.changed $clause2");
}
function admin_summary() {
if (!empty($this->options['exposed'])) {
return t('exposed');
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* @file
* Definition of views_handler_filter_node_access.
*/
/**
* Filter by node_access records.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_node_access extends views_handler_filter {
function admin_summary() { }
function operator_form(&$form, &$form_state) { }
function can_expose() {
return FALSE;
}
/**
* See _node_access_where_sql() for a non-views query based implementation.
*/
function query() {
if (!user_access('administer nodes') && module_implements('node_grants')) {
$table = $this->ensure_my_table();
$grants = db_or();
foreach (node_access_grants('view') as $realm => $gids) {
foreach ($gids as $gid) {
$grants->condition(db_and()
->condition($table . '.gid', $gid)
->condition($table . '.realm', $realm)
);
}
}
$this->query->add_where('AND', $grants);
$this->query->add_where('AND', $table . '.grant_view', 1, '>=');
}
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* @file
* Definition of views_handler_filter_node_status.
*/
/**
* Filter by published status.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_node_status extends views_handler_filter {
function admin_summary() { }
function operator_form(&$form, &$form_state) { }
function can_expose() { return FALSE; }
function query() {
$table = $this->ensure_my_table();
$this->query->add_where_expression($this->options['group'], "$table.status = 1 OR ($table.uid = ***CURRENT_USER*** AND ***CURRENT_USER*** <> 0 AND ***VIEW_OWN_UNPUBLISHED_NODES*** = 1) OR ***BYPASS_NODE_ACCESS*** = 1");
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* Definition of views_handler_filter_node_type.
*/
/**
* Filter by node type.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_node_type extends views_handler_filter_in_operator {
function get_value_options() {
if (!isset($this->value_options)) {
$this->value_title = t('Content types');
$types = node_type_get_types();
$options = array();
foreach ($types as $type => $info) {
$options[$type] = t($info->name);
}
asort($options);
$this->value_options = $options;
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* @file
* Definition of views_handler_filter_node_uid_revision.
*/
/**
* Filter handler to check for revisions a certain user has created.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_node_uid_revision extends views_handler_filter_user_name {
function query($group_by = FALSE) {
$this->ensure_my_table();
$placeholder = $this->placeholder();
$args = array_values($this->value);
$this->query->add_where_expression($this->options['group'], "$this->table_alias.uid IN($placeholder) " . $condition . " OR
((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid IN($placeholder) AND nr.nid = $this->table_alias.nid) > 0)", array($placeholder => $args),
$args);
}
}

View File

@@ -0,0 +1,26 @@
<?php
/**
* @file
* Contains the node from URL argument default plugin.
*/
/**
* 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 views_plugin_argument_default {
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);
}
}
}

View File

@@ -0,0 +1,135 @@
<?php
/**
* @file
* Contains the 'node' argument validator plugin.
*/
/**
* Validate whether an argument is an acceptable node.
*/
class views_plugin_argument_validate_node extends views_plugin_argument_validate {
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'],
'#dependency' => array('edit-options-validate-options-node-access' => array(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->title);
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();
$result = db_query("SELECT * FROM {node} WHERE nid IN (:nids)", array(':nids' => $nids->value));
foreach ($result 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->title);
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);
}
}
}

View File

@@ -0,0 +1,174 @@
<?php
/**
* @file
* Contains the node RSS row style plugin.
*/
/**
* Plugin which performs a node_view on the resulting object
* and formats it as an RSS item.
*/
class views_plugin_row_node_rss extends views_plugin_row {
// 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 = variable_get('feed_item_length', 'teaser');
}
// Load the specified node:
$node = $this->nodes[$nid];
if (empty($node)) {
return;
}
$item_text = '';
$uri = entity_uri('node', $node);
$node->link = url($uri['path'], $uri['options'] + array('absolute' => TRUE));
$node->rss_namespaces = array();
$node->rss_elements = array(
array(
'key' => 'pubDate',
'value' => gmdate('r', $node->created),
),
array(
'key' => 'dc:creator',
'value' => $node->name,
),
array(
'key' => 'guid',
'value' => $node->nid . ' at ' . $base_url,
'attributes' => array('isPermaLink' => 'false'),
),
);
// The node gets built and modules add to or modify $node->rss_elements
// and $node->rss_namespaces.
$build_mode = $display_mode;
$build = node_view($node, $build_mode);
unset($build['#theme']);
if (!empty($node->rss_namespaces)) {
$this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces);
}
elseif (function_exists('rdf_get_namespaces')) {
// Merge RDF namespaces in the XML namespaces in case they are used
// further in the RSS content.
$xml_rdf_namespaces = array();
foreach (rdf_get_namespaces() as $prefix => $uri) {
$xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
}
$this->view->style_plugin->namespaces += $xml_rdf_namespaces;
}
// Hide the links if desired.
if (!$this->options['links']) {
hide($build['links']);
}
if ($display_mode != 'title') {
// We render node 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 = $node->title;
$item->link = $node->link;
$item->elements = $node->rss_elements;
$item->nid = $node->nid;
return theme($this->theme_functions(), array(
'view' => $this->view,
'options' => $this->options,
'row' => $item
));
}
}

View File

@@ -0,0 +1,110 @@
<?php
/**
* @file
* Contains the node view row style plugin.
*/
/**
* Plugin which performs a node_view on the resulting object.
*
* Most of the code on this object is in the theme function.
*
* @ingroup views_row_plugins
*/
class views_plugin_row_node_view extends views_plugin_row {
// 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 init(&$view, &$display, $options = NULL) {
parent::init($view, $display, $options);
// Handle existing views with the deprecated 'teaser' option.
if (isset($this->options['teaser'])) {
$this->options['build_mode'] = $this->options['teaser'] ? 'teaser' : 'full';
}
// Handle existing views which has used build_mode instead of view_mode.
if (isset($this->options['build_mode'])) {
$this->options['view_mode'] = $this->options['build_mode'];
}
}
function option_definition() {
$options = parent::option_definition();
$options['view_mode'] = array('default' => 'teaser');
$options['links'] = array('default' => TRUE, 'bool' => TRUE);
$options['comments'] = array('default' => FALSE, 'bool' => TRUE);
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'],
);
$form['comments'] = array(
'#type' => 'checkbox',
'#title' => t('Display comments'),
'#default_value' => $this->options['comments'],
);
}
/**
* 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'];
}
}
if (empty($options)) {
$options = array(
'teaser' => t('Teaser'),
'full' => t('Full content')
);
}
return $options;
}
function summary_title() {
$options = $this->options_form_summary_options();
return check_plain($options[$this->options['view_mode']]);
}
function pre_render($values) {
$nids = array();
foreach ($values as $row) {
$nids[] = $row->{$this->field_alias};
}
$this->nodes = node_load_multiple($nids);
}
function render($row) {
if (isset($this->nodes[$row->{$this->field_alias}])) {
$node = $this->nodes[$row->{$this->field_alias}];
$node->view = $this->view;
$build = node_view($node, $this->options['view_mode']);
return drupal_render($build);
}
}
}