aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2011-07-26 19:04:50 +0000
committerrvelices <rv-github@modusoptimus.com>2011-07-26 19:04:50 +0000
commitc0bb4dfb43d05d68cb4abe69e279e91c88bd2f11 (patch)
treed82bf347d8b4a5deb8532371e7073e2692737bec
parent630c4bb85e82c956053526255097f3fa706427b4 (diff)
feature 2384: improve average rating calculation (final)
git-svn-id: http://piwigo.org/svn/trunk@11839 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/intro.php7
-rw-r--r--admin/themes/default/template/intro.tpl1
-rw-r--r--include/picture_comment.inc.php2
-rw-r--r--language/en_UK/admin.lang.php4
-rw-r--r--language/en_UK/common.lang.php13
-rw-r--r--picture.php11
-rw-r--r--themes/default/js/rating.js1
-rw-r--r--themes/default/template/picture.tpl19
8 files changed, 33 insertions, 25 deletions
diff --git a/admin/intro.php b/admin/intro.php
index 7b6985e6f..63d5b9805 100644
--- a/admin/intro.php
+++ b/admin/intro.php
@@ -191,6 +191,12 @@ SELECT COUNT(*)
;';
list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
+$query = '
+SELECT COUNT(*)
+ FROM '.RATE_TABLE.'
+;';
+list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
+
$template->assign(
array(
'PHPWG_URL' => PHPWG_URL,
@@ -213,6 +219,7 @@ $template->assign(
'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments),
+ 'DB_RATES' => sprintf('%d rates', $nb_rates),
'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
'PHP_DATATIME' => $php_current_timestamp,
diff --git a/admin/themes/default/template/intro.tpl b/admin/themes/default/template/intro.tpl
index 6bdbfc9ff..21646e01e 100644
--- a/admin/themes/default/template/intro.tpl
+++ b/admin/themes/default/template/intro.tpl
@@ -78,6 +78,7 @@ jQuery().ready(function(){
(<a href="{$unvalidated.URL}">{$unvalidated.INFO}</a>)
{/if}
</li>
+ <li>{$DB_RATES}</li>
</ul>
</dd>
</dl>
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index ec92594e8..064e02056 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -31,7 +31,7 @@
$page['show_comments'] = false;
foreach ($related_categories as $category)
{
- if ($category['commentable'] == 'true')
+ if ($category['commentable'])
{
$page['show_comments'] = true;
break;
diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php
index 295a32842..34e89e169 100644
--- a/language/en_UK/admin.lang.php
+++ b/language/en_UK/admin.lang.php
@@ -160,6 +160,7 @@ $lang['Authorized'] = "Authorized";
$lang['Automatic correction'] = "Automatic correction";
$lang['automatic order'] = 'automatic order';
$lang['Available only with HTML format'] = "Available only with HTML format";
+$lang['Average rate'] = "Average rate";
$lang['average time'] = "average time";
$lang['Batch management'] = "Batch management";
$lang['Batch Manager'] = 'Batch Manager';
@@ -547,7 +548,8 @@ $lang['Quick Local Synchronization'] = "Quick Local Synchronization";
$lang['Random photo'] = "Random photo";
$lang['randomly represented'] = "random representative";
$lang['ranks'] = "ranks";
-$lang['Rate date'] = "Rating date";
+$lang['Rate'] = "Rate";
+$lang['Rate date'] = "Rate date";
$lang['Rating by guests'] = "Rating by guests";
$lang['Rating'] = "Rating";
$lang['read local listing.xml and update'] = "read local listing.xml and update";
diff --git a/language/en_UK/common.lang.php b/language/en_UK/common.lang.php
index 32a62fcaf..a47dc5c53 100644
--- a/language/en_UK/common.lang.php
+++ b/language/en_UK/common.lang.php
@@ -35,29 +35,28 @@ $lang_info['code'] = "en";
$lang_info['zero_plural'] = "1";
-$lang['%.2f (rated %d times)'] = "%.2f (rated %d times)";
-$lang['%d Kb'] = "%d Kb";
$lang['%d album updated'] = "%d album updated";
$lang['%d albums updated'] = "%d albums updated";
$lang['%d comment to validate'] = "%d comment to validate";
-$lang['%d comments to validate'] = "%d comments to validate";
-$lang['%d new comment'] = "%d new comment";
-$lang['%d new comments'] = "%d new comments";
$lang['%d comment'] = "%d comment";
+$lang['%d comments to validate'] = "%d comments to validate";
$lang['%d comments'] = "%d comments";
$lang['%d hit'] = "%d hit";
$lang['%d hits'] = "%d hits";
+$lang['%d Kb'] = "%d Kb";
+$lang['%d new comment'] = "%d new comment";
+$lang['%d new comments'] = "%d new comments";
$lang['%d new photo'] = "%d new photo";
$lang['%d new photos'] = "%d new photos";
$lang['%d new user'] = "%d new user";
$lang['%d new users'] = "%d new users";
+$lang['%d rates'] = "%d rates";
$lang['About'] = "About";
$lang['All tags'] = "All tags";
$lang['Any tag'] = "Any tag";
$lang['At least one listed rule must be satisfied.'] = "At least one listed criterion must be satisfied.";
$lang['At least one tag must match'] = "At least one tag must match";
$lang['Author'] = "Author";
-$lang['Average rate'] = "Average rate";
$lang['Albums'] = "Albums";
$lang['Album'] = "Album";
$lang['Close this window'] = "Close this window";
@@ -104,7 +103,7 @@ $lang['Posted on'] = "Posted on";
$lang['Profile'] = "Profile";
$lang['Quick connect'] = "Quick connect";
$lang['RSS feed'] = "RSS feed";
-$lang['Rate'] = "Rate";
+$lang['Rating score'] = "Rating score";
$lang['Register'] = "Register";
$lang['Registration'] = "Registration";
$lang['Related tags'] = "Related tags";
diff --git a/picture.php b/picture.php
index 60dc7cc52..fb7b19307 100644
--- a/picture.php
+++ b/picture.php
@@ -313,22 +313,15 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
case 'rate' :
{
include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
- rate_picture(
- $page['image_id'],
- isset($_POST['rate']) ? $_POST['rate'] : $_GET['rate']
- );
+ rate_picture($page['image_id'], $_POST['rate']);
redirect($url_self);
}
case 'edit_comment' :
{
check_pwg_token();
-
include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
-
check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID);
-
$author_id = get_comment_author_id($_GET['comment_to_edit']);
-
if (can_manage_comment('edit', $author_id))
{
if (!empty($_POST['content']))
@@ -441,7 +434,7 @@ $result = pwg_query($query);
$related_categories = array();
while ($row = pwg_db_fetch_assoc($result))
{
- $row['commentable'] = boolean_to_string($row['commentable']);
+ $row['commentable'] = get_boolean($row['commentable']);
array_push($related_categories, $row);
}
usort($related_categories, 'global_rank_compare');
diff --git a/themes/default/js/rating.js b/themes/default/js/rating.js
index b72b55477..3bc846681 100644
--- a/themes/default/js/rating.js
+++ b/themes/default/js/rating.js
@@ -69,6 +69,7 @@ function updateRating(e)
onSuccess: function(result) {
gUserRating = rateButton.initialRateValue;
for (var i=0; i<gRatingButtons.length; i++) gRatingButtons[i].disabled=false;
+ if (gRatingOptions.onSuccess) gRatingOptions.onSuccess(result);
if (gRatingOptions.updateRateElement) gRatingOptions.updateRateElement.innerHTML = gRatingOptions.updateRateText;
if (gRatingOptions.ratingSummaryElement)
{
diff --git a/themes/default/template/picture.tpl b/themes/default/template/picture.tpl
index 6ffaa7261..d83795d58 100644
--- a/themes/default/template/picture.tpl
+++ b/themes/default/template/picture.tpl
@@ -196,13 +196,12 @@ y.callService(
{if $display_info.average_rate and isset($rate_summary)}
<tr id="Average">
- <td class="label">{'Rating'|@translate}</td>
- <td class="value" id="ratingSummary">
+ <td class="label">{'Rating score'|@translate}</td>
+ <td class="value">
{if $rate_summary.count}
- {assign var='rate_text' value='%.2f (rated %d times)'|@translate}
- {$pwg->sprintf($rate_text, $rate_summary.score, $rate_summary.count, $rate_summary.average)}
+ <span id="ratingScore">{$rate_summary.score}</span> <span id="ratingCount">({assign var='rate_text' value='%d rates'|@translate}{$pwg->sprintf($rate_text, $rate_summary.count)})</span>
{else}
- {'no rate'|@translate}
+ <span id="ratingScore">{'no rate'|@translate}</span> <span id="ratingCount"></span>
{/if}
</td>
</tr>
@@ -228,8 +227,14 @@ y.callService(
{footer_script}
var _pwgRatingAutoQueue = _pwgRatingAutoQueue||[];
_pwgRatingAutoQueue.push( {ldelim}rootUrl: '{$ROOT_URL}', image_id: {$current.id},
- updateRateText: "{'Update your rating'|@translate|@escape:'javascript'}", updateRateElement: document.getElementById("updateRate"),
- ratingSummaryText: "{'%.2f (rated %d times)'|@translate|@escape:'javascript'}", ratingSummaryElement: document.getElementById("ratingSummary"){rdelim} );
+ onSuccess : function(rating) {ldelim}
+ var e = document.getElementById("updateRate");
+ if (e) e.innerHTML = "{'Update your rating'|@translate|@escape:'javascript'}";
+ e = document.getElementById("ratingScore");
+ if (e) e.innerHTML = rating.score;
+ e = document.getElementById("ratingCount");
+ if (e) e.innerHTML = "({'%d rates'|@translate|@escape:'javascript'})".replace( "%d", rating.count);
+ {rdelim}{rdelim} );
{/footer_script}
{/strip}
</div>