Ejemplo n.º 1
0
 public function testTimezoneShifts()
 {
     $objDate = new class_date("20141026000000");
     $objDate->setNextDay();
     $this->assertEquals($objDate->getLongTimestamp(), "20141027000000");
     $objDate = new class_date("20141027000000");
     $objDate->setPreviousDay();
     $this->assertEquals($objDate->getLongTimestamp(), "20141026000000");
 }
Ejemplo n.º 2
0
 public function testReports()
 {
     if (!defined("_skinwebpath_")) {
         define("_skinwebpath_", "1");
     }
     echo "processing reports...\n";
     $arrReportsInFs = class_resourceloader::getInstance()->getFolderContent("/admin/statsreports", array(".php"), false, function ($strOneFile) {
         if (uniStripos($strOneFile, "class_stats_report") === false) {
             return false;
         }
         return true;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang());
     });
     $arrReports = array();
     foreach ($arrReportsInFs as $objReport) {
         if ($objReport instanceof interface_admin_statsreports) {
             $arrReports[$objReport->getTitle()] = $objReport;
         }
         $objStartDate = new class_date();
         $objStartDate->setPreviousDay();
         $objEndDate = new class_date();
         $objEndDate->setNextDay();
         $intStartDate = mktime(0, 0, 0, $objStartDate->getIntMonth(), $objStartDate->getIntDay(), $objStartDate->getIntYear());
         $intEndDate = mktime(0, 0, 0, $objEndDate->getIntMonth(), $objEndDate->getIntDay(), $objEndDate->getIntYear());
         $objReport->setEndDate($intEndDate);
         $objReport->setStartDate($intStartDate);
         $objReport->setInterval(2);
     }
     /** @var interface_admin_statsreports $objReport */
     foreach ($arrReports as $objReport) {
         ob_start();
         echo "processing report " . $objReport->getTitle() . "\n";
         $objReport->getReport();
         $objReport->getReportGraph();
     }
 }
Ejemplo n.º 3
0
 /**
  * This method is called, when the widget should generate it's content.
  * Return the complete content using the methods provided by the base class.
  * Do NOT use the toolkit right here! 
  *
  * @return string
  */
 public function getWidgetOutput()
 {
     $strReturn = "";
     if (!class_module_system_module::getModuleByName("stats")->rightView()) {
         return $this->getLang("commons_error_permissions");
     }
     $objStatsCommon = new class_stats_report_common(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang());
     //check wich infos to produce
     if ($this->getFieldValue("current") == "checked") {
         $strReturn .= $this->getLang("stats_online") . $objStatsCommon->getNumberOfCurrentUsers();
         $strReturn .= $this->widgetSeparator();
     }
     if ($this->getFieldValue("chart") == "checked") {
         //load the last view days
         $objDate = new class_date();
         $objDate->setIntHour(0);
         $objDate->setIntMin(0);
         $objDate->setIntSec(0);
         $arrHits = array();
         $arrLabels = array();
         for ($intI = 0; $intI < 7; $intI++) {
             $objEndDate = clone $objDate;
             $objEndDate->setNextDay();
             $objStatsCommon->setStartDate($objDate->getTimeInOldStyle());
             $objStatsCommon->setEndDate($objEndDate->getTimeInOldStyle());
             $arrHits[] = $objStatsCommon->getHits();
             $arrLabels[] = $objDate->getIntDay();
             $objDate->setPreviousDay();
         }
         $arrHits = array_reverse($arrHits);
         $arrLabels = array_reverse($arrLabels);
         $strReturn .= $this->widgetText($this->getLang("stats_hits"));
         $objChart = class_graph_factory::getGraphInstance();
         $objChart->setArrXAxisTickLabels($arrLabels);
         $objChart->addLinePlot($arrHits, "");
         $objChart->setBitRenderLegend(false);
         $objChart->setIntHeight(220);
         $objChart->setIntWidth(300);
         $objChart->setStrXAxisTitle("");
         $objChart->setStrYAxisTitle("");
         $strReturn .= $objChart->renderGraph();
     }
     if ($this->getFieldValue("day") == "checked") {
         //current day:
         //pass date to commons-object
         $objDate = new class_date();
         $objDate->setIntHour(0);
         $objDate->setIntMin(0);
         $objDate->setIntSec(0);
         $strReturn .= $this->widgetText(dateToString($objDate, false));
         $objStatsCommon->setStartDate($objDate->getTimeInOldStyle());
         $objDate->setNextDay();
         $objStatsCommon->setEndDate($objDate->getTimeInOldStyle());
         $strReturn .= $this->widgetText($this->getLang("stats_hits") . " " . $objStatsCommon->getHits());
         $strReturn .= $this->widgetText($this->getLang("stats_visitors") . " " . $objStatsCommon->getVisitors());
         $strReturn .= $this->widgetSeparator();
     }
     if ($this->getFieldValue("last") == "checked") {
         $strReturn .= $this->widgetText($this->getLang("stats_ip") . " " . $this->getLang("stats_page"));
         $intMaxRecords = $this->getFieldValue("nrLast");
         if (!is_numeric($intMaxRecords) || $intMaxRecords > 15) {
             $intMaxRecords = 15;
         }
         $arrRecordsets = class_carrier::getInstance()->getObjDB()->getPArray("SELECT * FROM " . _dbprefix_ . "stats_data ORDER BY stats_date DESC ", array(), 0, $intMaxRecords - 1);
         foreach ($arrRecordsets as $arrOneRecord) {
             $strReturn .= $this->widgetText($arrOneRecord["stats_ip"] . " " . $arrOneRecord["stats_page"]);
         }
     }
     return $strReturn;
 }
 /**
  * @return string
  * @permissions view
  */
 protected function actionRenderCalendar()
 {
     $strReturn = "";
     $strContent = "";
     $arrJsHighlights = array();
     $strReturn .= "<content><![CDATA[";
     /** @var interface_calendarsource_admin[] $arrRelevantModules  */
     $arrRelevantModules = array();
     //fetch modules relevant for processing
     $arrModules = class_module_system_module::getAllModules();
     foreach ($arrModules as $objSingleModule) {
         if ($objSingleModule->getIntRecordStatus() == 1 && $objSingleModule->getAdminInstanceOfConcreteModule() instanceof interface_calendarsource_admin) {
             $arrRelevantModules[] = $objSingleModule->getAdminInstanceOfConcreteModule();
         }
     }
     //the header row
     $arrWeekdays = explode(",", $this->getLang("calendar_weekday"));
     foreach ($arrWeekdays as $intKey => $strValue) {
         $arrWeekdays[$intKey] = trim(uniStrReplace("\"", "", $strValue));
     }
     $strContent .= $this->objToolkit->getCalendarHeaderRow($arrWeekdays);
     //render the single rows. calculate the first day of the row
     $objDate = new class_date();
     $objDate->setIntDay(1);
     //set to interval stored in session
     if ($this->objSession->getSession($this->strStartMonthKey) != "") {
         $objDate->setIntMonth($this->objSession->getSession($this->strStartMonthKey));
     }
     if ($this->objSession->getSession($this->strStartYearKey) != "") {
         $objDate->setIntYear($this->objSession->getSession($this->strStartYearKey));
     }
     $intCurMonth = $objDate->getIntMonth();
     $intCurYear = $objDate->getIntYear();
     $objToday = new class_date();
     //start by monday
     while ($objDate->getIntDayOfWeek() != 1) {
         $objDate->setPreviousDay();
     }
     $strEntries = "";
     $intRowEntryCount = 0;
     while ($objDate->getIntMonth() <= $intCurMonth && $objDate->getIntYear() <= $intCurYear || $objDate->getIntMonth() == 12 && $objDate->getIntYear() < $intCurYear || $intRowEntryCount % 7 != 0) {
         $intRowEntryCount++;
         $strDate = $objDate->getIntDay();
         $arrEvents = array();
         if ($objDate->getIntMonth() == $intCurMonth) {
             //Query modules for dates
             $objStartDate = clone $objDate;
             $objStartDate->setIntHour(0)->setIntMin(0)->setIntSec(0);
             $objEndDate = clone $objDate;
             $objEndDate->setIntHour(23)->setIntMin(59)->setIntSec(59);
             foreach ($arrRelevantModules as $objOneModule) {
                 $arrEvents = array_merge($objOneModule->getArrCalendarEntries($objStartDate, $objEndDate), $arrEvents);
             }
         }
         while (count($arrEvents) <= 3) {
             $objDummy = new class_calendarentry();
             $objDummy->setStrClass("spacer");
             $objDummy->setStrName("&nbsp;");
             $arrEvents[] = $objDummy;
         }
         $strEvents = "";
         /** @var class_calendarentry $objOneEvent */
         foreach ($arrEvents as $objOneEvent) {
             $strName = $objOneEvent->getStrName();
             $strSecondLine = $objOneEvent->getStrSecondLine();
             if ($strSecondLine != "") {
                 $strSecondLine = "<br />" . $strSecondLine;
             }
             //register mouse-over highlight relations
             if ($objOneEvent->getStrHighlightId() != "" && $objOneEvent->getStrSystemid() != "") {
                 if (!isset($arrJsHighlights[$objOneEvent->getStrHighlightId()])) {
                     $arrJsHighlights[$objOneEvent->getStrHighlightId()] = array();
                 }
                 $arrJsHighlights[$objOneEvent->getStrHighlightId()][] = $objOneEvent->getStrSystemid();
             }
             $strEvents .= $this->objToolkit->getCalendarEvent($strName . $strSecondLine, $objOneEvent->getStrSystemid(), $objOneEvent->getStrHighlightId(), $objOneEvent->getStrClass());
         }
         $bitBlocked = false;
         if ($objDate->getIntDayOfWeek() == 0 || $objDate->getIntDayOfWeek() == 6) {
             $bitBlocked = true;
         }
         $strToday = "";
         if ($objToday->getIntYear() == $objDate->getIntYear() && $objToday->getIntMonth() == $objDate->getIntMonth() && $objToday->getIntDay() == $objDate->getIntDay()) {
             $strToday = " calendarDateToday";
         }
         if ($objDate->getIntMonth() != $intCurMonth) {
             $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryOutOfRange" . $strToday);
         } else {
             if ($bitBlocked) {
                 $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntryBlocked" . $strToday);
             } else {
                 $strEntries .= $this->objToolkit->getCalendarEntry($strEvents, $strDate, "calendarEntry" . $strToday);
             }
         }
         if ($intRowEntryCount % 7 == 0) {
             $strContent .= $this->objToolkit->getCalendarRow($strEntries);
             $strEntries = "";
         }
         $objDate->setNextDay();
     }
     if ($strEntries != "") {
         $strContent .= $this->objToolkit->getCalendarRow($strEntries);
     }
     $strReturn .= $this->objToolkit->getCalendarWrapper($strContent);
     //build js-arrays
     $strJs = "<script type=\"text/javascript\">";
     foreach ($arrJsHighlights as $strCommonId => $arrEntries) {
         $strJs .= " var kj_cal_" . $strCommonId . " = new Array();";
         foreach ($arrEntries as $strOneIdentifier) {
             $strJs .= "kj_cal_" . $strCommonId . ".push('" . $strOneIdentifier . "');";
         }
     }
     $strJs .= "</script>";
     $strReturn .= $strJs;
     $strReturn .= "]]></content>";
     return $strReturn;
 }