Changeset 11893


Ignore:
Timestamp:
08/02/11 21:20:50 (8 years ago)
Author:
rvelices
Message:

rename #images.average_rate to rating_score

Location:
trunk
Files:
1 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/configuration.php

    r11827 r11893  
    9999    'categories', 
    100100    'visits', 
    101     'average_rate', 
     101    'rating_score', 
    102102    'privacy_level', 
    103103  ); 
     
    110110  'date_creation' => l10n('Creation date'), 
    111111  'date_available' => l10n('Post date'), 
    112   'average_rate' => l10n('Rating score'), 
     112  'rating_score' => l10n('Rating score'), 
    113113  'hit' => l10n('Most visited'), 
    114114  'id' => 'Id', 
  • trunk/admin/element_set_ranks.php

    r11829 r11893  
    9393  { 
    9494    asort($_POST['rank_of_image'], SORT_NUMERIC); 
    95    
     95 
    9696    save_images_order( 
    9797      $page['category_id'], 
     
    106106 
    107107  $image_order = null; 
    108   if (!empty($_POST['image_order_choice'])  
     108  if (!empty($_POST['image_order_choice']) 
    109109      && in_array($_POST['image_order_choice'], $image_order_choices)) 
    110110  { 
    111111    $image_order_choice = $_POST['image_order_choice']; 
    112112  } 
    113        
     113 
    114114  if ($image_order_choice=='user_define') 
    115115  { 
     
    142142  { 
    143143    $cat_info = get_cat_info($page['category_id']); 
    144      
     144 
    145145    $query = ' 
    146146UPDATE '.CATEGORIES_TABLE.' 
     
    173173  $image_order_choice = 'rank'; 
    174174} 
    175 elseif ($category['image_order']!='')  
     175elseif ($category['image_order']!='') 
    176176{ 
    177177  $image_order_choice = 'user_define'; 
     
    218218        { 
    219219                $src = get_thumbnail_url($row); 
    220                  
     220 
    221221                $thumbnail_size = getimagesize($src); 
    222222                if ( !empty( $row['name'] ) ) 
     
    274274  'date_creation' => l10n('Creation date'), 
    275275  'date_available' => l10n('Post date'), 
    276   'average_rate' => l10n('Rating score'), 
     276  'rating_score' => l10n('Rating score'), 
    277277  'hit' => l10n('Most visited'), 
    278278  'file' => l10n('File name'), 
  • trunk/admin/rating.php

    r11827 r11893  
    165165       i.file, 
    166166       i.tn_ext, 
    167        i.average_rate                           AS score, 
     167       i.rating_score                           AS score, 
    168168       MAX(r.date)          AS recently_rated, 
    169169                         ROUND(AVG(r.rate),2) AS avg_rates, 
     
    177177        i.file, 
    178178        i.tn_ext, 
    179         i.average_rate, 
     179        i.rating_score, 
    180180        r.element_id 
    181181  ORDER BY ' . $available_order_by[$order_by_index][1] .' 
  • trunk/admin/themes/default/template/configuration.tpl

    r11827 r11893  
    417417      <label> 
    418418        <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}> 
    420420      </label> 
    421421    </li> 
  • trunk/include/category_default.inc.php

    r11591 r11893  
    154154      case 'best_rated' : 
    155155      { 
    156         $name = '('.$row['average_rate'].') '.$name; 
     156        $name = '('.$row['rating_score'].') '.$name; 
    157157        break; 
    158158      } 
  • trunk/include/config_default.inc.php

    r11739 r11893  
    497497// delete from piwigo_sessions; 
    498498// delete from piwigo_rate; 
    499 // update piwigo_images set average_rate = null; 
     499// update piwigo_images set rating_score = null; 
    500500// delete from piwigo_caddie; 
    501501// delete from piwigo_favorites; 
  • trunk/include/functions_category.inc.php

    r11827 r11893  
    291291    array( 
    292292    array(l10n('Default'), '', true), 
    293     array(l10n('Rating score'), 'average_rate DESC', $conf['rate']), 
     293    array(l10n('Rating score'), 'rating_score DESC', $conf['rate']), 
    294294    array(l10n('Most visited'), 'hit DESC', true), 
    295295    array(l10n('Creation date'), 'date_creation DESC', true), 
     
    560560  $tree = array(); 
    561561  $key_of_cat = array(); 
    562    
     562 
    563563  foreach ($categories as $key => &$node) 
    564564  { 
    565565    $key_of_cat[$node['id']] = $key; 
    566      
     566 
    567567    if (!isset($node['id_uppercat'])) 
    568568    { 
     
    575575        $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'] = array(); 
    576576      } 
    577        
     577 
    578578      $categories[ $key_of_cat[ $node['id_uppercat'] ] ]['sub_categories'][$key] = &$node; 
    579579    } 
    580580  } 
    581    
     581 
    582582  return $tree; 
    583583} 
  • trunk/include/functions_rate.inc.php

    r11827 r11893  
    121121 
    122122 
    123 /* update images.average_rate field 
     123/* update images.rating_score field 
    124124  * we use a bayesian average (http://en.wikipedia.org/wiki/Bayesian_average) with 
    125125C = average number of rates per item 
     
    127127 
    128128 * param int $element_id optional, otherwise applies to all 
    129  * @return array(average_rate, count) if element_id is specified 
     129 * @return array(rating_score, count) if element_id is specified 
    130130*/ 
    131131function update_rating_score($element_id = false) 
     
    167167        ); 
    168168    } 
    169     $updates[] = array( 'id'=>$id, 'average_rate'=>$score ); 
     169    $updates[] = array( 'id'=>$id, 'rating_score'=>$score ); 
    170170  } 
    171171  mass_updates( 
     
    173173    array( 
    174174      'primary' => array('id'), 
    175       'update' => array('average_rate') 
     175      'update' => array('rating_score') 
    176176      ), 
    177177    $updates 
     
    184184SELECT id FROM '.IMAGES_TABLE .' 
    185185  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'; 
    187187 
    188188    $to_update = array_from_query( $query, 'id'); 
     
    192192      $query=' 
    193193UPDATE '.IMAGES_TABLE .' 
    194   SET average_rate=NULL 
     194  SET rating_score=NULL 
    195195  WHERE id IN (' . implode(',',$to_update) . ')'; 
    196196    pwg_query($query); 
  • trunk/include/picture_rate.inc.php

    r11827 r11893  
    2929if ($conf['rate']) 
    3030{ 
    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 ); 
    3232  if ( NULL != $rate_summary['score'] ) 
    3333  { 
  • trunk/include/section_init.inc.php

    r8728 r11893  
    6262    break; 
    6363  } 
    64    
     64 
    6565  // the $_GET keys are not protected in include/common.inc.php, only the values 
    6666  $rewritten = pwg_db_real_escape_string($rewritten); 
    67    
     67 
    6868  $page['root_path'] = PHPWG_ROOT_PATH; 
    6969} 
     
    464464  { 
    465465    $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'; 
    467467    $query = ' 
    468 SELECT DISTINCT(id), hit, file 
     468SELECT DISTINCT(id) 
    469469  FROM '.IMAGES_TABLE.' 
    470470    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
     
    490490  { 
    491491    $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'; 
    493493 
    494494    $query =' 
    495 SELECT DISTINCT(id), average_rate 
     495SELECT DISTINCT(id) 
    496496  FROM '.IMAGES_TABLE.' 
    497497    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
    498   WHERE average_rate IS NOT NULL 
     498  WHERE rating_score IS NOT NULL 
    499499    '.$forbidden.' 
    500500    '.$conf['order_by'].' 
  • trunk/include/ws_functions.inc.php

    r11827 r11893  
    5555  if ( is_numeric($params['f_min_rate']) ) 
    5656  { 
    57     $clauses[] = $tbl_name.'average_rate>'.$params['f_min_rate']; 
     57    $clauses[] = $tbl_name.'rating_score>'.$params['f_min_rate']; 
    5858  } 
    5959  if ( is_numeric($params['f_max_rate']) ) 
    6060  { 
    61     $clauses[] = $tbl_name.'average_rate<='.$params['f_max_rate']; 
     61    $clauses[] = $tbl_name.'rating_score<='.$params['f_max_rate']; 
    6262  } 
    6363  if ( is_numeric($params['f_min_hit']) ) 
     
    124124        $matches[1][$i] = DB_RANDOM_FUNCTION.'()'; break; 
    125125    } 
    126     $sortable_fields = array('id', 'file', 'name', 'hit', 'average_rate', 
     126    $sortable_fields = array('id', 'file', 'name', 'hit', 'rating_score', 
    127127      'date_creation', 'date_available', DB_RANDOM_FUNCTION.'()' ); 
    128128    if ( in_array($matches[1][$i], $sortable_fields) ) 
     
    193193 
    194194  $infos['version'] = PHPWG_VERSION; 
    195          
     195 
    196196  $query = 'SELECT COUNT(*) FROM '.IMAGES_TABLE.';'; 
    197197  list($infos['nb_elements']) = pwg_db_fetch_row(pwg_query($query)); 
     
    444444      // which is an element in the XML output. The "hierarchy" output is 
    445445      // only compatible with json/php output. 
    446        
     446 
    447447      return new PwgError(405, "The tree_output option is only compatible with json/php output formats"); 
    448448    } 
     
    472472    $where[] = 'status = "public"'; 
    473473    $where[] = 'visible = "true"'; 
    474      
     474 
    475475    $join_user = $conf['guest_id']; 
    476476  } 
     
    480480    // categories. Function calculate_permissions will only return 
    481481    // categories that are either locked or private and not permitted 
    482     //  
     482    // 
    483483    // calculate_permissions does not consider empty categories as forbidden 
    484484    $forbidden_categories = calculate_permissions($user['id'], $user['status']); 
     
    519519        ) 
    520520      ); 
    521      
     521 
    522522    $row['comment'] = strip_tags( 
    523523      trigger_event( 
     
    527527        ) 
    528528      ); 
    529      
     529 
    530530    array_push($cats, $row); 
    531531  } 
     
    533533 
    534534  if ($params['tree_output']) 
    535   {  
     535  { 
    536536    return categories_flatlist_to_tree($cats); 
    537537  } 
     
    782782  } 
    783783  //------------------------------------------------------------- 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); 
    785785        if (isset($rating['score'])) 
    786786        { 
     
    10291029    return new PwgError(401, 'Access denied'); 
    10301030  } 
    1031    
     1031 
    10321032  if (!$service->isPost()) 
    10331033  { 
     
    10551055    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid rank"); 
    10561056  } 
    1057    
     1057 
    10581058  // does the image really exist? 
    10591059  $query=' 
     
    10691069    return new PwgError(404, "image_id not found"); 
    10701070  } 
    1071    
     1071 
    10721072  // is the image associated to this category? 
    10731073  $query = ' 
     
    11381138{ 
    11391139  global $conf; 
    1140    
     1140 
    11411141  ws_logfile('[ws_images_add_chunk] welcome'); 
    11421142  // data 
     
    11591159      continue; 
    11601160    } 
    1161      
     1161 
    11621162    ws_logfile( 
    11631163      sprintf( 
     
    12191219{ 
    12201220  global $conf; 
    1221    
     1221 
    12221222  ws_logfile('[merge_chunks] input parameter $output_filepath : '.$output_filepath); 
    12231223 
     
    12871287{ 
    12881288  include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php'); 
    1289    
     1289 
    12901290  $file_path = file_path_for_type($file_path, $type); 
    12911291 
     
    12981298  ws_logfile('[add_file] file_path  : '.$file_path); 
    12991299  ws_logfile('[add_file] upload_dir : '.$upload_dir); 
    1300    
     1300 
    13011301  if (!is_dir($upload_dir)) { 
    13021302    umask(0000); 
     
    14461446    $where_clause = "file = '".$params['original_filename']."'"; 
    14471447  } 
    1448    
     1448 
    14491449  $query = ' 
    14501450SELECT 
     
    15501550  require_once(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php'); 
    15511551  update_metadata(array($image_id=>$file_path)); 
    1552    
     1552 
    15531553  invalidate_user_cache(); 
    15541554} 
     
    15711571    return new PwgError(405, "The image (file) parameter is missing"); 
    15721572  } 
    1573    
     1573 
    15741574  $params['image_id'] = (int)$params['image_id']; 
    15751575  if ($params['image_id'] > 0) 
     
    16771677;'; 
    16781678  list($file_path) = pwg_db_fetch_row(pwg_query($query)); 
    1679    
     1679 
    16801680  require_once(PHPWG_ROOT_PATH.'admin/include/functions_metadata.php'); 
    16811681  update_metadata(array($image_id=>$file_path)); 
     
    17321732  list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); 
    17331733  $res['current_datetime'] = $dbnow; 
    1734    
     1734 
    17351735  return $res; 
    17361736} 
     
    18271827 
    18281828  $image_ids = array_slice($image_ids, (int)($params['per_page']*$params['page']), (int)$params['per_page'] ); 
    1829    
     1829 
    18301830  $image_tag_map = array(); 
    18311831  if ( !empty($image_ids) and !$params['tag_mode_and'] ) 
     
    19631963{ 
    19641964  global $conf; 
    1965    
     1965 
    19661966  if (!is_admin()) 
    19671967  { 
     
    20022002    } 
    20032003  } 
    2004    
     2004 
    20052005  if ('filename' == $conf['uniqueness_mode']) 
    20062006  { 
     
    24812481{ 
    24822482  global $conf; 
    2483    
     2483 
    24842484  if (!is_admin()) 
    24852485  { 
     
    25192519    return new PwgError(WS_ERR_INVALID_PARAM, "Invalid image_id"); 
    25202520  } 
    2521    
     2521 
    25222522  // does the image really exist? 
    25232523  $query=' 
     
    26122612    return; 
    26132613  } 
    2614    
     2614 
    26152615  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); 
    26162616  delete_categories($category_ids, $params['photo_deletion_mode']); 
     
    26212621{ 
    26222622  global $conf, $page; 
    2623    
     2623 
    26242624  if (!is_admin()) 
    26252625  { 
     
    26612661  // we can't move physical categories 
    26622662  $categories_in_db = array(); 
    2663    
     2663 
    26642664  $query = ' 
    26652665SELECT 
     
    26842684          ) 
    26852685        ); 
    2686        
     2686 
    26872687      return new PwgError( 
    26882688        403, 
     
    26992699  { 
    27002700    $unknown_category_ids = array_diff($category_ids, array_keys($categories_in_db)); 
    2701      
     2701 
    27022702    return new PwgError( 
    27032703      403, 
     
    27172717    return new PwgError(403, 'Invalid parent input parameter'); 
    27182718  } 
    2719    
     2719 
    27202720  if (0 != $params['parent']) { 
    27212721    $params['parent'] = intval($params['parent']); 
     
    27662766  $ret['message'] = ready_for_upload_message(); 
    27672767  $ret['ready_for_upload'] = true; 
    2768    
     2768 
    27692769  if (!empty($ret['message'])) 
    27702770  { 
    27712771    $ret['ready_for_upload'] = false; 
    27722772  } 
    2773    
     2773 
    27742774  return $ret; 
    27752775} 
     
    27782778{ 
    27792779  global $conf; 
    2780    
     2780 
    27812781  if (!is_admin()) 
    27822782  { 
     
    28182818{ 
    28192819  global $template; 
    2820    
     2820 
    28212821  if (!is_admin()) 
    28222822  { 
     
    28342834  $errors = $plugins->perform_action($params['action'], $params['plugin']); 
    28352835 
    2836    
     2836 
    28372837  if (!empty($errors)) 
    28382838  { 
     
    28522852{ 
    28532853  global $template; 
    2854    
     2854 
    28552855  if (!is_admin()) 
    28562856  { 
     
    28672867  $themes = new themes(); 
    28682868  $errors = $themes->perform_action($params['action'], $params['theme']); 
    2869    
     2869 
    28702870  if (!empty($errors)) 
    28712871  { 
     
    30453045      ); 
    30463046    } 
    3047      
     3047 
    30483048    $upgrade_status = $extension->extract_plugin_files('upgrade', $revision, $extension_id); 
    30493049    $extension_name = $extension->fs_plugins[$extension_id]['name']; 
  • trunk/install/config.sql

    r11587 r11893  
    4848  VALUES ( 
    4949    '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;}', 
    5151    'Information displayed on picture page' 
    5252  ); 
  • trunk/install/piwigo_structure-mysql.sql

    r10341 r11893  
    188188  `representative_ext` varchar(4) default NULL, 
    189189  `date_metadata_update` date default NULL, 
    190   `average_rate` float(5,2) unsigned default NULL, 
     190  `rating_score` float(5,2) unsigned default NULL, 
    191191  `has_high` enum('true') default NULL, 
    192192  `path` varchar(255) NOT NULL default '', 
     
    200200  PRIMARY KEY  (`id`), 
    201201  KEY `images_i2` (`date_available`), 
    202   KEY `images_i3` (`average_rate`), 
     202  KEY `images_i3` (`rating_score`), 
    203203  KEY `images_i4` (`hit`), 
    204204  KEY `images_i5` (`date_creation`), 
  • trunk/install/piwigo_structure-pdo-sqlite.sql

    r10198 r11893  
    184184  "representative_ext" VARCHAR(4), 
    185185  "date_metadata_update" DATE, 
    186   "average_rate" FLOAT, 
     186  "rating_score" FLOAT, 
    187187  "has_high" BOOLEAN default false, 
    188188  "path" VARCHAR(255) default '' NOT NULL, 
     
    200200CREATE INDEX "images_i2" ON "piwigo_images" ("date_available"); 
    201201 
    202 CREATE INDEX "images_i3" ON "piwigo_images" ("average_rate"); 
     202CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score"); 
    203203 
    204204CREATE INDEX "images_i4" ON "piwigo_images" ("hit"); 
  • trunk/install/piwigo_structure-pgsql.sql

    r10198 r11893  
    228228  "representative_ext" VARCHAR(4), 
    229229  "date_metadata_update" DATE, 
    230   "average_rate" FLOAT, 
     230  "rating_score" FLOAT, 
    231231  "has_high" BOOLEAN default false, 
    232232  "path" VARCHAR(255) default '' NOT NULL, 
     
    247247CREATE INDEX "images_i2" ON "piwigo_images" ("date_available"); 
    248248 
    249 CREATE INDEX "images_i3" ON "piwigo_images" ("average_rate"); 
     249CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score"); 
    250250 
    251251CREATE INDEX "images_i4" ON "piwigo_images" ("hit"); 
  • trunk/install/piwigo_structure-sqlite.sql

    r10198 r11893  
    184184  "representative_ext" VARCHAR(4), 
    185185  "date_metadata_update" DATE, 
    186   "average_rate" FLOAT, 
     186  "rating_score" FLOAT, 
    187187  "has_high" BOOLEAN default false, 
    188188  "path" VARCHAR(255) default '' NOT NULL, 
     
    200200CREATE INDEX "images_i2" ON "piwigo_images" ("date_available"); 
    201201 
    202 CREATE INDEX "images_i3" ON "piwigo_images" ("average_rate"); 
     202CREATE INDEX "images_i3" ON "piwigo_images" ("rating_score"); 
    203203 
    204204CREATE INDEX "images_i4" ON "piwigo_images" ("hit"); 
  • trunk/language/it_IT/help/configuration.html

    r11518 r11893  
    4444      <li><b>name</b> : nome della foto</li> 
    4545      <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> 
    4747    </ul> 
    4848    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  
    195195        {/if} 
    196196 
    197 {if $display_info.average_rate and isset($rate_summary)} 
     197{if $display_info.rating_score and isset($rate_summary)} 
    198198        <tr id="Average"> 
    199199                <td class="label">{'Rating score'|@translate}</td> 
  • trunk/ws.php

    r11746 r11893  
    7474      'Returns elements for the corresponding categories. 
    7575<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,...)' 
    7777    ); 
    7878 
Note: See TracChangeset for help on using the changeset viewer.