ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

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

20 {
21 $this->wiki_id = (int)$a_wiki_id;
22 $this->page_id = (int)$a_page_id;
23 }

Member Function Documentation

◆ executeCommand()

ilWikiStatGUI::executeCommand ( )

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

26 {
27 global $ilCtrl;
28
29 $next_class = $ilCtrl->getNextClass($this);
30 $cmd = $ilCtrl->getCmd("view");
31
32 switch($next_class)
33 {
34 default:
35 $this->$cmd();
36 break;
37 }
38 }
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35

References $cmd, and $ilCtrl.

◆ export()

ilWikiStatGUI::export ( )
protected

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

125 {
126 global $ilCtrl;
127
128 $params = $this->viewToolbar();
129 if($params)
130 {
131 // data
132
133 $tfr = explode("-", (string)$params["month"]);
134 $day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1]-($params["scope"]-1), 1, $tfr[0]));
135 $day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1]+1, 0, $tfr[0]));
136 unset($tfr);
137
138 $chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
139
140
141 // excel
142
144 new ilDate($day_from, IL_CAL_DATE),
145 new ilDate($day_to, IL_CAL_DATE));
146
147 $filename = ilObject::_lookupTitle($this->wiki_id);
148 if($this->page_id)
149 {
150 $filename .= " - ".ilWikiPage::lookupTitle($this->page_id);
151 }
152 $filename .= " - ".ilWikiStat::getFigureTitle($params["figure"])." - ".$period;
153
154 include_once "./Services/Excel/classes/class.ilExcel.php";
155 $excel = new ilExcel();
156 $excel->addSheet($this->lng->txt("statistics"));
157
158 $row = 1;
159 foreach($chart_data as $day => $value)
160 {
161 $excel->setCell($row, 0, $day);
162 $excel->setCell($row++, 1, $value);
163 }
164
165 $excel->sendToClient($filename);
166 }
167
168 $ilCtrl->redirect($this, "view");
169 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
const IL_CAL_DATE
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
Class for single dates.
static _lookupTitle($a_id)
lookup object title
getChartData($a_figure, $a_scope, $a_from, $a_to)
viewToolbar($a_is_initial=false)
$params
Definition: example_049.php:96

References $filename, $ilCtrl, $params, $row, ilObject\_lookupTitle(), date, ilDatePresentation\formatPeriod(), getChartData(), IL_CAL_DATE, 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 227 of file class.ilWikiStatGUI.php.

228 {
229 $data = array();
230
231 $raw = $this->page_id
232 ? ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $a_figure, $a_from, $a_to)
233 : ilWikiStat::getFigureData($this->wiki_id, $a_figure, $a_from, $a_to);
234
235 $parts = explode("-", $a_from);
236 for($loop = 0; $loop <= ($a_scope*31); $loop++)
237 {
238 $current_day = date("Y-m-d", mktime(0, 0, 1, $parts[1], $parts[2]+$loop, $parts[0]));
239 if($current_day <= $a_to)
240 {
241 $data[$current_day] = (float)$raw[$current_day];
242 }
243 }
244
245 return $data;
246 }
Wiki statistics class.
static getFigureDataPage($a_wiki_id, $a_page_id, $a_figure, $a_from, $a_to)

References $data, date, 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 248 of file class.ilWikiStatGUI.php.

249 {
250 $data = array();
251
252 $today = date("Y-m-d");
253 $yesterday = date("Y-m-d", strtotime("yesterday"));
254
255 $all = $this->page_id
257 : ilWikiStat::getFigureOptions();
258 foreach($all as $figure => $title)
259 {
260 if($this->page_id)
261 {
262 $tmp = (array)ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $figure, $yesterday, $today);
263 }
264 else
265 {
266 $tmp = (array)ilWikiStat::getFigureData($this->wiki_id, $figure, $yesterday, $today);
267 }
268 $data[$title] = array(
269 "yesterday" => (float)$tmp[$yesterday],
270 "today" => (float)$tmp[$today]
271 );
272 }
273
274 return $data;
275 }
static getFigureData($a_wiki_id, $a_figure, $a_from, $a_to)
static getFigureOptionsPage()

References $data, $title, date, 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 171 of file class.ilWikiStatGUI.php.

172 {
173 $this->view(true);
174 }
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 277 of file class.ilWikiStatGUI.php.

278 {
279 $scope = ceil(sizeof($a_data)/31);
280
281 include_once "Services/Chart/classes/class.ilChartGrid.php";
283 $chart->setSize("100%", 400);
284 $chart->setColors(array("#C0E0FF"));
285
286 $legend = new ilChartLegend();
287 $chart->setLegend($legend);
288
289 // lines vs. bars
290 if(in_array($a_figure, array(
291 // wiki
304 // page
310 )))
311 {
312 $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
313 $series->setLineSteps(true);
314 $series->setFill(true, "#E0F0FF");
315 }
316 else
317 {
318 $series = $chart->getDataInstance(ilChartGrid::DATA_BARS);
319 $series->setBarOptions(round(10/($scope*2))/10);
320 }
321 $series->setLabel(ilWikiStat::getFigureTitle($a_figure));
322
323 $labels = array();
324 $x = 0;
325 foreach($a_data as $date => $value)
326 {
327 $series->addPoint($x, $value);
328
329 $day = (int)substr($date, 8, 2);
330
331 // match scale to scope
332 if($scope == 1)
333 {
334 // daily
335 $labels[$x] = substr($date, 8, 2);
336 }
337 elseif($scope == 2)
338 {
339 // weekly
340 if(!($x%7))
341 {
342 $labels[$x] = substr($date, 8, 2).".".substr($date, 5, 2).".";
343 }
344 }
345 else
346 {
347 // 1st/15th
348 if($day == 1 || $day == 15 || $x == sizeof($a_data)-1)
349 {
350 $labels[$x] = substr($date, 8, 2).".".substr($date, 5, 2).".";
351 }
352 }
353
354 $x++;
355 }
356
357 $chart->addData($series);
358 $chart->setTicks($labels, null, true);
359
360 // int vs. float (averages)
361 if(in_array($a_figure, array(
362 // wiki
375 // page
385 )))
386 {
387 $chart->setYAxisToInteger(true);
388 }
389
390 return $chart->getHTML();
391 }
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
static getFigureTitle($a_figure)
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
$x
Definition: example_009.php:98

References $chart, $legend, $series, $x, 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 176 of file class.ilWikiStatGUI.php.

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

References $counter, $lng, $params, $tpl, date, 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 40 of file class.ilWikiStatGUI.php.

41 {
42 global $ilToolbar, $lng, $ilCtrl;
43
44 $current_figure = (int)$_POST["fig"];
45 $current_time_frame = (string)$_POST["tfr"];
46 $current_scope = (int)$_POST["scp"];
47
48 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
49 $view = new ilSelectInputGUI($lng->txt("wiki_stat_figure"), "fig");
50 $view->setOptions($this->page_id
53 if($current_figure)
54 {
55 $view->setValue($current_figure);
56 }
57 else if($a_is_initial)
58 {
59 // default
60 $current_figure = $this->page_id
63 }
64 $ilToolbar->addInputItem($view, true);
65
66 $options = array();
67 include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
68 $lng->loadLanguageModule("dateplaner");
69 foreach(ilWikiStat::getAvailableMonths($this->wiki_id) as $month)
70 {
71 $parts = explode("-", $month);
72 $options[$month] = ilCalendarUtil::_numericMonthToString((int)$parts[1]).
73 " ".$parts[0];
74 }
75 krsort($options);
76
77 $tframe = new ilSelectInputGUI($lng->txt("month"), "tfr");
78 $tframe->setOptions($options);
79 if($current_time_frame)
80 {
81 $tframe->setValue($current_time_frame);
82 }
83 else if($a_is_initial)
84 {
85 $current_time_frame = array_shift(array_keys($options)); // default
86 }
87 $ilToolbar->addInputItem($tframe, true);
88
89 $scope = new ilSelectInputGUI($lng->txt("wiki_stat_scope"), "scp");
90 $scope->setOptions(array(
91 1 => "1 ".$lng->txt("month"),
92 2 => "2 ".$lng->txt("months"),
93 3 => "3 ".$lng->txt("months"),
94 4 => "4 ".$lng->txt("months"),
95 5 => "5 ".$lng->txt("months"),
96 6 => "6 ".$lng->txt("months")
97 ));
98 if($current_scope)
99 {
100 $scope->setValue($current_scope);
101 }
102 else if($a_is_initial)
103 {
104 $current_scope = 1; // default
105 }
106 $ilToolbar->addInputItem($scope, true);
107
108 $ilToolbar->setFormAction($ilCtrl->getFormAction($this, "view"));
109 $ilToolbar->addFormButton($lng->txt("show"), "view");
110
111 if($current_figure && $current_time_frame && $current_scope)
112 {
113 $ilToolbar->addSeparator();
114 $ilToolbar->addFormButton($lng->txt("export"), "export");
115
116 return array(
117 "figure" => $current_figure,
118 "month" => $current_time_frame,
119 "scope" => $current_scope
120 );
121 }
122 }
$_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()
if(!is_array($argv)) $options

References $_POST, $ilCtrl, $lng, $options, 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

◆ $page_id

ilWikiStatGUI::$page_id
protected

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

◆ $wiki_id

ilWikiStatGUI::$wiki_id
protected

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


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