function views_object::unpack_translatable

cis7 base.inc views_object::unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array())
cle7 base.inc views_object::unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array())
elmsmedia7 base.inc views_object::unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array())
icor7 base.inc views_object::unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array())
meedjum_blog7 base.inc views_object::unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array())
mooc7 base.inc views_object::unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array())

Unpack a single option definition.

This function run's through all suboptions recursive.

Parameters

$translatable: Stores all available translatable items.

$storage:

$option:

$definition:

$parents:

$keys:

1 call to views_object::unpack_translatable()
views_object::unpack_translatables in sites/all/modules/ulmus/views/includes/base.inc
Unpacks each handler to store translatable texts.

File

sites/all/modules/ulmus/views/includes/base.inc, line 295
Provides the basic object definitions used by plugins and handlers.

Class

views_object
Basic definition for many views objects.

Code

function unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) {
  // Do not export options for which we have no settings.
  if (!isset($storage[$option])) {
    return;
  }

  // Special handling for some items
  if (isset($definition['unpack_translatable']) && method_exists($this, $definition['unpack_translatable'])) {
    return $this->{$definition['unpack_translatable']}($translatable, $storage, $option, $definition, $parents, $keys);
  }

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

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

  // If it has child items, unpack those separately.
  if (isset($definition['contains'])) {
    foreach ($definition['contains'] as $sub_option => $sub_definition) {
      $translation_keys = array_merge($keys, array($sub_option));
      $this->unpack_translatable($translatable, $storage[$option], $sub_option, $sub_definition, $parents, $translation_keys);
    }
  }

  // @todo Figure out this double definition stuff.
  $options = $storage[$option];
  if (is_array($options)) {
    foreach ($options as $key => $value) {
      $translation_keys = array_merge($keys, array($key));
      if (is_array($value)) {
        $this->unpack_translatable($translatable, $options, $key, $definition, $parents, $translation_keys);
      }
      else if (!empty($definition[$key]['translatable']) && !empty($value)) {
        // Build source data and add to the array
        $format = NULL;
        if (isset($definition['format_key']) && isset($options[$definition['format_key']])) {
          $format = $options[$definition['format_key']];
        }
        $translatable[] = array(
          'value' => $value,
          'keys' => $translation_keys,
          'format' => $format,
        );
      }
    }
  }
  else if (!empty($definition['translatable']) && !empty($options)) {
    $value = $options;
    // Build source data and add to the array
    $format = NULL;
    if (isset($definition['format_key']) && isset($storage[$definition['format_key']])) {
      $format = $storage[$definition['format_key']];
    }
    $translatable[] = array(
      'value' => $value,
      'keys' => isset($translation_keys) ? $translation_keys : $parents,
      'format' => $format,
    );
  }
}