ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDidacticTemplateSetting Class Reference
+ Collaboration diagram for ilDidacticTemplateSetting:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 getId ()
 Get id. More...
 
 enable ($a_status)
 Set enabled status. More...
 
 isEnabled ()
 Check if template is enabled. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 getPresentationTitle ($a_lng="")
 
 getDescription ()
 Get description. More...
 
 getPresentationDescription ($a_lng="")
 
 setDescription ($a_description)
 Set description. More...
 
 setInfo ($a_info)
 Set installation info text. More...
 
 getInfo ()
 Get installation info text. More...
 
 setType ($a_type)
 Set type. More...
 
 getType ()
 Get type. More...
 
 setAssignments (array $a_ass)
 Set assignments. More...
 
 getAssignments ()
 Get object assignemnts. More...
 
 addAssignment ($a_obj_type)
 Add one assignment obj type. More...
 
 getEffectiveFrom ()
 
 setEffectiveFrom ($effective_from)
 
 isAutoGenerated ()
 
 isExclusive ()
 
 setExclusive ($exclusive)
 
 getTranslations ()
 get all translations from this object More...
 
 delete ()
 Delete settings. More...
 
 save ()
 Save settings. More...
 
 update ()
 Update settings ilDB $ilDB. More...
 
 toXml (ilXmlWriter $writer)
 Export. More...
 
 __clone ()
 Implemented clone method. More...
 
 getTranslationObject ()
 
 isEffective ($a_node_id)
 

Data Fields

const TYPE_CREATION = 1
 

Protected Member Functions

 setId ($a_id)
 Set id. More...
 
 getPresentation ($a_value, $a_lng)
 
 saveEffectiveNodes ()
 
 deleteEffectiveNodes ()
 
 readEffectiveNodes ()
 
 read ()
 read settings from db More...
 

Private Member Functions

 setAutoGenerated ($auto_generated)
 DO NOT CHANGE THIS VALUE. More...
 
 saveAssignments ()
 Save assignments in DB. More...
 
 saveAssignment ($a_obj_type)
 Add one object assignment ilDB $ilDB. More...
 
 deleteAssignments ()
 Delete assignments ilDB $ilDB. More...
 

Private Attributes

 $id = 0
 
 $enabled = false
 
 $title = ''
 
 $description = ''
 
 $info = ''
 
 $type = self::TYPE_CREATION
 
 $assignments = array()
 
 $effective_from = array()
 
 $auto_generated = false
 
 $exclusive = false
 

Detailed Description

Definition at line 10 of file class.ilDidacticTemplateSetting.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSetting::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

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

References read(), and setId().

32  {
33  $this->setId($a_id);
34  $this->read();
35  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateSetting::__clone ( )

Implemented clone method.

Definition at line 608 of file class.ilDidacticTemplateSetting.php.

References ilDidacticTemplateCopier\appendCopyInfo(), enable(), getTitle(), setAutoGenerated(), setId(), and setTitle().

609  {
610  $this->setId(0);
611  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateCopier.php';
613  $this->enable(false);
614  $this->setAutoGenerated(false);
615  }
setAutoGenerated($auto_generated)
DO NOT CHANGE THIS VALUE.
enable($a_status)
Set enabled status.
+ Here is the call graph for this function:

◆ addAssignment()

ilDidacticTemplateSetting::addAssignment (   $a_obj_type)

Add one assignment obj type.

Parameters
string$a_obj_type

Definition at line 197 of file class.ilDidacticTemplateSetting.php.

Referenced by read().

198  {
199  $this->assignments[] = $a_obj_type;
200  }
+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateSetting::delete ( )

Delete settings.

Definition at line 302 of file class.ilDidacticTemplateSetting.php.

References $action, $ilDB, $query, ilDidacticTemplateObjSettings\deleteByTemplateId(), deleteEffectiveNodes(), ilDidacticTemplateActionFactory\getActionsByTemplateId(), getId(), getTranslationObject(), and isAutoGenerated().

303  {
304  global $ilDB;
305 
306  if ($this->isAutoGenerated()) {
307  return false;
308  }
309 
310  // Delete settings
311  $query = 'DELETE FROM didactic_tpl_settings ' .
312  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
313  $ilDB->manipulate($query);
314 
315  // Delete obj assignments
316  $query = 'DELETE FROM didactic_tpl_sa ' .
317  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
318  $ilDB->manipulate($query);
319 
320  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
322  $action->delete();
323  }
324 
325  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
327 
328  $this->getTranslationObject()->delete();
329  $this->deleteEffectiveNodes();
330  return true;
331  }
$action
static deleteByTemplateId($a_tpl_id)
Delete by template id ilDB $ilDB.
$query
global $ilDB
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
+ Here is the call graph for this function:

