Index: /extensions/lmt/admin/plugin_admin.php
===================================================================
--- /extensions/lmt/admin/plugin_admin.php	(revision 7559)
+++ /extensions/lmt/admin/plugin_admin.php	(revision 7560)
@@ -14,7 +14,6 @@
 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
 
-include(LMT_PATH."lmt_aip.class.inc.php");
+global $prefixeTable;
 
-global $prefixeTable;
 
 load_language('plugin.lang', LMT_PATH);
@@ -22,5 +21,41 @@
 $main_plugin_object = get_plugin_data($plugin_id);
 
-$plugin_aip = new LMT_AIP($prefixeTable, $main_plugin_object->getFileLocation());
+
+if(CommonPlugin::checkGPCRelease(LMT_GPC_NEEDED))
+{
+  $config=Array();
+  GPCCore::loadConfig('lmt', $config);
+
+
+  if($config['installed']!=LMT_VERSION2)
+  {
+    /* the plugin was updated without being deactivated
+     * deactivate + activate the plugin to process the database upgrade
+     */
+    include(LMT_PATH."lmt_install.class.inc.php");
+    $obj=new LMT_Install($prefixeTable, dirname(__FILE__));
+    $obj->deactivate();
+    $obj->activate();
+    $template->delete_compiled_templates();
+    //$config['newInstall']='n';
+  }
+
+  include(LMT_PATH."lmt_aip.class.inc.php");
+  $plugin_aip = new LMT_AIP($prefixeTable, $main_plugin_object->getFileLocation());
+}
+else
+{
+  /*
+   * plugin was upgraded, but GPC was not
+   * display a page to inform user to upgrade GPC
+   */
+  include(LMT_PATH."lmt_aip_release.class.inc.php");
+  $plugin_aip = new LMT_AIPRelease($prefixeTable, $main_plugin_object->getFileLocation());
+}
+
+
+
+
 $plugin_aip->manage();
+
 ?>
