[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/ctools/plugins/arguments/ -> rid.inc (source)

   1  <?php
   2  // $Id: rid.inc,v 1.1.2.1 2010/10/15 21:12:58 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   *
   7   * Plugin to provide an argument handler for a node revision id
   8   */
   9  
  10  /**
  11   * Plugins are described by creating a $plugin array which will be used
  12   * by the system that includes this file.
  13   */
  14  $plugin = array(
  15    'title' => t("Revision: ID"),
  16    'keyword' => 'revision',
  17    'description' => t('Creates a node context from a revision ID argument.'),
  18    'context' => 'ctools_argument_rid_context',
  19    'placeholder form' => array(
  20      '#type' => 'textfield',
  21      '#description' => t('Enter the revision ID of a node for this argument'),
  22    ),
  23  );
  24  
  25  /**
  26   * Discover if this argument gives us the node we crave.
  27   */
  28  function ctools_argument_rid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
  29    // If unset it wants a generic, unfilled context.
  30    if ($empty) {
  31      return ctools_context_create_empty('node');
  32    }
  33  
  34    // We can accept either a node object or a pure nid.
  35    if (is_object($arg)) {
  36      return ctools_context_create('node', $arg);
  37    }
  38  
  39    if (!is_numeric($arg)) {
  40      return FALSE;
  41    }
  42  
  43    $nid = db_result(db_query("SELECT nid FROM {node_revisions} WHERE vid = %d", $arg));
  44    $node = node_load($nid, $arg);
  45    if (!$node) {
  46      return FALSE;
  47    }
  48  
  49    return ctools_context_create('node', $node);
  50  }
  51  


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7