/** * create the image for player activity * @todo To complete * @return array The path to the image */ private function _mostTimeOnline() { exit; if (!in_array('Players', get_declared_classes())) { require 'players.class.php'; } $playersObj = new Players($this->_game); $data = $playersObj->getMostTimeOnline(); $c = 0; $xLine = array(); $connects = array(); $disconnects = array(); // we need only the count for each day foreach ($data['connect'] as $d => $e) { $connects[] = count($e); // this shows the date only every 5 days if ($c % 5 == 0) { $xLine[] = $d; } else { $xLine[] = ''; } $c++; } // we need only the count for each day foreach ($data['disconnect'] as $d => $e) { $disconnects[] = count($e); } // add the connects $this->_pData->AddPoint($connects, '1'); $this->_pData->AddSerie('1'); $this->_pData->SetSerieName(l("Connects"), '1'); // the dates for x axe $this->_pData->AddPoint($xLine, 'x'); $this->_pData->SetAbsciseLabelSerie("x"); // add the disconnects $this->_pData->AddPoint($disconnects, '2'); $this->_pData->AddSerie('2'); $this->_pData->SetSerieName(l("Disconnects"), '2'); $this->_pChart->setFontProperties("class/pchart/Fonts/tahoma.ttf", 8); $this->_pChart->setGraphArea(50, 30, $this->_option['width'] - 10, $this->_option['height'] - 70); $this->_pChart->drawFilledRoundedRectangle(3, 3, $this->_option['width'] - 3, $this->_option['height'] - 3, 5, 240, 240, 240); $this->_pChart->drawGraphArea(255, 255, 255, TRUE); $this->_pChart->drawScale($this->_pData->GetData(), $this->_pData->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2); $this->_pChart->drawGrid(4, TRUE, 230, 230, 230, 50); # // Draw the cubic curve graph $this->_pChart->drawCubicCurve($this->_pData->GetData(), $this->_pData->GetDataDescription()); # # // Finish the graph //$this->_pChart->setFontProperties("class/pchart/Fonts/tahoma.ttf",8); $this->_pChart->drawLegend(10, $this->_option['height'] - 40, $this->_pData->GetDataDescription(), 255, 255, 255); $this->_pChart->setFontProperties("class/pchart/Fonts/tahoma.ttf", 10); $this->_pChart->drawTitle(0, 20, l("Player activity"), 50, 50, 50, $this->_option['width']); return "tmp/" . $this->_option['chartId'] . ".png"; }
/** * create the image for player activity * @param object $playersObj The already existing players Object * * @return the path to the image */ private function _mostTimeOnline($playersObj = false) { $ret = false; if (!in_array('Players', get_declared_classes())) { require 'players.class.php'; } $cl = 'Players'; if (!$playersObj instanceof $cl) { $playersObj = new Players($this->_game); } $data = $playersObj->getMostTimeOnline(); # used to access the loaded data for other uses $this->_currentChartData = $data; if (!empty($data)) { $players = array(); $times = array(); foreach ($data as $playerId => $entry) { $players[] = $entry['playerName']; $times[] = $entry['timeSec'] / 60 / 60; } // add the players $this->_pData->AddPoint($times, '1'); $this->_pData->AddSerie('1'); $this->_pData->SetSerieName(l("Most time online (hours)"), '1'); // the dates for x axe $this->_pData->AddPoint($players, 'x'); $this->_pData->SetAbsciseLabelSerie("x"); $this->_pChart->setFontProperties("class/pchart/Fonts/tahoma.ttf", 8); $this->_pChart->setGraphArea(50, 30, $this->_option['width'] - 10, $this->_option['height'] - 100); $this->_pChart->drawFilledRoundedRectangle(3, 3, $this->_option['width'] - 3, $this->_option['height'] - 3, 5, 240, 240, 240); $this->_pChart->drawGraphArea(250, 250, 250, true); $this->_pChart->drawScale($this->_pData->GetData(), $this->_pData->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 30, 2, TRUE); $this->_pChart->drawGrid(4, false, 230, 230, 230, 250); // draw the bar graph $this->_pChart->drawBarGraph($this->_pData->GetData(), $this->_pData->GetDataDescription(), TRUE); # // Finish the graph //$this->_pChart->setFontProperties("class/pchart/Fonts/tahoma.ttf",8); $this->_pChart->drawLegend(10, $this->_option['height'] - 40, $this->_pData->GetDataDescription(), 250, 250, 250); $this->_pChart->setFontProperties("class/pchart/Fonts/tahoma.ttf", 10); $this->_pChart->drawTitle(0, 20, l("Most time online (hours)"), 50, 50, 50, $this->_option['width']); $this->_pChart->Render($this->_option['chartFile']); $ret = $this->_option['chartFile']; } return $ret; }