ILIAS  release_8 Revision v8.24
ilWikiPageTemplate Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilWikiPageTemplate:

Public Member Functions

 __construct (int $a_wiki_id)
 
 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. More...
 
 remove (int $a_id)
 Remove template status of a page. More...
 
 isPageTemplate (int $a_id)
 Is page set as template? More...
 

Data Fields

const TYPE_ALL = 0
 
const TYPE_NEW_PAGES = 1
 
const TYPE_ADD_TO_PAGE = 2
 

Protected Attributes

ilDBInterface $db
 
int $wiki_id
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Wiki page template

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilWikiPageTemplate::__construct ( int  $a_wiki_id)

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

35 {
36 global $DIC;
37
38 $this->wiki_id = $a_wiki_id;
39 $this->db = $DIC->database();
40 }
global $DIC
Definition: feed.php:28

References $DIC.

Member Function Documentation

◆ getAllInfo()

ilWikiPageTemplate::getAllInfo ( int  $a_type = self::TYPE_ALL)

Definition at line 42 of file class.ilWikiPageTemplate.php.

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 }

◆ isPageTemplate()

ilWikiPageTemplate::isPageTemplate ( int  $a_id)

Is page set as template?

Definition at line 120 of file class.ilWikiPageTemplate.php.

120 : 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 }

◆ remove()

ilWikiPageTemplate::remove ( int  $a_id)

Remove template status of a page.

Parameters
int$a_idwiki page id

Definition at line 107 of file class.ilWikiPageTemplate.php.

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 }

◆ save()

ilWikiPageTemplate::save ( int  $a_id,
int  $a_new_pages = 0,
int  $a_add_to_page = 0 
)

Add wiki page template.

Parameters
int$a_idwiki page id

Definition at line 70 of file class.ilWikiPageTemplate.php.

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 }

Field Documentation

◆ $db

ilDBInterface ilWikiPageTemplate::$db
protected

Definition at line 30 of file class.ilWikiPageTemplate.php.

◆ $wiki_id

int ilWikiPageTemplate::$wiki_id
protected

Definition at line 31 of file class.ilWikiPageTemplate.php.

◆ TYPE_ADD_TO_PAGE

const ilWikiPageTemplate::TYPE_ADD_TO_PAGE = 2

Definition at line 28 of file class.ilWikiPageTemplate.php.

Referenced by ilWikiPage\getContentTemplates().

◆ TYPE_ALL

const ilWikiPageTemplate::TYPE_ALL = 0

Definition at line 26 of file class.ilWikiPageTemplate.php.

◆ TYPE_NEW_PAGES

const ilWikiPageTemplate::TYPE_NEW_PAGES = 1

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