[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/ctools/plugins/contexts/ -> string.inc (source)

   1  <?php
   2  // $Id: string.inc,v 1.5.2.3 2010/01/29 20:18:26 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   *
   7   * Plugin to provide a string context
   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('String'),
  16    'description' => t('A context that is just a string.'),
  17    'context' => 'ctools_context_create_string',
  18    'keyword' => 'string',
  19    'no ui' => TRUE,
  20    'context name' => 'string',
  21    'convert list' => array(
  22      'raw' => t('Raw string'),
  23      'html_safe' => t('HTML-safe string'),
  24    ),
  25    'convert' => 'ctools_context_string_convert',
  26    'placeholder form' => array(
  27      '#type' => 'textfield',
  28      '#description' => t('Enter the string for this context.'),
  29    ),
  30  );
  31  
  32  /**
  33   * It's important to remember that $conf is optional here, because contexts
  34   * are not always created from the UI.
  35   */
  36  function ctools_context_create_string($empty, $data = NULL, $conf = FALSE) {
  37    // The input is expected to be an object as created by ctools_break_phrase
  38    // which contains a group of string.
  39  
  40    $context = new ctools_context('string');
  41    $context->plugin = 'string';
  42  
  43    if ($empty) {
  44      return $context;
  45    }
  46  
  47    if ($data !== FALSE ) {
  48      $context->data = $data;
  49      $context->title = check_plain($data);
  50      return $context;
  51    }
  52  }
  53  
  54  /**
  55   * Convert a context into a string.
  56   */
  57  function ctools_context_string_convert($context, $type) {
  58    switch ($type) {
  59      case 'raw':
  60        return $context->data;
  61      case 'html_safe':
  62        return check_plain($context->data);
  63    }
  64  }
  65  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7