ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.".xls";
153
154 include_once "./Services/Excel/classes/class.ilExcelUtils.php";
155 include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
156 $adapter = new ilExcelWriterAdapter($filename, true);
157 $workbook = $adapter->getWorkbook();
158 $worksheet = $workbook->addWorksheet();
159 // $worksheet->setLandscape();
160
161 /*
162 $worksheet->setColumn(0, 0, 20);
163 $worksheet->setColumn(1, 1, 40);
164 */
165
166 $row = 0;
167 foreach($chart_data as $day => $value)
168 {
169 $row++;
170
171 $worksheet->writeString($row, 0, $day);
172 $worksheet->writeNumber($row, 1, $value);
173 }
174
175 $workbook->close();
176 exit();
177 }
178
179 $ilCtrl->redirect($this, "view");
180 }
$filename
Definition: buildRTE.php:89
const IL_CAL_DATE
static formatPeriod(ilDateTime $start, ilDateTime $end)
Format a period of two date Shows: 14.
Class for single dates.
Class ilExcelWriterAdapter.
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
exit
Definition: login.php:54

References $filename, $ilCtrl, $params, $row, ilObject\_lookupTitle(), exit, 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 238 of file class.ilWikiStatGUI.php.

239 {
240 $data = array();
241
242 $raw = $this->page_id
243 ? ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $a_figure, $a_from, $a_to)
244 : ilWikiStat::getFigureData($this->wiki_id, $a_figure, $a_from, $a_to);
245
246 $parts = explode("-", $a_from);
247 for($loop = 0; $loop <= ($a_scope*31); $loop++)
248 {
249 $current_day = date("Y-m-d", mktime(0, 0, 1, $parts[1], $parts[2]+$loop, $parts[0]));
250 if($current_day <= $a_to)
251 {
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

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 {
271 if($this->page_id)
272 {
273 $tmp = (array)ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $figure, $yesterday, $today);
274 }
275 else
276 {
277 $tmp = (array)ilWikiStat::getFigureData($this->wiki_id, $figure, $yesterday, $today);
278 }
279 $data[$title] = array(
280 "yesterday" => (float)$tmp[$yesterday],
281 "today" => (float)$tmp[$today]
282 );
283 }
284
285 return $data;
286 }
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 182 of file class.ilWikiStatGUI.php.

183 {
184 $this->view(true);
185 }
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 288 of file class.ilWikiStatGUI.php.

289 {
290 $scope = ceil(sizeof($a_data)/31);
291
292 include_once "Services/Chart/classes/class.ilChartGrid.php";
294 $chart->setSize("100%", 400);
295 $chart->setColors(array("#C0E0FF"));
296
297 $legend = new ilChartLegend();
298 $chart->setLegend($legend);
299
300 // lines vs. bars
301 if(in_array($a_figure, array(
302 // wiki
315 // page
321 )))
322 {
323 $series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
324 $series->setLineSteps(true);
325 $series->setFill(true, "#E0F0FF");
326 }
327 else
328 {
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 {
338 $series->addPoint($x, $value);
339
340 $day = (int)substr($date, 8, 2);
341
342 // match scale to scope
343 if($scope == 1)
344 {
345 // daily
346 $labels[$x] = substr($date, 8, 2);
347 }
348 elseif($scope == 2)
349 {
350 // weekly
351 if(!($x%7))
352 {
353 $labels[$x] = substr($date, 8, 2).".".substr($date, 5, 2).".";
354 }
355 }
356 else
357 {
358 // 1st/15th
359 if($day == 1 || $day == 15 || $x == sizeof($a_data)-1)
360 {
361 $labels[$x] = substr($date, 8, 2).".".substr($date, 5, 2).".";
362 }
363 }
364
365 $x++;
366 }
367
368 $chart->addData($series);
369 $chart->setTicks($labels, null, true);
370
371 // int vs. float (averages)
372 if(in_array($a_figure, array(
373 // wiki
386 // page
396 )))
397 {
398 $chart->setYAxisToInteger(true);
399 }
400
401 return $chart->getHTML();
402 }
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
$legend

References $legend, $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 187 of file class.ilWikiStatGUI.php.

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

References $lng, $params, $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 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 }
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()
$_POST['username']
Definition: cron.php:12
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: