ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilWikiStatGUI Class Reference

Wiki statistics GUI class. More...

+ Collaboration diagram for ilWikiStatGUI:

Public Member Functions

 __construct (int $a_wiki_id, ?int $a_page_id=null)
 
 executeCommand ()
 

Protected Member Functions

 viewToolbar (bool $a_is_initial=false)
 
 export ()
 
 initial ()
 
 view (bool $a_is_initial=false)
 
 getChartData (int $a_figure, int $a_scope, string $a_from, string $a_to)
 
 getListData ()
 
 renderGraph (int $a_figure, array $a_data)
 

Protected Attributes

ILIAS Wiki InternalGUIService $gui
 
WikiGUIRequest $request
 
ilCtrl $ctrl
 
ilToolbarGUI $toolbar
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
int $wiki_id
 
int $page_id
 

Detailed Description

Wiki statistics GUI class.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 26 of file class.ilWikiStatGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilWikiStatGUI::__construct ( int  $a_wiki_id,
?int  $a_page_id = null 
)

Definition at line 37 of file class.ilWikiStatGUI.php.

40 {
41 global $DIC;
42
43 $this->ctrl = $DIC->ctrl();
44 $this->toolbar = $DIC->toolbar();
45 $this->lng = $DIC->language();
46 $this->tpl = $DIC["tpl"];
47 $this->wiki_id = $a_wiki_id;
48 $this->page_id = (int) $a_page_id;
49 $this->request = $DIC
50 ->wiki()
51 ->internal()
52 ->gui()
53 ->request();
54 $this->gui = $DIC->wiki()->internal()->gui();
55 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

ilWikiStatGUI::executeCommand ( )

Definition at line 57 of file class.ilWikiStatGUI.php.

57 : void
58 {
59 $ilCtrl = $this->ctrl;
60
61 $next_class = $ilCtrl->getNextClass($this);
62 $cmd = $ilCtrl->getCmd("view");
63
64 switch ($next_class) {
65 default:
66 $this->$cmd();
67 break;
68 }
69 }
getNextClass($a_gui_class=null)
@inheritDoc

References $ctrl, and ilCtrl\getNextClass().

+ Here is the call graph for this function:

◆ export()

ilWikiStatGUI::export ( )
protected

Definition at line 147 of file class.ilWikiStatGUI.php.

147 : void
148 {
149 $ilCtrl = $this->ctrl;
150
151 $params = $this->viewToolbar();
152 if ($params) {
153 // data
154
155 $tfr = explode("-", (string) $params["month"]);
156 $day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1] - ($params["scope"] - 1), 1, $tfr[0]));
157 $day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1] + 1, 0, $tfr[0]));
158 unset($tfr);
159
160 $chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
161
162
163 // excel
164
166 new ilDate($day_from, IL_CAL_DATE),
167 new ilDate($day_to, IL_CAL_DATE)
168 );
169
170 $filename = ilObject::_lookupTitle($this->wiki_id);
171 if ($this->page_id) {
172 $filename .= " - " . ilWikiPage::lookupTitle($this->page_id);
173 }
174 $filename .= " - " . ilWikiStat::getFigureTitle($params["figure"]) . " - " . $period;
175
176 $excel = new ilExcel();
177 $excel->addSheet($this->lng->txt("statistics"));
178
179 $row = 1;
180 foreach ($chart_data as $day => $value) {
181 $excel->setCell($row, 0, $day);
182 $excel->setCell($row++, 1, $value);
183 }
184
185 $excel->sendToClient($filename);
186 }
187
188 $ilCtrl->redirect($this, "view");
189 }
$filename
Definition: buildRTE.php:78
const IL_CAL_DATE
static formatPeriod(ilDateTime $start, ilDateTime $end, bool $a_skip_starting_day=false, ?ilObjUser $user=null)
Format a period of two dates Shows: 14.
Class for single dates.
static _lookupTitle(int $obj_id)
static lookupTitle(int $a_page_id, string $lang="-")
viewToolbar(bool $a_is_initial=false)
getChartData(int $a_figure, int $a_scope, string $a_from, string $a_to)
static getFigureTitle(int $a_figure)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $filename, $params, ilObject\_lookupTitle(), ilDatePresentation\formatPeriod(), ilWikiStat\getFigureTitle(), IL_CAL_DATE, ILIAS\Repository\lng(), and ilWikiPage\lookupTitle().

+ Here is the call graph for this function:

◆ getChartData()

ilWikiStatGUI::getChartData ( int  $a_figure,
int  $a_scope,
string  $a_from,
string  $a_to 
)
protected

Definition at line 243 of file class.ilWikiStatGUI.php.

248 : array {
249 $data = array();
250
251 $raw = $this->page_id
252 ? ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $a_figure, $a_from, $a_to)
253 : ilWikiStat::getFigureData($this->wiki_id, $a_figure, $a_from, $a_to);
254
255 $parts = explode("-", $a_from);
256 for ($loop = 0; $loop <= ($a_scope * 31); $loop++) {
257 $current_day = date("Y-m-d", mktime(0, 0, 1, $parts[1], $parts[2] + $loop, $parts[0]));
258 if ($current_day <= $a_to) {
259 $data[$current_day] = (float) ($raw[$current_day] ?? 0);
260 }
261 }
262
263 return $data;
264 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getFigureDataPage(int $a_wiki_id, int $a_page_id, int $a_figure, string $a_from, string $a_to)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61

◆ getListData()

ilWikiStatGUI::getListData ( )
protected

Definition at line 266 of file class.ilWikiStatGUI.php.

266 : array
267 {
268 $data = array();
269
270 $today = date("Y-m-d");
271 $yesterday = date("Y-m-d", strtotime("yesterday"));
272
273 $all = $this->page_id
275 : ilWikiStat::getFigureOptions();
276 foreach ($all as $figure => $title) {
277 if ($this->page_id) {
278 $tmp = ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $figure, $yesterday, $today);
279 } else {
280 $tmp = ilWikiStat::getFigureData($this->wiki_id, $figure, $yesterday, $today);
281 }
282 $data[$title] = array(
283 "yesterday" => (float) ($tmp[$yesterday] ?? 0),
284 "today" => (float) ($tmp[$today] ?? 0)
285 );
286 }
287
288 return $data;
289 }
static getFigureOptionsPage()
static getFigureData(int $a_wiki_id, int $a_figure, string $a_from, string $a_to)

References $data, ilWikiStat\getFigureData(), ilWikiStat\getFigureDataPage(), ilWikiStat\getFigureOptions(), and ilWikiStat\getFigureOptionsPage().

+ Here is the call graph for this function:

◆ initial()

ilWikiStatGUI::initial ( )
protected

Definition at line 191 of file class.ilWikiStatGUI.php.

191 : void
192 {
193 $this->view(true);
194 }
view(bool $a_is_initial=false)

◆ renderGraph()

ilWikiStatGUI::renderGraph ( int  $a_figure,
array  $a_data 
)
protected

Definition at line 291 of file class.ilWikiStatGUI.php.