Index: /extensions/lmt/admin/plugin_admin_list.tpl
===================================================================
--- /extensions/lmt/admin/plugin_admin_list.tpl	(revision 7559)
+++ /extensions/lmt/admin/plugin_admin_list.tpl	(revision 7560)
@@ -3,14 +3,16 @@
   function loadpage(pagenum)
   {
-    $("#list").html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");
+    $("#list").html("<div style='margin:20px auto;text-align:center;'><img src='./plugins/GrumPluginClasses/icons/processing.gif'></div>");
 
     $.ajax(
       {
         type: "POST",
-        datas:
+        data:
           {
+            ajaxfct:'admin.img.list',
+            numPage:pagenum,
             filter:$("#filter").val()
           },
-        url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}"+pagenum,
+        url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}",
         async: true,
         success: function(msg)
Index: /extensions/lmt/admin/plugin_admin_manage.tpl
===================================================================
--- /extensions/lmt/admin/plugin_admin_manage.tpl	(revision 7559)
+++ /extensions/lmt/admin/plugin_admin_manage.tpl	(revision 7560)
@@ -10,10 +10,15 @@
   function loadpage(pagenum)
   {
-    $("#list").html("<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>");
+    $("#list").html("<div style='margin:20px auto;text-align:center;'><img src='./plugins/GrumPluginClasses/icons/processing.gif'></div>");
 
     $.ajax(
       {
         type: "POST",
-        url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}"+pagenum,
+        data:
+          {
+            ajaxfct:'admin.manage.list',
+            numPage:pagenum
+          },
+        url: "{/literal}{$datas.LMT_AJAX_URL_LIST}{literal}",
         async: true,
         success: function (msg)
Index: /extensions/lmt/admin/plugin_admin_manageaut.tpl
===================================================================
--- /extensions/lmt/admin/plugin_admin_manageaut.tpl	(revision 7559)
+++ /extensions/lmt/admin/plugin_admin_manageaut.tpl	(revision 7560)
@@ -4,5 +4,5 @@
 
   function init() {
-    $("tr").filter(".TableRow").bind("mouseover", 
+    $("tr").filter(".TableRow_{/literal}{$themeconf.name}{literal}").bind("mouseover",
       function (event) {
         {/literal}
@@ -16,11 +16,11 @@
         {literal}
         $("#iexample").attr("innerHTML", txt);
-      }      
+      }
     );
 
-    $("tr").filter(".TableRow").bind("mouseout", 
+    $("tr").filter(".TableRow_{/literal}{$themeconf.name}{literal}").bind("mouseout",
       function (event) {
        // $("#iexample").attr("innerHTML", "");
-      }      
+      }
     );
   }
@@ -52,5 +52,5 @@
     </tr>
     {foreach from=$datas.author_list key=name item=data}
-      <tr class="TableRow">
+      <tr class="TableRow_{$themeconf.name}">
         <td>{$data.id}</td>
         <td>{$data.text1}</td>
Index: /extensions/lmt/language/de_DE/plugin.lang.php
===================================================================
--- /extensions/lmt/language/de_DE/plugin.lang.php	(revision 7559)
+++ /extensions/lmt/language/de_DE/plugin.lang.php	(revision 7560)
@@ -156,3 +156,25 @@
 
 
+/*
+ * need to be translated
+ *
+ * thanks ! :-)
+ */
+
+// 1.2.0
+$lang['To install this plugin, you need to install Grum Plugin Classes %s before'] = 'To install this plugin, you need to install Grum Plugin Classes %s before';
+
+// 1.3.0
+$lang['lmt_add_licence_type'] = "Add a licence type";
+$lang['lmt_choose_licence_type'] = "Choose licence type";
+$lang['lmt_search'] = "Search";
+$lang['lmt_search_by_licence'] = "Search photos under licence";
+$lang['lmt_licence_type']="Licence type";
+$lang['lmt_ok']="Ok";
+$lang['lmt_search_pictures_with_licence_1']="Search photos under licence:";
+$lang['lmt_search_pictures_with_licence_n']="Search photos under one of theses licences:";
+$lang['lmt_error_num_items']="At least, one licence must be selected";
+
+
+
 ?>
Index: /extensions/lmt/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/lmt/language/en_UK/plugin.lang.php	(revision 7559)
+++ /extensions/lmt/language/en_UK/plugin.lang.php	(revision 7560)
@@ -1,24 +1,3 @@
 <?php
-
-/* -----------------------------------------------------------------------------
-  This file was created by 'Translator r2.0.0-beta' plugin
-
-  **** Export informations
-  Export date       : 2009-04-30 22:59:49
-  Number of items   : 149
-    Number exported : 149
-  Exported by       : grum
-
-  **** File informations
-  Language          : English [ISO en_UK]
-  Charset           : utf-8
-  Type              : plugin
-  Name (Release)    : lmt (2.0.0-beta)
-
-  **** Export options
-  Items exported    : "ok"
-  Translator export : NO
------------------------------------------------------------------------------ */
-
 
 $lang['example'] = 'Display sample';
@@ -176,4 +155,17 @@
 $lang["lmt_cfg_warning_target"] = "Force the page openning in a new window";
 
+// 1.2.0
+$lang['To install this plugin, you need to install Grum Plugin Classes %s before'] = 'To install this plugin, you need to install Grum Plugin Classes %s before';
+
+// 1.3.0
+$lang['lmt_add_licence_type'] = "Add a licence type";
+$lang['lmt_choose_licence_type'] = "Choose licence type";
+$lang['lmt_search'] = "Search";
+$lang['lmt_search_by_licence'] = "Search photos under licence";
+$lang['lmt_licence_type']="Licence type";
+$lang['lmt_ok']="Ok";
+$lang['lmt_search_pictures_with_licence_1']="Search photos under licence:";
+$lang['lmt_search_pictures_with_licence_n']="Search photos under one of theses licences:";
+$lang['lmt_error_num_items']="At least, one licence must be selected";
 
 ?>
Index: /extensions/lmt/language/es_ES/plugin.lang.php
===================================================================
--- /extensions/lmt/language/es_ES/plugin.lang.php	(revision 7559)
+++ /extensions/lmt/language/es_ES/plugin.lang.php	(revision 7560)
@@ -182,5 +182,23 @@
 $lang["lmt_cfg_warning_target"] = "Forzar la apertura en una nueva ventana"
 
-
+/*
+ * need to be translated
+ *
+ * thanks ! :-)
+ */
+
+// 1.2.0
+$lang['To install this plugin, you need to install Grum Plugin Classes %s before'] = 'To install this plugin, you need to install Grum Plugin Classes %s before';
+
+// 1.3.0
+$lang['lmt_add_licence_type'] = "Add a licence type";
+$lang['lmt_choose_licence_type'] = "Choose licence type";
+$lang['lmt_search'] = "Search";
+$lang['lmt_search_by_licence'] = "Search photos under licence";
+$lang['lmt_licence_type']="Licence type";
+$lang['lmt_ok']="Ok";
+$lang['lmt_search_pictures_with_licence_1']="Search photos under licence:";
+$lang['lmt_search_pictures_with_licence_n']="Search photos under one of theses licences:";
+$lang['lmt_error_num_items']="At least, one licence must be selected";
 
 ?>
Index: /extensions/lmt/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/lmt/language/fr_FR/plugin.lang.php	(revision 7559)
+++ /extensions/lmt/language/fr_FR/plugin.lang.php	(revision 7560)
@@ -186,3 +186,14 @@
 
 
+// 1.3.0
+$lang['lmt_add_licence_type'] = "Ajouter un type de licence";
+$lang['lmt_choose_licence_type'] = "Sélectionner le type de licence";
+$lang['lmt_search'] = "Rechercher";
+$lang['lmt_search_by_licence'] = "Rechercher des photos en fonction de leur licence";
+$lang['lmt_licence_type']="Type de licence";
+$lang['lmt_ok']="Ok";
+$lang['lmt_search_pictures_with_licence_1']="Rechercher les photos sous licence :";
+$lang['lmt_search_pictures_with_licence_n']="Rechercher les photos sous l'une des licences suivantes :";
+$lang['lmt_error_num_items']="Au moins une licence doit être sélectionnée";
+
 ?>
Index: /extensions/lmt/lmt.css
===================================================================
--- /extensions/lmt/lmt.css	(revision 7560)
+++ /extensions/lmt/lmt.css	(revision 7560)
@@ -0,0 +1,85 @@
+.TableRow_roma:hover { background-color:#303030; }
+.TableRow_clear:hover { background-color:#DDDDDD; }
+
+.formtable
+{
+  text-align:justify;
+  display:block;
+  margin-top:0px;
+  margin-bottom:0px;
+  width:100%;
+}
+
+.formtable tr { vertical-align:top; }
+
+.littlefont { font-size:90%; }
+table.littlefont th { text-align:center; padding:3px;padding-left:9px;padding-right:9px; }
+table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; }
+
+.lmt_page {
+  text-align:justify;
+  margin:8px;
+}
+
+.lmt { text-align:justify; }
+
+#list {
+  width:100%;
+  overflow-y:scroll;
+  min-height:250px;
+  max-height:650px;
+}
+
+#ullist li {
+  width:300px;
+  display:block;
+  float:left;
+  text-align:left;
+}
+
+#ullist label { float:left; }
+
+#ullist li table {
+  margin:0px;
+  text-align:left;
+  width:300px;
+  font-size:80%;
+}
+
+#ullist li tr { vertical-align:top; }
+
+.content ul.thumbnails span.extendwrap1 {
+  margin:0px;
+  cursor:pointer;
+  overflow:hidden
+}
+
+.is_on, .is_off {
+  z-index:20;
+  width:12px;
+  height:12px;
+  display:block;
+  cursor:pointer;
+}
+
+.is_on { background:url(./img/cb_on.png); }
+.is_off { background:url(./img/cb_off.png); }
+
+.icnhelp {
+  weight:bold;
+  text-decoration:none;
+  cursor:help;
+}
+
+.hinthlp {
+  position:absolute;
+  max-width:400px;
+  border:1px solid #000000;
+  background:#ffffa0;
+  color:#000000;
+  top:0px;
+  left:-450px;
+  padding:2px;
+  text-align:justify;
+}
+
Index: /extensions/lmt/lmt_aip.class.inc.php
===================================================================
--- /extensions/lmt/lmt_aip.class.inc.php	(revision 7559)
+++ /extensions/lmt/lmt_aip.class.inc.php	(revision 7560)
@@ -17,11 +17,10 @@
 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTranslate.class.inc.php');
 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCTables.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
 include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/genericjs.class.inc.php');
-include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPagesNavigation.class.inc.php');
 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
 
 class LMT_AIP extends LMT_root
 {
-  protected $google_translate;
   protected $tabsheet;
 
@@ -42,4 +41,7 @@
                           l10n('lmt_manageaut'),
                           $this->getAdminLink()."&amp;f_tabsheet=manageaut");
+    $this->tabsheet->add('search',
+                          l10n('lmt_search'),
+                          $this->getAdminLink()."&amp;f_tabsheet=search");
     $this->tabsheet->add('config',
                           l10n('lmt_config'),
@@ -48,20 +50,8 @@
                           l10n('lmt_help'),
                           $this->getAdminLink()."&amp;f_tabsheet=help");
-
-
-    // don't create the google_translate object everytime, otherwise google's js
-    // code is always included in the header even if translation functionalities
-    // aren't needed
-    // translation is needed only if we are in a ajax request
-    /*if((isset($_POST['fmypolls_gomodify_translation'])||isset($_POST['fmypolls_goadd_translation'])))
-    {
-      $this->google_translate = new GPCTranslate();
-    }
-    */
   }
 
   public function __destruct()
   {
-    unset($this->google_translate);
     unset($this->tabsheet);
     parent::__destruct();
@@ -74,6 +64,15 @@
   {
     parent::initEvents();
+
+    if(isset($_REQUEST['f_tabsheet']) and $_REQUEST['f_tabsheet']=='search')
+    {
+      // load request builder JS only on the search page
+      GPCRequestBuilder::loadJSandCSS();
+    }
+
     add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
     add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS'));
+
+    GPCCss::applyGpcCss();
   }
 
@@ -84,6 +83,4 @@
   {
     global $template;
-
-    $this->return_ajax_content();
 
     $template->set_filename('plugin_admin_content', dirname(__FILE__)."/admin/lmt_admin.tpl");
@@ -108,4 +105,7 @@
         $this->display_managedoc_page();
         break;
+      case 'search':
+        $this->displaySearch();
+        break;
       case 'help':
         $this->display_help_page();
@@ -127,29 +127,4 @@
     $template->assign('plugin', $template_plugin);
     $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
-  }
-
-
-  /*
-    return ajax content
-  */
-  protected function return_ajax_content()
-  {
-    global $ajax, $template;
-
-    if(isset($_REQUEST['ajaxfct']))
-    {
-      //$this->debug("AJAXFCT:".$_REQUEST['ajaxfct']);
-      $result="<p class='errors'>An error has occured</p>";
-      switch($_REQUEST['ajaxfct'])
-      {
-        case 'img_list':
-          $result=$this->ajax_img_list($_REQUEST['numpage']);
-          break;
-        case 'manage_list':
-          $result=$this->ajax_manage_list($_REQUEST['numpage']);
-          break;
-      }
-      GPCAjax::returnResult($result);
-    }
   }
 
@@ -233,9 +208,9 @@
 
     $datas=array(
-      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink().'&ajaxfct=img_list&numpage='
+      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
     );
 
     $filter_list_selected = '';
-    $filter_list_values = array_slice($this->licences,0,count($this->licences)-1);
+    $filter_list_values = array_slice(LMT_root::$licences,0,count(LMT_root::$licences)-1);
     $filter_list_labels = array();
     foreach($filter_list_values as $key=>$val)
@@ -369,5 +344,5 @@
 
     $datas=array(
-      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink().'&ajaxfct=manage_list&numpage='
+      "LMT_AJAX_URL_LIST" =>  $this->getAdminLink('ajax')
     );
 
@@ -395,5 +370,5 @@
 
     $licences_list_values = array();
-    $licences_list_values = $this->licences;
+    $licences_list_values = self::$licences;
     $licences_list_labels = array();
     foreach($licences_list_values as $key=>$val)
@@ -459,5 +434,5 @@
 
     $datas['lmt_redirect_urls']=array();
-    $lmt_licence_default_values = array_slice($this->licences,0,count($this->licences)-1);
+    $lmt_licence_default_values = array_slice(self::$licences,0,count(self::$licences)-1);
     $lmt_licence_default_labels = array();
 
@@ -540,4 +515,21 @@
 
 
+  /**
+   * display the search page
+   *
+   */
+  protected function displaySearch()
+  {
+    global $template;
+
+    $template->set_filename('body_page',
+                dirname($this->getFileLocation()).'/admin/lmt_search.tpl');
+
+    $template->assign('lmt_search_page', GPCRequestBuilder::displaySearchPage($this->getPluginName()));
+
+    $template->assign_var_from_handle('LMT_BODY_PAGE', 'body_page');
+  }
+
+
 
   /*
@@ -555,5 +547,4 @@
       $_REQUEST['id']="";
     }
-
 
     /* ------------------------------------------------------------------------
@@ -780,5 +771,5 @@
                   dirname($this->getFileLocation()).'/admin/lmt_js.tpl');
 
-    $lmt_licence_default_values=array_slice($this->licences,0,count($this->licences)-1);
+    $lmt_licence_default_values=array_slice(self::$licences,0,count(self::$licences)-1);
     $datas['shortlicencetext']=array();
     foreach($lmt_licence_default_values as $key=>$val)
@@ -795,29 +786,4 @@
   }
 
-  protected function make_image_data($tmp, $imageId)
-  {
-    $tmp2=array();
-    foreach($tmp['id'] as $key=>$val)
-    {
-      $tmp2[]=array(
-        'id' => $tmp['id'][$key],
-        'name' => $tmp['name'][$key],
-        'type' => $tmp['type'][$key],
-        'plinks' => $tmp['plinks'][$key],
-        'link'=> make_picture_url(
-                  array(
-                    'image_id' => $imageId,
-                    'category' => array
-                      (
-                        'id' => $tmp['id'][$key],
-                        'name' => $tmp['name'][$key],
-                        'permalink' => $tmp['plinks'][$key]
-                      )
-                  )
-                )
-      );
-    }
-    return($tmp2);
-  }
 
   /* ---------------------------------------------------------------------------
@@ -826,209 +792,4 @@
 
 
-
-
-
-  /* ---------------------------------------------------------------------------
-    ajax functions
-  --------------------------------------------------------------------------- */
-
-  protected function ajax_img_list($pagenum)
-  {
-    global $conf;
-
-    $local_tpl = new Template(LMT_PATH."admin/", "");
-    $local_tpl->set_filename('body_page',
-                  dirname($this->getFileLocation()).'/admin/plugin_admin_listitems.tpl');
-
-    if(!isset($_REQUEST['filter']) ||
-       !($_REQUEST['filter']=="BY" ||
-         $_REQUEST['filter']=="BY-SA" ||
-         $_REQUEST['filter']=="BY-ND" ||
-         $_REQUEST['filter']=="BY-NC-ND" ||
-         $_REQUEST['filter']=="BY-NC-SA" ||
-         $_REQUEST['filter']=="BY-NC" ||
-         $_REQUEST['filter']=="CRIGHT" ||
-         $_REQUEST['filter']=="CLEFT"
-      ))
-    {
-      $_REQUEST['filter']='';
-    }
-
-    $img_ids=array();
-    $img_liste = array();
-    $sql="SELECT SQL_CALC_FOUND_ROWS lmti.*, img.file, img.path, img.tn_ext,
-                  GROUP_CONCAT(cat.id) AS catid,
-                  GROUP_CONCAT(CASE WHEN cat.name IS NULL THEN '' ELSE cat.name END SEPARATOR '@sep@') AS catname,
-                  GROUP_CONCAT(CASE WHEN cat.permalink IS NULL THEN '' ELSE cat.permalink END SEPARATOR '@sep@') AS catpermalink,
-                  GROUP_CONCAT(CASE WHEN cat.dir IS NULL THEN 'V' ELSE 'P' END) AS cattype,
-                  lmtla.text1, lmtla.text2
-          FROM ".$this->tables["images"]." lmti
-                  LEFT OUTER JOIN ".$this->tables["licence_author"]." lmtla ON lmtla.id = lmti.author_id,
-               ".IMAGES_TABLE." img
-                  LEFT OUTER JOIN ".IMAGE_CATEGORY_TABLE." imgcat ON img.id = imgcat.image_id
-                  LEFT OUTER JOIN ".CATEGORIES_TABLE." cat ON imgcat.category_id = cat.id
-          WHERE lmti.image_id = img.id ";
-    if($_REQUEST['filter']!="")
-    {
-      $sql.=" AND lmti.licence_type='".$_REQUEST['filter']."'";
-    }
-
-    $sql.=" GROUP BY lmti.image_id ORDER BY cat.id, img.id ";
-
-    if($this->config['lmt_list_maxitems']>0)
-    {
-      $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
-      $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
-    }
-
-    $result=pwg_query($sql);
-    if($result)
-    {
-      while($row = pwg_db_fetch_assoc($result))
-      {
-        $filenfo = pathinfo($row['path']);
-        preg_match("/(.*)\./i", $filenfo["basename"], $tmp);
-        $filenfo['filename'] = $tmp[1];
-
-        $tmp=array(
-              'id'=>explode(',',$row['catid']),
-              'name'=>explode('@sep@',$row['catname']),
-              'type'=>explode(',',$row['cattype']),
-              'plinks'=>explode('@sep@',$row['catpermalink']),
-              'link'=>array()
-            );
-        $tmpcat=$this->make_image_data($tmp, $row['image_id']);
-
-        $img_ids[]=$row['image_id'];
-        $img_liste[]=array(
-          'id' => $row['image_id'],
-          'licence' => ($row['licence_type']=="CRIGHT")?l10n("lmt_lbl_cc_s-".strtolower($row['licence_type'])):"",
-          'licencei' => LMT_PATH."img/".strtolower($row['licence_type'])."_80x15.png",
-          'aut_text1' => $row['text1'],
-          'aut_text2' => $row['text2'],
-          'file' => $row['file'],
-          'cat' => $tmpcat,
-          'thumb' => $filenfo["dirname"]."/thumbnail/".$conf["prefix_thumbnail"].$filenfo["filename"].".".$row["tn_ext"]
-        );
-      }
-    }
-
-    $sql="select FOUND_ROWS()";
-    $result=pwg_query($sql);
-    $nb=pwg_db_fetch_row($result);
-
-    $GPCPagesNavigation = new GPCPagesNavigation();
-    $GPCPagesNavigation->setNbItems($nb[0]);
-    $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
-    $GPCPagesNavigation->setCurrentPage($pagenum);
-    $GPCPagesNavigation->setOptions(array(
-      "text_prev" => l10n("lmt_nav_prev"),
-      "text_next" => l10n("lmt_nav_next"),
-      "text_first" => l10n("lmt_nav_first"),
-      "text_last" => l10n("lmt_nav_last")
-    ));
-    $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
-    if($navbar!="")
-    {
-      $navbar=", ".$navbar;
-    }
-
-    $local_tpl->assign('imgliste', $img_liste);
-    return($nb[0]."&nbsp;".l10n("lmt_lst_nb_photos").$navbar."#".$local_tpl->parse('body_page', true));
-  }
-
-  protected function ajax_manage_list($pagenum)
-  {
-    global $conf, $user;
-
-    $local_tpl = new Template(LMT_PATH."admin/", "");
-    $local_tpl->set_filename('body_page',
-                  dirname($this->getFileLocation()).'/admin/plugin_admin_manageitems.tpl');
-
-    if(!isset($_REQUEST['select']))
-    {
-      $_REQUEST['select']="caddie";
-    }
-
-    $img_liste = array();
-    $sql="SELECT SQL_CALC_FOUND_ROWS img.id as image_id, img.file, img.path, img.tn_ext,
-                  GROUP_CONCAT(cat.id) AS catid,
-                  GROUP_CONCAT(CASE WHEN cat.name IS NULL THEN '' ELSE cat.name END SEPARATOR '@sep@') AS catname,
-                  GROUP_CONCAT(CASE WHEN cat.permalink IS NULL THEN '' ELSE cat.permalink END SEPARATOR '@sep@') AS catpermalink,
-                  GROUP_CONCAT(CASE WHEN cat.dir IS NULL THEN 'V' ELSE 'P' END) AS cattype,
-                 lmti.licence_type, lmtla.text1, lmtla.text2
-          FROM ".CADDIE_TABLE." caddie,
-              (".IMAGES_TABLE." img
-                  LEFT OUTER JOIN ".IMAGE_CATEGORY_TABLE." imgcat ON img.id = imgcat.image_id
-                  LEFT OUTER JOIN ".CATEGORIES_TABLE." cat ON imgcat.category_id = cat.id)
-                LEFT OUTER JOIN ".$this->tables["images"]." AS lmti ON img.id = lmti.image_id
-                LEFT OUTER JOIN ".$this->tables["licence_author"]." lmtla  ON lmtla.id = lmti.author_id
-          WHERE img.id = caddie.element_id
-            AND caddie.user_id = '".$user['id']."'
-          GROUP BY img.id
-          ORDER BY cat.id, img.id ";
-
-    if($this->config['lmt_list_maxitems']>0)
-    {
-      $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
-      $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
-    }
-
-    $result=pwg_query($sql);
-
-    if($result)
-    {
-      while($row = pwg_db_fetch_assoc($result))
-      {
-        $filenfo = pathinfo($row['path']);
-        preg_match("/(.*)\./i", $filenfo["basename"], $tmp);
-        $filenfo['filename'] = $tmp[1];
-
-        $tmp=array(
-              'id'=>explode(',',$row['catid']),
-              'name'=>explode('@sep@',$row['catname']),
-              'type'=>explode(',',$row['cattype']),
-              'plinks'=>explode('@sep@',$row['catpermalink']),
-              'link'=>array()
-            );
-        $tmpcat=$this->make_image_data($tmp, $row['image_id']);
-
-        $img_liste[]=array(
-          'id' => $row['image_id'],
-          'licence' => ($row['licence_type']=="")?"DEFAULT":$row['licence_type'],
-          'licencei' => ($row['licence_type']=="")?"":LMT_PATH."img/".strtolower($row['licence_type'])."_80x15.png",
-          'aut_text1' => $row['text1'],
-          'aut_text2' => $row['text2'],
-          'file' => $row['file'],
-          'cat' => $tmpcat,
-          'thumb' => $filenfo["dirname"]."/thumbnail/".$conf["prefix_thumbnail"].$filenfo["filename"].".".$row["tn_ext"]
-        );
-      }
-    }
-
-    $sql="select FOUND_ROWS()";
-    $result=pwg_query($sql);
-    $nb=pwg_db_fetch_row($result);
-
-    $GPCPagesNavigation = new GPCPagesNavigation();
-    $GPCPagesNavigation->setNbItems($nb[0]);
-    $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
-    $GPCPagesNavigation->setCurrentPage($pagenum);
-    $GPCPagesNavigation->setOptions(array(
-      "text_prev" => l10n("lmt_nav_prev"),
-      "text_next" => l10n("lmt_nav_next"),
-      "text_first" => l10n("lmt_nav_first"),
-      "text_last" => l10n("lmt_nav_last")
-    ));
-    $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
-    if($navbar!="")
-    {
-      $navbar=", ".$navbar;
-    }
-
-    $local_tpl->assign('imgliste', $img_liste);
-    return($nb[0]."&nbsp;".l10n("lmt_lst_nb_photos").$navbar."#".$local_tpl->parse('body_page', true));
-  }
-
 } //class
 
