Changeset 1020 for trunk


Ignore:
Timestamp:
Feb 1, 2006, 3:46:26 AM (18 years ago)
Author:
rvelices
Message:

feature 280: Allow visitors/users to choose image ordering inside a category

improvement 82: Viewing pictures from remote galleries does not check anymore
for the high pictures (existence flag added to create_listing_file and db)

correction: link element in picture is in the head instead of body (w3c spec)

correction: in profile.php the current template was not selected by default

Location:
trunk
Files:
1 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/remote_site.php

    r1004 r1020  
    410410                             'name',
    411411                             'comment',
     412                             'has_high',
    412413                             'path');
    413414      foreach ($optional_atts as $att)
     
    426427    $dbfields = array('file','storage_category_id','date_available','tn_ext',
    427428                      'filesize','width','height','date_creation','author',
    428                       'keywords','name','comment','path');
     429                      'keywords','name','comment','has_high','path');
    429430    mass_inserts(IMAGES_TABLE, $dbfields, $inserts);
    430431    $counts{'new_elements'}+= count($inserts);
  • trunk/category.php

    r1015 r1020  
    407407      );
    408408  }
     409  if ($page['cat_nb_images']>0 and
     410       $page['cat'] != 'most_visited' and $page['cat'] != 'best_rated')
     411  {
     412    // image order
     413    $template->assign_block_vars( 'preferred_image_order', array() );
     414 
     415    if ( isset($_GET['image_order']) )
     416    {
     417      $order_idx = $_GET['image_order'];
     418    }
     419    else
     420    {
     421      $order_idx = isset($_COOKIE['pwg_image_order']) ?
     422                     $_COOKIE['pwg_image_order'] : 0;
     423    }
     424 
     425    $orders = get_category_preferred_image_orders();
     426    for ( $i = 0; $i < count($orders); $i++)
     427    {
     428      if ($orders[$i][2])
     429      {
     430        $url = PHPWG_ROOT_PATH.'category.php'
     431                 .get_query_string_diff(array('image_order'));
     432        $url .= '&amp;image_order='.$i;
     433        $template->assign_block_vars( 'preferred_image_order.order', array(
     434          'DISPLAY' => $orders[$i][0],
     435          'URL' => $url,
     436          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ),
     437          ) );
     438      }
     439    }
     440  }
    409441}
    410442//------------------------------------------------------------ log informations
  • trunk/include/functions.inc.php

    r1015 r1020  
    534534}
    535535
     536function url_is_remote($url)
     537{
     538  if (preg_match('/^https?:\/\/[~\/\.\w-]+$/', $url))
     539  {
     540    return true;
     541  }
     542  return false;
     543}
     544
    536545/**
    537546 * returns available templates/themes
  • trunk/include/functions_category.inc.php

    r1008 r1020  
    319319}
    320320
     321// returns an array of image orders available for users/visitors
     322function get_category_preferred_image_orders()
     323{
     324  global $lang, $conf;
     325  return array(
     326        array('Default', '', true),
     327        array($lang['best_rated_cat'],   'average_rate DESC', $conf['rate']),
     328        array($lang['most_visited_cat'], 'hit DESC', true),
     329        array($lang['Creation date'], 'date_creation DESC', true),
     330        array($lang['Availability date'], 'date_available DESC', true)
     331  );
     332}
     333
     334
    321335// initialize_category initializes ;-) the variables in relation
    322336// with category :
     
    604618                               $user['nb_image_page'], 'back' );
    605619    }
     620   
     621    if ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated')
     622    {
     623      $available_image_orders = get_category_preferred_image_orders();
     624     
     625      $order_idx=0;
     626      if ( isset($_GET['image_order']) )
     627      {
     628        $order_idx = $_GET['image_order'];
     629        setcookie( 'pwg_image_order', $order_idx, 0 );
     630      }
     631      else if ( isset($_COOKIE['pwg_image_order']) )
     632      {
     633        $order_idx = $_COOKIE['pwg_image_order'];
     634      }
     635     
     636      if ( $order_idx > 0 )
     637      {
     638        $order = $available_image_orders[$order_idx][1];
     639        $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY '.$order.',',
     640                                          $conf['order_by'] );
     641      }
     642    }
    606643  }
    607644  else
  • trunk/install/phpwebgallery_structure.sql

    r1008 r1020  
    1 -- MySQL dump 9.11
    2 --
    3 -- Host: localhost    Database: pwg-bsf
     1-- MySQL dump 10.9
     2--
     3-- Host: localhost    Database: pwg_dev_bsf
    44-- ------------------------------------------------------
    5 -- Server version       4.0.24_Debian-10-log
     5-- Server version       4.1.15-nt
    66
    77--
     
    156156  `date_metadata_update` date default NULL,
    157157  `average_rate` float(5,2) unsigned default NULL,
     158  `has_high` enum('true') default NULL,
    158159  `path` varchar(255) NOT NULL default '',
    159160  PRIMARY KEY  (`id`),
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r1015 r1020  
    4444$lang['At least one listed rule must be satisfied.'] = 'At least one listed rule must be satisfied.';
    4545$lang['Author'] = 'Author';
     46$lang['Availability date'] = 'Availability date';
    4647$lang['Average rate'] = 'Average rate';
    4748$lang['Categories'] = 'Categories';
     
    5455$lang['Create a new account'] = 'Create a new account';
    5556$lang['Created on'] = 'Created on';
     57$lang['Creation date'] = 'Creation date';
    5658$lang['Current password is wrong'] = 'Current password is wrong';
    5759$lang['Dimensions'] = 'Dimensions';
     
    122124$lang['became available between %s (%s) and %s (%s)'] = 'became available between %s (%s) and %s (%s)';
    123125$lang['became available on %s'] = 'became available on %s';
    124 $lang['best_rated_cat'] = 'best rated';
     126$lang['best_rated_cat'] = 'Best rated';
    125127$lang['best_rated_cat_hint'] = 'displays best rated items';
    126128$lang['caddie'] = 'caddie';
  • trunk/language/fr_FR.iso-8859-1/common.lang.php

    r1015 r1020  
    4343$lang['At least one listed rule must be satisfied.'] = 'Au moins un des critères doit être satisfait.';
    4444$lang['Author'] = 'Auteur';
     45$lang['Availability date'] = 'Date de disponibilité';
    4546$lang['Average rate'] = 'Note moyenne';
    4647$lang['Categories'] = 'Catégories';
     
    5354$lang['Create a new account'] = 'Créer un nouveau compte';
    5455$lang['Created on'] = 'Créée le';
     56$lang['Creation date'] = 'Date de création';
    5557$lang['Current password is wrong'] = 'Erreur sur le mot de passe actuel';
    5658$lang['Dimensions'] = 'Dimensions';
  • trunk/picture.php

    r1014 r1020  
    248248    // if we are working on the "current" element, we search if there is a
    249249    // high quality picture
    250     // FIXME : with remote pictures, this "remote fopen" takes long...
    251250    if ($i == 'current')
    252251    {
    253       if (@fopen($cat_directory.'/pwg_high/'.$row['file'], 'r'))
     252      $url_high=$cat_directory.'/pwg_high/'.$row['file'];
     253      if (url_is_remote($cat_directory))
    254254      {
    255         $picture[$i]['high'] = $cat_directory.'/pwg_high/'.$row['file'];
     255        if ($row['has_high'])
     256        {
     257          $picture[$i]['high'] = $url_high;
     258        }
     259      }
     260      else
     261      {
     262        if (@fopen($url_high, 'r'))
     263        {
     264          $picture[$i]['high'] = $url_high;
     265        }
    256266      }
    257267    }
     
    527537
    528538$page['body_id'] = 'thePicturePage';
     539//-------------------------------------------------------- navigation management
     540if ($has_prev)
     541{
     542  $template->assign_block_vars(
     543    'previous',
     544    array(
     545      'TITLE_IMG' => $picture['prev']['name'],
     546      'IMG' => $picture['prev']['thumbnail'],
     547      'U_IMG' => $picture['prev']['url'],
     548      'U_IMG_SRC' => $picture['prev']['src']
     549      ));
     550}
     551
     552if ($has_next)
     553{
     554  $template->assign_block_vars(
     555    'next',
     556    array(
     557      'TITLE_IMG' => $picture['next']['name'],
     558      'IMG' => $picture['next']['thumbnail'],
     559      'U_IMG' => $picture['next']['url'],
     560      'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload
     561      ));
     562}
     563
    529564include(PHPWG_ROOT_PATH.'include/page_header.php');
    530565$template->set_filenames(array('picture'=>'picture.tpl'));
     
    586621if (isset($picture['current']['high']))
    587622{
    588   $full_size = @getimagesize($picture['current']['high']);
    589   $full_width = $full_size[0];
    590   $full_height = $full_size[1];
    591623  $uuid = uniqid(rand());
    592624  $template->assign_block_vars('high', array(
    593625    'U_HIGH' => $picture['current']['high'],
    594         'UUID'=>$uuid,
    595         'WIDTH_IMG'=>($full_width + 40),
    596         'HEIGHT_IMG'=>($full_height + 40)
     626        'UUID'=>$uuid
    597627        ));
    598628  $template->assign_block_vars(
     
    672702{
    673703  $template->assign_block_vars('admin', array());
    674 }
    675 
    676 //-------------------------------------------------------- navigation management
    677 if ($has_prev)
    678 {
    679   $template->assign_block_vars(
    680     'previous',
    681     array(
    682       'TITLE_IMG' => $picture['prev']['name'],
    683       'IMG' => $picture['prev']['thumbnail'],
    684       'U_IMG' => $picture['prev']['url'],
    685       'U_IMG_SRC' => $picture['prev']['src']
    686       ));
    687 }
    688 
    689 if ($has_next)
    690 {
    691   $template->assign_block_vars(
    692     'next',
    693     array(
    694       'TITLE_IMG' => $picture['next']['name'],
    695       'IMG' => $picture['next']['thumbnail'],
    696       'U_IMG' => $picture['next']['url'],
    697       'U_IMG_SRC' => $picture['next']['src'] // allow navigator to preload
    698       ));
    699704}
    700705
  • trunk/profile.php

    r1004 r1020  
    212212    $selected = $_POST['template']==$pwg_template ? 'selected="selected"' : '';
    213213  }
    214   else if ($userdata['template'] == $pwg_template)
     214  else if ($userdata['template'].'/'.$userdata['theme'] == $pwg_template)
    215215  {
    216216    $selected = 'selected="selected"';
  • trunk/template/yoga/category.tpl

    r1015 r1020  
    121121      <!-- END search_rules -->
    122122
     123      <!-- BEGIN preferred_image_order -->
     124      <li>
     125      {lang:Sort order}:
     126      <select onchange="document.location = this.options[this.selectedIndex].value;">
     127        <!-- BEGIN order -->
     128        <option value="{preferred_image_order.order.URL}" {preferred_image_order.order.SELECTED_OPTION}>{preferred_image_order.order.DISPLAY}</option>
     129        <!-- END order -->
     130      </select>
     131      </li>
     132      <!-- END preferred_image_order -->
    123133    </ul>
    124134   
  • trunk/template/yoga/content.css

    r981 r1020  
    120120#content UL.categoryActions LI {
    121121  display: inline;
     122
    122123}
    123124
    124125#content UL.categoryActions A IMG, UL.categoryActions A {
    125126  border: none;
     127  margin-bottom: -5px;
    126128}
    127129
  • trunk/template/yoga/header.tpl

    r983 r1020  
    1212<link rel="stylesheet" type="text/css" href="template/{themeconf:template}/default-colors.css">
    1313<link rel="stylesheet" type="text/css" href="template/{themeconf:template}/theme/{themeconf:theme}/theme.css">
     14<!-- BEGIN next -->
     15<link rel="prefetch" href="{next.U_IMG_SRC}">
     16<!-- END next -->
    1417<!-- BEGIN refresh -->
    1518<meta http-equiv="refresh" content="{REFRESH_TIME};url={U_REFRESH}">
  • trunk/template/yoga/picture.tpl

    r1014 r1020  
    4040<!-- BEGIN next -->
    4141  <a class="navButton next" href="{next.U_IMG}" title="{L_NEXT_IMG}{next.TITLE_IMG}" rel="next"><img src="{themeconf:icon_dir}/right.png" class="button" alt="next"></a>
    42   <link rel="prefetch" href="{next.U_IMG_SRC}"><link rel="prefetch" href="{next.U_IMG}">
    4342<!-- END next -->
    4443  <a class="navButton up" href="{U_UP}" title="{L_UP_HINT}"><img src="{themeconf:icon_dir}/up.png" class="button" alt="{L_UP_ALT}"></a>
     
    5554<div id="theImage">
    5655<!-- BEGIN high -->
    57 <a href="javascript:phpWGOpenWindow('{high.U_HIGH}','{high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes,width={high.WIDTH_IMG},height={high.HEIGHT_IMG}')">
     56<a href="javascript:phpWGOpenWindow('{high.U_HIGH}','{high.UUID}','scrollbars=yes,toolbar=no,status=no,resizable=yes')">
    5857<!-- END high -->
    5958  <img src="{SRC_IMG}" style="width:{WIDTH_IMG}px;height:{HEIGHT_IMG}px;" alt="{ALT_IMG}">
  • trunk/tools/create_listing_file.php

    r954 r1020  
    281281
    282282/**
     283 * returns an array with high quality/resolution picture files of a directory
     284 * according to $conf['picture_ext']
     285 *
     286 * @param string $dir
     287 * @return array
     288 */
     289function get_high_files($dir)
     290{
     291  global $conf;
     292
     293  $pictures = array();
     294  if ($opendir = @opendir($dir.'/pwg_high'))
     295  {
     296    while ($file = readdir($opendir))
     297    {
     298      if (in_array(get_extension($file), $conf['picture_ext']))
     299      {
     300        array_push($pictures, $file);
     301      }
     302    }
     303  }
     304  return $pictures;
     305}
     306
     307/**
    283308 * search in $basedir the sub-directories and calls get_pictures
    284309 *
     
    348373  $fs_thumbnails = get_thumb_files($dir);
    349374  $fs_representatives = get_representative_files($dir);
     375  $fs_highs = get_high_files($dir);
    350376
    351377  $elements = array();
     
    378404
    379405    // 2 cases : the element is a picture or not. Indeed, for a picture
    380     // thumbnail is mandatory and for non picture element, thumbnail and
    381     // representative is optionnal
     406    // thumbnail is mandatory, high is optional and for non picture element,
     407    // thumbnail and representative is optionnal
    382408    if (in_array(get_extension($fs_file), $conf['picture_ext']))
    383409    {
     
    389415          $element['width'] = $image_size[0];
    390416          $element['height'] = $image_size[1];
     417        }
     418       
     419        if ( in_array($fs_file, $fs_highs) )
     420        {
     421          $element['has_high'] = 'true';
    391422        }
    392423
     
    453484  $attributes = array('file','tn_ext','representative_ext','filesize',
    454485                      'width','height','date_creation','author','keywords',
    455                       'name','comment','path');
     486                      'name','comment','has_high', 'path');
    456487  foreach ($elements as $element)
    457488  {
Note: See TracChangeset for help on using the changeset viewer.