◆ deleteAssignments()

ilDidacticTemplateSetting::deleteAssignments ( )
private

Delete assignments ilDB $ilDB.

Returns
bool

Definition at line 452 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, getId(), and isAutoGenerated().

Referenced by update().

453  {
454  global $ilDB;
455 
456  if ($this->isAutoGenerated()) {
457  return false;
458  }
459 
460  $query = 'DELETE FROM didactic_tpl_sa ' .
461  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
462  $ilDB->manipulate($query);
463  return true;
464  }
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteEffectiveNodes()

ilDidacticTemplateSetting::deleteEffectiveNodes ( )
protected

Definition at line 422 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, and getId().

Referenced by delete(), and update().

423  {
424  global $ilDB;
425 
426  $query = 'DELETE FROM didactic_tpl_en ' .
427  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
428  $ilDB->manipulate($query);
429  return true;
430  }
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enable()

ilDidacticTemplateSetting::enable (   $a_status)

Set enabled status.

Parameters
bool$a_status

Definition at line 59 of file class.ilDidacticTemplateSetting.php.

Referenced by __clone(), and read().

60  {
61  $this->enabled = $a_status;
62  }
+ Here is the caller graph for this function:

◆ getAssignments()

ilDidacticTemplateSetting::getAssignments ( )

Get object assignemnts.

Returns
array

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

References $assignments, and array.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), saveAssignments(), and toXml().

189  {
190  return (array) $this->assignments;
191  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getDescription()

ilDidacticTemplateSetting::getDescription ( )

Get description.

Returns
string

Definition at line 110 of file class.ilDidacticTemplateSetting.php.

References $description.

Referenced by getPresentationDescription(), getTranslations(), save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ getEffectiveFrom()

ilDidacticTemplateSetting::getEffectiveFrom ( )
Returns
int[]

Definition at line 205 of file class.ilDidacticTemplateSetting.php.

References $effective_from.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), isEffective(), saveEffectiveNodes(), and toXml().

+ Here is the caller graph for this function:

◆ getId()

ilDidacticTemplateSetting::getId ( )

◆ getInfo()

ilDidacticTemplateSetting::getInfo ( )

Get installation info text.

Returns
string

Definition at line 152 of file class.ilDidacticTemplateSetting.php.

References $info.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ getPresentation()

ilDidacticTemplateSetting::getPresentation (   $a_value,
  $a_lng 
)
protected

Definition at line 279 of file class.ilDidacticTemplateSetting.php.

References $ilUser, $lang, and getTranslationObject().

Referenced by getPresentationDescription(), and getPresentationTitle().

280  {
281  $lang = $this->getTranslationObject()->getLanguages();
282 
283  if (!$lang) {
284  return "";
285  }
286 
287  if (!$a_lng) {
288  global $ilUser;
289  $a_lng = $ilUser->getCurrentLanguage();
290  }
291 
292  if (isset($lang[$a_lng][$a_value])) {
293  return $lang[$a_lng][$a_value] ;
294  } else {
295  return $lang[$a_lng][$this->getTranslationObject()->getDefaultLanguage()];
296  }
297  }
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPresentationDescription()

ilDidacticTemplateSetting::getPresentationDescription (   $a_lng = "")
Parameters
string$a_lng
Returns
string

Definition at line 119 of file class.ilDidacticTemplateSetting.php.

References $lng, getDescription(), getPresentation(), and isAutoGenerated().

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate().

120  {
121  if ($this->isAutoGenerated()) {
122  global $lng;
123  return $lng->txt($this->getDescription());
124  }
125 
126  $desc = $this->getPresentation('description', $a_lng);
127  return $desc ? $desc : $this->getDescription();
128  }
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPresentationTitle()

ilDidacticTemplateSetting::getPresentationTitle (   $a_lng = "")
Parameters
string$a_lng
Returns
string

Definition at line 95 of file class.ilDidacticTemplateSetting.php.

References $lng, getPresentation(), getTitle(), and isAutoGenerated().

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate().

