ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjRootFolder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 public function __construct(
29 int $a_id,
30 bool $a_call_by_reference = true
31 ) {
32 $this->type = "root";
33 parent::__construct($a_id, $a_call_by_reference);
34 }
35
39 public function delete(): bool
40 {
41 $message = get_class($this) . "::delete(): Can't delete root folder!";
42 throw new ilException($message);
43 }
44
45 public function getTranslations(): array
46 {
47 global $ilDB;
48
49 $q = "SELECT * FROM object_translation WHERE obj_id = " .
50 $ilDB->quote($this->getId(), 'integer') . " ORDER BY lang_default DESC";
51 $r = $this->ilias->db->query($q);
52
53 $num = 0;
54
55 $data["Fobject"] = [];
56 while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
57 $data["Fobject"][$num] = [
58 "title" => $row->title,
59 "desc" => $row->description,
60 "lang" => $row->lang_code
61 ];
62 $num++;
63 }
64
65 // first entry is always the default language
66 $data["default_language"] = 0;
67
68 return $data ?: [];
69 }
70
71 // remove translations of current category
72 public function deleteTranslation(string $a_lang): void
73 {
74 global $ilDB;
75
76 $query = "DELETE FROM object_translation WHERE obj_id= " .
77 $ilDB->quote($this->getId(), 'integer') . " AND lang_code = " .
78 $ilDB->quote($a_lang, 'text');
79 $res = $ilDB->manipulate($query);
80 }
81
82 // remove all Translations of current category
83 public function removeTranslations(): void
84 {
85 global $ilDB;
86
87 $query = "DELETE FROM object_translation WHERE obj_id= " .
88 $ilDB->quote($this->getId(), 'integer');
89 $res = $ilDB->manipulate($query);
90 }
91
92 // add a new translation to current category
93 public function addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default): void
94 {
95 global $ilDB;
96
97 if ($a_title === '') {
98 $a_title = "NO TITLE";
99 }
100
101 $query = "INSERT INTO object_translation " .
102 "(obj_id,title,description,lang_code,lang_default) " .
103 "VALUES " .
104 "(" . $ilDB->quote($this->getId(), 'integer') . "," .
105 $ilDB->quote($a_title, 'text') . "," .
106 $ilDB->quote($a_desc, 'text') . "," .
107 $ilDB->quote($a_lang, 'text') . "," .
108 $ilDB->quote($a_lang_default, 'integer') . ")";
109 $ilDB->manipulate($query);
110 }
111
112 public function addAdditionalSubItemInformation(array &$object): void
113 {
115 }
116}
Class ilContainer.
Base class for ILIAS Exception handling.
Class ilObjRootFolder.
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
Class ilObjForumAdministration.
$q
Definition: shib_logout.php:23
$message
Definition: xapiexit.php:31