ILIAS  Release_4_0_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  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Table/classes/class.ilTable2GUI.php");
25 
26 define ("IL_WIKI_ALL_PAGES", "all");
27 define ("IL_WIKI_NEW_PAGES", "new");
28 define ("IL_WIKI_POPULAR_PAGES", "popular");
29 define ("IL_WIKI_WHAT_LINKS_HERE", "what_links");
30 define ("IL_WIKI_ORPHANED_PAGES", "orphaned");
31 
41 {
42 
43  function ilWikiPagesTableGUI($a_parent_obj, $a_parent_cmd = "",
44  $a_wiki_id, $a_mode = IL_WIKI_ALL_PAGES, $a_page_id = 0)
45  {
46  global $ilCtrl, $lng;
47 
48  parent::__construct($a_parent_obj, $a_parent_cmd);
49  $this->pg_list_mode = $a_mode;
50  $this->wiki_id = $a_wiki_id;
51  $this->page_id = $a_page_id;
52 
53  switch($this->pg_list_mode)
54  {
55  case IL_WIKI_NEW_PAGES:
56  $this->addColumn($lng->txt("created"), "", "33%");
57  $this->addColumn($lng->txt("wiki_page"), "", "33%");
58  $this->addColumn($lng->txt("wiki_created_by"), "", "34%");
59  $this->setRowTemplate("tpl.table_row_wiki_new_page.html",
60  "Modules/Wiki");
61  break;
62 
64  $this->addColumn($lng->txt("wiki_page"), "", "50%");
65  $this->addColumn($lng->txt("wiki_page_hits"), "", "50%");
66  $this->setRowTemplate("tpl.table_row_wiki_popular_page.html",
67  "Modules/Wiki");
68  break;
69 
71  $this->addColumn($lng->txt("wiki_page"), "", "100%");
72  $this->setRowTemplate("tpl.table_row_wiki_orphaned_page.html",
73  "Modules/Wiki");
74  break;
75 
76  default:
77  $this->addColumn($lng->txt("wiki_page"), "", "33%");
78  $this->addColumn($lng->txt("wiki_last_changed"), "", "33%");
79  $this->addColumn($lng->txt("wiki_last_changed_by"), "", "34%");
80  $this->setRowTemplate("tpl.table_row_wiki_page.html",
81  "Modules/Wiki");
82  break;
83  }
84  $this->setEnableHeader(true);
85  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
86  $this->getPages();
87 
88  switch($this->pg_list_mode)
89  {
91  $this->setTitle(sprintf($lng->txt("wiki_what_links_to_page"),
92  ilWikiPage::lookupTitle($this->page_id)));
93  break;
94 
95  default:
96  $this->setTitle($lng->txt("wiki_".$a_mode."_pages"));
97  break;
98  }
99  }
100 
104  function getPages()
105  {
106  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
107 
108  $pages = array();
109  $this->setDefaultOrderField("title");
110 
111  switch ($this->pg_list_mode)
112  {
114  $pages = ilWikiPage::getLinksToPage($this->wiki_id, $this->page_id);
115  break;
116 
117  case IL_WIKI_ALL_PAGES:
118  $pages = ilWikiPage::getAllPages($this->wiki_id);
119  break;
120 
121  case IL_WIKI_NEW_PAGES:
122  $this->setDefaultOrderField("created");
123  $this->setDefaultOrderDirection("desc");
124  $pages = ilWikiPage::getNewPages($this->wiki_id);
125  break;
126 
128  $this->setDefaultOrderField("cnt");
129  $this->setDefaultOrderDirection("desc");
130  $pages = ilWikiPage::getPopularPages($this->wiki_id);
131  break;
132 
134  $pages = ilWikiPage::getOrphanedPages($this->wiki_id);
135  break;
136  }
137 
138  $this->setData($pages);
139  }
140 
141  function numericOrdering($a_field)
142  {
143  if ($a_field == "cnt")
144  {
145  return true;
146  }
147  return false;
148  }
149 
154  protected function fillRow($a_set)
155  {
156  global $lng, $ilCtrl;
157 
158  if ($this->pg_list_mode == IL_WIKI_NEW_PAGES)
159  {
160  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
161  $this->tpl->setVariable("DATE",
163  }
164  else if ($this->pg_list_mode == IL_WIKI_POPULAR_PAGES)
165  {
166  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
167  $this->tpl->setVariable("HITS", $a_set["cnt"]);
168  }
169  else
170  {
171  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
172  $this->tpl->setVariable("DATE",
174  }
175  $this->tpl->setVariable("HREF_PAGE",
176  ilObjWikiGUI::getGotoLink($_GET["ref_id"], $a_set["title"]));
177 
178  // user name
179  include_once("./Services/User/classes/class.ilUserUtil.php");
180  $this->tpl->setVariable("TXT_USER",
181  ilUserUtil::getNamePresentation($a_set["user"], true, true,
182  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())
183  ));
184  }
185 
186 }
187 ?>