Changeset 17181


Ignore:
Timestamp:
Jul 27, 2012, 6:57:18 PM (12 years ago)
Author:
mistic100
Message:

respect image order on the slideshow

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ExtendedDescription/main.inc.php

    r17180 r17181  
    530530function get_slider($param)
    531531{
    532   global $template, $conf;
     532  global $template, $conf, $ids; // global $ids for the callback
    533533 
    534534  $default_params = array(
     
    594594  LIMIT '.$params['nb_images'].'
    595595;';
    596     $params['list'] = implode(',', array_from_query($query, 'image_id'));
     596    $ids = array_from_query($query, 'image_id');
    597597  }
    598598  // ...or pictures list
    599   if (empty($params['list']))
     599  else if (empty($params['list']))
    600600  {
    601601    return 'missing album id or empty picture list';
    602602  }
     603  else
     604  {
     605    $ids = explode(',', $params['list']);
     606  }
     607 
    603608 
    604609  // get pictures
     
    606611SELECT *
    607612  FROM '.IMAGES_TABLE.'
    608   WHERE id IN ('.$params['list'].')
     613  WHERE id IN ('.implode(',', $ids).')
    609614;';
    610615  $pictures = hash_from_query($query, 'id');
    611    
     616 
     617  // sort pictures
     618  function rank_sort($a, $b)
     619  {
     620    global $ids;
     621    return array_search($a, $ids) > array_search($b, $ids);
     622  }
     623  uksort($pictures, 'rank_sort');
     624 
    612625  foreach ($pictures as $row)
    613626  {
Note: See TracChangeset for help on using the changeset viewer.