ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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, string $lang="-")
 
 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: shib_login.php:26

References $DIC.

Member Function Documentation

◆ getAllInfo()

ilWikiPageTemplate::getAllInfo ( int  $a_type = self::TYPE_ALL,
string  $lang = "-" 
)

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

45 : array {
46 if ($lang === "") {
47 $lang = "-";
48 }
49 $and = "";
50 if ($a_type === self::TYPE_NEW_PAGES) {
51 $and = " AND t.new_pages = " . $this->db->quote(1, "integer");
52 }
53 if ($a_type === self::TYPE_ADD_TO_PAGE) {
54 $and = " AND t.add_to_page = " . $this->db->quote(1, "integer");
55 }
56
57 $set = $this->db->queryF(
58 $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 " .
59 " (t.wpage_id = p.id AND p.lang = %s) " .
60 " WHERE t.wiki_id = %s " .
61 $and,
62 ["text", "integer"],
63 [$lang, $this->wiki_id]
64 );
65 $templates = array();
66 while ($rec = $this->db->fetchAssoc($set)) {
67 $templates[] = $rec;
68 }
69 return $templates;
70 }
$q
Definition: shib_logout.php:23
$lang
Definition: xapiexit.php:25

References $lang.

◆ isPageTemplate()

ilWikiPageTemplate::isPageTemplate ( int  $a_id)

Is page set as template?

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

126 : bool
127 {
128 $set = $this->db->query("SELECT t.wpage_id" .
129 " FROM wiki_page_template t" .
130 " JOIN il_wiki_page p ON " .
131 " (t.wpage_id = p.id) " .
132 " WHERE t.wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
133 " AND p.id = " . $this->db->quote($a_id, "integer"));
134 return (bool) $this->db->numRows($set);
135 }

◆ remove()

ilWikiPageTemplate::remove ( int  $a_id)

Remove template status of a page.

Parameters
int$a_idwiki page id

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

115 : void {
116 $this->db->manipulate(
117 "DELETE FROM wiki_page_template WHERE " .
118 " wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
119 " AND wpage_id = " . $this->db->quote($a_id, "integer")
120 );
121 }

◆ 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 76 of file class.ilWikiPageTemplate.php.

80 : void {
81 if ($a_id <= 0) {
82 return;
83 }
84
85 $set = $this->db->query(
86 "SELECT * FROM wiki_page_template " .
87 " WHERE wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
88 " AND wpage_id = " . $this->db->quote($a_id, "integer")
89 );
90 if (!$this->db->fetchAssoc($set)) {
91 $this->db->manipulate("INSERT INTO wiki_page_template " .
92 "(wiki_id, wpage_id, new_pages, add_to_page) VALUES (" .
93 $this->db->quote($this->wiki_id, "integer") . "," .
94 $this->db->quote($a_id, "integer") . "," .
95 $this->db->quote($a_new_pages, "integer") . "," .
96 $this->db->quote($a_add_to_page, "integer") .
97 ")");
98 } else {
99 $this->db->manipulate(
100 "UPDATE wiki_page_template SET " .
101 " new_pages = " . $this->db->quote($a_new_pages, "integer") . "," .
102 " add_to_page = " . $this->db->quote($a_add_to_page, "integer") .
103 " WHERE wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
104 " AND wpage_id = " . $this->db->quote($a_id, "integer")
105 );
106 }
107 }

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


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