ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilPageMultiLang Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilPageMultiLang:

Public Member Functions

 __construct (string $a_parent_type, int $a_parent_id)
 Constructor. More...
 
 setParentType (string $a_val)
 
 getParentType ()
 
 setParentId (int $a_val)
 
 getParentId ()
 
 setMasterLanguage (string $a_val)
 
 getMasterLanguage ()
 
 setLanguages (array $a_val)
 
 getLanguages ()
 
 addLanguage (string $a_lang)
 
 getActivated ()
 
 read ()
 
 delete ()
 
 save ()
 
 copy (string $a_target_parent_type, int $a_target_parent_id)
 Copy multilinguality settings. More...
 
 getEffectiveLang (string $a_lang)
 Get effective language for given language. More...
 

Protected Member Functions

 setActivated (bool $a_val)
 

Protected Attributes

ilDBInterface $db
 
string $parent_type
 
int $parent_id
 
string $master_lang
 
array $languages = array()
 
bool $activated = false
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Multi-language properties

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilPageMultiLang::__construct ( string  $a_parent_type,
int  $a_parent_id 
)

Constructor.

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

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

43 {
44 global $DIC;
45
46 $ilDB = $DIC->database();
47
48 $this->db = $ilDB;
49
50 $this->setParentType($a_parent_type);
51 $this->setParentId($a_parent_id);
52
53 if ($this->getParentType() == "") {
54 throw new ilCOPageException("ilPageMultiLang: No parent type passed.");
55 }
56
57 if ($this->getParentId() <= 0) {
58 throw new ilCOPageException("ilPageMultiLang: No parent ID passed.");
59 }
60
61 $this->read();
62 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setParentType(string $a_val)
global $DIC
Definition: shib_login.php:26

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguage()

ilPageMultiLang::addLanguage ( string  $a_lang)

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

104 : void
105 {
106 if ($a_lang != "" && !in_array($a_lang, $this->languages)) {
107 $this->languages[] = $a_lang;
108 }
109 }

Referenced by read().

+ Here is the caller graph for this function:

◆ copy()

ilPageMultiLang::copy ( string  $a_target_parent_type,
int  $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
Exceptions
ilCOPageException

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

192 : ?ilPageMultiLang {
193 if ($this->getActivated()) {
194 $target_ml = new ilPageMultiLang($a_target_parent_type, $a_target_parent_id);
195 $target_ml->setMasterLanguage($this->getMasterLanguage());
196 $target_ml->setLanguages($this->getLanguages());
197 $target_ml->save();
198 return $target_ml;
199 }
200
201 return null;
202 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References getLanguages(), and getMasterLanguage().

+ Here is the call graph for this function:

◆ delete()

ilPageMultiLang::delete ( )

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

146 : void
147 {
148 $this->db->manipulate(
149 "DELETE FROM copg_multilang " .
150 " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
151 " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
152 );
153 $this->db->manipulate(
154 "DELETE FROM copg_multilang_lang " .
155 " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
156 " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
157 );
158 }

References getParentId().

+ Here is the call graph for this function:

◆ getActivated()

ilPageMultiLang::getActivated ( )

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

116 : bool
117 {
118 return $this->activated;
119 }

References $activated.

◆ getEffectiveLang()

ilPageMultiLang::getEffectiveLang ( string  $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 214 of file class.ilPageMultiLang.php.

214 : string
215 {
216 if ($this->getActivated() &&
217 in_array($a_lang, $this->getLanguages()) &&
218 ilPageObject::_exists($this->getParentType(), $this->getParentId(), $a_lang)) {
219 return $a_lang;
220 }
221 return "-";
222 }
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.

References ilPageObject\_exists().

+ Here is the call graph for this function:

◆ getLanguages()

ilPageMultiLang::getLanguages ( )

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

99 : array
100 {
101 return $this->languages;
102 }

References $languages.

Referenced by copy(), and save().

+ Here is the caller graph for this function:

◆ getMasterLanguage()

ilPageMultiLang::getMasterLanguage ( )

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

89 : string
90 {
91 return $this->master_lang;
92 }

References $master_lang.

Referenced by copy(), and save().

+ Here is the caller graph for this function:

◆ getParentId()

ilPageMultiLang::getParentId ( )

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

79 : int
80 {
81 return $this->parent_id;
82 }

References $parent_id.

Referenced by __construct(), delete(), and save().

+ Here is the caller graph for this function:

◆ getParentType()

ilPageMultiLang::getParentType ( )

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

69 : string
70 {
71 return $this->parent_type;
72 }

References $parent_type.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ read()

ilPageMultiLang::read ( )

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

121 : void
122 {
123 $set = $this->db->query(
124 "SELECT * FROM copg_multilang " .
125 " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
126 " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
127 );
128 if ($rec = $this->db->fetchAssoc($set)) {
129 $this->setMasterLanguage($rec["master_lang"]);
130 $this->setActivated(true);
131 } else {
132 $this->setActivated(false);
133 }
134
135 $this->setLanguages(array());
136 $set = $this->db->query(
137 "SELECT * FROM copg_multilang_lang " .
138 " WHERE parent_type = " . $this->db->quote($this->getParentType(), "text") .
139 " AND parent_id = " . $this->db->quote($this->getParentId(), "integer")
140 );
141 while ($rec = $this->db->fetchAssoc($set)) {
142 $this->addLanguage($rec["lang"]);
143 }
144 }
setLanguages(array $a_val)
setMasterLanguage(string $a_val)
addLanguage(string $a_lang)

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

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

160 : void
161 {
162 $this->delete();
163
164 $this->db->manipulate("INSERT INTO copg_multilang " .
165 "(parent_type, parent_id, master_lang) VALUES (" .
166 $this->db->quote($this->getParentType(), "text") . "," .
167 $this->db->quote($this->getParentId(), "integer") . "," .
168 $this->db->quote($this->getMasterLanguage(), "text") .
169 ")");
170
171 foreach ($this->getLanguages() as $lang) {
172 $this->db->manipulate("INSERT INTO copg_multilang_lang " .
173 "(parent_type, parent_id, lang) VALUES (" .
174 $this->db->quote($this->getParentType(), "text") . "," .
175 $this->db->quote($this->getParentId(), "integer") . "," .
176 $this->db->quote($lang, "text") .
177 ")");
178 }
179 }
$lang
Definition: xapiexit.php:25

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

+ Here is the call graph for this function:

◆ setActivated()

ilPageMultiLang::setActivated ( bool  $a_val)
protected

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

111 : void
112 {
113 $this->activated = $a_val;
114 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setLanguages()

ilPageMultiLang::setLanguages ( array  $a_val)

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

94 : void
95 {
96 $this->languages = $a_val;
97 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMasterLanguage()

ilPageMultiLang::setMasterLanguage ( string  $a_val)

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

84 : void
85 {
86 $this->master_lang = $a_val;
87 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setParentId()

ilPageMultiLang::setParentId ( int  $a_val)

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

74 : void
75 {
76 $this->parent_id = $a_val;
77 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setParentType()

ilPageMultiLang::setParentType ( string  $a_val)

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

64 : void
65 {
66 $this->parent_type = $a_val;
67 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $activated

bool ilPageMultiLang::$activated = false
protected

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

Referenced by getActivated().

◆ $db

ilDBInterface ilPageMultiLang::$db
protected

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

◆ $languages

array ilPageMultiLang::$languages = array()
protected

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

Referenced by getLanguages().

◆ $master_lang

string ilPageMultiLang::$master_lang
protected

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

Referenced by getMasterLanguage().

◆ $parent_id

int ilPageMultiLang::$parent_id
protected

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

Referenced by getParentId().

◆ $parent_type

string ilPageMultiLang::$parent_type
protected

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

Referenced by getParentType().


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