ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $ilDB, getParentId(), getParentType(), read(), setParentId(), and setParentType().

29  {
30  global $ilDB;
31 
32  $this->db = $ilDB;
33 
34  $this->setParentType($a_parent_type);
35  $this->setParentId($a_parent_id);
36 
37  if ($this->getParentType() == "")
38  {
39  include_once("./Services/COPage/exceptions/class.ilCOPageException.php");
40  throw new ilCOPageException("ilPageMultiLang: No parent type passed.");
41  }
42 
43  if ($this->getParentId() <= 0)
44  {
45  include_once("./Services/COPage/exceptions/class.ilCOPageException.php");
46  throw new ilCOPageException("ilPageMultiLang: No parent ID passed.");
47  }
48 
49  $this->read();
50  }
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  {
141  $this->languages[] = $a_lang;
142  }
143  }
+ 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 243 of file class.ilPageMultiLang.php.

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

244  {
245  if ($this->getActivated())
246  {
247  $target_ml = new ilPageMultiLang($a_target_parent_type, $a_target_parent_id);
248  $target_ml->setMasterLanguage($this->getMasterLanguage());
249  $target_ml->setLanguages($this->getLanguages());
250  $target_ml->save();
251  return $target_ml;
252  }
253 
254  return null;
255  }
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 199 of file class.ilPageMultiLang.php.

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

◆ getActivated()

ilPageMultiLang::getActivated ( )

Get activated.

Returns
bool activated?

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

References $activated.

Referenced by copy(), and getEffectiveLang().

162  {
163  return $this->activated;
164  }
+ 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 267 of file class.ilPageMultiLang.php.

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

268  {
269  if ($this->getActivated() &&
270  in_array($a_lang, $this->getLanguages()) &&
271  ilPageObject::_exists($this->getParentType(), $this->getParentId(), $a_lang))
272  {
273  return $a_lang;
274  }
275  return "-";
276  }
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 169 of file class.ilPageMultiLang.php.

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

Referenced by __construct().

170  {
171  $set = $this->db->query("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  {
177  $this->setMasterLanguage($rec["master_lang"]);
178  $this->setActivated(true);
179  }
180  else
181  {
182  $this->setActivated(false);
183  }
184 
185  $this->setLanguages(array());
186  $set = $this->db->query("SELECT * FROM copg_multilang_lang ".
187  " WHERE parent_type = ".$this->db->quote($this->getParentType(), "text").
188  " AND parent_id = ".$this->db->quote($this->getParentId(), "integer")
189  );
190  while ($rec = $this->db->fetchAssoc($set))
191  {
192  $this->addLanguage($rec["lang"]);
193  }
194  }
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 214 of file class.ilPageMultiLang.php.

References $lang, and getLanguages().

215  {
216  $this->delete();
217 
218  $this->db->manipulate("INSERT INTO copg_multilang ".
219  "(parent_type, parent_id, master_lang) VALUES (".
220  $this->db->quote($this->getParentType(), "text").",".
221  $this->db->quote($this->getParentId(), "integer").",".
222  $this->db->quote($this->getMasterLanguage(), "text").
223  ")");
224 
225  foreach ($this->getLanguages() as $lang)
226  {
227  $this->db->manipulate("INSERT INTO copg_multilang_lang ".
228  "(parent_type, parent_id, lang) VALUES (".
229  $this->db->quote($this->getParentType(), "text").",".
230  $this->db->quote($this->getParentId(), "integer").",".
231  $this->db->quote($lang, "text").
232  ")");
233  }
234  }
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
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 151 of file class.ilPageMultiLang.php.

Referenced by read().

152  {
153  $this->activated = $a_val;
154  }
+ 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: