ILIAS  release_7 Revision v7.30-3-g800a261c036
ilWikiStatGUI Class Reference

Wiki statistics GUI class. More...

+ Collaboration diagram for ilWikiStatGUI:

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

 $ctrl
 
 $toolbar
 
 $lng
 
 $tpl
 
 $wiki_id
 
 $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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 39 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 = (int) $a_wiki_id;
48 $this->page_id = (int) $a_page_id;
49 }
global $DIC
Definition: goto.php:24

References $DIC.

Member Function Documentation

◆ executeCommand()

ilWikiStatGUI::executeCommand ( )

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

52 {
53 $ilCtrl = $this->ctrl;
54
55 $next_class = $ilCtrl->getNextClass($this);
56 $cmd = $ilCtrl->getCmd("view");
57
58 switch ($next_class) {
59 default:
60 $this->$cmd();
61 break;
62 }
63 }

References $ctrl.

◆ export()

ilWikiStatGUI::export ( )
protected

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

141 {
142 $ilCtrl = $this->ctrl;
143
144 $params = $this->viewToolbar();
145 if ($params) {
146 // data
147
148 $tfr = explode("-", (string) $params["month"]);
149 $day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1] - ($params["scope"] - 1), 1, $tfr[0]));
150 $day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1] + 1, 0, $tfr[0]));
151 unset($tfr);
152
153 $chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
154
155
156 // excel
157
159 new ilDate($day_from, IL_CAL_DATE),
160 new ilDate($day_to, IL_CAL_DATE)
161 );
162
163 $filename = ilObject::_lookupTitle($this->wiki_id);
164 if ($this->page_id) {
165 $filename .= " - " . ilWikiPage::lookupTitle($this->page_id);
166 }
167 $filename .= " - " . ilWikiStat::getFigureTitle($params["figure"]) . " - " . $period;
168
169 include_once "./Services/Excel/classes/class.ilExcel.php";
170 $excel = new ilExcel();
171 $excel->addSheet($this->lng->txt("statistics"));
172
173 $row = 1;
174 foreach ($chart_data as $day => $value) {
175 $excel->setCell($row, 0, $day);
176 $excel->setCell($row++, 1, $value);
177 }
178
179 $excel->sendToClient($filename);
180 }
181
182 $ilCtrl->redirect($this, "view");
183 }
$filename
Definition: buildRTE.php:89
const IL_CAL_DATE
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
Class for single dates.
static _lookupTitle($a_id)
lookup object title
static lookupTitle($a_page_id)
Checks whether a page with given title exists.
getChartData($a_figure, $a_scope, $a_from, $a_to)
viewToolbar($a_is_initial=false)
static getFigureTitle($a_figure)

References $ctrl, $filename, ilObject\_lookupTitle(), ilDatePresentation\formatPeriod(), getChartData(), ilWikiStat\getFigureTitle(), IL_CAL_DATE, ilWikiPage\lookupTitle(), and viewToolbar().

+ Here is the call graph for this function:

◆ getChartData()

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

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

241 {
242 $data = array();
243
244 $raw = $this->page_id
245 ? ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $a_figure, $a_from, $a_to)
246 : ilWikiStat::getFigureData($this->wiki_id, $a_figure, $a_from, $a_to);
247
248 $parts = explode("-", $a_from);
249 for ($loop = 0; $loop <= ($a_scope * 31); $loop++) {
250 $current_day = date("Y-m-d", mktime(0, 0, 1, $parts[1], $parts[2] + $loop, $parts[0]));
251 if ($current_day <= $a_to) {
252 $data[$current_day] = (float) $raw[$current_day];
253 }
254 }
255
256 return $data;
257 }
Wiki statistics class.
static getFigureDataPage($a_wiki_id, $a_page_id, $a_figure, $a_from, $a_to)
$data
Definition: storeScorm.php:23

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

Referenced by export(), and view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getListData()

ilWikiStatGUI::getListData ( )
protected

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