Index: /extensions/lmt/lmt_aip_release.class.inc.php
===================================================================
--- /extensions/lmt/lmt_aip_release.class.inc.php	(revision 7560)
+++ /extensions/lmt/lmt_aip_release.class.inc.php	(revision 7560)
@@ -0,0 +1,70 @@
+<?php
+/**
+ * -----------------------------------------------------------------------------
+ * Plugin     : LMT
+ * -----------------------------------------------------------------------------
+ * Author     : Grum
+ *   email    : grum@piwigo.org
+ *   website  : http://photos.grum.fr
+ *   PWG user : http://forum.piwigo.org/profile.php?id=3706
+ *
+ *   << May the Little SpaceFrog be with you ! >>
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * See main.inc.php for release information
+ *
+ * AIPRelease class => display warning if GPC release is not up to date
+ *
+ * -----------------------------------------------------------------------------
+ */
+
+
+if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+include_once('lmt_root.class.inc.php');
+
+class LMT_AIPRelease extends LMT_root
+{
+  public function __construct($prefixeTable, $filelocation)
+  {
+    parent::__construct($prefixeTable, $filelocation);
+    $this->loadConfig();
+    $this->initEvents();
+  }
+
+  /*
+    initialize events call for the plugin
+  */
+  public function initEvents()
+  {
+    parent::initEvents();
+    add_event_handler('loc_end_page_header', array(&$this->css, 'applyCSS'));
+  }
+
+  /*
+    display administration page
+  */
+  public function manage()
+  {
+    global $template;
+
+    $template->set_filename('plugin_admin_content', dirname($this->getFileLocation())."/admin/lmt_admin.tpl");
+
+    $pluginInfo=array(
+      'LMT_VERSION' => "<i>".$this->getPluginName()."</i> ".l10n('lmt_release').LMT_VERSION,
+      'PATH' => LMT_PATH
+    );
+
+    $template->assign('plugin', $pluginInfo);
+    $template->assign('LMT_BODY_PAGE', '<p class="warnings">'.sprintf(l10n('lmt_gpc_not_up_to_date'),LMT_GPC_NEEDED, LMT_VERSION).'</p>');
+    $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
+  }
+
+
+
+
+} //class
+
+
+?>
Index: /extensions/lmt/lmt_ajax.php
===================================================================
--- /extensions/lmt/lmt_ajax.php	(revision 7560)
+++ /extensions/lmt/lmt_ajax.php	(revision 7560)
@@ -0,0 +1,325 @@
+<?php
+/*
+ * -----------------------------------------------------------------------------
+ * Plugin Name: LMT
+ * -----------------------------------------------------------------------------
+ * Author     : Grum
+ *   email    : grum@piwigo.org
+ *   website  : http://photos.grum.fr
+ *   PWG user : http://forum.piwigo.org/profile.php?id=3706
+ *
+ *   << May the Little SpaceFrog be with you ! >>
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * See main.inc.php for release information
+ *
+ * manage all the ajax requests
+ * -----------------------------------------------------------------------------
+ */
+
+define('PHPWG_ROOT_PATH',dirname(dirname(dirname(__FILE__))).'/');
+
+/*
+ * set ajax module in admin mode if request is used for admin interface
+ */
+if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']='';
+if(preg_match('/^admin\./i', $_REQUEST['ajaxfct']))
+{
+  define('IN_ADMIN', true);
+}
+
+// the common.inc.php file loads all the main.inc.php plugins files
+include_once(PHPWG_ROOT_PATH.'include/common.inc.php' );
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPagesNavigation.class.inc.php');
+include_once('lmt_root.class.inc.php');
+
+load_language('plugin.lang', LMT_PATH);
+
+
+class LMT_Ajax extends LMT_root
+{
+  /**
+   * constructor
+   */
+  public function __construct($prefixeTable, $filelocation)
+  {
+    parent::__construct($prefixeTable, $filelocation);
+    $this->loadConfig();
+    $this->checkRequest();
+    $this->returnAjaxContent();
+  }
+
+  /**
+   * check the $_REQUEST values and set default values
+   *
+   */
+  protected function checkRequest()
+  {
+    global $user;
+
+    if(!isset($_REQUEST['ajaxfct'])) $_REQUEST['ajaxfct']='';
+    if(!isset($_REQUEST['errcode'])) $_REQUEST['errcode']='';
+
+    // check if asked function is valid
+    if(!($_REQUEST['ajaxfct']=='admin.img.list' or
+         $_REQUEST['ajaxfct']=='admin.manage.list'
+         )) $_REQUEST['ajaxfct']='';
+
+    if(preg_match('/^admin\./i', $_REQUEST['ajaxfct']) and !is_admin()) $_REQUEST['ajaxfct']='';
+
+
+    if($_REQUEST['ajaxfct']!='admin.img.list')
+    {
+      if(!isset($_REQUEST['numPage']) or
+         $_REQUEST['numPage'] <=0) $_REQUEST['ajaxfct']='';
+
+
+      if(!isset($_REQUEST['filter']) ||
+         !($_REQUEST['filter']=="BY" ||
+           $_REQUEST['filter']=="BY-SA" ||
+           $_REQUEST['filter']=="BY-ND" ||
+           $_REQUEST['filter']=="BY-NC-ND" ||
+           $_REQUEST['filter']=="BY-NC-SA" ||
+           $_REQUEST['filter']=="BY-NC" ||
+           $_REQUEST['filter']=="CRIGHT" ||
+           $_REQUEST['filter']=="CLEFT"
+        ))
+      {
+        $_REQUEST['filter']='';
+      }
+    }
+
+    if($_REQUEST['ajaxfct']!='admin.manage.list')
+    {
+      if(!isset($_REQUEST['numPage']) or
+         $_REQUEST['numPage'] <=0) $_REQUEST['ajaxfct']='';
+    }
+
+  } //checkRequest
+
+
+  /**
+   * return ajax content
+   */
+  protected function returnAjaxContent()
+  {
+    $result="<p class='errors'>An error has occured</p>";
+    switch($_REQUEST['ajaxfct'])
+    {
+      case 'admin.img.list':
+        $result=$this->ajax_lmt_admin_imgList($_REQUEST['numPage'], $_REQUEST['filter']);
+        break;
+      case 'admin.manage.list':
+        $result=$this->ajax_lmt_admin_manageList($_REQUEST['numPage']);
+        break;
+    }
+    GPCAjax::returnResult($result);
+  }
+
+
+  /*------------------------------------------------------------------------*
+   *
+   * ADMIN FUNCTIONS
+   *
+   *----------------------------------------------------------------------- */
+
+
+  /**
+   * this function returns the list of pictures with a license
+   *
+   * @param Integer $pagenum : page number to display
+   * @param String $filter : filter to apply
+   * @return String : html string, ready to be displayed
+   */
+  protected function ajax_lmt_admin_imgList($pagenum, $filter)
+  {
+    global $conf, $template;
+
+    $template->set_filename('lmt_page',
+                  dirname($this->getFileLocation()).'/admin/plugin_admin_listitems.tpl');
+
+
+    $img_ids=array();
+    $img_liste = array();
+    $sql="SELECT SQL_CALC_FOUND_ROWS lmti.*, img.file, img.path, img.tn_ext,
+                  GROUP_CONCAT(cat.id) AS catid,
+                  GROUP_CONCAT(CASE WHEN cat.name IS NULL THEN '' ELSE cat.name END SEPARATOR '@sep@') AS catname,
+                  GROUP_CONCAT(CASE WHEN cat.permalink IS NULL THEN '' ELSE cat.permalink END SEPARATOR '@sep@') AS catpermalink,
+                  GROUP_CONCAT(CASE WHEN cat.dir IS NULL THEN 'V' ELSE 'P' END) AS cattype,
+                  lmtla.text1, lmtla.text2
+          FROM ".$this->tables["images"]." lmti
+                  LEFT OUTER JOIN ".$this->tables["licence_author"]." lmtla ON lmtla.id = lmti.author_id,
+               ".IMAGES_TABLE." img
+                  LEFT OUTER JOIN ".IMAGE_CATEGORY_TABLE." imgcat ON img.id = imgcat.image_id
+                  LEFT OUTER JOIN ".CATEGORIES_TABLE." cat ON imgcat.category_id = cat.id
+          WHERE lmti.image_id = img.id ";
+    if($_REQUEST['filter']!="")
+    {
+      $sql.=" AND lmti.licence_type='".$_REQUEST['filter']."'";
+    }
+
+    $sql.=" GROUP BY lmti.image_id ORDER BY cat.id, img.id ";
+
+    if($this->config['lmt_list_maxitems']>0)
+    {
+      $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
+      $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
+    }
+
+    $result=pwg_query($sql);
+    if($result)
+    {
+      while($row = pwg_db_fetch_assoc($result))
+      {
+        $filenfo = pathinfo($row['path']);
+        preg_match("/(.*)\./i", $filenfo["basename"], $tmp);
+        $filenfo['filename'] = $tmp[1];
+
+        $tmp=array(
+              'id'=>explode(',',$row['catid']),
+              'name'=>explode('@sep@',$row['catname']),
+              'type'=>explode(',',$row['cattype']),
+              'plinks'=>explode('@sep@',$row['catpermalink']),
+              'link'=>array()
+            );
+        $tmpcat=$this->makeImageDatas($tmp, $row['image_id']);
+
+        $img_ids[]=$row['image_id'];
+        $img_liste[]=array(
+          'id' => $row['image_id'],
+          'licence' => ($row['licence_type']=="CRIGHT")?l10n("lmt_lbl_cc_s-".strtolower($row['licence_type'])):"",
+          'licencei' => 'plugins/'.basename(LMT_PATH)."/img/".strtolower($row['licence_type'])."_80x15.png",
+          'aut_text1' => $row['text1'],
+          'aut_text2' => $row['text2'],
+          'file' => $row['file'],
+          'cat' => $tmpcat,
+          'thumb' => $filenfo["dirname"]."/thumbnail/".$conf["prefix_thumbnail"].$filenfo["filename"].".".$row["tn_ext"]
+        );
+      }
+    }
+
+    $sql="select FOUND_ROWS()";
+    $result=pwg_query($sql);
+    $nb=pwg_db_fetch_row($result);
+
+    $GPCPagesNavigation = new GPCPagesNavigation();
+    $GPCPagesNavigation->setNbItems($nb[0]);
+    $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
+    $GPCPagesNavigation->setCurrentPage($pagenum);
+    $GPCPagesNavigation->setOptions(array(
+      "text_prev" => l10n("lmt_nav_prev"),
+      "text_next" => l10n("lmt_nav_next"),
+      "text_first" => l10n("lmt_nav_first"),
+      "text_last" => l10n("lmt_nav_last")
+    ));
+    $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
+    if($navbar!="")
+    {
+      $navbar=", ".$navbar;
+    }
+
+    $template->assign('imgliste', $img_liste);
+    return($nb[0]."&nbsp;".l10n("lmt_lst_nb_photos").$navbar."#".$template->parse('lmt_page', true));
+  }
+
+  protected function ajax_lmt_admin_manageList($pagenum)
+  {
+    global $conf, $user, $template;
+
+    $template->set_filename('lmt_page',
+                  dirname($this->getFileLocation()).'/admin/plugin_admin_manageitems.tpl');
+
+    if(!isset($_REQUEST['select']))
+    {
+      $_REQUEST['select']="caddie";
+    }
+
+    $img_liste = array();
+    $sql="SELECT SQL_CALC_FOUND_ROWS img.id as image_id, img.file, img.path, img.tn_ext,
+                  GROUP_CONCAT(cat.id) AS catid,
+                  GROUP_CONCAT(CASE WHEN cat.name IS NULL THEN '' ELSE cat.name END SEPARATOR '@sep@') AS catname,
+                  GROUP_CONCAT(CASE WHEN cat.permalink IS NULL THEN '' ELSE cat.permalink END SEPARATOR '@sep@') AS catpermalink,
+                  GROUP_CONCAT(CASE WHEN cat.dir IS NULL THEN 'V' ELSE 'P' END) AS cattype,
+                 lmti.licence_type, lmtla.text1, lmtla.text2
+          FROM ".CADDIE_TABLE." caddie,
+              (".IMAGES_TABLE." img
+                  LEFT OUTER JOIN ".IMAGE_CATEGORY_TABLE." imgcat ON img.id = imgcat.image_id
+                  LEFT OUTER JOIN ".CATEGORIES_TABLE." cat ON imgcat.category_id = cat.id)
+                LEFT OUTER JOIN ".$this->tables["images"]." AS lmti ON img.id = lmti.image_id
+                LEFT OUTER JOIN ".$this->tables["licence_author"]." lmtla  ON lmtla.id = lmti.author_id
+          WHERE img.id = caddie.element_id
+            AND caddie.user_id = '".$user['id']."'
+          GROUP BY img.id
+          ORDER BY cat.id, img.id ";
+
+    if($this->config['lmt_list_maxitems']>0)
+    {
+      $refdbt = ($pagenum-1)*$this->config['lmt_list_maxitems'];
+      $sql.=" LIMIT ".$refdbt.", ".$this->config['lmt_list_maxitems'];
+    }
+
+    $result=pwg_query($sql);
+
+    if($result)
+    {
+      while($row = pwg_db_fetch_assoc($result))
+      {
+        $filenfo = pathinfo($row['path']);
+        preg_match("/(.*)\./i", $filenfo["basename"], $tmp);
+        $filenfo['filename'] = $tmp[1];
+
+        $tmp=array(
+              'id'=>explode(',',$row['catid']),
+              'name'=>explode('@sep@',$row['catname']),
+              'type'=>explode(',',$row['cattype']),
+              'plinks'=>explode('@sep@',$row['catpermalink']),
+              'link'=>array()
+            );
+        $tmpcat=$this->makeImageDatas($tmp, $row['image_id']);
+
+        $img_liste[]=array(
+          'id' => $row['image_id'],
+          'licence' => ($row['licence_type']=="")?"DEFAULT":$row['licence_type'],
+          'licencei' => ($row['licence_type']=="")?"":'plugins/'.basename(LMT_PATH)."/img/".strtolower($row['licence_type'])."_80x15.png",
+          'aut_text1' => $row['text1'],
+          'aut_text2' => $row['text2'],
+          'file' => $row['file'],
+          'cat' => $tmpcat,
+          'thumb' => $filenfo["dirname"]."/thumbnail/".$conf["prefix_thumbnail"].$filenfo["filename"].".".$row["tn_ext"]
+        );
+      }
+    }
+
+    $sql="select FOUND_ROWS()";
+    $result=pwg_query($sql);
+    $nb=pwg_db_fetch_row($result);
+
+    $GPCPagesNavigation = new GPCPagesNavigation();
+    $GPCPagesNavigation->setNbItems($nb[0]);
+    $GPCPagesNavigation->setNbItemsPerPage($this->config['lmt_list_maxitems']);
+    $GPCPagesNavigation->setCurrentPage($pagenum);
+    $GPCPagesNavigation->setOptions(array(
+      "text_prev" => l10n("lmt_nav_prev"),
+      "text_next" => l10n("lmt_nav_next"),
+      "text_first" => l10n("lmt_nav_first"),
+      "text_last" => l10n("lmt_nav_last")
+    ));
+    $navbar=$GPCPagesNavigation->makeNavigation("loadpage");
+    if($navbar!="")
+    {
+      $navbar=", ".$navbar;
+    }
+
+    $template->assign('imgliste', $img_liste);
+    return($nb[0]."&nbsp;".l10n("lmt_lst_nb_photos").$navbar."#".$template->parse('lmt_page', true));
+  }
+
+
+
+} //class
+
+
+$returned=new LMT_Ajax($prefixeTable, __FILE__);
+?>
Index: /extensions/lmt/lmt_icn.css
===================================================================
--- /extensions/lmt/lmt_icn.css	(revision 7560)
+++ /extensions/lmt/lmt_icn.css	(revision 7560)
@@ -0,0 +1,27 @@
+
+.logo80x15 {
+  position:relative;
+  top:4px;
+  margin-right:4px;
+  border:0px none;
+  z-index:1;
+}
+
+.logo88x31 {
+  position:relative;
+  margin-right:4px;
+  border:0px none;
+  z-index:1;
+}
+
+#theImage img.logo80x15, #theImage img.logo88x31 {
+  border:0px none;
+  padding:0px;
+  z-index:1;
+}
+
+.licencetag {
+  display:block;
+  padding-top:10px;
+  font-size:80%;
+}
Index: /extensions/lmt/lmt_install.class.inc.php
===================================================================
--- /extensions/lmt/lmt_install.class.inc.php	(revision 7559)
+++ /extensions/lmt/lmt_install.class.inc.php	(revision 7560)
@@ -28,5 +28,4 @@
       parent::__construct($prefixeTable, $filelocation);
       $this->tablef= new GPCTables($this->tables);
