ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjectTranslation Class Reference

Class handles translation mode for an object. More...

+ Collaboration diagram for ilObjectTranslation:

Public Member Functions

 setObjId ($a_val)
 Set object id.
 getObjId ()
 Get object id.
 setMasterLanguage ($a_val)
 Set master language.
 getMasterLanguage ()
 Get master language.
 setLanguages (array $a_val)
 Set languages.
 getLanguages ()
 Get languages.
 addLanguage ($a_lang, $a_title, $a_description, $a_default)
 Add language.
 getDefaultTitle ()
 Get default title.
 setDefaultTitle ($a_title)
 Set default title.
 getDefaultDescription ()
 Get default description.
 setDefaultDescription ($a_description)
 Set default description.
 removeLanguage ($a_lang)
 Remove language.
 getContentActivated ()
 Get activated for content.
 read ()
 Read.
 delete ()
 Delete.
 deactivateContentTranslation ()
 Deactivate content translation.
 save ()
 Save.
 copy ($a_obj_id)
 Copy multilinguality settings.
 getEffectiveContentLang ($a_lang, $a_parent_type)
 Get effective language for given language.

Static Public Member Functions

static getInstance ($a_obj_id)
 Get instance.

Protected Member Functions

 setContentActivated ($a_val)
 Set activated for content.

Protected Attributes

 $db
 $obj_id
 $master_lang
 $languages = array()
 $content_activated = false

Static Protected Attributes

static $instances = array()

Private Member Functions

 __construct ($a_obj_id)
 Constructor.

Detailed Description

Class handles translation mode for an object.

Objects may not use any translations at all

  • use translations for title/description only or
  • use translation for (the page editing) content, too.

Currently supported by container objects and ILIAS learning modules.

