Changeset 605


Ignore:
Timestamp:
11/16/04 00:13:24 (15 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)

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/category.php

    r602 r605  
    198198  'special_cat', 
    199199  array( 
    200     'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=random'), 
     200    'URL' => add_session_id(PHPWG_ROOT_PATH.'random.php'), 
    201201    'TITLE' => $lang['random_cat_hint'], 
    202202    'NAME' => $lang['random_cat'] 
     
    275275                           ,'recent_pics' 
    276276                           ,'best_rated' 
    277                            ,'random' 
     277                           ,'list' 
    278278                       )))) 
    279279{ 
  • trunk/include/category_default.inc.php

    r602 r605  
    106106    $url_link.= '&search='.$_GET['search']; 
    107107  } 
     108  else if ($page['cat'] == 'list') 
     109  { 
     110    $url_link.= '&list='.$_GET['list']; 
     111  } 
    108112     
    109113  $template->assign_block_vars( 
  • 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 
  • trunk/picture.php

    r602 r605  
    209209{ 
    210210  $url_up.= "&search=".$_GET['search']; 
     211} 
     212if ( $page['cat'] == 'list' ) 
     213{ 
     214  $url_up.= "&list=".$_GET['list']; 
    211215} 
    212216 
Note: See TracChangeset for help on using the changeset viewer.