Index: /extensions/AStat/admin/astat_admin.tpl
===================================================================
--- /extensions/AStat/admin/astat_admin.tpl	(revision 5422)
+++ /extensions/AStat/admin/astat_admin.tpl	(revision 5423)
@@ -1,34 +1,42 @@
-<div class="titrePage">
-  <h2 style="position:absolute;right:0px;top:32px;height:auto;font-size:12px;font-weight:normal;">:: {$plugin.ASTAT_VERSION} ::</h2>
-  <h2>{'AStat_title_page'|@translate} <span style="font-size:-1;font-weight:normal;">{$TABSHEET_TITLE}</span></h2>
 
+<h2 style="float:right;top:-24px;position:relative;height:auto;font-size:12px;font-weight:normal;">{$plugin.ASTAT_VERSION}</h2>
+
+
+<div style="position:relative;top:-24px;clear:right;">
   {$tabsheet}
+
+  {if isset($datas)}
+    <p>{$datas.ASTAT_NFO_STAT}</p>
+
+    <h3>{$datas.L_STAT_TITLE}</h3>
+
+    {if isset($f_AStat_catfilter_list_values) and count($f_AStat_catfilter_list_values)
+           and isset($plugin.ASTAT_PAGE) and $plugin.ASTAT_PAGE != "config" and $plugin.ASTAT_PAGE != "tools"}
+      <center>
+        <form method="GET" action="{$plugin.ASTAT_LINK}" class="general">
+
+            {if isset($f_AStat_parameters) and count($f_AStat_parameters)}
+              {foreach from=$f_AStat_parameters key=name item=data}
+                <INPUT type="hidden" name="{$data.NAME}" value="{$data.VALUE}">
+              {/foreach}
+            {/if}
+            <fieldset>
+              <legend>{'AStat_catfilter_list'|@translate}</legend>
+              <select name="fAStat_catfilter" onchange="this.form.submit();">
+                {html_options values=$f_AStat_catfilter_list_values output=$f_AStat_catfilter_list_labels selected=$f_AStat_catfilter_selected}
+              </select>
+            </fieldset>
+        </form>
+      </center>
+    {/if}
+
+  {/if}
+
+
 </div>
 
-{if isset($datas)}
-  {$datas.ASTAT_NFO_STAT}
-  <h3>{$datas.L_STAT_TITLE}</h3>
 
-  {if isset($f_AStat_catfilter_list_values) and count($f_AStat_catfilter_list_values)
-         and isset($plugin.ASTAT_PAGE) and $plugin.ASTAT_PAGE != "config" and $plugin.ASTAT_PAGE != "tools"}
-    <center>
-      <form method="GET" action="{$plugin.ASTAT_LINK}" class="general">
 
-          {if isset($f_AStat_parameters) and count($f_AStat_parameters)}
-            {foreach from=$f_AStat_parameters key=name item=data}
-              <INPUT type="hidden" name="{$data.NAME}" value="{$data.VALUE}">
-            {/foreach}
-          {/if}
-          <fieldset>
-            <legend>{'AStat_catfilter_list'|@translate}</legend>
-            <select name="fAStat_catfilter" onchange="this.form.submit();">
-              {html_options values=$f_AStat_catfilter_list_values output=$f_AStat_catfilter_list_labels selected=$f_AStat_catfilter_selected}
-            </select>
-          </fieldset>
-      </form>
-    </center>
-  {/if}
 
-{/if}
 
 {$ASTAT_BODY_PAGE}
Index: /extensions/AStat/admin/astat_tools.tpl
===================================================================
--- /extensions/AStat/admin/astat_tools.tpl	(revision 5422)
+++ /extensions/AStat/admin/astat_tools.tpl	(revision 5423)
@@ -1,5 +1,5 @@
-{known_script id="jquery.ui" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.core.packed.js"}
-{known_script id="jquery.ui.datepicker" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.datepicker.packed.js"}
-{assign var="datepicker_language" value="template-common/lib/ui/i18n/ui.datepicker-"|@cat:$lang_info.code|@cat:".js"}
+{known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.core.packed.js"}
+{known_script id="jquery.ui.datepicker" src=$ROOT_URL|@cat:"themes/default/js/ui/packed/ui.datepicker.packed.js"}
+{assign var="datepicker_language" value="themes/default/js/ui/packed/i18n/ui.datepicker-"|@cat:$lang_info.code|@cat:".js"}
 
 {if "PHPWG_ROOT_PATH"|@constant|@cat:$datepicker_language|@file_exists}
@@ -19,11 +19,11 @@
 
   if(($('#purge_history_confirm').attr('checked')&&$('#purge_history_type0').attr('checked')&&re.test($('#purge_history_date').val()))||
-     ($('#purge_history_confirm').attr('checked')&&!('#purge_history_type0').attr('checked')))
+     ($('#purge_history_confirm').attr('checked')&&!$('#purge_history_type0').attr('checked')))
   {
-    $('#purge_history_button').attr('disabled', true);
+    $('#purge_history_button').attr('disabled', false);
   }
   else
   {
-    $('#purge_history_button').attr('disabled', false);
+    $('#purge_history_button').attr('disabled', true);
   }
  }
Index: /extensions/AStat/astat_aim.class.inc.php
===================================================================
--- /extensions/AStat/astat_aim.class.inc.php	(revision 5422)
+++ /extensions/AStat/astat_aim.class.inc.php	(revision 5423)
@@ -171,5 +171,5 @@
     if($result)
     {
-      $row = mysql_fetch_array($result);
+      $row = pwg_db_fetch_assoc($result);
       $list=substr($row['Type'], 5, strlen($row['Type'])-6);
       $returned[0]=explode(',', $list);
Index: /extensions/AStat/astat_aip.class.inc.php
===================================================================
--- /extensions/AStat/astat_aip.class.inc.php	(revision 5422)
+++ /extensions/AStat/astat_aip.class.inc.php	(revision 5423)
@@ -435,5 +435,5 @@
 
     $i=0;
-    while ($row = mysql_fetch_array($result))
+    while ($row = pwg_db_fetch_assoc($result))
     {
       if($year.$month.$day=="")
@@ -534,5 +534,5 @@
 
     $i=0;
-    while ($row = mysql_fetch_array($result))
+    while ($row = pwg_db_fetch_assoc($result))
     {
       $returned0[$i] = $row; $i++;
@@ -543,5 +543,5 @@
     if($result)
     {
-      $row = mysql_fetch_array($result); $returned[1] = $row[0];
+      $row = pwg_db_fetch_row($result); $returned[1] = $row[0];
     }
     else
@@ -638,5 +638,5 @@
 
     $i=0;
-    while ($row = mysql_fetch_array($result))
+    while ($row = pwg_db_fetch_assoc($result))
     {
       $returned0[$i] = $row; $i++;
@@ -647,5 +647,5 @@
     if($result)
     {
-      $row = mysql_fetch_array($result); $returned[1] = $row[0];
+      $row = pwg_db_fetch_row($result); $returned[1] = $row[0];
     }
     else
@@ -738,5 +738,5 @@
 
     $i=0;
-    while ($row = mysql_fetch_array($result))
+    while ($row = pwg_db_fetch_assoc($result))
     {
       $returned0[$i] = $row; $i++;
@@ -747,5 +747,5 @@
     if($result)
     {
-      $row = mysql_fetch_array($result); $returned[1] = $row[0];
+      $row = pwg_db_fetch_row($result); $returned[1] = $row[0];
     }
     else
@@ -1116,4 +1116,6 @@
     $template->set_filename('body_page', dirname(__FILE__)."/admin/astat_by_category.tpl");
 
+    $template_datas=array();
+    $template_datarows=array();
 
     /* requete */
@@ -1918,5 +1920,5 @@
       {
         $returned[0]=0;
-        while ($row = mysql_fetch_array($result))
+        while ($row = pwg_db_fetch_row($result))
         {
           $returned[2][$returned[0]][0] = $row[0];
@@ -1965,5 +1967,5 @@
       {
         $returned[0]=0;
-        while ($row = mysql_fetch_array($result))
+        while ($row = pwg_db_fetch_row($result))
         {
           $returned[2][$returned[0]][0] = $row[0];
@@ -2017,5 +2019,5 @@
       {
         $returned[0]=0;
-        while ($row = mysql_fetch_array($result))
+        while ($row = pwg_db_fetch_row($result))
         {
           $returned[2][$returned[0]][0] = $row[0];
@@ -2062,5 +2064,5 @@
     if($result)
     {
-      $row = mysql_fetch_array($result);
+      $row = pwg_db_fetch_row($result);
       if(is_array($row))
       {
@@ -2070,5 +2072,5 @@
         if($result)
         {
-          $row2=mysql_fetch_array($result);
+          $row2=pwg_db_fetch_assoc($result);
           array_push($returned, $row2['Data_length'], $row2['Index_length']);
         }
@@ -2124,5 +2126,5 @@
     if($result)
     {
-      $row=mysql_fetch_array($result);
+      $row=pwg_db_fetch_row($result);
       return($row[0]);
     }
@@ -2136,5 +2138,5 @@
     if($result)
     {
-      $row=mysql_fetch_array($result);
+      $row=pwg_db_fetch_row($result);
       return($row[0]);
     }
@@ -2163,5 +2165,5 @@
       if($result)
       {
-        $row=mysql_fetch_array($result);
+        $row=pwg_db_fetch_row($result);
         $returned[0]=$row[0];
       }
@@ -2184,5 +2186,5 @@
     if($result)
     {
-      if(mysql_num_rows($result)==1)
+      if(pwg_db_num_rows($result)==1)
       {
         return(true);
@@ -2222,7 +2224,7 @@
       if($result)
       {
-        if(mysql_num_rows($result)>0)
-        {
-          $row=mysql_fetch_row($result);
+        if(pwg_db_num_rows($result)>0)
+        {
+          $row=pwg_db_fetch_row($result);
           $returned[0]=true;
           $returned[1]=$row[0];
@@ -2296,5 +2298,5 @@
     if($result)
     {
-      while ($row = mysql_fetch_array($result))
+      while ($row = pwg_db_fetch_assoc($result))
       {
         $text=str_repeat('&nbsp;&nbsp;', substr_count($row['global_rank'], '.'));
@@ -2339,5 +2341,5 @@
     if($result)
     {
-      while ($row = mysql_fetch_row($result))
+      while ($row = pwg_db_fetch_row($result))
       {
         $returned[]=$row[0];
@@ -2473,5 +2475,5 @@
     if($result)
     {
-      while($row=mysql_fetch_array($result))
+      while($row=pwg_db_fetch_assoc($result))
       {
         $list.="<option value='".$row['IP']."'>".$row['IP'].str_repeat("&nbsp;", 15-strlen($row['IP']))."&nbsp;&nbsp;&nbsp;&nbsp;(".$row['NbEvents'].")</option>";
Index: /extensions/AStat/main.inc.php
===================================================================
--- /extensions/AStat/main.inc.php	(revision 5422)
+++ /extensions/AStat/main.inc.php	(revision 5423)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: AStat.2
-Version: 2.1.1
+Version: 2.2.0
 Description: Statistiques avancées / Advanced statistics
 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=172
@@ -42,4 +42,14 @@
 | 2.1.1   | 2009/11/15 | * bug on tools (cf. bug #1242 in mantis)
 |         |            |   it was impossible to purge items in history due to an invalid regexp in the javascript
+| 2.2.0   | 2010/03/28 | * release for compatibility with Piwigo 2.1
+|         |            | * mantis: bug 1192
+|         |            |   Constant already defined when deactivating the plugin
+|         |            | * mantis: bug 1344
+|         |            |   In tools, it's allowed to do purge only if checkbox is not checked
+|         |            |
+|         |            |
+|         |            |
+|         |            |
+|         |            |
 |         |            |
 |         |            |
@@ -71,5 +81,5 @@
 define('ASTAT_PATH' , PHPWG_PLUGINS_PATH . ASTAT_DIR . '/');
 
-define('ASTAT_VERSION' , '2.1.1'); // => ne pas oublier la version dans l'entête !!
+define('ASTAT_VERSION' , '2.2.0'); // => ne pas oublier la version dans l'entête !!
 
 global $prefixeTable;
Index: /extensions/AStat/maintain.inc.php
===================================================================
--- /extensions/AStat/maintain.inc.php	(revision 5422)
+++ /extensions/AStat/maintain.inc.php	(revision 5423)
@@ -12,8 +12,8 @@
   --------------------------------------------------------------------------- */
 
-if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
+if(!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); }
 
-define('ASTAT_DIR' , basename(dirname(__FILE__)));
-define('ASTAT_PATH' , PHPWG_PLUGINS_PATH . ASTAT_DIR . '/');
+if(!defined('ASTAT_DIR')) define('ASTAT_DIR' , basename(dirname(__FILE__)));
+if(!defined('ASTAT_PATH')) define('ASTAT_PATH' , PHPWG_PLUGINS_PATH . ASTAT_DIR . '/');
 
 //ini_set('error_reporting', E_ALL);
@@ -46,5 +46,5 @@
 load_language('plugin.lang', ASTAT_PATH);
 
-function plugin_install($plugin_id, $plugin_version, &$errors) 
+function plugin_install($plugin_id, $plugin_version, &$errors)
 {
   global $prefixeTable, $gpc_installed;