-      $this->exportfile=dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().'.sql';
     }
 
@@ -71,18 +70,9 @@
       );
 
-      //if present, try to import backup
-      //if backup file
-      $import=$this->tablef->import($this->exportfile);
-      if($import['errors']<0)
-      {
-        $result=$this->tablef->create($tables_def);
-        return($result);
-      }
-      else
-      {
-        return(true);
-      }
+      $result=$this->tablef->create($tables_def);
+      GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED);
+
+      return($result);
     }
-
 
     /*
@@ -91,7 +81,7 @@
     public function uninstall()
     {
-      $this->tablef->export($this->exportfile);
       $this->deleteConfig();
       $this->tablef->drop();
+      GPCCore::unregister($this->getPluginName());
       return('');
     }
@@ -105,4 +95,7 @@
       $this->config['installed']=LMT_VERSION2;
       $this->saveConfig();
+
+      GPCCore::register($this->getPluginName(), LMT_VERSION, LMT_GPC_NEEDED);
+      GPCRequestBuilder::register($this->getPluginName(), dirname($this->getFileLocation()).'/lmt_rb_callback.class.inc.php');
       return('');
     }
@@ -110,6 +103,6 @@
     public function deactivate()
     {
+      GPCRequestBuilder::unregister($this->getPluginName());
     }
-
   } //class
 
Index: /extensions/lmt/lmt_pip.class.inc.php
===================================================================
--- /extensions/lmt/lmt_pip.class.inc.php	(revision 7559)
+++ /extensions/lmt/lmt_pip.class.inc.php	(revision 7560)
@@ -17,4 +17,6 @@
 //include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCPublicIntegration.class.inc.php');
 
+load_language('plugin.lang', LMT_PATH);
+
 class LMT_PIP extends LMT_root
 {
@@ -27,5 +29,4 @@
 
     $this->initEvents();
-    $this->load_lang();
   }
 
@@ -36,36 +37,19 @@
   }
 
-  /*
-    load language file
-  */
-  public function load_lang()
-  {
-    global $lang;
-
-    load_language('plugin.lang', LMT_PATH);
-
-    // ajax is managed here ; this permit to use user&language properties inside
-    // ajax content
-    //$this->return_ajax_content();
-  }
-
-  /*
-    initialize events call for the plugin
-  */
+  /**
+   * initialize events call for the plugin
+   */
   public function initEvents()
   {
     parent::initEvents();
-/*
-    add_event_handler('blockmanager_apply', array(&$this, 'blockmanager_apply') );
-    add_event_handler('loading_lang', array(&$this, 'load_lang'));
-*/
+
     if($this->config['lmt_licence_activated']=='y')
     {
       add_event_handler('loc_end_page_header', array(&$this->css_icn, 'applyCSS'));
-      add_event_handler('loc_end_picture', array(&$this, 'manage_licence_element'));
+      add_event_handler('loc_end_picture', array(&$this, 'manageLicenceElement'));
 
       if($this->config['lmt_warning_visible']=='y')
       {
-        add_event_handler('loc_end_page_tail', array(&$this, 'manage_warning_text'));
+        add_event_handler('loc_end_page_tail', array(&$this, 'manageWarningText'));
       }
     }
@@ -77,9 +61,9 @@
     FUNCTIONS TO MANAGE LMT DISPLAY
   ------------------------------------------------------------------------- */
-  public function manage_licence_element()
+  public function manageLicenceElement()
   {
     global $template, $page, $user;
 
-    $licence=$this->get_image_licence($page['image_id']);
+    $licence=$this->getImageLicence($page['image_id']);
     if($licence['licence']=="")
     {
@@ -148,5 +132,5 @@
   }
 
-  public function manage_warning_text()
+  public function manageWarningText()
   {
     global $template, $user;
@@ -198,8 +182,4 @@
 
 
-  /* ---------------------------------------------------------------------------
-    ajax functions
-  --------------------------------------------------------------------------- */
-
 } //class
 
Index: /extensions/lmt/lmt_rb_callback.class.inc.php
===================================================================
--- /extensions/lmt/lmt_rb_callback.class.inc.php	(revision 7560)
+++ /extensions/lmt/lmt_rb_callback.class.inc.php	(revision 7560)
@@ -0,0 +1,191 @@
+<?php
+/* -----------------------------------------------------------------------------
+  Plugin     : LMT
+  Author     : Grum
+    email    : grum@piwigo.org
+    website  : http://photos.grum.fr
+
+    << May the Little SpaceFrog be with you ! >>
+  ------------------------------------------------------------------------------
+  See main.inc.php for release information
+
+
+  --------------------------------------------------------------------------- */
+
+  if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCore.class.inc.php');
+  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCRequestBuilder.class.inc.php');
+
+load_language('plugin.lang', LMT_PATH);
+
+class RBCallBackLMT extends GPCSearchCallback {
+  static public $lmtDefaultLicence='';
+
+  static public function init()
+  {
+    $config=array();
+    GPCCore::loadConfig('lmt', $config);
+
+    self::$lmtDefaultLicence=$config['lmt_licence_default'];
+  }
+
+  /**
+   * the getImageId returns the name of the image id attribute
+   * return String
+   */
+  static public function getImageId()
+  {
+    return("pit2.id");
+  }
+
+  /**
+   * the getSelect function must return an attribute list separated with a comma
+   *
+   * "att1, att2, att3, att4"
+   */
+  static public function getSelect($param="")
+  {
+    //return("IF(pli.licence_type IS NULL, '".self::$lmtDefaultLicence."', pli.licence_type) AS imgLicence");
+    return("pli.licence_type");
+  }
+
+  /**
+   * the getFrom function must return a tables list separated with a comma
+   *
+   * "table1, (table2 left join table3 on table2.key = table3.key), table4"
+   */
+  static public function getFrom($param="")
+  {
+    global $prefixeTable;
+
+    return($prefixeTable."lmt_images pli
+        RIGHT JOIN ".IMAGES_TABLE." pit2 ON pit2.id = pli.image_id ");
+  }
+
+  /**
+   * the getWhere function must return a ready to use where clause
+   *
+   * "(att1 = value0 OR att2 = value1) AND att4 LIKE value2 "
+   */
+  static public function getWhere($param="")
+  {
+    global $user, $prefixeTable;
+
+    $returned=array();
+
+    foreach($param['licences'] as $val)
+    {
+      $returned[]="pli.licence_type = '$val'";
+
+      if($val==self::$lmtDefaultLicence)
+      {
+        $returned[]="pit2.id NOT IN (SELECT image_id FROM ".$prefixeTable."lmt_images)";
+      }
+    }
+
+    $returned=' '.implode(' OR ', $returned).' ';
+
+    return($returned);
+  }
+
+  /**
+   * the getJoin function must return a ready to use where allowing to join the
+   * IMAGES table (key : id) with given conditions
+   *
+   * "att3 = pit.id "
+   */
+  static public function getJoin($param="")
+  {
+    return("pit2.id = pit.id");
+  }
+
+
+  /**
+   * the getFilter function must return a ready to use where clause
+   * this where clause is used to filter the cache when the used tables can
+   * return more than one result
+   *
+   * the filter can be empty, can be equal to the where clause, or can be equal
+   * to a sub part of the where clause
+   *
+   */
+  static public function getFilter($param="")
+  {
+    return('');
+  }
+
+  /**
+   * this function is called by the request builder, allowing to display plugin
+   * data with a specific format
+   *
+   * @param Array $attributes : array of ('attribute_name' => 'attribute_value')
+   * @return String : HTML formatted value
+   */
+  static public function formatData($attributes)
+  {
+    /* attributes is an array :
+     *    Array(
+     *      'csColors' => 'color1,color2,color3,...,colorN',
+     *      'csColorsPct' => 'pct1,pct2,pct3,...,pctN'
+     *    );
+     */
+    if($attributes['licence_type']=='') $attributes['licence_type']=self::$lmtDefaultLicence;
+    $returned="<img class='imgLicence' src='./plugins/lmt/img/".strtolower($attributes['licence_type'])."_80x15.png'>&nbsp;".l10n('lmt_lbl_cc_s-'.strtolower($attributes['licence_type']));
+
+    return($returned);
+  }
+
+
+
+  /**
+   * this function is called by the request builder to make the search page, and
+   * must return the HTML & JS code of the dialogbox used to select criterion
+   *
+   * Notes :
+   *  - the dialogbox is a JS object with a public method 'show'
+   *  - when the method show is called, one parameter is given by the request
+   *    builder ; the parameter is an object defined as this :
+   *      {
+   *        cBuilder: an instance of the criteriaBuilder object used in the page,
+   *        eventOK : a callback function, called when the OK button is pushed
+   *        id:
+   *      }
+   *
+   *
+   *
+   *
+   * @param String $mode : can take 'admin' or 'public' values, allowing to
+   *                       return different interface if needed
+   * @return String : HTML formatted value
+   */
+  static public function getInterfaceContent($mode='admin')
+  {
+    return(LMT_functions::dialogBoxLMT());
+  }
+
+  /**
+   * this function returns the label displayed in the criterion menu
+   *
+   * @return String : label displayed in the criterions menu
+   */
+  static public function getInterfaceLabel()
+  {
+    return(l10n('lmt_add_licence_type'));
+  }
+
+  /**
+   * this function returns the name of the dialog box class
+   *
+   * @return String : name of the dialogbox class
+   */
+  static public function getInterfaceDBClass()
+  {
+    return('dialogChooseLMTBox');
+  }
+}
+
+RBCallBackLMT::init();
+
+
+?>
Index: /extensions/lmt/lmt_root.class.inc.php
===================================================================
--- /extensions/lmt/lmt_root.class.inc.php	(revision 7559)
+++ /extensions/lmt/lmt_root.class.inc.php	(revision 7560)
@@ -13,291 +13,167 @@
 
   --------------------------------------------------------------------------- */
-  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
-  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
-  include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
-
-  class LMT_root extends CommonPlugin
-  {
-    protected $css;   //the css object
-    protected $css_icn;   //the css object
-
-    protected $licences=array('BY', 'BY-ND', 'BY-NC', 'BY-NC-ND', 'BY-NC-SA', 'BY-SA', 'CRIGHT', 'CLEFT', 'DEFAULT');
-
-    public function __construct($prefixeTable, $filelocation)
-    {
-      $this->setPluginName('LMT');
-      $this->setPluginNameFiles("lmt");
-      parent::__construct($prefixeTable, $filelocation);
-      $this->section_name=$this->getPluginNameFiles();
-
-      $this->setTablesList(array('images', 'licence_author'));
-
-
-      $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
-      $this->css_icn = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."_icn.css");
-    }
-
-    public function __destruct()
-    {
-      unset($this->css);
-      unset($this->css_icn);
-      unset($this->licences);
-      parent::__destruct();
-    }
-
-    public function initEvents()
-    {
-      add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
-    }
-
-    /*
-      menu block management
-    */
-    public function register_blocks()
-    {
-    }
-
-
-
-    /*
-      surchage of CommonPlugin->saveConfig function
-    */
-    public function saveConfig()
-    {
-      if(parent::saveConfig())
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/CommonPlugin.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCCss.class.inc.php');
+include_once(PHPWG_PLUGINS_PATH.'GrumPluginClasses/classes/GPCAjax.class.inc.php');
+
+class LMT_root extends CommonPlugin
+{
+  protected $css;   //the css object
+  protected $css_icn;   //the css object
+
+  static public $licences=array('BY', 'BY-ND', 'BY-NC', 'BY-NC-ND', 'BY-NC-SA', 'BY-SA', 'CRIGHT', 'CLEFT', 'DEFAULT');
+
+  /**
+   * constructor
+   */
+  public function __construct($prefixeTable, $filelocation)
+  {
+    $this->setPluginName('LMT');
+    $this->setPluginNameFiles("lmt");
+    parent::__construct($prefixeTable, $filelocation);
+    $this->section_name=$this->getPluginNameFiles();
+
+    $this->setTablesList(array('images', 'licence_author'));
+
+    $this->css = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles().".css");
+    $this->css_icn = new GPCCss(dirname($this->getFileLocation()).'/'.$this->getPluginNameFiles()."_icn.css");
+  }
+
+  /**
+   * destructor
+   */
+  public function __destruct()
+  {
+    unset($this->css);
+    unset($this->css_icn);
+    parent::__destruct();
+  }
+
+  public function initEvents()
+  {
+    add_event_handler('blockmanager_register_blocks', array(&$this, 'register_blocks') );
+  }
+
+  /**
+   * menu block management
+   */
+  public function register_blocks()
+  {
+  }
+
+
+  /**
+   * initialize default values for config var
+   */
+  public function initConfig()
+  {
+    //global $user;
+    $this->config=array(
+      'lmt_list_maxheight' => '650',
+      'lmt_list_maxitems' => '0',    /* limit number of item displayed ; 0 : no limit */
+      'lmt_licence_default' => 'BY',
+      'lmt_licence_default_author' => 0,
+      'lmt_licence_activated' => 'n',
+      'lmt_licence_visible' => 'n',  /* y:always visible, n:only if needed */
+      'lmt_licence_logo' => '80x15', /* 80x15, 88x31, text */
+      'lmt_warning_visible' => 'y',     /* y: display a text at the bottom of each page */
+      'lmt_warning_texts' => array(), /* text displayed - multi lang */
+      'lmt_redirect_activated' => 'y',     /* y: the text is an url to a warning page */
+      'lmt_redirect_open_target' => 'n',   /* y: url are openned in a new page/tab */
+      'lmt_redirect_url-by' => array(),
+      'lmt_redirect_url-by-nd' => array(),
+      'lmt_redirect_url-by-nc' => array(),
+      'lmt_redirect_url-by-nc-nd' => array(),
+      'lmt_redirect_url-by-nc-sa' => array(),
+      'lmt_redirect_url-by-sa' => array(),
+      'lmt_redirect_url-cright' => array(),
+      'lmt_redirect_url-cleft' => array(),
+    );
+
+    $languages=get_languages();
+    foreach($languages as $key => $val)
+    {
+      $lang=substr($key,0,2)."/";
+      if($lang=="en/") { $lang=""; }
+      $this->config['lmt_warning_texts'][$key]='';
+      $this->config['lmt_redirect_url-by'][$key]='http://creativecommons.org/licenses/by/2.0/'.$lang;
+      $this->config['lmt_redirect_url-by-nd'][$key]='http://creativecommons.org/licenses/by-nd/2.0/'.$lang;
+      $this->config['lmt_redirect_url-by-nc'][$key]='http://creativecommons.org/licenses/by-nc/2.0/'.$lang;
+      $this->config['lmt_redirect_url-by-nc-nd'][$key]='http://creativecommons.org/licenses/by-nc-nd/2.0/'.$lang;
+      $this->config['lmt_redirect_url-by-nc-sa'][$key]='http://creativecommons.org/licenses/by-nc-sa/2.0/'.$lang;
+      $this->config['lmt_redirect_url-by-sa'][$key]='http://creativecommons.org/licenses/by-sa/2.0/'.$lang;
+      $this->config['lmt_redirect_url-cright'][$key]='';
+      $this->config['lmt_redirect_url-cleft'][$key]='';
+    }
+  }
+
+  /**
+   * returns the admin page link
+   */
+  public function getAdminLink($mode='')
+  {
+    if($mode=='ajax')
+    {
+      return('plugins/'.basename(dirname($this->getFileLocation())).'/lmt_ajax.php');
+    }
+    else
+    {
+      return(parent::getAdminLink());
+    }
+  }
+
+
+  /**
+   * return the licence type for an image
+   *
+   * returned array
+   *  'default'   => 'y' => if no licence for the picture, return de default
+   *                        licence
+   *                 'n' => if no licence for the picture, return empty values
+   *  'licence'   => the licence type
+   *  'aut_text1' => author, text 1
+   *  'aut_text2' => author, text 2
+   *
+   * @param Integer $image_id : the image id
+   * @return Array
+   */
+  public function getImageLicence($image_id)
+  {
+
+    $return=array(
+      "default" => "",
+      "licence" => "",
+      "aut_text1" => "",
+      "aut_text2" => ""
+    );
+    $sql="SELECT lmti.licence_type, lmta.text1, lmta.text2
+          FROM ".$this->tables['images']." lmti
+            LEFT OUTER JOIN ".$this->tables['licence_author']." lmta ON lmti.author_id = lmta.id
+          WHERE lmti.image_id = '".$image_id."'";
+    $result=pwg_query($sql);
+    if($result)
+    {
+      while($row=pwg_db_fetch_assoc($result))
       {
-        $this->css->makeCSS($this->generate_CSS());
-        $this->css_icn->makeCSS($this->generate_CSS2());
-        return(true);
+        $return=array(
+          "defaut" => "n",
+          "licence" => $row['licence_type'],
+          "aut_text1" => $row['text1'],
+          "aut_text2" => $row['text2']
+        );
       }
-      return(false);
-    }
-
-    /*
-      surchage of CommonPlugin->saveConfig function
-    */
-    public function loadConfig()
-    {
-      parent::loadConfig();
-      if(!$this->css->fileExists())
-      {
-        $this->css->makeCSS($this->generate_CSS());
-      }
-      if(!$this->css_icn->fileExists())
-      {
-        $this->css_icn->makeCSS($this->generate_CSS2());
-      }
-    }
-
-    /*
-      intialize default values
-    */
-    public function initConfig()
-    {
-      //global $user;
-      $this->config=array(
-        'lmt_mouseovercolor' => '303030', /**/
-        'lmt_list_maxheight' => '650',
-        'lmt_list_maxitems' => '0',    /* limit number of item displayed ; 0 : no limit */
-        'lmt_licence_default' => 'BY',
-        'lmt_licence_default_author' => 0,
-        'lmt_licence_activated' => 'n',
-        'lmt_licence_visible' => 'n',  /* y:always visible, n:only if needed */
-        'lmt_licence_logo' => '80x15', /* 80x15, 88x31, text */
-        'lmt_warning_visible' => 'y',     /* y: display a text at the bottom of each page */
-        'lmt_warning_texts' => array(), /* text displayed - multi lang */
-        'lmt_redirect_activated' => 'y',     /* y: the text is an url to a warning page */
-        'lmt_redirect_open_target' => 'n',   /* y: url are openned in a new page/tab */
-        'lmt_redirect_url-by' => array(),
-        'lmt_redirect_url-by-nd' => array(),
-        'lmt_redirect_url-by-nc' => array(),
-        'lmt_redirect_url-by-nc-nd' => array(),
-        'lmt_redirect_url-by-nc-sa' => array(),
-        'lmt_redirect_url-by-sa' => array(),
-        'lmt_redirect_url-cright' => array(),
-        'lmt_redirect_url-cleft' => array(),
-      );
-
-      $languages=get_languages();
-      foreach($languages as $key => $val)
-      {
-        $lang=substr($key,0,2)."/";
-        if($lang=="en/") { $lang=""; }
-        $this->config['lmt_warning_texts'][$key]='';
-        $this->config['lmt_redirect_url-by'][$key]='http://creativecommons.org/licenses/by/2.0/'.$lang;
-        $this->config['lmt_redirect_url-by-nd'][$key]='http://creativecommons.org/licenses/by-nd/2.0/'.$lang;
-        $this->config['lmt_redirect_url-by-nc'][$key]='http://creativecommons.org/licenses/by-nc/2.0/'.$lang;
-        $this->config['lmt_redirect_url-by-nc-nd'][$key]='http://creativecommons.org/licenses/by-nc-nd/2.0/'.$lang;
-        $this->config['lmt_redirect_url-by-nc-sa'][$key]='http://creativecommons.org/licenses/by-nc-sa/2.0/'.$lang;
-        $this->config['lmt_redirect_url-by-sa'][$key]='http://creativecommons.org/licenses/by-sa/2.0/'.$lang;
-        $this->config['lmt_redirect_url-cright'][$key]='';
-        $this->config['lmt_redirect_url-cleft'][$key]='';
-      }
-
-    }
-
-    /*
-      generate the css code
-    */
-    protected function generate_CSS()
-    {
-      $text = "
-.TableRow:hover
-{
-  background-color:#".$this->config['lmt_mouseovercolor'].";
-}
-
-.formtable
-{
-  text-align:justify;
-  display:block;
-  margin-top:0px;
-  margin-bottom:0px;
-  width:100%;
-}
-
-.formtable tr {
-  vertical-align:top;
-}
-
-.littlefont { font-size:90%; }
-table.littlefont th { text-align:center; padding:3px;padding-left:9px;padding-right:9px; }
-table.littlefont td { text-align:left; padding:0px;padding-left:3px;padding-right:3px; }
-
-.lmt_page
-{
-  text-align:justify;
-  margin:8px;
-}
-
-.lmt  {
-  text-align:justify;
-}
-
-#list {
-  width:100%;
-  overflow-y:scroll;
-  min-height:250px;
-  max-height:650px;
-}
-
-#ullist li {
-  width:300px;
-  display:block;
-  float:left;
-  text-align:left;
-}
-
-#ullist label {
-  float:left;
-}
-
-#ullist li table {
-  margin:0px;
-  text-align:left;
-  width:300px;
-  font-size:80%;
-}
-
-#ullist li tr {
-  vertical-align:top;
-}
-
-.content ul.thumbnails span.extendwrap1 {
-  margin:0px;
-  cursor:pointer;
-}
-
-.is_on, .is_off {
-  z-index:20;
-  width:12px;
-  height:12px;
-  display:block;
-  cursor:pointer;
-}
-
-.is_on {
-  background:url(./img/cb_on.png);
-}
-.is_off {
-  background:url(./img/cb_off.png);
-}
-
-.icnhelp {
-  weight:bold;
-  text-decoration:none;
-  cursor:help;
-}
-
-.hinthlp {
-  position:absolute;
-  max-width:400px;
-  border:1px solid #000000;
-  background:#ffffa0;
-  color:#000000;
-  top:0px;
-  left:-450px;
-  padding:2px;
-  text-align:justify;
-}
-
-      ";
-      return($text);
-    }
-
-    /*
-      generate the css code
-    */
-    protected function generate_CSS2()
-    {
-      $text = "
-.logo80x15 {
-  position:relative;
-  top:4px;
-  margin-right:4px;
-  border:0px none;
-}
-
-.logo88x31 {
-  position:relative;
-  margin-right:4px;
-  border:0px none;
-}
-
-#theImage img.logo80x15, #theImage img.logo88x31 {
-  border:0px none;
-  padding:0px;
-}
-
-.licencetag {
-  display:block;
-  padding-top:10px;
-  font-size:80%;
-}
-      ";
-      return($text);
-    }
-
-
-
-
-    /* -------------------------------------------------------------------------
-     return the licence type for an image
-      $default = 'y' => if no licence for the picture, return de default licence
-                 'n' => if no licence for the picture, return empty values
-    ------------------------------------------------------------------------- */
-    public function get_image_licence($image_id)
-    {
-
+    }
+
+    if(($return["licence"]=="")&&($this->config["lmt_licence_visible"]=="y"))
+    {
       $return=array(
-        "default" => "",
-        "licence" => "",
+        "defaut" => "y",
+        "licence" => $this->config["lmt_licence_default"],
         "aut_text1" => "",
         "aut_text2" => ""
       );
-      $sql="SELECT lmti.licence_type, lmta.text1, lmta.text2
-            FROM ".$this->tables['images']." lmti
-              LEFT OUTER JOIN ".$this->tables['licence_author']." lmta ON lmti.author_id = lmta.id
-            WHERE lmti.image_id = '".$image_id."'";
+
+      $sql="SELECT * FROM ".$this->tables['licence_author']."
+            WHERE id = '".$this->config["lmt_licence_default_author"]."'";
       $result=pwg_query($sql);
       if($result)
@@ -305,81 +181,146 @@
         while($row=pwg_db_fetch_assoc($result))
         {
-          $return=array(
-            "defaut" => "n",
-            "licence" => $row['licence_type'],
-            "aut_text1" => $row['text1'],
-            "aut_text2" => $row['text2']
-          );
+          $return["aut_text1"]=$row['text1'];
+          $return["aut_text2"]=$row['text2'];
         }
       }
-
-      if(($return["licence"]=="")&&($this->config["lmt_licence_visible"]=="y"))
+    }
+
+    return($return);
+  }
+
+
+  /**
+   * returns an array of image id with the asked licence type
+   * if $licence = "" => return all picture with a specific licences
+   *
+   * @param String $licence : licence to be filtered
+   * @return Array
+   */
+  public function getImagesLicences($licence)
+  {
+    $sql="".$this->tables['lmt'];
+
+    $result=pwg_query($sql.$sql_where.$sql_order);
+    if($result)
+    {
+      $returned=array();
+      while($row=pwg_db_fetch_assoc($result))
       {
-        $return=array(
-          "defaut" => "y",
-          "licence" => $this->config["lmt_licence_default"],
-          "aut_text1" => "",
-          "aut_text2" => ""
+        array_push($returned, $row);
+      }
+      return($returned);
+    }
+    return(false);
+  }
+
+
+  protected function displayResult($action_msg, $result)
+  {
+    global $page;
+
+    if($result)
+    {
+      array_push($page['infos'], $action_msg);
+    }
+    else
+    {
+      array_push($page['errors'], $action_msg);
+    }
+  }
+
+
+  /**
+   * build image url (for a given category)
+   *
+   *
+   */
+  protected function makeImageDatas($tmp, $imageId)
+  {
+    $tmp2=array();
+    foreach($tmp['id'] as $key=>$val)
+    {
+      $tmp2[]=array(
+        'id' => $tmp['id'][$key],
+        'name' => $tmp['name'][$key],
+        'type' => $tmp['type'][$key],
+        'plinks' => $tmp['plinks'][$key],
+        'link'=> make_picture_url(
+                  array(
+                    'image_id' => $imageId,
+                    'category' => array
+                      (
+                        'id' => $tmp['id'][$key],
+                        'name' => $tmp['name'][$key],
+                        'permalink' => $tmp['plinks'][$key]
+                      )
+                  )
+                )
+      );
+    }
+    return($tmp2);
+  }
+
+} //class
+
+
+
+
+class LMT_functions
+{
+  static private $tables = Array();
+  static private $config = Array();
+
+  /**
+   * initialise the class
+   *
+   * @param String $prefixeTable : the piwigo prefixe used on tables name
+   * @param String $pluginNameFile : the plugin name used for tables name
+   */
+  static public function init($prefixeTable)
+  {
+    GPCCore::loadConfig(LMT_root::$pluginNameFile, self::$config);
+    $list=LMT_root::$pluginTables;
+
+    for($i=0;$i<count($list);$i++)
+    {
+      self::$tables[$list[$i]]=$prefixeTable.LMT_root::$pluginNameFile.'_'.$list[$i];
+    }
+  }
+
+
+  /**
+   *  return all HTML&JS code necessary to display a dialogbox to choose
+   *  geographic area
+   */
+  static public function dialogBoxLMT()
+  {
+    global $template;
+
+    $template->set_filename('lmt_choose',
+                  dirname(__FILE__).'/templates/lmt_dialog_licence_choose.tpl');
+
+    $datas=Array(
+      'licencesList' => array()
+    );
+
+    foreach(LMT_root::$licences as $licence)
+    {
+      if($licence!='DEFAULT')
+      {
+        $datas['licencesList'][]=array(
+          'value' => $licence,
+          'name' => l10n('lmt_lbl_cc_s-'.strtolower($licence))
         );
-
-        $sql="SELECT * FROM ".$this->tables['licence_author']."
-              WHERE id = '".$this->config["lmt_licence_default_author"]."'";
-        $result=pwg_query($sql);
-        if($result)
-        {
-          while($row=pwg_db_fetch_assoc($result))
-          {
-            $return["aut_text1"]=$row['text1'];
-            $return["aut_text2"]=$row['text2'];
-          }
-        }
       }
-
-      return($return);
-    }
-
-
-    /* -------------------------------------------------------------------------
-     returns an array of image id with the licence type
-      if $licence = "" => return all picture with a specific licences
-    ------------------------------------------------------------------------- */
-    public function get_images_licences($licence)
-    {
-      $sql="".$this->tables['lmt'];
-
-      $result=pwg_query($sql.$sql_where.$sql_order);
-      if($result)
-      {
-        $returned=array();
-        while($row=pwg_db_fetch_assoc($result))
-        {
-          array_push($returned, $row);
-        }
-        return($returned);
-      }
-      return(false);
-    }
-
-  protected function displayResult($action_msg, $result)
-  {
-    global $page;
-
-    if($result)
-    {
-      array_push($page['infos'], $action_msg);
-    }
-    else
-    {
-      array_push($page['errors'], $action_msg);
-    }
-  }
-
-
-    /* ---------------------------------------------------------------------------
-      ajax functions
-    --------------------------------------------------------------------------- */
-
-
-  } //class
+    }
+
+    $template->assign('datas', $datas);
+
+    return($template->parse('lmt_choose', true));
+  }
+} //GMaps_functions
+
+
 
 ?>
