Ignore:
Timestamp:
Feb 2, 2004, 1:55:18 AM (20 years ago)
Author:
gweltas
Message:

Merge of the 1.3.1 release
Creation of an unique include file (common.php)
Creation of an unique define file (include/constants.php)
Modification of the installation procedure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_list.php

    r226 r345  
    1919 ***************************************************************************/
    2020include_once( './admin/include/isadmin.inc.php' );
     21
    2122//----------------------------------------------------- template initialization
    2223$sub = $vtp->Open( './template/'.$user['template'].'/admin/cat_list.vtp' );
    2324$tpl = array( 'cat_edit','cat_up','cat_down','cat_image_info',
    2425              'cat_permission','cat_update','cat_add','cat_parent','submit',
    25               'cat_virtual','delete','cat_first','cat_last' );
     26              'cat_virtual','delete','cat_first','cat_last','errors_title' );
    2627templatize_array( $tpl, 'lang', $sub );
    2728$vtp->setGlobalVar( $sub, 'user_template', $user['template'] );
     
    3031if ( isset( $_POST['submit'] ) )
    3132{
    32   if ( !preg_match( '/^\s*$/', $_POST['virtual_name'] ) )
     33  // is the given category name only containing blank spaces ?
     34  if ( preg_match( '/^\s*$/', $_POST['virtual_name'] ) )
     35    array_push( $errors, $lang['cat_error_name'] );
     36  // does the uppercat id exists in the database ?
     37  if ( $_POST['associate'] == '' )
     38  {
     39    $_POST['associate'] = -1;
     40  }
     41  else if ( !is_numeric( $_POST['associate'] ) )
     42  {
     43    array_push( $errors, $lang['cat_unknown_id'] );
     44  }
     45  else
     46  {
     47    $query = 'SELECT id';
     48    $query.= ' FROM '.PREFIX_TABLE.'categories';
     49    $query.= ' WHERE id = '.$_POST['associate'];
     50    $query.= ';';
     51    if ( mysql_num_rows( mysql_query( $query ) ) == 0 )
     52      array_push( $errors, $lang['cat_unknown_id'] );
     53  }
     54 
     55  if ( count( $errors ) == 0 )
    3356  {
    3457    // we have then to add the virtual category
     
    4265    $query.= ';';
    4366    mysql_query( $query );
    44   }
    45   else
    46   {
    47     array_push( $errors, $lang['cat_error_name'] );
     67    synchronize_all_users();
    4868  }
    4969}
     
    172192{
    173193  delete_category( $_GET['delete'] );
     194  synchronize_all_users();
    174195}
    175196//------------------------------------------------------------------ reordering
     
    234255  $result = mysql_query( $query );
    235256  $row    = mysql_fetch_array( $result );
     257  if ( !isset( $row['min'] ) ) $row['min'] = 0;
     258  if ( !isset( $row['max'] ) ) $row['max'] = 0;
    236259  $min_rank = $row['min'];
    237260  $max_rank = $row['max'];
     
    259282  {
    260283    $subcat_visible = true;
     284    if ( !isset( $row['dir'] ) ) $row['dir'] = '';
    261285
    262286    $vtp->addSession( $sub, 'cat' );
     287    // is the category expanded or not ?
     288    if ( isset($page['expand']) && $page['expand'] == 'all' )
     289    {
     290      $vtp->addSession( $sub, 'bullet_wo_link' );
     291      $vtp->closeSession( $sub, 'bullet_wo_link' );
     292    }
     293    else if ( isset($page['tab_expand']) && in_array( $row['id'], $page['tab_expand'] ) )
     294    {
     295      $vtp->addSession( $sub, 'bullet_expanded' );
     296      $tab_expand = array_diff( $page['tab_expand'], array( $row['id'] ) );
     297      $expand = implode( ',', $tab_expand );
     298      $url = './admin.php?page=cat_list&expand='.$expand;
     299      $vtp->setVar( $sub, 'bullet_expanded.link', add_session_id( $url ) );
     300      $vtp->closeSession( $sub, 'bullet_expanded' );
     301    }
     302    else
     303    {
     304      $vtp->addSession( $sub, 'bullet_collapsed' );
     305      $tab_expand = array_merge( $page['tab_expand'], array( $row['id'] ) );
     306      $expand = implode( ',', $tab_expand );
     307      $url = './admin.php?page=cat_list&expand='.$expand;
     308      $vtp->setVar( $sub, 'bullet_collapsed.link', add_session_id( $url ) );
     309      $vtp->closeSession( $sub, 'bullet_collapsed' );
     310    }
     311   
    263312    $vtp->setVar( $sub, 'cat.td', $td );
    264313    $vtp->setVar( $sub, 'cat.class', $class );
    265314    $vtp->setVar( $sub, 'cat.indent', $indent );
    266315    $vtp->setVar( $sub, 'cat.name', $row['name'] );
    267     $vtp->setVar( $sub, 'cat.id', $row['id'] );
     316
    268317    if ( $row['dir'] != '' )
    269318    {
     
    281330      // category can be deleted
    282331      $vtp->addSession( $sub, 'delete' );
    283       $url = './admin.php?page=cat_list&delete='.$row['id'];
     332      $url = './admin.php?page=cat_list&expand='.$page['expand'];
     333      $url.= '&delete='.$row['id'];
    284334      $vtp->setVar( $sub, 'delete.delete_url', add_session_id( $url ) );
    285335      $vtp->closeSession( $sub, 'delete' );
     
    300350    {
    301351      $vtp->addSession( $sub, 'up' );
    302       $vtp->setVar( $sub, 'up.id', $row['id'] );
    303       $url = add_session_id( './admin.php?page=cat_list&up='.$row['id'] );
    304       $vtp->setVar( $sub, 'up.up_url', $url );
     352      $url = './admin.php?page=cat_list&expand='.$page['expand'];
     353      $url.= '&up='.$row['id'];
     354      $vtp->setVar( $sub, 'up.up_url', add_session_id( $url ) );
    305355      $vtp->closeSession( $sub, 'up' );
    306356    }
     
    308358    {
    309359      $vtp->addSession( $sub, 'no_up' );
    310       $vtp->setVar( $sub, 'no_up.id', $row['id'] );
    311       $url = add_session_id( './admin.php?page=cat_list&last='.$row['id']);
    312       $vtp->setVar( $sub, 'no_up.last_url', $url );
     360      $url = './admin.php?page=cat_list&expand='.$page['expand'];
     361      $url.= '&last='.$row['id'];
     362      $vtp->setVar( $sub, 'no_up.last_url', add_session_id( $url ) );
    313363      $vtp->closeSession( $sub, 'no_up' );
    314364    }
     
    316366    {
    317367      $vtp->addSession( $sub, 'down' );
    318       $vtp->setVar( $sub, 'down.id', $row['id'] );
    319       $url = add_session_id( './admin.php?page=cat_list&down='.$row['id']);
    320       $vtp->setVar( $sub, 'down.down_url', $url );
     368      $url = './admin.php?page=cat_list&expand='.$page['expand'];
     369      $url.= '&down='.$row['id'];
     370      $vtp->setVar( $sub, 'down.down_url', add_session_id( $url ) );
    321371      $vtp->closeSession( $sub, 'down' );
    322372    }
     
    324374    {
    325375      $vtp->addSession( $sub, 'no_down' );
    326       $vtp->setVar( $sub, 'no_down.id', $row['id'] );
    327       $url = add_session_id('./admin.php?page=cat_list&first='.$row['id']);
    328       $vtp->setVar( $sub, 'no_down.first_url', $url );
     376      $url = './admin.php?page=cat_list&expand='.$page['expand'];
     377      $url.= '&first='.$row['id'];
     378      $vtp->setVar( $sub, 'no_down.first_url', add_session_id( $url ) );
    329379      $vtp->closeSession( $sub, 'no_down' );
    330380    }
     
    332382    {
    333383      $vtp->addSession( $sub, 'image_info' );
    334       $url = add_session_id( './admin.php?page=infos_images&cat_id='
    335                              .$row['id'] );
    336       $vtp->setVar( $sub, 'image_info.image_info_url', $url );
     384      $url = './admin.php?page=infos_images&cat_id='.$row['id'];
     385      $vtp->setVar( $sub, 'image_info.image_info_url', add_session_id($url) );
    337386      $vtp->closeSession( $sub, 'image_info' );
    338387    }
     
    372421    $vtp->closeSession( $sub, 'cat' );
    373422
    374     display_cat_manager( $row['id'], $indent.str_repeat( '&nbsp', 4 ),
    375                          $subcat_visible, $level + 1 );
     423    if ( in_array( $row['id'], $page['tab_expand'] )
     424         or $page['expand'] == 'all')
     425      display_cat_manager( $row['id'], $indent.str_repeat( '&nbsp', 4 ),
     426                           $subcat_visible, $level + 1 );
    376427  }
    377428}
    378429display_cat_manager( 'NULL', str_repeat( '&nbsp', 4 ), true, 0 );
    379430// add a virtual category ?
    380 $vtp->addSession( $sub, 'associate_cat' );
    381 $vtp->setVar( $sub, 'associate_cat.value', '-1' );
    382 $vtp->setVar( $sub, 'associate_cat.content', '' );
    383 $vtp->closeSession( $sub, 'associate_cat' );
    384 $page['plain_structure'] = get_plain_structure();
    385 $structure = create_structure( '', array() );
    386 display_categories( $structure, ' ' );
     431// We only show a List Of Values if the number of categories is less than
     432// $conf['max_LOV_categories']
     433$query = 'SELECT COUNT(id) AS nb_total_categories';
     434$query.= ' FROM '.PREFIX_TABLE.'categories';
     435$query.= ';';
     436$row = mysql_fetch_array( mysql_query( $query ) );
     437if ( $row['nb_total_categories'] < $conf['max_LOV_categories'] )
     438{
     439  $vtp->addSession( $sub, 'associate_LOV' );
     440  $vtp->addSession( $sub, 'associate_cat' );
     441  $vtp->setVar( $sub, 'associate_cat.value', '-1' );
     442  $vtp->setVar( $sub, 'associate_cat.content', '' );
     443  $vtp->closeSession( $sub, 'associate_cat' );
     444  $page['plain_structure'] = get_plain_structure( true );
     445  $structure = create_structure( '', array() );
     446  display_categories( $structure, '&nbsp;' );
     447  $vtp->closeSession( $sub, 'associate_LOV' );
     448}
     449// else, we only display a small text field, we suppose the administrator
     450// knows the id of its category
     451else
     452{
     453  $vtp->addSession( $sub, 'associate_text' );
     454  $vtp->closeSession( $sub, 'associate_text' );
     455}
    387456//----------------------------------------------------------- sending html code
    388457$vtp->Parse( $handle , 'sub', $sub );
Note: See TracChangeset for help on using the changeset viewer.