Changeset 5549


Ignore:
Timestamp:
Apr 1, 2010, 9:06:01 PM (11 years ago)
Author:
grum
Message:

Update the plugin for compatibility with Piwigo 2.1

Location:
extensions/UserStat
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserStat/admin/plugin_admin.php

    r4270 r5549  
    2222$main_plugin_object = get_plugin_data($plugin_id);
    2323
    24 $plugin_ai = new UserStat_AIP($prefixeTable, $main_plugin_object->get_filelocation());
     24$plugin_ai = new UserStat_AIP($prefixeTable, $main_plugin_object->getFileLocation());
    2525$plugin_ai->manage();
    2626
  • extensions/UserStat/language/fr_FR/plugin.lang.php

    r4270 r5549  
    5050$lang['us_withMail'] = 'Avec eMail';
    5151
     52//1.1.0
     53$lang['To install this plugin, you need to install Grum Plugin Classes %s before'] = 'Pour installer ce plugin, vous devez au préalable, installer le plugin Grum Plugin Classes %s';
     54
    5255
    5356?>
  • extensions/UserStat/main.inc.php

    r5433 r5549  
    5454define('USERSTAT_PATH' , PHPWG_PLUGINS_PATH . USERSTAT_DIR . '/');
    5555
    56 define('USERSTAT_VERSION' , '1.1.0'); // => ne pas oublier la version dans l'entête !!
     56include_once('userstat_version.inc.php'); // => Don't forget to update this file !!
    5757
    5858global $prefixeTable;
     
    6464
    6565  $obj = new UserStat_AIM($prefixeTable, __FILE__);
    66   $obj->init_events();
     66  $obj->initEvents();
    6767  set_plugin_data($plugin['id'], $obj);
    6868}
  • extensions/UserStat/maintain.inc.php

    r5433 r5549  
    1414//ini_set('display_errors', true);
    1515
     16include_once('userstat_version.inc.php'); // => Don't forget to update this file !!
     17
    1618if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1719
     
    2022
    2123
    22 global $gpc_installed, $lang; //needed for plugin manager compatibility
     24global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
    2325
    2426/* -----------------------------------------------------------------------------
     
    2628----------------------------------------------------------------------------- */
    2729$gpc_installed=false;
    28 if(file_exists(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php'))
     30$gpcNeeded="3.0.0";
     31if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
    2932{
    30   @include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/main.inc.php');
    31   // need GPC release greater or equal than 2.0.5
    32   if(checkGPCRelease(2,0,5))
     33  @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))
    3336  {
    3437    @include_once("userstat_aim.class.inc.php");
     
    3942function gpcMsgError(&$errors)
    4043{
    41   array_push($errors, sprintf(l10n('us_gpc2_not_installed'), "2.0.5"));
     44  global $gpcNeeded;
     45  $msg=sprintf(l10n('To install this plugin, you need to install Grum Plugin Classes %s before'), $gpcNeeded);
     46  if(is_array($errors))
     47  {
     48    array_push($errors, $msg);
     49  }
     50  else
     51  {
     52    $errors=Array($msg);
     53  }
    4254}
    4355// -----------------------------------------------------------------------------
     
    4860function plugin_install($plugin_id, $plugin_version, &$errors)
    4961{
    50   global $prefixeTable, $gpc_installed;
     62  global $prefixeTable, $gpc_installed, $gpcNeeded;
    5163  if($gpc_installed)
    5264  {
    5365    $obj = new UserStat_AIM($prefixeTable, __FILE__);
    54     $obj->delete_config();
    55     $obj->init_config();
    56     $obj->save_config();
     66    $obj->deleteConfig();
     67    $obj->initConfig();
     68    $obj->my_config['installed']=USERSTAT_VERSION2;
     69    $obj->saveConfig();
     70    GPCCore::register($obj->getPluginName(), USERSTAT_VERSION, $gpcNeeded);
    5771  }
    5872  else
     
    6478function plugin_activate($plugin_id, $plugin_version, &$errors)
    6579{
    66   global $prefixeTable, $gpc_installed;
     80  global $prefixeTable, $gpc_installed, $gpcNeeded;
    6781  if($gpc_installed)
    6882  {
    6983    $obj = new UserStat_AIM($prefixeTable, __FILE__);
    70     $obj->init_config();
    71     $obj->load_config();
    72     $obj->save_config();
     84    $obj->initConfig();
     85    $obj->loadConfig();
     86    $obj->my_config['installed']=USERSTAT_VERSION2;
     87    $obj->saveConfig();
    7388  }
    7489  else
     
    88103  {
    89104    $obj = new UserStat_AIM($prefixeTable, __FILE__);
    90     $obj->delete_config();
     105    $obj->deleteConfig();
     106    GPCCore::unregister($obj->getPluginName());
    91107  }
    92108  else
  • extensions/UserStat/userstat_aim.class.inc.php

    r4270 r5549  
    1616if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
    1717
    18 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/common_plugin.class.inc.php');
    19 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/css.class.inc.php');
     18include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
     19include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
    2020
    21 class UserStat_AIM extends common_plugin
     21class UserStat_AIM extends CommonPlugin
    2222{
    2323  protected $css = null;
    2424
    25   function UserStat_AIM($prefixeTable, $filelocation)
     25  public function __construct($prefixeTable, $filelocation)
    2626  {
    27     $this->plugin_name="UserStat";
    28     $this->plugin_name_files="userstat";
     27    $this->setPluginName("UserStat");
     28    $this->setPluginNameFiles("userstat");
    2929    parent::__construct($prefixeTable, $filelocation);
    30     $this->css = new css(dirname($this->filelocation).'/'.$this->plugin_name_files.".css");
     30    $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
     31  }
     32
     33  public function __destruct()
     34  {
     35    unset($this->css);
     36    parent::__destruct();
    3137  }
    3238
     
    3440    initialize events call for the plugin
    3541  */
    36   function init_events()
     42  function initEvents()
    3743  {
    38     add_event_handler('get_admin_plugin_menu_links', array(&$this, 'plugin_admin_menu') );
     44    add_event_handler('get_admin_plugin_menu_links', array(&$this, 'pluginAdminMenu') );
    3945  }
    4046
     
    4349    initialization of config properties
    4450  */
    45   function init_config()
     51  function initConfig()
    4652  {
    47     $this->my_config=array(
     53    $this->config=array(
    4854      'UserStat_MouseOverColor' => '303030',
    4955      /*'AStat_BarColor_Pages' => '6666ff',
     
    6975
    7076  /*
    71     surchage of common_plugin->save_config function
     77    surchage of CommonPlugin->saveConfig function
    7278  */
    73   function load_config()
     79  function loadConfig()
    7480  {
    75     parent::load_config();
    76     if(!$this->css->css_file_exists())
     81    parent::loadConfig();
     82    if(!$this->css->fileExists())
    7783    {
    78       $this->css->make_CSS($this->generate_CSS());
     84      $this->css->makeCSS($this->generate_CSS());
    7985    }
    8086  }
    8187
    8288  /*
    83     surchage of common_plugin->save_config function
     89    surchage of CommonPlugin->saveConfig function
    8490  */
    85   function save_config()
     91  function saveConfig()
    8692  {
    87     if(parent::save_config())
     93    if(parent::saveConfig())
    8894    {
    89       $this->css->make_CSS($this->generate_CSS());
     95      $this->css->makeCSS($this->generate_CSS());
    9096      return(true);
    9197    }
     
    99105  {
    100106    $text = "
    101 .StatTableRow:hover { background-color:#".$this->my_config['UserStat_MouseOverColor']."; }
     107.StatTableRow:hover { background-color:#".$this->config['UserStat_MouseOverColor']."; }
    102108.formtable, .formtable P { text-align:left; display:block; }
    103109.formtable tr { vertical-align:top; }
  • extensions/UserStat/userstat_aip.class.inc.php

    r5433 r5549  
    1717include_once('userstat_aim.class.inc.php');
    1818include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
    19 include_once(PHPWG_PLUGINS_PATH.'grum_plugins_classes-2/ajax.class.inc.php');
     19include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
    2020
    2121class UserStat_AIP extends UserStat_AIM
    2222{
    2323  protected $tabsheet;
    24   protected $ajax;
    25 
    26   function UserStat_AIP($prefixeTable, $filelocation)
     24
     25  public function __construct($prefixeTable, $filelocation)
    2726  {
    2827    parent::__construct($prefixeTable, $filelocation);
    2928
    30     $this->load_config();
    31     $this->init_events();
     29    $this->loadConfig();
     30    $this->initEvents();
    3231
    3332    $this->tabsheet = new tabsheet();
    3433    $this->tabsheet->add('global_stats',
    3534                          l10n('us_tsGlobal'),
    36                           $this->page_link.'&fUserStat_tabsheet=global_stats');
     35                          $this->getAdminLink().'&fUserStat_tabsheet=global_stats');
    3736    $this->tabsheet->add('users_stats',
    3837                          l10n('us_tsUsers'),
    39                           $this->page_link.'&fUserStat_tabsheet=users_stats');
    40 
    41     $this->ajax = new Ajax();
     38                          $this->getAdminLink().'&fUserStat_tabsheet=users_stats');
     39  }
     40
     41  public function __destruct()
     42  {
     43    unset($this->tabsheet);
     44    parent::__destruct();
    4245  }
    4346
     
    4548    initialize events call for the plugin
    4649  */
    47   function init_events()
    48   {
    49     add_event_handler('loc_end_page_header', array(&$this->css, 'apply_CSS'));
     50  function initEvents()
     51  {
     52    add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
    5053  }
    5154
     
    112115          break;
    113116      }
    114       //$template->
    115       $this->ajax->return_result($result);
     117      GPCAjax::returnResult($result);
    116118    }
    117119  }
     
    154156    $template_datas = array();
    155157
    156     $template_datas["ajaxUrl"] = $this->page_link;
     158    $template_datas["ajaxUrl"] = $this->getAdminLink();
    157159    $template_datas["users"] = $this->getUsersGlobalStats();
    158160
     
    526528    $local_tpl = new Template(USERSTAT_PATH."admin/", "");
    527529    $local_tpl->set_filename('body_page',
    528                   dirname($this->filelocation).'/admin/userstat_userstat.tpl');
     530                  dirname($this->getFileLocation()).'/admin/userstat_userstat.tpl');
    529531
    530532    $template_datas["list"] = $this->makeUserStats($userId);
Note: See TracChangeset for help on using the changeset viewer.