ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Wiki\Page\PageDBRepository Class Reference

Wiki page repo. More...

+ Collaboration diagram for ILIAS\Wiki\Page\PageDBRepository:

Public Member Functions

 __construct (InternalDataService $data, \ilDBInterface $db)
 
 delete ($id, $lang="-")
 
 getWikiPages (int $wiki_id, string $lang="-")
 
 getMasterPagesWithoutTranslation (int $wiki_id, string $trans)
 
 getAllPagesInfo (int $wiki_id)
 Queries last change and user per page regardless of language. More...
 
 getInfoOfSelected ($wiki_id, array $ids, $lang="-")
 
 getRecentChanges (int $wiki_id, int $period=30)
 Queries last change and user per page regardless of language. More...
 
 getNewPages (int $wiki_id)
 
 getPopularPages (int $a_wiki_id)
 
 getLanguages (int $wpg_id)
 
 doesAtLeastOnePageExist (int $wiki_id, array $ids)
 
 getPageIdForTitle (int $wiki_id, string $title, string $lang="-")
 
 existsByTitle (int $wiki_id, string $title, string $lang="-")
 
 exists (int $id, string $lang="-")
 
 getTitle (int $id, string $lang="-")
 
 getWikiIdByPageId (int $id)
 

Protected Member Functions

 getPageFromRecord (array $rec)
 
 getPageInfoFromRecord (array $rec)
 

Protected Attributes

InternalDataService $data
 
ilDBInterface $db
 

Detailed Description

Wiki page repo.

Definition at line 28 of file PageDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Wiki\Page\PageDBRepository::__construct ( InternalDataService  $data,
\ilDBInterface  $db 
)

Definition at line 33 of file PageDBRepository.php.

References ILIAS\Wiki\Page\PageDBRepository\$data, and ILIAS\Wiki\Page\PageDBRepository\$db.

36  {
37  $this->data = $data;
38  $this->db = $db;
39  }

Member Function Documentation

◆ delete()

ILIAS\Wiki\Page\PageDBRepository::delete (   $id,
  $lang = "-" 
)

Definition at line 41 of file PageDBRepository.php.

References $id, and ilDBInterface\quote().

41  : void
42  {
43  $and = in_array($lang, ["", "-"])
44  ? ""
45  : " AND lang = " . $this->db->quote($lang, "text");
46  $query = "DELETE FROM il_wiki_page" .
47  " WHERE id = " . $this->db->quote($id, "integer") .
48  $and;
49  $this->db->manipulate($query);
50  }
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ doesAtLeastOnePageExist()

ILIAS\Wiki\Page\PageDBRepository::doesAtLeastOnePageExist ( int  $wiki_id,
array  $ids 
)

Definition at line 238 of file PageDBRepository.php.

238  : bool
239  {
240  // cross check existence of sources in il_wiki_page
241  $query = "SELECT count(*) cnt FROM il_wiki_page" .
242  " WHERE " . $this->db->in("id", $ids, false, "integer") .
243  " AND wiki_id = " . $this->db->quote($wiki_id, "integer") .
244  " GROUP BY wiki_id";
245  $set = $this->db->query($query);
246  $rec = $this->db->fetchAssoc($set);
247  return ((int) $rec["cnt"]) > 0;
248  }

◆ exists()

ILIAS\Wiki\Page\PageDBRepository::exists ( int  $id,
string  $lang = "-" 
)

Definition at line 285 of file PageDBRepository.php.

Referenced by ILIAS\Wiki\Page\PageDBRepository\existsByTitle().

288  : bool {
289  if ($lang === "") {
290  $lang = "-";
291  }
292  $query = "SELECT w.id FROM il_wiki_page w " .
293  " JOIN page_object p ON (w.id = p.page_id AND w.lang = p.lang) " .
294  " WHERE w.id = " . $this->db->quote($id, "integer") .
295  " AND w.lang = " . $this->db->quote($lang, "text");
296  $set = $this->db->query($query);
297  if ($rec = $this->db->fetchAssoc($set)) {
298  return true;
299  }
300  return false;
301  }
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ existsByTitle()

ILIAS\Wiki\Page\PageDBRepository::existsByTitle ( int  $wiki_id,
string  $title,
string  $lang = "-" 
)

Definition at line 273 of file PageDBRepository.php.

References $id, ILIAS\Wiki\Page\PageDBRepository\exists(), and ILIAS\Wiki\Page\PageDBRepository\getPageIdForTitle().

277  : bool {
278  $id = $this->getPageIdForTitle($wiki_id, $title, $lang);
279  if (is_null($id)) {
280  return false;
281  }
282  return $this->exists($id, $lang);
283  }
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
exists(int $id, string $lang="-")
getPageIdForTitle(int $wiki_id, string $title, string $lang="-")
+ Here is the call graph for this function:

◆ getAllPagesInfo()

ILIAS\Wiki\Page\PageDBRepository::getAllPagesInfo ( int  $wiki_id)

Queries last change and user per page regardless of language.

Returns
iterable<PageInfo>

Definition at line 117 of file PageDBRepository.php.

References ILIAS\Wiki\Page\PageDBRepository\getPageInfoFromRecord(), and ILIAS\Repository\int().

117  : \Iterator
118  {
119  $set = $this->db->queryF(
120  "SELECT w.id, p.last_change_user, p.last_change, w.title " . "FROM page_object p JOIN il_wiki_page w " .
121  " ON (w.wiki_id = %s AND p.parent_type = %s AND p.page_id = w.id AND w.lang = %s) " .
122  " JOIN ( select page_id, max(last_change) mlc FROM page_object " .
123  " WHERE parent_type='wpg' group by page_id) mp " .
124  " ON (mp.page_id = p.page_id AND mp.mlc = p.last_change)",
125  ["integer", "string", "string"],
126  [$wiki_id, "wpg", "-"]
127  );
128  $ids = [];
129  while ($rec = $this->db->fetchAssoc($set)) {
130  // note: the query may get multiple entries for a page id, if multiple
131  // languages share the same max(last_change). We only return one.
132  if (isset($ids[(int) $rec["id"]])) {
133  continue;
134  }
135  $ids[(int) $rec["id"]] = (int) $rec["id"];
136  yield $this->getPageInfoFromRecord($rec);
137  }
138  }
+ Here is the call graph for this function:

◆ getInfoOfSelected()

ILIAS\Wiki\Page\PageDBRepository::getInfoOfSelected (   $wiki_id,
array  $ids,
  $lang = "-" 
)

Definition at line 140 of file PageDBRepository.php.

References ILIAS\Wiki\Page\PageDBRepository\getPageInfoFromRecord().

140  : \Iterator
141  {
142  $query = "SELECT wp.id, p.last_change_user, p.last_change, wp.title, wp.lang " .
143  " FROM il_wiki_page wp JOIN page_object p " .
144  " ON (wp.id = p.page_id AND wp.lang = p.lang) " .
145  " WHERE " . $this->db->in("wp.id", $ids, false, "integer") .
146  " AND p.parent_type = " . $this->db->quote("wpg", "text") .
147  " AND wp.wiki_id = " . $this->db->quote($wiki_id, "integer") .
148  " AND wp.lang = " . $this->db->quote($lang, "text") .
149  " ORDER BY title";
150  $set = $this->db->query($query);
151 
152  while ($rec = $this->db->fetchAssoc($set)) {
153  yield $this->getPageInfoFromRecord($rec);
154  }
155  }
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

◆ getLanguages()

ILIAS\Wiki\Page\PageDBRepository::getLanguages ( int  $wpg_id)
Returns
string[]

Definition at line 223 of file PageDBRepository.php.

223  : array
224  {
225  $set = $this->db->queryF(
226  "SELECT DISTINCT lang FROM " .
227  " il_wiki_page WHERE id = %s AND lang <> '-' ",
228  ["integer"],
229  [$wpg_id]
230  );
231  $langs = [];
232  while ($rec = $this->db->fetchAssoc($set)) {
233  $langs[] = $rec["lang"];
234  }
235  return $langs;
236  }

◆ getMasterPagesWithoutTranslation()

ILIAS\Wiki\Page\PageDBRepository::getMasterPagesWithoutTranslation ( int  $wiki_id,
string  $trans 
)
Returns
iterable<Page>

Definition at line 99 of file PageDBRepository.php.

References ILIAS\Wiki\Page\PageDBRepository\getPageFromRecord().

99  : \Iterator
100  {
101  $set = $this->db->queryF(
102  "SELECT w1.* FROM il_wiki_page w1 LEFT JOIN il_wiki_page w2 " .
103  " ON w1.id = w2.id AND w2.lang = %s " .
104  " WHERE w1.lang = %s AND w1.wiki_id = %s AND w2.id IS NULL ORDER BY w1.title",
105  ["string", "string", "integer"],
106  [$trans, "-", $wiki_id]
107  );
108  while ($rec = $this->db->fetchAssoc($set)) {
109  yield $this->getPageFromRecord($rec);
110  }
111  }
+ Here is the call graph for this function:

◆ getNewPages()

