You are here

function node_views_tables in Views (for Drupal 7) 5

This include file implements views functionality on behalf of node.module

File

modules/views_node.inc, line 7

Code

function node_views_tables() {
  $tables['node'] = array(
    'name' => 'node',
    'provider' => 'internal',
    // won't show up in external list.
    'fields' => array(
      'title' => array(
        'name' => t('Node: Title'),
        'handler' => array(
          'views_handler_field_nodelink' => t('Normal'),
          'views_handler_field_nodelink_with_mark' => t('With updated mark'),
        ),
        'option' => array(
          '#type' => 'select',
          '#options' => array(
            'link' => 'As link',
            'nolink' => 'Without link',
          ),
        ),
        'sortable' => true,
        'addlfields' => array(
          'changed',
        ),
        'help' => t('Display the title of the node.'),
      ),
      'nid' => array(
        'name' => t('Node: ID'),
        'sortable' => true,
        'notafield' => true,
        'handler' => 'views_handler_node_nid',
        'sort_handler' => 'views_node_query_handler_nid',
        'help' => t('Display the NID of a node.'),
      ),
      'created' => array(
        'name' => t('Node: Created Time'),
        'sortable' => true,
        'handler' => views_handler_field_dates(),
        'option' => 'string',
        'help' => t('Display the post time of the node.') . ' ' . t('The option field may be used to specify the custom date format as it\'s required by the date() function or if "as time ago" has been chosen to customize the granularity of the time interval.'),
      ),
      'changed' => array(
        'name' => t('Node: Updated Time'),
        'sortable' => true,
        'handler' => views_handler_field_dates(),
        'option' => 'string',
        'help' => t('Display the last time the node was updated.') . ' ' . t('The option field may be used to specify the custom date format as it\'s required by the date() function or if "as time ago" has been chosen to customize the granularity of the time interval.'),
      ),
      'type' => array(
        'name' => t('Node: Type'),
        'handler' => 'views_handler_nodetype',
        'sortable' => true,
        'help' => t("The Node Type field will display the type of a node (for example, 'blog entry', 'forum post', 'story', etc)"),
      ),
      'link' => array(
        'name' => t('Node: Link to node'),
        'handler' => 'views_handler_field_node_link',
        'sortable' => false,
        'option' => 'string',
        'notafield' => 'true',
        'help' => t("This will create a link to the node; fill the option field with the text for the link. If you want titles that link to the node, use Node: Title instead."),
      ),
      'body' => array(
        'name' => t('Node: Body'),
        'handler' => array(
          'views_handler_field_body' => t('Full Text'),
          'views_handler_field_teaser' => t('Teaser'),
        ),
        'addlfields' => array(
          'nid',
        ),
        'notafield' => TRUE,
        'help' => t('Display the Main Content.'),
      ),
      'view' => array(
        'name' => t('Node: View link'),
        'handler' => 'views_handler_node_view',
        'notafield' => TRUE,
        'option' => 'string',
        'help' => t('Display a link to view the node. Enter the text of this link into the option field; if blank the default "View" will be used.'),
      ),
      'edit' => array(
        'name' => t('Node: Edit link'),
        'handler' => array(
          'views_handler_node_edit_destination' => t('Return To View'),
          'views_handler_node_edit' => t('Return to Node'),
        ),
        'notafield' => TRUE,
        'addlfields' => array(
          'type',
          'uid',
        ),
        'option' => 'string',
        'help' => t('Display a link to edit the node. Enter the text of this link into the option field; if blank the default "Edit" will be used.'),
      ),
      'delete' => array(
        'name' => t('Node: Delete link'),
        'handler' => array(
          'views_handler_node_delete_destination' => t('Return To View'),
          'views_handler_node_delete' => t('Return To The Frontpage'),
        ),
        'notafield' => TRUE,
        'addlfields' => array(
          'type',
          'uid',
        ),
        'option' => 'string',
        'help' => t('Display a link to delete the node. Enter the text of this link into the option field; if blank the default "Delete" will be used.'),
      ),
    ),
    'sorts' => array(
      'nid' => array(
        'name' => t('Node: ID'),
        'help' => t('Sort by the database ID of the node.'),
        'handler' => 'views_node_sort_handler_nid',
      ),
      'created' => array(
        'name' => t('Node: Created Time'),
        'handler' => 'views_handler_sort_date',
        'option' => views_handler_sort_date_options(),
        'help' => t('Sort by the submission date of the node.'),
      ),
      'changed' => array(
        'name' => t('Node: Updated Time'),
        'handler' => 'views_handler_sort_date',
        'option' => views_handler_sort_date_options(),
        'help' => t('Sort by the last update date of the node.'),
      ),
      'sticky' => array(
        'name' => t('Node: Sticky'),
        'help' => t('Sort by whether or not the node is sticky. Choose descending to put sticky nodes at the top.'),
      ),
      'title' => array(
        'name' => t('Node: Title'),
        'help' => t('Sort by the node title, alphabetically'),
      ),
      'type' => array(
        'name' => t('Node: Type'),
        'help' => t('Sort by the node type, alphabetically'),
      ),
      'random' => array(
        'name' => t('Random'),
        'handler' => 'views_handler_sort_random',
        'help' => t('By choosing random, nodes will be ordered completely randomly. This is a good way to choose X random nodes from a group of nodes.'),
      ),
    ),
    'filters' => array(
      'status' => array(
        'name' => t('Node: Published'),
        'operator' => array(
          '=' => t('Equals'),
        ),
        'list' => 'views_handler_operator_yesno',
        'list-type' => 'select',
        'help' => t('Filter by whether or not the node is published. This is recommended for most Views!'),
      ),
      'promote' => array(
        'name' => t('Node: Front Page'),
        'operator' => array(
          '=' => t('Equals'),
        ),
        'list' => 'views_handler_operator_yesno',
        'list-type' => 'select',
        'help' => t('Filter by whether or not the node has been promoted to Front Page.'),
      ),
      'sticky' => array(
        'name' => t('Node: Sticky'),
        'operator' => array(
          '=' => t('Equals'),
        ),
        'list' => 'views_handler_operator_yesno',
        'list-type' => 'select',
        'help' => t('Filter by whether or not the node is set sticky.'),
      ),
      'moderate' => array(
        'name' => t('Node: Moderated'),
        'operator' => array(
          '=' => t('Equals'),
        ),
        'list' => 'views_handler_operator_yesno',
        'list-type' => 'select',
        'help' => t('Filter by whether or not the node is moderated.'),
      ),
      'type' => array(
        'name' => t('Node: Type'),
        'list' => 'views_handler_filter_nodetype',
        'list-type' => 'list',
        'operator' => 'views_handler_operator_or',
        'value-type' => 'array',
        'help' => t('Include or exclude nodes of the selected types.'),
      ),
      'anon' => array(
        'field' => 'uid',
        'name' => t('Node: Author is Anonymous'),
        'operator' => 'views_handler_operator_eqneq',
        'list' => 'views_handler_filter_useranon',
        'value-type' => 'array',
        'help' => t('This allows you to filter by whether or not the node author is anonymous.'),
      ),
      'currentuid' => array(
        'field' => 'uid',
        'name' => t('Node: Author is Current User'),
        'operator' => 'views_handler_operator_eqneq',
        'list' => 'views_handler_filter_usercurrent',
        'list-type' => 'select',
        'help' => t('This allows you to filter by whether or not the node was authored by the logged in user of the view.'),
      ),
      'currentuidtouched' => array(
        'field' => 'uid',
        'name' => t('Node: Current User Authored or Commented'),
        'operator' => array(
          '=' => 'touched by',
        ),
        'list' => 'views_handler_filter_usercurrent',
        'list-type' => 'select',
        'handler' => 'views_handler_filter_uid_touched',
        'help' => t('This allows you to filter by whether or not the logged in user authored or commented on the node.'),
      ),
      'distinct' => array(
        'name' => t('Node: Distinct'),
        'operator' => array(
          '=' => 'is',
        ),
        'list' => array(
          'distinct' => 'distinct',
        ),
        'handler' => 'views_handler_filter_distinct',
        'value-type' => 'array',
        'help' => t('This filter ensures that each node may only be listed once, even if it matches multiple criteria. Use this if multiple taxonomy matches return duplicated nodes.'),
      ),
      'title' => array(
        'name' => t('Node: Title'),
        'operator' => 'views_handler_operator_like',
        'handler' => 'views_handler_filter_like',
        'help' => t('This filter allows nodes to be filtered by their title.'),
      ),
      'created' => array(
        'name' => t('Node: Created Time'),
        'operator' => 'views_handler_operator_gtlt',
        'value' => views_handler_filter_date_value_form(),
        'handler' => 'views_handler_filter_timestamp',
        'option' => 'string',
        'help' => t('This filter allows nodes to be filtered by their creation date.') . ' ' . views_t_strings('filter date'),
      ),
      'changed' => array(
        'name' => t('Node: Updated Time'),
        'operator' => 'views_handler_operator_gtlt',
        'value' => views_handler_filter_date_value_form(),
        'handler' => 'views_handler_filter_timestamp',
        'option' => 'string',
        'help' => t('This filter allows nodes to be filtered by the time they were updated.') . ' ' . views_t_strings('filter date'),
      ),
      'body' => array(
        'name' => t('Node: Body'),
        'operator' => 'views_handler_operator_like',
        'handler' => 'views_handler_filter_body',
        'help' => t('This filter allows nodes to be filtered by their body.'),
      ),
    ),
  );

  // By default history table assumes current user.
  $tables['history'] = array(
    'name' => 'history',
    'provider' => 'internal',
    'join' => array(
      'left' => array(
        'table' => 'node',
        'field' => 'nid',
      ),
      'right' => array(
        'field' => 'nid',
      ),
      'extra' => array(
        'uid' => '***CURRENT_USER***',
      ),
    ),
    'filters' => array(
      'timestamp' => array(
        'name' => t('Node: Has New Content'),
        'operator' => array(
          'Has',
        ),
        'list' => array(
          'New Content',
        ),
        'handler' => 'views_handler_filter_isnew',
        'value-type' => 'array',
        'help' => t('Including this filter will reduce the node set to nodes that have been updated or have new content since the user last read the node, as well as unread nodes.'),
      ),
    ),
  );
  return $tables;
}