[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/ctools/ctools_plugin_example/plugins/relationships/ -> relcontext_from_simplecontext.inc (source)

   1  <?php
   2  // $Id: relcontext_from_simplecontext.inc,v 1.1.2.1 2010/01/29 19:54:02 merlinofchaos Exp $
   3  
   4  
   5  /**
   6   * @file
   7   *
   8   * Sample relationship plugin.
   9   *
  10   * We take a simplecontext, look in it for what we need to make a relcontext, and make it.
  11   * In the real world, this might be getting a taxonomy id from a node, for example.
  12   */
  13  
  14  /**
  15   * Plugins are described by creating a $plugin array which will be used
  16   * by the system that includes this file.
  17   */
  18  $plugin = array(
  19    'title' => t("Relcontext from simplecontext"),
  20    'keyword' => 'relcontext',
  21    'description' => t('Adds a relcontext from existing simplecontext.'),
  22    'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'),
  23    'context' => 'ctools_relcontext_from_simplecontext_context',
  24    'settings form' => 'ctools_relcontext_from_simplecontext_settings_form',
  25  );
  26  
  27  /**
  28   * Return a new context based on an existing context.
  29   */
  30  function ctools_relcontext_from_simplecontext_context($context = NULL, $conf) {
  31    // If unset it wants a generic, unfilled context, which is just NULL.
  32    if (empty($context->data)) {
  33      return ctools_context_create_empty('relcontext', NULL);
  34    }
  35  
  36    // You should do error-checking here.
  37  
  38    // Create the new context from some element of the parent context.
  39    // In this case, we'll pass in the whole context so it can be used to
  40    // create the relcontext.
  41    return ctools_context_create('relcontext', $context);
  42  }
  43  
  44  /**
  45   * Settings form for the relationship.
  46   */
  47  function ctools_relcontext_from_simplecontext_settings_form($conf) {
  48    // We won't configure it in this case.
  49    return array();
  50  }
  51  


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