Index: /extensions/lmt/lmt_version.inc.php
===================================================================
--- /extensions/lmt/lmt_version.inc.php	(revision 7559)
+++ /extensions/lmt/lmt_version.inc.php	(revision 7560)
@@ -15,5 +15,6 @@
   if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-  define('LMT_VERSION',  '1.2.3');
-  define('LMT_VERSION2', '01.02.03');
+  define('LMT_VERSION',  '1.3.0');
+  define('LMT_VERSION2', '01.03.00');
+  define('LMT_GPC_NEEDED', '3.3.3');
 ?>
Index: /extensions/lmt/main.inc.php
===================================================================
--- /extensions/lmt/main.inc.php	(revision 7559)
+++ /extensions/lmt/main.inc.php	(revision 7560)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: LMT
-Version: 1.2.3
+Version: 1.3.0
 Description: Appliquer une licence sur ses photos / Apply a licence on photos
 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=282
@@ -108,6 +108,10 @@
 {
   //LMT public interface loaded and active only if in public page
-  include_once("lmt_pip.class.inc.php");
-  $obj=new LMT_PIP($prefixeTable, __FILE__);
+  if(CommonPlugin::checkGPCRelease(LMT_GPC_NEEDED))
+  {
+    //LMT public interface loaded and active only if in public page
+    include_once("lmt_pip.class.inc.php");
+    $obj=new LMT_PIP($prefixeTable, __FILE__);
+  }
 }
 
