function views_object::export_option

3.x base.inc views_object::export_option($indent, $prefix, $storage, $option, $definition, $parents)
3 calls to views_object::export_option()
views_object::export_options in includes/base.inc
views_object::export_option_always in includes/base.inc
Always exports the option, regardless of the default value.
views_plugin_display::export_option in plugins/views_plugin_display.inc
Override of export_option()
1 method overrides views_object::export_option()
views_plugin_display::export_option in plugins/views_plugin_display.inc
Override of export_option()

File

includes/base.inc, line 212
Provides the basic object definitions used by plugins and handlers.

Class

views_object
Basic definition for many views objects.

Code

function export_option($indent, $prefix, $storage, $option, $definition, $parents) {
  // Do not export options for which we have no settings.
  if (!isset($storage[$option])) {
    return;
  }

  if (isset($definition['export'])) {
    if ($definition['export'] === FALSE) {
      return;
    }

    // Special handling for some items
    if (method_exists($this, $definition['export'])) {
      return $this->{$definition['export']}($indent, $prefix, $storage, $option, $definition, $parents);
    }
  }

  // Add the current option to the parents tree.
  $parents[] = $option;
  $output = '';

  // If it has child items, export those separately.
  if (isset($definition['contains'])) {
    foreach ($definition['contains'] as $sub_option => $sub_definition) {
      $output .= $this->export_option($indent, $prefix, $storage[$option], $sub_option, $sub_definition, $parents);
    }
  }
  // Otherwise export just this item.
  else {
    $default = isset($definition['default']) ? $definition['default'] : NULL;
    $value = $storage[$option];
    if (isset($definition['bool'])) {
      $value = (bool) $value;
    }

    if ($value !== $default) {
      $output .= $indent . $prefix . "['" . implode("']['", $parents) . "'] = ";
      if (isset($definition['bool'])) {
        $output .= empty($storage[$option]) ? 'FALSE' : 'TRUE';
      }
      else {
        $output .= views_var_export($storage[$option], $indent);
      }

      $output .= ";\n";
    }
  }
  return $output;
}