ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Wiki\Navigation\ImportantPageDBRepository Class Reference

Wiki page repo. More...

+ Collaboration diagram for ILIAS\Wiki\Navigation\ImportantPageDBRepository:

Public Member Functions

 __construct (InternalDataService $data, \ilDBInterface $db)
 
 getList (int $wiki_id)
 
 getListAsArray (int $wiki_id)
 
 add (int $wiki_id, int $page_id, int $nr=0, int $indent=0)
 
 isImportantPage (int $wiki_id, int $page_id)
 
 removeImportantPage (int $wiki_id, int $page_id)
 
 saveOrderingAndIndentation (int $wiki_id, array $a_ord, array $a_indent)
 
 getImportantPageIds (int $wiki_id)
 

Protected Member Functions

 getPageInfoFromRecord (array $rec)
 
 getMaxOrdNr (int $wiki_id)
 
 fixImportantPagesNumbering (int $wiki_id)
 

Protected Attributes

InternalDataService $data
 
ilDBInterface $db
 

Detailed Description

Wiki page repo.

Definition at line 29 of file ImportantPageDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::__construct ( InternalDataService  $data,
\ilDBInterface  $db 
)

Member Function Documentation

◆ add()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::add ( int  $wiki_id,
int  $page_id,
int  $nr = 0,
int  $indent = 0 
)

Definition at line 89 of file ImportantPageDBRepository.php.

References ILIAS\Wiki\Navigation\ImportantPageDBRepository\getMaxOrdNr(), and ILIAS\Wiki\Navigation\ImportantPageDBRepository\isImportantPage().

94  : void {
95  if (!$this->isImportantPage($wiki_id, $page_id)) {
96  if ($nr === 0) {
97  $nr = $this->getMaxOrdNr($wiki_id) + 10;
98  }
99 
100  $this->db->manipulate("INSERT INTO il_wiki_imp_pages " .
101  "(wiki_id, ord, indent, page_id) VALUES (" .
102  $this->db->quote($wiki_id, "integer") . "," .
103  $this->db->quote($nr, "integer") . "," .
104  $this->db->quote($indent, "integer") . "," .
105  $this->db->quote($page_id, "integer") .
106  ")");
107  }
108  }
+ Here is the call graph for this function:

◆ fixImportantPagesNumbering()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::fixImportantPagesNumbering ( int  $wiki_id)
protected

Definition at line 181 of file ImportantPageDBRepository.php.

References $q, and ILIAS\Wiki\Navigation\ImportantPageDBRepository\getListAsArray().

Referenced by ILIAS\Wiki\Navigation\ImportantPageDBRepository\removeImportantPage().

183  : void {
184  $ipages = $this->getListAsArray($wiki_id);
185  // fix indentation: no 2 is allowed after a 0
186  $c_indent = 0;
187  foreach ($ipages as $k => $v) {
188  if ($v["indent"] == 2 && $c_indent == 0) {
189  $ipages[$k]["indent"] = 1;
190  }
191  $c_indent = $ipages[$k]["indent"];
192  }
193 
194  $ord = 10;
195  foreach ($ipages as $k => $v) {
196  $this->db->manipulate(
197  $q = "UPDATE il_wiki_imp_pages SET " .
198  " ord = " . $this->db->quote($ord, "integer") .
199  ", indent = " . $this->db->quote($v["indent"], "integer") .
200  " WHERE wiki_id = " . $this->db->quote($v["wiki_id"], "integer") .
201  " AND page_id = " . $this->db->quote($v["page_id"], "integer")
202  );
203  $ord += 10;
204  }
205  }
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImportantPageIds()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::getImportantPageIds ( int  $wiki_id)

Definition at line 207 of file ImportantPageDBRepository.php.

References ILIAS\Repository\int().

207  : array
208  {
209  $set = $this->db->query(
210  "SELECT DISTINCT page_id FROM il_wiki_imp_pages WHERE " .
211  " wiki_id = " . $this->db->quote($wiki_id, "integer")
212  );
213  $ids = [];
214  while ($rec = $this->db->fetchAssoc($set)) {
215  $ids[] = (int) $rec["page_id"];
216  }
217  return $ids;
218  }
+ Here is the call graph for this function:

◆ getList()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::getList ( int  $wiki_id)
Returns
iterable<ImportantPage>

Definition at line 54 of file ImportantPageDBRepository.php.

References ILIAS\Wiki\Navigation\ImportantPageDBRepository\getPageInfoFromRecord().

Referenced by ILIAS\Wiki\Navigation\ImportantPageDBRepository\getListAsArray().

