ILIAS  release_8 Revision v8.24
class.ilObjRootFolder.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
24{
25 public function __construct(
26 int $a_id,
27 bool $a_call_by_reference = true
28 ) {
29 $this->type = "root";
30 parent::__construct($a_id, $a_call_by_reference);
31 }
32
36 public function delete(): bool
37 {
38 $message = get_class($this) . "::delete(): Can't delete root folder!";
39 throw new ilException($message);
40 }
41
42 public function getTranslations(): array
43 {
44 global $ilDB;
45
46 $q = "SELECT * FROM object_translation WHERE obj_id = " .
47 $ilDB->quote($this->getId(), 'integer') . " ORDER BY lang_default DESC";
48 $r = $this->ilias->db->query($q);
49
50 $num = 0;
51
52 $data["Fobject"] = [];
53 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
54 $data["Fobject"][$num] = [
55 "title" => $row->title,
56 "desc" => $row->description,
57 "lang" => $row->lang_code
58 ];
59 $num++;
60 }
61
62 // first entry is always the default language
63 $data["default_language"] = 0;
64
65 return $data ?: [];
66 }
67
68 // remove translations of current category
69 public function deleteTranslation(string $a_lang): void
70 {
71 global $ilDB;
72
73 $query = "DELETE FROM object_translation WHERE obj_id= " .
74 $ilDB->quote($this->getId(), 'integer') . " AND lang_code = " .
75 $ilDB->quote($a_lang, 'text');
76 $res = $ilDB->manipulate($query);
77 }
78
79 // remove all Translations of current category
80 public function removeTranslations(): void
81 {
82 global $ilDB;
83
84 $query = "DELETE FROM object_translation WHERE obj_id= " .
85 $ilDB->quote($this->getId(), 'integer');
86 $res = $ilDB->manipulate($query);
87 }
88
89 // add a new translation to current category
90 public function addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default): void
91 {
92 global $ilDB;
93
94 if ($a_title === '') {
95 $a_title = "NO TITLE";
96 }
97
98 $query = "INSERT INTO object_translation " .
99 "(obj_id,title,description,lang_code,lang_default) " .
100 "VALUES " .
101 "(" . $ilDB->quote($this->getId(), 'integer') . "," .
102 $ilDB->quote($a_title, 'text') . "," .
103 $ilDB->quote($a_desc, 'text') . "," .
104 $ilDB->quote($a_lang, 'text') . "," .
105 $ilDB->quote($a_lang_default, 'integer') . ")";
106 $ilDB->manipulate($query);
107 }
108
109 public function addAdditionalSubItemInformation(array &$object): void
110 {
112 }
113}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deleteTranslation(string $a_lang)
addAdditionalSubItemInformation(array &$object)
Add additional information to sub item, e.g.
addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default)
__construct(int $a_id, bool $a_call_by_reference=true)
static addAdditionalSubItemInformation(array &$item)
Parse item data for list entries.
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
header include for all ilias files.
$query
$message
Definition: xapiexit.php:32