| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: simplecontext_arg.inc,v 1.1.2.1 2010/01/29 19:54:02 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * 7 * Sample plugin to provide an argument handler for a simplecontext. 8 * 9 * Given any argument to the page, simplecontext will get it 10 * and turn it into a piece of data (a "context") just by adding some text to it. 11 * Normally, the argument would be a key into some database (like the node 12 * database, for example, and the result of using the argument would be to load 13 * a specific "context" or data item that we can use elsewhere. 14 */ 15 16 /** 17 * Plugins are described by creating a $plugin array which will be used 18 * by the system that includes this file. 19 */ 20 $plugin = array( 21 'title' => t("Simplecontext arg"), 22 // keyword to use for %substitution 23 'keyword' => 'simplecontext', 24 'description' => t('Creates a "simplecontext" from the arg.'), 25 'context' => 'simplecontext_arg_context', 26 // 'settings form' => 'simplecontext_arg_settings_form', 27 28 // placeholder_form is used in panels preview, for example, so we can 29 // preview without getting the arg from a URL 30 'placeholder form' => array( 31 '#type' => 'textfield', 32 '#description' => t('Enter the simplecontext arg'), 33 ), 34 ); 35 36 /** 37 * Get the simplecontext context using the arg. In this case we're just going 38 * to manufacture the context from the data in the arg, but normally it would 39 * be an API call, db lookup, etc. 40 */ 41 function simplecontext_arg_context($arg = NULL, $conf = NULL, $empty = FALSE) { 42 // If $empty == TRUE it wants a generic, unfilled context. 43 if ($empty) { 44 return ctools_context_create_empty('simplecontext'); 45 } 46 // Do whatever error checking is required, returning FALSE if it fails the test 47 // Normally you'd check 48 // for a missing object, one you couldn't create, etc. 49 if (empty($arg)) { 50 return FALSE; 51 } 52 return ctools_context_create('simplecontext', $arg); 53 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |