Skip to content

Commit

Permalink
Update the plugin for compatibility with Piwigo 2.1 and fix some bugs
Browse files Browse the repository at this point in the history
feature 1192, feature 1344

git-svn-id: http://piwigo.org/svn/extensions/AStat@5423 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
grum committed Mar 28, 2010
1 parent c542e89 commit 1337686
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 61 deletions.
62 changes: 35 additions & 27 deletions admin/astat_admin.tpl
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
<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}
</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 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}

{/if}

</div>





{$ASTAT_BODY_PAGE}

12 changes: 6 additions & 6 deletions admin/astat_tools.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{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}
{known_script id="jquery.ui.datepicker-$lang_info.code" src=$ROOT_URL|@cat:$datepicker_language}
Expand All @@ -18,13 +18,13 @@
re = /\d{2}\/\d{2}\/\d{4}/i;

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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion astat_aim.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function get_section_enum($add)
$result=pwg_query($sql);
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);
if((strpos($list, "'$add'")===false)&&($add!=''))
Expand Down
44 changes: 23 additions & 21 deletions astat_aip.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ private function stats_by_period($total, $year, $month, $day)
$result = pwg_query($sql);

$i=0;
while ($row = mysql_fetch_array($result))
while ($row = pwg_db_fetch_assoc($result))
{
if($year.$month.$day=="")
{ $returned[$i] = $row; $i++; }
Expand Down Expand Up @@ -533,7 +533,7 @@ private function stats_by_ip($year, $month, $day, $nbipperpage, $pagenumber, $so
$sql="select FOUND_ROWS()";

$i=0;
while ($row = mysql_fetch_array($result))
while ($row = pwg_db_fetch_assoc($result))
{
$returned0[$i] = $row; $i++;
}
Expand All @@ -542,7 +542,7 @@ private function stats_by_ip($year, $month, $day, $nbipperpage, $pagenumber, $so
$result = pwg_query($sql);
if($result)
{
$row = mysql_fetch_array($result); $returned[1] = $row[0];
$row = pwg_db_fetch_row($result); $returned[1] = $row[0];
}
else
{
Expand Down Expand Up @@ -637,7 +637,7 @@ private function stats_by_category($year, $month, $day, $nbipperpage, $pagenumbe
$sql="select FOUND_ROWS()";

$i=0;
while ($row = mysql_fetch_array($result))
while ($row = pwg_db_fetch_assoc($result))
{
$returned0[$i] = $row; $i++;
}
Expand All @@ -646,7 +646,7 @@ private function stats_by_category($year, $month, $day, $nbipperpage, $pagenumbe
$result = pwg_query($sql);
if($result)
{
$row = mysql_fetch_array($result); $returned[1] = $row[0];
$row = pwg_db_fetch_row($result); $returned[1] = $row[0];
}
else
{
Expand Down Expand Up @@ -737,7 +737,7 @@ private function stats_by_image($year, $month, $day, $nbipperpage, $pagenumber,
$sql="select FOUND_ROWS()";

$i=0;
while ($row = mysql_fetch_array($result))
while ($row = pwg_db_fetch_assoc($result))
{
$returned0[$i] = $row; $i++;
}
Expand All @@ -746,7 +746,7 @@ private function stats_by_image($year, $month, $day, $nbipperpage, $pagenumber,
$result = pwg_query($sql);
if($result)
{
$row = mysql_fetch_array($result); $returned[1] = $row[0];
$row = pwg_db_fetch_row($result); $returned[1] = $row[0];
}
else
{
Expand Down Expand Up @@ -1115,6 +1115,8 @@ private function display_stats_by_category($year, $month, $day, $max_width, $nbi

$template->set_filename('body_page', dirname(__FILE__)."/admin/astat_by_category.tpl");

$template_datas=array();
$template_datarows=array();

/* requete */
//calc_time(true);
Expand Down Expand Up @@ -1917,7 +1919,7 @@ private function tools_deleted_user($mode)
if($result)
{
$returned[0]=0;
while ($row = mysql_fetch_array($result))
while ($row = pwg_db_fetch_row($result))
{
$returned[2][$returned[0]][0] = $row[0];
$returned[2][$returned[0]][1] = $row[1];
Expand Down Expand Up @@ -1964,7 +1966,7 @@ private function tools_deleted_picture($mode)
if($result)
{
$returned[0]=0;
while ($row = mysql_fetch_array($result))
while ($row = pwg_db_fetch_row($result))
{
$returned[2][$returned[0]][0] = $row[0];
$returned[2][$returned[0]][1] = $row[1];
Expand Down Expand Up @@ -2016,7 +2018,7 @@ private function tools_deleted_category($mode)
if($result)
{
$returned[0]=0;
while ($row = mysql_fetch_array($result))
while ($row = pwg_db_fetch_row($result))
{
$returned[2][$returned[0]][0] = $row[0];
$returned[2][$returned[0]][1] = $row[1];
Expand Down Expand Up @@ -2061,15 +2063,15 @@ private function tools_general_nfo()
$result=pwg_query($sql);
if($result)
{
$row = mysql_fetch_array($result);
$row = pwg_db_fetch_row($result);
if(is_array($row))
{
$returned = $row;
$sql="SHOW TABLE STATUS LIKE '".HISTORY_TABLE."';";
$result=pwg_query($sql);
if($result)
{
$row2=mysql_fetch_array($result);
$row2=pwg_db_fetch_assoc($result);
array_push($returned, $row2['Data_length'], $row2['Index_length']);
}
}
Expand Down Expand Up @@ -2123,7 +2125,7 @@ private function purge_history_count_imageid0()
$result=pwg_query($sql);
if($result)
{
$row=mysql_fetch_array($result);
$row=pwg_db_fetch_row($result);
return($row[0]);
}
return(0);
Expand All @@ -2135,7 +2137,7 @@ private function purge_history_count_categoryid0()
$result=pwg_query($sql);
if($result)
{
$row=mysql_fetch_array($result);
$row=pwg_db_fetch_row($result);
return($row[0]);
}
return(0);
Expand All @@ -2162,7 +2164,7 @@ private function purge_history_count_ipid0()
$result=pwg_query($sql);
if($result)
{
$row=mysql_fetch_array($result);
$row=pwg_db_fetch_row($result);
$returned[0]=$row[0];
}
}
Expand All @@ -2183,7 +2185,7 @@ private function verify_AStat_picture_table_status()
$result=pwg_query($sql);
if($result)
{
if(mysql_num_rows($result)==1)
if(pwg_db_num_rows($result)==1)
{
return(true);
}
Expand Down Expand Up @@ -2221,9 +2223,9 @@ private function count_AStat_picture_table()
$result=pwg_query($sql);
if($result)
{
if(mysql_num_rows($result)>0)
if(pwg_db_num_rows($result)>0)
{
$row=mysql_fetch_row($result);
$row=pwg_db_fetch_row($result);
$returned[0]=true;
$returned[1]=$row[0];
$returned[2]=$row[1];
Expand Down Expand Up @@ -2295,7 +2297,7 @@ private function make_filter_list($selected="")
$result = pwg_query($sql);
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'], '.'));
$template_datarows_values[]=$row['id'];
Expand Down Expand Up @@ -2338,7 +2340,7 @@ private function make_where_clause($catfilter)

if($result)
{
while ($row = mysql_fetch_row($result))
while ($row = pwg_db_fetch_row($result))
{
$returned[]=$row[0];
}
Expand Down Expand Up @@ -2472,7 +2474,7 @@ protected function ajax_listip($filter, $exclude)
$result=pwg_query($sql);
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>";
}
Expand Down
14 changes: 12 additions & 2 deletions main.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
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
Author: grum@piwigo.org
Expand Down Expand Up @@ -41,6 +41,16 @@
| | | - use of jQuery datepicker for purge date
| 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
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
Expand Down Expand Up @@ -70,7 +80,7 @@
define('ASTAT_DIR' , basename(dirname(__FILE__)));
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;

Expand Down
8 changes: 4 additions & 4 deletions maintain.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
--------------------------------------------------------------------------- */

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);
//ini_set('display_errors', true);
Expand Down Expand Up @@ -45,7 +45,7 @@ function gpcMsgError(&$errors)

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;
if($gpc_installed)
Expand Down

0 comments on commit 1337686

Please sign in to comment.