ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  public function __construct(
24  $a_parent_obj,
25  $a_parent_cmd = "",
26  $a_wiki_id,
27  $a_mode = IL_WIKI_ALL_PAGES,
28  $a_page_id = 0
29  ) {
30  global $DIC;
31 
32  $this->ctrl = $DIC->ctrl();
33  $this->lng = $DIC->language();
34  $ilCtrl = $DIC->ctrl();
35  $lng = $DIC->language();
36 
37  parent::__construct($a_parent_obj, $a_parent_cmd);
38  $this->pg_list_mode = $a_mode;
39  $this->wiki_id = $a_wiki_id;
40  $this->page_id = $a_page_id;
41 
42  switch ($this->pg_list_mode) {
43  case IL_WIKI_NEW_PAGES:
44  $this->addColumn($lng->txt("created"), "created", "33%");
45  $this->addColumn($lng->txt("wiki_page"), "title", "33%");
46  $this->addColumn($lng->txt("wiki_created_by"), "user_sort", "34%");
47  $this->setRowTemplate(
48  "tpl.table_row_wiki_new_page.html",
49  "Modules/Wiki"
50  );
51  break;
52 
54  $this->addColumn($lng->txt("wiki_page"), "title", "50%");
55  $this->addColumn($lng->txt("wiki_page_hits"), "cnt", "50%");
56  $this->setRowTemplate(
57  "tpl.table_row_wiki_popular_page.html",
58  "Modules/Wiki"
59  );
60  break;
61 
63  $this->addColumn($lng->txt("wiki_page"), "title", "100%");
64  $this->setRowTemplate(
65  "tpl.table_row_wiki_orphaned_page.html",
66  "Modules/Wiki"
67  );
68  break;
69 
70  default:
71  $this->addColumn($lng->txt("wiki_page"), "title", "33%");
72  $this->addColumn($lng->txt("wiki_last_changed"), "date", "33%");
73  $this->addColumn($lng->txt("wiki_last_changed_by"), "user_sort", "34%");
74  $this->setRowTemplate(
75  "tpl.table_row_wiki_page.html",
76  "Modules/Wiki"
77  );
78  break;
79  }
80  $this->setEnableHeader(true);
81  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
82  $this->getPages();
83 
84  $this->setShowRowsSelector(true);
85 
86  switch ($this->pg_list_mode) {
88  $this->setTitle(sprintf(
89  $lng->txt("wiki_what_links_to_page"),
90  ilWikiPage::lookupTitle($this->page_id)
91  ));
92  break;
93 
94  default:
95  $this->setTitle($lng->txt("wiki_" . $a_mode . "_pages"));
96  break;
97  }
98  }
99 
103  public function getPages()
104  {
105  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
106 
107  $pages = array();
108  $this->setDefaultOrderField("title");
109 
110  switch ($this->pg_list_mode) {
112  $pages = ilWikiPage::getLinksToPage($this->wiki_id, $this->page_id);
113  break;
114 
115  case IL_WIKI_ALL_PAGES:
116  $pages = ilWikiPage::getAllWikiPages($this->wiki_id);
117  break;
118 
119  case IL_WIKI_NEW_PAGES:
120  $this->setDefaultOrderField("created");
121  $this->setDefaultOrderDirection("desc");
122  $pages = ilWikiPage::getNewWikiPages($this->wiki_id);
123  break;
124 
126  $this->setDefaultOrderField("cnt");
127  $this->setDefaultOrderDirection("desc");
128  $pages = ilWikiPage::getPopularPages($this->wiki_id);
129  break;
130 
132  $pages = ilWikiPage::getOrphanedPages($this->wiki_id);
133  break;
134  }
135 
136  if ($pages) {
137  // enable sorting
138  include_once("./Services/User/classes/class.ilUserUtil.php");
139  foreach (array_keys($pages) as $idx) {
140  $pages[$idx]["user_sort"] = ilUserUtil::getNamePresentation($pages[$idx]["user"], false, false);
141  }
142  }
143 
144  $this->setData($pages);
145  }
146 
147  public function numericOrdering($a_field)
148  {
149  if ($a_field == "cnt") {
150  return true;
151  }
152  return false;
153  }
154 
159  protected function fillRow($a_set)
160  {
161  $lng = $this->lng;
163 
164  if ($this->pg_list_mode == IL_WIKI_NEW_PAGES) {
165  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
166  $this->tpl->setVariable(
167  "DATE",
169  );
170  } elseif ($this->pg_list_mode == IL_WIKI_POPULAR_PAGES) {
171  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
172  $this->tpl->setVariable("HITS", $a_set["cnt"]);
173  } else {
174  $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
175  $this->tpl->setVariable(
176  "DATE",
178  );
179  }
180  $this->tpl->setVariable(
181  "HREF_PAGE",
182  ilObjWikiGUI::getGotoLink($_GET["ref_id"], $a_set["title"])
183  );
184 
185  // user name
186  include_once("./Services/User/classes/class.ilUserUtil.php");
187  $this->tpl->setVariable(
188  "TXT_USER",
190  $a_set["user"],
191  true,
192  true,
193  $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())
194  )
195  );
196  }
197 }
static getGotoLink($a_ref_id, $a_page="")
Get goto link.
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
const IL_CAL_DATETIME
const IL_WIKI_POPULAR_PAGES
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static getNewWikiPages($a_wiki_id)
Get all pages of wiki.
static getPopularPages($a_wiki_id)
Get popular pages of wiki.
__construct( $a_parent_obj, $a_parent_cmd="", $a_wiki_id, $a_mode=IL_WIKI_ALL_PAGES, $a_page_id=0)
TableGUI class for wiki pages table.
getParentCmd()
Get parent command.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
Date and time handling
getPages()
Get pages for list.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static getAllWikiPages($a_wiki_id)
Get all pages of wiki.
static getOrphanedPages($a_wiki_id)
Get orphaned pages of wiki.
fillRow($a_set)
Standard Version of Fill Row.
const IL_WIKI_WHAT_LINKS_HERE
const IL_WIKI_ALL_PAGES
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
const IL_WIKI_ORPHANED_PAGES
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setEnableHeader($a_enableheader)
Set Enable Header.
static getLinksToPage($a_wiki_id, $a_page_id)
Get links to a page.
const IL_WIKI_NEW_PAGES