class ctools_context_optional

  1. cis7 sites/all/modules/ulmus/ctools/includes/context.inc ctools_context_optional
  2. cle7 sites/all/modules/ulmus/ctools/includes/context.inc ctools_context_optional
  3. elmsmedia7 sites/all/modules/ulmus/ctools/includes/context.inc ctools_context_optional
  4. icor7 sites/all/modules/ulmus/ctools/includes/context.inc ctools_context_optional
  5. meedjum_blog7 sites/all/modules/ulmus/ctools/includes/context.inc ctools_context_optional
  6. mooc7 sites/all/modules/ulmus/ctools/includes/context.inc ctools_context_optional

Used to compare to see if a list of contexts match an optional context. This can produce empty contexts to use as placeholders.

Hierarchy

Expanded class hierarchy of ctools_context_optional

Members

Contains filters are case sensitive

File

sites/all/modules/ulmus/ctools/includes/context.inc, line 200
Contains code related to the ctools system of 'context'.

View source
class ctools_context_optional extends ctools_context_required {
  var $required = FALSE;
  function ctools_context_optional() {
    $args = func_get_args();
    call_user_func_array(array($this, 'ctools_context_required'), $args);
  }

  /**
   * Add the 'empty' context which is possible for optional
   */
  function add_empty(&$contexts) {
    $context = new ctools_context('any');
    $context->title = t('No context');
    $context->identifier = t('No context');
    $contexts = array_merge(array('empty' => $context), $contexts);
  }

  function filter($contexts) {
    $this->add_empty($contexts);
    return parent::filter($contexts);
  }

  function select($contexts, $context) {
    $this->add_empty($contexts);
    if (empty($context)) {
      return $contexts['empty'];
    }

    $result = parent::select($contexts, $context);

    // Don't flip out if it can't find the context; this is optional, put
    // in an empty.
    if ($result == FALSE) {
      $result = $contexts['empty'];
    }
    return $result;
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.