ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjSystemFolder.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
34require_once "./Services/Object/classes/class.ilObject.php";
35
37{
41 protected $user;
42
49 public function __construct($a_id, $a_call_by_reference = true)
50 {
51 global $DIC;
52
53 $this->db = $DIC->database();
54 $this->user = $DIC->user();
55 $this->type = "adm";
56 parent::__construct($a_id, $a_call_by_reference);
57 }
58
59
66 public function delete()
67 {
68 // DISABLED
69 return false;
70
71 // always call parent delete function first!!
72 if (!parent::delete()) {
73 return false;
74 }
75
76 // put here systemfolder specific stuff
77
78 // always call parent delete function at the end!!
79 return true;
80 }
81
88 public function getHeaderTitleTranslations()
89 {
94
95 $q = "SELECT * FROM object_translation WHERE obj_id = " .
96 $ilDB->quote($this->getId(), 'integer') . " ORDER BY lang_default DESC";
97 $r = $ilDB->query($q);
98
99 $num = 0;
100
101 while ($row = $ilDB->fetchObject($r)) {
102 $data["Fobject"][$num]= array("title" => $row->title,
103 "desc" => ilUtil::shortenText($row->description, ilObject::DESC_LENGTH, true),
104 "lang" => $row->lang_code
105 );
106 $num++;
107 }
108
109 // first entry is always the default language
110 $data["default_language"] = 0;
111
112 return $data ? $data : array();
113 }
114
115 // remove all Translations of current category
117 {
119
120 $query = "DELETE FROM object_translation WHERE obj_id= " .
121 $ilDB->quote($this->getId(), 'integer');
122 $res = $ilDB->manipulate($query);
123 }
124
125 // add a new translation to current category
126 public function addHeaderTitleTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
127 {
129
130 $query = "INSERT INTO object_translation " .
131 "(obj_id,title,description,lang_code,lang_default) " .
132 "VALUES " .
133 "(" . $ilDB->quote($this->getId(), 'integer') . "," .
134 $ilDB->quote($a_title, 'text') . "," .
135 $ilDB->quote($a_desc, 'text') . "," .
136 $ilDB->quote($a_lang, 'text') . "," .
137 $ilDB->quote($a_lang_default, 'integer') . ")";
138 $res = $ilDB->manipulate($query);
139
140 return true;
141 }
142
143 public static function _getId()
144 {
148 global $DIC;
149
150 $ilDB = $DIC->database();
151
152 $q = "SELECT obj_id FROM object_data WHERE type = " . $ilDB->quote('adm', 'text');
153 $r = $ilDB->query($q);
154 $row = $ilDB->fetchObject($r);
155
156 return $row->obj_id;
157 }
158
159 public static function _getHeaderTitle()
160 {
165 global $DIC;
166
167 $ilDB = $DIC->database();
168 $ilUser = $DIC->user();
169
170 $id = ilObjSystemFolder::_getId();
171
172 $q = "SELECT title,description FROM object_translation " .
173 "WHERE obj_id = " . $ilDB->quote($id, 'integer') . " " .
174 "AND lang_default = 1";
175 $r = $ilDB->query($q);
176 $row = $ilDB->fetchObject($r);
177 $title = $row->title;
178
179 $q = "SELECT title,description FROM object_translation " .
180 "WHERE obj_id = " . $ilDB->quote($id, 'integer') . " " .
181 "AND lang_code = " .
182 $ilDB->quote($ilUser->getCurrentLanguage(), 'text') . " " .
183 "AND NOT lang_default = 1";
184 $r = $ilDB->query($q);
185 $row = $ilDB->fetchObject($r);
186
187 if ($row) {
188 $title = $row->title;
189 }
190
191 return $title;
192 }
193
195 {
198
199 $id = ilObjSystemFolder::_getId();
200
201 $q = "SELECT title,description FROM object_translation " .
202 "WHERE obj_id = " . $ilDB->quote($id, 'integer') . " " .
203 "AND lang_default = 1";
204 $r = $ilDB->query($q);
205 $row = $ilDB->fetchObject($r);
206 $description = $row->description;
207
208 $q = "SELECT title,description FROM object_translation " .
209 "WHERE obj_id = " . $ilDB->quote($id, 'integer') . " " .
210 "AND lang_code = " .
211 $ilDB->quote($ilUser->getPref("language"), 'text') . " " .
212 "AND NOT lang_default = 1";
213 $r = $ilDB->query($q);
214 $row = $ilDB->fetchObject($r);
215
216 if ($row) {
218 }
219
220 return $description;
221 }
222} // END class.ilObjSystemFolder
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Class ilObjSystemFolder.
__construct($a_id, $a_call_by_reference=true)
Constructor @access public.
addHeaderTitleTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
Class ilObject Basic functions for all objects.
getId()
get object id @access public
const DESC_LENGTH
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
$r
Definition: example_031.php:79
$query
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
$ilUser
Definition: imgupload.php:18