Ignore:
Timestamp:
Jan 29, 2010, 11:14:41 PM (14 years ago)
Author:
plg
Message:

feature 1406 added: Upload Form is able to create a category "on the fly".

Note: needs a better display when switching from "existing" to "new" category.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/upload_form/upload.php

    r4789 r4796  
    3737
    3838// +-----------------------------------------------------------------------+
    39 // |                               functions                               |
     39// |                             process form                              |
    4040// +-----------------------------------------------------------------------+
    4141
    4242if (isset($_POST['submit_upload']))
    4343{
    44   // echo '<pre>'; print_r($_FILES); echo '</pre>'; exit();
     44  $category_id = null;
     45  if ('existing' == $_POST['category_type'])
     46  {
     47    $category_id = $_POST['category'];
     48  }
     49  elseif ('new' == $_POST['category_type'])
     50  {
     51    $output_create = create_virtual_category(
     52      $_POST['category_name'],
     53      (0 == $_POST['category_parent'] ? null : $_POST['category_parent'])
     54      );
     55
     56    if (isset($output_create['error']))
     57    {
     58      array_push($page['errors'], $output_create['error']);
     59    }
     60    else
     61    {
     62      // information
     63      array_push(
     64        $page['infos'],
     65        sprintf(
     66          l10n('Category "%s" has been added'),
     67          '<em>'.get_cat_display_name_from_id($output_create['id']).'</em>'
     68          )
     69        );
     70    }
     71
     72    $category_id = $output_create['id'];
     73  }
    4574 
    4675  $starttime = get_moment();
     
    5281      $source_filepath = $_FILES['image_upload']['tmp_name'][$idx];
    5382      $original_filename = $_FILES['image_upload']['name'][$idx];
    54       add_uploaded_file($source_filepath, $original_filename, array($_POST['category']));
     83      add_uploaded_file($source_filepath, $original_filename, array($category_id));
    5584    }
    5685  }
Note: See TracChangeset for help on using the changeset viewer.