2009-05-17 11:16:51 +00:00
< ? php
/**
* @ file
* Provide views data and handlers for node . module .
*
* @ ingroup views_module_handlers
*/
2012-06-17 09:53:13 +00:00
use Drupal\views\Analyzer ;
2013-01-10 17:14:16 +00:00
use Drupal\views\ViewExecutable ;
2012-06-17 09:53:13 +00:00
2009-05-17 11:16:51 +00:00
/**
* Implements hook_views_data () .
*/
function node_views_data () {
// node table -- basic table information.
// Define the base group of this table. Fields that don't
// have a group defined will go into this field by default.
$data [ 'node' ][ 'table' ][ 'group' ] = t ( 'Content' );
// Advertise this table as a possible base table
$data [ 'node' ][ 'table' ][ 'base' ] = array (
'field' => 'nid' ,
'title' => t ( 'Content' ),
'weight' => - 10 ,
'access query tag' => 'node_access' ,
'defaults' => array (
'field' => 'title' ,
),
);
$data [ 'node' ][ 'table' ][ 'entity type' ] = 'node' ;
2012-11-29 06:20:24 +00:00
$data [ 'node' ][ 'table' ][ 'wizard_id' ] = 'node' ;
2009-05-17 11:16:51 +00:00
// node table -- fields
// nid
$data [ 'node' ][ 'nid' ] = array (
'title' => t ( 'Nid' ),
'help' => t ( 'The node ID.' ), // The help that appears on the UI,
// Information for displaying the nid
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node' ,
2009-05-17 11:16:51 +00:00
),
// Information for accepting a nid as an argument
'argument' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node_nid' ,
2009-05-17 11:16:51 +00:00
'name field' => 'title' , // the field to display in the summary.
'numeric' => TRUE ,
'validate type' => 'nid' ,
),
// Information for accepting a nid as a filter
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'numeric' ,
2009-05-17 11:16:51 +00:00
),
// Information for sorting on a nid.
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
);
// title
// This definition has more items in it than it needs to as an example.
$data [ 'node' ][ 'title' ] = array (
'title' => t ( 'Title' ), // The item it appears as on the UI,
'help' => t ( 'The content title.' ), // The help that appears on the UI,
// Information for displaying a title as a field
'field' => array (
'field' => 'title' , // the real field. This could be left out since it is the same.
'group' => t ( 'Content' ), // The group it appears in on the UI. Could be left out.
2012-08-11 11:46:07 +00:00
'id' => 'node' ,
2009-05-17 11:16:51 +00:00
'link_to_node default' => TRUE ,
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
// Information for accepting a title as a filter
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'string' ,
2009-05-17 11:16:51 +00:00
),
'argument' => array (
2012-08-11 11:46:07 +00:00
'id' => 'string' ,
2009-05-17 11:16:51 +00:00
),
);
// created field
$data [ 'node' ][ 'created' ] = array (
'title' => t ( 'Post date' ), // The item it appears as on the UI,
'help' => t ( 'The date the content was posted.' ), // The help that appears on the UI,
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date' ,
2009-05-17 11:16:51 +00:00
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date'
2009-05-17 11:16:51 +00:00
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date' ,
2009-05-17 11:16:51 +00:00
),
);
// changed field
$data [ 'node' ][ 'changed' ] = array (
'title' => t ( 'Updated date' ), // The item it appears as on the UI,
'help' => t ( 'The date the content was last updated.' ), // The help that appears on the UI,
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date' ,
2009-05-17 11:16:51 +00:00
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date'
2009-05-17 11:16:51 +00:00
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date' ,
2009-05-17 11:16:51 +00:00
),
);
// Content type
$data [ 'node' ][ 'type' ] = array (
'title' => t ( 'Type' ), // The item it appears as on the UI,
'help' => t ( 'The content type (for example, "blog entry", "forum post", "story", etc).' ), // The help that appears on the UI,
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node_type' ,
2009-05-17 11:16:51 +00:00
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
'filter' => array (
2013-02-06 12:42:57 +00:00
'id' => 'bundle' ,
2009-05-17 11:16:51 +00:00
),
'argument' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node_type' ,
2009-05-17 11:16:51 +00:00
),
);
// published status
$data [ 'node' ][ 'status' ] = array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Published status' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Whether or not the content is published.' ),
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'boolean' ,
2009-05-17 11:16:51 +00:00
'output formats' => array (
'published-notpublished' => array ( t ( 'Published' ), t ( 'Not published' )),
),
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'boolean' ,
2013-02-09 22:07:15 +00:00
'label' => t ( 'Published status' ),
2009-05-17 11:16:51 +00:00
'type' => 'yes-no' ,
2012-08-12 00:10:20 +00:00
'use_equal' => TRUE , // Use status = 1 instead of status <> 0 in WHERE statment
2009-05-17 11:16:51 +00:00
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
);
// published status + extra
$data [ 'node' ][ 'status_extra' ] = array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Published status or admin user' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Filters out unpublished content if the current user cannot view it.' ),
'filter' => array (
'field' => 'status' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_status' ,
2013-02-09 22:07:15 +00:00
'label' => t ( 'Published status or admin user' ),
2009-05-17 11:16:51 +00:00
),
);
// promote status
$data [ 'node' ][ 'promote' ] = array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Promoted to front page status' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Whether or not the content is promoted to the front page.' ),
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'boolean' ,
2009-05-17 11:16:51 +00:00
'output formats' => array (
'promoted-notpromoted' => array ( t ( 'Promoted' ), t ( 'Not promoted' )),
),
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'boolean' ,
2013-02-09 22:07:15 +00:00
'label' => t ( 'Promoted to front page status' ),
2009-05-17 11:16:51 +00:00
'type' => 'yes-no' ,
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
);
// sticky
$data [ 'node' ][ 'sticky' ] = array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Sticky status' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Whether or not the content is sticky.' ), // The help that appears on the UI,
// Information for displaying a title as a field
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'boolean' ,
2009-05-17 11:16:51 +00:00
'output formats' => array (
'sticky' => array ( t ( 'Sticky' ), t ( 'Not sticky' )),
),
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'boolean' ,
2013-02-09 22:07:15 +00:00
'label' => t ( 'Sticky status' ),
2009-05-17 11:16:51 +00:00
'type' => 'yes-no' ,
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
'help' => t ( 'Whether or not the content is sticky. To list sticky content first, set this to descending.' ),
),
);
2012-08-26 19:44:59 +00:00
// Language field
if ( module_exists ( 'language' )) {
$data [ 'node' ][ 'langcode' ] = array (
'title' => t ( 'Language' ),
'help' => t ( 'The language the content is in.' ),
'field' => array (
'id' => 'node_language' ,
),
'filter' => array (
'id' => 'language' ,
),
'argument' => array (
'id' => 'language' ,
),
'sort' => array (
'id' => 'standard' ,
),
);
}
2013-01-25 20:32:06 +00:00
// Entity translation field.
if ( drupal_container () -> get ( 'module_handler' ) -> moduleExists ( 'translation_entity' )) {
$data [ 'node' ][ 'translation_link' ] = array (
'title' => t ( 'Translation link' ),
'help' => t ( 'Provide a link to the translations overview for nodes.' ),
'field' => array (
'id' => 'translation_entity_link' ,
),
);
}
2009-05-17 11:16:51 +00:00
// Define some fields based upon views_handler_field_entity in the entity
// table so they can be re-used with other query backends.
// @see views_handler_field_entity
2012-07-16 08:02:23 +00:00
$data [ 'views_entity_node' ][ 'table' ][ 'group' ] = t ( 'Content' );
2009-05-17 11:16:51 +00:00
$data [ 'views_entity_node' ][ 'view_node' ] = array (
'field' => array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Link to content' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Provide a simple link to the content.' ),
2012-08-11 11:46:07 +00:00
'id' => 'node_link' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'views_entity_node' ][ 'edit_node' ] = array (
'field' => array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Link to edit content' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Provide a simple link to edit the content.' ),
2012-08-11 11:46:07 +00:00
'id' => 'node_link_edit' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'views_entity_node' ][ 'delete_node' ] = array (
'field' => array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Link to delete content' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Provide a simple link to delete the content.' ),
2012-08-11 11:46:07 +00:00
'id' => 'node_link_delete' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'path' ] = array (
'field' => array (
'title' => t ( 'Path' ),
'help' => t ( 'The aliased path to this content.' ),
2012-08-11 11:46:07 +00:00
'id' => 'node_path' ,
2009-05-17 11:16:51 +00:00
),
);
// Bogus fields for aliasing purposes.
$data [ 'node' ][ 'created_fulldate' ] = array (
'title' => t ( 'Created date' ),
'help' => t ( 'Date in the form of CCYYMMDD.' ),
'argument' => array (
'field' => 'created' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_fulldate' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'created_year_month' ] = array (
'title' => t ( 'Created year + month' ),
'help' => t ( 'Date in the form of YYYYMM.' ),
'argument' => array (
'field' => 'created' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_year_month' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'created_year' ] = array (
'title' => t ( 'Created year' ),
'help' => t ( 'Date in the form of YYYY.' ),
'argument' => array (
'field' => 'created' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_year' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'created_month' ] = array (
'title' => t ( 'Created month' ),
'help' => t ( 'Date in the form of MM (01 - 12).' ),
'argument' => array (
'field' => 'created' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_month' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'created_day' ] = array (
'title' => t ( 'Created day' ),
'help' => t ( 'Date in the form of DD (01 - 31).' ),
'argument' => array (
'field' => 'created' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_day' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'created_week' ] = array (
'title' => t ( 'Created week' ),
'help' => t ( 'Date in the form of WW (01 - 53).' ),
'argument' => array (
'field' => 'created' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_week' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'changed_fulldate' ] = array (
'title' => t ( 'Updated date' ),
'help' => t ( 'Date in the form of CCYYMMDD.' ),
'argument' => array (
'field' => 'changed' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_fulldate' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'changed_year_month' ] = array (
'title' => t ( 'Updated year + month' ),
'help' => t ( 'Date in the form of YYYYMM.' ),
'argument' => array (
'field' => 'changed' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_year_month' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'changed_year' ] = array (
'title' => t ( 'Updated year' ),
'help' => t ( 'Date in the form of YYYY.' ),
'argument' => array (
'field' => 'changed' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_year' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'changed_month' ] = array (
'title' => t ( 'Updated month' ),
'help' => t ( 'Date in the form of MM (01 - 12).' ),
'argument' => array (
'field' => 'changed' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_month' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'changed_day' ] = array (
'title' => t ( 'Updated day' ),
'help' => t ( 'Date in the form of DD (01 - 31).' ),
'argument' => array (
'field' => 'changed' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_day' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'changed_week' ] = array (
'title' => t ( 'Updated week' ),
'help' => t ( 'Date in the form of WW (01 - 53).' ),
'argument' => array (
'field' => 'changed' ,
2012-08-11 11:46:07 +00:00
'id' => 'node_created_week' ,
2009-05-17 11:16:51 +00:00
),
);
// uid field
$data [ 'node' ][ 'uid' ] = array (
'title' => t ( 'Author uid' ),
'help' => t ( 'The user authoring the content. If you need more fields than the uid add the content: author relationship' ),
'relationship' => array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Content author' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Relate content to the user who created it.' ),
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
'base' => 'users' ,
'field' => 'uid' ,
'label' => t ( 'author' ),
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'user_name' ,
2009-05-17 11:16:51 +00:00
),
'argument' => array (
2012-08-11 11:46:07 +00:00
'id' => 'numeric' ,
2009-05-17 11:16:51 +00:00
),
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'user' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node' ][ 'uid_revision' ] = array (
'title' => t ( 'User has a revision' ),
'help' => t ( 'All nodes where a certain user has a revision' ),
'real field' => 'nid' ,
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node_uid_revision' ,
2009-05-17 11:16:51 +00:00
),
'argument' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node_uid_revision' ,
2009-05-17 11:16:51 +00:00
),
);
// Content revision table
// Define the base group of this table. Fields that don't
// have a group defined will go into this field by default.
$data [ 'node_revision' ][ 'table' ][ 'entity type' ] = 'node' ;
$data [ 'node_revision' ][ 'table' ][ 'group' ] = t ( 'Content revision' );
2012-11-29 06:20:24 +00:00
$data [ 'node_revision' ][ 'table' ][ 'wizard_id' ] = 'node_revision' ;
2009-05-17 11:16:51 +00:00
// Advertise this table as a possible base table
$data [ 'node_revision' ][ 'table' ][ 'base' ] = array (
'field' => 'vid' ,
'title' => t ( 'Content revision' ),
'help' => t ( 'Content revision is a history of changes to content.' ),
'defaults' => array (
'field' => 'title' ,
),
);
// For other base tables, explain how we join
$data [ 'node_revision' ][ 'table' ][ 'join' ] = array (
// Directly links to node table.
'node' => array (
'left_field' => 'vid' ,
'field' => 'vid' ,
),
);
2013-02-09 22:07:15 +00:00
// UID field for node revision.
2009-05-17 11:16:51 +00:00
$data [ 'node_revision' ][ 'uid' ] = array (
'title' => t ( 'User' ),
'help' => t ( 'Relate a content revision to the user who created the revision.' ),
'relationship' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
'base' => 'users' ,
'base field' => 'uid' ,
'label' => t ( 'revision user' ),
),
);
// nid
2012-09-16 19:11:40 +00:00
$data [ 'node_revision' ][ 'nid' ] = array (
'title' => t ( 'Nid' ),
// The help that appears on the UI.
'help' => t ( 'The revision NID of the content revision.' ),
// Information for displaying the nid.
'field' => array (
2012-10-10 23:36:49 +00:00
'id' => 'standard' ,
2012-09-16 19:11:40 +00:00
),
// Information for accepting a nid as an argument.
'argument' => array (
'id' => 'node_nid' ,
'numeric' => TRUE ,
),
// Information for accepting a nid as a filter.
'filter' => array (
'id' => 'numeric' ,
),
// Information for sorting on a nid.
'sort' => array (
'id' => 'standard' ,
),
'relationship' => array (
'id' => 'standard' ,
'base' => 'node' ,
'base field' => 'nid' ,
'title' => t ( 'Content' ),
'label' => t ( 'Get the actual content from a content revision.' ),
),
);
// vid
2009-05-17 11:16:51 +00:00
$data [ 'node_revision' ][ 'vid' ] = array (
'title' => t ( 'Vid' ),
2012-09-16 19:11:40 +00:00
'help' => t ( 'The revision ID of the content revision.' ),
// Information for displaying the vid
2009-05-17 11:16:51 +00:00
'field' => array (
2012-10-10 23:36:49 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
2012-09-16 19:11:40 +00:00
// Information for accepting a vid as an argument
2009-05-17 11:16:51 +00:00
'argument' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node_vid' ,
2009-05-17 11:16:51 +00:00
'numeric' => TRUE ,
),
2012-09-16 19:11:40 +00:00
// Information for accepting a vid as a filter
2009-05-17 11:16:51 +00:00
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'numeric' ,
2009-05-17 11:16:51 +00:00
),
2012-09-16 19:11:40 +00:00
// Information for sorting on a vid.
2009-05-17 11:16:51 +00:00
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
'relationship' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
'base' => 'node' ,
'base field' => 'vid' ,
'title' => t ( 'Content' ),
'label' => t ( 'Get the actual content from a content revision.' ),
),
);
2012-09-25 19:09:00 +00:00
// published status
$data [ 'node_revision' ][ 'status' ] = array (
'title' => t ( 'Published' ),
'help' => t ( 'Whether or not the content is published.' ),
'field' => array (
'id' => 'boolean' ,
'output formats' => array (
'published-notpublished' => array ( t ( 'Published' ), t ( 'Not published' )),
),
),
'filter' => array (
'id' => 'boolean' ,
'label' => t ( 'Published' ),
'type' => 'yes-no' ,
'use_equal' => TRUE , // Use status = 1 instead of status <> 0 in WHERE statment
),
'sort' => array (
'id' => 'standard' ,
),
);
2009-05-17 11:16:51 +00:00
// title
$data [ 'node_revision' ][ 'title' ] = array (
'title' => t ( 'Title' ), // The item it appears as on the UI,
'help' => t ( 'The content title.' ), // The help that appears on the UI,
// Information for displaying a title as a field
'field' => array (
'field' => 'title' , // the real field
2012-08-11 11:46:07 +00:00
'id' => 'node_revision' ,
2009-05-17 11:16:51 +00:00
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'standard' ,
2009-05-17 11:16:51 +00:00
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'string' ,
2009-05-17 11:16:51 +00:00
),
'argument' => array (
2012-08-11 11:46:07 +00:00
'id' => 'string' ,
2009-05-17 11:16:51 +00:00
),
);
// log field
$data [ 'node_revision' ][ 'log' ] = array (
'title' => t ( 'Log message' ), // The item it appears as on the UI,
'help' => t ( 'The log message entered when the revision was created.' ), // The help that appears on the UI,
// Information for displaying a title as a field
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'xss' ,
2009-05-17 11:16:51 +00:00
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'string' ,
2009-05-17 11:16:51 +00:00
),
);
// revision timestamp
// changed field
$data [ 'node_revision' ][ 'timestamp' ] = array (
'title' => t ( 'Updated date' ), // The item it appears as on the UI,
'help' => t ( 'The date the node was last updated.' ), // The help that appears on the UI,
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date' ,
2009-05-17 11:16:51 +00:00
),
'sort' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date'
2009-05-17 11:16:51 +00:00
),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'date' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node_revision' ][ 'link_to_revision' ] = array (
'field' => array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Link to revision' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Provide a simple link to the revision.' ),
2012-08-11 11:46:07 +00:00
'id' => 'node_revision_link' ,
2013-01-21 20:59:01 +00:00
'click sortable' => FALSE ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node_revision' ][ 'revert_revision' ] = array (
'field' => array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Link to revert revision' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Provide a simple link to revert to the revision.' ),
2012-08-11 11:46:07 +00:00
'id' => 'node_revision_link_revert' ,
2013-01-21 20:59:01 +00:00
'click sortable' => FALSE ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'node_revision' ][ 'delete_revision' ] = array (
'field' => array (
2013-02-09 22:07:15 +00:00
'title' => t ( 'Link to delete revision' ),
2009-05-17 11:16:51 +00:00
'help' => t ( 'Provide a simple link to delete the content revision.' ),
2012-08-11 11:46:07 +00:00
'id' => 'node_revision_link_delete' ,
2013-01-21 20:59:01 +00:00
'click sortable' => FALSE ,
2009-05-17 11:16:51 +00:00
),
);
// Node access table
// Define the base group of this table. Fields that don't
// have a group defined will go into this field by default.
$data [ 'node_access' ][ 'table' ][ 'group' ] = t ( 'Content access' );
// For other base tables, explain how we join
$data [ 'node_access' ][ 'table' ][ 'join' ] = array (
// Directly links to node table.
'node' => array (
'left_field' => 'nid' ,
'field' => 'nid' ,
),
);
// nid field
$data [ 'node_access' ][ 'nid' ] = array (
'title' => t ( 'Access' ),
'help' => t ( 'Filter by access.' ),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'node_access' ,
2009-05-17 11:16:51 +00:00
'help' => t ( 'Filter for content by view access. <strong>Not necessary if you are using node as your base table.</strong>' ),
),
);
return $data ;
}
/**
* Implements hook_preprocess_node () .
*/
function node_row_node_view_preprocess_node ( & $vars ) {
$node = $vars [ 'node' ];
2013-02-18 11:04:51 +00:00
$options = $vars [ 'view' ] -> rowPlugin -> options ;
2009-05-17 11:16:51 +00:00
// Prevent the comment form from showing up if this is not a page display.
2012-08-30 09:23:13 +00:00
if ( $vars [ 'view_mode' ] == 'full' && ! $vars [ 'view' ] -> display_handler -> hasPath ()) {
2009-05-17 11:16:51 +00:00
$node -> comment = FALSE ;
}
if ( ! $options [ 'links' ]) {
unset ( $vars [ 'content' ][ 'links' ]);
}
if ( ! empty ( $options [ 'comments' ]) && user_access ( 'access comments' ) && $node -> comment ) {
$vars [ 'content' ][ 'comments' ] = comment_node_page_additions ( $node );
}
}
/**
* Implements hook_views_query_substitutions () .
*/
function node_views_query_substitutions () {
return array (
'***ADMINISTER_NODES***' => intval ( user_access ( 'administer nodes' )),
'***VIEW_OWN_UNPUBLISHED_NODES***' => intval ( user_access ( 'view own unpublished content' )),
'***BYPASS_NODE_ACCESS***' => intval ( user_access ( 'bypass node access' )),
);
}
/**
* Implements hook_views_analyze () .
*/
2013-01-10 17:14:16 +00:00
function node_views_analyze ( ViewExecutable $view ) {
2009-05-17 11:16:51 +00:00
$ret = array ();
// Check for something other than the default display:
2013-01-10 17:14:16 +00:00
if ( $view -> storage -> get ( 'base_table' ) == 'node' ) {
2012-09-21 05:53:42 +00:00
foreach ( $view -> displayHandlers as $id => $display ) {
if ( ! $display -> isDefaulted ( 'access' ) || ! $display -> isDefaulted ( 'filters' )) {
2009-05-17 11:16:51 +00:00
// check for no access control
2012-09-21 05:53:42 +00:00
$access = $display -> getOption ( 'access' );
2009-05-17 11:16:51 +00:00
if ( empty ( $access [ 'type' ]) || $access [ 'type' ] == 'none' ) {
Issue #1479454 by Hugo Wetterberg, galooph, andypost, marcingy, heyrocker, larowlan, alexpott, tim.plunkett, fubhy, sun, dawehner: Convert user roles to configurables.
2013-01-19 21:53:56 +00:00
$result = db_select ( 'role_permission' , 'p' )
-> fields ( 'p' , array ( 'rid' , 'permission' ))
-> condition ( 'p.rid' , array ( DRUPAL_ANONYMOUS_RID , DRUPAL_AUTHENTICATED_RID ), 'IN' )
2009-05-17 11:16:51 +00:00
-> condition ( 'p.permission' , 'access content' )
-> execute ();
foreach ( $result as $role ) {
$role -> safe = TRUE ;
2012-06-10 16:36:09 +00:00
$roles [ $role -> rid ] = $role ;
2009-05-17 11:16:51 +00:00
}
Issue #1479454 by Hugo Wetterberg, galooph, andypost, marcingy, heyrocker, larowlan, alexpott, tim.plunkett, fubhy, sun, dawehner: Convert user roles to configurables.
2013-01-19 21:53:56 +00:00
if ( ! ( $roles [ DRUPAL_ANONYMOUS_RID ] -> safe && $roles [ DRUPAL_AUTHENTICATED_RID ] -> safe )) {
2013-01-10 17:14:16 +00:00
$ret [] = Analyzer :: formatMessage ( t ( 'Some roles lack permission to access content, but display %display has no access control.' , array ( '%display' => $display -> display [ 'display_title' ])), 'warning' );
2009-05-17 11:16:51 +00:00
}
2012-09-21 05:53:42 +00:00
$filters = $display -> getOption ( 'filters' );
2009-05-17 11:16:51 +00:00
foreach ( $filters as $filter ) {
if ( $filter [ 'table' ] == 'node' && ( $filter [ 'field' ] == 'status' || $filter [ 'field' ] == 'status_extra' )) {
continue 2 ;
}
}
2013-01-10 17:14:16 +00:00
$ret [] = Analyzer :: formatMessage ( t ( 'Display %display has no access control but does not contain a filter for published nodes.' , array ( '%display' => $display -> display [ 'display_title' ])), 'warning' );
2009-05-17 11:16:51 +00:00
}
}
}
}
2013-01-10 17:14:16 +00:00
foreach ( $view -> displayHandlers as $display ) {
2012-09-21 05:53:42 +00:00
if ( $display -> getPluginId () == 'page' ) {
if ( $display -> getOption ( 'path' ) == 'node/%' ) {
2013-01-10 17:14:16 +00:00
$ret [] = Analyzer :: formatMessage ( t ( 'Display %display has set node/% as path. This will not produce what you want. If you want to have multiple versions of the node view, use panels.' , array ( '%display' => $display -> display [ 'display_title' ])), 'warning' );
2009-05-17 11:16:51 +00:00
}
}
}
return $ret ;
}
2012-07-14 19:09:49 +00:00
/**
* Implements hook_views_wizard () .
*/
function node_views_wizard () {
2012-07-28 23:20:10 +00:00
// @todo: figure this piece out.
2012-07-14 19:09:49 +00:00
if ( module_exists ( 'statistics' )) {
$plugins [ 'node' ][ 'available_sorts' ][ 'node_counter-totalcount:DESC' ] = t ( 'Number of hits' );
}
}