[ Index ]
 

Code source de phpMyVisites 2.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/core/views/ -> ViewGraph.class.php (source)

   1  <?php
   2  /* 
   3   * phpMyVisites : website statistics and audience measurements
   4   * Copyright (C) 2002 - 2006
   5   * http://www.phpmyvisites.net/ 
   6   * phpMyVisites is free software (license GNU/GPL)
   7   * Authors : phpMyVisites team
   8  */
   9  
  10  // $Id: ViewGraph.class.php 39 2006-08-20 18:02:29Z cmil $
  11  
  12  
  13  require_once  INCLUDE_PATH."/core/include/ViewModule.class.php";
  14  
  15  class ViewGraph extends ViewModule
  16  {
  17      var $graph;
  18      var $graph_type;
  19      var $graph_data;
  20      
  21  	function ViewGraph()
  22      {
  23          $this->width = 0;
  24          $this->height = 0;
  25          $this->showLabelBar2 = true;
  26      }
  27  
  28      /**
  29       * module initialization tasks
  30       *
  31       * @param object $request
  32       * @param object $tpl Template instance
  33       * 
  34       * @return void
  35       */
  36      function init(&$request, $tpl = null, $o_archive = null, $p_graphType = null, $p_graphdata = null) {
  37          ViewModule::init($request, $tpl, $o_archive);
  38  
  39          if ($p_graphType == null) {
  40              $this->graph_type = Request::getGraphType();
  41          }
  42          else {
  43              $this->graph_type = $p_graphType;
  44          }
  45          if ($p_graphdata == null) {
  46              $this->graph_data = Request::getGraphData();
  47          }
  48          else {
  49              $this->graph_data = $p_graphdata;
  50          }
  51      }
  52          
  53  	function graphFactory()
  54      {
  55          /*        
  56          (1) barres verticales + courbe
  57          (2) barres verticales simples
  58          (3) camembert 3D 
  59          (4) camembert 2D à plat
  60          (5) barres verticales splittées en 2 valeurs
  61          (6) graphique a barres verticales avec plusieurs profondeurs
  62          */
  63          
  64          $graphAsked = $this->graph_type; //Request::getGraphType();
  65          switch($graphAsked)
  66          {
  67              case 1:
  68                  require_once  INCLUDE_PATH."/core/include/graphs/GraphBarAndCurb.class.php";
  69                  $graph = new GraphBarAndCurb($this->width == 0 ? 580 : $this->width, 
  70                                          $this->height == 0 ? 250 : $this->height,
  71                                          $this->showLabelBar2
  72                                          );
  73              break;
  74              
  75              case 2:
  76                  require_once  INCLUDE_PATH."/core/include/graphs/GraphVerticalBar.class.php";
  77                  $graph = new GraphVerticalBar($this->width == 0 ? 500 : $this->width, 
  78                                          $this->height == 0 ? 230 : $this->height
  79                                          );
  80              break;
  81              
  82              case 3:
  83                  require_once  INCLUDE_PATH."/core/include/graphs/Graph3DPie.class.php";
  84                  $graph = new Graph3DPie($this->width == 0 ? 400 : $this->width, 
  85                                          $this->height == 0 ? 250 : $this->height
  86                                          );
  87              break;
  88              
  89              case 4:
  90                  require_once  INCLUDE_PATH."/core/include/graphs/Graph3DPie.class.php";
  91                  $graph = new Graph3DPie($this->width == 0 ? 400 : $this->width, 
  92                                          280,
  93                                          false
  94                                          );
  95              break;
  96              
  97              case 5:
  98                  require_once  INCLUDE_PATH."/core/include/graphs/GraphSplitBar.class.php";
  99                  $graph = new GraphSplitBar($this->width == 0 ? 600 : $this->width, 
 100                                          $this->height == 0 ? 250 : $this->height,
 101                                          $this->showLabelBar2);
 102              break;
 103              
 104              default:
 105                  exit();
 106              break;
 107          }
 108          return $graph;
 109      }
 110      
 111  	function moduleDataFactory()
 112      {
 113          $dataAsked = $this->graph_data; // Request::getGraphData();
 114          switch($dataAsked)
 115          {
 116              /**
 117               * Visits
 118               */
 119              case 'visits_period_summaries':
 120                  $data = $this->data->getVisitsPeriodSummariesGraph();
 121                  
 122                  if($this->data->archive->periodType == DB_ARCHIVES_PERIOD_WEEK)
 123                  {
 124                      $data['interval'] = true;
 125                  }
 126                  else
 127                  {
 128                      $data['interval'] = false;
 129                  }
 130              break;
 131              case 'visits_server_time':
 132                  $data = $this->data->getVisitsServerTimeGraph();
 133              break;
 134              case 'visits_local_time':
 135                  $data = $this->data->getVisitsLocalTimeGraph();
 136              break;
 137              case 'visits_time':
 138                  $data = $this->data->getVisitsTimeVisitsGraph();
 139              break;
 140              
 141              case 'visits_all_period_summary':
 142                  $data = $this->data->getVisitsAllPeriodSummaryGraph();
 143                  $data['title'] = $GLOBALS['lang']['visites_longterm_statd'];
 144                  $this->width = 680;
 145                  if($this->data->archive->periodType==DB_ARCHIVES_PERIOD_MONTH)
 146                  {
 147                      $data['title'] = $GLOBALS['lang']['visites_longterm_statm'];
 148                      $data['interval'] = true;
 149                      $this->width += 100;
 150                  }
 151              break;
 152              
 153              /**
 154               * Pages
 155               */
 156              case 'pages_by_visit':
 157                  $this->width = 640;
 158                  $data = $this->data->getPagesByVisitGraph();
 159              break;
 160              
 161              /**
 162               * Frequency
 163               */
 164              case 'visits_by_visitor':
 165                  $data = $this->data->getVisitsFrequencyVisitsByVisitor();
 166              break;
 167              
 168              case 'frequency_new_vs_returning':
 169                  $data = $this->data->getVisitsFrequencyNewReturningGraph();
 170  
 171                  if($this->data->archive->periodType == DB_ARCHIVES_PERIOD_MONTH
 172                      || $this->data->archive->periodType == DB_ARCHIVES_PERIOD_DAY)
 173                  {
 174                      $this->showLabelBar2 = false;
 175                  }
 176                  else
 177                  {
 178                      $this->showLabelBar2 = true;
 179                  }
 180              break;
 181              /**
 182               * Source
 183               */
 184              case 'source_countries':
 185                  $data = $this->data->getSourceCountriesGraph();
 186              break;
 187              
 188              /**
 189               * Settings
 190               */
 191              case 'settings_browsers':
 192                  $data = $this->data->getSettingsBrowsersGraph();
 193              break;
 194              case 'settings_os':
 195                  $data = $this->data->getSettingsOsGraph();
 196              break;
 197              case 'settings_browsers_type':
 198                  $this->width = 500;
 199                  $data = $this->data->getSettingsBrowsersTypeGraph();
 200              break;
 201              case 'settings_resolutions':
 202                  $data = $this->data->getSettingsResolutionsGraph();
 203              break;
 204              case 'settings_plugins':
 205                  $data = $this->data->getSettingsPluginsGraph();
 206              break;
 207              
 208              /**
 209               * Referers
 210               */
 211              case 'referers_summary':
 212                  $data = $this->data->getReferersSummaryGraph();
 213              break;
 214              
 215              /**
 216               * Sites summary
 217               */
 218              case 'sites_summary':
 219                  $data = $this->data->getSitesSummaryStatisticsGraph();
 220              break;
 221          }
 222          return $data;
 223      }
 224      
 225  	function process()
 226      {
 227          $data = $this->moduleDataFactory();
 228          $this->graph = $this->graphFactory();
 229          $this->graph->setData( $data );
 230          $this->graph->process();
 231      }
 232  	function showAll()
 233      {        
 234          $this->process();
 235          $this->graph->display();
 236      }
 237  }
 238  ?>


Généré le : Mon Nov 26 14:10:01 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics