class ctools_context_optional

  1. nittany7 modules/contrib/ctools/includes/ ctools_context_optional
  2. cis7 modules/contrib/ctools/includes/ ctools_context_optional
  3. mooc7 modules/contrib/ctools/includes/ 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.


Expanded class hierarchy of ctools_context_optional


Contains filters are case sensitive


modules/contrib/ctools/includes/, 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) {
    return parent::filter($contexts);

  function select($contexts, $context) {
    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;