Changeset 2517


Ignore:
Timestamp:
Sep 11, 2008, 11:40:00 PM (16 years ago)
Author:
plg
Message:

feature 169 added: ability to manually sort images inside a category. A
dedicated screen let the administrator sort the images (pur HTML, no
JavaScript yet). The "rank" sort order is available only for a category
without flat mode. New database column image_category.rank.

Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r2490 r2517  
    275275if ($category['has_images'])
    276276{
    277   $template->assign( 'U_MANAGE_ELEMENTS',
    278         $base_url.'element_set&cat='.$category['id']
     277  $template->assign(
     278    'U_MANAGE_ELEMENTS',
     279    $base_url.'element_set&cat='.$category['id']
     280    );
     281  $template->assign(
     282    'U_MANAGE_RANKS',
     283    $base_url.'element_set_ranks&cat_id='.$category['id']
    279284    );
    280285}
     
    314319  'file' => l10n('File name'),
    315320  'id' => 'Id',
     321  'rank' => l10n('Rank'),
    316322  );
    317323
  • trunk/admin/template/yoga/admin/cat_modify.tpl

    r2490 r2517  
    1010  {if isset($U_MANAGE_ELEMENTS) }
    1111  <li><a href="{$U_MANAGE_ELEMENTS}" title="{'manage category elements'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/category_elements.png" class="button" alt="{'elements'|@translate}" /></a></li>
     12  <li><a href="{$U_MANAGE_RANKS}" title="{'manage element ranks'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/ranks.png" class="button" alt="{'ranks'|@translate}" /></a></li>
    1213  {/if}
    1314  <li><a href="{$U_CHILDREN}" title="{'manage sub-categories'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/category_children.png" class="button" alt="{'sub-categories'|@translate}" /></a></li>
  • trunk/include/config_default.inc.php

    r2516 r2517  
    6363//    the date_available
    6464$conf['order_by'] = ' ORDER BY date_available DESC, file ASC, id ASC';
     65
     66// order_by_inside_category : inside a category, images can also be ordered
     67// by rank. A manually defined rank on each image for the category.
     68//
     69// In addition to fields of #images table, you can use the
     70// #image_category.rank column
     71//
     72// $conf['order_by_inside_category'] = ' ORDER BY rank';
     73// will sort images by the manually defined rank of images in this category.
     74$conf['order_by_inside_category'] = $conf['order_by'];
    6575
    6676// file_ext : file extensions (case sensitive) authorized
  • trunk/include/functions_category.inc.php

    r2433 r2517  
    258258function get_category_preferred_image_orders()
    259259{
    260   global $conf;
     260  global $conf, $page;
     261 
    261262  return array(
    262263    array(l10n('default_sort'), '', true),
     
    265266    array(l10n('Creation date'), 'date_creation DESC', true),
    266267    array(l10n('Post date'), 'date_available DESC', true),
    267     array(l10n('File name'), 'file ASC', true)
    268   );
     268    array(l10n('File name'), 'file ASC', true),
     269    array(
     270      l10n('Rank'),
     271      'rank ASC',
     272      ('categories' == $page['section'] and !isset($page['flat']))
     273      )
     274    );
    269275}
    270276
  • trunk/include/section_init.inc.php

    r2451 r2517  
    173173$page['nb_image_page'] = $user['nb_image_page'];
    174174
     175// if flat mode is active, we must consider the image set as a standard set
     176// and not as a category set because we can't use the #image_category.rank :
     177// displayed images are not directly linked to the displayed category
     178if ('categories' == $page['section'] and !isset($page['flat']))
     179{
     180  $conf['order_by'] = $conf['order_by_inside_category'];
     181}
     182
    175183if (pwg_get_session_var('image_order',0) > 0)
    176184{
     185  $image_order_id = pwg_get_session_var('image_order');
     186 
    177187  $orders = get_category_preferred_image_orders();
    178188
    179   $conf['order_by'] = str_replace(
    180     'ORDER BY ',
    181     'ORDER BY '.$orders[ pwg_get_session_var('image_order',0) ][1].',',
    182     $conf['order_by']
     189  // the current session stored image_order might be not compatible with
     190  // current image set, for example if the current image_order is the rank
     191  // and that we are displaying images related to a tag.
     192  //
     193  // In case of incompatibility, the session stored image_order is removed.
     194  if ($orders[$image_order_id][2])
     195  {
     196    $conf['order_by'] = str_replace(
     197      'ORDER BY ',
     198      'ORDER BY '.$orders[$image_order_id][1].',',
     199      $conf['order_by']
    183200    );
    184   $page['super_order_by'] = true;
     201    $page['super_order_by'] = true;
     202
     203  }
     204  else
     205  {
     206    pwg_unset_session_var('image_order');
     207    $page['super_order_by'] = false;
     208  }
    185209}
    186210
  • trunk/index.php

    r2488 r2517  
    261261
    262262  $orders = get_category_preferred_image_orders();
    263   for ($i = 0; $i < count($orders); $i++)
    264   {
    265     if ($orders[$i][2])
     263  foreach ($orders as $order_id => $order)
     264  {
     265    if ($order[2])
    266266    {
    267267      $template->append(
    268268        'image_orders',
    269269        array(
    270           'DISPLAY' => $orders[$i][0],
    271           'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
    272           'SELECTED' => ($order_idx==$i ? true:false),
     270          'DISPLAY' => $order[0],
     271          'URL' => add_url_params(
     272            duplicate_index_url(),
     273            array('image_order' => $order_id)
     274            ),
     275          'SELECTED' => ($order_idx == $order_id ? true:false),
    273276          )
    274277        );
  • trunk/install/piwigo_structure.sql

    r2448 r2517  
    151151  `image_id` mediumint(8) unsigned NOT NULL default '0',
    152152  `category_id` smallint(5) unsigned NOT NULL default '0',
     153  `rank` mediumint(8) unsigned default NULL,
    153154  PRIMARY KEY  (`image_id`,`category_id`),
    154155  KEY `image_category_i1` (`category_id`)
Note: See TracChangeset for help on using the changeset viewer.