ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
34 require_once "./Services/Object/classes/class.ilObject.php";
35 
37 {
44  function ilObjSystemFolder($a_id,$a_call_by_reference = true)
45  {
46  $this->type = "adm";
47  $this->ilObject($a_id,$a_call_by_reference);
48  }
49 
50 
57  function delete()
58  {
59  // DISABLED
60  return false;
61 
62  // always call parent delete function first!!
63  if (!parent::delete())
64  {
65  return false;
66  }
67 
68  // put here systemfolder specific stuff
69 
70  // always call parent delete function at the end!!
71  return true;
72  }
73 
80  function getHeaderTitleTranslations()
81  {
85  global $ilDB;
86 
87  $q = "SELECT * FROM object_translation WHERE obj_id = ".
88  $ilDB->quote($this->getId(),'integer')." ORDER BY lang_default DESC";
89  $r = $ilDB->query($q);
90 
91  $num = 0;
92 
93  while ($row = $ilDB->fetchObject($r))
94  {
95  $data["Fobject"][$num]= array("title" => $row->title,
96  "desc" => ilUtil::shortenText($row->description,ilObject::DESC_LENGTH,true),
97  "lang" => $row->lang_code
98  );
99  $num++;
100  }
101 
102  // first entry is always the default language
103  $data["default_language"] = 0;
104 
105  return $data ? $data : array();
106  }
107 
108  // remove all Translations of current category
110  {
111  global $ilDB;
112 
113  $query = "DELETE FROM object_translation WHERE obj_id= ".
114  $ilDB->quote($this->getId(),'integer');
115  $res = $ilDB->manipulate($query);
116  }
117 
118  // add a new translation to current category
119  function addHeaderTitleTranslation($a_title,$a_desc,$a_lang,$a_lang_default)
120  {
121  global $ilDB;
122 
123  $query = "INSERT INTO object_translation ".
124  "(obj_id,title,description,lang_code,lang_default) ".
125  "VALUES ".
126  "(".$ilDB->quote($this->getId(),'integer').",".
127  $ilDB->quote($a_title,'text').",".
128  $ilDB->quote($a_desc,'text').",".
129  $ilDB->quote($a_lang,'text').",".
130  $ilDB->quote($a_lang_default,'integer').")";
131  $res = $ilDB->manipulate($query);
132 
133  return true;
134  }
135 
136  function _getId()
137  {
141  global $ilDB;
142 
143  $q = "SELECT obj_id FROM object_data WHERE type = " . $ilDB->quote('adm', 'text');
144  $r = $ilDB->query($q);
145  $row = $ilDB->fetchObject($r);
146 
147  return $row->obj_id;
148  }
149 
150  function _getHeaderTitle()
151  {
156  global $ilDB, $ilUser;
157 
158  $id = ilObjSystemFolder::_getId();
159 
160  $q = "SELECT title,description FROM object_translation ".
161  "WHERE obj_id = ".$ilDB->quote($id,'integer')." ".
162  "AND lang_default = 1";
163  $r = $ilDB->query($q);
164  $row = $ilDB->fetchObject($r);
165  $title = $row->title;
166 
167  $q = "SELECT title,description FROM object_translation ".
168  "WHERE obj_id = ".$ilDB->quote($id,'integer')." ".
169  "AND lang_code = ".
170  $ilDB->quote($ilUser->getCurrentLanguage(),'text')." ".
171  "AND NOT lang_default = 1";
172  $r = $ilDB->query($q);
173  $row = $ilDB->fetchObject($r);
174 
175  if ($row)
176  {
177  $title = $row->title;
178  }
179 
180  return $title;
181  }
182 
183  function _getHeaderTitleDescription()
184  {
188  global $ilDB;
189 
190  $id = ilObjSystemFolder::_getId();
191 
192  $q = "SELECT title,description FROM object_translation ".
193  "WHERE obj_id = ".$ilDB->quote($id,'integer')." ".
194  "AND lang_default = 1";
195  $r = $ilDB->query($q);
196  $row = $ilDB->fetchObject($r);
197  $description = $row->description;
198 
199  $q = "SELECT title,description FROM object_translation ".
200  "WHERE obj_id = ".$ilDB->quote($id,'integer')." ".
201  "AND lang_code = ".
202  $ilDB->quote($this->ilias->account->getPref("language"),'text')." ".
203  "AND NOT lang_default = 1";
204  $r = $ilDB->query($q);
205  $row = $ilDB->fetchObject($r);
206 
207  if ($row)
208  {
209  $description = ilUtil::shortenText($row->description,ilObject::DESC_LENGTH,true);
210  }
211 
212  return $description;
213  }
214 
215 } // END class.ilObjSystemFolder
216 ?>