[ 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/ -> ViewDataArray.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: ViewDataArray.class.php 29 2006-08-18 07:35:21Z matthieu_ $
  11  
  12  
  13  require_once  INCLUDE_PATH."/core/include/ViewModule.class.php";
  14  
  15  class ViewDataArray extends ViewModule
  16  {
  17      var $a_lang;
  18      
  19      var $a_idToIdForSort;
  20      
  21      var $a_toRemoveFromMethodNameToGetId;
  22      
  23      var $a_allLimitArrayData;
  24      
  25      
  26  	function ViewDataArray( $o_data = null )
  27      {
  28         
  29          parent::ViewModule( "", $o_data );
  30          
  31      }
  32      
  33  	function init($request, $tpl = null)
  34      {
  35          parent::init($request, $tpl);
  36          
  37          $this->a_lang = array(
  38              'refererssearchengines' => 'affluents_moteurs',
  39              'refererssearchenginesinterest' => 'affluents_moteurs',
  40              'refererskeywords' => 'affluents_motscles',
  41              'refererskeywordsinterest' => 'affluents_motscles',
  42              'refererssites' => 'affluents_sitesinternet',
  43              'refererssitesinterest' => 'affluents_sitesinternet',
  44              'refererspartners' => 'affluents_partenaires',
  45              'refererspartnersinterest' => 'affluents_partenaires',
  46              'referersnewsletters' => 'affluents_newsletters',
  47              'referersnewslettersinterest' => 'affluents_newsletters',
  48              'refererspartners' => 'affluents_partenaires',
  49              'refererspartnersinterest' => 'affluents_partenaires',
  50              'referersnewsletters' => 'affluents_newsletters',
  51              'referersnewslettersinterest' => 'affluents_newsletters',
  52              'refererstypeinterest' => 'affluents_type',
  53              
  54              'settingsconfig' => 'configurations_configurations',
  55              'settingsos' => 'configurations_os',
  56              'settingsosinterest' => 'configurations_os',
  57              'settingsbrowserstype' => 'configurations_navigateursbytype',
  58              'settingsbrowsers' => 'configurations_navigateurs',
  59              'settingsbrowsersinterest' => 'configurations_navigateurs',
  60              'settingsplugins' => 'configurations_plugins',
  61              'settingsresolutions' => 'configurations_resolutions',
  62              'settingsresolutionsinterest' => 'configurations_resolutions',
  63              'settingsnormalwidescreen' => 'configurations_rapport',
  64              
  65              'sourcecountries' => 'provenance_recappays',
  66              'sourcecontinentcountries' => 'provenance_continent',
  67              'sourcecountriesinterest' => 'provenance_recappays',
  68              'sourceproviders' => 'provenance_provider',
  69              
  70              );
  71              
  72          $this->a_idToIdForSort = array(
  73              'os' => 'int',
  74              'browsers' => 'int',
  75              'resolutions' => 'int',
  76              'countries' => 'int',
  77              'searchengines' => 'searchengine', 
  78              'keywords' => 'keyword',
  79              'sites' => 'site',
  80              'partners' => 'partner',
  81              'newsletters' => 'newsletter',
  82              'type' => 'type'
  83              );
  84              
  85          $this->a_toRemoveFromMethodNameToGetId = array(
  86              'interest',
  87              'settings',
  88              'referers',
  89              'source'
  90              );
  91              
  92          // for those non specified, take default value (10)
  93          $this->a_allLimitArrayData = array(
  94                  'settingsconfig' => 3,
  95                  'refererskeywords' => 15,
  96              );
  97  
  98          
  99      }
 100      
 101  	function showAll( $methodToUse = null,  $return = false, $externalCall = false)
 102      {
 103           if ($externalCall)
 104           {
 105               $oldModule = $this->request->getModuleName();
 106               $this->request->setModuleName('view_data_array');
 107           }
 108             
 109             
 110          // case call from ajax, no parameters set
 111          if(is_null($methodToUse)) 
 112          {
 113              $methodToUse = $this->request->getMethodName();
 114          }
 115          
 116          $this->request->method_name = $methodToUse;
 117  
 118          
 119          $idToAssign = $methodToUse;
 120          $idDetailsAsked = $this->request->getIdDetails();
 121          
 122          if($methodToUse == 'sourcecontinentcountries')
 123          {
 124              $idDetailsContinentAsked = $this->request->getContinentZoom();
 125              if($idDetailsContinentAsked)
 126              {
 127                  $parameters[] = $idDetailsContinentAsked;
 128                  $this->a_lang['sourcecontinentcountries'] = 'provenance_recappays';
 129                  $this->tpl->assign("continent_asked", $idDetailsContinentAsked);
 130              }
 131          }
 132          
 133          // asked for a detail subtable in referers
 134          if($idDetailsAsked)
 135          {
 136              $parameters[] = $idDetailsAsked;
 137              //print("Asked id : $idDetailsAsked");
 138              $this->viewTemplate =  "common/data_array_details.tpl";
 139              $nameTemplateVariable = "zoom";
 140  
 141          }
 142          // asked for classic data table, or interest table
 143          else
 144          {
 145              // generic name of smarty var is data
 146              $nameTemplateVariable = "data";
 147              
 148              // if asked for a referer table
 149              if(substr_count( $methodToUse, 'interest') > 0)
 150              {
 151                  $this->viewTemplate = "common/data_array_interest.tpl";
 152                  $idToAssign = str_replace($this->a_toRemoveFromMethodNameToGetId, '', $methodToUse);
 153          
 154              }
 155              // asked for a classic table
 156              else
 157              {                
 158                  $this->viewTemplate = "common/data_array.tpl";
 159              }
 160          }
 161  
 162  
 163          // get offset (0 by default)
 164          $offset = $this->request->getOffset();
 165          $parameters[] = $offset;
 166          
 167          // nb element max
 168          if(isset($this->a_allLimitArrayData[$idToAssign]))
 169          {
 170              $dataLimit = $this->a_allLimitArrayData[$idToAssign];
 171              
 172          }
 173          else
 174          {
 175              $dataLimit = NB_ELEMENTS_TO_DISPLAY;
 176          }
 177          
 178          $parameters[] = $dataLimit;
 179          
 180      
 181          $methodsToCall = array(
 182              $methodToUse => $parameters, // get main data from DataModel method
 183          );
 184          // empty when defaut GET value used (empty) in getRequestVar for method_name
 185          
 186          // case we have interest in method to use, remove interest 
 187          // from method name to get getDistinct type method name
 188  
 189          if(!empty($methodToUse)) 
 190          {
 191              $methodToUseDistinct = str_replace('interest', '', $methodToUse)  . "distinct";
 192              // if get distinct method exists, when necessary (when there can be many elements)
 193              if(method_exists( $this->data , 'get'.$methodToUseDistinct))
 194              {
 195                  // we don't specify id details because its saved during the main process
 196                  // then the distinct value is simply read
 197                  $methodsToCall[$methodToUseDistinct] = array();
 198              }
 199              else
 200              {
 201                  print("<br>Method <b>get$methodToUseDistinct</b> does not exist !");
 202              }
 203              //printDebug($methodsToCall);
 204              $a_value = $this->getDataMethod( $methodsToCall , true );
 205          }
 206  
 207          // case there is a nb_elements, when there can be several pages
 208          if(isset($a_value[$methodToUseDistinct]))
 209          {
 210              $this->tpl->assign( "nb_elements", $a_value[$methodToUseDistinct]);
 211          }
 212                  
 213          // set smarty variable containing data
 214          $this->tpl->assign( $nameTemplateVariable, $a_value[$methodToUse]);
 215          $this->tpl->assign( "offset", $offset);
 216          $this->tpl->assign( "id", $idToAssign);
 217          $this->tpl->assign( "id_details", $idDetailsAsked);
 218          
 219          // case id for interest setted
 220          if(isset($this->a_idToIdForSort[$idToAssign]))
 221          {
 222              $this->tpl->assign( "id_sort", $this->a_idToIdForSort[$idToAssign]);
 223          }
 224          
 225          
 226          $this->tpl->assign('path', array(
 227                          // generic 
 228                          'theme'                     => DIR_IMG_THEMES,
 229                          
 230                          // source
 231                          'sourcecountries'             => DIR_IMG_COUNTRIES_FLAGS,
 232                          'countries'                 => DIR_IMG_COUNTRIES_FLAGS,
 233                          'sourcecontinentcountries'     => DIR_IMG_COUNTRIES_FLAGS,
 234                          
 235                          // referers
 236                          'refererssearchengines'     => DIR_IMG_SEARCH_ENGINES,
 237                          'refererskeywordsdetails'     => DIR_IMG_SEARCH_ENGINES,
 238                          'searchengines'             => DIR_IMG_SEARCH_ENGINES,
 239                          
 240                          // settings
 241                          'settingsos'                 => DIR_IMG_OS,
 242                          'os'                         => DIR_IMG_OS,
 243                          'settingsbrowsers'             => DIR_IMG_BROWSERS,
 244                          'browsers'                     => DIR_IMG_BROWSERS,
 245                          'settingsplugins'             => DIR_IMG_PLUGINS,
 246                          'plugins'                     => DIR_IMG_PLUGINS,
 247                          'settingsnormalwidescreen'     => DIR_IMG_SCREENS,
 248                          'normalwidescreen'             => DIR_IMG_SCREENS,
 249                          )
 250                      );
 251          
 252          $this->tpl->assign("data_limit", $dataLimit);
 253          
 254          // for details
 255          if(strpos($methodToUse, 'details') === false)
 256          {
 257              $this->tpl->assign( "headline", $GLOBALS['lang'][$this->a_lang[$methodToUse]] );
 258          }
 259          if ($return)
 260          {
 261              return $this->fetch($this->viewTemplate, $this->request, $methodToUse);
 262          }
 263          else 
 264          {
 265              $this->tpl->setTemplate($this->viewTemplate);
 266              $this->display(); 
 267              return true;
 268          }
 269      }
 270  }
 271  ?>


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