/**
  * Loads the list of elements on a single page.
  * Returns an array of plain data, not the corresponding objects.
  * In most cases getElementsOnPage is the right way to go.
  *
  *
  * @param string $strPageId
  * @param bool $bitJustActive
  * @param string $strLanguage
  *
  * @see class_module_pages_pageelement::getElementsOnPage()
  * @return array
  */
 public static function getPlainElementsOnPage($strPageId, $bitJustActive = false, $strLanguage = "")
 {
     //Calculate the current day as a time-stamp. This improves database-caches e.g. the kajona or mysql-query-cache.
     $objDate = new class_date();
     $objDate->setIntMin(0, true);
     $objDate->setIntSec(0, true);
     $objDate->setIntHour(0, true);
     $longToday = $objDate->getLongTimestamp();
     $arrParams = array($strPageId, $strLanguage);
     $objORM = new class_orm_objectlist();
     $strAnd = "";
     if ($bitJustActive) {
         $strAnd = "AND system_status = 1\n                       AND ( system_date_start IS null OR (system_date_start = 0 OR system_date_start <= ?))\n                       AND ( system_date_end IS null OR (system_date_end = 0 OR system_date_end >= ?)) ";
         $arrParams[] = $longToday;
         $arrParams[] = $longToday;
     }
     $strQuery = "SELECT *\n                       FROM " . _dbprefix_ . "page_element,\n                            " . _dbprefix_ . "element,\n                            " . _dbprefix_ . "system_right,\n                            " . _dbprefix_ . "system as system\n                  LEFT JOIN " . _dbprefix_ . "system_date\n                         ON (system_id = system_date_id)\n                      WHERE system_prev_id= ?\n                        AND page_element_ph_element = element_name\n                        AND system_id = page_element_id\n                        AND system_id = right_id\n                        AND page_element_ph_language = ?\n                       " . $strAnd . "\n                       " . $objORM->getDeletedWhereRestriction() . "\n                  ORDER BY page_element_ph_placeholder ASC,\n                           page_element_ph_language ASC,\n                           system_sort ASC";
     $arrReturn = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, $arrParams);
     foreach ($arrReturn as $arrOneRow) {
         class_orm_rowcache::addSingleInitRow($arrOneRow);
     }
     return $arrReturn;
 }
 /**
  * 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;
 }