ILIAS  Release_4_4_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  //$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  $list = new ilAdvancedSelectionListGUI();
200  $list->setListTitle($lng->txt("wiki_page_actions"));
201  $list->setId("wiki_pgactions");
202 
203  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
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 
221  if ($ilAccess->checkAccess("edit_content", "", $_GET["ref_id"]))
222  {
223  // rename
224  $list->addItem($lng->txt("wiki_rename_page"), "",
225  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage"));
226  }
227 
228  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
229  {
230  // block/unblock
231  if ($this->getPageObject()->getBlocked())
232  {
233  $list->addItem($lng->txt("wiki_unblock_page"), "",
234  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage"));
235  }
236  else
237  {
238  $list->addItem($lng->txt("wiki_block_page"), "",
239  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage"));
240  }
241 
242  // delete page
243  $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
244  if ($st_page != $this->getPageObject()->getTitle())
245  {
246  $list->addItem($lng->txt("wiki_delete_page"), "",
247  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen"));
248  }
249  }
250 
251  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) ||
252  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
253  {
254  $tpl->setCurrentBlock("plain");
255  $tpl->setVariable("PLAIN", $list->getHTML());
256  $tpl->parseCurrentBlock();
257  $tpl->touchBlock("item");
258  }
259 
260  // permissions
261 // if ($ilAccess->checkAccess('edit_permission', "", $_GET["ref_id"]))
262 // {
263 // $actions[] = array(
264 // "txt" => $lng->txt("perm_settings"),
265 // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
266 // );
267 // }
268 
269  $actions = array();
270 
271  // settings
272  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
273  {
274 // $actions[] = array(
275 // "txt" => $lng->txt("settings"),
276 // "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
277 // );
278  $actions[] = array(
279  "txt" => $lng->txt("wiki_contributors"),
280  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
281  );
282  }
283 
284  // manage
285  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
286  {
287  $actions[] = array(
288  "txt" => $lng->txt("settings"),
289  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
290  );
291  }
292 
293  foreach ($actions as $a)
294  {
295  $tpl->setCurrentBlock("action");
296  $tpl->setVariable("HREF", $a["href"]);
297  $tpl->setVariable("TXT", $a["txt"]);
298  $tpl->parseCurrentBlock();
299 
300  $tpl->touchBlock("item");
301  }
302 
303 
304  $this->setDataSection($tpl->get());
305  }
306 }
307 
308 ?>