260 {
261 $data = array();
262
263 $today = date("Y-m-d");
264 $yesterday = date("Y-m-d", strtotime("yesterday"));
265
266 $all = $this->page_id
268 : ilWikiStat::getFigureOptions();
269 foreach ($all as $figure => $title) {
270 if ($this->page_id) {
271 $tmp = (array) ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $figure, $yesterday, $today);
272 } else {
273 $tmp = (array) ilWikiStat::getFigureData($this->wiki_id, $figure, $yesterday, $today);
274 }
275 $data[$title] = array(
276 "yesterday" => (float) $tmp[$yesterday],
277 "today" => (float) $tmp[$today]
278 );
279 }
280
281 return $data;
282 }
static getFigureData($a_wiki_id, $a_figure, $a_from, $a_to)
static getFigureOptionsPage()

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

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initial()

ilWikiStatGUI::initial ( )
protected

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

186 {
187 $this->view(true);
188 }
view($a_is_initial=false)

References view().

+ Here is the call graph for this function:

◆ renderGraph()

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

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

285 {
286 $scope = ceil(sizeof($a_data) / 31);
287
288 include_once "Services/Chart/classes/class.ilChartGrid.php";
290 $chart->setSize("100%", 400);
291 $chart->setColors(array("#C0E0FF"));
292
293 $legend = new ilChartLegend();
294 $chart->setLegend($legend);
295
296 // lines vs. bars
297 if (in_array($a_figure, array(
298 // wiki
311 // page
317 ))) {
318 $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
319 $series->setLineSteps(true);
320 $series->setFill(true, "#E0F0FF");
321 } else {
322 $series = $chart->getDataInstance(ilChartGrid::DATA_BARS);
323 $series->setBarOptions(round(10 / ($scope * 2)) / 10);
324 }
325 $series->setLabel(ilWikiStat::getFigureTitle($a_figure));
326
327 $labels = array();
328 $x = 0;
329 foreach ($a_data as $date => $value) {
330 $series->addPoint($x, $value);
331
332 $day = (int) substr($date, 8, 2);
333
334 // match scale to scope
335 if ($scope == 1) {
336 // daily
337 $labels[$x] = substr($date, 8, 2);
338 } elseif ($scope == 2) {
339 // weekly
340 if (!($x % 7)) {
341 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
342 }
343 } else {
344 // 1st/15th
345 if ($day == 1 || $day == 15 || $x == sizeof($a_data) - 1) {
346 $labels[$x] = substr($date, 8, 2) . "." . substr($date, 5, 2) . ".";
347 }
348 }
349
350 $x++;
351 }
352
353 $chart->addData($series);
354 $chart->setTicks($labels, null, true);
355
356 // int vs. float (averages)
357 if (in_array($a_figure, array(
358 // wiki
371 // page
381 ))) {
382 $chart->setYAxisToInteger(true);
383 }
384
385 return $chart->getHTML();
386 }
static getInstanceByType($a_type, $a_id)
Get type instance.
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

