diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/category_default.inc.php | 2 | ||||
-rw-r--r-- | include/config_default.inc.php | 2 | ||||
-rw-r--r-- | include/functions_category.inc.php | 10 | ||||
-rw-r--r-- | include/functions_rate.inc.php | 12 | ||||
-rw-r--r-- | include/picture_rate.inc.php | 2 | ||||
-rw-r--r-- | include/section_init.inc.php | 14 | ||||
-rw-r--r-- | include/ws_functions.inc.php | 88 |
7 files changed, 65 insertions, 65 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php index bbc63fe21..c6e9834d7 100644 --- a/include/category_default.inc.php +++ b/include/category_default.inc.php @@ -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' : diff --git a/include/config_default.inc.php b/include/config_default.inc.php index c57929471..f4cacc854 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -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; // diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 23509a684..19436fd30 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -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), @@ -559,11 +559,11 @@ function categories_flatlist_to_tree($categories) { $tree = array(); $key_of_cat = array(); - + foreach ($categories as $key => &$node) { $key_of_cat[$node['id']] = $key; - + if (!isset($node['id_uppercat'])) { $tree[$key] = &$node; @@ -574,11 +574,11 @@ function categories_flatlist_to_tree($categories) { $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array(); } - + $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node; } } - + return $tree; } ?>
\ No newline at end of file diff --git a/include/functions_rate.inc.php b/include/functions_rate.inc.php index de52c37f3..4cf6cc9ca 100644 --- a/include/functions_rate.inc.php +++ b/include/functions_rate.inc.php @@ -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); } diff --git a/include/picture_rate.inc.php b/include/picture_rate.inc.php index 086287c81..2459d56a2 100644 --- a/include/picture_rate.inc.php +++ b/include/picture_rate.inc.php @@ -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 = ' diff --git a/include/section_init.inc.php b/include/section_init.inc.php index da064cb68..a3f617e41 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -61,10 +61,10 @@ else $rewritten = $key; break; } - + // the $_GET keys are not protected in include/common.inc.php, only the values $rewritten = pwg_db_real_escape_string($rewritten); - + $page['root_path'] = PHPWG_ROOT_PATH; } @@ -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'].' diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 04e0dbbf3..af96a360a 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -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) ) { @@ -192,7 +192,7 @@ function ws_getInfos($params, &$service) } $infos['version'] = PHPWG_VERSION; - + $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.';'; list($infos['nb_elements']) = pwg_db_fetch_row(pwg_query($query)); @@ -443,7 +443,7 @@ function ws_categories_getList($params, &$service) // PwgNamedArray is useful to define which data is an attribute and // which is an element in the XML output. The "hierarchy" output is // only compatible with json/php output. - + return new PwgError(405, "The tree_output option is only compatible with json/php output formats"); } } @@ -471,7 +471,7 @@ function ws_categories_getList($params, &$service) { $where[] = 'status = "public"'; $where[] = 'visible = "true"'; - + $join_user = $conf['guest_id']; } elseif (is_admin()) @@ -479,7 +479,7 @@ function ws_categories_getList($params, &$service) // in this very specific case, we don't want to hide empty // categories. Function calculate_permissions will only return // categories that are either locked or private and not permitted - // + // // calculate_permissions does not consider empty categories as forbidden $forbidden_categories = calculate_permissions($user['id'], $user['status']); $where[]= 'id NOT IN ('.$forbidden_categories.')'; @@ -518,7 +518,7 @@ SELECT id, name, permalink, uppercats, global_rank, id_uppercat, 'ws_categories_getList' ) ); - + $row['comment'] = strip_tags( trigger_event( 'render_category_description', @@ -526,13 +526,13 @@ SELECT id, name, permalink, uppercats, global_rank, id_uppercat, 'ws_categories_getList' ) ); - + array_push($cats, $row); } usort($cats, 'global_rank_compare'); if ($params['tree_output']) - { + { return categories_flatlist_to_tree($cats); } else @@ -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 = ' @@ -1028,7 +1028,7 @@ function ws_images_setRank($params, &$service) { return new PwgError(401, 'Access denied'); } - + if (!$service->isPost()) { return new PwgError(405, "This method requires HTTP POST"); @@ -1054,7 +1054,7 @@ function ws_images_setRank($params, &$service) { return new PwgError(WS_ERR_INVALID_PARAM, "Invalid rank"); } - + // does the image really exist? $query=' SELECT @@ -1068,7 +1068,7 @@ SELECT { return new PwgError(404, "image_id not found"); } - + // is the image associated to this category? $query = ' SELECT @@ -1137,7 +1137,7 @@ UPDATE '.IMAGE_CATEGORY_TABLE.' function ws_images_add_chunk($params, &$service) { global $conf; - + ws_logfile('[ws_images_add_chunk] welcome'); // data // original_sum @@ -1158,7 +1158,7 @@ function ws_images_add_chunk($params, &$service) if ('data' == $param_key) { continue; } - + ws_logfile( sprintf( '[ws_images_add_chunk] input param "%s" : "%s"', @@ -1218,7 +1218,7 @@ function ws_images_add_chunk($params, &$service) function merge_chunks($output_filepath, $original_sum, $type) { global $conf; - + ws_logfile('[merge_chunks] input parameter $output_filepath : '.$output_filepath); if (is_file($output_filepath)) @@ -1286,7 +1286,7 @@ function merge_chunks($output_filepath, $original_sum, $type) function add_file($file_path, $type, $original_sum, $file_sum) { include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); - + $file_path = file_path_for_type($file_path, $type); $upload_dir = dirname($file_path); @@ -1297,7 +1297,7 @@ function add_file($file_path, $type, $original_sum, $file_sum) ws_logfile('[add_file] file_path : '.$file_path); ws_logfile('[add_file] upload_dir : '.$upload_dir); - + if (!is_dir($upload_dir)) { umask(0000); $recursive = true; @@ -1445,7 +1445,7 @@ function ws_images_add($params, &$service) { $where_clause = "file = '".$params['original_filename']."'"; } - + $query = ' SELECT COUNT(*) AS counter @@ -1549,7 +1549,7 @@ SELECT // update metadata from the uploaded file (exif/iptc) require_once(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php'); update_metadata(array($image_id=>$file_path)); - + invalidate_user_cache(); } @@ -1570,7 +1570,7 @@ function ws_images_addSimple($params, &$service) { return new PwgError(405, "The image (file) parameter is missing"); } - + $params['image_id'] = (int)$params['image_id']; if ($params['image_id'] > 0) { @@ -1676,7 +1676,7 @@ SELECT WHERE id = '.$image_id.' ;'; list($file_path) = pwg_db_fetch_row(pwg_query($query)); - + require_once(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php'); update_metadata(array($image_id=>$file_path)); @@ -1731,7 +1731,7 @@ function ws_session_getStatus($params, &$service) list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); $res['current_datetime'] = $dbnow; - + return $res; } @@ -1826,7 +1826,7 @@ function ws_tags_getImages($params, &$service) $image_ids = array_slice($image_ids, (int)($params['per_page']*$params['page']), (int)$params['per_page'] ); - + $image_tag_map = array(); if ( !empty($image_ids) and !$params['tag_mode_and'] ) { // build list of image ids with associated tags per image @@ -1962,7 +1962,7 @@ function ws_tags_add($params, &$service) function ws_images_exist($params, &$service) { global $conf; - + if (!is_admin()) { return new PwgError(401, 'Access denied'); @@ -2001,7 +2001,7 @@ SELECT } } } - + if ('filename' == $conf['uniqueness_mode']) { // search among photos the list of photos already added, based on @@ -2480,7 +2480,7 @@ function ws_categories_setInfo($params, &$service) function ws_categories_setRepresentative($params, &$service) { global $conf; - + if (!is_admin()) { return new PwgError(401, 'Access denied'); @@ -2518,7 +2518,7 @@ SELECT { return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id"); } - + // does the image really exist? $query=' SELECT @@ -2611,7 +2611,7 @@ SELECT id { return; } - + include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); delete_categories($category_ids, $params['photo_deletion_mode']); update_global_rank(); @@ -2620,7 +2620,7 @@ SELECT id function ws_categories_move($params, &$service) { global $conf, $page; - + if (!is_admin()) { return new PwgError(401, 'Access denied'); @@ -2660,7 +2660,7 @@ function ws_categories_move($params, &$service) // we can't move physical categories $categories_in_db = array(); - + $query = ' SELECT id, @@ -2683,7 +2683,7 @@ SELECT 'ws_categories_move' ) ); - + return new PwgError( 403, sprintf( @@ -2698,7 +2698,7 @@ SELECT if (count($categories_in_db) != count($category_ids)) { $unknown_category_ids = array_diff($category_ids, array_keys($categories_in_db)); - + return new PwgError( 403, sprintf( @@ -2716,7 +2716,7 @@ SELECT { return new PwgError(403, 'Invalid parent input parameter'); } - + if (0 != $params['parent']) { $params['parent'] = intval($params['parent']); $subcat_ids = get_subcat_ids(array($params['parent'])); @@ -2765,19 +2765,19 @@ function ws_images_checkUpload($params, &$service) include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); $ret['message'] = ready_for_upload_message(); $ret['ready_for_upload'] = true; - + if (!empty($ret['message'])) { $ret['ready_for_upload'] = false; } - + return $ret; } function ws_plugins_getList($params, &$service) { global $conf; - + if (!is_admin()) { return new PwgError(401, 'Access denied'); @@ -2817,7 +2817,7 @@ function ws_plugins_getList($params, &$service) function ws_plugins_performAction($params, &$service) { global $template; - + if (!is_admin()) { return new PwgError(401, 'Access denied'); @@ -2833,7 +2833,7 @@ function ws_plugins_performAction($params, &$service) $plugins = new plugins(); $errors = $plugins->perform_action($params['action'], $params['plugin']); - + if (!empty($errors)) { return new PwgError(500, $errors); @@ -2851,7 +2851,7 @@ function ws_plugins_performAction($params, &$service) function ws_themes_performAction($params, &$service) { global $template; - + if (!is_admin()) { return new PwgError(401, 'Access denied'); @@ -2866,7 +2866,7 @@ function ws_themes_performAction($params, &$service) include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); $themes = new themes(); $errors = $themes->perform_action($params['action'], $params['theme']); - + if (!empty($errors)) { return new PwgError(500, $errors); @@ -3044,7 +3044,7 @@ function ws_extensions_update($params, &$service) . '&format=json' ); } - + $upgrade_status = $extension->extract_plugin_files('upgrade', $revision, $extension_id); $extension_name = $extension->fs_plugins[$extension_id]['name']; @@ -3175,4 +3175,4 @@ function ws_extensions_checkupdates($params, &$service) return $result; } -?> +?>
\ No newline at end of file |