ILIAS  release_4-3 Revision
 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"), "created", "33%");
38  $this->addColumn($lng->txt("wiki_page"), "title", "33%");
39  $this->addColumn($lng->txt("wiki_created_by"), "user_sort", "34%");
40  $this->setRowTemplate("tpl.table_row_wiki_new_page.html",
41  "Modules/Wiki");
42  break;
43 
45  $this->addColumn($lng->txt("wiki_page"), "title", "50%");
46  $this->addColumn($lng->txt("wiki_page_hits"), "cnt", "50%");
47  $this->setRowTemplate("tpl.table_row_wiki_popular_page.html",
48  "Modules/Wiki");
49  break;
50 
52  $this->addColumn($lng->txt("wiki_page"), "title", "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"), "title", "33%");
59  $this->addColumn($lng->txt("wiki_last_changed"), "date", "33%");
60  $this->addColumn($lng->txt("wiki_last_changed_by"), "user_sort", "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  if($pages)
120  {
121  // enable sorting
122  include_once("./Services/User/classes/class.ilUserUtil.php");
123  foreach(array_keys($pages) as $idx)
124  {
125  $pages[$idx]["user_sort"] = ilUserUtil::getNamePresentation($pages[$idx]["user"], false, false);
126  }
127  }
128 
129  $this->setData($pages);
130  }
131 
132  function numericOrdering($a_field)
133  {
134  if ($a_field == "cnt")
135  {
136  return true;
137  }
138  return false;
139  }
140 
145  protected function fillRow($a_set)
146  {
147  global $lng, $ilCtrl;
148 
149  if ($this->pg_list_mode == IL_WIKI_NEW_PAGES)
150  {
151  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
152  $this->tpl->setVariable("DATE",
154  }
155  else if ($this->pg_list_mode == IL_WIKI_POPULAR_PAGES)
156  {
157  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
158  $this->tpl->setVariable("HITS", $a_set["cnt"]);
159  }
160  else
161  {
162  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
163  $this->tpl->setVariable("DATE",
165  }
166  $this->tpl->setVariable("HREF_PAGE",
167  ilObjWikiGUI::getGotoLink($_GET["ref_id"], $a_set["title"]));
168 
169  // user name
170  include_once("./Services/User/classes/class.ilUserUtil.php");
171  $this->tpl->setVariable("TXT_USER",
172  ilUserUtil::getNamePresentation($a_set["user"], true, true,
173  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())
174  ));
175  }
176 
177 }
178 ?>