Index: /extensions/lmt/maintain.inc.php
===================================================================
--- /extensions/lmt/maintain.inc.php	(revision 7559)
+++ /extensions/lmt/maintain.inc.php	(revision 7560)
@@ -14,4 +14,6 @@
 if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
 
+include_once('lmt_version.inc.php'); // => Don't forget to update this file !!
+
 if(!defined('LMT_DIR')) define('LMT_DIR' , basename(dirname(__FILE__)));
 if(!defined('LMT_PATH')) define('LMT_PATH' , PHPWG_PLUGINS_PATH . LMT_DIR . '/');
@@ -20,21 +22,21 @@
 //ini_set('display_errors', true);
 
-global $gpc_installed, $gpcNeeded, $lang; //needed for plugin manager compatibility
+global $gpcInstalled, $lang; //needed for plugin manager compatibility
 
 /* -----------------------------------------------------------------------------
-LMT needs the Grum Plugin Classe
+LMT needs the Grum Plugin Classes
 ----------------------------------------------------------------------------- */
-$gpc_installed=false;
-$gpcNeeded="3.0.0";
+$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 3.0.0
-  if(CommonPlugin::checkGPCRelease(3,0,0))
+  // need GPC release greater or equal than ...
+  if(CommonPlugin::checkGPCRelease(LMT_GPC_NEEDED))
   {
     @include_once('lmt_install.class.inc.php');
-    $gpc_installed=true;
+    $gpcInstalled=true;
   }
 }
