Ignore:
Timestamp:
Nov 16, 2004, 12:13:24 AM (19 years ago)
Author:
plg
Message:

category random replaced by a more generic category : list. You give a list
of element identifiers and it creates a page virtual temporary
category. random.php generates a randomized list of element id visible to
the user (according to permissions) and redirects to category.php.

Major problem : elements order is in id ascending order, I don't know how to
change order when having id1,id2,id3 and id2,id3,id1 (the display order is
the same)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_category.inc.php

    r603 r605  
    6767 *  - equals 'recent_cats'
    6868 *  - equals 'calendar'
    69  *  - equals 'random'
     69 *  - equals 'list'
    7070 *
    7171 * The function fills the global var $page['cat'] and returns nothing
     
    100100         or $cat == 'recent_pics'
    101101         or $cat == 'recent_cats'
    102          or $cat == 'calendar'
    103          or $cat == 'random' )
     102         or $cat == 'calendar' )
    104103    {
    105104      $page['cat'] = $cat;
     
    108107    {
    109108      $page['cat'] = $cat;
     109    }
     110    if ($cat == 'list'
     111        and isset($_GET['list'])
     112        and preg_match('/^\d+(,\d+)*$/', $_GET['list']))
     113    {
     114      $page['cat'] = 'list';
    110115    }
    111116  }
     
    435440//       - best rated pictures
    436441//       - recent pictures
    437 //       - random pictures
     442//       - defined list (used for random)
    438443// 3. determination of the title of the page
    439444// 4. creation of the navigation bar
     
    468473    else
    469474    {
    470       if ( $page['cat'] == 'search'
    471            or $page['cat'] == 'most_visited'
    472            or $page['cat'] == 'recent_pics'
    473            or $page['cat'] == 'recent_cats'
    474            or $page['cat'] == 'best_rated'
    475            or $page['cat'] == 'calendar' )
     475      if ($page['cat'] == 'search'
     476          or $page['cat'] == 'most_visited'
     477          or $page['cat'] == 'recent_pics'
     478          or $page['cat'] == 'recent_cats'
     479          or $page['cat'] == 'best_rated'
     480          or $page['cat'] == 'calendar'
     481          or $page['cat'] == 'list')
    476482      {
    477483        // we must not show pictures of a forbidden category
     
    789795        }
    790796      }
    791       else if ($page['cat'] == 'random')
     797      else if ($page['cat'] == 'list')
    792798      {
    793799        $page['title'] = $lang['random_cat'];
    794800         
     801        $page['where'] = 'WHERE 1=1';
    795802        if (isset($forbidden))
    796803        {
    797           $page['where'] = 'WHERE '.$forbidden;
    798         }
    799         else
    800         {
    801           $page['where'] = 'WHERE 1=1';
    802         }
    803 
    804         $conf['order_by'] = ' ORDER BY RAND()';
    805 
    806         $page['cat_nb_images'] = $conf['top_number'];
    807         $page['nb_image_page'] = $page['cat_nb_images'];
     804          $page['where'].= ' AND '.$forbidden;
     805        }
     806        $page['where'].= ' AND image_id IN ('.$_GET['list'].')';
     807        $page['cat_nb_images'] = count(explode(',', $_GET['list']));
    808808      }
    809809
Note: See TracChangeset for help on using the changeset viewer.