54  : \Iterator
55  {
56  $set = $this->db->query(
57  "SELECT * FROM il_wiki_imp_pages WHERE " .
58  " wiki_id = " . $this->db->quote($wiki_id, "integer") . " ORDER BY ord ASC "
59  );
60  while ($rec = $this->db->fetchAssoc($set)) {
61  yield $this->getPageInfoFromRecord($rec);
62  }
63  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getListAsArray()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::getListAsArray ( int  $wiki_id)

Definition at line 65 of file ImportantPageDBRepository.php.

References ILIAS\Wiki\Navigation\ImportantPageDBRepository\getList().

Referenced by ILIAS\Wiki\Navigation\ImportantPageDBRepository\fixImportantPagesNumbering(), and ILIAS\Wiki\Navigation\ImportantPageDBRepository\saveOrderingAndIndentation().

65  : array
66  {
67  $ipages = [];
68  foreach ($this->getList($wiki_id) as $ip) {
69  $ipages[$ip->getId()]["page_id"] = $ip->getId();
70  $ipages[$ip->getId()]["ord"] = $ip->getOrder();
71  $ipages[$ip->getId()]["indent"] = $ip->getIndent();
72  $ipages[$ip->getId()]["wiki_id"] = $wiki_id;
73  }
74  return $ipages;
75  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxOrdNr()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::getMaxOrdNr ( int  $wiki_id)
protected

Definition at line 77 of file ImportantPageDBRepository.php.

Referenced by ILIAS\Wiki\Navigation\ImportantPageDBRepository\add().

79  : int {
80  $set = $this->db->query(
81  "SELECT MAX(ord) as m FROM il_wiki_imp_pages WHERE " .
82  " wiki_id = " . $this->db->quote($wiki_id, "integer")
83  );
84  $rec = $this->db->fetchAssoc($set);
85  return (int) $rec["m"];
86  }
+ Here is the caller graph for this function:

◆ getPageInfoFromRecord()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::getPageInfoFromRecord ( array  $rec)
protected

Definition at line 42 of file ImportantPageDBRepository.php.

Referenced by ILIAS\Wiki\Navigation\ImportantPageDBRepository\getList().

42  : ImportantPage
43  {
44  return $this->data->importantPage(
45  (int) $rec["page_id"],
46  (int) $rec["ord"],
47  (int) $rec["indent"]
48  );
49  }
+ Here is the caller graph for this function:

◆ isImportantPage()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::isImportantPage ( int  $wiki_id,
int  $page_id 
)

Definition at line 110 of file ImportantPageDBRepository.php.

Referenced by ILIAS\Wiki\Navigation\ImportantPageDBRepository\add().

113  : bool {
114  $set = $this->db->query(
115  "SELECT * FROM il_wiki_imp_pages WHERE " .
116  " wiki_id = " . $this->db->quote($wiki_id, "integer") . " AND " .
117  " page_id = " . $this->db->quote($page_id, "integer")
118  );
119  if ($this->db->fetchAssoc($set)) {
120  return true;
121  }
122  return false;
123  }
+ Here is the caller graph for this function:

◆ removeImportantPage()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::removeImportantPage ( int  $wiki_id,
int  $page_id 
)

Definition at line 125 of file ImportantPageDBRepository.php.

References ILIAS\Wiki\Navigation\ImportantPageDBRepository\fixImportantPagesNumbering().

128  : void {
129  $this->db->manipulate(
130  "DELETE FROM il_wiki_imp_pages WHERE "
131  . " wiki_id = " . $this->db->quote($wiki_id, "integer")
132  . " AND page_id = " . $this->db->quote($page_id, "integer")
133  );
134  $this->fixImportantPagesNumbering($wiki_id);
135  }
+ Here is the call graph for this function:

◆ saveOrderingAndIndentation()

ILIAS\Wiki\Navigation\ImportantPageDBRepository::saveOrderingAndIndentation ( int  $wiki_id,
array  $a_ord,
array  $a_indent 
)

Definition at line 137 of file ImportantPageDBRepository.php.

References $q, ILIAS\Wiki\Navigation\ImportantPageDBRepository\getListAsArray(), ILIAS\Repository\int(), and ilArrayUtil\sortArray().

141  : bool {
142  $ipages = $this->getListAsArray($wiki_id);
143 
144  foreach ($ipages as $k => $v) {
145  if (isset($a_ord[$v["page_id"]])) {
146  $ipages[$k]["ord"] = (int) $a_ord[$v["page_id"]];
147  }
148  if (isset($a_indent[$v["page_id"]])) {
149  $ipages[$k]["indent"] = (int) $a_indent[$v["page_id"]];
150  }
151  }
152  $ipages = \ilArrayUtil::sortArray($ipages, "ord", "asc", true);
153 
154  // fix indentation: no 2 is allowed after a 0
155  $c_indent = 0;
156  $fixed = false;
157  foreach ($ipages as $k => $v) {
158  if ($v["indent"] == 2 && $c_indent == 0) {
159  $ipages[$k]["indent"] = 1;
160  $fixed = true;
161  }
162  $c_indent = $ipages[$k]["indent"];
163  }
164 
165  $ord = 10;
166  reset($ipages);
167  foreach ($ipages as $k => $v) {
168  $this->db->manipulate(
169  $q = "UPDATE il_wiki_imp_pages SET " .
170  " ord = " . $this->db->quote($ord, "integer") . "," .
171  " indent = " . $this->db->quote($v["indent"], "integer") .
172  " WHERE wiki_id = " . $this->db->quote($wiki_id, "integer") .
173  " AND page_id = " . $this->db->quote($v["page_id"], "integer")
174  );
175  $ord += 10;
176  }
177 
178  return $fixed;
179  }
$q
Definition: shib_logout.php:21
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:

Field Documentation

◆ $data

InternalDataService ILIAS\Wiki\Navigation\ImportantPageDBRepository::$data
protected

◆ $db

ilDBInterface ILIAS\Wiki\Navigation\ImportantPageDBRepository::$db
protected

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