ILIAS  release_8 Revision v8.24
class.ilWikiPagesTableGUI.php
Go to the documentation of this file.
1<?php
2
19const IL_WIKI_ALL_PAGES = "all";
20const IL_WIKI_NEW_PAGES = "new";
21const IL_WIKI_POPULAR_PAGES = "popular";
22const IL_WIKI_WHAT_LINKS_HERE = "what_links";
23const IL_WIKI_ORPHANED_PAGES = "orphaned";
24
31{
32 protected int $requested_ref_id;
33 protected int $page_id = 0;
34 protected int $wiki_id = 0;
35 protected string $pg_list_mode = "";
36
37 public function __construct(
38 object $a_parent_obj,
39 string $a_parent_cmd,
40 int $a_wiki_id,
41 string $a_mode = IL_WIKI_ALL_PAGES,
42 int $a_page_id = 0
43 ) {
44 global $DIC;
45
46 $this->ctrl = $DIC->ctrl();
47 $this->lng = $DIC->language();
48 $ilCtrl = $DIC->ctrl();
49 $lng = $DIC->language();
50
51 $this->requested_ref_id = $DIC
52 ->wiki()
53 ->internal()
54 ->gui()
55 ->editing()
56 ->request()
57 ->getRefId();
58
59 parent::__construct($a_parent_obj, $a_parent_cmd);
60 $this->pg_list_mode = $a_mode;
61 $this->wiki_id = $a_wiki_id;
62 $this->page_id = $a_page_id;
63
64 switch ($this->pg_list_mode) {
66 $this->addColumn($lng->txt("created"), "created", "33%");
67 $this->addColumn($lng->txt("wiki_page"), "title", "33%");
68 $this->addColumn($lng->txt("wiki_created_by"), "user_sort", "34%");
69 $this->setRowTemplate(
70 "tpl.table_row_wiki_new_page.html",
71 "Modules/Wiki"
72 );
73 break;
74
76 $this->addColumn($lng->txt("wiki_page"), "title", "50%");
77 $this->addColumn($lng->txt("wiki_page_hits"), "cnt", "50%");
78 $this->setRowTemplate(
79 "tpl.table_row_wiki_popular_page.html",
80 "Modules/Wiki"
81 );
82 break;
83
85 $this->addColumn($lng->txt("wiki_page"), "title", "100%");
86 $this->setRowTemplate(
87 "tpl.table_row_wiki_orphaned_page.html",
88 "Modules/Wiki"
89 );
90 break;
91
92 default:
93 $this->addColumn($lng->txt("wiki_page"), "title", "33%");
94 $this->addColumn($lng->txt("wiki_last_changed"), "date", "33%");
95 $this->addColumn($lng->txt("wiki_last_changed_by"), "user_sort", "34%");
96 $this->setRowTemplate(
97 "tpl.table_row_wiki_page.html",
98 "Modules/Wiki"
99 );
100 break;
101 }
102 $this->setEnableHeader(true);
103 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
104 $this->getPages();
105
106 $this->setShowRowsSelector(true);
107
108 switch ($this->pg_list_mode) {
110 $this->setTitle(
111 sprintf(
112 $lng->txt("wiki_what_links_to_page"),
113 ilWikiPage::lookupTitle($this->page_id)
114 )
115 );
116 break;
117
118 default:
119 $this->setTitle($lng->txt("wiki_" . $a_mode . "_pages"));
120 break;
121 }
122 }
123
124 public function getPages(): void
125 {
126 $pages = array();
127 $this->setDefaultOrderField("title");
128
129 switch ($this->pg_list_mode) {
131 $pages = ilWikiPage::getLinksToPage($this->wiki_id, $this->page_id);
132 break;
133
135 $pages = ilWikiPage::getAllWikiPages($this->wiki_id);
136 break;
137
139 $this->setDefaultOrderField("created");
140 $this->setDefaultOrderDirection("desc");
141 $pages = ilWikiPage::getNewWikiPages($this->wiki_id);
142 break;
143
145 $this->setDefaultOrderField("cnt");
146 $this->setDefaultOrderDirection("desc");
147 $pages = ilWikiPage::getPopularPages($this->wiki_id);
148 break;
149
151 $pages = ilWikiPage::getOrphanedPages($this->wiki_id);
152 break;
153 }
154
155 if ($pages) {
156 // enable sorting
157 foreach (array_keys($pages) as $idx) {
158 if (isset($pages[$idx]["user"])) {
159 $pages[$idx]["user_sort"] = ilUserUtil::getNamePresentation($pages[$idx]["user"], false, false);
160 }
161 }
162 }
163
164 $this->setData($pages);
165 }
166
167 public function numericOrdering(string $a_field): bool
168 {
169 if ($a_field === "cnt") {
170 return true;
171 }
172 return false;
173 }
174
175 protected function fillRow(array $a_set): void
176 {
177 $ilCtrl = $this->ctrl;
178
179 if ($this->pg_list_mode === IL_WIKI_NEW_PAGES) {
180 $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
181 $this->tpl->setVariable(
182 "DATE",
184 );
185 } elseif ($this->pg_list_mode === IL_WIKI_POPULAR_PAGES) {
186 $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
187 $this->tpl->setVariable("HITS", $a_set["cnt"]);
188 } else {
189 $this->tpl->setVariable("TXT_PAGE_TITLE", $a_set["title"]);
190 $this->tpl->setVariable(
191 "DATE",
193 );
194 }
195 $this->tpl->setVariable(
196 "HREF_PAGE",
198 $this->requested_ref_id,
199 $a_set["title"]
200 )
201 );
202
203 // user name
204 $this->tpl->setVariable(
205 "TXT_USER",
207 $a_set["user"] ?? 0,
208 true,
209 true,
210 $ilCtrl->getLinkTarget($this->getParentObject(), $this->getParentCmd())
211 )
212 );
213 }
214}
const IL_CAL_DATETIME
const IL_WIKI_ALL_PAGES
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_WIKI_POPULAR_PAGES
const IL_WIKI_NEW_PAGES
const IL_WIKI_ORPHANED_PAGES
const IL_WIKI_WHAT_LINKS_HERE
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getGotoLink(int $a_ref_id, string $a_page="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
ilLanguage $lng
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static getAllWikiPages(int $a_wiki_id)
static getLinksToPage(int $a_wiki_id, int $a_page_id)
static getPopularPages(int $a_wiki_id)
static getNewWikiPages(int $a_wiki_id)
static lookupTitle(int $a_page_id)
static getOrphanedPages(int $a_wiki_id)
TableGUI class for wiki pages table.
numericOrdering(string $a_field)
Should this field be sorted numeric?
fillRow(array $a_set)
Standard Version of Fill Row.
__construct(object $a_parent_obj, string $a_parent_cmd, int $a_wiki_id, string $a_mode=IL_WIKI_ALL_PAGES, int $a_page_id=0)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc