report_top_clicked_categories.php

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

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5