Contributions API

i18nstrings_get_source

Definition

i18nstrings_get_source($context, $string = NULL)
contributions/i18n/i18nstrings/i18nstrings.module, line 262

Description

Get source string provided a string context

This will search first with the full context parameters and, if not found, it will search again only with textgroup and source string

Parameters

$context Context string or object

Return value

Context object if it exists

Code

<?php
function i18nstrings_get_source($context, $string = NULL) {
  $context = i18nstrings_context($context);
  
  // Check if we have the string for this location
  list($where, $args) = i18nstrings_context_query($context);
  if ($source = db_fetch_object(db_query("SELECT s.*, i.type, i.oid, i.property  FROM {locales_source} s LEFT JOIN {i18n_strings} i ON s.lid = i.lid WHERE ". implode(' AND ', $where), $args))) {
    $source->context = $context;
    return $source;
  }
  // Search for the same string for this textgroup without object data
  if ($string && $source = db_fetch_object(db_query("SELECT s.*, i.type, i.oid, i.property FROM {locales_source} s  LEFT JOIN {i18n_strings} i ON s.lid = i.lid WHERE s.textgroup = '%s' AND s.source = '%s' AND i.lid IS NULL", $context->textgroup, $string))) {
    $source->context = NULL;
    return $source;
  }
}
?>