ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBookmarkFolder Class Reference

bookmark folder (note: this class handles personal bookmarks folders only) More...

+ Collaboration diagram for ilBookmarkFolder:

Public Member Functions

 __construct ($a_bmf_id=0, $a_tree_id=0)
 Constructor public. More...
 
 read ()
 read bookmark folder data from db More...
 
 delete ()
 delete object data More...
 
 createNewBookmarkTree ()
 create personal bookmark tree More...
 
 create ()
 creates new bookmark folder in db More...
 
 update ()
 Update bookmark folder item. More...
 
 getId ()
 
 setId ($a_id)
 
 getTitle ()
 
 setTitle ($a_title)
 
 getParent ()
 
 setParent ($a_parent_id)
 
 getRootFolder ()
 

Static Public Member Functions

static _lookupTitle ($a_bmf_id)
 lookup bookmark folder title More...
 
static getObjects ($a_id)
 static More...
 
static _getNumberOfObjects ()
 Get number of folders and bookmarks for current user. More...
 
static getObject ($a_id)
 static More...
 
static isRootFolder ($a_id)
 
static _getParentId ($a_id)
 

Data Fields

 $tree
 
 $id
 
 $title
 
 $parent
 

Protected Attributes

 $db
 
 $error
 

Detailed Description

bookmark folder (note: this class handles personal bookmarks folders only)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Manfred Thaler manfr.nosp@m.ed.t.nosp@m.haler.nosp@m.@end.nosp@m.o7.co.nosp@m.m
Version
$Id$

Definition at line 14 of file class.ilBookmarkFolder.php.

Constructor & Destructor Documentation

◆ __construct()

ilBookmarkFolder::__construct (   $a_bmf_id = 0,
  $a_tree_id = 0 
)

Constructor public.

Parameters
integeruser_id (optional)

Definition at line 41 of file class.ilBookmarkFolder.php.

References $DIC, $GLOBALS, and read().

42  {
43  global $DIC;
44 
45  $this->db = $DIC->database();
46  $this->error = $DIC["ilErr"];
47  // Initiate variables
48  if ($a_tree_id == 0) {
49  $a_tree_id = $GLOBALS['DIC']['ilUser']->getId();
50  }
51 
52  $this->tree = new ilTree($a_tree_id);
53  $this->tree->setTableNames('bookmark_tree', 'bookmark_data');
54  $this->id = $a_bmf_id;
55 
56  if (!empty($this->id)) {
57  $this->read();
58  }
59  }
global $DIC
Definition: saml.php:7
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
read()
read bookmark folder data from db
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the call graph for this function:

Member Function Documentation

◆ _getNumberOfObjects()

static ilBookmarkFolder::_getNumberOfObjects ( )
static

Get number of folders and bookmarks for current user.

Definition at line 233 of file class.ilBookmarkFolder.php.

References $GLOBALS, $tree, and array.

Referenced by ilBookmarkBlockGUI\fillDataSection().

234  {
235  $a_tree_id = $GLOBALS['DIC']['ilUser']->getId();
236  $tree = new ilTree($a_tree_id);
237  $tree->setTableNames('bookmark_tree', 'bookmark_data');
238 
239  $root_node = $tree->getNodeData($tree->getRootId());
240 
241  if ($root_node["lft"] != "") {
242  $bmf = $tree->getSubTree($root_node, false, "bmf");
243  $bm = $tree->getSubTree($root_node, false, "bm");
244  } else {
245  $bmf = array("dummy");
246  $bm = array();
247  }
248 
249  return array("folders" => (int) count($bmf) - 1, "bookmarks" => (int) count($bm));
250  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ _getParentId()

static ilBookmarkFolder::_getParentId (   $a_id)
static

Definition at line 292 of file class.ilBookmarkFolder.php.

References $GLOBALS, and $tree.

Referenced by ilBookmarkBlockGUI\getListRowData().

293  {
294  $a_tree_id = $GLOBALS['DIC']['ilUser']->getId();
295  $tree = new ilTree($a_tree_id);
296  $tree->setTableNames('bookmark_tree', 'bookmark_data');
297  return $tree->getParentId($a_id);
298  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the caller graph for this function:

◆ _lookupTitle()

static ilBookmarkFolder::_lookupTitle (   $a_bmf_id)
static

lookup bookmark folder title

Definition at line 181 of file class.ilBookmarkFolder.php.

References $DIC, and $ilDB.

Referenced by ilBookmarkBlockGUI\getListRowData().

182  {
183  global $DIC;
184 
185  $ilDB = $DIC->database();
186 
187  $q = "SELECT * FROM bookmark_data WHERE obj_id = " .
188  $ilDB->quote($a_bmf_id, "integer");
189  $bmf_set = $ilDB->query($q);
190  $bmf = $ilDB->fetchAssoc($bmf_set);
191 
192  return $bmf["title"];
193  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ create()

ilBookmarkFolder::create ( )

creates new bookmark folder in db

note: parent and title must be set

Definition at line 113 of file class.ilBookmarkFolder.php.

References $db, $GLOBALS, $ilDB, getId(), getParent(), and setId().

114  {
115  $ilDB = $this->db;
116 
117  $this->setId($ilDB->nextId("bookmark_data"));
118  $q = sprintf(
119  "INSERT INTO bookmark_data (obj_id, user_id, title, type) " .
120  "VALUES (%s,%s,%s,%s)",
121  $ilDB->quote($this->getId(), "integer"),
122  $ilDB->quote($GLOBALS['DIC']['ilUser']->getId(), "integer"),
123  $ilDB->quote($this->getTitle(), "text"),
124  $ilDB->quote('bmf', "text")
125  );
126 
127  $ilDB->manipulate($q);
128  $this->tree->insertNode($this->getId(), $this->getParent());
129  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilDB
+ Here is the call graph for this function:

◆ createNewBookmarkTree()

ilBookmarkFolder::createNewBookmarkTree ( )

create personal bookmark tree

Definition at line 96 of file class.ilBookmarkFolder.php.

References $db, and $ilDB.

97  {
98  $ilDB = $this->db;
99 
100  /*
101  $q = "INSERT INTO bookmark_data (user_id, title, target, type) ".
102  "VALUES ('".$this->tree->getTreeId()."','dummy_folder','','bmf')";
103  $ilDB->query($q);*/
104  //$this->tree->addTree($this->tree->getTreeId(), $ilDB->getLastInsertId());
105  $this->tree->addTree($this->tree->getTreeId(), 1);
106  }
global $ilDB

◆ delete()

ilBookmarkFolder::delete ( )

delete object data

Definition at line 85 of file class.ilBookmarkFolder.php.

References $db, $ilDB, and getId().

86  {
87  $ilDB = $this->db;
88 
89  $q = "DELETE FROM bookmark_data WHERE obj_id = " . $ilDB->quote($this->getId(), "integer");
90  $ilDB->query($q);
91  }
global $ilDB
+ Here is the call graph for this function:

◆ getId()

ilBookmarkFolder::getId ( )

Definition at line 148 of file class.ilBookmarkFolder.php.

References $id.

Referenced by create(), delete(), and read().

149  {
150  return $this->id;
151  }
+ Here is the caller graph for this function:

◆ getObject()

static ilBookmarkFolder::getObject (   $a_id)
static

static

Definition at line 256 of file class.ilBookmarkFolder.php.

References $GLOBALS, and $tree.

Referenced by ilBookmarkImportExport\_exportBookmark().

257  {
258  $a_tree_id = $GLOBALS['DIC']['ilUser']->getId();
259  $tree = new ilTree($a_tree_id);
260  $tree->setTableNames('bookmark_tree', 'bookmark_data');
261 
262  if (empty($a_id)) {
263  $a_id = $tree->getRootId();
264  }
265 
266  $object = $tree->getNodeData($a_id);
267  return $object;
268  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the caller graph for this function:

◆ getObjects()

static ilBookmarkFolder::getObjects (   $a_id)
static

static

Definition at line 198 of file class.ilBookmarkFolder.php.

References $GLOBALS, $key, $tree, and array.

Referenced by ilBookmarkImportExport\__parseExport(), ilBookmarkBlockGUI\getListRowData(), and ilBookmarkAdministrationGUI\view().

199  {
200  $a_tree_id = $GLOBALS['DIC']['ilUser']->getId();
201  $tree = new ilTree($a_tree_id);
202  $tree->setTableNames('bookmark_tree', 'bookmark_data');
203 
204  if (empty($a_id)) {
205  $a_id = $tree->getRootId();
206  }
207 
208  $childs = $tree->getChilds($a_id, "title");
209 
210  $objects = array();
211  $bookmarks = array();
212 
213  foreach ($childs as $key => $child) {
214  switch ($child["type"]) {
215  case "bmf":
216  $objects[] = $child;
217  break;
218 
219  case "bm":
220  $bookmarks[] = $child;
221  break;
222  }
223  }
224  foreach ($bookmarks as $key => $bookmark) {
225  $objects[] = $bookmark;
226  }
227  return $objects;
228  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Create styles array
The data for the language used.
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ getParent()

ilBookmarkFolder::getParent ( )

Definition at line 168 of file class.ilBookmarkFolder.php.

References $parent.

Referenced by create().

169  {
170  return $this->parent;
171  }
+ Here is the caller graph for this function:

◆ getRootFolder()

ilBookmarkFolder::getRootFolder ( )

Definition at line 283 of file class.ilBookmarkFolder.php.

References $GLOBALS, and $tree.

284  {
285  $a_tree_id = $GLOBALS['DIC']['ilUser']->getId();
286  $tree = new ilTree($a_tree_id);
287  $tree->setTableNames('bookmark_tree', 'bookmark_data');
288 
289  return $tree->getRootId();
290  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...

◆ getTitle()

ilBookmarkFolder::getTitle ( )

Definition at line 158 of file class.ilBookmarkFolder.php.

References $title.

159  {
160  return $this->title;
161  }

◆ isRootFolder()

static ilBookmarkFolder::isRootFolder (   $a_id)
static

Definition at line 270 of file class.ilBookmarkFolder.php.

References $GLOBALS, and $tree.

Referenced by ilBookmarkBlockGUI\getListRowData().

271  {
272  $a_tree_id = $GLOBALS['DIC']['ilUser']->getId();
273  $tree = new ilTree($a_tree_id);
274  $tree->setTableNames('bookmark_tree', 'bookmark_data');
275 
276  if ($a_id == $tree->getRootId()) {
277  return true;
278  } else {
279  return false;
280  }
281  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
+ Here is the caller graph for this function:

◆ read()

ilBookmarkFolder::read ( )

read bookmark folder data from db

Definition at line 64 of file class.ilBookmarkFolder.php.

References $db, $error, $ilDB, $ilErr, $message, getId(), setParent(), and setTitle().

Referenced by __construct().

65  {
66  $ilDB = $this->db;
68 
69  $q = "SELECT * FROM bookmark_data WHERE obj_id = " .
70  $ilDB->quote($this->getId(), "integer");
71  $bmf_set = $ilDB->query($q);
72  if ($ilDB->numRows($bmf_set) == 0) {
73  $message = "ilBookmarkFolder::read(): Bookmark Folder with id " . $this->getId() . " not found!";
74  $ilErr->raiseError($message, $ilErr->WARNING);
75  } else {
76  $bmf = $ilDB->fetchAssoc($bmf_set);
77  $this->setTitle($bmf["title"]);
78  $this->setParent($this->tree->getParentId($this->getId()));
79  }
80  }
global $ilErr
Definition: raiseError.php:16
catch(Exception $e) $message
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setId()

ilBookmarkFolder::setId (   $a_id)

Definition at line 153 of file class.ilBookmarkFolder.php.

Referenced by create().

154  {
155  $this->id = $a_id;
156  }
+ Here is the caller graph for this function:

◆ setParent()

ilBookmarkFolder::setParent (   $a_parent_id)

Definition at line 173 of file class.ilBookmarkFolder.php.

Referenced by read().

174  {
175  $this->parent = $a_parent_id;
176  }
+ Here is the caller graph for this function:

◆ setTitle()

ilBookmarkFolder::setTitle (   $a_title)

Definition at line 163 of file class.ilBookmarkFolder.php.

Referenced by read().

164  {
165  $this->title = $a_title;
166  }
+ Here is the caller graph for this function:

◆ update()

ilBookmarkFolder::update ( )

Update bookmark folder item.

Definition at line 134 of file class.ilBookmarkFolder.php.

References $db, and $ilDB.

135  {
136  $ilDB = $this->db;
137 
138  $q = sprintf(
139  "UPDATE bookmark_data SET title=%s " .
140  "WHERE obj_id=%s",
141  $ilDB->quote($this->getTitle(), "text"),
142  $ilDB->quote($this->getId(), "integer")
143  );
144  $ilDB->manipulate($q);
145  }
global $ilDB

Field Documentation

◆ $db

ilBookmarkFolder::$db
protected

Definition at line 19 of file class.ilBookmarkFolder.php.

Referenced by create(), createNewBookmarkTree(), delete(), read(), and update().

◆ $error

ilBookmarkFolder::$error
protected

Definition at line 24 of file class.ilBookmarkFolder.php.

Referenced by read().

◆ $id

ilBookmarkFolder::$id

Definition at line 32 of file class.ilBookmarkFolder.php.

Referenced by getId().

◆ $parent

ilBookmarkFolder::$parent

Definition at line 34 of file class.ilBookmarkFolder.php.

Referenced by getParent().

◆ $title

ilBookmarkFolder::$title

Definition at line 33 of file class.ilBookmarkFolder.php.

Referenced by getTitle().

◆ $tree

ilBookmarkFolder::$tree

The documentation for this class was generated from the following file: