19declare(strict_types=1);
60 $this->
lng = $DIC->language();
61 $this->
user = $DIC->user();
62 $this->db =
$DIC->database();
63 $this->setting =
$DIC->settings();
64 $this->tree =
$DIC->repositoryTree();
76 protected function setId(
int $a_id): void
86 public function enable(
bool $a_status): void
88 $this->enabled = $a_status;
96 public function setTitle(
string $a_title): void
98 $this->title = $a_title;
133 $this->description = $a_description;
142 $this->
info = $a_info;
156 $this->type = $a_type;
181 $this->assignments = $a_ass;
194 $this->assignments[] = $a_obj_type;
235 $this->icon_ide = $icon_identifier;
250 $lang = $trans->getLanguages();
252 foreach (
$lang as $k => $v) {
253 if ($v[
'lang_default']) {
259 if (!isset(
$lang[0])) {
262 $lang[0][
'lang_code'] = $trans->getDefaultLanguage();
276 $a_lng = $this->
user->getCurrentLanguage();
278 if (!isset(
$lang[$a_lng])) {
281 return $lang[$a_lng][$a_value] ??
'';
284 public function delete():
bool
291 $query =
'DELETE FROM didactic_tpl_settings ' .
292 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
293 $this->db->manipulate($query);
296 $query =
'DELETE FROM didactic_tpl_sa ' .
297 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
298 $this->db->manipulate($query);
313 $this->
setId($this->db->nextId(
'didactic_tpl_settings'));
314 $query =
'INSERT INTO didactic_tpl_settings (id,enabled,title,description,info,type,auto_generated,exclusive_tpl,icon_ide) ' .
316 $this->db->quote($this->
getId(),
'integer') .
', ' .
317 $this->db->quote($this->
isEnabled(),
'integer') .
', ' .
318 $this->db->quote($this->
getTitle(),
'text') .
', ' .
320 $this->db->quote($this->
getInfo(),
'text') .
', ' .
321 $this->db->quote($this->
getType(),
'integer') .
', ' .
323 $this->db->quote((
int) $this->
isExclusive(),
'integer') .
', ' .
327 $this->db->manipulate($query);
359 $query =
'INSERT INTO didactic_tpl_sa (id,obj_type) ' .
361 $this->db->quote($this->
getId(),
'integer') .
', ' .
362 $this->db->quote($a_obj_type,
'text') .
364 $this->db->manipulate($query);
375 $this->db->quote($this->
getId(),
'integer') .
', ' .
376 $this->db->quote($node,
'integer') .
380 $query =
'INSERT INTO didactic_tpl_en (id,node) ' .
381 'VALUES ' . implode(
', ', $values);
383 $this->db->manipulate($query);
388 $query =
'DELETE FROM didactic_tpl_en ' .
389 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
390 $this->db->manipulate($query);
397 $effective_nodes = [];
399 $query =
'SELECT * FROM didactic_tpl_en ' .
400 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
401 $res = $this->db->query($query);
403 $effective_nodes[] = (
int) $row->node;
418 $query =
'DELETE FROM didactic_tpl_sa ' .
419 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
420 $this->db->manipulate($query);
427 $query =
'UPDATE didactic_tpl_settings ' .
429 'enabled = ' . $this->db->quote($this->
isEnabled(),
'integer') .
', ' .
430 'title = ' . $this->db->quote($this->
getTitle(),
'text') .
', ' .
431 'description = ' . $this->db->quote($this->
getDescription(),
'text') .
', ' .
432 'info = ' . $this->db->quote($this->
getInfo(),
'text') .
', ' .
433 'type = ' . $this->db->quote($this->
getType(),
'integer') .
', ' .
434 'exclusive_tpl = ' . $this->db->quote((
int) $this->
isExclusive(),
'integer') .
', ' .
436 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
437 $this->db->manipulate($query);
446 protected function read(): bool
448 if (!$this->
getId()) {
451 $query =
'SELECT * FROM didactic_tpl_settings dtpl ' .
452 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
453 $res = $this->db->query($query);
455 $this->
setType((
int) $row->type);
456 $this->
enable((
bool) $row->enabled);
457 $this->
setTitle((
string) $row->title);
459 $this->
setInfo((
string) $row->info);
464 $query =
'SELECT * FROM didactic_tpl_sa ' .
465 'WHERE id = ' . $this->db->quote($this->
getId(),
'integer');
466 $res = $this->db->query($query);
493 $info_lines = (array) explode(
"\n", $this->
getInfo());
494 foreach ($info_lines as
$info) {
495 $trimmed_info = trim(
$info);
496 if ($trimmed_info !==
'') {
507 $writer->
xmlStartTag(
'effectiveFrom', [
'nic_id' => $this->setting->get(
'inst_id')]);
517 $writer->
xmlElement(
'assignment', [], $assignment);
522 $action->toXml($writer);
552 if ($a_node_id > 0 && $this->tree->isGrandChild($node, $a_node_id)) {
static getActionsByTemplateId(int $a_tpl_id)
Get actions of one template.
static appendCopyInfo(string $a_orig_title)
Icon handler for didactic template custom icons.
static deleteByTemplateId(int $a_tpl_id)
addAssignment(string $a_obj_type)
setDescription(string $a_description)
setExclusive(bool $exclusive)
saveAssignment(string $a_obj_type)
Add one object assignment.
setInfo(string $a_info)
Set installation info text.
getPresentation(string $a_value, string $a_lng)
getPresentationDescription(string $a_lng="")
__construct(int $a_id=0)
Constructor.
saveAssignments()
Save assignments in DB.
getTranslations()
Get all translations from this object.
hasIconSupport(ilObjectDefinition $definition)
setTitle(string $a_title)
setIconIdentifier(string $icon_identifier)
getInfo()
Get installation info text.
setAssignments(array $a_ass)
getPresentationTitle(string $a_lng="")
isEffective(int $a_node_id)
deleteAssignments()
Delete assignments.
toXml(ilXmlWriter $writer)
setEffectiveFrom(array $effective_from)
setAutoGenerated(bool $auto_generated)
ilDidacticTemplateIconHandler $iconHandler
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $a_obj_id, string $a_type)
parses the objects.xml it handles the xml-description of all ilias objects
isContainer(string $obj_name)
Check if object type is container ('crs','fold','grp' ...)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.