123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- $plugin = array(
- 'title' => t("Revision: ID"),
- 'keyword' => 'revision',
- 'description' => t('Creates a node context from a revision ID argument.'),
- 'context' => 'ctools_argument_rid_context',
- 'placeholder form' => array(
- '#type' => 'textfield',
- '#description' => t('Enter the revision ID of a node for this argument'),
- ),
- );
- function ctools_argument_rid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
-
- if ($empty) {
- return ctools_context_create_empty('node');
- }
-
- if (is_object($arg)) {
- return ctools_context_create('node', $arg);
- }
- if (!is_numeric($arg)) {
- return FALSE;
- }
- $nid = db_query('SELECT nid FROM {node_revision} WHERE vid = :vid', array(':vid' => $arg))->fetchField();
- $node = node_load($nid, $arg);
- if (!$node) {
- return FALSE;
- }
- return ctools_context_create('node', $node);
- }
|