Changeset 11893
- Timestamp:
- Aug 2, 2011, 9:20:50 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/configuration.php
r11827 r11893 99 99 'categories', 100 100 'visits', 101 ' average_rate',101 'rating_score', 102 102 'privacy_level', 103 103 ); … … 110 110 'date_creation' => l10n('Creation date'), 111 111 'date_available' => l10n('Post date'), 112 ' average_rate' => l10n('Rating score'),112 'rating_score' => l10n('Rating score'), 113 113 'hit' => l10n('Most visited'), 114 114 'id' => 'Id', -
trunk/admin/element_set_ranks.php
r11829 r11893 93 93 { 94 94 asort($_POST['rank_of_image'], SORT_NUMERIC); 95 95 96 96 save_images_order( 97 97 $page['category_id'], … … 106 106 107 107 $image_order = null; 108 if (!empty($_POST['image_order_choice']) 108 if (!empty($_POST['image_order_choice']) 109 109 && in_array($_POST['image_order_choice'], $image_order_choices)) 110 110 { 111 111 $image_order_choice = $_POST['image_order_choice']; 112 112 } 113 113 114 114 if ($image_order_choice=='user_define') 115 115 { … … 142 142 { 143 143 $cat_info = get_cat_info($page['category_id']); 144 144 145 145 $query = ' 146 146 UPDATE '.CATEGORIES_TABLE.' … … 173 173 $image_order_choice = 'rank'; 174 174 } 175 elseif ($category['image_order']!='') 175 elseif ($category['image_order']!='') 176 176 { 177 177 $image_order_choice = 'user_define'; … … 218 218 { 219 219 $src = get_thumbnail_url($row); 220 220 221 221 $thumbnail_size = getimagesize($src); 222 222 if ( !empty( $row['name'] ) ) … … 274 274 'date_creation' => l10n('Creation date'), 275 275 'date_available' => l10n('Post date'), 276 ' average_rate' => l10n('Rating score'),276 'rating_score' => l10n('Rating score'), 277 277 'hit' => l10n('Most visited'), 278 278 'file' => l10n('File name'), -
trunk/admin/rating.php
r11827 r11893 165 165 i.file, 166 166 i.tn_ext, 167 i. average_rate AS score,167 i.rating_score AS score, 168 168 MAX(r.date) AS recently_rated, 169 169 ROUND(AVG(r.rate),2) AS avg_rates, … … 177 177 i.file, 178 178 i.tn_ext, 179 i. average_rate,179 i.rating_score, 180 180 r.element_id 181 181 ORDER BY ' . $available_order_by[$order_by_index][1] .' -
trunk/admin/themes/default/template/configuration.tpl
r11827 r11893 417 417 <label> 418 418 <span class="property">{'Rating score'|@translate}</span> 419 <input type="checkbox" name="picture_informations[ average_rate]" {if ($display.picture_informations.average_rate)}checked="checked"{/if}>419 <input type="checkbox" name="picture_informations[rating_score]" {if ($display.picture_informations.rating_score)}checked="checked"{/if}> 420 420 </label> 421 421 </li> -
trunk/include/category_default.inc.php
r11591 r11893 154 154 case 'best_rated' : 155 155 { 156 $name = '('.$row[' average_rate'].') '.$name;156 $name = '('.$row['rating_score'].') '.$name; 157 157 break; 158 158 } -
trunk/include/config_default.inc.php
r11739 r11893 497 497 // delete from piwigo_sessions; 498 498 // delete from piwigo_rate; 499 // update piwigo_images set average_rate = null;499 // update piwigo_images set rating_score = null; 500 500 // delete from piwigo_caddie; 501 501 // delete from piwigo_favorites; -
trunk/include/functions_category.inc.php
r11827 r11893 291 291 array( 292 292 array(l10n('Default'), '', true), 293 array(l10n('Rating score'), ' average_rate DESC', $conf['rate']),293 array(l10n('Rating score'), 'rating_score DESC', $conf['rate']), 294 294 array(l10n('Most visited'), 'hit DESC', true), 295 295 array(l10n('Creation date'), 'date_creation DESC', true), … … 560 560 $tree = array(); 561 561 $key_of_cat = array(); 562 562 563 563 foreach ($categories as $key => &$node) 564 564 { 565 565 $key_of_cat[$node['id']] = $key; 566 566 567 567 if (!isset($node['id_uppercat'])) 568 568 { … … 575 575 $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array(); 576 576 } 577 577 578 578 $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node; 579 579 } 580 580 } 581 581 582 582 return $tree; 583 583 } -
trunk/include/functions_rate.inc.php
r11827 r11893 121 121 122 122 123 /* update images. average_rate field123 /* update images.rating_score field 124 124 * we use a bayesian average (http://en.wikipedia.org/wiki/Bayesian_average) with 125 125 C = average number of rates per item … … 127 127 128 128 * param int $element_id optional, otherwise applies to all 129 * @return array( average_rate, count) if element_id is specified129 * @return array(rating_score, count) if element_id is specified 130 130 */ 131 131 function update_rating_score($element_id = false) … … 167 167 ); 168 168 } 169 $updates[] = array( 'id'=>$id, ' average_rate'=>$score );169 $updates[] = array( 'id'=>$id, 'rating_score'=>$score ); 170 170 } 171 171 mass_updates( … … 173 173 array( 174 174 'primary' => array('id'), 175 'update' => array(' average_rate')175 'update' => array('rating_score') 176 176 ), 177 177 $updates … … 184 184 SELECT id FROM '.IMAGES_TABLE .' 185 185 LEFT JOIN '.RATE_TABLE.' ON id=element_id 186 WHERE element_id IS NULL AND average_rate IS NOT NULL';186 WHERE element_id IS NULL AND rating_score IS NOT NULL'; 187 187 188 188 $to_update = array_from_query( $query, 'id'); … … 192 192 $query=' 193 193 UPDATE '.IMAGES_TABLE .' 194 SET average_rate=NULL194 SET rating_score=NULL 195 195 WHERE id IN (' . implode(',',$to_update) . ')'; 196 196 pwg_query($query); -
trunk/include/picture_rate.inc.php
r11827 r11893 29 29 if ($conf['rate']) 30 30 { 31 $rate_summary = array( 'count'=>0, 'score'=>$picture['current'][' average_rate'], 'average'=>null );31 $rate_summary = array( 'count'=>0, 'score'=>$picture['current']['rating_score'], 'average'=>null ); 32 32 if ( NULL != $rate_summary['score'] ) 33 33 { -
trunk/include/section_init.inc.php
r8728 r11893 62 62 break; 63 63 } 64 64 65 65 // the $_GET keys are not protected in include/common.inc.php, only the values 66 66 $rewritten = pwg_db_real_escape_string($rewritten); 67 67 68 68 $page['root_path'] = PHPWG_ROOT_PATH; 69 69 } … … 464 464 { 465 465 $page['super_order_by'] = true; 466 $conf['order_by'] = ' ORDER BY hit DESC, file ASC';466 $conf['order_by'] = ' ORDER BY hit DESC, id DESC'; 467 467 $query = ' 468 SELECT DISTINCT(id) , hit, file468 SELECT DISTINCT(id) 469 469 FROM '.IMAGES_TABLE.' 470 470 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id … … 490 490 { 491 491 $page['super_order_by'] = true; 492 $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';492 $conf['order_by'] = ' ORDER BY rating_score DESC, id DESC'; 493 493 494 494 $query =' 495 SELECT DISTINCT(id) , average_rate495 SELECT DISTINCT(id) 496 496 FROM '.IMAGES_TABLE.' 497 497 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 498 WHERE average_rate IS NOT NULL498 WHERE rating_score IS NOT NULL 499 499 '.$forbidden.' 500 500 '.$conf['order_by'].' -
trunk/include/ws_functions.inc.php
r11827 r11893 55 55 if ( is_numeric($params['f_min_rate']) ) 56 56 { 57 $clauses[] = $tbl_name.' average_rate>'.$params['f_min_rate'];57 $clauses[] = $tbl_name.'rating_score>'.$params['f_min_rate']; 58 58 } 59 59 if ( is_numeric($params['f_max_rate']) ) 60 60 { 61 $clauses[] = $tbl_name.' average_rate<='.$params['f_max_rate'];61 $clauses[] = $tbl_name.'rating_score<='.$params['f_max_rate']; 62 62 } 63 63 if ( is_numeric($params['f_min_hit']) ) … … 124 124 $matches[1][$i] = DB_RANDOM_FUNCTION.'()'; break; 125 125 } 126 $sortable_fields = array('id', 'file', 'name', 'hit', ' average_rate',126 $sortable_fields = array('id', 'file', 'name', 'hit', 'rating_score', 127 127 'date_creation', 'date_available', DB_RANDOM_FUNCTION.'()' ); 128 128 if ( in_array($matches[1][$i], $sortable_fields) ) … … 193 193 194 194 $infos['version'] = PHPWG_VERSION; 195 195 196 196 $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.';'; 197 197 list($infos['nb_elements']) = pwg_db_fetch_row(pwg_query($query)); … … 444 444 // which is an element in the XML output. The "hierarchy" output is 445 445 // only compatible with json/php output. 446 446 447 447 return new PwgError(405, "The tree_output option is only compatible with json/php output formats"); 448 448 } … … 472 472 $where[] = 'status = "public"'; 473 473 $where[] = 'visible = "true"'; 474 474 475 475 $join_user = $conf['guest_id']; 476 476 } … … 480 480 // categories. Function calculate_permissions will only return 481 481 // categories that are either locked or private and not permitted 482 // 482 // 483 483 // calculate_permissions does not consider empty categories as forbidden 484 484 $forbidden_categories = calculate_permissions($user['id'], $user['status']); … … 519 519 ) 520 520 ); 521 521 522 522 $row['comment'] = strip_tags( 523 523 trigger_event( … … 527 527 ) 528 528 ); 529 529 530 530 array_push($cats, $row); 531 531 } … … 533 533 534 534 if ($params['tree_output']) 535 { 535 { 536 536 return categories_flatlist_to_tree($cats); 537 537 } … … 782 782 } 783 783 //------------------------------------------------------------- related rates 784 $rating = array('score'=>$image_row[' average_rate'], 'count'=>0, 'average'=>null);784 $rating = array('score'=>$image_row['rating_score'], 'count'=>0, 'average'=>null); 785 785 if (isset($rating['score'])) 786 786 { … … 1029 1029 return new PwgError(401, 'Access denied'); 1030 1030 } 1031 1031 1032 1032 if (!$service->isPost()) 1033 1033 { … … 1055 1055 return new PwgError(WS_ERR_INVALID_PARAM, "Invalid rank"); 1056 1056 } 1057 1057 1058 1058 // does the image really exist? 1059 1059 $query=' … … 1069 1069 return new PwgError(404, "image_id not found"); 1070 1070 } 1071 1071 1072 1072 // is the image associated to this category? 1073 1073 $query = ' … … 1138 1138 { 1139 1139 global $conf; 1140 1140 1141 1141 ws_logfile('[ws_images_add_chunk] welcome'); 1142 1142 // data … … 1159 1159 continue; 1160 1160 } 1161 1161 1162 1162 ws_logfile( 1163 1163 sprintf( … … 1219 1219 { 1220 1220 global $conf; 1221 1221 1222 1222 ws_logfile('[merge_chunks] input parameter $output_filepath : '.$output_filepath); 1223 1223 … … 1287 1287 { 1288 1288 include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 1289 1289 1290 1290 $file_path = file_path_for_type($file_path, $type); 1291 1291 … … 1298 1298 ws_logfile('[add_file] file_path : '.$file_path); 1299 1299 ws_logfile('[add_file] upload_dir : '.$upload_dir); 1300 1300 1301 1301 if (!is_dir($upload_dir)) { 1302 1302 umask(0000); … … 1446 1446 $where_clause = "file = '".$params['original_filename']."'"; 1447 1447 } 1448 1448 1449 1449 $query = ' 1450 1450 SELECT … … 1550 1550 require_once(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php'); 1551 1551 update_metadata(array($image_id=>$file_path)); 1552 1552 1553 1553 invalidate_user_cache(); 1554 1554 } … … 1571 1571 return new PwgError(405, "The image (file) parameter is missing"); 1572 1572 } 1573 1573 1574 1574 $params['image_id'] = (int)$params['image_id']; 1575 1575 if ($params['image_id'] > 0) … … 1677 1677 ;'; 1678 1678 list($file_path) = pwg_db_fetch_row(pwg_query($query)); 1679 1679 1680 1680 require_once(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php'); 1681 1681 update_metadata(array($image_id=>$file_path)); … … 1732 1732 list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); 1733 1733 $res['current_datetime'] = $dbnow; 1734 1734 1735 1735 return $res; 1736 1736 } … … 1827 1827 1828 1828 $image_ids = array_slice($image_ids, (int)($params['per_page']*$params['page']), (int)$params['per_page'] ); 1829 1829 1830 1830 $image_tag_map = array(); 1831 1831 if ( !empty($image_ids) and !$params['tag_mode_and'] ) … … 1963 1963 { 1964 1964 global $conf; 1965 1965 1966 1966 if (!is_admin()) 1967 1967 { … … 2002 2002 } 2003 2003 } 2004 2004 2005 2005 if ('filename' == $conf['uniqueness_mode']) 2006 2006 { … … 2481 2481 { 2482 2482 global $conf; 2483 2483 2484 2484 if (!is_admin()) 2485 2485 { … … 2519 2519 return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id"); 2520 2520 } 2521 2521 2522 2522 // does the image really exist? 2523 2523 $query=' … … 2612 2612 return; 2613 2613 } 2614 2614 2615 2615 include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 2616 2616 delete_categories($category_ids, $params['photo_deletion_mode']); … … 2621 2621 { 2622 2622 global $conf, $page; 2623 2623 2624 2624 if (!is_admin()) 2625 2625 { … … 2661 2661 // we can't move physical categories 2662 2662 $categories_in_db = array(); 2663 2663 2664 2664 $query = ' 2665 2665 SELECT … … 2684 2684 ) 2685 2685 ); 2686 2686 2687 2687 return new PwgError( 2688 2688 403, … … 2699 2699 { 2700 2700 $unknown_category_ids = array_diff($category_ids, array_keys($categories_in_db)); 2701 2701 2702 2702 return new PwgError( 2703 2703 403, … … 2717 2717 return new PwgError(403, 'Invalid parent input parameter'); 2718 2718 } 2719 2719 2720 2720 if (0 != $params['parent']) { 2721 2721 $params['parent'] = intval($params['parent']); … … 2766 2766 $ret['message'] = ready_for_upload_message(); 2767 2767 $ret['ready_for_upload'] = true; 2768 2768 2769 2769 if (!empty($ret['message'])) 2770 2770 { 2771 2771 $ret['ready_for_upload'] = false; 2772 2772 } 2773 2773 2774 2774 return $ret; 2775 2775 } … … 2778 2778 { 2779 2779 global $conf; 2780 2780 2781 2781 if (!is_admin()) 2782 2782 { … … 2818 2818 { 2819 2819 global $template; 2820 2820 2821 2821 if (!is_admin()) 2822 2822 { … … 2834 2834 $errors = $plugins->perform_action($params['action'], $params['plugin']); 2835 2835 2836 2836 2837 2837 if (!empty($errors)) 2838 2838 { … … 2852 2852 { 2853 2853 global $template; 2854 2854 2855 2855 if (!is_admin()) 2856 2856 { … … 2867 2867 $themes = new themes(); 2868 2868 $errors = $themes->perform_action($params['action'], $params['theme']); 2869 2869 2870 2870 if (!empty($errors)) 2871 2871 { … … 3045 3045 ); 3046 3046 } 3047 3047 3048 3048 $upgrade_status = $extension->extract_plugin_files('upgrade', $revision, $extension_id); 3049 3049 $extension_name = $extension->fs_plugins[$extension_id]['name']; -
trunk/install/config.sql
r11587 r11893 48 48 VALUES ( 49 49 'picture_informations', 50 '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;}',50 '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;}', 51 51 'Information displayed on picture page' 52 52 ); -
trunk/install/piwigo_structure-mysql.sql
r10341 r11893 188 188 `representative_ext` varchar(4) default NULL, 189 189 `date_metadata_update` date default NULL, 190 ` average_rate` float(5,2) unsigned default NULL,190 `rating_score` float(5,2) unsigned default NULL, 191 191 `has_high` enum('true') default NULL, 192 192 `path` varchar(255) NOT NULL default '', … … 200 200 PRIMARY KEY (`id`), 201 201 KEY `images_i2` (`date_available`), 202 KEY `images_i3` (` average_rate`),202 KEY `images_i3` (`rating_score`), 203 203 KEY `images_i4` (`hit`), 204 204 KEY `images_i5` (`date_creation`), -
trunk/install/piwigo_structure-pdo-sqlite.sql
r10198 r11893 184 184 "representative_ext" VARCHAR(4), 185 185 "date_metadata_update" DATE, 186 " average_rate" FLOAT,186 "rating_score" FLOAT, 187 187 "has_high" BOOLEAN default false, 188 188 "path" VARCHAR(255) default '' NOT NULL, … … 200 200 CREATE INDEX "images_i2" ON "piwigo_images" ("date_available"); 201 201 202 CREATE INDEX "images_i3" ON "piwigo_images" (" average_rate");202 CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score"); 203 203 204 204 CREATE INDEX "images_i4" ON "piwigo_images" ("hit"); -
trunk/install/piwigo_structure-pgsql.sql
r10198 r11893 228 228 "representative_ext" VARCHAR(4), 229 229 "date_metadata_update" DATE, 230 " average_rate" FLOAT,230 "rating_score" FLOAT, 231 231 "has_high" BOOLEAN default false, 232 232 "path" VARCHAR(255) default '' NOT NULL, … … 247 247 CREATE INDEX "images_i2" ON "piwigo_images" ("date_available"); 248 248 249 CREATE INDEX "images_i3" ON "piwigo_images" (" average_rate");249 CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score"); 250 250 251 251 CREATE INDEX "images_i4" ON "piwigo_images" ("hit"); -
trunk/install/piwigo_structure-sqlite.sql
r10198 r11893 184 184 "representative_ext" VARCHAR(4), 185 185 "date_metadata_update" DATE, 186 " average_rate" FLOAT,186 "rating_score" FLOAT, 187 187 "has_high" BOOLEAN default false, 188 188 "path" VARCHAR(255) default '' NOT NULL, … … 200 200 CREATE INDEX "images_i2" ON "piwigo_images" ("date_available"); 201 201 202 CREATE INDEX "images_i3" ON "piwigo_images" (" average_rate");202 CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score"); 203 203 204 204 CREATE INDEX "images_i4" ON "piwigo_images" ("hit"); -
trunk/language/it_IT/help/configuration.html
r11518 r11893 44 44 <li><b>name</b> : nome della foto</li> 45 45 <li><b>hit</b> : numero di visite</li> 46 <li><b> average_rate</b>: nota globbale</li>46 <li><b>rating_score</b>: nota globbale</li> 47 47 </ul> 48 48 Non dimenticate che per ogni campo di specificare l'ordinamento con le parole chiavi <i>ASC</i> e <i>DESC</i> -
trunk/themes/default/template/picture.tpl
r11839 r11893 195 195 {/if} 196 196 197 {if $display_info. average_rate and isset($rate_summary)}197 {if $display_info.rating_score and isset($rate_summary)} 198 198 <tr id="Average"> 199 199 <td class="label">{'Rating score'|@translate}</td> -
trunk/ws.php
r11746 r11893 74 74 'Returns elements for the corresponding categories. 75 75 <br><b>cat_id</b> can be empty if <b>recursive</b> is true. Can be sent as an array. 76 <br><b>order</b> comma separated fields for sorting (file,id, average_rate,...)'76 <br><b>order</b> comma separated fields for sorting (file,id, rating_score,...)' 77 77 ); 78 78
Note: See TracChangeset
for help on using the changeset viewer.