Projet

Général

Profil

Paste
Télécharger (1,48 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / ctools_plugin_example / plugins / relationships / relcontext_from_simplecontext.inc @ 7fe061e8

1
<?php
2

    
3

    
4
/**
5
 * @file
6
 *
7
 * Sample relationship plugin.
8
 *
9
 * We take a simplecontext, look in it for what we need to make a relcontext, and make it.
10
 * In the real world, this might be getting a taxonomy id from a node, for example.
11
 */
12

    
13
/**
14
 * Plugins are described by creating a $plugin array which will be used
15
 * by the system that includes this file.
16
 */
17
$plugin = array(
18
  'title' => t("Relcontext from simplecontext"),
19
  'keyword' => 'relcontext',
20
  'description' => t('Adds a relcontext from existing simplecontext.'),
21
  'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'),
22
  'context' => 'ctools_relcontext_from_simplecontext_context',
23
  'settings form' => 'ctools_relcontext_from_simplecontext_settings_form',
24
);
25

    
26
/**
27
 * Return a new context based on an existing context.
28
 */
29
function ctools_relcontext_from_simplecontext_context($context = NULL, $conf) {
30
  // If unset it wants a generic, unfilled context, which is just NULL.
31
  if (empty($context->data)) {
32
    return ctools_context_create_empty('relcontext', NULL);
33
  }
34

    
35
  // You should do error-checking here.
36

    
37
  // Create the new context from some element of the parent context.
38
  // In this case, we'll pass in the whole context so it can be used to
39
  // create the relcontext.
40
  return ctools_context_create('relcontext', $context);
41
}
42

    
43
/**
44
 * Settings form for the relationship.
45
 */
46
function ctools_relcontext_from_simplecontext_settings_form($conf) {
47
  // We won't configure it in this case.
48
  return array();
49
}
50