96  {
97  if ($this->isAutoGenerated()) {
98  global $lng;
99  return $lng->txt($this->getTitle());
100  }
101 
102  $tit = $this->getPresentation('title', $a_lng);
103  return $tit ? $tit : $this->getTitle();
104  }
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitle()

ilDidacticTemplateSetting::getTitle ( )

Get title.

Returns
string

Definition at line 86 of file class.ilDidacticTemplateSetting.php.

References $title.

Referenced by __clone(), getPresentationTitle(), getTranslations(), save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ getTranslationObject()

ilDidacticTemplateSetting::getTranslationObject ( )
Returns
ilMultilingualism

Definition at line 620 of file class.ilDidacticTemplateSetting.php.

References getId(), and ilMultilingualism\getInstance().

Referenced by delete(), getPresentation(), getTranslations(), and toXml().

621  {
622  include_once("./Services/Multilingualism/classes/class.ilMultilingualism.php");
623  return ilMultilingualism::getInstance($this->getId(), "dtpl");
624  }
static getInstance($a_obj_id, $a_type)
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTranslations()

ilDidacticTemplateSetting::getTranslations ( )

get all translations from this object

public

Returns
array

Definition at line 258 of file class.ilDidacticTemplateSetting.php.

References $lang, getDescription(), getTitle(), and getTranslationObject().

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate().

259  {
260  $trans = $this->getTranslationObject();
261  $lang = $trans->getLanguages();
262 
263  foreach ($lang as $k => $v) {
264  if ($v['lang_default']) {
265  $lang[0] = $lang[$k];
266  }
267  }
268 
269  // fallback if translation object is empty
270  if (!isset($lang[0])) {
271  $lang[0]['title'] = $this->getTitle();
272  $lang[0]['description'] = $this->getDescription();
273  $lang[0]['lang_code'] = $trans->getDefaultLanguage();
274  }
275 
276  return $lang;
277  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateSetting::getType ( )

Get type.

Returns
int

Definition at line 170 of file class.ilDidacticTemplateSetting.php.

References $type.

Referenced by save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ isAutoGenerated()

ilDidacticTemplateSetting::isAutoGenerated ( )

◆ isEffective()

ilDidacticTemplateSetting::isEffective (   $a_node_id)
Parameters
int$a_node_id
Returns
bool

Definition at line 630 of file class.ilDidacticTemplateSetting.php.

References getEffectiveFrom().

631  {
632  global $tree;
633 
634  if (!count($this->getEffectiveFrom()) || in_array($a_node_id, $this->getEffectiveFrom())) {
635  return true;
636  }
637 
638  foreach ($this->getEffectiveFrom() as $node) {
639  if ($tree->isGrandChild($node, $a_node_id)) {
640  return true;
641  }
642  }
643 
644  return false;
645  }
+ Here is the call graph for this function:

◆ isEnabled()

ilDidacticTemplateSetting::isEnabled ( )

Check if template is enabled.

Returns
bool

Definition at line 68 of file class.ilDidacticTemplateSetting.php.

References $enabled.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), save(), and update().

+ Here is the caller graph for this function:

◆ isExclusive()

ilDidacticTemplateSetting::isExclusive ( )
Returns
boolean

Definition at line 239 of file class.ilDidacticTemplateSetting.php.

References $exclusive.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ read()

ilDidacticTemplateSetting::read ( )
protected

read settings from db

Returns
bool

Read settings

Read assigned objects

Definition at line 498 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, $res, $row, addAssignment(), enable(), ilDBConstants\FETCHMODE_OBJECT, getId(), readEffectiveNodes(), setAutoGenerated(), setDescription(), setExclusive(), setInfo(), setTitle(), and setType().

Referenced by __construct().

499  {
500  global $ilDB;
501 
502  if (!$this->getId()) {
503  return false;
504  }
505 
509  $query = 'SELECT * FROM didactic_tpl_settings dtpl ' .
510  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
511  $res = $ilDB->query($query);
512  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
513  $this->setType($row->type);
514  $this->enable($row->enabled);
515  $this->setTitle($row->title);
516  $this->setDescription($row->description);
517  $this->setInfo($row->info);
518  $this->setAutoGenerated((bool) $row->auto_generated);
519  $this->setExclusive((bool) $row->exclusive_tpl);
520  }
521 
525  $query = 'SELECT * FROM didactic_tpl_sa ' .
526  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
527  $res = $ilDB->query($query);
528  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
529  $this->addAssignment($row->obj_type);
530  }
531 
532  $this->readEffectiveNodes();
533 
534  return true;
535  }
setInfo($a_info)
Set installation info text.
addAssignment($a_obj_type)
Add one assignment obj type.
setAutoGenerated($auto_generated)
DO NOT CHANGE THIS VALUE.
foreach($_POST as $key=> $value) $res
$query
enable($a_status)
Set enabled status.
global $ilDB
setDescription($a_description)
Set description.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readEffectiveNodes()