Content master lang vs. default language

  • If no translation mode for the content is active no master lang will be set and no record in table obj_content_master_lng will be saved. For the title/descriptions the default will be marked by field lang_default in table object_translation.
  • If translation for content is activated a master language must be set (since concent may already exist the language of this content is defined through setting the master language (in obj_content_master_lng). Modules that use this mode will not get informed about this, so they can not internally assign existing content to the master lang
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 29 of file class.ilObjectTranslation.php.

Constructor & Destructor Documentation

ilObjectTranslation::__construct (   $a_obj_id)
private

Constructor.

Parameters
int$a_obj_idobject id
Exceptions
ilObjectException

Definition at line 44 of file class.ilObjectTranslation.php.

References $ilDB, getObjId(), read(), and setObjId().

{
global $ilDB;
$this->db = $ilDB;
$this->setObjId($a_obj_id);
if ($this->getObjId() <= 0)
{
include_once("./Services/Object/exceptions/class.ilObjectException.php");
throw new ilObjectException("ilObjectTranslation: No object ID passed.");
}
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilObjectTranslation::addLanguage (   $a_lang,
  $a_title,
  $a_description,
  $a_default 
)

Add language.

Parameters
string$a_langlanguage
string$a_titletitle
string$a_descriptiondescription
bool$a_defaultdefault language?

Definition at line 146 of file class.ilObjectTranslation.php.

Referenced by read().

{
if ($a_lang != "" && !isset($this->languages[$a_lang]))
{
if ($a_default)
{
foreach ($this->languages as $k => $l)
{
$this->languages[$k]["lang_default"] = false;
}
}
$this->languages[$a_lang] = array("lang_code" => $a_lang, "lang_default" => $a_default,
"title" => $a_title, "description" => $a_description);
}
}

+ Here is the caller graph for this function:

ilObjectTranslation::copy (   $a_obj_id)

Copy multilinguality settings.

Parameters
string$a_target_parent_typeparent object type
int$a_target_parent_idparent object id
Returns
ilObjectTranslation target multilang object

Definition at line 368 of file class.ilObjectTranslation.php.

References getLanguages(), and getMasterLanguage().

{
$target_ml = new ilObjectTranslation($a_obj_id);
$target_ml->setMasterLanguage($this->getMasterLanguage());
$target_ml->setLanguages($this->getLanguages());
$target_ml->save();
return $target_ml;
}

+ Here is the call graph for this function:

ilObjectTranslation::deactivateContentTranslation ( )

Deactivate content translation.

Definition at line 307 of file class.ilObjectTranslation.php.

{
$this->db->manipulate("DELETE FROM obj_content_master_lng ".
" WHERE obj_id = ".$this->db->quote($this->getObjId(), "integer")
);
}
ilObjectTranslation::delete ( )

Delete.

Definition at line 294 of file class.ilObjectTranslation.php.

{
$this->db->manipulate("DELETE FROM obj_content_master_lng ".
" WHERE obj_id = ".$this->db->quote($this->getObjId(), "integer")
);
$this->db->manipulate("DELETE FROM object_translation ".
" WHERE obj_id = ".$this->db->quote($this->getObjId(), "integer")
);
}
ilObjectTranslation::getContentActivated ( )

Get activated for content.

Returns
bool activated for content?

Definition at line 258 of file class.ilObjectTranslation.php.

References $content_activated.

Referenced by getEffectiveContentLang().

+ Here is the caller graph for this function:

ilObjectTranslation::getDefaultDescription ( )

Get default description.

Returns
string description of default language

Definition at line 200 of file class.ilObjectTranslation.php.

{
foreach ($this->languages as $l)
{
if ($l["lang_default"])
{
return $l["description"];
}
}
return "";
}
ilObjectTranslation::getDefaultTitle ( )

Get default title.

Returns
string title of default language

Definition at line 167 of file class.ilObjectTranslation.php.

{
foreach ($this->languages as $l)
{
if ($l["lang_default"])
{
return $l["title"];
}
}
return "";
}
ilObjectTranslation::getEffectiveContentLang (   $a_lang,
  $a_parent_type 
)

Get effective language for given language.

This checks if

  • multilinguality is activated and
  • the given language is part of the available translations If not a "-" is returned (master language).
Parameters
string$a_langlanguage
string$a_parent_typepage parent type
Returns
string effective language ("-" for master)

Definition at line 388 of file class.ilObjectTranslation.php.

References ilPageObject\_exists(), getContentActivated(), getLanguages(), and getObjId().

{
$langs = $this->getLanguages();
if ($this->getContentActivated() &&
isset($langs[$a_lang]) &&
ilPageObject::_exists($a_parent_type, $this->getObjId(), $a_lang))
{
return $a_lang;
}
return "-";
}

+ Here is the call graph for this function:

ilObjectTranslation::getLanguages ( )

Get languages.

Returns
array array of language codes

Definition at line 133 of file class.ilObjectTranslation.php.

References $languages.

Referenced by copy(), getEffectiveContentLang(), and save().

{
}

+ Here is the caller graph for this function:

ilObjectTranslation::getMasterLanguage ( )

Get master language.

Returns
string master language

Definition at line 113 of file class.ilObjectTranslation.php.

References $master_lang.

Referenced by copy(), removeLanguage(), and save().

{
}

+ Here is the caller graph for this function:

ilObjectTranslation::getObjId ( )

Get object id.

Returns
int object id

Definition at line 93 of file class.ilObjectTranslation.php.

References $obj_id.

Referenced by __construct(), and getEffectiveContentLang().

{
return $this->obj_id;
}

+ Here is the caller graph for this function:

ilObjectTranslation::read ( )

Read.

Definition at line 266 of file class.ilObjectTranslation.php.

References addLanguage(), setContentActivated(), setLanguages(), and setMasterLanguage().

Referenced by __construct().

{
$set = $this->db->query("SELECT * FROM obj_content_master_lng ".
" WHERE obj_id = ".$this->db->quote($this->getObjId(), "integer")
);
if ($rec = $this->db->fetchAssoc($set))
{
$this->setMasterLanguage($rec["master_lang"]);
$this->setContentActivated(true);
}
else
{
$this->setContentActivated(false);
}
$this->setLanguages(array());
$set = $this->db->query("SELECT * FROM object_translation ".
" WHERE obj_id = ".$this->db->quote($this->getObjId(), "integer")
);
while ($rec = $this->db->fetchAssoc($set))
{
$this->addLanguage($rec["lang_code"], $rec["title"], $rec["description"], $rec["lang_default"]);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectTranslation::removeLanguage (   $a_lang)

Remove language.

Parameters
string$a_langlanguage code

Definition at line 234 of file class.ilObjectTranslation.php.

References getMasterLanguage().

{
if ($a_lang != $this->getMasterLanguage())
{
unset($this->languages[$a_lang]);
}
}

+ Here is the call graph for this function:

ilObjectTranslation::save ( )

Save.

Definition at line 317 of file class.ilObjectTranslation.php.

References getLanguages(), and getMasterLanguage().

{
$this->delete();
if ($this->getMasterLanguage() != "")
{
$this->db->manipulate("INSERT INTO obj_content_master_lng ".
"(obj_id, master_lang) VALUES (".
$this->db->quote($this->getObjId(), "integer").",".
$this->db->quote($this->getMasterLanguage(), "text").
")");
// ensure that an entry for the master language exists and is the default
if (!isset($this->languages[$this->getMasterLanguage()]))
{
$this->languages[$this->getMasterLanguage()] = array("title" => "",
"description" => "", "lang_code" => $this->getMasterLanguage(), "lang_default" => 1);
}
foreach ($this->languages as $l => $trans)
{
if ($l == $this->getMasterLanguage())
{
$this->languages[$l]["lang_default"] = 1;
}
else
{
$this->languages[$l]["lang_default"] = 0;
}
}
}
foreach ($this->getLanguages() as $l => $trans)
{
$this->db->manipulate("INSERT INTO object_translation ".
"(obj_id, title, description, lang_code, lang_default) VALUES (".
$this->db->quote($this->getObjId(), "integer").",".
$this->db->quote($trans["title"], "text").",".
$this->db->quote($trans["description"], "text").",".
$this->db->quote($l, "text").",".
$this->db->quote($trans["lang_default"], "integer").
")");
}
}

+ Here is the call graph for this function:

ilObjectTranslation::setContentActivated (   $a_val)
protected

Set activated for content.

Parameters
bool$a_valactivated for content?

Definition at line 248 of file class.ilObjectTranslation.php.

Referenced by read().

{
$this->content_activated = $a_val;
}

+ Here is the caller graph for this function:

ilObjectTranslation::setDefaultDescription (   $a_description)

Set default description.

Parameters
string$a_descriptiondescription

Definition at line 217 of file class.ilObjectTranslation.php.

{
foreach ($this->languages as $k => $l)
{
if ($l["lang_default"])
{
$this->languages[$k]["description"] = $a_description;
}
}
}
ilObjectTranslation::setDefaultTitle (   $a_title)

Set default title.

Parameters
string$a_titletitle

Definition at line 184 of file class.ilObjectTranslation.php.

{
foreach ($this->languages as $k => $l)
{
if ($l["lang_default"])
{
$this->languages[$k]["title"] = $a_title;
}
}
}
ilObjectTranslation::setLanguages ( array  $a_val)

Set languages.

Parameters
array$a_valarray of language codes

Definition at line 123 of file class.ilObjectTranslation.php.

Referenced by read().

{
$this->languages = $a_val;
}

+ Here is the caller graph for this function:

ilObjectTranslation::setMasterLanguage (   $a_val)

Set master language.

Parameters
string$a_valmaster language

Definition at line 103 of file class.ilObjectTranslation.php.

Referenced by read().

{
$this->master_lang = $a_val;
}

+ Here is the caller graph for this function:

ilObjectTranslation::setObjId (   $a_val)

Set object id.

Parameters
int$a_valobject id

Definition at line 83 of file class.ilObjectTranslation.php.

Referenced by __construct().

{
$this->obj_id = $a_val;
}

+ Here is the caller graph for this function:

Field Documentation

ilObjectTranslation::$content_activated = false
protected

Definition at line 35 of file class.ilObjectTranslation.php.

Referenced by getContentActivated().

ilObjectTranslation::$db
protected

Definition at line 31 of file class.ilObjectTranslation.php.

ilObjectTranslation::$instances = array()
staticprotected

Definition at line 36 of file class.ilObjectTranslation.php.

ilObjectTranslation::$languages = array()
protected

Definition at line 34 of file class.ilObjectTranslation.php.

Referenced by getLanguages().

ilObjectTranslation::$master_lang
protected

Definition at line 33 of file class.ilObjectTranslation.php.

Referenced by getMasterLanguage().

ilObjectTranslation::$obj_id
protected

Definition at line 32 of file class.ilObjectTranslation.php.

Referenced by getObjId().


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