ILIAS  release_8 Revision v8.24
class.ilWikiPageTemplate.php
Go to the documentation of this file.
1<?php
2
25{
26 public const TYPE_ALL = 0;
27 public const TYPE_NEW_PAGES = 1;
28 public const TYPE_ADD_TO_PAGE = 2;
29
30 protected ilDBInterface $db;
31 protected int $wiki_id;
32
33 public function __construct(
34 int $a_wiki_id
35 ) {
36 global $DIC;
37
38 $this->wiki_id = $a_wiki_id;
39 $this->db = $DIC->database();
40 }
41
42 public function getAllInfo(
43 int $a_type = self::TYPE_ALL
44 ): array {
45 $and = "";
46 if ($a_type === self::TYPE_NEW_PAGES) {
47 $and = " AND t.new_pages = " . $this->db->quote(1, "integer");
48 }
49 if ($a_type === self::TYPE_ADD_TO_PAGE) {
50 $and = " AND t.add_to_page = " . $this->db->quote(1, "integer");
51 }
52
53 $set = $this->db->query(
54 $q = "SELECT t.wiki_id, t.wpage_id, p.title, t.new_pages, t.add_to_page FROM wiki_page_template t JOIN il_wiki_page p ON " .
55 " (t.wpage_id = p.id) " .
56 " WHERE t.wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
57 $and
58 );
59 $templates = array();
60 while ($rec = $this->db->fetchAssoc($set)) {
61 $templates[] = $rec;
62 }
63 return $templates;
64 }
65
70 public function save(
71 int $a_id,
72 int $a_new_pages = 0,
73 int $a_add_to_page = 0
74 ): void {
75 if ($a_id <= 0) {
76 return;
77 }
78
79 $set = $this->db->query(
80 "SELECT * FROM wiki_page_template " .
81 " WHERE wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
82 " AND wpage_id = " . $this->db->quote($a_id, "integer")
83 );
84 if (!$this->db->fetchAssoc($set)) {
85 $this->db->manipulate("INSERT INTO wiki_page_template " .
86 "(wiki_id, wpage_id, new_pages, add_to_page) VALUES (" .
87 $this->db->quote($this->wiki_id, "integer") . "," .
88 $this->db->quote($a_id, "integer") . "," .
89 $this->db->quote($a_new_pages, "integer") . "," .
90 $this->db->quote($a_add_to_page, "integer") .
91 ")");
92 } else {
93 $this->db->manipulate(
94 "UPDATE wiki_page_template SET " .
95 " new_pages = " . $this->db->quote($a_new_pages, "integer") . "," .
96 " add_to_page = " . $this->db->quote($a_add_to_page, "integer") .
97 " WHERE wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
98 " AND wpage_id = " . $this->db->quote($a_id, "integer")
99 );
100 }
101 }
102
107 public function remove(
108 int $a_id
109 ): void {
110 $this->db->manipulate(
111 "DELETE FROM wiki_page_template WHERE " .
112 " wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
113 " AND wpage_id = " . $this->db->quote($a_id, "integer")
114 );
115 }
116
120 public function isPageTemplate(int $a_id): bool
121 {
122 $set = $this->db->query("SELECT t.wpage_id" .
123 " FROM wiki_page_template t" .
124 " JOIN il_wiki_page p ON " .
125 " (t.wpage_id = p.id) " .
126 " WHERE t.wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
127 " AND p.id = " . $this->db->quote($a_id, "integer"));
128 return (bool) $this->db->numRows($set);
129 }
130}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isPageTemplate(int $a_id)
Is page set as template?
getAllInfo(int $a_type=self::TYPE_ALL)
save(int $a_id, int $a_new_pages=0, int $a_add_to_page=0)
Add wiki page template.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
Interface ilDBInterface.