You are here

public static function i18n_string_textgroup_default::load_source in Internationalization 7

Load string source from db

File

i18n_string/i18n_string.inc, line 648
API for internationalization strings

Class

i18n_string_textgroup_default
Textgroup handler for i18n_string API

Code

public static function load_source($i18nstring) {

  // Search the database using lid if we've got it or textgroup, context otherwise
  $query = db_select('locales_source', 's')
    ->fields('s');
  $query
    ->leftJoin('i18n_string', 'i', 's.lid = i.lid');
  $query
    ->fields('i', array(
    'format',
    'objectid',
    'type',
    'property',
    'objectindex',
  ));
  if (!empty($i18nstring->lid)) {
    $query
      ->condition('s.lid', $i18nstring->lid);
  }
  else {
    $query
      ->condition('s.textgroup', $i18nstring->textgroup);
    $query
      ->condition('s.context', $i18nstring->context);
  }

  // Speed up the query, we just need one row
  return $query
    ->range(0, 1)
    ->execute()
    ->fetchObject();
}