ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilWikiPageTemplate Class Reference

Wiki page template. More...

+ Collaboration diagram for ilWikiPageTemplate:

Public Member Functions

 __construct ($a_wiki_id)
 Constructor. More...
 
 getAllInfo ($a_type=self::TYPE_ALL)
 Get all info. More...
 
 save ($a_id, $a_new_pages=0, $a_add_to_page=0)
 Add wiki page template. More...
 
 remove ($a_id)
 Remove template status of a page. More...
 
 isPageTemplate ($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

 $db
 
 $wiki_id
 
 $ilDB
 

Detailed Description

Wiki page template.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilWikiPageTemplate::__construct (   $a_wiki_id)

Constructor.

Parameters
int$a_wiki_idwiki id

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

References $DIC, and $ilDB.

32  {
33  global $DIC;
34 
35  $ilDB = $DIC->database();
36 
37  $this->wiki_id = $a_wiki_id;
38  $this->db = $ilDB;
39  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ getAllInfo()

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

Get all info.

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

References $a_type, and array.

Referenced by ilObjWikiGUI\initTemplateSelectionForm().

45  {
46  $and = "";
47  if ($a_type == self::TYPE_NEW_PAGES) {
48  $and = " AND t.new_pages = " . $this->db->quote(1, "integer");
49  }
50  if ($a_type == self::TYPE_ADD_TO_PAGE) {
51  $and = " AND t.add_to_page = " . $this->db->quote(1, "integer");
52  }
53 
54  $set = $this->db->query(
55  $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 " .
56  " (t.wpage_id = p.id) " .
57  " WHERE t.wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
58  $and
59  );
60  $templates = array();
61  while ($rec = $this->db->fetchAssoc($set)) {
62  $templates[] = $rec;
63  }
64  return $templates;
65  }
$a_type
Definition: workflow.php:92
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ isPageTemplate()

ilWikiPageTemplate::isPageTemplate (   $a_id)

Is page set as template?

Parameters
int$a_idwiki page id
Returns
type bool

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

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

◆ remove()

ilWikiPageTemplate::remove (   $a_id)

Remove template status of a page.

Parameters
int$a_idwiki page id

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

Referenced by ilWikiPageTemplateGUI\remove(), and ilWikiPageTemplateGUI\removePageTemplateFromPageAction().

108  {
109  $this->db->manipulate(
110  "DELETE FROM wiki_page_template WHERE " .
111  " wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
112  " AND wpage_id = " . $this->db->quote($a_id, "integer")
113  );
114  }
+ Here is the caller graph for this function:

◆ save()

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

Add wiki page template.

Parameters
int$a_idwiki page id

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

Referenced by ilWikiPageTemplateGUI\add(), ilWikiPageTemplateGUI\addPageTemplateFromPageAction(), and ilWikiPageTemplateGUI\saveTemplateSettings().

73  {
74  if ($a_id <= 0) {
75  return;
76  }
77 
78  $set = $this->db->query(
79  "SELECT * FROM wiki_page_template " .
80  " WHERE wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
81  " AND wpage_id = " . $this->db->quote($a_id, "integer")
82  );
83  if (!$this->db->fetchAssoc($set)) {
84  $this->db->manipulate("INSERT INTO wiki_page_template " .
85  "(wiki_id, wpage_id, new_pages, add_to_page) VALUES (" .
86  $this->db->quote($this->wiki_id, "integer") . "," .
87  $this->db->quote($a_id, "integer") . "," .
88  $this->db->quote($a_new_pages, "integer") . "," .
89  $this->db->quote($a_add_to_page, "integer") .
90  ")");
91  } else {
92  $this->db->manipulate(
93  "UPDATE wiki_page_template SET " .
94  " new_pages = " . $this->db->quote($a_new_pages, "integer") . "," .
95  " add_to_page = " . $this->db->quote($a_add_to_page, "integer") .
96  " WHERE wiki_id = " . $this->db->quote($this->wiki_id, "integer") .
97  " AND wpage_id = " . $this->db->quote($a_id, "integer")
98  );
99  }
100  }
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilWikiPageTemplate::$db
protected

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

◆ $ilDB

ilWikiPageTemplate::$ilDB
protected

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

Referenced by __construct().

◆ $wiki_id

ilWikiPageTemplate::$wiki_id
protected

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

◆ TYPE_ADD_TO_PAGE

const ilWikiPageTemplate::TYPE_ADD_TO_PAGE = 2

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

Referenced by ilWikiPage\getContentTemplates().

◆ TYPE_ALL

const ilWikiPageTemplate::TYPE_ALL = 0

Definition at line 19 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: