ILIAS  Release_4_4_x_branch Revision 61816
 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  $this->setShowRowsSelector(true);
70 
71  switch($this->pg_list_mode)
72  {
74  $this->setTitle(sprintf($lng->txt("wiki_what_links_to_page"),
75  ilWikiPage::lookupTitle($this->page_id)));
76  break;
77 
78  default:
79  $this->setTitle($lng->txt("wiki_".$a_mode."_pages"));
80  break;
81  }
82  }
83 
87  function getPages()
88  {
89  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
90 
91  $pages = array();
92  $this->setDefaultOrderField("title");
93 
94  switch ($this->pg_list_mode)
95  {
97  $pages = ilWikiPage::getLinksToPage($this->wiki_id, $this->page_id);
98  break;
99 
100  case IL_WIKI_ALL_PAGES:
101  $pages = ilWikiPage::getAllPages($this->wiki_id);
102  break;
103 
104  case IL_WIKI_NEW_PAGES:
105  $this->setDefaultOrderField("created");
106  $this->setDefaultOrderDirection("desc");
107  $pages = ilWikiPage::getNewPages($this->wiki_id);
108  break;
109 
111  $this->setDefaultOrderField("cnt");
112  $this->setDefaultOrderDirection("desc");
113  $pages = ilWikiPage::getPopularPages($this->wiki_id);
114  break;
115 
117  $pages = ilWikiPage::getOrphanedPages($this->wiki_id);
118  break;
119  }
120 
121  if($pages)
122  {
123  // enable sorting
124  include_once("./Services/User/classes/class.ilUserUtil.php");
125  foreach(array_keys($pages) as $idx)
126  {
127  $pages[$idx]["user_sort"] = ilUserUtil::getNamePresentation($pages[$idx]["user"], false, false);
128  }
129  }
130 
131  $this->setData($pages);
132  }
133 
134  function numericOrdering($a_field)
135  {
136  if ($a_field == "cnt")
137  {
138  return true;
139  }
140  return false;
141  }
142 
147  protected function fillRow($a_set)
148  {
149  global $lng, $ilCtrl;
150 
151  if ($this->pg_list_mode == IL_WIKI_NEW_PAGES)
152  {
153  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
154  $this->tpl->setVariable("DATE",
156  }
157  else if ($this->pg_list_mode == IL_WIKI_POPULAR_PAGES)
158  {
159  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
160  $this->tpl->setVariable("HITS", $a_set["cnt"]);
161  }
162  else
163  {
164  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
165  $this->tpl->setVariable("DATE",
167  }
168  $this->tpl->setVariable("HREF_PAGE",
169  ilObjWikiGUI::getGotoLink($_GET["ref_id"], $a_set["title"]));
170 
171  // user name
172  include_once("./Services/User/classes/class.ilUserUtil.php");
173  $this->tpl->setVariable("TXT_USER",
174  ilUserUtil::getNamePresentation($a_set["user"], true, true,
175  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())
176  ));
177  }
178 
179 }
180 ?>