ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilAdvancedMDSubstitution Class Reference
+ Collaboration diagram for ilAdvancedMDSubstitution:

Public Member Functions

 sortDefinitions (array $a_definitions)
 Sort definitions. More...
 
 isActive ()
 
 isDescriptionEnabled ()
 
 enableDescription (bool $a_status)
 
 enabledFieldNames ()
 
 enableFieldNames (bool $a_status)
 
 getParsedSubstitutions (int $a_ref_id, int $a_obj_id)
 
 resetSubstitutions ()
 
 appendSubstitution (int $a_field_id, bool $a_bold=false, bool $a_newline=false)
 append field to substitutions @access public More...
 
 getSubstitutions ()
 
 isSubstituted (int $a_field_id)
 
 isBold (int $a_field_id)
 
 hasNewline (int $a_field_id)
 
 update ()
 update @access public More...
 

Static Public Member Functions

static _getInstanceByObjectType (string $a_type)
 

Protected Attributes

ilDBInterface $db
 
string $type
 
array $substitutions
 
array $bold = array()
 
array $newline = array()
 
bool $enabled_desc = true
 
bool $enabled_field_names = true
 
bool $active = false
 
array $date_fields = array()
 
array $datetime_fields = array()
 
array $active_fields = array()
 

Private Member Functions

 __construct (string $a_type)
 
 parseValue (int $a_field_id, array $a_values_records)
 
 read ()
 Read db entries @access private. More...
 
 initECSMappings ()
 

Static Private Attributes

static array $instances = null
 
static array $mappings = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAdvancedMDSubstitution::__construct ( string  $a_type)
private

Definition at line 43 of file class.ilAdvancedMDSubstitution.php.

44 {
45 global $DIC;
46
47 $this->db = $DIC->database();
48 $this->type = $a_type;
49
50 $this->initECSMappings();
51 $this->read();
52 }
read()
Read db entries @access private.
global $DIC
Definition: shib_login.php:26

