ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

 $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 26 of file class.ilWikiPageTemplate.php.

References $ilDB.

27  {
28  global $ilDB;
29 
30  $this->wiki_id = $a_wiki_id;
31  $this->db = $ilDB;
32  }

Member Function Documentation

◆ getAllInfo()

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

Get all info.

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

References $a_type, and array.

Referenced by ilObjWikiGUI\initTemplateSelectionForm().

38  {
39  $and = "";
40  if ($a_type == self::TYPE_NEW_PAGES)
41  {
42  $and = " AND t.new_pages = ".$this->db->quote(1, "integer");
43  }
44  if ($a_type == self::TYPE_ADD_TO_PAGE)
45  {
46  $and = " AND t.add_to_page = ".$this->db->quote(1, "integer");
47  }
48 
49  $set = $this->db->query($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 ".
50  " (t.wpage_id = p.id) ".
51  " WHERE t.wiki_id = ".$this->db->quote($this->wiki_id, "integer").
52  $and
53  );
54  $templates = array();
55  while ($rec = $this->db->fetchAssoc($set))
56  {
57  $templates[] = $rec;
58  }
59  return $templates;
60  }
$a_type
Definition: workflow.php:93
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 118 of file class.ilWikiPageTemplate.php.

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

◆ remove()

ilWikiPageTemplate::remove (   $a_id)

Remove template status of a page.

Parameters
int$a_idwiki page id

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

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

105  {
106  $this->db->manipulate("DELETE FROM wiki_page_template WHERE ".
107  " wiki_id = ".$this->db->quote($this->wiki_id, "integer").
108  " AND wpage_id = ".$this->db->quote($a_id, "integer")
109  );
110  }
+ 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 67 of file class.ilWikiPageTemplate.php.

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

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

Field Documentation

◆ $ilDB

ilWikiPageTemplate::$ilDB
protected

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

Referenced by __construct().

◆ $wiki_id

ilWikiPageTemplate::$wiki_id
protected

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

◆ TYPE_ADD_TO_PAGE

const ilWikiPageTemplate::TYPE_ADD_TO_PAGE = 2

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

Referenced by ilWikiPage\getContentTemplates().

◆ TYPE_ALL

const ilWikiPageTemplate::TYPE_ALL = 0

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