5 * Sample ctools context type plugin that
6 * is used in this demo to create a relcontext from an existing simplecontext.
10 * Plugins are described by creating a $plugin array which will be used
11 * by the system that includes this file.
14 'title' => t("Relcontext"),
15 'description' => t('A relcontext object.'),
16 // Function to create the relcontext.
17 'context' => 'ctools_plugin_example_context_create_relcontext',
18 // Function that does the settings.
19 'settings form' => 'relcontext_settings_form',
20 'keyword' => 'relcontext',
21 'context name' => 'relcontext',
25 * Create a context, either from manual configuration (form) or from an argument on the URL.
28 * If true, just return an empty context.
30 * If from settings form, an array as from a form. If from argument, a string.
32 * TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg.
37 function ctools_plugin_example_context_create_relcontext($empty, $data = NULL, $conf = FALSE) {
38 $context = new ctools_context('relcontext');
39 $context->plugin = 'relcontext';
45 $context->data = new stdClass();
46 // For this simple item we'll just create our data by stripping non-alpha and
47 // adding 'sample_relcontext_setting' to it.
48 $context->data->description = 'relcontext_from__' . preg_replace('/[^a-z]/i', '', $data['sample_relcontext_setting']);
49 $context->data->description .= '_from_configuration_sample_simplecontext_setting';
50 $context->title = t("Relcontext context from simplecontext");
55 // $data is coming from an arg - it's just a string.
56 // This is used for keyword.
57 $context->title = "relcontext_" . $data->data->description;
58 $context->argument = $data->argument;
59 // Make up a bogus context.
60 $context->data = new stdClass();
61 // For this simple item we'll just create our data by stripping non-alpha and
62 // prepend 'relcontext_' and adding '_created_from_from_simplecontext' to it.
63 $context->data->description = 'relcontext_' . preg_replace('/[^a-z]/i', '', $data->data->description);
64 $context->data->description .= '_created_from_simplecontext';
69 function relcontext_settings_form($conf, $external = FALSE) {
72 $form['sample_relcontext_setting'] = array(
73 '#type' => 'textfield',
74 '#title' => t('Relcontext setting'),
76 '#description' => t('Just an example setting.'),
77 '#default_value' => !empty($conf['sample_relcontext_setting']) ? $conf['sample_relcontext_setting'] : '',
78 '#prefix' => '<div class="clear-block no-float">',
79 '#suffix' => '</div>',