3 if (!class_exists(
"report_top_viewed_products")) {
 
    7     class Report_top_viewed_products 
extends report_base
 
   15         protected $_sThisTemplate = 
"report_top_viewed_products.tpl";
 
   22         public function render()
 
   29             $oSmarty = $this->getSmarty();
 
   30             $sTimeFrom = $oDb->quote(date(
"Y-m-d H:i:s", strtotime($oSmarty->_tpl_vars[
'time_from'])));
 
   31             $sTimeTo = $oDb->quote(date(
"Y-m-d H:i:s", strtotime($oSmarty->_tpl_vars[
'time_to'])));
 
   33             $sSQL = 
"select count(*) as nrof, oxarticles.oxtitle from oxlogs, oxarticles " .
 
   34                     "where oxlogs.oxclass = 'details' and oxlogs.oxanid = oxarticles.oxid  " .
 
   35                     "and oxlogs.oxtime >= $sTimeFrom and oxlogs.oxtime <= $sTimeTo group by oxlogs.oxanid " .
 
   36                     "order by nrof desc limit 0, 25";
 
   37             $rs = $oDb->execute($sSQL);
 
   38             if ($rs != 
false && $rs->recordCount() > 0) {
 
   41                         $aDataX[] = $rs->fields[0];
 
   42                         $aDataY[] = $rs->fields[1];
 
   48             for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
 
   49                 if ($iMax < $aDataX[$iCtr]) {
 
   50                     $iMax = $aDataX[$iCtr];
 
   56             $aAligns[0] = 
'report_searchstrings_scale_aligns_left"';
 
   57             $iTenth = strlen($iMax) - 1;
 
   60                 $aPoints[(round(($iMax / 2)))] = $iMax / 2;
 
   61                 $aAligns[(round(($iMax / 2)))] = 
'report_searchstrings_scale_aligns_center" width="' . (720 / 3) . 
'"';
 
   62                 $aPoints[$iMax] = $iMax;
 
   63                 $aAligns[$iMax] = 
'report_searchstrings_scale_aligns_right" width="' . (720 / 3) . 
'"';
 
   65                 $iDeg = bcpow(10, $iTenth);
 
   69                 for ($iCtr = 10; $iCtr > 0; $iCtr--) {
 
   70                     $aPoints[(round(($ctr)))] = $ctr += $iScaleMax / 10;
 
   71                     $aAligns[(round(($ctr)))] = 
'report_searchstrings_scale_aligns_center" width="' . (720 / 10) . 
'"';
 
   73                 $aAligns[(round(($ctr)))] = 
'report_searchstrings_scale_aligns_right" width="' . (720 / 10) . 
'"';
 
   76             $aAligns[0] .= 
' width="' . (720 / count($aAligns)) . 
'"';
 
   80             for ($iCtr = 0; $iCtr < count($aDataY); $iCtr++) {
 
   81                 $aDataVals[$iCtr][
'pc'] = round($aDataX[$iCtr] / $iMax * 100);
 
   82                 $aDataVals[$iCtr][
'nm'] = $aDataY[$iCtr];
 
   85             if (count($aDataY) > 0) {
 
   86                 $oSmarty->assign(
"drawStat", 
true);
 
   88                 $oSmarty->assign(
"drawStat", 
false);
 
   91             $oSmarty->assign(
"classes", array($aAligns));
 
   92             $oSmarty->assign(
"allCols", count($aAligns));
 
   93             $oSmarty->assign(
"cols", count($aAligns));
 
   94             $oSmarty->assign(
"percents", array($aDataVals));
 
   95             $oSmarty->assign(
"y", $aDataY);
 
   97             return parent::render();
 
  103         public function graph1()
 
  111             $sTimeFrom = $oDb->quote(date(
"Y-m-d H:i:s", strtotime(
oxRegistry::getConfig()->getRequestParameter(
"time_from"))));
 
  112             $sTimeTo = $oDb->quote(date(
"Y-m-d H:i:s", strtotime(
oxRegistry::getConfig()->getRequestParameter(
"time_to"))));
 
  114             $sSQL = 
"select count(*) as nrof, oxparameter from oxlogs where oxclass = 'search' and oxtime >= $sTimeFrom and oxtime <= $sTimeTo group by oxparameter order by nrof desc";
 
  115             $rs = $oDb->execute($sSQL);
 
  116             if ($rs != 
false && $rs->recordCount() > 0) {
 
  118                     if ($rs->fields[1]) {
 
  119                         $aDataX[] = $rs->fields[0];
 
  120                         $aDataY[] = $rs->fields[1];
 
  126             header(
"Content-type: image/png");
 
  129             $graph = 
new Graph(800, max(640, 20 * count($aDataX)));
 
  130             $graph->setBackgroundImage(
$myConfig->getImageDir(
true) . 
"/reportbgrnd.jpg", BGIMG_FILLFRAME);
 
  133             $graph->setScale(
"textlin");
 
  139             $graph->set90AndMargin($left, $right, $top, $bottom);
 
  142             $graph->xaxis->setLabelAlign(
'right', 
'center', 
'right');
 
  145             $graph->yaxis->setLabelAlign(
'center', 
'bottom');
 
  149             $graph->xaxis->setTickLabels($aDataY);
 
  154             $graph->title->set(
"Suchw�rter");
 
  157             $graph->title->setFont(FF_FONT1, FS_BOLD);
 
  160             $bplot = 
new BarPlot($aDataX);
 
  161             $bplot->setFillGradient(
"navy", 
"lightsteelblue", GRAD_VER);
 
  162             $bplot->setLegend(
"Hits");