function views_object::unpack_translatable
Same name in other branches
- 7.x-3.x includes/base.inc \views_object::unpack_translatable()
Unpack a single option definition.
This function run's through all suboptions recursive.
Parameters
$translatable: Stores all availible translatable items.
$storage:
$option:
$definition:
$parents:
$keys:
1 call to views_object::unpack_translatable()
- views_object::unpack_translatables in includes/
base.inc - Unpacks each handler to store translatable texts.
File
-
includes/
base.inc, line 275
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($options[$definition['format_key']])) {
$format = $options[$definition['format_key']];
}
$translatable[] = array(
'value' => $value,
'keys' => isset($translation_keys) ? $translation_keys : $parents,
'format' => $format,
);
}
}
}