ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjWorkspaceRootFolder.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once "Services/Object/classes/class.ilObject2.php";
6 
16 {
17 
21  public function __construct($a_id = 0, $a_reference = true)
22  {
23  global $DIC;
24  parent::__construct($a_id, $a_reference);
25 
26  $this->db = $DIC->database();
27  }
28 
29  public function initType()
30  {
31  $this->type = "wsrt";
32  }
33 
40  public function getTranslations()
41  {
42  $ilDB = $this->db;
43 
44  $q = "SELECT * FROM object_translation WHERE obj_id = " .
45  $ilDB->quote($this->getId(), 'integer') . " ORDER BY lang_default DESC";
46  $r = $ilDB->query($q);
47 
48  $num = 0;
49 
50  $data["Fobject"] = array();
51  while ($row = $r->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
52  $data["Fobject"][$num]= array("title" => $row->title,
53  "desc" => $row->description,
54  "lang" => $row->lang_code
55  );
56  $num++;
57  }
58 
59  // first entry is always the default language
60  $data["default_language"] = 0;
61 
62  return $data ? $data : array();
63  }
64 
65  // remove all Translations of current category
66  public function removeTranslations()
67  {
68  $ilDB = $this->db;
69 
70  $query = "DELETE FROM object_translation WHERE obj_id= " .
71  $ilDB->quote($this->getId(), 'integer');
72  $res = $ilDB->manipulate($query);
73  }
74 
75  // add a new translation to current category
76  public function addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
77  {
78  $ilDB = $this->db;
79 
80  if (empty($a_title)) {
81  $a_title = "NO TITLE";
82  }
83 
84  $query = "INSERT INTO object_translation " .
85  "(obj_id,title,description,lang_code,lang_default) " .
86  "VALUES " .
87  "(" . $ilDB->quote($this->getId(), 'integer') . "," .
88  $ilDB->quote($a_title, 'text') . "," .
89  $ilDB->quote($a_desc, 'text') . "," .
90  $ilDB->quote($a_lang, 'text') . "," .
91  $ilDB->quote($a_lang_default, 'integer') . ")";
92  $res = $ilDB->manipulate($query);
93  return true;
94  }
95 } // END class.ObjRootFolder
global $DIC
Definition: saml.php:7
__construct($a_id=0, $a_reference=true)
Constructor.
$r
Definition: example_031.php:79
foreach($_POST as $key=> $value) $res
addTranslation($a_title, $a_desc, $a_lang, $a_lang_default)
Class ilObjWorkspaceRootFolder.
$query
Create styles array
The data for the language used.
getTranslations()
get all translations from this category
global $ilDB
Class ilObject2 This is an intermediate progress of ilObject class.