source: extensions/AMetaData/maintain.inc.php @ 31844

Last change on this file since 31844 was 28817, checked in by Youp3, 10 years ago

Advanced Meta Data : adaptation des fonctions de maintenance du plugin pour adopter les nouveaux standards de Piwigo 2.6+

  • Property svn:executable set to *
File size: 3.2 KB
RevLine 
[4905]1<?php
2/*
3 * -----------------------------------------------------------------------------
4 * Plugin Name: Advanced MetaData
5 * -----------------------------------------------------------------------------
6 * Author     : Grum
7 *   email    : grum@piwigo.org
8 *   website  : http://photos.grum.fr
9 *   PWG user : http://forum.piwigo.org/profile.php?id=3706
10 *
11 *   << May the Little SpaceFrog be with you ! >>
12 *
13 * -----------------------------------------------------------------------------
14 *
15 */
16
17if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
18
19//ini_set('error_reporting', E_ALL);
20//ini_set('display_errors', true);
21
[28817]22function gpcMsgError(&$errors=array())
[4905]23{
[28815]24  $msg=l10n('To install this plugin, you need to install Grum Plugin Classes %s before', AMD_GPC_NEEDED);
[5935]25  if(is_array($errors))
26  {
27    array_push($errors, $msg);
28  }
29  else
30  {
31    $errors=Array($msg);
32  }
[4905]33}
34
[28817]35function amdInit()
36{
37  include_once('amd_version.inc.php'); // => Don't forget to update this file !!
[4905]38
[28817]39  defined('AMD_DIR') || define('AMD_DIR' , basename(dirname(__FILE__)));
40  defined('AMD_PATH') || define('AMD_PATH' , PHPWG_PLUGINS_PATH . AMD_DIR . '/');
41  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCore.class.inc.php');
42  @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
[4905]43
[28817]44  global $gpcInstalled, $lang; //needed for plugin manager compatibility
[4905]45
[28817]46  /* -----------------------------------------------------------------------------
47   * AMD needs the Grum Plugin Classe
48   * -------------------------------------------------------------------------- */
49  $gpcInstalled=false;
50  if(file_exists(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php'))
[4905]51  {
[28817]52    @include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
53    // need GPC release greater or equal than AMD_GPC_NEEDED
54    if(CommonPlugin::checkGPCRelease(AMD_GPC_NEEDED))
55    {
56      @include_once("amd_install.class.inc.php");
57      $gpcInstalled=true;
58    }
[4905]59  }
[28817]60
61  load_language('plugin.lang', AMD_PATH);
[4905]62}
[28817]63// -----------------------------------------------------------------------------
[4905]64
[28817]65
66class AMetaData_maintain extends PluginMaintain
[4905]67{
[28817]68
69  function install($plugin_version, &$errors=array())
[6977]70  {
[28817]71    amdInit();
72
73    global $prefixeTable, $gpcInstalled, $lang;
74
75    if($gpcInstalled)
76    {
77      $amd=new AMD_install($prefixeTable, __FILE__);
78      $result=$amd->install();
79    }
80    else
81    {
82      gpcMsgError($errors);
83    }
[6977]84  }
[4905]85
[28817]86  function activate($plugin_version, &$errors=array())
87  {
88    amdInit();
[6891]89
[28817]90    global $prefixeTable, $gpcInstalled, $lang;
91
92    if($gpcInstalled)
93    {
94      $amd=new AMD_install($prefixeTable, __FILE__);
95      $result=$amd->activate();
96    }
[6977]97  }
[4905]98
[28817]99  function deactivate()
[4905]100  {
[28817]101    amdInit();
102
103    global $prefixeTable, $gpcInstalled, $lang;
104
105    if($gpcInstalled)
106    {
107      $amd=new AMD_install($prefixeTable, __FILE__);
108      $amd->deactivate();
109    }
[4905]110  }
[28817]111
112  function uninstall()
[4905]113  {
[28817]114    amdInit();
115
116    global $prefixeTable, $gpcInstalled, $lang;
117
118    if($gpcInstalled)
119    {
120      $amd=new AMD_install($prefixeTable, __FILE__);
121      $result=$amd->uninstall();
122    }
123    else
124    {
125      gpcMsgError($errors);
126    }
[4905]127  }
[28817]128
[4905]129}
130
131?>
Note: See TracBrowser for help on using the repository browser.