Changeset 331


Ignore:
Timestamp:
Jan 30, 2004, 11:47:18 PM (20 years ago)
Author:
z0rglub
Message:
  • Php warnings correction
  • many categories management : display a simple text field for uppercat id instead of a selection box
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/release-1_3/admin/cat_modify.php

    r322 r331  
    6565  {
    6666    $query.= ', id_uppercat = ';
    67     if ( $_POST['associate'] == -1 ) $query.= 'NULL';
    68     else                             $query.= $_POST['associate'];
     67    if ( $_POST['associate'] == -1 or $_POST['associate'] == '' )
     68      $query.= 'NULL';
     69    else
     70      $query.= $_POST['associate'];
    6971  }
    7072  $query.= ' WHERE id = '.$_GET['cat'];
     
    114116$query.= ';';
    115117$row = mysql_fetch_array( mysql_query( $query ) );
     118
     119if ( !isset( $row['dir'] ) ) $row['dir'] = '';
     120if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = '';
     121
    116122$result = get_cat_info( $row['id'] );
    117123// cat name
     
    119125$vtp->setVar( $sub, 'cat:name', $cat_name );
    120126// cat dir
    121 if ( isset( $row['dir'] ) and $row['dir'] != '' )
     127if ( $row['dir'] != '' )
    122128{
    123129  $vtp->addSession( $sub, 'storage' );
     
    207213{
    208214  $vtp->addSession( $sub, 'parent' );
    209   $vtp->addSession( $sub, 'associate_cat' );
    210   $vtp->setVar( $sub, 'associate_cat.value', '-1' );
    211   $vtp->setVar( $sub, 'associate_cat.content', '' );
    212   $vtp->closeSession( $sub, 'associate_cat' );
    213   $structure = create_structure( '', array() );
    214   display_categories( $structure, ' ', $row['id_uppercat'], $row['id'] );
     215  // We only show a List Of Values if the number of categories is less than
     216  // $conf['max_LOV_categories']
     217  $query = 'SELECT COUNT(id) AS nb_total_categories';
     218  $query.= ' FROM '.PREFIX_TABLE.'categories';
     219  $query.= ';';
     220  $countrow = mysql_fetch_array( mysql_query( $query ) );
     221  if ( $countrow['nb_total_categories'] < $conf['max_LOV_categories'] )
     222  {
     223    $vtp->addSession( $sub, 'associate_LOV' );
     224    $vtp->addSession( $sub, 'associate_cat' );
     225    $vtp->setVar( $sub, 'associate_cat.value', '-1' );
     226    $vtp->setVar( $sub, 'associate_cat.content', '' );
     227    $vtp->closeSession( $sub, 'associate_cat' );
     228    $page['plain_structure'] = get_plain_structure( true );
     229    $structure = create_structure( '', array() );
     230    display_categories( $structure, '&nbsp;', $row['id_uppercat'],$row['id'] );
     231    $vtp->closeSession( $sub, 'associate_LOV' );
     232  }
     233  // else, we only display a small text field, we suppose the administrator
     234  // knows the id of its category
     235  else
     236  {
     237    $vtp->addSession( $sub, 'associate_text' );
     238    $vtp->setVar( $sub, 'associate_text.value', $row['id_uppercat'] );
     239    $vtp->closeSession( $sub, 'associate_text' );
     240  }
    215241  $vtp->closeSession( $sub, 'parent' );
    216242}
Note: See TracChangeset for help on using the changeset viewer.