Index: /extensions/AMetaData/maintain.inc.php
===================================================================
--- /extensions/AMetaData/maintain.inc.php	(revision 28816)
+++ /extensions/AMetaData/maintain.inc.php	(revision 28817)
@@ -20,31 +20,5 @@
 //ini_set('display_errors', true);
 
-include_once('amd_version.inc.php'); // => Don't forget to update this file !!
-
-
-defined('AMD_DIR') || define('AMD_DIR' , basename(dirname(__FILE__)));
-defined('AMD_PATH') || define('AMD_PATH' , PHPWG_PLUGINS_PATH . AMD_DIR . '/');
-include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCore.class.inc.php');
-include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
-
-
-global $gpcInstalled, $lang; //needed for plugin manager compatibility
-
-/* -----------------------------------------------------------------------------
- * AMD needs the Grum Plugin Classe
- * -------------------------------------------------------------------------- */
-$gpcInstalled=false;
-if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
-{
-  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
-  // need GPC release greater or equal than AMD_GPC_NEEDED
-  if(CommonPlugin::checkGPCRelease(AMD_GPC_NEEDED))
-  {
-    @include_once("amd_install.class.inc.php");
-    $gpcInstalled=true;
-  }
-}
-
-function gpcMsgError(&$errors)
+function gpcMsgError(&$errors=array())
 {
   $msg=l10n('To install this plugin, you need to install Grum Plugin Classes %s before', AMD_GPC_NEEDED);
@@ -58,60 +32,100 @@
   }
 }
+
+function amdInit()
+{
+  include_once('amd_version.inc.php'); // => Don't forget to update this file !!
+
+  defined('AMD_DIR') || define('AMD_DIR' , basename(dirname(__FILE__)));
+  defined('AMD_PATH') || define('AMD_PATH' , PHPWG_PLUGINS_PATH . AMD_DIR . '/');
+  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCore.class.inc.php');
+  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
+
+  global $gpcInstalled, $lang; //needed for plugin manager compatibility
+
+  /* -----------------------------------------------------------------------------
+   * AMD needs the Grum Plugin Classe
+   * -------------------------------------------------------------------------- */
+  $gpcInstalled=false;
+  if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
+  {
+    @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
+    // need GPC release greater or equal than AMD_GPC_NEEDED
+    if(CommonPlugin::checkGPCRelease(AMD_GPC_NEEDED))
+    {
+      @include_once("amd_install.class.inc.php");
+      $gpcInstalled=true;
+    }
+  }
+
+  load_language('plugin.lang', AMD_PATH);
+}
 // -----------------------------------------------------------------------------
 
 
+class AMetaData_maintain extends PluginMaintain
+{
 
-load_language('plugin.lang', AMD_PATH);
+  function install($plugin_version, &$errors=array())
+  {
+    amdInit();
 
-function plugin_install($plugin_id, $plugin_version, &$errors)
-{
-  global $prefixeTable, $gpcInstalled;
-  if($gpcInstalled)
+    global $prefixeTable, $gpcInstalled, $lang;
+
+    if($gpcInstalled)
+    {
+      $amd=new AMD_install($prefixeTable, __FILE__);
+      $result=$amd->install();
+    }
+    else
+    {
+      gpcMsgError($errors);
+    }
+  }
+
+  function activate($plugin_version, &$errors=array())
   {
-    $amd=new AMD_install($prefixeTable, __FILE__);
-    $result=$amd->install();
+    amdInit();
+
+    global $prefixeTable, $gpcInstalled, $lang;
+
+    if($gpcInstalled)
+    {
+      $amd=new AMD_install($prefixeTable, __FILE__);
+      $result=$amd->activate();
+    }
   }
-  else
+
+  function deactivate()
   {
-    gpcMsgError($errors);
+    amdInit();
+
+    global $prefixeTable, $gpcInstalled, $lang;
+
+    if($gpcInstalled)
+    {
+      $amd=new AMD_install($prefixeTable, __FILE__);
+      $amd->deactivate();
+    }
   }
+
+  function uninstall()
+  {
+    amdInit();
+
+    global $prefixeTable, $gpcInstalled, $lang;
+
+    if($gpcInstalled)
+    {
+      $amd=new AMD_install($prefixeTable, __FILE__);
+      $result=$amd->uninstall();
+    }
+    else
+    {
+      gpcMsgError($errors);
+    }
+  }
+
 }
 
-function plugin_activate($plugin_id, $plugin_version, &$errors)
-{
-  global $prefixeTable, $gpcInstalled;
-  if($gpcInstalled)
-  {
-    $amd=new AMD_install($prefixeTable, __FILE__);
-    $result=$amd->activate();
-  }
-}
-
-function plugin_deactivate($plugin_id)
-{
-  global $prefixeTable, $gpcInstalled;
-
-  if($gpcInstalled)
-  {
-    $amd=new AMD_install($prefixeTable, __FILE__);
-    $amd->deactivate();
-  }
-}
-
-function plugin_uninstall($plugin_id)
-{
-  global $prefixeTable, $gpcInstalled;
-  if($gpcInstalled)
-  {
-    $amd=new AMD_install($prefixeTable, __FILE__);
-    $result=$amd->uninstall();
-  }
-  else
-  {
-    gpcMsgError($errors);
-  }
-}
-
-
-
 ?>
