ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
15 {
16  static $block_type = "wikiside";
17  static $st_data;
18 
22  function __construct()
23  {
24  global $ilCtrl, $lng;
25 
26  parent::__construct();
27 
28  $lng->loadLanguageModule("wiki");
29  $this->setEnableNumInfo(false);
30 
31  $this->setTitle($lng->txt("wiki_functions"));
32  $this->allow_moving = false;
33  }
34 
40  static function getBlockType()
41  {
42  return self::$block_type;
43  }
44 
50  static function isRepositoryObject()
51  {
52  return false;
53  }
54 
58  static function getScreenMode()
59  {
60  return IL_SCREEN_SIDE;
61  }
62 
66  function executeCommand()
67  {
68  global $ilCtrl;
69 
70  $next_class = $ilCtrl->getNextClass();
71  $cmd = $ilCtrl->getCmd("getHTML");
72 
73  switch ($next_class)
74  {
75  default:
76  return $this->$cmd();
77  }
78  }
79 
85  function setPageObject($a_pageob)
86  {
87  $this->pageob = $a_pageob;
88  }
89 
95  function getPageObject()
96  {
97  return $this->pageob;
98  }
99 
103  function getHTML()
104  {
105  global $ilCtrl, $lng, $ilUser;
106 
107  return parent::getHTML();
108  }
109 
113  function fillDataSection()
114  {
115  global $ilCtrl, $lng, $ilAccess;
116 
117  $tpl = new ilTemplate("tpl.wiki_side_block_content.html", true, true, "Modules/Wiki");
118 
119  $wp = $this->getPageObject();
120 
121  // info
122  $actions[] = array(
123  "txt" => $lng->txt("info_short"),
124  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "infoScreen")
125  );
126 
127  // recent changes
128  $actions[] = array(
129  "txt" => $lng->txt("wiki_recent_changes"),
130  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "recentChanges")
131  );
132 
133  foreach ($actions as $a)
134  {
135  $tpl->setCurrentBlock("action");
136  $tpl->setVariable("HREF", $a["href"]);
137  $tpl->setVariable("TXT", $a["txt"]);
138  $tpl->parseCurrentBlock();
139 
140  $tpl->touchBlock("item");
141  }
142 
143 
144  $actions = array();
145 
146  // all pages
147  $actions[] = array(
148  "txt" => $lng->txt("wiki_all_pages"),
149  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "allPages")
150  );
151 
152  // new pages
153  $actions[] = array(
154  "txt" => $lng->txt("wiki_new_pages"),
155  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "newPages")
156  );
157 
158  // popular pages
159  $actions[] = array(
160  "txt" => $lng->txt("wiki_popular_pages"),
161  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "popularPages")
162  );
163 
164  // orphaned pages
165  $actions[] = array(
166  "txt" => $lng->txt("wiki_orphaned_pages"),
167  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "orphanedPages")
168  );
169 
170 
171  // page lists
172  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
173  $list = new ilAdvancedSelectionListGUI();
174  $list->setListTitle($lng->txt("wiki_page_lists"));
176  $list->setId("wiki_pglists");
177 
178  foreach ($actions as $a)
179  {
180  $list->addItem($a["txt"], "",
181  $a["href"]);
182  }
183  $tpl->setCurrentBlock("plain");
184  $tpl->setVariable("PLAIN", $list->getHTML());
185  $tpl->parseCurrentBlock();
186  $tpl->touchBlock("item");
187 
188 
189  // page actions
190  $list = new ilAdvancedSelectionListGUI();
192  $list->setListTitle($lng->txt("wiki_page_actions"));
193  $list->setId("wiki_pgactions");
194 
195  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
196  {
197  // rating
198  if(ilObjWiki::_lookupRating($this->getPageObject()->getWikiId()))
199  {
200  if(!$this->getPageObject()->getRating())
201  {
202  $list->addItem($lng->txt("wiki_activate_page_rating"), "",
203  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "activateWikiPageRating"));
204  }
205  else
206  {
207  $list->addItem($lng->txt("wiki_deactivate_page_rating"), "",
208  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deactivateWikiPageRating"));
209  }
210  }
211 
212  // unhide advmd?
213  include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDRecord.php';
214  if((bool)sizeof(ilAdvancedMDRecord::_getSelectedRecordsByObject("wiki", $this->getPageObject()->getWikiId(), "wpg")) &&
216  {
217  $list->addItem($lng->txt("wiki_unhide_meta_adv_records"), "",
218  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unhideAdvancedMetaData"));
219  }
220  }
221 
222  if (($ilAccess->checkAccess("edit_content", "", $_GET["ref_id"]) && !$this->getPageObject()->getBlocked())
223  || $ilAccess->checkAccess("write", "", $_GET["ref_id"]))
224  {
225  // rename
226  $list->addItem($lng->txt("wiki_rename_page"), "",
227  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "renameWikiPage"));
228  }
229 
230  include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
231  if (ilWikiPerm::check("activate_wiki_protection", $_GET["ref_id"]))
232  {
233  // block/unblock
234  if ($this->getPageObject()->getBlocked())
235  {
236  $list->addItem($lng->txt("wiki_unblock_page"), "",
237  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "unblockWikiPage"));
238  }
239  else
240  {
241  $list->addItem($lng->txt("wiki_block_page"), "",
242  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "blockWikiPage"));
243  }
244  }
245 
246  include_once("./Modules/Wiki/classes/class.ilWikiPerm.php");
247  if (ilWikiPerm::check("delete_wiki_pages", $_GET["ref_id"]))
248  {
249  // delete page
250  $st_page = ilObjWiki::_lookupStartPage($this->getPageObject()->getParentId());
251  if ($st_page != $this->getPageObject()->getTitle())
252  {
253  $list->addItem($lng->txt("wiki_delete_page"), "",
254  $ilCtrl->getLinkTargetByClass("ilwikipagegui", "deleteWikiPageConfirmationScreen"));
255  }
256  }
257 
258  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
259  {
260 
261  include_once "Modules/Wiki/classes/class.ilWikiPageTemplate.php";
262  $wpt = new ilWikiPageTemplate($this->getPageObject()->getParentId());
263  if(!$wpt->isPageTemplate($this->getPageObject()->getId()))
264  {
265  $list->addItem($lng->txt("wiki_add_template"), "",
266  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "addPageTemplateFromPageAction"));
267  }
268  else
269  {
270  $list->addItem($lng->txt("wiki_remove_template_status"), "",
271  $ilCtrl->getLinkTargetByClass("ilwikipagetemplategui", "removePageTemplateFromPageAction"));
272  }
273  }
274 
275  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) ||
276  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
277  {
278  $tpl->setCurrentBlock("plain");
279  $tpl->setVariable("PLAIN", $list->getHTML());
280  $tpl->parseCurrentBlock();
281  $tpl->touchBlock("item");
282  }
283 
284  // permissions
285 // if ($ilAccess->checkAccess('edit_permission', "", $_GET["ref_id"]))
286 // {
287 // $actions[] = array(
288 // "txt" => $lng->txt("perm_settings"),
289 // "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilpermissiongui"), "perm")
290 // );
291 // }
292 
293  $actions = array();
294 
295  // settings
296  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
297  {
298  $actions[] = array(
299  "txt" => $lng->txt("wiki_contributors"),
300  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "listContributors")
301  );
302  }
303 
304  // manage
305  if (ilWikiPerm::check("wiki_html_export", $_GET["ref_id"]))
306  {
307  $actions[] = array(
308  "txt" => $lng->txt("wiki_html_export"),
309  "id" => "il_wiki_user_export",
310  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "initUserHTMLExport")
311  );
312  }
313 
314  // manage
315  if ($ilAccess->checkAccess('write', "", $_GET["ref_id"]))
316  {
317  $actions[] = array(
318  "txt" => $lng->txt("settings"),
319  "href" => $ilCtrl->getLinkTargetByClass("ilobjwikigui", "editSettings")
320  );
321  }
322  else if ($ilAccess->checkAccess('statistics_read', "", $_GET["ref_id"]))
323  {
324  $actions[] = array(
325  "txt" => $lng->txt("statistics"),
326  "href" => $ilCtrl->getLinkTargetByClass(array("ilobjwikigui", "ilwikistatgui"), "initial")
327  );
328  }
329 
330  foreach ($actions as $a)
331  {
332  $tpl->setCurrentBlock("action");
333  $tpl->setVariable("HREF", $a["href"]);
334  $tpl->setVariable("TXT", $a["txt"]);
335  if ($a["id"] != "")
336  {
337  $tpl->setVariable("ACT_ID", "id='".$a["id"]."'");
338  }
339  $tpl->parseCurrentBlock();
340 
341  $tpl->touchBlock("item");
342  }
343 
344 
345  $this->setDataSection($tpl->get());
346  }
347 }
348 
349 ?>
static check($a_perm, $a_ref_id, $a_cmd="")
Check permission.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
static _lookupStartPage($a_wiki_id)
Lookup start page.
$cmd
Definition: sahs_server.php:35
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
static lookupAdvancedMetadataHidden($a_page_id)
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
BlockGUI class for wiki functions block.
static _lookupRating($a_wiki_id)
Lookup whether rating is activated.
setTitle($a_title)
Set Title.
static isRepositoryObject()
Is this a repository object.
special template class to simplify handling of ITX/PEAR
$ilUser
Definition: imgupload.php:18
static _getSelectedRecordsByObject($a_obj_type, $a_obj_id, $a_sub_type="")
Get selected records by object.
static getScreenMode()
Get Screen Mode for current command.
Create styles array
The data for the language used.
User interface class for advanced drop-down selection lists.
global $lng
Definition: privfeed.php:17
static getBlockType()
Get block type.
This class represents a block method of a block.
const IL_SCREEN_SIDE
setPageObject($a_pageob)
Set Page Object.
getTitle()
Get Title.