Changeset 11839


Ignore:
Timestamp:
Jul 26, 2011, 9:04:50 PM (9 years ago)
Author:
rvelices
Message:

feature 2384: improve average rating calculation (final)

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/intro.php

    r10684 r11839  
    191191;';
    192192list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
     193
     194$query = '
     195SELECT COUNT(*)
     196  FROM '.RATE_TABLE.'
     197;';
     198list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
    193199
    194200$template->assign(
     
    214220    'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
    215221    'DB_COMMENTS' => l10n_dec('%d comment', '%d comments', $nb_comments),
     222                'DB_RATES' => sprintf('%d rates', $nb_rates),
    216223    'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
    217224    'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
  • trunk/admin/themes/default/template/intro.tpl

    r10684 r11839  
    7979        {/if}
    8080      </li>
     81                        <li>{$DB_RATES}</li>
    8182    </ul>
    8283  </dd>
  • trunk/include/picture_comment.inc.php

    r11236 r11839  
    3232foreach ($related_categories as $category)
    3333{
    34   if ($category['commentable'] == 'true')
     34  if ($category['commentable'])
    3535  {
    3636    $page['show_comments'] = true;
  • trunk/language/en_UK/admin.lang.php

    r11641 r11839  
    161161$lang['automatic order'] = 'automatic order';
    162162$lang['Available only with HTML format'] = "Available only with HTML format";
     163$lang['Average rate'] = "Average rate";
    163164$lang['average time'] = "average time";
    164165$lang['Batch management'] = "Batch management";
     
    548549$lang['randomly represented'] = "random representative";
    549550$lang['ranks'] = "ranks";
    550 $lang['Rate date'] = "Rating date";
     551$lang['Rate'] = "Rate";
     552$lang['Rate date'] = "Rate date";
    551553$lang['Rating by guests'] = "Rating by guests";
    552554$lang['Rating'] = "Rating";
  • trunk/language/en_UK/common.lang.php

    r10815 r11839  
    3636
    3737
    38 $lang['%.2f (rated %d times)'] = "%.2f (rated %d times)";
    39 $lang['%d Kb'] = "%d Kb";
    4038$lang['%d album updated'] = "%d album updated";
    4139$lang['%d albums updated'] = "%d albums updated";
    4240$lang['%d comment to validate'] = "%d comment to validate";
     41$lang['%d comment'] = "%d comment";
    4342$lang['%d comments to validate'] = "%d comments to validate";
    44 $lang['%d new comment'] = "%d new comment";
    45 $lang['%d new comments'] = "%d new comments";
    46 $lang['%d comment'] = "%d comment";
    4743$lang['%d comments'] = "%d comments";
    4844$lang['%d hit'] = "%d hit";
    4945$lang['%d hits'] = "%d hits";
     46$lang['%d Kb'] = "%d Kb";
     47$lang['%d new comment'] = "%d new comment";
     48$lang['%d new comments'] = "%d new comments";
    5049$lang['%d new photo'] = "%d new photo";
    5150$lang['%d new photos'] = "%d new photos";
    5251$lang['%d new user'] = "%d new user";
    5352$lang['%d new users'] = "%d new users";
     53$lang['%d rates'] = "%d rates";
    5454$lang['About'] = "About";
    5555$lang['All tags'] = "All tags";
     
    5858$lang['At least one tag must match'] = "At least one tag must match";
    5959$lang['Author'] = "Author";
    60 $lang['Average rate'] = "Average rate";
    6160$lang['Albums'] = "Albums";
    6261$lang['Album'] = "Album";
     
    105104$lang['Quick connect'] = "Quick connect";
    106105$lang['RSS feed'] = "RSS feed";
    107 $lang['Rate'] = "Rate";
     106$lang['Rating score'] = "Rating score";
    108107$lang['Register'] = "Register";
    109108$lang['Registration'] = "Registration";
  • trunk/picture.php

    r10970 r11839  
    314314    {
    315315      include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
    316       rate_picture(
    317         $page['image_id'],
    318         isset($_POST['rate']) ? $_POST['rate'] : $_GET['rate']
    319         );
     316      rate_picture($page['image_id'], $_POST['rate']);
    320317      redirect($url_self);
    321318    }
     
    323320    {
    324321      check_pwg_token();
    325 
    326322      include_once(PHPWG_ROOT_PATH.'include/functions_comment.inc.php');
    327 
    328323      check_input_parameter('comment_to_edit', $_GET, false, PATTERN_ID);
    329 
    330324      $author_id = get_comment_author_id($_GET['comment_to_edit']);
    331 
    332325      if (can_manage_comment('edit', $author_id))
    333326      {
     
    442435while ($row = pwg_db_fetch_assoc($result))
    443436{
    444   $row['commentable'] = boolean_to_string($row['commentable']);
     437  $row['commentable'] = get_boolean($row['commentable']);
    445438  array_push($related_categories, $row);
    446439}
  • trunk/themes/default/js/rating.js

    r11834 r11839  
    7070                                gUserRating = rateButton.initialRateValue;
    7171                                for (var i=0; i<gRatingButtons.length; i++) gRatingButtons[i].disabled=false;
     72                                if (gRatingOptions.onSuccess) gRatingOptions.onSuccess(result);
    7273                                if (gRatingOptions.updateRateElement) gRatingOptions.updateRateElement.innerHTML = gRatingOptions.updateRateText;
    7374                                if (gRatingOptions.ratingSummaryElement)
  • trunk/themes/default/template/picture.tpl

    r11827 r11839  
    197197{if $display_info.average_rate and isset($rate_summary)}
    198198        <tr id="Average">
    199                 <td class="label">{'Rating'|@translate}</td>
    200                 <td class="value" id="ratingSummary">
     199                <td class="label">{'Rating score'|@translate}</td>
     200                <td class="value">
    201201                {if $rate_summary.count}
    202                         {assign var='rate_text' value='%.2f (rated %d times)'|@translate}
    203                         {$pwg->sprintf($rate_text, $rate_summary.score, $rate_summary.count, $rate_summary.average)}
     202                        <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>
    204203                {else}
    205                         {'no rate'|@translate}
     204                        <span id="ratingScore">{'no rate'|@translate}</span> <span id="ratingCount"></span>
    206205                {/if}
    207206                </td>
     
    229228                                var _pwgRatingAutoQueue = _pwgRatingAutoQueue||[];
    230229                                _pwgRatingAutoQueue.push( {ldelim}rootUrl: '{$ROOT_URL}', image_id: {$current.id},
    231                                         updateRateText: "{'Update your rating'|@translate|@escape:'javascript'}", updateRateElement: document.getElementById("updateRate"),
    232                                         ratingSummaryText: "{'%.2f (rated %d times)'|@translate|@escape:'javascript'}", ratingSummaryElement: document.getElementById("ratingSummary"){rdelim} );
     230                                        onSuccess : function(rating) {ldelim}
     231                                                var e = document.getElementById("updateRate");
     232                                                if (e) e.innerHTML = "{'Update your rating'|@translate|@escape:'javascript'}";
     233                                                e = document.getElementById("ratingScore");
     234                                                if (e) e.innerHTML = rating.score;
     235                                                e = document.getElementById("ratingCount");
     236                                                if (e) e.innerHTML = "({'%d rates'|@translate|@escape:'javascript'})".replace( "%d", rating.count);
     237                                        {rdelim}{rdelim} );
    233238                        {/footer_script}
    234239                        {/strip}
Note: See TracChangeset for help on using the changeset viewer.