References $DIC, initECSMappings(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstanceByObjectType()

◆ appendSubstitution()

ilAdvancedMDSubstitution::appendSubstitution ( int  $a_field_id,
bool  $a_bold = false,
bool  $a_newline = false 
)

append field to substitutions @access public

Parameters
intfield id

Definition at line 167 of file class.ilAdvancedMDSubstitution.php.

167 : void
168 {
169 $this->substitutions[] = $a_field_id;
170 if ($a_bold) {
171 $this->bold[] = $a_field_id;
172 }
173 if ($a_newline) {
174 $this->newline[] = $a_field_id;
175 }
176 }

References ILIAS\UI\examples\Symbol\Glyph\Bold\bold().

+ Here is the call graph for this function:

◆ enableDescription()

ilAdvancedMDSubstitution::enableDescription ( bool  $a_status)

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

89 : void
90 {
91 $this->enabled_desc = $a_status;
92 }

◆ enabledFieldNames()

ilAdvancedMDSubstitution::enabledFieldNames ( )

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

References $enabled_field_names.

Referenced by getParsedSubstitutions(), and update().

+ Here is the caller graph for this function:

◆ enableFieldNames()

ilAdvancedMDSubstitution::enableFieldNames ( bool  $a_status)

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

99 : void
100 {
101 $this->enabled_field_names = $a_status;
102 }

◆ getParsedSubstitutions()

ilAdvancedMDSubstitution::getParsedSubstitutions ( int  $a_ref_id,
int  $a_obj_id 
)

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

104 : array
105 {
106 if (!count($this->getSubstitutions())) {
107 return array();
108 }
109
110 $values_records = ilAdvancedMDValues::preloadedRead($this->type, $a_obj_id);
111
112 $counter = 0;
113 $substituted = [];
114 foreach ($this->getSubstitutions() as $field_id) {
115 if (!isset($this->active_fields[$field_id])) {
116 continue;
117 }
118
119 $value = $this->parseValue($field_id, $values_records);
120
121 if ($value === null) {
122 if ($this->hasNewline($field_id) and $counter) {
123 $substituted[$counter - 1]['newline'] = true;
124 }
125 continue;
126 }
127
128 $substituted[$counter]['name'] = $this->active_fields[$field_id];
129 $substituted[$counter]['value'] = $value;
130 $substituted[$counter]['bold'] = $this->isBold($field_id);
131 if ($this->hasNewline($field_id)) {
132 $substituted[$counter]['newline'] = true;
133 } else {
134 $substituted[$counter]['newline'] = false;
135 }
136 $substituted[$counter]['show_field'] = $this->enabledFieldNames();
137 $counter++;
138 }
139 return $substituted;
140 }
parseValue(int $a_field_id, array $a_values_records)
static preloadedRead(string $a_type, int $a_obj_id)
$counter

References $counter, enabledFieldNames(), getSubstitutions(), hasNewline(), isBold(), parseValue(), and ilAdvancedMDValues\preloadedRead().

+ Here is the call graph for this function:

◆ getSubstitutions()

ilAdvancedMDSubstitution::getSubstitutions ( )

Definition at line 178 of file class.ilAdvancedMDSubstitution.php.

178 : array
179 {
180 return !$this->substitutions ? array() : $this->substitutions;
181 }

References $substitutions.

Referenced by getParsedSubstitutions(), and isSubstituted().

+ Here is the caller graph for this function:

◆ hasNewline()

ilAdvancedMDSubstitution::hasNewline ( int  $a_field_id)

Definition at line 193 of file class.ilAdvancedMDSubstitution.php.

193 : bool
194 {
195 return in_array($a_field_id, $this->newline);
196 }

Referenced by getParsedSubstitutions(), and update().

+ Here is the caller graph for this function:

◆ initECSMappings()

ilAdvancedMDSubstitution::initECSMappings ( )
private

Definition at line 278 of file class.ilAdvancedMDSubstitution.php.

278 : void
279 {
280 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ isActive()

ilAdvancedMDSubstitution::isActive ( )

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

79 : bool
80 {
81 return $this->active;
82 }

References $active.

◆ isBold()

ilAdvancedMDSubstitution::isBold ( int  $a_field_id)

Definition at line 188 of file class.ilAdvancedMDSubstitution.php.

188 : bool
189 {
190 return in_array($a_field_id, $this->bold);
191 }

References ILIAS\UI\examples\Symbol\Glyph\Bold\bold().

Referenced by getParsedSubstitutions(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDescriptionEnabled()

ilAdvancedMDSubstitution::isDescriptionEnabled ( )

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

84 : bool
85 {
87 }

References $enabled_desc.

Referenced by update().

+ Here is the caller graph for this function:

◆ isSubstituted()

ilAdvancedMDSubstitution::isSubstituted ( int  $a_field_id)

Definition at line 183 of file class.ilAdvancedMDSubstitution.php.

183 : bool
184 {
185 return in_array($a_field_id, $this->getSubstitutions());
186 }

References getSubstitutions().

+ Here is the call graph for this function:

◆ parseValue()

ilAdvancedMDSubstitution::parseValue ( int  $a_field_id,
array  $a_values_records 
)
private

Definition at line 142 of file class.ilAdvancedMDSubstitution.php.

142 : ?string
143 {
144 foreach ($a_values_records as $a_values) {
145 if ($a_values->getADTGroup()->hasElement((string) $a_field_id)) {
146 $element = $a_values->getADTGroup()->getElement((string) $a_field_id);
147 if (!$element->isNull()) {
148 return ilADTFactory::getInstance()->getPresentationBridgeForInstance($element)->getList();
149 }
150 }
151 }
152 return null;
153 }

References ilADTFactory\getInstance().

Referenced by getParsedSubstitutions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilAdvancedMDSubstitution::read ( )
private

Read db entries @access private.

Definition at line 234 of file class.ilAdvancedMDSubstitution.php.

234 : void
235 {
236 global $DIC;
237
238 $ilDB = $DIC['ilDB'];
239
240 // Check active status
241 $query = "SELECT active,field_id,amfd.title FROM adv_md_record amr " .
242 "JOIN adv_md_record_objs amro ON amr.record_id = amro.record_id " .
243 "JOIN adv_mdf_definition amfd ON amr.record_id = amfd.record_id " .
244 "WHERE active = 1 " .
245 "AND obj_type = " . $this->db->quote($this->type, 'text') . " ";
246 $res = $this->db->query($query);
247 $this->active = $res->numRows() ? true : false;
248 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
249 $this->active_fields[(int) $row->field_id] = (string) $row->title;
250 }
251
252 $query = "SELECT * FROM adv_md_substitutions " .
253 "WHERE obj_type = " . $this->db->quote($this->type, 'text') . " ";
254 $res = $this->db->query($query);
255 $this->substitutions = array();
256 $this->bold = array();
257 $this->newline = array();
258 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
259 $tmp_substitutions = unserialize((string) $row->substitution);
260 if (is_array($tmp_substitutions)) {
261 foreach ($tmp_substitutions as $substitution) {
262 if ($substitution['field_id']) {
263 $this->substitutions[] = $substitution['field_id'];
264 }
265 if ($substitution['bold']) {
266 $this->bold[] = $substitution['field_id'];
267 }
268 if ($substitution['newline']) {
269 $this->newline[] = $substitution['field_id'];
270 }
271 }
272 }
273 $this->enabled_desc = !$row->hide_description;
274 $this->enabled_field_names = !$row->hide_field_names;
275 }
276 }
return true
$res
Definition: ltiservices.php:69

References $DIC, $ilDB, $res, ILIAS\UI\examples\Symbol\Glyph\Bold\bold(), ilDBConstants\FETCHMODE_OBJECT, ILIAS\Repository\int(), and true.

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resetSubstitutions()

ilAdvancedMDSubstitution::resetSubstitutions ( )

Definition at line 155 of file class.ilAdvancedMDSubstitution.php.

155 : void
156 {
157 $this->substitutions = array();
158 $this->bold = array();
159 $this->newline = array();
160 }

References ILIAS\UI\examples\Symbol\Glyph\Bold\bold().

+ Here is the call graph for this function:

◆ sortDefinitions()

ilAdvancedMDSubstitution::sortDefinitions ( array  $a_definitions)

Sort definitions.

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

67 : array
68 {
69 $sorted = array();
70 foreach ($this->substitutions as $field_id) {
71 if (isset($a_definitions[$field_id])) {
72 $sorted[$field_id] = $a_definitions[$field_id];
73 unset($a_definitions[$field_id]);
74 }
75 }
76 return array_merge($sorted, $a_definitions);
77 }

◆ update()

ilAdvancedMDSubstitution::update ( )

update @access public

Definition at line 202 of file class.ilAdvancedMDSubstitution.php.

202 : void
203 {
204 global $DIC;
205
206 $ilDB = $DIC['ilDB'];
207
208 $counter = 0;
209 $substitutions = array();
210
211 foreach ($this->substitutions as $field_id) {
212 $substitutions[$counter]['field_id'] = $field_id;
213 $substitutions[$counter]['bold'] = $this->isBold($field_id);
214 $substitutions[$counter]['newline'] = $this->hasNewline($field_id);
215 $counter++;
216 }
217
218 $query = "DELETE FROM adv_md_substitutions WHERE obj_type = " . $ilDB->quote($this->type, 'text');
219 $res = $ilDB->manipulate($query);
220
221 $values = array(
222 'obj_type' => array('text', $this->type),
223 'substitution' => array('clob', serialize($substitutions)),
224 'hide_description' => array('integer', !$this->isDescriptionEnabled()),
225 'hide_field_names' => array('integer', !$this->enabledFieldNames())
226 );
227 $ilDB->insert('adv_md_substitutions', $values);
228 }

References $counter, $DIC, $ilDB, $res, $substitutions, enabledFieldNames(), hasNewline(), isBold(), and isDescriptionEnabled().

+ Here is the call graph for this function:

Field Documentation

◆ $active

bool ilAdvancedMDSubstitution::$active = false
protected

Definition at line 38 of file class.ilAdvancedMDSubstitution.php.

Referenced by isActive().

◆ $active_fields

array ilAdvancedMDSubstitution::$active_fields = array()
protected

Definition at line 41 of file class.ilAdvancedMDSubstitution.php.

◆ $bold

array ilAdvancedMDSubstitution::$bold = array()
protected

Definition at line 33 of file class.ilAdvancedMDSubstitution.php.

◆ $date_fields

array ilAdvancedMDSubstitution::$date_fields = array()
protected

Definition at line 39 of file class.ilAdvancedMDSubstitution.php.

◆ $datetime_fields

array ilAdvancedMDSubstitution::$datetime_fields = array()
protected

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

◆ $db

ilDBInterface ilAdvancedMDSubstitution::$db
protected

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

◆ $enabled_desc

bool ilAdvancedMDSubstitution::$enabled_desc = true
protected

Definition at line 36 of file class.ilAdvancedMDSubstitution.php.

Referenced by isDescriptionEnabled().

◆ $enabled_field_names

bool ilAdvancedMDSubstitution::$enabled_field_names = true
protected

Definition at line 37 of file class.ilAdvancedMDSubstitution.php.

Referenced by enabledFieldNames().

◆ $instances

array ilAdvancedMDSubstitution::$instances = null
staticprivate

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

◆ $mappings

array ilAdvancedMDSubstitution::$mappings = null
staticprivate

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

◆ $newline

array ilAdvancedMDSubstitution::$newline = array()
protected

Definition at line 34 of file class.ilAdvancedMDSubstitution.php.

◆ $substitutions

array ilAdvancedMDSubstitution::$substitutions
protected

Definition at line 32 of file class.ilAdvancedMDSubstitution.php.

Referenced by getSubstitutions(), and update().

◆ $type

string ilAdvancedMDSubstitution::$type
protected

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


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