ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilWikiPagesTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("Services/Table/classes/class.ilTable2GUI.php");
6 
7 define ("IL_WIKI_ALL_PAGES", "all");
8 define ("IL_WIKI_NEW_PAGES", "new");
9 define ("IL_WIKI_POPULAR_PAGES", "popular");
10 define ("IL_WIKI_WHAT_LINKS_HERE", "what_links");
11 define ("IL_WIKI_ORPHANED_PAGES", "orphaned");
12 
22 {
23 
24  function ilWikiPagesTableGUI($a_parent_obj, $a_parent_cmd = "",
25  $a_wiki_id, $a_mode = IL_WIKI_ALL_PAGES, $a_page_id = 0)
26  {
27  global $ilCtrl, $lng;
28 
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30  $this->pg_list_mode = $a_mode;
31  $this->wiki_id = $a_wiki_id;
32  $this->page_id = $a_page_id;
33 
34  switch($this->pg_list_mode)
35  {
36  case IL_WIKI_NEW_PAGES:
37  $this->addColumn($lng->txt("created"), "", "33%");
38  $this->addColumn($lng->txt("wiki_page"), "", "33%");
39  $this->addColumn($lng->txt("wiki_created_by"), "", "34%");
40  $this->setRowTemplate("tpl.table_row_wiki_new_page.html",
41  "Modules/Wiki");
42  break;
43 
45  $this->addColumn($lng->txt("wiki_page"), "", "50%");
46  $this->addColumn($lng->txt("wiki_page_hits"), "", "50%");
47  $this->setRowTemplate("tpl.table_row_wiki_popular_page.html",
48  "Modules/Wiki");
49  break;
50 
52  $this->addColumn($lng->txt("wiki_page"), "", "100%");
53  $this->setRowTemplate("tpl.table_row_wiki_orphaned_page.html",
54  "Modules/Wiki");
55  break;
56 
57  default:
58  $this->addColumn($lng->txt("wiki_page"), "", "33%");
59  $this->addColumn($lng->txt("wiki_last_changed"), "", "33%");
60  $this->addColumn($lng->txt("wiki_last_changed_by"), "", "34%");
61  $this->setRowTemplate("tpl.table_row_wiki_page.html",
62  "Modules/Wiki");
63  break;
64  }
65  $this->setEnableHeader(true);
66  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
67  $this->getPages();
68 
69  switch($this->pg_list_mode)
70  {
72  $this->setTitle(sprintf($lng->txt("wiki_what_links_to_page"),
73  ilWikiPage::lookupTitle($this->page_id)));
74  break;
75 
76  default:
77  $this->setTitle($lng->txt("wiki_".$a_mode."_pages"));
78  break;
79  }
80  }
81 
85  function getPages()
86  {
87  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
88 
89  $pages = array();
90  $this->setDefaultOrderField("title");
91 
92  switch ($this->pg_list_mode)
93  {
95  $pages = ilWikiPage::getLinksToPage($this->wiki_id, $this->page_id);
96  break;
97 
98  case IL_WIKI_ALL_PAGES:
99  $pages = ilWikiPage::getAllPages($this->wiki_id);
100  break;
101 
102  case IL_WIKI_NEW_PAGES:
103  $this->setDefaultOrderField("created");
104  $this->setDefaultOrderDirection("desc");
105  $pages = ilWikiPage::getNewPages($this->wiki_id);
106  break;
107 
109  $this->setDefaultOrderField("cnt");
110  $this->setDefaultOrderDirection("desc");
111  $pages = ilWikiPage::getPopularPages($this->wiki_id);
112  break;
113 
115  $pages = ilWikiPage::getOrphanedPages($this->wiki_id);
116  break;
117  }
118 
119  $this->setData($pages);
120  }
121 
122  function numericOrdering($a_field)
123  {
124  if ($a_field == "cnt")
125  {
126  return true;
127  }
128  return false;
129  }
130 
135  protected function fillRow($a_set)
136  {
137  global $lng, $ilCtrl;
138 
139  if ($this->pg_list_mode == IL_WIKI_NEW_PAGES)
140  {
141  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
142  $this->tpl->setVariable("DATE",
144  }
145  else if ($this->pg_list_mode == IL_WIKI_POPULAR_PAGES)
146  {
147  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
148  $this->tpl->setVariable("HITS", $a_set["cnt"]);
149  }
150  else
151  {
152  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
153  $this->tpl->setVariable("DATE",
155  }
156  $this->tpl->setVariable("HREF_PAGE",
157  ilObjWikiGUI::getGotoLink($_GET["ref_id"], $a_set["title"]));
158 
159  // user name
160  include_once("./Services/User/classes/class.ilUserUtil.php");
161  $this->tpl->setVariable("TXT_USER",
162  ilUserUtil::getNamePresentation($a_set["user"], true, true,
163  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())
164  ));
165  }
166 
167 }
168 ?>