You are here

class panels_optional_context in Panels 6.2

Same name and namespace in other branches
  1. 5.2 includes/plugins.inc \panels_optional_context
  2. 6.3 includes/plugins.inc \panels_optional_context

Hierarchy

Expanded class hierarchy of panels_optional_context

File

includes/plugins.inc, line 107
plugins.inc

View source
class panels_optional_context extends panels_required_context {
  function panels_optional_context() {
    $args = func_get_args();
    call_user_func_array(array(
      $this,
      'panels_required_context',
    ), $args);
  }

  /**
   * Add the 'empty' context which is possible for optional
   */
  function add_empty(&$contexts) {
    $context = new panels_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;
  }

}

Members