Contributions API

i18nstrings_context

Definition

i18nstrings_context($context, $string = NULL)
contributions/i18n/i18nstrings/i18nstrings.module, line 464

Description

Convert context string in a context object

I.e. 'taxonomy:term:1:name' will become a $context object where $context->textgroup = 'taxonomy'; $context->type = 'term'; $context->oid = 1; $context->property = 'name'; Examples: 'taxonomy:title' -> (taxonomy, title, 0, 0) 'contenttypes:type:[type]:name' 'contenttypes:type:[type]:description' 'profile:category' 'profile:field:[fid]:title'

Parameters

$context Context string or object

Return value

Context object with textgroup, type, oid, property and location names

Code

<?php
function i18nstrings_context($context, $string = NULL) {
  // Context may be already an object
  if (is_object($context)) {
    return $context;
  } else {
    // We add empty fields at the end before splitting
    list($textgroup, $type, $oid, $property) = split(':', $context.':::');
    $context = (object)array(
      'textgroup' => $textgroup,
      'type' => $type,
      'oid' => $oid ? $oid : 0,
      'property' => $property ? $property : 0,
    );
    $context->location = i18nstrings_location($context);
    if (!$context->oid && !$context->property && $string) {
      $context->source = $string;
    }
    return $context;
  }
}
?>