ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilWikiFunctionsBlockGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("Services/Block/classes/class.ilBlockGUI.php");
5 
17 {
18  static $block_type = "wikiside";
19  static $st_data;
20 
24  function __construct()
25  {
26  global $ilCtrl, $lng;
27 
29 
30  $lng->loadLanguageModule("wiki");
31  $this->setEnableNumInfo(false);
32 
33  $this->setTitle($lng->txt("wiki_functions"));
34  $this->allow_moving = false;
35  }
36 
42  static function getBlockType()
43  {
44  return self::$block_type;
45  }
46 
52  static function isRepositoryObject()
53  {
54  return false;
55  }
56 
60  static function getScreenMode()
61  {
62  return IL_SCREEN_SIDE;
63  }
64 
68  function &executeCommand()
69  {
70  global $ilCtrl;
71 
72  $next_class = $ilCtrl->getNextClass();
73  $cmd = $ilCtrl->getCmd("getHTML");
74 
75  switch ($next_class)
76  {
77  default:
78  return $this->$cmd();
79  }
80  }
81 
87  function setPageObject($a_pageob)
88  {
89  $this->pageob = $a_pageob;
90  }
91 
97  function getPageObject()
98  {
99  return $this->pageob;
100  }
101 
105  function getHTML()
106  {
107  global $ilCtrl, $lng, $ilUser;
108 
109  return parent::getHTML();
110  }
111 
115  function fillDataSection()
116  {
117  global $ilCtrl, $lng, $ilAccess;
118 
119  $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki");
120 
121  $wp = $this->getPageObject();
122 
123  // info
124  $actions[] = array(
125  "txt" => $lng->txt("info_short"),
126  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")
127  );
128 
129  // recent changes
130  $actions[] = array(
131  "txt" => $lng->txt("wiki_recent_changes"),
132  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")
133  );
134 
135  foreach ($actions as $a)
136  {
137  $tpl->setCurrentBlock("action");
138  $tpl->setVariable("HREF", $a["href"]);
139  $tpl->setVariable("TXT", $a["txt"]);
140  $tpl->parseCurrentBlock();
141 
142  $tpl->touchBlock("item");
143  }
144 
145 
146  $actions = array();
147 
148  // all pages
149  $actions[] = array(
150  "txt" => $lng->txt("wiki_all_pages"),
151  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")
152  );
153 
154  // new pages
155  $actions[] = array(
156  "txt" => $lng->txt("wiki_new_pages"),
157  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")
158  );
159 
160  // popular pages
161  $actions[] = array(
162  "txt" => $lng->txt("wiki_popular_pages"),
163  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")
164  );
165 
166  // orphaned pages
167  $actions[] = array(
168  "txt" => $lng->txt("wiki_orphaned_pages"),
169  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")
170  );
171 
172 
173  // page lists
174  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
175  $list = new ilAdvancedSelectionListGUI();
176  $list->setListTitle($lng->txt("wiki_page_lists"));
178  $list->setId("wiki_pglists");
179 
180  foreach ($actions as $a)
181  {
182  $list->addItem($a["txt"], "",
183  $a["href"]);
184  }
185  $tpl->setCurrentBlock("plain");
186  $tpl->setVariable("PLAIN", $list->getHTML());
187  $tpl->parseCurrentBlock();
188  $tpl->touchBlock("item");
189 
190 
191  // page actions
192  $list = new ilAdvancedSelectionListGUI();
194  $list->setListTitle($lng->txt("wiki_page_actions"));
195  $list->setId("wiki_pgactions");
196 
197  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
198  {
199  // rating
200  if(ilObjWiki::_lookupRating($this->getPageObject()->getWikiId()))
201  {
202  if(!$this->getPageObject()->getRating())
203  {
204  $list->addItem($lng->txt("wiki_activate_page_rating"), "",
205  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating"));
206  }
207  else
208  {
209  $list->addItem($lng->txt("wiki_deactivate_page_rating"), "",
210  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating"));
211  }
212  }
213 
214  // unhide advmd?
215  include_once("./Modules/Wiki/classes/class.ilWikiAdvMetaDataBlockGUI.php");
216  if(ilWikiAdvMetaDataBlockGUI::isActive($this->getPageObject()->getWikiId()) &&
218  {
219  $list->addItem($lng->txt("wiki_unhide_meta_adv_records"), "",
220  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData"));
221  }
222  }
223 
224  if (($ilAccess->checkAccess("edit_content", "", $_GET["ref_id"]) && !$this->getPageObject()->getBlocked())
225  || $ilAccess->checkAccess("write", "", $_GET["ref_id"]))
226  {
227  // rename
228  $list->addItem($lng->txt("wiki_rename_page"), "",
229  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage"));
230  }
231 
232  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
233  {
234  // block/unblock
235  if ($this->getPageObject()->getBlocked())
236  {
237  $list->addItem($lng->txt("wiki_unblock_page"), "",
238  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage"));
239  }
240  else
241  {
242  $list->addItem($lng->txt("wiki_block_page"), "",
243  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage"));
244  }
245 
246  // delete page
247  $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
248  if ($st_page != $this->getPageObject()->getTitle())
249  {
250  $list->addItem($lng->txt("wiki_delete_page"), "",
251  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen"));
252  }
253 
254  include_once "Modules/Wiki/classes/class.ilWikiPageTemplate.php";
255  $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId());
256  if(!$wpt->isPageTemplate($this->getPageObject()->getId()))
257  {
258  $list->addItem($lng->txt("wiki_add_template"), "",
259  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction"));
260  }
261  else
262  {
263  $list->addItem($lng->txt("wiki_remove_template_status"), "",
264  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction"));
265  }
266  }
267 
268  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) ||
269  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
270  {
271  $tpl->setCurrentBlock("plain");
272  $tpl->setVariable("PLAIN", $list->getHTML());
273  $tpl->parseCurrentBlock();
274  $tpl->touchBlock("item");
275  }
276 
277  // permissions
278 // if ($ilAccess->checkAccess('edit_permission', "", $_GET["ref_id"]))
279 // {
280 // $actions[] = array(
281 // "txt" => $lng->txt("perm_settings"),
282 // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
283 // );
284 // }
285 
286  $actions = array();
287 
288  // settings
289  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
290  {
291 // $actions[] = array(
292 // "txt" => $lng->txt("settings"),
293 // "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
294 // );
295  $actions[] = array(
296  "txt" => $lng->txt("wiki_contributors"),
297  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
298  );
299  }
300 
301  // manage
302  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
303  {
304  $actions[] = array(
305  "txt" => $lng->txt("settings"),
306  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
307  );
308  }
309  else if ($ilAccess->checkAccess('statistics_read', "", $_GET["ref_id"]))
310  {
311  $actions[] = array(
312  "txt" => $lng->txt("statistics"),
313  "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial")
314  );
315  }
316 
317  foreach ($actions as $a)
318  {
319  $tpl->setCurrentBlock("action");
320  $tpl->setVariable("HREF", $a["href"]);
321  $tpl->setVariable("TXT", $a["txt"]);
322  $tpl->parseCurrentBlock();
323 
324  $tpl->touchBlock("item");
325  }
326 
327 
328  $this->setDataSection($tpl->get());
329  }
330 }
331 
332 ?>