| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: relcontext.inc,v 1.1.2.1 2010/01/29 19:54:02 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * Sample ctools context type plugin that 7 * is used in this demo to create a relcontext from an existing simplecontext. 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("Relcontext"), 16 'description' => t('A relcontext object.'), 17 // Function to create the relcontext. 18 'context' => 'ctools_plugin_example_context_create_relcontext', 19 // Function that does the settings. 20 'settings form' => 'relcontext_settings_form', 21 'keyword' => 'relcontext', 22 'context name' => 'relcontext', 23 ); 24 25 /** 26 * Create a context, either from manual configuration (form) or from an argument on the URL. 27 * 28 * @param $empty 29 * If true, just return an empty context. 30 * @param $data 31 * If from settings form, an array as from a form. If from argument, a string. 32 * @param $conf 33 * TRUE if the $data is coming from admin configuration, FALSE if it's from a URL arg. 34 * 35 * @return 36 * a Context object. 37 */ 38 function ctools_plugin_example_context_create_relcontext($empty, $data = NULL, $conf = FALSE) { 39 $context = new ctools_context('relcontext'); 40 $context->plugin = 'relcontext'; 41 if ($empty) { 42 return $context; 43 } 44 if ($conf) { 45 if (!empty($data)) { 46 $context->data = new stdClass(); 47 // For this simple item we'll just create our data by stripping non-alpha and 48 // adding 'sample_relcontext_setting' to it. 49 $context->data->description = 'relcontext_from__' . preg_replace('/[^a-z]/i', '', $data['sample_relcontext_setting']); 50 $context->data->description .= '_from_configuration_sample_simplecontext_setting'; 51 $context->title = t("Relcontext context from simplecontext"); 52 return $context; 53 } 54 } 55 else { 56 // $data is coming from an arg - it's just a string. 57 // This is used for keyword. 58 $context->title = "relcontext_" . $data->data->description; 59 $context->argument = $data->argument; 60 // Make up a bogus context. 61 $context->data = new stdClass(); 62 // For this simple item we'll just create our data by stripping non-alpha and 63 // prepend 'relcontext_' and adding '_created_from_from_simplecontext' to it. 64 $context->data->description = 'relcontext_' . preg_replace('/[^a-z]/i', '', $data->data->description); 65 $context->data->description .= '_created_from_simplecontext'; 66 return $context; 67 } 68 } 69 70 function relcontext_settings_form($conf, $external = FALSE) { 71 $form = array(); 72 73 $form['sample_relcontext_setting'] = array( 74 '#type' => 'textfield', 75 '#title' => t('Relcontext setting'), 76 '#size' => 50, 77 '#description' => t('Just an example setting.'), 78 '#default_value' => !empty($conf['sample_relcontext_setting']) ? $conf['sample_relcontext_setting'] : '', 79 '#prefix' => '<div class="clear-block no-float">', 80 '#suffix' => '</div>', 81 ); 82 return $form; 83 } 84
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |