ILIAS  Release_3_10_x_branch Revision 61812
 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 
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  if (ilObject::_exists($a_set["user"]))
170  {
171  // user name
172  $user = ilObjUser::_lookupName($a_set["user"]);
173  $login = ilObjUser::_lookupLogin($a_set["user"]);
174  $this->tpl->setVariable("TXT_LINKED_USER",
175  $user["lastname"].", ".$user["firstname"]." [".$login."]");
176 
177  // profile link
178  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "user", $a_set["user"]);
179  $ilCtrl->setParameterByClass("ilpublicuserprofilegui", "back_url",
180  rawurlencode($ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())));
181  $this->tpl->setVariable("USER_LINK",
182  $ilCtrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML"));
183  $img = ilObjUser::_getPersonalPicturePath($a_set["user"], "xxsmall");
184  $this->tpl->setVariable("IMG_USER", $img);
185  }
186 
187  }
188 
189 }
190 ?>