ILIAS  release_8 Revision v8.24
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

EditingGUIRequest $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 36 of file class.ilWikiStatGUI.php.

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

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 56 of file class.ilWikiStatGUI.php.

56 : void
57 {
58 $ilCtrl = $this->ctrl;
59
60 $next_class = $ilCtrl->getNextClass($this);
61 $cmd = $ilCtrl->getCmd("view");
62
63 switch ($next_class) {
64 default:
65 $this->$cmd();
66 break;
67 }
68 }
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 146 of file class.ilWikiStatGUI.php.

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

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 242 of file class.ilWikiStatGUI.php.

247 : array {
248 $data = array();
249
250 $raw = $this->page_id
251 ? ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $a_figure, $a_from, $a_to)
252 : ilWikiStat::getFigureData($this->wiki_id, $a_figure, $a_from, $a_to);
253
254 $parts = explode("-", $a_from);
255 for ($loop = 0; $loop <= ($a_scope * 31); $loop++) {
256 $current_day = date("Y-m-d", mktime(0, 0, 1, $parts[1], $parts[2] + $loop, $parts[0]));
257 if ($current_day <= $a_to) {
258 $data[$current_day] = (float) ($raw[$current_day] ?? 0);
259 }
260 }
261
262 return $data;
263 }
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:64

◆ getListData()

ilWikiStatGUI::getListData ( )
protected

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

265 : array
266 {
267 $data = array();
268
269 $today = date("Y-m-d");
270 $yesterday = date("Y-m-d", strtotime("yesterday"));
271
272 $all = $this->page_id
274 : ilWikiStat::getFigureOptions();
275 foreach ($all as $figure => $title) {
276 if ($this->page_id) {
277 $tmp = ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $figure, $yesterday, $today);
278 } else {
279 $tmp = ilWikiStat::getFigureData($this->wiki_id, $figure, $yesterday, $today);
280 }
281 $data[$title] = array(
282 "yesterday" => (float) ($tmp[$yesterday] ?? 0),
283 "today" => (float) ($tmp[$today] ?? 0)
284 );
285 }
286
287 return $data;
288 }
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 190 of file class.ilWikiStatGUI.php.

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

◆ renderGraph()

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

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

293 : string {
294 $scope = ceil(count($a_data) / 31);
295
297 $chart->setSize("100%", "400");
298 $chart->setColors(array("#C0E0FF"));
299
300 $legend = new ilChartLegend();
301 $chart->setLegend($legend);
302
303 // lines vs. bars
304 if (in_array($a_figure, array(
305 // wiki
318 // page
324 ), true)) {
325 $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
326 $series->setLineSteps(true);
327 $series->setFill(true, "#E0F0FF");
328 } else {
329 $series = $chart->getDataInstance(ilChartGrid::DATA_BARS);
330 $series->setBarOptions(round(10 / ($scope * 2)) / 10);
331 }
332 $series->setLabel(ilWikiStat::getFigureTitle($a_figure));
333
334 $labels = array();
335 $x = 0;
336 foreach ($a_data as $date => $value) {
337 $series->addPoint($x, $value);
338
339 $day = (int) substr($date, 8, 2);
340
341 // match scale to scope
342 if ($scope == 1) {
343 // daily
344 $labels[$x] = substr($date, 8, 2);
345 } elseif ($scope == 2) {
346 // weekly
347 if (!($x % 7)) {
348 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
349 }
350 } elseif ($day === 1 || $day === 15 || $x === count($a_data) - 1) {
351 // 1st/15th
352 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
353 }
354
355 $x++;
356 }
357
358 $chart->addData($series);
359 $chart->setTicks($labels, null, true);
360
361 // int vs. float (averages)
362 if (in_array($a_figure, array(
363 // wiki
376 // page
386 ), true)) {
387 $chart->setYAxisToInteger(true);
388 }
389
390 return $chart->getHTML();
391 }
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:53

◆ view()

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

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

197 : void {
200
201 $params = $this->viewToolbar($a_is_initial);
202 if (is_array($params)) {
203 // data
204
205 $tfr = explode("-", (string) $params["month"]);
206 $day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1] - ($params["scope"] - 1), 1, $tfr[0]));
207 $day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1] + 1, 0, $tfr[0]));
208 unset($tfr);
209
210 $chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
211 $list_data = $this->getListData();
212
213
214 // render
215
216 $vtpl = new ilTemplate("tpl.wiki_stat_list.html", true, true, "Modules/Wiki");
217
218 $chart_panel = ilPanelGUI::getInstance();
219
220 $vtpl->setVariable("CHART", $this->renderGraph($params["figure"], $chart_data));
221
222 $vtpl->setCurrentBlock("row_bl");
223 foreach ($list_data as $figure => $values) {
224 $vtpl->setVariable("FIGURE", $figure);
225 $vtpl->setVariable("YESTERDAY_VALUE", $values["yesterday"]);
226 $vtpl->setVariable("TODAY_VALUE", $values["today"]);
227 $vtpl->parseCurrentBlock();
228 }
229
230 $vtpl->setVariable("FIGURE_HEAD", $lng->txt("wiki_stat_figure"));
231 $vtpl->setVariable("YESTERDAY_HEAD", $lng->txt("yesterday"));
232 $vtpl->setVariable("TODAY_HEAD", $lng->txt("today"));
233
234 $chart_panel->setHeading($lng->txt("statistics"));
235 $chart_panel->setBody($vtpl->get());
236 $chart_panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_SUBHEADING);
237
238 $tpl->setContent($chart_panel->getHTML());
239 }
240 }
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...
const HEADING_STYLE_SUBHEADING
static getInstance()
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 70 of file class.ilWikiStatGUI.php.

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

Referenced by executeCommand().

◆ $lng

ilLanguage ilWikiStatGUI::$lng
protected

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

◆ $page_id

int ilWikiStatGUI::$page_id
protected

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

◆ $request

EditingGUIRequest ilWikiStatGUI::$request
protected

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

◆ $toolbar

ilToolbarGUI ilWikiStatGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilWikiStatGUI::$tpl
protected

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

◆ $wiki_id

int ilWikiStatGUI::$wiki_id
protected

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


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