[ Index ]
 

Code source de phpMyVisites 2.3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/core/forms/ -> FormPluginConfig.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: FormPdfConfig.class.php 29 2006-08-18 07:35:21Z matthieu_ $
  11  
  12  
  13  
  14  require_once  INCLUDE_PATH . "/core/forms/Form.class.php";
  15  require_once  INCLUDE_PATH . "/core/include/SiteConfigDb.class.php";
  16  require_once  INCLUDE_PATH . "/core/include/Cookie.class.php";
  17  require_once  INCLUDE_PATH . "/core/include/PdfConfigDb.class.php";
  18  require_once  INCLUDE_PATH . "/libs/Xml/Unserializer.php";
  19  
  20  class FormPluginConfig extends Form
  21  {
  22      var $listAvailablePlugin;
  23      var $configPluginFile;
  24      
  25  	function FormPluginConfig( &$template)
  26      {
  27          parent::Form( $template );
  28          
  29          // Get installed plugins
  30          $this->configPluginFile = &PmvConfig::getInstance("plugin.php", false);
  31          
  32          // Get list available plugins
  33          $dir = PLUGINS_PATH;
  34          $d = dir($dir);
  35          $arDir = array();
  36          
  37          while (false !== ($entry = $d->read())) 
  38          {
  39              if($entry != '.' 
  40                  && $entry != '..'
  41                  && is_dir($dir.$entry)
  42                  && is_file($dir.$entry."/config.xml")) 
  43              {
  44                  $serializer_options = array (
  45                      'addDecl' => TRUE,
  46                      'encoding' => 'UTF-8',
  47                      'indent' => '  ',
  48                      'rootName' => 'plugin',
  49                      'defaultTagName' => 'item',
  50                      'rootAttributes' => array ( 'version' => '1.0'));
  51                  
  52                  
  53                  $unserializer = &new XML_Unserializer($serializer_options);
  54                  if (($res = $unserializer->unserialize($dir.$entry."/config.xml", true)) === true) 
  55                  {
  56                      $conf = $unserializer->getUnserializedData();
  57                      if (isset($this->configPluginFile ->content[$entry])) 
  58                      {
  59                          $conf['pmv_install'] = true;
  60                          $conf['pmv_type'] = $this->configPluginFile ->content[$entry]['type'];
  61                          $conf['pmv_menuModName'] = $this->configPluginFile ->content[$entry]['menuModName'];
  62                      }
  63                      else 
  64                      {
  65                          $conf['pmv_install'] = false;
  66                          $conf['pmv_type'] = $conf['type'];
  67                          $conf['pmv_menuModName'] = $conf['menuModName'];
  68                      }
  69                      
  70                      if ( isset($conf['langPath']) && !empty($conf['langPath'])) 
  71                      {
  72                          Lang::addPluginLangFile ($entry."/".$conf['langPath'], $conf['defaultLang']);
  73                      }
  74                      $arDir[$entry] = $conf;
  75                  }
  76              }
  77          }
  78          $d->close();
  79          $this->listAvailablePlugin = $arDir;
  80      }
  81      
  82  	function process()
  83      {
  84          $listType = array('admin' => 'Admin',
  85                          'menu' => 'Menu',
  86                          'all' => 'All');
  87          $this->tpl->assign('listType', $listType);
  88  
  89          $listMenu = array("view_visits" => 'menu_visites',
  90                          "view_frequency" => 'frequence_titremenu',
  91                          "view_pages" => 'menu_pagesvues',
  92                          "view_followup" => 'menu_suivi',
  93                          "view_source" => 'menu_provenance',
  94                          "view_settings" => 'menu_configurations',
  95                          "view_referers" => 'menu_affluents');
  96          $this->tpl->assign('listMenu', $listMenu);
  97          // Get plugin list
  98          $this->tpl->assign('listPlugin', $this->listAvailablePlugin);
  99  
 100          // launche process
 101          return parent::process('admin_pdf_title');
 102      }
 103      
 104  	function postProcess() {
 105          $tabConfig = array();
 106          foreach ($this->listAvailablePlugin as $key => $value) {
 107              $installPlugin = $this->getSubmitValue("PluginInstall$key");
 108              if ($installPlugin == "true") {
 109                  $tabConfig[$key] = $value;
 110                  $tabConfig[$key]['type'] = $this->getSubmitValue("type$key");
 111                  $tabConfig[$key]['menuModName'] = $this->getSubmitValue("menuModName$key");
 112                  //echo "$key : to install<br>";
 113                  // Install table
 114                  $thereIsNoTable = false;
 115                  if (is_dir(PLUGINS_PATH.$key."/updates")) {
 116                      $db =& Db::getInstance($key);
 117                      $tablesInstalled = $db->getAllInstalledTables();
 118                      // some tables are already in the database
 119                      if(sizeof($tablesInstalled) > 0) {
 120                          $thereIsNoTable = false;
 121                      }
 122                      else {
 123                          $thereIsNoTable = true;
 124                      }
 125                      if($thereIsNoTable) {
 126                          $db->createAllTables();
 127                          $db->setVersion( $tabConfig[$key]['version'] );
 128                      }
 129                      elseif ($db->getVersion() != $tabConfig[$key]['version']){
 130                          $db->updateTables ($tabConfig[$key]['version']);
 131                      }
 132                  }
 133              }
 134              else {
 135                  //echo "$key : to desinstall<br>";
 136              }
 137          }
 138          $this->configPluginFile->content = $tabConfig;
 139          $this->configPluginFile->write();
 140      }
 141  }
 142  ?>


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