report_top_clicked_categories.php

Go to the documentation of this file.
00001 <?php
00002 
00003 if ( !class_exists( "report_top_clicked_categories" ) ) {
00009     class Report_top_clicked_categories extends report_base
00010     {
00016         protected $_sThisTemplate = "report_top_clicked_categories.tpl";
00017 
00023         public function graphToText()
00024         {
00025             $aDataX = array();
00026             $aDataY = array();
00027 
00028             $oSmarty = oxUtilsView::getInstance()->getSmarty();
00029             $sTime_from = date( "Y-m-d H:i:s", strtotime( $oSmarty->_tpl_vars['time_from']));
00030             $sTime_to   = date( "Y-m-d H:i:s", strtotime( $oSmarty->_tpl_vars['time_to']));
00031 
00032             $sSQL = "select count(*) as nrof, oxcategories.oxtitle from oxlogs, oxcategories where oxlogs.oxclass = 'alist' and oxlogs.oxcnid = oxcategories.oxid  and oxlogs.oxtime >= '$sTime_from' and oxlogs.oxtime <= '$sTime_to' group by oxcategories.oxtitle order by nrof desc limit 0, 25";
00033             $rs = oxDb::getDb()->execute( $sSQL);
00034             if ($rs != false && $rs->recordCount() > 0) {
00035                 while (!$rs->EOF) {
00036                     if ( $rs->fields[1]) {
00037                         $aDataX[] = $rs->fields[0];
00038                         $aDataY[] = $rs->fields[1];
00039                     }
00040                     $rs->moveNext();
00041                 }
00042             }
00043             $iMax = 0;
00044             for ($iCtr = 0; $iCtr < count($aDataX); $iCtr++) {
00045                 if ($iMax < $aDataX[$iCtr])
00046                     $iMax = $aDataX[$iCtr];
00047             }
00048 
00049             $aPoints = array();
00050             $aPoints["0"] = 0;
00051             $aAligns["0"] = 'report_searchstrings_scale_aligns_left"';
00052             $iTenth = strlen($iMax) - 1;
00053             if ($iTenth < 1) {
00054                 $iScaleMax = $iMax;
00055                 $aPoints["".(round(($iMax/2))).""] = $iMax/2;
00056                 $aAligns["".(round(($iMax/2))).""] = 'report_searchstrings_scale_aligns_center" width="'.(720/3).'"';
00057                 $aPoints["".$iMax.""] = $iMax;
00058                 $aAligns["".$iMax.""] = 'report_searchstrings_scale_aligns_right" width="'.(720/3).'"';
00059             } else {
00060                 $iDeg = bcpow(10, $iTenth);
00061                 //$iScaleMax = $iDeg * (round($iMax/$iDeg));
00062                 $iScaleMax = $iMax;
00063                 $ctr = 0;
00064                 for ($iCtr = 10; $iCtr>0; $iCtr-- ) {
00065                     $aPoints["".(round(($ctr))).""] = $ctr += $iScaleMax / 10;
00066                     $aAligns["".(round(($ctr))).""] = 'report_searchstrings_scale_aligns_center" width="'.(720/10).'"';
00067                 }
00068                 $aAligns["".(round(($ctr))).""] = 'report_searchstrings_scale_aligns_right" width="'.(720/10).'"';
00069             }
00070 
00071             $aAligns["0"] .= ' width="'.(720/count($aAligns)).'"';
00072 
00073             for ($iCtr = 0; $iCtr < count($aDataY); $iCtr++) {
00074                 $aDataVals[$aDataY[$iCtr]] = round($aDataX[$iCtr]/$iMax*100);
00075             }
00076 
00077             if ( count($aDataY) > 0 )
00078                 $oSmarty->assign( "drawStat", true);
00079             else
00080                 $oSmarty->assign( "drawStat", false);
00081 
00082             $oSmarty->assign( "classes", array ( $aAligns ));
00083             $oSmarty->assign( "allCols", count( $aAligns ));
00084             $oSmarty->assign( "cols", count( $aAligns ) );
00085             $oSmarty->assign( "percents", array ( $aDataVals ) );
00086             $oSmarty->assign( "y", $aDataY );
00087         }
00088 
00094         public function graph1()
00095         {
00096             $myConfig = $this->getConfig();
00097 
00098             $aDataX = array();
00099             $aDataY = array();
00100 
00101             $sTime_from = date( "Y-m-d H:i:s", strtotime( oxConfig::getParameter( "time_from")));
00102             $sTime_to   = date( "Y-m-d H:i:s", strtotime( oxConfig::getParameter( "time_to")));
00103 
00104             $sSQL = "select count(*) as nrof, oxparameter from oxlogs where oxclass = 'search' and oxtime >= '$sTime_from' and oxtime <= '$sTime_to' group by oxparameter order by nrof desc";
00105             $rs = oxDb::getDb()->execute( $sSQL);
00106             if ($rs != false && $rs->recordCount() > 0) {
00107                 while (!$rs->EOF) {
00108                     if ( $rs->fields[1]) {
00109                         $aDataX[] = $rs->fields[0];
00110                         $aDataY[] = $rs->fields[1];
00111                     }
00112                     $rs->moveNext();
00113                 }
00114             }
00115 
00116             header ("Content-type: image/png" );
00117 
00118             // New graph with a drop shadow
00119             $graph = new Graph(800, max( 640, 20*count($aDataX)));
00120             $graph->setBackgroundImage( $myConfig->getAbsAdminImageDir()."/reportbgrnd.jpg", BGIMG_FILLFRAME);
00121 
00122             // Use a "text" X-scale
00123             $graph->setScale("textlin");
00124 
00125             $top = 60;
00126             $bottom = 30;
00127             $left = 80;
00128             $right = 30;
00129             $graph->set90AndMargin($left, $right, $top, $bottom);
00130 
00131             // Label align for X-axis
00132             $graph->xaxis->setLabelAlign('right', 'center', 'right');
00133 
00134             // Label align for Y-axis
00135             $graph->yaxis->setLabelAlign('center', 'bottom');
00136 
00137             $graph->setShadow();
00138             // Description
00139             $graph->xaxis->setTickLabels( $aDataY);
00140 
00141             // Set title and subtitle
00142             $graph->title->set("Suchwörter");
00143 
00144             // Use built in font
00145             $graph->title->setFont(FF_FONT1, FS_BOLD);
00146 
00147             // Create the bar plot
00148             $bplot = new BarPlot( $aDataX);
00149             $bplot->setFillGradient("navy", "lightsteelblue", GRAD_VER);
00150             $bplot->setLegend("Hits");
00151 
00152             $graph->add($bplot);
00153 
00154             // Finally output the  image
00155             $graph->stroke();
00156         }
00157     }
00158 }

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5