References ilChartGrid\DATA_BARS, ilChartGrid\DATA_LINES, ilWikiStat\getFigureTitle(), ilChart\getInstanceByType(), ilWikiStat\KEY_FIGURE_WIKI_CHARS, ilWikiStat\KEY_FIGURE_WIKI_CHARS_AVG, ilWikiStat\KEY_FIGURE_WIKI_DELETED_PAGES, ilWikiStat\KEY_FIGURE_WIKI_EDIT_PAGES, ilWikiStat\KEY_FIGURE_WIKI_EXTERNAL_LINKS, ilWikiStat\KEY_FIGURE_WIKI_EXTERNAL_LINKS_AVG, ilWikiStat\KEY_FIGURE_WIKI_FOOTNOTES, ilWikiStat\KEY_FIGURE_WIKI_FOOTNOTES_AVG, ilWikiStat\KEY_FIGURE_WIKI_INTERNAL_LINKS, ilWikiStat\KEY_FIGURE_WIKI_INTERNAL_LINKS_AVG, ilWikiStat\KEY_FIGURE_WIKI_NEW_PAGES, ilWikiStat\KEY_FIGURE_WIKI_NUM_PAGES, ilWikiStat\KEY_FIGURE_WIKI_NUM_RATING, ilWikiStat\KEY_FIGURE_WIKI_PAGE_CHANGES, ilWikiStat\KEY_FIGURE_WIKI_PAGE_CHARS, ilWikiStat\KEY_FIGURE_WIKI_PAGE_EXTERNAL_LINKS, ilWikiStat\KEY_FIGURE_WIKI_PAGE_FOOTNOTES, ilWikiStat\KEY_FIGURE_WIKI_PAGE_INTERNAL_LINKS, ilWikiStat\KEY_FIGURE_WIKI_PAGE_RATINGS, ilWikiStat\KEY_FIGURE_WIKI_PAGE_READ, ilWikiStat\KEY_FIGURE_WIKI_PAGE_USER_EDIT, ilWikiStat\KEY_FIGURE_WIKI_PAGE_WORDS, ilWikiStat\KEY_FIGURE_WIKI_RATING_AVG, ilWikiStat\KEY_FIGURE_WIKI_READ_PAGES, ilWikiStat\KEY_FIGURE_WIKI_USER_EDIT_PAGES, ilWikiStat\KEY_FIGURE_WIKI_WORDS, ilWikiStat\KEY_FIGURE_WIKI_WORDS_AVG, and ilChart\TYPE_GRID.

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ view()

ilWikiStatGUI::view (   $a_is_initial = false)
protected

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

191 {
194
195 $params = $this->viewToolbar($a_is_initial);
196 if (is_array($params)) {
197 // data
198
199 $tfr = explode("-", (string) $params["month"]);
200 $day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1] - ($params["scope"] - 1), 1, $tfr[0]));
201 $day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1] + 1, 0, $tfr[0]));
202 unset($tfr);
203
204 $chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
205 $list_data = $this->getListData();
206
207
208 // render
209
210 $vtpl = new ilTemplate("tpl.wiki_stat_list.html", true, true, "Modules/Wiki");
211
212 include_once("./Services/UIComponent/Panel/classes/class.ilPanelGUI.php");
213 $chart_panel = ilPanelGUI::getInstance();
214
215 $vtpl->setVariable("CHART", $this->renderGraph($params["figure"], $chart_data));
216
217 $vtpl->setCurrentBlock("row_bl");
218 $counter = 0;
219 foreach ($list_data as $figure => $values) {
220 $day = (int) substr($day, 8);
221 $vtpl->setVariable("CSS_ROW", ($counter++ % 2) ? "tblrow1" : "tblrow2");
222 $vtpl->setVariable("FIGURE", $figure);
223 $vtpl->setVariable("YESTERDAY_VALUE", $values["yesterday"]);
224 $vtpl->setVariable("TODAY_VALUE", $values["today"]);
225 $vtpl->parseCurrentBlock();
226 }
227
228 $vtpl->setVariable("FIGURE_HEAD", $lng->txt("wiki_stat_figure"));
229 $vtpl->setVariable("YESTERDAY_HEAD", $lng->txt("yesterday"));
230 $vtpl->setVariable("TODAY_HEAD", $lng->txt("today"));
231
232 $chart_panel->setHeading($lng->txt("statistics"));
233 $chart_panel->setBody($vtpl->get());
234 $chart_panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_SUBHEADING);
235
236 $tpl->setContent($chart_panel->getHTML());
237 }
238 }
const HEADING_STYLE_SUBHEADING
static getInstance()
Get instance.
special template class to simplify handling of ITX/PEAR
renderGraph($a_figure, array $a_data)

References $lng, $tpl, getChartData(), ilPanelGUI\getInstance(), getListData(), ilPanelGUI\HEADING_STYLE_SUBHEADING, renderGraph(), and viewToolbar().