294 : string {
295 $scope = ceil(count($a_data) / 31);
296
298 $chart->setSize("100%", "400");
299 $chart->setColors(array("#C0E0FF"));
300
301 $legend = new ilChartLegend();
302 $chart->setLegend($legend);
303
304 // lines vs. bars
305 if (in_array($a_figure, array(
306 // wiki
319 // page
325 ), true)) {
326 $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
327 $series->setLineSteps(true);
328 $series->setFill(true, "#E0F0FF");
329 } else {
330 $series = $chart->getDataInstance(ilChartGrid::DATA_BARS);
331 $series->setBarOptions(round(10 / ($scope * 2)) / 10);
332 }
333 $series->setLabel(ilWikiStat::getFigureTitle($a_figure));
334
335 $labels = array();
336 $x = 0;
337 foreach ($a_data as $date => $value) {
338 $series->addPoint($x, $value);
339
340 $day = (int) substr($date, 8, 2);
341
342 // match scale to scope
343 if ($scope == 1) {
344 // daily
345 $labels[$x] = substr($date, 8, 2);
346 } elseif ($scope == 2) {
347 // weekly
348 if (!($x % 7)) {
349 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
350 }
351 } elseif ($day === 1 || $day === 15 || $x === count($a_data) - 1) {
352 // 1st/15th
353 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
354 }
355
356 $x++;
357 }
358
359 $chart->addData($series);
360 $chart->setTicks($labels, null, true);
361
362 // int vs. float (averages)
363 if (in_array($a_figure, array(
364 // wiki
377 // page
387 ), true)) {
388 $chart->setYAxisToInteger(true);
389 }
390
391 return $chart->getHTML();
392 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByType(int $a_type, string $a_id)
const TYPE_GRID
const KEY_FIGURE_WIKI_PAGE_READ
const KEY_FIGURE_WIKI_NUM_RATING
const KEY_FIGURE_WIKI_DELETED_PAGES
const KEY_FIGURE_WIKI_WORDS
const KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS
const KEY_FIGURE_WIKI_INTERNAL_LINKS
const KEY_FIGURE_WIKI_PAGE_RATINGS
const KEY_FIGURE_WIKI_WORDS_AVG
const KEY_FIGURE_WIKI_READ_PAGES
const KEY_FIGURE_WIKI_NEW_PAGES
const KEY_FIGURE_WIKI_EDIT_PAGES
const KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG
const KEY_FIGURE_WIKI_PAGE_CHANGES
const KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG
const KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS
const KEY_FIGURE_WIKI_FOOTNOTES
const KEY_FIGURE_WIKI_PAGE_USER_EDIT
const KEY_FIGURE_WIKI_FOOTNOTES_AVG
const KEY_FIGURE_WIKI_EXTERNAL_LINKS
const KEY_FIGURE_WIKI_PAGE_FOOTNOTES
const KEY_FIGURE_WIKI_CHARS_AVG
const KEY_FIGURE_WIKI_PAGE_CHARS
const KEY_FIGURE_WIKI_USER_EDIT_PAGES
const KEY_FIGURE_WIKI_NUM_PAGES
const KEY_FIGURE_WIKI_CHARS
const KEY_FIGURE_WIKI_PAGE_WORDS
const KEY_FIGURE_WIKI_RATING_AVG
$scope
Definition: ltiregstart.php:51

◆ view()

ilWikiStatGUI::view ( bool  $a_is_initial = false)
protected

Definition at line 196 of file class.ilWikiStatGUI.php.

198 : void {
201
202 $params = $this->viewToolbar($a_is_initial);
203 if (is_array($params)) {
204 // data
205
206 $tfr = explode("-", (string) $params["month"]);
207 $day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1] - ($params["scope"] - 1), 1, $tfr[0]));
208 $day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1] + 1, 0, $tfr[0]));
209 unset($tfr);
210
211 $chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
212 $list_data = $this->getListData();
213
214
215 // render
216
217 $vtpl = new ilTemplate("tpl.wiki_stat_list.html", true, true, "components/ILIAS/Wiki");
218
219 $vtpl->setVariable("CHART", $this->renderGraph($params["figure"], $chart_data));
220
221 $vtpl->setCurrentBlock("row_bl");
222 foreach ($list_data as $figure => $values) {
223 $vtpl->setVariable("FIGURE", $figure);
224 $vtpl->setVariable("YESTERDAY_VALUE", $values["yesterday"]);
225 $vtpl->setVariable("TODAY_VALUE", $values["today"]);
226 $vtpl->parseCurrentBlock();
227 }
228
229 $vtpl->setVariable("FIGURE_HEAD", $lng->txt("wiki_stat_figure"));
230 $vtpl->setVariable("YESTERDAY_HEAD", $lng->txt("yesterday"));
231 $vtpl->setVariable("TODAY_HEAD", $lng->txt("today"));
232
233 $f = $this->gui->ui()->factory();
234 $r = $this->gui->ui()->renderer();
235 $p = $f->panel()->standard(
236 $lng->txt("statistics"),
237 $f->legacy()->content($vtpl->get())
238 );
239 $tpl->setContent($r->render($p));
240 }
241 }
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...
special template class to simplify handling of ITX/PEAR
ilGlobalTemplateInterface $tpl
renderGraph(int $a_figure, array $a_data)
setContent(string $a_html)
Sets content for standard template.

◆ viewToolbar()

