ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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

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

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

{
$this->wiki_id = (int)$a_wiki_id;
$this->page_id = (int)$a_page_id;
}

Member Function Documentation

ilWikiStatGUI::executeCommand ( )

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

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$next_class = $ilCtrl->getNextClass($this);
$cmd = $ilCtrl->getCmd("view");
switch($next_class)
{
default:
$this->$cmd();
break;
}
}
ilWikiStatGUI::export ( )
protected

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

References $filename, $ilCtrl, $row, ilObject\_lookupTitle(), exit, ilDatePresentation\formatPeriod(), getChartData(), IL_CAL_DATE, and viewToolbar().

{
global $ilCtrl;
$params = $this->viewToolbar();
if($params)
{
// data
$tfr = explode("-", (string)$params["month"]);
$day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1]-($params["scope"]-1), 1, $tfr[0]));
$day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1]+1, 0, $tfr[0]));
unset($tfr);
$chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
// excel
new ilDate($day_from, IL_CAL_DATE),
new ilDate($day_to, IL_CAL_DATE));
$filename = ilObject::_lookupTitle($this->wiki_id);
if($this->page_id)
{
$filename .= " - ".ilWikiPage::lookupTitle($this->page_id);
}
$filename .= " - ".ilWikiStat::getFigureTitle($params["figure"])." - ".$period.".xls";
include_once "./Services/Excel/classes/class.ilExcelUtils.php";
include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php";
$adapter = new ilExcelWriterAdapter($filename, true);
$workbook = $adapter->getWorkbook();
$worksheet = $workbook->addWorksheet();
// $worksheet->setLandscape();
/*
$worksheet->setColumn(0, 0, 20);
$worksheet->setColumn(1, 1, 40);
*/
$row = 0;
foreach($chart_data as $day => $value)
{
$row++;
$worksheet->writeString($row, 0, $day);
$worksheet->writeNumber($row, 1, $value);
}
$workbook->close();
exit();
}
$ilCtrl->redirect($this, "view");
}

+ Here is the call graph for this function:

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

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

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

Referenced by export(), and view().

{
$data = array();
$raw = $this->page_id
? ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $a_figure, $a_from, $a_to)
: ilWikiStat::getFigureData($this->wiki_id, $a_figure, $a_from, $a_to);
$parts = explode("-", $a_from);
for($loop = 0; $loop <= ($a_scope*31); $loop++)
{
$current_day = date("Y-m-d", mktime(0, 0, 1, $parts[1], $parts[2]+$loop, $parts[0]));
if($current_day <= $a_to)
{
$data[$current_day] = (float)$raw[$current_day];
}
}
return $data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilWikiStatGUI::getListData ( )
protected

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

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

Referenced by view().

{
$data = array();
$today = date("Y-m-d");
$yesterday = date("Y-m-d", strtotime("yesterday"));
$all = $this->page_id
: ilWikiStat::getFigureOptions();
foreach($all as $figure => $title)
{
if($this->page_id)
{
$tmp = (array)ilWikiStat::getFigureDataPage($this->wiki_id, $this->page_id, $figure, $yesterday, $today);
}
else
{
$tmp = (array)ilWikiStat::getFigureData($this->wiki_id, $figure, $yesterday, $today);
}
$data[$title] = array(
"yesterday" => (float)$tmp[$yesterday],
"today" => (float)$tmp[$today]
);
}
return $data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilWikiStatGUI::initial ( )
protected

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

References view().

{
$this->view(true);
}

+ Here is the call graph for this function:

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

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

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().

{
$scope = ceil(sizeof($a_data)/31);
include_once "Services/Chart/classes/class.ilChartGrid.php";
$chart->setSize("100%", 400);
$chart->setColors(array("#C0E0FF"));
$legend = new ilChartLegend();
$chart->setLegend($legend);
// lines vs. bars
if(in_array($a_figure, array(
// wiki
// page
)))
{
$series = $chart->getDataInstance(ilChartGrid::DATA_LINES);
$series->setLineSteps(true);
$series->setFill(true, "#E0F0FF");
}
else
{
$series = $chart->getDataInstance(ilChartGrid::DATA_BARS);
$series->setBarOptions(round(10/($scope*2))/10);
}
$series->setLabel(ilWikiStat::getFigureTitle($a_figure));
$labels = array();
$x = 0;
foreach($a_data as $date => $value)
{
$series->addPoint($x, $value);
$day = (int)substr($date, 8, 2);
// match scale to scope
if($scope == 1)
{
// daily
$labels[$x] = substr($date, 8, 2);
}
elseif($scope == 2)
{
// weekly
if(!($x%7))
{
$labels[$x] = substr($date, 8, 2).".".substr($date, 5, 2).".";
}
}
else
{
// 1st/15th
if($day == 1 || $day == 15 || $x == sizeof($a_data)-1)
{
$labels[$x] = substr($date, 8, 2).".".substr($date, 5, 2).".";
}
}
$x++;
}
$chart->addData($series);
$chart->setTicks($labels, null, true);
// int vs. float (averages)
if(in_array($a_figure, array(
// wiki
// page
)))
{
$chart->setYAxisToInteger(true);
}
return $chart->getHTML();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilWikiStatGUI::view (   $a_is_initial = false)
protected

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

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

Referenced by initial().

{
global $tpl, $lng;
$params = $this->viewToolbar($a_is_initial);
if(is_array($params))
{
// data
$tfr = explode("-", (string)$params["month"]);
$day_from = date("Y-m-d", mktime(0, 0, 1, $tfr[1]-($params["scope"]-1), 1, $tfr[0]));
$day_to = date("Y-m-d", mktime(0, 0, 1, $tfr[1]+1, 0, $tfr[0]));
unset($tfr);
$chart_data = $this->getChartData($params["figure"], $params["scope"], $day_from, $day_to);
$list_data = $this->getListData();
// render
$vtpl = new ilTemplate("tpl.wiki_stat_list.html", true, true, "Modules/Wiki");
include_once("./Services/UIComponent/Panel/classes/class.ilPanelGUI.php");
$chart_panel = ilPanelGUI::getInstance();
$vtpl->setVariable("CHART", $this->renderGraph($params["figure"], $chart_data));
$vtpl->setCurrentBlock("row_bl");
$counter = 0;
foreach($list_data as $figure => $values)
{
$day = (int)substr($day, 8);
$vtpl->setVariable("CSS_ROW", ($counter++%2) ? "tblrow1" : "tblrow2");
$vtpl->setVariable("FIGURE", $figure);
$vtpl->setVariable("YESTERDAY_VALUE", $values["yesterday"]);
$vtpl->setVariable("TODAY_VALUE", $values["today"]);
$vtpl->parseCurrentBlock();
}
$vtpl->setVariable("FIGURE_HEAD", $lng->txt("wiki_stat_figure"));
$vtpl->setVariable("YESTERDAY_HEAD", $lng->txt("yesterday"));
$vtpl->setVariable("TODAY_HEAD", $lng->txt("today"));
$chart_panel->setHeading($lng->txt("statistics"));
$chart_panel->setBody($vtpl->get());
$chart_panel->setHeadingStyle(ilPanelGUI::HEADING_STYLE_SUBHEADING);
$tpl->setContent($chart_panel->getHTML());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilWikiStatGUI::viewToolbar (   $a_is_initial = false)
protected

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

References $_POST, $ilCtrl, $lng, $options, ilCalendarUtil\_numericMonthToString(), ilWikiStat\getAvailableMonths(), ilWikiStat\getFigureOptions(), ilWikiStat\getFigureOptionsPage(), ilWikiStat\KEY_FIGURE_WIKI_NUM_PAGES, ilWikiStat\KEY_FIGURE_WIKI_PAGE_CHANGES, and ilSelectInputGUI\setOptions().

Referenced by export(), and view().

{
global $ilToolbar, $lng, $ilCtrl;
$current_figure = (int)$_POST["fig"];
$current_time_frame = (string)$_POST["tfr"];
$current_scope = (int)$_POST["scp"];
include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
$view = new ilSelectInputGUI($lng->txt("wiki_stat_figure"), "fig");
$view->setOptions($this->page_id
if($current_figure)
{
$view->setValue($current_figure);
}
else if($a_is_initial)
{
// default
$current_figure = $this->page_id
}
$ilToolbar->addInputItem($view, true);
$options = array();
include_once "Services/Calendar/classes/class.ilCalendarUtil.php";
$lng->loadLanguageModule("dateplaner");
foreach(ilWikiStat::getAvailableMonths($this->wiki_id) as $month)
{
$parts = explode("-", $month);
" ".$parts[0];
}
krsort($options);
$tframe = new ilSelectInputGUI($lng->txt("month"), "tfr");
$tframe->setOptions($options);
if($current_time_frame)
{
$tframe->setValue($current_time_frame);
}
else if($a_is_initial)
{
$current_time_frame = array_shift(array_keys($options)); // default
}
$ilToolbar->addInputItem($tframe, true);
$scope = new ilSelectInputGUI($lng->txt("wiki_stat_scope"), "scp");
$scope->setOptions(array(
1 => "1 ".$lng->txt("month"),
2 => "2 ".$lng->txt("months"),
3 => "3 ".$lng->txt("months"),
4 => "4 ".$lng->txt("months"),
5 => "5 ".$lng->txt("months"),
6 => "6 ".$lng->txt("months")
));
if($current_scope)
{
$scope->setValue($current_scope);
}
else if($a_is_initial)
{
$current_scope = 1; // default
}
$ilToolbar->addInputItem($scope, true);
$ilToolbar->setFormAction($ilCtrl->getFormAction($this, "view"));
$ilToolbar->addFormButton($lng->txt("show"), "view");
if($current_figure && $current_time_frame && $current_scope)
{
$ilToolbar->addSeparator();
$ilToolbar->addFormButton($lng->txt("export"), "export");
return array(
"figure" => $current_figure,
"month" => $current_time_frame,
"scope" => $current_scope
);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilWikiStatGUI::$page_id
protected

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

ilWikiStatGUI::$wiki_id
protected

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


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