ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDBUpdate4963.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
9 
10  private static $table_tree;
11  private static $tree_id;
12  private static $gap;
13 
22  static function renumberBookmarkTree()
23  {
24  global $ilDB;
25 
26  self::$table_tree = "bookmark_tree";
27  self::$gap = 0;
28 
29  $query = 'SELECT tree FROM '.self::$table_tree .
30  ' GROUP BY tree';
31  $res = $ilDB->query($query);
32 
33  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
34  {
35  self::$tree_id = $row->tree;
36  self::__renumber();
37  }
38 
39 
40  }
41 
42  // PRIVATE
52  private static function __renumber($node_id = 1, $i = 1)
53  {
54  global $ilDB;
55 
56  $query = 'UPDATE '.self::$table_tree.' SET lft = %s WHERE child = %s AND tree = %s';
57  $res = $ilDB->manipulateF($query,array('integer','integer','integer'),array(
58  $i,
59  $node_id,
60  self::$tree_id));
61 
62  // to much dependencies
63  //$childs = $this->getChilds($node_id);
64  $childs = self::getChildIds($node_id);
65 
66  foreach ($childs as $child)
67  {
68  $i = self::__renumber($child,$i+1);
69  }
70  $i++;
71 
72  // Insert a gap at the end of node, if the node has children
73  if (count($childs) > 0)
74  {
75  $i += self::$gap * 2;
76  }
77 
78 
79  $query = 'UPDATE '.self::$table_tree.' SET rgt = %s WHERE child = %s AND tree = %s';
80  $res = $ilDB->manipulateF($query,array('integer','integer', 'integer'),array(
81  $i,
82  $node_id,
83  self::$tree_id));
84  return $i;
85  }
86 
93  private static function getChildIds($a_node)
94  {
95  global $ilDB;
96 
97  $query = 'SELECT * FROM '.self::$table_tree .
98  ' WHERE parent = '.$ilDB->quote($a_node,'integer').' '.
99  'AND tree = '.$ilDB->quote(self::$tree_id,'integer');
100  $res = $ilDB->query($query);
101 
102  $childs = array();
103  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
104  {
105  $childs[] = $row->child;
106  }
107  return $childs;
108  }
109 }
static renumberBookmarkTree()
Wrapper for renumber.
static getChildIds($a_node)
Get node child ids type $ilDB.
Create styles array
The data for the language used.
global $ilDB
Class ilDBUpdate4950.
static __renumber($node_id=1, $i=1)
This method is private.