ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPageMultiLang Class Reference

Multi-language properties. More...

+ Collaboration diagram for ilPageMultiLang:

Public Member Functions

 __construct ($a_parent_type, $a_parent_id)
 Constructor.
 setParentType ($a_val)
 Set parent type.
 getParentType ()
 Get parent type.
 setParentId ($a_val)
 Set parent id.
 getParentId ()
 Get parent id.
 setMasterLanguage ($a_val)
 Set master language.
 getMasterLanguage ()
 Get master language.
 setLanguages (array $a_val)
 Set languages.
 getLanguages ()
 Get languages.
 addLanguage ($a_lang)
 Add language.
 getActivated ()
 Get activated.
 read ()
 Read.
 delete ()
 Delete.
 save ()
 Save.
 copy ($a_target_parent_type, $a_target_parent_id)
 Copy multilinguality settings.
 getEffectiveLang ($a_lang)
 Get effective language for given language.

Protected Member Functions

 setActivated ($a_val)
 Set activated.

Protected Attributes

 $db
 $parent_type
 $parent_id
 $master_lang
 $languages = array()
 $activated = false

Detailed Description

Multi-language properties.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilPageMultiLang.php.

Constructor & Destructor Documentation

ilPageMultiLang::__construct (   $a_parent_type,
  $a_parent_id 
)

Constructor.

Parameters
string$a_parent_typeparent object type
int$a_parent_idparent object id
Exceptions
ilCOPageException

Definition at line 28 of file class.ilPageMultiLang.php.

References getParentId(), getParentType(), read(), setParentId(), and setParentType().

{
global $ilDB;
$this->db = $ilDB;
$this->setParentType($a_parent_type);
$this->setParentId($a_parent_id);
if ($this->getParentType() == "")
{
include_once("./Services/COPage/exceptions/class.ilCOPageException.php");
throw new ilCOPageException("ilPageMultiLang: No parent type passed.");
}
if ($this->getParentId() <= 0)
{
include_once("./Services/COPage/exceptions/class.ilCOPageException.php");
throw new ilCOPageException("ilPageMultiLang: No parent ID passed.");
}
$this->read();
}

+ Here is the call graph for this function:

Member Function Documentation

ilPageMultiLang::addLanguage (   $a_lang)

Add language.

Parameters
string$a_langlanguage

Definition at line 137 of file class.ilPageMultiLang.php.

Referenced by read().

{
if ($a_lang != "" && !in_array($a_lang, $this->languages))
{
$this->languages[] = $a_lang;
}
}

+ Here is the caller graph for this function:

ilPageMultiLang::copy (   $a_target_parent_type,
  $a_target_parent_id 
)

Copy multilinguality settings.

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

Definition at line 243 of file class.ilPageMultiLang.php.

References getActivated(), getLanguages(), and getMasterLanguage().

{
if ($this->getActivated())
{
$target_ml = new ilPageMultiLang($a_target_parent_type, $a_target_parent_id);
$target_ml->setMasterLanguage($this->getMasterLanguage());
$target_ml->setLanguages($this->getLanguages());
$target_ml->save();
return $target_ml;
}
return null;
}

+ Here is the call graph for this function:

ilPageMultiLang::delete ( )

Delete.

Definition at line 199 of file class.ilPageMultiLang.php.

{
$this->db->manipulate("DELETE FROM copg_multilang ".
" WHERE parent_type = ".$this->db->quote($this->getParentType(), "text").
" AND parent_id = ".$this->db->quote($this->getParentId(), "integer")
);
$this->db->manipulate("DELETE FROM copg_multilang_lang ".
" WHERE parent_type = ".$this->db->quote($this->getParentType(), "text").
" AND parent_id = ".$this->db->quote($this->getParentId(), "integer")
);
}
ilPageMultiLang::getActivated ( )

Get activated.

Returns
bool activated?

Definition at line 161 of file class.ilPageMultiLang.php.

References $activated.

Referenced by copy(), and getEffectiveLang().

{
}

+ Here is the caller graph for this function:

ilPageMultiLang::getEffectiveLang (   $a_lang)

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
Returns
string effective language ("-" for master)

Definition at line 267 of file class.ilPageMultiLang.php.

References ilPageObject\_exists(), getActivated(), getLanguages(), getParentId(), and getParentType().

{
if ($this->getActivated() &&
in_array($a_lang, $this->getLanguages()) &&
ilPageObject::_exists($this->getParentType(), $this->getParentId(), $a_lang))
{
return $a_lang;
}
return "-";
}

+ Here is the call graph for this function:

ilPageMultiLang::getLanguages ( )

Get languages.

Returns
array array of language codes

Definition at line 127 of file class.ilPageMultiLang.php.

References $languages.

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

{
}

+ Here is the caller graph for this function:

ilPageMultiLang::getMasterLanguage ( )

Get master language.

Returns
string master language

Definition at line 107 of file class.ilPageMultiLang.php.

References $master_lang.

Referenced by copy().

{
}

+ Here is the caller graph for this function:

ilPageMultiLang::getParentId ( )

Get parent id.

Returns
int parent id

Definition at line 87 of file class.ilPageMultiLang.php.

References $parent_id.

Referenced by __construct(), and getEffectiveLang().

{
}

+ Here is the caller graph for this function:

ilPageMultiLang::getParentType ( )

Get parent type.

Returns
string parent type

Definition at line 67 of file class.ilPageMultiLang.php.

References $parent_type.

Referenced by __construct(), and getEffectiveLang().

{
}

+ Here is the caller graph for this function:

ilPageMultiLang::read ( )

Read.

Definition at line 169 of file class.ilPageMultiLang.php.

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

Referenced by __construct().

{
$set = $this->db->query("SELECT * FROM copg_multilang ".
" WHERE parent_type = ".$this->db->quote($this->getParentType(), "text").
" AND parent_id = ".$this->db->quote($this->getParentId(), "integer")
);
if ($rec = $this->db->fetchAssoc($set))
{
$this->setMasterLanguage($rec["master_lang"]);
$this->setActivated(true);
}
else
{
$this->setActivated(false);
}
$this->setLanguages(array());
$set = $this->db->query("SELECT * FROM copg_multilang_lang ".
" WHERE parent_type = ".$this->db->quote($this->getParentType(), "text").
" AND parent_id = ".$this->db->quote($this->getParentId(), "integer")
);
while ($rec = $this->db->fetchAssoc($set))
{
$this->addLanguage($rec["lang"]);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPageMultiLang::save ( )

Save.

Definition at line 214 of file class.ilPageMultiLang.php.

References $lang, and getLanguages().

{
$this->delete();
$this->db->manipulate("INSERT INTO copg_multilang ".
"(parent_type, parent_id, master_lang) VALUES (".
$this->db->quote($this->getParentType(), "text").",".
$this->db->quote($this->getParentId(), "integer").",".
$this->db->quote($this->getMasterLanguage(), "text").
")");
foreach ($this->getLanguages() as $lang)
{
$this->db->manipulate("INSERT INTO copg_multilang_lang ".
"(parent_type, parent_id, lang) VALUES (".
$this->db->quote($this->getParentType(), "text").",".
$this->db->quote($this->getParentId(), "integer").",".
$this->db->quote($lang, "text").
")");
}
}

+ Here is the call graph for this function:

ilPageMultiLang::setActivated (   $a_val)
protected

Set activated.

Parameters
bool$a_valactivated?

Definition at line 151 of file class.ilPageMultiLang.php.

Referenced by read().

{
$this->activated = $a_val;
}

+ Here is the caller graph for this function:

ilPageMultiLang::setLanguages ( array  $a_val)

Set languages.

Parameters
array$a_valarray of language codes

Definition at line 117 of file class.ilPageMultiLang.php.

Referenced by read().

{
$this->languages = $a_val;
}

+ Here is the caller graph for this function:

ilPageMultiLang::setMasterLanguage (   $a_val)

Set master language.

Parameters
string$a_valmaster language

Definition at line 97 of file class.ilPageMultiLang.php.

Referenced by read().

{
$this->master_lang = $a_val;
}

+ Here is the caller graph for this function:

ilPageMultiLang::setParentId (   $a_val)

Set parent id.

Parameters
int$a_valparent id

Definition at line 77 of file class.ilPageMultiLang.php.

Referenced by __construct().

{
$this->parent_id = $a_val;
}

+ Here is the caller graph for this function:

ilPageMultiLang::setParentType (   $a_val)

Set parent type.

Parameters
string$a_valparent type

Definition at line 57 of file class.ilPageMultiLang.php.

Referenced by __construct().

{
$this->parent_type = $a_val;
}

+ Here is the caller graph for this function:

Field Documentation

ilPageMultiLang::$activated = false
protected

Definition at line 19 of file class.ilPageMultiLang.php.

Referenced by getActivated().

ilPageMultiLang::$db
protected

Definition at line 14 of file class.ilPageMultiLang.php.

ilPageMultiLang::$languages = array()
protected

Definition at line 18 of file class.ilPageMultiLang.php.

Referenced by getLanguages().

ilPageMultiLang::$master_lang
protected

Definition at line 17 of file class.ilPageMultiLang.php.

Referenced by getMasterLanguage().

ilPageMultiLang::$parent_id
protected

Definition at line 16 of file class.ilPageMultiLang.php.

Referenced by getParentId().

ilPageMultiLang::$parent_type
protected

Definition at line 15 of file class.ilPageMultiLang.php.

Referenced by getParentType().


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