+
 
 function gpcMsgError(&$errors)
@@ -61,68 +63,48 @@
 function plugin_install($plugin_id, $plugin_version, &$errors)
 {
-  global $prefixeTable, $gpc_installed, $gpcNeeded;
+  global $prefixeTable, $gpcInstalled;
+  if(!$gpcInstalled)
+  {
+    gpcMsgError($errors, 'gpc');
+    return(false);
+  }
 
-  if($gpc_installed)
+  $obj = new LMT_Install($prefixeTable, __FILE__);
+  $result=$obj->install();
+}
+
+
+
+function plugin_activate($plugin_id, $plugin_version, &$errors)
+{
+  global $prefixeTable, $gpcInstalled;
+
+  if($gpcInstalled)
   {
     $obj = new LMT_Install($prefixeTable, __FILE__);
-    $result=$obj->install();
-    if(!$result)
-    {
-      array_push($errors, "error");
-    }
-    GPCCore::register($obj->getPluginName(), LMT_VERSION, $gpcNeeded);
-  }
-  else
-  {
-    gpcMsgError($errors);
+    $result=$obj->activate();
   }
 }
 
-function plugin_activate($plugin_id, $plugin_version, &$errors)
-{
-  global $prefixeTable, $gpc_installed;
-
-  if($gpc_installed)
-  {
-    $obj = new LMT_Install($prefixeTable, __FILE__);
-    $result=$obj->activate();
-    if($result===false or $result!='')
-    {
-      if(is_string($result))
-      {
-        array_push($errors, $result);
-      }
-      else
-      {
-        array_push($errors, "");
-      }
-    }
-  }
-  else
-  {
-    gpcMsgError($errors);
-  }
-}
 
 function plugin_deactivate($plugin_id)
 {
-/*  global $prefixeTable;
-  $obj = new install_mypolls($prefixeTable, __FILE__);
-  $obj->deactivate(); */
+  global $prefixeTable, $gpcInstalled;
+
+  if($gpcInstalled)
+  {
+    $obj=new LMT_Install($prefixeTable, __FILE__);
+    $obj->deactivate();
+  }
 }
 
 function plugin_uninstall($plugin_id)
 {
-  global $prefixeTable, $gpc_installed;
+  global $prefixeTable, $gpcInstalled;
 
-  if($gpc_installed)
+  if($gpcInstalled)
   {
     $obj = new LMT_Install($prefixeTable, __FILE__);
     $obj->uninstall();
-    GPCCore::unregister($obj->getPluginName());
-  }
-  else
-  {
-    gpcMsgError($errors);
   }
 }