ILIAS\Wiki\Page\PageDBRepository::getNewPages ( int  $wiki_id)
Returns
iterable<PageInfo>

Definition at line 186 of file PageDBRepository.php.

References ILIAS\Wiki\Page\PageDBRepository\getPageInfoFromRecord().

186  : \Iterator
187  {
188  $set = $this->db->queryF(
189  "SELECT w.id, p.created, p.create_user, w.title, w.lang FROM page_object p " .
190  " JOIN il_wiki_page w " .
191  " ON w.id = p.page_id AND p.parent_type = %s AND w.lang = p.lang AND w.wiki_id = %s " .
192  " ORDER BY created DESC",
193  ["string", "integer"],
194  ["wpg", $wiki_id]
195  );
196  while ($rec = $this->db->fetchAssoc($set)) {
197  yield $this->getPageInfoFromRecord($rec);
198  }
199  }
+ Here is the call graph for this function:

◆ getPageFromRecord()

ILIAS\Wiki\Page\PageDBRepository::getPageFromRecord ( array  $rec)
protected

Definition at line 52 of file PageDBRepository.php.

Referenced by ILIAS\Wiki\Page\PageDBRepository\getMasterPagesWithoutTranslation(), and ILIAS\Wiki\Page\PageDBRepository\getWikiPages().

52  : Page
53  {
54  return $this->data->page(
55  (int) $rec["id"],
56  (int) $rec["wiki_id"],
57  $rec["title"],
58  $rec["lang"],
59  (bool) $rec["blocked"],
60  (bool) $rec["rating"],
61  (bool) $rec["hide_adv_md"]
62  );
63  }
+ Here is the caller graph for this function:

◆ getPageIdForTitle()

ILIAS\Wiki\Page\PageDBRepository::getPageIdForTitle ( int  $wiki_id,
string  $title,
string  $lang = "-" 
)

Definition at line 250 of file PageDBRepository.php.

References ilWikiUtil\makeDbTitle(), and null.

Referenced by ILIAS\Wiki\Page\PageDBRepository\existsByTitle().

254  : ?int {
255  if ($lang === "") {
256  $lang = "-";
257  }
258  $title = \ilWikiUtil::makeDbTitle($title);
259 
260  $query = "SELECT w.id FROM il_wiki_page w " .
261  " JOIN page_object p ON (w.id = p.page_id AND w.lang = p.lang) " .
262  " WHERE w.wiki_id = " . $this->db->quote($wiki_id, "integer") .
263  " AND w.title = " . $this->db->quote($title, "text") .
264  " AND w.lang = " . $this->db->quote($lang, "text");
265  $set = $this->db->query($query);
266  if ($rec = $this->db->fetchAssoc($set)) {
267  return (int) $rec["id"];
268  }
269 
270  return null;
271  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$lang
Definition: xapiexit.php:25
static makeDbTitle(string $a_par)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPageInfoFromRecord()

ILIAS\Wiki\Page\PageDBRepository::getPageInfoFromRecord ( array  $rec)
protected

Definition at line 65 of file PageDBRepository.php.

Referenced by ILIAS\Wiki\Page\PageDBRepository\getAllPagesInfo(), ILIAS\Wiki\Page\PageDBRepository\getInfoOfSelected(), ILIAS\Wiki\Page\PageDBRepository\getNewPages(), ILIAS\Wiki\Page\PageDBRepository\getPopularPages(), and ILIAS\Wiki\Page\PageDBRepository\getRecentChanges().

65  : PageInfo
66  {
67  return $this->data->pageInfo(
68  (int) $rec["id"],
69  $rec["lang"] ?? "",
70  $rec["title"],
71  (int) ($rec["last_change_user"] ?? 0),
72  $rec["last_change"] ?? "",
73  (int) ($rec["create_user"] ?? 0),
74  $rec["created"] ?? "",
75  (int) ($rec["cnt"] ?? 0),
76  (int) ($rec["nr"] ?? 0)
77  );
78  }
+ Here is the caller graph for this function:

◆ getPopularPages()

ILIAS\Wiki\Page\PageDBRepository::getPopularPages ( int  $a_wiki_id)
Returns
iterable<PageInfo>

Definition at line 204 of file PageDBRepository.php.

References ILIAS\Wiki\Page\PageDBRepository\getPageInfoFromRecord().

206  : \Iterator {
207 
208  $query = "SELECT wp.id, wp.title, wp.lang, po.view_cnt as cnt FROM il_wiki_page wp JOIN page_object po" .
209  " ON (wp.id = po.page_id AND wp.lang = po.lang) " .
210  " WHERE wp.wiki_id = " . $this->db->quote($a_wiki_id, "integer") .
211  " AND po.parent_type = " . $this->db->quote("wpg", "text") . " " .
212  " ORDER BY po.view_cnt";
213  $set = $this->db->query($query);
214 
215  while ($rec = $this->db->fetchAssoc($set)) {
216  yield $this->getPageInfoFromRecord($rec);
217  }
218  }
+ Here is the call graph for this function:

◆ getRecentChanges()

ILIAS\Wiki\Page\PageDBRepository::getRecentChanges ( int  $wiki_id,
int  $period = 30 
)

Queries last change and user per page regardless of language.

Returns
iterable<PageInfo>

Definition at line 161 of file PageDBRepository.php.

References $q, and ILIAS\Wiki\Page\PageDBRepository\getPageInfoFromRecord().

164  : \Iterator {
165  $limit_ts = date('Y-m-d H:i:s', time() - ($period * 24 * 60 * 60));
166  $q1 = "SELECT w.id, p.last_change_user, p.last_change, w.title, w.lang, 0 nr FROM page_object p " .
167  " JOIN il_wiki_page w ON (w.id = p.page_id AND p.parent_type = %s AND w.lang = p.lang AND w.wiki_id = %s) " .
168  " WHERE p.last_change >= " . $this->db->quote($limit_ts, "timestamp");
169  $q2 = "SELECT w.id, p.user_id last_change_user, p.hdate last_change, w.title, w.lang, p.nr FROM page_history p " .
170  " JOIN il_wiki_page w ON (w.id = p.page_id AND p.parent_type = %s AND w.lang = p.lang AND w.wiki_id = %s) " .
171  " WHERE p.hdate >= " . $this->db->quote($limit_ts, "timestamp");
172  $q = $q1 . " UNION " . $q2 . " ORDER BY last_change DESC ";
173  $set = $this->db->queryF(
174  $q,
175  ["string", "integer", "string", "integer"],
176  ["wpg", $wiki_id,"wpg", $wiki_id]
177  );
178  while ($rec = $this->db->fetchAssoc($set)) {
179  yield $this->getPageInfoFromRecord($rec);
180  }
181  }
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ getTitle()

ILIAS\Wiki\Page\PageDBRepository::getTitle ( int  $id,
string  $lang = "-" 
)

Definition at line 303 of file PageDBRepository.php.

306  : string {
307  if ($lang === "") {
308  $lang = "-";
309  }
310  $query = "SELECT title FROM il_wiki_page " .
311  " WHERE id = " . $this->db->quote($id, "integer") .
312  " AND lang = " . $this->db->quote($lang, "text");
313  $set = $this->db->query($query);
314  if ($rec = $this->db->fetchAssoc($set)) {
315  return $rec["title"];
316  }
317  return "";
318  }
$lang
Definition: xapiexit.php:25
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ getWikiIdByPageId()

ILIAS\Wiki\Page\PageDBRepository::getWikiIdByPageId ( int  $id)

Definition at line 320 of file PageDBRepository.php.

References null.

322  : ?int {
323  $query = "SELECT wiki_id FROM il_wiki_page" .
324  " WHERE id = " . $this->db->quote($id, "integer") .
325  " AND lang = " . $this->db->quote('-', "text");
326  $set = $this->db->query($query);
327  if ($rec = $this->db->fetchAssoc($set)) {
328  return (int) $rec["wiki_id"];
329  }
330  return null;
331  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ getWikiPages()

ILIAS\Wiki\Page\PageDBRepository::getWikiPages ( int  $wiki_id,
string  $lang = "-" 
)
Returns
iterable<Page>

Definition at line 83 of file PageDBRepository.php.

References ILIAS\Wiki\Page\PageDBRepository\getPageFromRecord().

83  : \Iterator
84  {
85  $set = $this->db->queryF(
86  "SELECT * FROM il_wiki_page " .
87  " WHERE lang = %s AND wiki_id = %s ORDER BY title",
88  ["string", "integer"],
89  [$lang, $wiki_id]
90  );
91  while ($rec = $this->db->fetchAssoc($set)) {
92  yield $this->getPageFromRecord($rec);
93  }
94  }
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

Field Documentation

◆ $data

InternalDataService ILIAS\Wiki\Page\PageDBRepository::$data
protected

Definition at line 30 of file PageDBRepository.php.

Referenced by ILIAS\Wiki\Page\PageDBRepository\__construct().

◆ $db

ilDBInterface ILIAS\Wiki\Page\PageDBRepository::$db
protected

Definition at line 31 of file PageDBRepository.php.

Referenced by ILIAS\Wiki\Page\PageDBRepository\__construct().


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