Changeset 10264


Ignore:
Timestamp:
Apr 10, 2011, 10:07:47 PM (13 years ago)
Author:
grum
Message:

bug:2146
Compatibility with Piwigo 2.2

Location:
extensions/AStat
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/AStat/astat_aim.class.inc.php

    r5546 r10264  
    1616if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1717
    18 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
     18include_once('astat_root.class.inc.php');
    1919include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
    2020
    21 class AStat_AIM extends CommonPlugin
     21class AStat_AIM extends AStat_root
    2222{
    2323  protected $css = null;
    2424
    25   function AStat_AIM($prefixeTable, $filelocation)
     25  function __construct($prefixeTable, $filelocation)
    2626  {
    27     $this->setPluginName("AStat.2");
    28     $this->setPluginNameFiles("astat");
    2927    parent::__construct($prefixeTable, $filelocation);
    30     $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
    3128  }
    3229
     
    3936  }
    4037
    41 
    42   /*
    43     initialization of config properties
    44   */
    45   function initConfig()
    46   {
    47     $this->config=array(
    48       'AStat_BarColor_Pages' => '6666ff',
    49       'AStat_BarColor_Img' => '66ff66',
    50       'AStat_BarColor_IP' => 'ff6666',
    51       'AStat_MouseOverColor' => '303030',
    52       'AStat_NpIPPerPages' => '25',
    53       'AStat_NpCatPerPages' => '50',
    54       'AStat_MaxBarWidth' => '400',
    55       'AStat_default_period' => 'global', //global, all, year, month, day
    56       'AStat_ShowThumbCat' => 'true',
    57       'AStat_DefaultSortCat' => 'page', //page, picture, nbpicture
    58       'AStat_ShowThumbImg' => 'true',
    59       'AStat_DefaultSortImg' => 'picture',  //picture, catname
    60       'AStat_NbImgPerPages' => '100',
    61       'AStat_BarColor_Cat' => 'fff966',
    62       'AStat_DefaultSortIP' => 'page',    //page, ip, picture
    63       'AStat_SeeTimeRequests' => 'false',
    64       'AStat_BlackListedIP' => '',    // ip blacklisted (separator : ",")
    65       'AStat_UseBlackList' => 'false'    // if false, blacklist usage is disabled, if "invert" then result are inverted
    66       );
    67 
    68   }
    69 
    70   /*
    71     surchage of CommonPlugin->saveConfig function
    72   */
    73   function loadConfig()
    74   {
    75     parent::loadConfig();
    76     if(!$this->css->fileExists())
    77     {
    78       $this->css->makeCSS($this->generate_CSS());
    79     }
    80   }
    81 
    82   /*
    83     surchage of CommonPlugin->saveConfig function
    84   */
    85   function saveConfig()
    86   {
    87     if(parent::saveConfig())
    88     {
    89       $this->css->makeCSS($this->generate_CSS());
    90       return(true);
    91     }
    92     return(false);
    93   }
    94 
    95   /*
    96     generate the css code
    97   */
    98   function generate_CSS()
    99   {
    100     $text = ".AStatBar1, .AStatBar2, .AStatBar3, .AStatBar4, .AStatBarX {
    101       border:0px;
    102       height:8px;
    103       display: block;
    104       margin:0px;
    105       padding:0px;
    106       left:0;
    107       position:relative;
    108       }
    109        .MiniSquare1, .MiniSquare2, .MiniSquare3, .MiniSquare4 {
    110       border:0px;
    111       height:8px;
    112       width:8px;
    113       margin:0px;
    114       padding:0px;
    115       }
    116        .AStatBar1 { background-color:#".$this->config['AStat_BarColor_Pages']."; top:5px;  }
    117        .AStatBar2 { background-color:#".$this->config['AStat_BarColor_Img']."; top:-3px; }
    118        .AStatBar3 { background-color:#".$this->config['AStat_BarColor_IP']."; top:-3px;}
    119        .AStatBar4 { background-color:#".$this->config['AStat_BarColor_Cat']."; top:-3px;}
    120        .AStatBarX { background-color:transparent; top:-3px; height:1px; }
    121        .MiniSquare1 { color:#".$this->config['AStat_BarColor_Pages'].";   }
    122        .MiniSquare2 { color:#".$this->config['AStat_BarColor_Img'].";  }
    123        .MiniSquare3 { color:#".$this->config['AStat_BarColor_IP']."; }
    124        .MiniSquare4 { color:#".$this->config['AStat_BarColor_Cat']."; }
    125        .StatTableRow:hover { background-color:#".$this->config['AStat_MouseOverColor']."; }
    126        .formtable, .formtable P { text-align:left; display:block; }
    127        .formtable tr { vertical-align:top; }
    128        .window_thumb {
    129       position:absolute;
    130       border: none;
    131       background: none;
    132       left:0;
    133       top:0;
    134       margin:0px;
    135       padding:0px;
    136       z-index:100;
    137       overflow:hidden;
    138       visibility:hidden; }
    139         .img_thumb {
    140       border: solid 3px #ffffff;
    141       background: #000000;
    142       margin:0px;
    143       padding:0px; }
    144         .time_request {
    145       font-size:83%;
    146       text-align:right; }
    147         .invisible { visibility:hidden; display:none; }
    148       .littlefont { font-size:90%; }
    149       table.littlefont th { padding:3px; }
    150       table.littlefont td { padding:0px;padding-left:3px;padding-right:3px; }
    151       #iplist { visibility:hidden; position:absolute; width:200px; z-index:1000; }
    152       .iipsellistitem { float:right; }
    153       #iipsellist { width:100%; font-family:monospace; }
    154     ";
    155 
    156     return($text);
    157   }
    158 
    159   /* ---------------------------------------------------------------------------
    160   Function needed for plugin activation
    161   --------------------------------------------------------------------------- */
    162 
    163   /*
    164     get 'section' enumeration from HISTORY_TABLE
    165   */
    166   function get_section_enum($add)
    167   {
    168     $returned=array('', false);
    169     $sql = 'SHOW COLUMNS FROM '.HISTORY_TABLE.' LIKE "section"';
    170     $result=pwg_query($sql);
    171     if($result)
    172     {
    173       $row = pwg_db_fetch_assoc($result);
    174       $list=substr($row['Type'], 5, strlen($row['Type'])-6);
    175       $returned[0]=explode(',', $list);
    176       if((strpos($list, "'$add'")===false)&&($add!=''))
    177       { array_push($returned[0], "'$add'"); }
    178       else
    179       { $returned[1]=true; }
    180       return($returned);
    181     }
    182   }
    183 
    184   function alter_history_section_enum($section)
    185   {
    186     $sections=$this->get_section_enum('deleted_cat');
    187     if(!$sections[1])
    188     {
    189       $enums=implode(',', $sections[0]);
    190       $sql="ALTER TABLE ".HISTORY_TABLE."
    191           CHANGE `section` `section`
    192           ENUM (".$enums.") ;";
    193       $result=pwg_query($sql);
    194       if(!$result)
    195       {
    196         return(false);
    197       }
    198     }
    199     return(true);
    200   }
    201 
    20238} // AStat_Plugin class
    20339
  • extensions/AStat/astat_aip.class.inc.php

    r6699 r10264  
    1515if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1616
    17 include_once('astat_aim.class.inc.php');
     17include_once('astat_root.class.inc.php');
    1818include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    1919include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
    2020
    21 class AStat_AIP extends AStat_AIM
     21class AStat_AIP extends AStat_root
    2222{
    2323  protected $tabsheet;
     
    6565  function initEvents()
    6666  {
    67     add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
     67    add_event_handler('loc_end_page_header', array(&$this, 'applyCSS'));
    6868  }
    6969
     
    7373  Public classe functions
    7474  --------------------------------------------------------------------------- */
     75
     76  public function applyCSS()
     77  {
     78    GPCCore::addHeaderCSS(basename(dirname($this->getPluginNameFiles())), PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'css/'.$this->getPluginNameFiles().".css");
     79  }
     80
     81
    7582
    7683  /*
  • extensions/AStat/astat_version.inc.php

    r6699 r10264  
    1515  if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1616
    17   define('ASTAT_VERSION',  '2.2.2');
    18   define('ASTAT_VERSION2', '02.02.02');
     17  define('ASTAT_VERSION',  '2.3.0');
     18  define('ASTAT_VERSION2', '02.03.00');
     19  define('ASTAT_GPC_NEEDED', '3.5.0');
    1920?>
  • extensions/AStat/main.inc.php

    r6699 r10264  
    22/*
    33Plugin Name: AStat.2
    4 Version: 2.2.2
     4Version: 2.3.0
    55Description: Statistiques avancées / Advanced statistics
    66Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=172
     
    6363|         |            |   Stat by categories doesn't work when IP filter is activated
    6464|         |            |
     65| 2.3.0   | 2011/04/10 | * mantis: bug 2146
     66|         |            |   . compatibility with piwigo 2.2
    6567|         |            |
    6668|         |            |
  • extensions/AStat/maintain.inc.php

    r5546 r10264  
    1717if(!defined('ASTAT_PATH')) define('ASTAT_PATH' , PHPWG_PLUGINS_PATH . ASTAT_DIR . '/');
    1818
    19 include_once('astat_version.inc.php');
     19include_once('astat_version.inc.php'); // => Don't forget to update this file !!
    2020
    21 //ini_set('error_reporting', E_ALL);
    22 //ini_set('display_errors', true);
    2321
    24 global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
     22global $gpcInstalled, $lang; //needed for plugin manager compatibility
    2523
    2624/* -----------------------------------------------------------------------------
    27 AStat-2 needs the Grum Plugin Classe
     25AStat needs the Grum Plugin Classe
    2826----------------------------------------------------------------------------- */
    29 $gpc_installed=false;
    30 $gpcNeeded="3.0.0";
     27$gpcInstalled=false;
    3128if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
    3229{
    3330  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
    34   // need GPC release greater or equal than 3.0.0
    35   if(CommonPlugin::checkGPCRelease(3,0,0))
     31  // need GPC release greater or equal than 3.5.0
     32  if(CommonPlugin::checkGPCRelease(ASTAT_GPC_NEEDED))
    3633  {
    37     @include_once("astat_aim.class.inc.php");
    38     $gpc_installed=true;
     34    include_once("astat_install.class.inc.php");
     35    $gpcInstalled=true;
    3936  }
    4037}
     
    4239function gpcMsgError(&$errors)
    4340{
    44   global $gpcNeeded;
    45   $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
     41  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), ASTAT_GPC_NEEDED);
    4642  if(is_array($errors))
    4743  {
     
    5652
    5753
     54
    5855load_language('plugin.lang', ASTAT_PATH);
     56
     57
     58
    5959
    6060function plugin_install($plugin_id, $plugin_version, &$errors)
    6161{
    62   global $prefixeTable, $gpc_installed, $gpcNeeded;
    63   if($gpc_installed)
     62  global $prefixeTable, $gpcInstalled;
     63  if($gpcInstalled)
    6464  {
    65     $obj = new AStat_AIM($prefixeTable, __FILE__);
    66     $obj->deleteConfig();
    67     $obj->initConfig();
    68     $obj->my_config['installed']=ASTAT_VERSION2;
    69     $obj->saveConfig();
    70     GPCCore::register($obj->getPluginName(), ASTAT_VERSION, $gpcNeeded);
     65    $obj=new AStat_install($prefixeTable, __FILE__);
     66    $result=$obj->install();
    7167  }
    7268  else
     
    7874function plugin_activate($plugin_id, $plugin_version, &$errors)
    7975{
    80   global $prefixeTable, $gpc_installed;
    81   if($gpc_installed)
     76  global $prefixeTable, $gpcInstalled;
     77  if($gpcInstalled)
    8278  {
    83     $obj = new AStat_AIM($prefixeTable, __FILE__);
    84     $obj->initConfig();
    85     $obj->loadConfig();
    86     $obj->my_config['installed']=ASTAT_VERSION2;
    87     $obj->saveConfig();
    88     $obj->alter_history_section_enum('deleted_cat');
    89   }
    90   else
    91   {
    92     gpcMsgError($errors);
     79    $obj=new AStat_install($prefixeTable, __FILE__);
     80    $result=$obj->activate();
    9381  }
    9482}
     
    9684function plugin_deactivate($plugin_id)
    9785{
     86  global $prefixeTable, $gpcInstalled;
     87
     88  if($gpcInstalled)
     89  {
     90    $obj=new AStat_install($prefixeTable, __FILE__);
     91    $obj->deactivate();
     92  }
    9893}
    9994
    10095function plugin_uninstall($plugin_id)
    10196{
    102   global $prefixeTable, $gpc_installed;
    103   if($gpc_installed)
     97  global $prefixeTable, $gpcInstalled;
     98  if($gpcInstalled)
    10499  {
    105     $obj = new AStat_AIM($prefixeTable, __FILE__);
    106     $obj->deleteConfig();
    107     GPCCore::unregister($obj->getPluginName());
     100    $obj=new AStat_install($prefixeTable, __FILE__);
     101    $result=$obj->uninstall();
    108102  }
    109103  else
     
    115109
    116110
     111
     112
    117113?>
Note: See TracChangeset for help on using the changeset viewer.