3 if (!class_exists(
"report_top_viewed_products")) {
 
    9     class Report_top_viewed_products 
extends report_base
 
   17         protected $_sThisTemplate = 
"report_top_viewed_products.tpl";
 
   24         public function render()
 
   31             $oSmarty = $this->getSmarty();
 
   32             $sTimeFrom = $oDb->quote(date(
"Y-m-d H:i:s", strtotime($oSmarty->_tpl_vars[
'time_from'])));
 
   33             $sTimeTo = $oDb->quote(date(
"Y-m-d H:i:s", strtotime($oSmarty->_tpl_vars[
'time_to'])));
 
   35             $sSQL = 
"select count(*) as nrof, oxarticles.oxtitle from oxlogs, oxarticles " .
 
   36                     "where oxlogs.oxclass = 'details' and oxlogs.oxanid = oxarticles.oxid  " .
 
   37                     "and oxlogs.oxtime >= $sTimeFrom and oxlogs.oxtime <= $sTimeTo group by oxlogs.oxanid " .
 
   38                     "order by nrof desc limit 0, 25";
 
   39             $rs = $oDb->execute($sSQL);
 
   40             if ($rs != 
false && $rs->recordCount() > 0) {
 
   43                         $aDataX[] = $rs->fields[0];
 
   44                         $aDataY[] = $rs->fields[1];
 
   50             for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
 
   51                 if ($iMax < $aDataX[$iCtr]) {
 
   52                     $iMax = $aDataX[$iCtr];
 
   58             $aAligns[0] = 
'report_searchstrings_scale_aligns_left"';
 
   59             $iTenth = strlen($iMax) - 1;
 
   62                 $aPoints[(round(($iMax / 2)))] = $iMax / 2;
 
   63                 $aAligns[(round(($iMax / 2)))] = 
'report_searchstrings_scale_aligns_center" width="' . (720 / 3) . 
'"';
 
   64                 $aPoints[$iMax] = $iMax;
 
   65                 $aAligns[$iMax] = 
'report_searchstrings_scale_aligns_right" width="' . (720 / 3) . 
'"';
 
   67                 $iDeg = bcpow(10, $iTenth);
 
   71                 for ($iCtr = 10; $iCtr > 0; $iCtr--) {
 
   72                     $aPoints[(round(($ctr)))] = $ctr += $iScaleMax / 10;
 
   73                     $aAligns[(round(($ctr)))] = 
'report_searchstrings_scale_aligns_center" width="' . (720 / 10) . 
'"';
 
   75                 $aAligns[(round(($ctr)))] = 
'report_searchstrings_scale_aligns_right" width="' . (720 / 10) . 
'"';
 
   78             $aAligns[0] .= 
' width="' . (720 / count($aAligns)) . 
'"';
 
   82             for ($iCtr = 0; $iCtr < count($aDataY); $iCtr++) {
 
   83                 $aDataVals[$iCtr][
'pc'] = round($aDataX[$iCtr] / $iMax * 100);
 
   84                 $aDataVals[$iCtr][
'nm'] = $aDataY[$iCtr];
 
   87             if (count($aDataY) > 0) {
 
   88                 $oSmarty->assign(
"drawStat", 
true);
 
   90                 $oSmarty->assign(
"drawStat", 
false);
 
   93             $oSmarty->assign(
"classes", array($aAligns));
 
   94             $oSmarty->assign(
"allCols", count($aAligns));
 
   95             $oSmarty->assign(
"cols", count($aAligns));
 
   96             $oSmarty->assign(
"percents", array($aDataVals));
 
   97             $oSmarty->assign(
"y", $aDataY);
 
   99             return parent::render();
 
  105         public function graph1()
 
  113             $sTimeFrom = $oDb->quote(date(
"Y-m-d H:i:s", strtotime(
oxRegistry::getConfig()->getRequestParameter(
"time_from"))));
 
  114             $sTimeTo = $oDb->quote(date(
"Y-m-d H:i:s", strtotime(
oxRegistry::getConfig()->getRequestParameter(
"time_to"))));
 
  116             $sSQL = 
"select count(*) as nrof, oxparameter from oxlogs where oxclass = 'search' and oxtime >= $sTimeFrom and oxtime <= $sTimeTo group by oxparameter order by nrof desc";
 
  117             $rs = $oDb->execute($sSQL);
 
  118             if ($rs != 
false && $rs->recordCount() > 0) {
 
  120                     if ($rs->fields[1]) {
 
  121                         $aDataX[] = $rs->fields[0];
 
  122                         $aDataY[] = $rs->fields[1];
 
  128             header(
"Content-type: image/png");
 
  131             $graph = 
new Graph(800, max(640, 20 * count($aDataX)));
 
  132             $graph->setBackgroundImage(
$myConfig->getImageDir(
true) . 
"/reportbgrnd.jpg", BGIMG_FILLFRAME);
 
  135             $graph->setScale(
"textlin");
 
  141             $graph->set90AndMargin($left, $right, $top, $bottom);
 
  144             $graph->xaxis->setLabelAlign(
'right', 
'center', 
'right');
 
  147             $graph->yaxis->setLabelAlign(
'center', 
'bottom');
 
  151             $graph->xaxis->setTickLabels($aDataY);
 
  156             $graph->title->set(
"Suchw�rter");
 
  159             $graph->title->setFont(FF_FONT1, FS_BOLD);
 
  162             $bplot = 
new BarPlot($aDataX);
 
  163             $bplot->setFillGradient(
"navy", 
"lightsteelblue", GRAD_VER);
 
  164             $bplot->setLegend(
"Hits");