ilDidacticTemplateSetting::readEffectiveNodes ( )
protected

Definition at line 432 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, $res, $row, array, ilDBConstants\FETCHMODE_OBJECT, getId(), and setEffectiveFrom().

Referenced by read().

433  {
434  global $ilDB;
435  $effective_nodes = array();
436 
437  $query = 'SELECT * FROM didactic_tpl_en ' .
438  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
439  $res = $ilDB->query($query);
440  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
441  $effective_nodes[] = $row->node;
442  }
443 
444  $this->setEffectiveFrom($effective_nodes);
445  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilDidacticTemplateSetting::save ( )

Save settings.

Definition at line 336 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, getDescription(), getId(), getInfo(), getTitle(), getType(), isAutoGenerated(), isEnabled(), isExclusive(), saveAssignments(), and setId().

337  {
338  global $ilDB;
339 
340  $this->setId($ilDB->nextId('didactic_tpl_settings'));
341 
342  $query = 'INSERT INTO didactic_tpl_settings (id,enabled,title,description,info,type,auto_generated,exclusive_tpl) ' .
343  'VALUES( ' .
344  $ilDB->quote($this->getId(), 'integer') . ', ' .
345  $ilDB->quote($this->isEnabled(), 'integer') . ', ' .
346  $ilDB->quote($this->getTitle(), 'text') . ', ' .
347  $ilDB->quote($this->getDescription(), 'text') . ', ' .
348  $ilDB->quote($this->getInfo(), 'text') . ', ' .
349  $ilDB->quote($this->getType(), 'integer') . ', ' .
350  $ilDB->quote((int) $this->isAutoGenerated(), 'integer') . ', ' .
351  $ilDB->quote((int) $this->isExclusive(), 'integer') .
352  ')';
353 
354  $ilDB->manipulate($query);
355 
356  $this->saveAssignments();
357 
358  return true;
359  }
isEnabled()
Check if template is enabled.
$query
global $ilDB
getInfo()
Get installation info text.
+ Here is the call graph for this function:

◆ saveAssignment()

ilDidacticTemplateSetting::saveAssignment (   $a_obj_type)
private

Add one object assignment ilDB $ilDB.

Parameters
string$a_obj_type

Definition at line 382 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, getId(), and isAutoGenerated().

Referenced by saveAssignments().

383  {
384  global $ilDB;
385 
386  if ($this->isAutoGenerated()) {
387  return;
388  }
389 
390  $query = 'INSERT INTO didactic_tpl_sa (id,obj_type) ' .
391  'VALUES( ' .
392  $ilDB->quote($this->getId(), 'integer') . ', ' .
393  $ilDB->quote($a_obj_type, 'text') .
394  ')';
395  $ilDB->manipulate($query);
396  }
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAssignments()

ilDidacticTemplateSetting::saveAssignments ( )
private

Save assignments in DB.

Returns
bool

Definition at line 365 of file class.ilDidacticTemplateSetting.php.

References getAssignments(), isAutoGenerated(), and saveAssignment().

Referenced by save(), and update().

366  {
367  if ($this->isAutoGenerated()) {
368  return false;
369  }
370 
371  foreach ($this->getAssignments() as $ass) {
372  $this->saveAssignment($ass);
373  }
374  return true;
375  }
saveAssignment($a_obj_type)
Add one object assignment ilDB $ilDB.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEffectiveNodes()

ilDidacticTemplateSetting::saveEffectiveNodes ( )
protected

Definition at line 401 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, getEffectiveFrom(), and getId().

Referenced by update().

402  {
403  global $ilDB;
404 
405  if (!count($this->getEffectiveFrom())) {
406  return;
407  }
408 
409  foreach ($this->getEffectiveFrom() as $node) {
410  $values[] = '( ' .
411  $ilDB->quote($this->getId(), 'integer') . ', ' .
412  $ilDB->quote($node, 'integer') .
413  ')';
414  }
415 
416  $query = 'INSERT INTO didactic_tpl_en (id,node) ' .
417  'VALUES ' . implode(', ', $values);
418 
419  $ilDB->manipulate($query);
420  }
$query
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAssignments()

ilDidacticTemplateSetting::setAssignments ( array  $a_ass)

Set assignments.

Parameters
array$a_ass

Definition at line 179 of file class.ilDidacticTemplateSetting.php.

References array.

180  {
181  $this->assignments = (array) $a_ass;
182  }
Create styles array
The data for the language used.

◆ setAutoGenerated()

ilDidacticTemplateSetting::setAutoGenerated (   $auto_generated)
private

DO NOT CHANGE THIS VALUE.

Parameters
bool$auto_generated

Definition at line 231 of file class.ilDidacticTemplateSetting.php.

References $auto_generated.

Referenced by __clone(), and read().

232  {
233  $this->auto_generated = $auto_generated;
234  }
+ Here is the caller graph for this function:

◆ setDescription()

ilDidacticTemplateSetting::setDescription (   $a_description)

Set description.

Parameters
string$a_description

Definition at line 134 of file class.ilDidacticTemplateSetting.php.

Referenced by read().

135  {
136  $this->description = $a_description;
137  }
+ Here is the caller graph for this function:

◆ setEffectiveFrom()

ilDidacticTemplateSetting::setEffectiveFrom (   $effective_from)
Parameters
int[]$effective_from

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

References $effective_from.

Referenced by readEffectiveNodes().

214  {
215  $this->effective_from = $effective_from;
216  }
+ Here is the caller graph for this function:

◆ setExclusive()

ilDidacticTemplateSetting::setExclusive (   $exclusive)
Parameters
boolean$exclusive

Definition at line 247 of file class.ilDidacticTemplateSetting.php.

References $exclusive.

Referenced by read().

248  {
249  $this->exclusive = $exclusive;
250  }
+ Here is the caller graph for this function:

◆ setId()

ilDidacticTemplateSetting::setId (   $a_id)
protected

Set id.

Parameters
int$a_id

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

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

42  {
43  $this->id = $a_id;
44  }
+ Here is the caller graph for this function:

◆ setInfo()

ilDidacticTemplateSetting::setInfo (   $a_info)

Set installation info text.

Parameters
string$a_info

Definition at line 143 of file class.ilDidacticTemplateSetting.php.

Referenced by read().

144  {
145  $this->info = $a_info;
146  }
+ Here is the caller graph for this function:

◆ setTitle()

ilDidacticTemplateSetting::setTitle (   $a_title)

Set title.

Parameters
string$a_title

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

Referenced by __clone(), and read().

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

◆ setType()

ilDidacticTemplateSetting::setType (   $a_type)

Set type.

Parameters
int$a_type

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

References $a_type.

Referenced by read().

162  {
163  $this->type = $a_type;
164  }
$a_type
Definition: workflow.php:92
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateSetting::toXml ( ilXmlWriter  $writer)

Export.

Parameters
ilXmlWriter$writer
Returns
ilXmlWriter

Definition at line 542 of file class.ilDidacticTemplateSetting.php.

References $action, $ilSetting, $info, $type, array, ilDidacticTemplateActionFactory\getActionsByTemplateId(), getAssignments(), getDescription(), getEffectiveFrom(), getId(), getInfo(), getTitle(), getTranslationObject(), getType(), isExclusive(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

543  {
544  global $ilSetting;
545  switch ($this->getType()) {
546  case self::TYPE_CREATION:
547  $type = 'creation';
548  break;
549  }
550 
551  $writer->xmlStartTag('didacticTemplate', array('type' => $type));
552  $writer->xmlElement('title', array(), $this->getTitle());
553  $writer->xmlElement('description', array(), $this->getDescription());
554 
555  $writer = $this->getTranslationObject()->toXml($writer);
556 
557  // info text with p-tags
558  if (strlen($this->getInfo())) {
559  $writer->xmlStartTag('info');
560 
561  $info_lines = (array) explode("\n", $this->getInfo());
562  foreach ($info_lines as $info) {
563  $trimmed_info = trim($info);
564  if (strlen($trimmed_info)) {
565  $writer->xmlElement('p', array(), $trimmed_info);
566  }
567  }
568 
569  $writer->xmlEndTag('info');
570  }
571 
572  if ($this->isExclusive()) {
573  $writer->xmlElement("exclusive");
574  }
575 
576 
577  if (count($this->getEffectiveFrom()) > 0) {
578  $writer->xmlStartTag('effectiveFrom', array('nic_id'=> $ilSetting->get('inst_id')));
579 
580  foreach ($this->getEffectiveFrom() as $node) {
581  $writer->xmlElement('node', array(), $node);
582  }
583  $writer->xmlEndTag('effectiveFrom');
584  }
585 
586  // Assignments
587  $writer->xmlStartTag('assignments');
588  foreach ($this->getAssignments() as $assignment) {
589  $writer->xmlElement('assignment', array(), $assignment);
590  }
591  $writer->xmlEndTag('assignments');
592 
593 
594  $writer->xmlStartTag('actions');
595  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
597  $action->toXml($writer);
598  }
599  $writer->xmlEndTag('actions');
600  $writer->xmlEndTag('didacticTemplate');
601 
602  return $writer;
603  }
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.
$action
xmlEndTag($tag)
Writes an endtag.
Create styles array
The data for the language used.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
global $ilSetting
Definition: privfeed.php:17
getInfo()
Get installation info text.
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
+ Here is the call graph for this function:

◆ update()

ilDidacticTemplateSetting::update ( )

Update settings ilDB $ilDB.

Returns
bool

Definition at line 471 of file class.ilDidacticTemplateSetting.php.

References $ilDB, $query, deleteAssignments(), deleteEffectiveNodes(), getDescription(), getId(), getInfo(), getTitle(), getType(), isEnabled(), isExclusive(), saveAssignments(), and saveEffectiveNodes().

472  {
473  global $ilDB;
474 
475  $query = 'UPDATE didactic_tpl_settings ' .
476  'SET ' .
477  'enabled = ' . $ilDB->quote($this->isEnabled(), 'integer') . ', ' .
478  'title = ' . $ilDB->quote($this->getTitle(), 'text') . ', ' .
479  'description = ' . $ilDB->quote($this->getDescription(), 'text') . ', ' .
480  'info = ' . $ilDB->quote($this->getInfo(), 'text') . ', ' .
481  'type = ' . $ilDB->quote($this->getType(), 'integer') . ', ' .
482  'exclusive_tpl = ' . $ilDB->quote((int) $this->isExclusive(), 'integer') . ' ' .
483  'WHERE id = ' . $ilDB->quote($this->getId(), 'integer');
484  $ilDB->manipulate($query);
485  $this->deleteAssignments();
486  $this->saveAssignments();
487 
488  $this->deleteEffectiveNodes();
489  $this->saveEffectiveNodes();
490 
491  return true;
492  }
isEnabled()
Check if template is enabled.
$query
global $ilDB
deleteAssignments()
Delete assignments ilDB $ilDB.
getInfo()
Get installation info text.
+ Here is the call graph for this function:

Field Documentation

◆ $assignments

ilDidacticTemplateSetting::$assignments = array()
private

Definition at line 21 of file class.ilDidacticTemplateSetting.php.

Referenced by getAssignments().

◆ $auto_generated

ilDidacticTemplateSetting::$auto_generated = false
private

Definition at line 23 of file class.ilDidacticTemplateSetting.php.

Referenced by isAutoGenerated(), and setAutoGenerated().

◆ $description

ilDidacticTemplateSetting::$description = ''
private

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

Referenced by getDescription().

◆ $effective_from

ilDidacticTemplateSetting::$effective_from = array()
private

Definition at line 22 of file class.ilDidacticTemplateSetting.php.

Referenced by getEffectiveFrom(), and setEffectiveFrom().

◆ $enabled

ilDidacticTemplateSetting::$enabled = false
private

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

Referenced by isEnabled().

◆ $exclusive

ilDidacticTemplateSetting::$exclusive = false
private

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

Referenced by isExclusive(), and setExclusive().

◆ $id

ilDidacticTemplateSetting::$id = 0
private

Definition at line 15 of file class.ilDidacticTemplateSetting.php.

Referenced by getId().

◆ $info

ilDidacticTemplateSetting::$info = ''
private

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

Referenced by getInfo(), and toXml().

◆ $title

ilDidacticTemplateSetting::$title = ''
private

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

Referenced by getTitle().

◆ $type

ilDidacticTemplateSetting::$type = self::TYPE_CREATION
private

Definition at line 20 of file class.ilDidacticTemplateSetting.php.

Referenced by getType(), and toXml().

◆ TYPE_CREATION

const ilDidacticTemplateSetting::TYPE_CREATION = 1

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