Referenced by initial().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewToolbar()

ilWikiStatGUI::viewToolbar (   $a_is_initial = false)
protected

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

66 {
67 $ilToolbar = $this->toolbar;
69 $ilCtrl = $this->ctrl;
70
71 $current_figure = (int) $_POST["fig"];
72 $current_time_frame = (string) $_POST["tfr"];
73 $current_scope = (int) $_POST["scp"];
74
75 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
76 $view = new ilSelectInputGUI($lng->txt("wiki_stat_figure"), "fig");
77 $view->setOptions($this->page_id
80 if ($current_figure) {
81 $view->setValue($current_figure);
82 } elseif ($a_is_initial) {
83 // default
84 $current_figure = $this->page_id
87 }
88 $ilToolbar->addInputItem($view, true);
89
90 $options = array();
91 include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
92 $lng->loadLanguageModule("dateplaner");
93 foreach (ilWikiStat::getAvailableMonths($this->wiki_id) as $month) {
94 $parts = explode("-", $month);
95 $options[$month] = ilCalendarUtil::_numericMonthToString((int) $parts[1]) .
96 " " . $parts[0];
97 }
98 krsort($options);
99
100 $tframe = new ilSelectInputGUI($lng->txt("month"), "tfr");
101 $tframe->setOptions($options);
102 if ($current_time_frame) {
103 $tframe->setValue($current_time_frame);
104 } elseif ($a_is_initial) {
105 $current_time_frame = array_shift(array_keys($options)); // default
106 }
107 $ilToolbar->addInputItem($tframe, true);
108
109 $scope = new ilSelectInputGUI($lng->txt("wiki_stat_scope"), "scp");
110 $scope->setOptions(array(
111 1 => "1 " . $lng->txt("month"),
112 2 => "2 " . $lng->txt("months"),
113 3 => "3 " . $lng->txt("months"),
114 4 => "4 " . $lng->txt("months"),
115 5 => "5 " . $lng->txt("months"),
116 6 => "6 " . $lng->txt("months")
117 ));
118 if ($current_scope) {
119 $scope->setValue($current_scope);
120 } elseif ($a_is_initial) {
121 $current_scope = 1; // default
122 }
123 $ilToolbar->addInputItem($scope, true);
124
125 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "view"));
126 $ilToolbar->addFormButton($lng->txt("show"), "view");
127
128 if ($current_figure && $current_time_frame && $current_scope) {
129 $ilToolbar->addSeparator();
130 $ilToolbar->addFormButton($lng->txt("export"), "export");
131
132 return array(
133 "figure" => $current_figure,
134 "month" => $current_time_frame,
135 "scope" => $current_scope
136 );
137 }
138 }
$_POST["username"]
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
This class represents a selection list property in a property form.
static getAvailableMonths($a_wiki_id)
static getFigureOptions()

References $_POST, $ctrl, $lng, $toolbar, ilCalendarUtil\_numericMonthToString(), ilWikiStat\getAvailableMonths(), ilWikiStat\getFigureOptions(), ilWikiStat\getFigureOptionsPage(), ilWikiStat\KEY_FIGURE_WIKI_NUM_PAGES, and ilWikiStat\KEY_FIGURE_WIKI_PAGE_CHANGES.

Referenced by export(), and view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilWikiStatGUI::$ctrl
protected

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

Referenced by executeCommand(), export(), and viewToolbar().

◆ $lng

ilWikiStatGUI::$lng
protected

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

Referenced by view(), and viewToolbar().

◆ $page_id

ilWikiStatGUI::$page_id
protected

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

◆ $toolbar

ilWikiStatGUI::$toolbar
protected

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

Referenced by viewToolbar().

◆ $tpl

ilWikiStatGUI::$tpl
protected

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

Referenced by view().

◆ $wiki_id

ilWikiStatGUI::$wiki_id
protected

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


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