ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilWikiPageTemplateGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 protected $wiki_gui;
15 protected $ctrl;
16 protected $tpl;
17
23 function __construct(ilObjWikiGUI $a_wiki_gui)
24 {
25 global $ilCtrl, $tpl, $ilToolbar, $lng;
26
27 $this->wiki_gui = $a_wiki_gui;
28 $this->wiki = $this->wiki_gui->object;
29 $this->ctrl = $ilCtrl;
30 $this->tpl = $tpl;
31 $this->lng = $lng;
32 $this->toolbar = $ilToolbar;
33 }
34
38 function executeCommand()
39 {
40 $nc = $this->ctrl->getNextClass();
41
42 switch($nc)
43 {
44 default:
45 $cmd = $this->ctrl->getCmd("listTemplates");
46 if (in_array($cmd, array("listTemplates", "add", "remove", "saveTemplateSettings", "addPageTemplateFromPageAction", "removePageTemplateFromPageAction")))
47 {
48 $this->$cmd();
49 }
50 break;
51 }
52 }
53
57 function listTemplates()
58 {
59 // list pages
60 include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
61 $pages = ilWikiPage::getAllPages($this->wiki->getId());
62 $options = array("" => $this->lng->txt("please_select"));
63 foreach ($pages as $p)
64 {
65 //if (!in_array($p["id"], $ipages_ids))
66 //{
67 $options[$p["id"]] = ilUtil::shortenText($p["title"], 60, true);
68 //}
69 }
70
71 $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
72 $this->toolbar->setOpenFormTag(true);
73 $this->toolbar->setCloseFormTag(false);
74
75 if (count($options) > 0)
76 {
77 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
78 $si = new ilSelectInputGUI($this->lng->txt("wiki_pages"), "templ_page_id");
79 $si->setOptions($options);
80 $this->toolbar->addInputItem($si);
81 $this->toolbar->addFormButton($this->lng->txt("wiki_add_template"), "add");
82 $this->toolbar->addSeparator();
83
84 }
85
86 // empty page as template?
87 include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
88 $cb = new ilCheckboxInputGUI($this->lng->txt("wiki_empty_page_template"), "empty_page_templ");
89 $cb->setChecked($this->wiki->getEmptyPageTemplate());
90 $this->toolbar->addInputItem($cb, true);
91 $this->toolbar->addFormButton($this->lng->txt("save"), "saveTemplateSettings");
92
93
94 include_once("./Modules/Wiki/classes/class.ilWikiPageTemplatesTableGUI.php");
95 $tab = new ilWikiPageTemplatesTableGUI($this, "listTemplates", $this->wiki->getId());
96 $tab->setOpenFormTag(false);
97 $tab->setCloseFormTag(true);
98 $this->tpl->setContent($tab->getHTML());
99 }
100
104 function add()
105 {
106 include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
107 $wpt = new ilWikiPageTemplate($this->wiki->getId());
108 $wpt->save((int) $_POST["templ_page_id"]);
109 ilUtil::sendSuccess($this->lng->txt("wiki_template_added"), true);
110 $this->ctrl->redirect($this, "listTemplates");
111 }
112
116 function remove()
117 {
118 include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
119 $wpt = new ilWikiPageTemplate($this->wiki->getId());
120
121 if (is_array($_POST["id"]))
122 {
123 foreach ($_POST["id"] as $id)
124 {
125 $wpt->remove((int) $id);
126 }
127 ilUtil::sendSuccess($this->lng->txt("wiki_template_status_removed"), true);
128 }
129
130 $this->ctrl->redirect($this, "listTemplates");
131 }
132
137 {
138 if (is_array($_POST["all_ids"]))
139 {
140 include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
141 foreach ($_POST["all_ids"] as $id)
142 {
143 $wpt = new ilWikiPageTemplate($this->wiki->getId());
144 $wpt->save((int) $id, (int) $_POST["new_pages"][$id], (int) $_POST["add_to_page"][$id]);
145 }
146 }
147
148 $this->wiki->setEmptyPageTemplate((int) $_POST["empty_page_templ"]);
149 $this->wiki->update();
150
151 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
152 $this->ctrl->redirect($this, "listTemplates");
153 }
154
155
156 //
157 // PAGE ACTIONS
158 //
159
161 {
162 $page_id = (int)$_GET["wpg_id"];
163 if($page_id)
164 {
165 include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
166 $wpt = new ilWikiPageTemplate($this->wiki->getId());
167 $wpt->remove($page_id);
168 ilUtil::sendSuccess($this->lng->txt("wiki_template_status_removed"), true);
169 }
170
171 $this->ctrl->redirect($this, "listTemplates");
172 }
173
175 {
176 $page_id = (int)$_GET["wpg_id"];
177 if($page_id)
178 {
179 include_once("./Modules/Wiki/classes/class.ilWikiPageTemplate.php");
180 $wpt = new ilWikiPageTemplate($this->wiki->getId());
181 $wpt->save($page_id);
182 ilUtil::sendSuccess($this->lng->txt("wiki_template_added"), true);
183 }
184
185 $this->ctrl->redirect($this, "listTemplates");
186 }
187}
188
189?>
$_GET["client_id"]
This class represents a checkbox property in a property form.
Class ilObjWikiGUI.
This class represents a selection list property in a property form.
static shortenText($a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
Wiki page template gui class.
__construct(ilObjWikiGUI $a_wiki_gui)
Constructor.
saveTemplateSettings()
Save template settings.
add()
Add page as template page.
TableGUI class for wiki page templates.
static getAllPages($a_wiki_id)
Get all pages of wiki
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
if(!is_array($argv)) $options