ILIAS  release_4-3 Revision
 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  //$this->setImage(ilUtil::getImagePath("icon_news_s.png"));
31 
32  $lng->loadLanguageModule("wiki");
33  //$this->setBlockId(...);
34  /*$this->setLimit(5);
35  $this->setAvailableDetailLevels(3);*/
36  $this->setEnableNumInfo(false);
37 
38  $this->setTitle($lng->txt("wiki_functions"));
39  //$this->setRowTemplate("tpl.block_row_news_for_context.html", "Services/News");
40  //$this->setData($data);
41  $this->allow_moving = false;
42  //$this->handleView();
43  }
44 
50  static function getBlockType()
51  {
52  return self::$block_type;
53  }
54 
60  static function isRepositoryObject()
61  {
62  return false;
63  }
64 
68  static function getScreenMode()
69  {
70  return IL_SCREEN_SIDE;
71  }
72 
76  function &executeCommand()
77  {
78  global $ilCtrl;
79 
80  $next_class = $ilCtrl->getNextClass();
81  $cmd = $ilCtrl->getCmd("getHTML");
82 
83  switch ($next_class)
84  {
85  default:
86  return $this->$cmd();
87  }
88  }
89 
95  function setPageObject($a_pageob)
96  {
97  $this->pageob = $a_pageob;
98  }
99 
105  function getPageObject()
106  {
107  return $this->pageob;
108  }
109 
113  function getHTML()
114  {
115  global $ilCtrl, $lng, $ilUser;
116 
117  return parent::getHTML();
118  }
119 
123  function fillDataSection()
124  {
125  global $ilCtrl, $lng, $ilAccess;
126 
127  $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki");
128 
129  $wp = $this->getPageObject();
130 
131  // info
132  $actions[] = array(
133  "txt" => $lng->txt("info_short"),
134  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")
135  );
136 
137  // recent changes
138  $actions[] = array(
139  "txt" => $lng->txt("wiki_recent_changes"),
140  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")
141  );
142 
143  foreach ($actions as $a)
144  {
145  $tpl->setCurrentBlock("action");
146  $tpl->setVariable("HREF", $a["href"]);
147  $tpl->setVariable("TXT", $a["txt"]);
148  $tpl->parseCurrentBlock();
149 
150  $tpl->touchBlock("item");
151  }
152 
153 
154  $actions = array();
155 
156  // all pages
157  $actions[] = array(
158  "txt" => $lng->txt("wiki_all_pages"),
159  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")
160  );
161 
162  // new pages
163  $actions[] = array(
164  "txt" => $lng->txt("wiki_new_pages"),
165  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")
166  );
167 
168  // popular pages
169  $actions[] = array(
170  "txt" => $lng->txt("wiki_popular_pages"),
171  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")
172  );
173 
174  // orphaned pages
175  $actions[] = array(
176  "txt" => $lng->txt("wiki_orphaned_pages"),
177  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")
178  );
179 
180 
181  // page lists
182  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
183  $list = new ilAdvancedSelectionListGUI();
184  $list->setListTitle($lng->txt("wiki_page_lists"));
185  $list->setId("wiki_pglists");
186 
187  foreach ($actions as $a)
188  {
189  $list->addItem($a["txt"], "",
190  $a["href"]);
191  }
192  $tpl->setCurrentBlock("plain");
193  $tpl->setVariable("PLAIN", $list->getHTML());
194  $tpl->parseCurrentBlock();
195  $tpl->touchBlock("item");
196 
197 
198  // page actions
199  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
200  {
201  $list = new ilAdvancedSelectionListGUI();
202  $list->setListTitle($lng->txt("wiki_page_actions"));
203  $list->setId("wiki_pgactions");
204 
205  // rating
206  if(ilObjWiki::_lookupRating($this->getPageObject()->getWikiId()))
207  {
208  if(!$this->getPageObject()->getRating())
209  {
210  $list->addItem($lng->txt("wiki_activate_page_rating"), "",
211  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating"));
212  }
213  else
214  {
215  $list->addItem($lng->txt("wiki_deactivate_page_rating"), "",
216  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating"));
217  }
218  }
219 
220  // rename
221  $list->addItem($lng->txt("wiki_rename_page"), "",
222  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage"));
223 
224  // block/unblock
225  if ($this->getPageObject()->getBlocked())
226  {
227  $list->addItem($lng->txt("wiki_unblock_page"), "",
228  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage"));
229  }
230  else
231  {
232  $list->addItem($lng->txt("wiki_block_page"), "",
233  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage"));
234  }
235 
236  // delete page
237  $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
238  if ($st_page != $this->getPageObject()->getTitle())
239  {
240  $list->addItem($lng->txt("wiki_delete_page"), "",
241  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen"));
242  }
243 
244  $tpl->setCurrentBlock("plain");
245  $tpl->setVariable("PLAIN", $list->getHTML());
246  $tpl->parseCurrentBlock();
247  $tpl->touchBlock("item");
248  }
249 
250 
251  // permissions
252 // if ($ilAccess->checkAccess('edit_permission', "", $_GET["ref_id"]))
253 // {
254 // $actions[] = array(
255 // "txt" => $lng->txt("perm_settings"),
256 // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
257 // );
258 // }
259 
260  $actions = array();
261 
262  // settings
263  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
264  {
265 // $actions[] = array(
266 // "txt" => $lng->txt("settings"),
267 // "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
268 // );
269  $actions[] = array(
270  "txt" => $lng->txt("wiki_contributors"),
271  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
272  );
273  }
274 
275  // manage
276  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
277  {
278  $actions[] = array(
279  "txt" => $lng->txt("settings"),
280  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
281  );
282  }
283 
284  foreach ($actions as $a)
285  {
286  $tpl->setCurrentBlock("action");
287  $tpl->setVariable("HREF", $a["href"]);
288  $tpl->setVariable("TXT", $a["txt"]);
289  $tpl->parseCurrentBlock();
290 
291  $tpl->touchBlock("item");
292  }
293 
294 
295  $this->setDataSection($tpl->get());
296  }
297 }
298 
299 ?>