ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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 }
Base exception class for copage service.
setParentId($a_val)
Set parent id.
getParentType()
Get parent type.
getParentId()
Get parent id.
setParentType($a_val)
Set parent type.
global $ilDB

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

+ 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.

138 {
139 if ($a_lang != "" && !in_array($a_lang, $this->languages))
140 {
141 $this->languages[] = $a_lang;
142 }
143 }

Referenced by read().

+ 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.

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.
getLanguages()
Get languages.
getMasterLanguage()
Get master language.
getActivated()
Get activated.

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

+ 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 }

References getParentId().

+ Here is the call graph for this function:

◆ getActivated()

ilPageMultiLang::getActivated ( )

Get activated.

Returns
bool activated?

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

162 {
163 return $this->activated;
164 }

References $activated.

Referenced by copy(), and getEffectiveLang().

+ 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.

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.

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

+ 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.

128 {
129 return $this->languages;
130 }

References $languages.

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

+ 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.

108 {
109 return $this->master_lang;
110 }

References $master_lang.

Referenced by copy(), and save().

+ 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(), delete(), getEffectiveLang(), and save().

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

+ Here is the caller graph for this function:

◆ read()

ilPageMultiLang::read ( )

Read.

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

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 }
setActivated($a_val)
Set activated.
setLanguages(array $a_val)
Set languages.
addLanguage($a_lang)
Add language.
setMasterLanguage($a_val)
Set master language.

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

Referenced by __construct().

+ 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.

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 }

References $lang, getLanguages(), getMasterLanguage(), and getParentId().

+ 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.

152 {
153 $this->activated = $a_val;
154 }

Referenced by read().

+ 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.

118 {
119 $this->languages = $a_val;
120 }

Referenced by read().

+ 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.

98 {
99 $this->master_lang = $a_val;
100 }

Referenced by read().

+ 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.

78 {
79 $this->parent_id = $a_val;
80 }

Referenced by __construct().

+ 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.

58 {
59 $this->parent_type = $a_val;
60 }

Referenced by __construct().

+ 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: