report_searchstrings.php

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

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5