diff -Nur dotclear-2.2.0/inc/core/class.dc.meta.php dotclear/inc/core/class.dc.meta.php
--- dotclear-2.2.0/inc/core/class.dc.meta.php 2010-08-29 21:35:30.000000000 +0200
+++ dotclear/inc/core/class.dc.meta.php 2010-08-29 21:30:46.000000000 +0200
@@ -23,7 +23,49 @@
private $core; ///< dcCore dcCore instance
private $con; ///< connection Database connection object
private $table; ///< string Media table name
-
+
+ function calcTagPercent($count, $min, $max) {
+ $borneInf = 5;
+ $borneSup = 50;
+ $normalisation = true;
+ $bornage = true;
+ $func = "log";
+
+ if ($max == $min) {
+ return 100;
+ }
+
+ if ($normalisation) {
+ if ($bornage) {
+ $borneInf = max($borneInf, $min);
+ $borneSup = min($borneSup, $max);
+ }
+ else {
+ $borneInf = $min;
+ $borneSup = $max;
+ $bornage = true;
+ }
+ }
+
+ if (!$bornage || $borneSup <= $borneInf) {
+ $borneSup = $max;
+ $borneInf = $min * $normalisation;
+ }
+
+ $count2 = max(0, min($count, $borneSup) - $borneInf);
+ $max2 = $borneSup - $borneInf;
+
+ if ($func == "log") {
+ return (integer) (log($count2 + 1) * 100 / log($max2 + 1));
+ }
+ else if ($func == "exp") {
+ return (integer) (exp($count2) * 100 / exp($max2));
+ }
+ else {
+ return (integer) $count2 * 100 / $max2;
+ }
+ }
+
/**
Object constructor.
@@ -389,15 +431,20 @@
$rs_static = $rs->toStatic();
$max = array();
+ $min = array();
while ($rs_static->fetch())
{
$type = $rs_static->meta_type;
if (!isset($max[$type])) {
$max[$type] = $rs_static->count;
+ $min[$type] = $rs_static->count;
} else {
if ($rs_static->count > $max[$type]) {
$max[$type] = $rs_static->count;
}
+ else if ($rs_static->count < $min[$type]) {
+ $min[$type] = $rs_static->count;
+ }
}
}
@@ -406,7 +453,12 @@
$rs_static->set('meta_id_lower',mb_strtolower($rs_static->meta_id));
$count = $rs_static->count;
- $percent = ((integer) $rs_static->count) * 100 / $max[$rs_static->meta_type];
+ if ($rs_static->meta_type == "tag") {
+ $percent = $this->calcTagPercent((integer) $rs_static->count, $min["tag"], $max["tag"]);
+ }
+ else {
+ $percent = ((integer) $rs_static->count) * 100 / $max[$rs_static->meta_type];
+ }
$rs_static->set('percent',(integer) round($percent));
$rs_static->set('roundpercent',round($percent/10)*10);