rename #images.average_rate to rating_score

git-svn-id: http://piwigo.org/svn/trunk@11893 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices 2011-08-02 19:20:50 +00:00
commit 86ae4d8b3a
20 changed files with 130 additions and 89 deletions

View file

@ -98,7 +98,7 @@ $display_info_checkboxes = array(
'tags',
'categories',
'visits',
'average_rate',
'rating_score',
'privacy_level',
);
@ -109,7 +109,7 @@ $sort_fields = array(
'file' => l10n('File name'),
'date_creation' => l10n('Creation date'),
'date_available' => l10n('Post date'),
'average_rate' => l10n('Rating score'),
'rating_score' => l10n('Rating score'),
'hit' => l10n('Most visited'),
'id' => 'Id',
);

View file

@ -273,7 +273,7 @@ $sort_fields = array(
'' => '',
'date_creation' => l10n('Creation date'),
'date_available' => l10n('Post date'),
'average_rate' => l10n('Rating score'),
'rating_score' => l10n('Rating score'),
'hit' => l10n('Most visited'),
'file' => l10n('File name'),
'id' => 'Id',

View file

@ -164,7 +164,7 @@ SELECT i.id,
i.path,
i.file,
i.tn_ext,
i.average_rate AS score,
i.rating_score AS score,
MAX(r.date) AS recently_rated,
ROUND(AVG(r.rate),2) AS avg_rates,
COUNT(r.rate) AS nb_rates,
@ -176,7 +176,7 @@ SELECT i.id,
i.path,
i.file,
i.tn_ext,
i.average_rate,
i.rating_score,
r.element_id
ORDER BY ' . $available_order_by[$order_by_index][1] .'
LIMIT '.$elements_per_page.' OFFSET '.$start.'

View file

@ -416,7 +416,7 @@ jQuery(document).ready(function () {
<li>
<label>
<span class="property">{'Rating score'|@translate}</span>
<input type="checkbox" name="picture_informations[average_rate]" {if ($display.picture_informations.average_rate)}checked="checked"{/if}>
<input type="checkbox" name="picture_informations[rating_score]" {if ($display.picture_informations.rating_score)}checked="checked"{/if}>
</label>
</li>

View file

@ -153,7 +153,7 @@ foreach ($pictures as $row)
{
case 'best_rated' :
{
$name = '('.$row['average_rate'].') '.$name;
$name = '('.$row['rating_score'].') '.$name;
break;
}
case 'most_visited' :

View file

@ -496,7 +496,7 @@ $conf['apache_authentication'] = false;
// delete from piwigo_user_infos;
// delete from piwigo_sessions;
// delete from piwigo_rate;
// update piwigo_images set average_rate = null;
// update piwigo_images set rating_score = null;
// delete from piwigo_caddie;
// delete from piwigo_favorites;
//

View file

@ -290,7 +290,7 @@ function get_category_preferred_image_orders()
return trigger_event('get_category_preferred_image_orders',
array(
array(l10n('Default'), '', true),
array(l10n('Rating score'), 'average_rate DESC', $conf['rate']),
array(l10n('Rating score'), 'rating_score DESC', $conf['rate']),
array(l10n('Most visited'), 'hit DESC', true),
array(l10n('Creation date'), 'date_creation DESC', true),
array(l10n('Post date'), 'date_available DESC', true),

View file

@ -120,13 +120,13 @@ INSERT
}
/* update images.average_rate field
/* update images.rating_score field
* we use a bayesian average (http://en.wikipedia.org/wiki/Bayesian_average) with
C = average number of rates per item
m = global average rate (all rates)
* param int $element_id optional, otherwise applies to all
* @return array(average_rate, count) if element_id is specified
* @return array(rating_score, count) if element_id is specified
*/
function update_rating_score($element_id = false)
{
@ -166,13 +166,13 @@ SELECT element_id,
'count' => $rate_summary['rcount'],
);
}
$updates[] = array( 'id'=>$id, 'average_rate'=>$score );
$updates[] = array( 'id'=>$id, 'rating_score'=>$score );
}
mass_updates(
IMAGES_TABLE,
array(
'primary' => array('id'),
'update' => array('average_rate')
'update' => array('rating_score')
),
$updates
);
@ -183,7 +183,7 @@ SELECT element_id,
$query='
SELECT id FROM '.IMAGES_TABLE .'
LEFT JOIN '.RATE_TABLE.' ON id=element_id
WHERE element_id IS NULL AND average_rate IS NOT NULL';
WHERE element_id IS NULL AND rating_score IS NOT NULL';
$to_update = array_from_query( $query, 'id');
@ -191,7 +191,7 @@ SELECT id FROM '.IMAGES_TABLE .'
{
$query='
UPDATE '.IMAGES_TABLE .'
SET average_rate=NULL
SET rating_score=NULL
WHERE id IN (' . implode(',',$to_update) . ')';
pwg_query($query);
}

View file

@ -28,7 +28,7 @@
if ($conf['rate'])
{
$rate_summary = array( 'count'=>0, 'score'=>$picture['current']['average_rate'], 'average'=>null );
$rate_summary = array( 'count'=>0, 'score'=>$picture['current']['rating_score'], 'average'=>null );
if ( NULL != $rate_summary['score'] )
{
$query = '

View file

@ -463,9 +463,9 @@ SELECT DISTINCT(id)
else if ($page['section'] == 'most_visited')
{
$page['super_order_by'] = true;
$conf['order_by'] = ' ORDER BY hit DESC, file ASC';
$conf['order_by'] = ' ORDER BY hit DESC, id DESC';
$query = '
SELECT DISTINCT(id), hit, file
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE hit > 0
@ -489,13 +489,13 @@ SELECT DISTINCT(id), hit, file
else if ($page['section'] == 'best_rated')
{
$page['super_order_by'] = true;
$conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';
$conf['order_by'] = ' ORDER BY rating_score DESC, id DESC';
$query ='
SELECT DISTINCT(id), average_rate
SELECT DISTINCT(id)
FROM '.IMAGES_TABLE.'
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
WHERE average_rate IS NOT NULL
WHERE rating_score IS NOT NULL
'.$forbidden.'
'.$conf['order_by'].'
LIMIT '.$conf['top_number'].'

View file

@ -54,11 +54,11 @@ function ws_std_image_sql_filter( $params, $tbl_name='' )
$clauses = array();
if ( is_numeric($params['f_min_rate']) )
{
$clauses[] = $tbl_name.'average_rate>'.$params['f_min_rate'];
$clauses[] = $tbl_name.'rating_score>'.$params['f_min_rate'];
}
if ( is_numeric($params['f_max_rate']) )
{
$clauses[] = $tbl_name.'average_rate<='.$params['f_max_rate'];
$clauses[] = $tbl_name.'rating_score<='.$params['f_max_rate'];
}
if ( is_numeric($params['f_min_hit']) )
{
@ -123,7 +123,7 @@ function ws_std_image_sql_order( $params, $tbl_name='' )
case 'rand': case 'random':
$matches[1][$i] = DB_RANDOM_FUNCTION.'()'; break;
}
$sortable_fields = array('id', 'file', 'name', 'hit', 'average_rate',
$sortable_fields = array('id', 'file', 'name', 'hit', 'rating_score',
'date_creation', 'date_available', DB_RANDOM_FUNCTION.'()' );
if ( in_array($matches[1][$i], $sortable_fields) )
{
@ -781,7 +781,7 @@ SELECT id, name, permalink, uppercats, global_rank, commentable
$related_tags[$i]=$tag;
}
//------------------------------------------------------------- related rates
$rating = array('score'=>$image_row['average_rate'], 'count'=>0, 'average'=>null);
$rating = array('score'=>$image_row['rating_score'], 'count'=>0, 'average'=>null);
if (isset($rating['score']))
{
$query = '

View file

@ -47,7 +47,7 @@ INSERT INTO piwigo_config (param,value,comment) VALUES ('picture_menu','false','
INSERT INTO piwigo_config (param,value,comment)
VALUES (
'picture_informations',
'a:11:{s:6:"author";b:1;s:10:"created_on";b:1;s:9:"posted_on";b:1;s:10:"dimensions";b:1;s:4:"file";b:1;s:8:"filesize";b:1;s:4:"tags";b:1;s:10:"categories";b:1;s:6:"visits";b:1;s:12:"average_rate";b:1;s:13:"privacy_level";b:1;}',
'a:11:{s:6:"author";b:1;s:10:"created_on";b:1;s:9:"posted_on";b:1;s:10:"dimensions";b:1;s:4:"file";b:1;s:8:"filesize";b:1;s:4:"tags";b:1;s:10:"categories";b:1;s:6:"visits";b:1;s:12:"rating_score";b:1;s:13:"privacy_level";b:1;}',
'Information displayed on picture page'
);
INSERT INTO piwigo_config (param,value,comment) VALUES ('week_starts_on','monday','Monday may not be the first day of the week');

View file

@ -0,0 +1,41 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2011 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
$upgrade_description = 'Rename #images.average_rate to ratingscore.';
include_once(PHPWG_ROOT_PATH.'include/constants.php');
if ('mysql' == $conf['dblayer'])
$q = 'ALTER TABLE '.IMAGES_TABLE.' CHANGE average_rate rating_score float(5,2) unsigned default NULL';
else
$q = 'ALTER TABLE '.IMAGES_TABLE.' RENAME average_rate TO rating_score';
pwg_query($q);
$q="UPDATE ".CATEGORIES_TABLE." SET image_order=REPLACE(image_order, 'average_rate', 'rating_score')";
pwg_query($q);
$q="UPDATE ".CONFIG_TABLE." SET value=REPLACE(value, 'average_rate', 'rating_score')
WHERE param IN ('picture_informations', 'order_by', 'order_by_inside_category')";
pwg_query($q);
?>

View file

@ -187,7 +187,7 @@ CREATE TABLE `piwigo_images` (
`height` smallint(9) unsigned default NULL,
`representative_ext` varchar(4) default NULL,
`date_metadata_update` date default NULL,
`average_rate` float(5,2) unsigned default NULL,
`rating_score` float(5,2) unsigned default NULL,
`has_high` enum('true') default NULL,
`path` varchar(255) NOT NULL default '',
`storage_category_id` smallint(5) unsigned default NULL,
@ -199,7 +199,7 @@ CREATE TABLE `piwigo_images` (
`added_by` smallint(5) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `images_i2` (`date_available`),
KEY `images_i3` (`average_rate`),
KEY `images_i3` (`rating_score`),
KEY `images_i4` (`hit`),
KEY `images_i5` (`date_creation`),
KEY `images_i1` (`storage_category_id`)

View file

@ -183,7 +183,7 @@ CREATE TABLE piwigo_images
"height" INTEGER,
"representative_ext" VARCHAR(4),
"date_metadata_update" DATE,
"average_rate" FLOAT,
"rating_score" FLOAT,
"has_high" BOOLEAN default false,
"path" VARCHAR(255) default '' NOT NULL,
"storage_category_id" INTEGER,
@ -199,7 +199,7 @@ CREATE TABLE piwigo_images
CREATE INDEX "images_i2" ON "piwigo_images" ("date_available");
CREATE INDEX "images_i3" ON "piwigo_images" ("average_rate");
CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score");
CREATE INDEX "images_i4" ON "piwigo_images" ("hit");

View file

@ -227,7 +227,7 @@ CREATE TABLE "piwigo_images"
"height" INTEGER,
"representative_ext" VARCHAR(4),
"date_metadata_update" DATE,
"average_rate" FLOAT,
"rating_score" FLOAT,
"has_high" BOOLEAN default false,
"path" VARCHAR(255) default '' NOT NULL,
"storage_category_id" INTEGER,
@ -246,7 +246,7 @@ COMMENT ON TABLE "piwigo_images" IS '';
SET search_path TO public;
CREATE INDEX "images_i2" ON "piwigo_images" ("date_available");
CREATE INDEX "images_i3" ON "piwigo_images" ("average_rate");
CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score");
CREATE INDEX "images_i4" ON "piwigo_images" ("hit");

View file

@ -183,7 +183,7 @@ CREATE TABLE piwigo_images
"height" INTEGER,
"representative_ext" VARCHAR(4),
"date_metadata_update" DATE,
"average_rate" FLOAT,
"rating_score" FLOAT,
"has_high" BOOLEAN default false,
"path" VARCHAR(255) default '' NOT NULL,
"storage_category_id" INTEGER,
@ -199,7 +199,7 @@ CREATE TABLE piwigo_images
CREATE INDEX "images_i2" ON "piwigo_images" ("date_available");
CREATE INDEX "images_i3" ON "piwigo_images" ("average_rate");
CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score");
CREATE INDEX "images_i4" ON "piwigo_images" ("hit");

View file

@ -43,7 +43,7 @@ alla galleria.</li>
<li><b>date_creation</b> : data di creazione</li>
<li><b>name</b> : nome della foto</li>
<li><b>hit</b> : numero di visite</li>
<li><b>average_rate</b>: nota globbale</li>
<li><b>rating_score</b>: nota globbale</li>
</ul>
Non dimenticate che per ogni campo di specificare l'ordinamento con le parole chiavi <i>ASC</i> e <i>DESC</i>
</li>

View file

@ -194,7 +194,7 @@ y.callService(
</tr>
{/if}
{if $display_info.average_rate and isset($rate_summary)}
{if $display_info.rating_score and isset($rate_summary)}
<tr id="Average">
<td class="label">{'Rating score'|@translate}</td>
<td class="value">

2
ws.php
View file

@ -73,7 +73,7 @@ function ws_addDefaultMethods( $arr )
),
'Returns elements for the corresponding categories.
<br><b>cat_id</b> can be empty if <b>recursive</b> is true. Can be sent as an array.
<br><b>order</b> comma separated fields for sorting (file,id, average_rate,...)'
<br><b>order</b> comma separated fields for sorting (file,id, rating_score,...)'
);
$service->addMethod('pwg.categories.getList', 'ws_categories_getList',