ilWikiStatGUI::viewToolbar ( bool  $a_is_initial = false)
protected

Definition at line 71 of file class.ilWikiStatGUI.php.

73 : ?array {
74 $ilToolbar = $this->toolbar;
76 $ilCtrl = $this->ctrl;
77
78 $current_figure = $this->request->getStatFig();
79 $current_time_frame = $this->request->getStatTfr();
80 $current_scope = $this->request->getStatScp();
81
82 $view = new ilSelectInputGUI($lng->txt("wiki_stat_figure"), "fig");
83 $view->setOptions($this->page_id
86 if ($current_figure) {
87 $view->setValue($current_figure);
88 } elseif ($a_is_initial) {
89 // default
90 $current_figure = $this->page_id
93 }
94 $ilToolbar->addInputItem($view, true);
95
96 $options = array();
97 $lng->loadLanguageModule("dateplaner");
98 foreach (ilWikiStat::getAvailableMonths($this->wiki_id) as $month) {
99 $parts = explode("-", $month);
100 $options[$month] = ilCalendarUtil::_numericMonthToString((int) $parts[1]) .
101 " " . $parts[0];
102 }
103 krsort($options);
104
105 $tframe = new ilSelectInputGUI($lng->txt("month"), "tfr");
106 $tframe->setOptions($options);
107 if ($current_time_frame) {
108 $tframe->setValue($current_time_frame);
109 } elseif ($a_is_initial) {
110 $opt = array_keys($options);
111 $current_time_frame = array_shift($opt); // default
112 }
113 $ilToolbar->addInputItem($tframe, true);
114
115 $scope = new ilSelectInputGUI($lng->txt("wiki_stat_scope"), "scp");
116 $scope->setOptions(array(
117 1 => "1 " . $lng->txt("month"),
118 2 => "2 " . $lng->txt("months"),
119 3 => "3 " . $lng->txt("months"),
120 4 => "4 " . $lng->txt("months"),
121 5 => "5 " . $lng->txt("months"),
122 6 => "6 " . $lng->txt("months")
123 ));
124 if ($current_scope) {
125 $scope->setValue($current_scope);
126 } elseif ($a_is_initial) {
127 $current_scope = 1; // default
128 }
129 $ilToolbar->addInputItem($scope, true);
130
131 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "view"));
132 $ilToolbar->addFormButton($lng->txt("show"), "view");
133
134 if ($current_figure && $current_time_frame && $current_scope) {
135 $ilToolbar->addSeparator();
136 $ilToolbar->addFormButton($lng->txt("export"), "export");
137
138 return array(
139 "figure" => $current_figure,
140 "month" => $current_time_frame,
141 "scope" => $current_scope
142 );
143 }
144 return null;
145 }
static _numericMonthToString(int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
numeric month to string
loadLanguageModule(string $a_module)
Load language module.
This class represents a selection list property in a property form.
ilToolbarGUI $toolbar
static getFigureOptions()
static getAvailableMonths(int $a_wiki_id)

Field Documentation

◆ $ctrl

ilCtrl ilWikiStatGUI::$ctrl
protected

Definition at line 30 of file class.ilWikiStatGUI.php.

Referenced by executeCommand().

◆ $gui

ILIAS Wiki InternalGUIService ilWikiStatGUI::$gui
protected

Definition at line 28 of file class.ilWikiStatGUI.php.

◆ $lng

ilLanguage ilWikiStatGUI::$lng
protected

Definition at line 32 of file class.ilWikiStatGUI.php.

◆ $page_id

int ilWikiStatGUI::$page_id
protected

Definition at line 35 of file class.ilWikiStatGUI.php.

◆ $request

WikiGUIRequest ilWikiStatGUI::$request
protected

Definition at line 29 of file class.ilWikiStatGUI.php.

◆ $toolbar

ilToolbarGUI ilWikiStatGUI::$toolbar
protected

Definition at line 31 of file class.ilWikiStatGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilWikiStatGUI::$tpl
protected

Definition at line 33 of file class.ilWikiStatGUI.php.

◆ $wiki_id

int ilWikiStatGUI::$wiki_id
protected

Definition at line 34 of file class.ilWikiStatGUI.php.


The documentation for this class was generated from the following file: