Ignore:
Timestamp:
Apr 5, 2006, 12:29:35 AM (18 years ago)
Author:
plg
Message:

feature deleted: code for categories link was too complicated for such a
simple fature. Replaced by static association. Links are not persistent
anymore.

modification removed: #image_category.is_storage replaced by
#images.storage_category_id as in branche 1.5..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r1082 r1121  
    115115   
    116116    // Link the new category to the current category
    117     $query = '
    118 INSERT
    119   INTO '.CATEGORIES_LINK_TABLE.'
    120   (source, destination)
    121   VALUES
    122   ('.$_GET['cat_id'].', '.$output_create['id'].')
    123 ;';
    124     pwg_query($query);
    125 
    126     check_links(array($output_create['id']));
    127     update_category(array($output_create['id']));
    128   }
    129 }
    130 else if (isset($_POST['destination_trueify'])
    131          and isset($_POST['destination_false'])
    132          and count($_POST['destination_false']))
    133 {
    134   $datas = array();
    135  
    136   foreach ($_POST['destination_false'] as $category_id)
    137   {
     117    associate_categories_to_categories(
     118      array($_GET['cat_id']),
     119      array($output_create['id'])
     120      );
     121
     122    // information
    138123    array_push(
    139       $datas,
    140       array(
    141         'source'      => $_GET['cat_id'],
    142         'destination' => $category_id,
     124      $page['infos'],
     125      sprintf(
     126        l10n('Category elements associated to the following categories: %s'),
     127        '<ul><li>'
     128        .get_cat_display_name_from_id($output_create['id'])
     129        .'</li></ul>'
    143130        )
    144131      );
    145132  }
    146  
    147   mass_inserts(
    148     CATEGORIES_LINK_TABLE,
    149     array('source', 'destination'),
    150     $datas
    151     );
    152 
    153   check_links($_POST['destination_false']);
    154   update_category(
    155     $_POST['destination_false'],
    156     true                          // recursive update
    157     );
    158 }
    159 else if (isset($_POST['destination_falsify'])
    160          and isset($_POST['destination_true'])
    161          and count($_POST['destination_true']))
    162 {
    163   foreach ($_POST['destination_true'] as $destination)
    164   {
    165     delete_sources($destination, array($_GET['cat_id']));
    166   }
    167 
    168   update_category(
    169     $_POST['destination_true'],
    170     true                          // recursive update
    171     );
    172 }
    173 else if (isset($_POST['source_trueify'])
    174          and isset($_POST['source_false'])
    175          and count($_POST['source_false']))
    176 {
    177   $datas = array();
    178  
    179   foreach ($_POST['source_false'] as $category_id)
     133}
     134else if (isset($_POST['submitDestinations'])
     135         and isset($_POST['destinations'])
     136         and count($_POST['destinations']) > 0)
     137{
     138  associate_categories_to_categories(
     139    array($_GET['cat_id']),
     140    $_POST['destinations']
     141    );
     142
     143  $category_names = array();
     144  foreach ($_POST['destinations'] as $category_id)
    180145  {
    181146    array_push(
    182       $datas,
    183       array(
    184         'source'      => $category_id,
    185         'destination' => $_GET['cat_id'],
    186         )
    187       );
    188   }
    189  
    190   mass_inserts(
    191     CATEGORIES_LINK_TABLE,
    192     array('source', 'destination'),
    193     $datas
    194     );
    195 
    196   check_links(array($_GET['cat_id']));
    197   update_category(
    198     array($_GET['cat_id']),
    199     true                          // recursive update
    200     );
    201 }
    202 else if (isset($_POST['source_falsify'])
    203          and isset($_POST['source_true'])
    204          and count($_POST['source_true']))
    205 {
    206   delete_sources($_GET['cat_id'], $_POST['source_true']);
    207  
    208   update_category(
    209     array($_GET['cat_id']),
    210     true                          // recursive update
    211     );
    212 }
    213 
     147      $category_names,
     148      get_cat_display_name_from_id($category_id)
     149      );
     150  }
     151
     152  array_push(
     153    $page['infos'],
     154    sprintf(
     155      l10n('Category elements associated to the following categories: %s'),
     156      '<ul><li>'.implode('</li><li>', $category_names).'</li></ul>'
     157      )
     158    );
     159}
    214160
    215161$query = '
     
    382328}
    383329
    384 if (!$category['is_virtual']) //!empty($category['dir']))
     330if (!$category['is_virtual'])
    385331{
    386332  $template->assign_block_vars(
     
    470416// destination categories
    471417$query = '
    472 SELECT DISTINCT id, name, uppercats, global_rank
     418SELECT id,name,uppercats,global_rank
    473419  FROM '.CATEGORIES_TABLE.'
    474     INNER JOIN '.CATEGORIES_LINK_TABLE.' ON destination = id
    475   WHERE source = '.$_GET['cat_id'].'
    476 ;';
    477 display_select_cat_wrapper($query, array(), 'destination_option_true');
    478 
    479 // non destination categories
    480 $destinations = array_merge(
    481   array($_GET['cat_id']),
    482   array_from_query($query, 'id')
     420  WHERE id != '.$category['id'].'
     421;';
     422
     423display_select_cat_wrapper(
     424  $query,
     425  array(),
     426  'category_option_destination'
    483427  );
    484428
    485 $query = '
    486 SELECT DISTINCT id, name, uppercats, global_rank
    487   FROM '.CATEGORIES_TABLE.'
    488   WHERE id NOT IN ('.implode(',', $destinations).')
    489 ;';
    490 display_select_cat_wrapper($query, array(), 'destination_option_false');
    491 
    492 // source categories
    493 $query = '
    494 SELECT DISTINCT id, name, uppercats, global_rank
    495   FROM '.CATEGORIES_TABLE.'
    496     INNER JOIN '.CATEGORIES_LINK_TABLE.' ON source = id
    497   WHERE destination = '.$_GET['cat_id'].'
    498 ;';
    499 display_select_cat_wrapper($query, array(), 'source_option_true');
    500 
    501 // non source categories
    502 $sources = array_merge(
    503   array($_GET['cat_id']),
    504   array_from_query($query, 'id')
    505   );
    506 
    507 $query = '
    508 SELECT DISTINCT id, name, uppercats, global_rank
    509   FROM '.CATEGORIES_TABLE.'
    510   WHERE id NOT IN ('.implode(',', $sources).')
    511 ;';
    512 display_select_cat_wrapper($query, array(), 'source_option_false');
    513429
    514430//----------------------------------------------------------- sending html code
Note: See TracChangeset for help on using the changeset viewer.