CMS  Version 3.9
TextTranslation Class Reference

Inherits DataItem.

Public Member Functions

 TextLookup ()
 
 TextTranslation ()
 

Static Public Member Functions

static getTranslation ($text)
 

Public Attributes

 $fields
 
 $relations
 

Static Public Attributes

static $languageOptions
 

Detailed Description

Definition at line 211 of file text_lookup.inc.

Member Function Documentation

◆ getTranslation()

static TextTranslation::getTranslation (   $text)
static

Definition at line 259 of file text_lookup.inc.

260  {
261  global $user;
262 
263  if($user && $user->hasField("language") && $user->language)
264  $language = $user->language;
265  else
266  $language = Settings::getValue("text_lookup", "language");
267 
268  if(!$language || $language == "English")
269  return $text;
270  else
271  {
272  $translations = Query::create(TextTranslation, "WHERE text_id=:text_id AND language=:language")
273  ->bind(":text_id", $text->text_id, ":language", $language)
274  ->execute();
275 
276  if(count($translations) > 0 && $translations[0]->text)
277  {
278  $text->text = $translations[0]->text;
279  }
280  }
281 
282  return $text;
283  }
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
global $user

◆ TextLookup()

TextTranslation::TextLookup ( )

Definition at line 238 of file text_lookup.inc.

239  {
240  return $this->getRelated(TextLookup);
241  }

◆ TextTranslation()

TextTranslation::TextTranslation ( )

Definition at line 243 of file text_lookup.inc.

244  {
245  $this->primary_key = "text_translation_id";
246  $this->table = "text_translation";
247 
248  $this->DataItem(func_get_args());
249  }

Member Data Documentation

◆ $fields

TextTranslation::$fields
Initial value:
= array(
"text_translation_id" => Number,
"text_id" => String,
"language" => String,
"text" => HTML
)

Definition at line 213 of file text_lookup.inc.

◆ $languageOptions

TextTranslation::$languageOptions
static
Initial value:
= array(
"English" => "English",
"French" => "French",
"Spanish" => "Spanish",
"German" => "German",
"Russian" => "Russian"
)

Definition at line 229 of file text_lookup.inc.

◆ $relations

TextTranslation::$relations
Initial value:
= array(
"TextLookup" => TextLookup
)

Definition at line 220 of file text_lookup.inc.


The documentation for this class was generated from the following file: