ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilPageMultiLang Class Reference

Multi-language properties. More...

+ Collaboration diagram for ilPageMultiLang:

Public Member Functions

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

Protected Member Functions

 setActivated ($a_val)
 Set activated. More...
 

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

◆ __construct()

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 $DIC, $ilDB, getParentId(), getParentType(), read(), setParentId(), and setParentType().

29  {
30  global $DIC;
31 
32  $ilDB = $DIC->database();
33 
34  $this->db = $ilDB;
35 
36  $this->setParentType($a_parent_type);
37  $this->setParentId($a_parent_id);
38 
39  if ($this->getParentType() == "") {
40  include_once("./Services/COPage/exceptions/class.ilCOPageException.php");
41  throw new ilCOPageException("ilPageMultiLang: No parent type passed.");
42  }
43 
44  if ($this->getParentId() <= 0) {
45  include_once("./Services/COPage/exceptions/class.ilCOPageException.php");
46  throw new ilCOPageException("ilPageMultiLang: No parent ID passed.");
47  }
48 
49  $this->read();
50  }
global $DIC
Definition: saml.php:7
setParentType($a_val)
Set parent type.
getParentId()
Get parent id.
setParentId($a_val)
Set parent id.
global $ilDB
getParentType()
Get parent type.
Base exception class for copage service.
+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguage()

ilPageMultiLang::addLanguage (   $a_lang)

Add language.

Parameters
string$a_langlanguage

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

Referenced by read().

138  {
139  if ($a_lang != "" && !in_array($a_lang, $this->languages)) {
140  $this->languages[] = $a_lang;
141  }
142  }
+ Here is the caller graph for this function:

◆ copy()

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 241 of file class.ilPageMultiLang.php.

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

242  {
243  if ($this->getActivated()) {
244  $target_ml = new ilPageMultiLang($a_target_parent_type, $a_target_parent_id);
245  $target_ml->setMasterLanguage($this->getMasterLanguage());
246  $target_ml->setLanguages($this->getLanguages());
247  $target_ml->save();
248  return $target_ml;
249  }
250 
251  return null;
252  }
Multi-language properties.
getMasterLanguage()
Get master language.
getActivated()
Get activated.
getLanguages()
Get languages.
+ Here is the call graph for this function:

◆ delete()

ilPageMultiLang::delete ( )

Delete.

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

197  {
198  $this->db->manipulate(
199  "DELETE FROM copg_multilang " .
200  " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
201  " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
202  );
203  $this->db->manipulate(
204  "DELETE FROM copg_multilang_lang " .
205  " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
206  " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
207  );
208  }

◆ getActivated()

ilPageMultiLang::getActivated ( )

Get activated.

Returns
bool activated?

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

References $activated.

Referenced by copy(), and getEffectiveLang().

161  {
162  return $this->activated;
163  }
+ Here is the caller graph for this function:

◆ getEffectiveLang()

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 264 of file class.ilPageMultiLang.php.

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

265  {
266  if ($this->getActivated() &&
267  in_array($a_lang, $this->getLanguages()) &&
268  ilPageObject::_exists($this->getParentType(), $this->getParentId(), $a_lang)) {
269  return $a_lang;
270  }
271  return "-";
272  }
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
getParentId()
Get parent id.
getActivated()
Get activated.
getParentType()
Get parent type.
getLanguages()
Get languages.
+ Here is the call graph for this function:

◆ getLanguages()

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().

128  {
129  return $this->languages;
130  }
+ Here is the caller graph for this function:

◆ getMasterLanguage()

ilPageMultiLang::getMasterLanguage ( )

Get master language.

Returns
string master language

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

References $master_lang.

Referenced by copy().

108  {
109  return $this->master_lang;
110  }
+ Here is the caller graph for this function:

◆ getParentId()

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().

88  {
89  return $this->parent_id;
90  }
+ Here is the caller graph for this function:

◆ getParentType()

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().

68  {
69  return $this->parent_type;
70  }
+ Here is the caller graph for this function:

◆ read()

ilPageMultiLang::read ( )

Read.

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

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

Referenced by __construct().

169  {
170  $set = $this->db->query(
171  "SELECT * FROM copg_multilang " .
172  " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
173  " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
174  );
175  if ($rec = $this->db->fetchAssoc($set)) {
176  $this->setMasterLanguage($rec["master_lang"]);
177  $this->setActivated(true);
178  } else {
179  $this->setActivated(false);
180  }
181 
182  $this->setLanguages(array());
183  $set = $this->db->query(
184  "SELECT * FROM copg_multilang_lang " .
185  " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
186  " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
187  );
188  while ($rec = $this->db->fetchAssoc($set)) {
189  $this->addLanguage($rec["lang"]);
190  }
191  }
addLanguage($a_lang)
Add language.
setMasterLanguage($a_val)
Set master language.
setActivated($a_val)
Set activated.
Create styles array
The data for the language used.
setLanguages(array $a_val)
Set languages.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilPageMultiLang::save ( )

Save.

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

References $lang, and getLanguages().

214  {
215  $this->delete();
216 
217  $this->db->manipulate("INSERT INTO copg_multilang " .
218  "(parent_type, parent_id, master_lang) VALUES (" .
219  $this->db->quote($this->getParentType(), "text") . "," .
220  $this->db->quote($this->getParentId(), "integer") . "," .
221  $this->db->quote($this->getMasterLanguage(), "text") .
222  ")");
223 
224  foreach ($this->getLanguages() as $lang) {
225  $this->db->manipulate("INSERT INTO copg_multilang_lang " .
226  "(parent_type, parent_id, lang) VALUES (" .
227  $this->db->quote($this->getParentType(), "text") . "," .
228  $this->db->quote($this->getParentId(), "integer") . "," .
229  $this->db->quote($lang, "text") .
230  ")");
231  }
232  }
getLanguages()
Get languages.
+ Here is the call graph for this function:

◆ setActivated()

ilPageMultiLang::setActivated (   $a_val)
protected

Set activated.

Parameters
bool$a_valactivated?

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

Referenced by read().

151  {
152  $this->activated = $a_val;
153  }
+ Here is the caller graph for this function:

◆ setLanguages()

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().

118  {
119  $this->languages = $a_val;
120  }
+ Here is the caller graph for this function:

◆ setMasterLanguage()

ilPageMultiLang::setMasterLanguage (   $a_val)

Set master language.

Parameters
string$a_valmaster language

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

Referenced by read().

98  {
99  $this->master_lang = $a_val;
100  }
+ Here is the caller graph for this function:

◆ setParentId()

ilPageMultiLang::setParentId (   $a_val)

Set parent id.

Parameters
int$a_valparent id

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

Referenced by __construct().

78  {
79  $this->parent_id = $a_val;
80  }
+ Here is the caller graph for this function:

◆ setParentType()

ilPageMultiLang::setParentType (   $a_val)

Set parent type.

Parameters
string$a_valparent type

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

Referenced by __construct().

58  {
59  $this->parent_type = $a_val;
60  }
+ Here is the caller graph for this function:

Field Documentation

◆ $activated

ilPageMultiLang::$activated = false
protected

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

Referenced by getActivated().

◆ $db

ilPageMultiLang::$db
protected

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

◆ $languages

ilPageMultiLang::$languages = array()
protected

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

Referenced by getLanguages().

◆ $master_lang

ilPageMultiLang::$master_lang
protected

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

Referenced by getMasterLanguage().

◆ $parent_id

ilPageMultiLang::$parent_id
protected

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

Referenced by getParentId().

◆ $parent_type

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: