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.

Location:
extensions/upload_form
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/upload_form/language/en_UK/plugin.lang.php

    r4789 r4796  
    2727$lang['Create the "%s" directory at the root of your Piwigo installation'] = 'Create the "%s" directory at the root of your Piwigo installation';
    2828$lang['Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'] = 'Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation';
     29$lang['existing category'] = 'existing category';
     30$lang['create a new category'] = 'create a new category';
     31$lang['Category name'] = 'Category name';
     32$lang['Category "%s" has been added'] = 'Category "%s" has been added';
    2933?>
  • extensions/upload_form/language/fr_FR/plugin.lang.php

    r4789 r4796  
    2727$lang['Create the "%s" directory at the root of your Piwigo installation'] = 'Créez le répertoire "%s" à la racine de votre installation Piwigo';
    2828$lang['Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'] = 'Donnez les droits en écriture (chmod 777) sur le répertoire "%s" à la racine de votre installation Piwigo';
     29$lang['existing category'] = 'catégorie existante';
     30$lang['create a new category'] = 'créer une nouvelle catégorie';
     31$lang['Category name'] = 'Nom de la catégorie';
     32$lang['Category "%s" has been added'] = 'La catégorie "%s" a été ajoutée';
    2933?>
  • 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  }
  • extensions/upload_form/upload.tpl

    r4789 r4796  
     1{known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"}
     2
     3{literal}
     4<script>
     5$(document).ready(function(){
     6
     7  $("input[name=category_type]").click(function () {
     8    $("[id^=category_type_]").hide();
     9    $("#category_type_"+$(this).attr("value")).show();
     10  });
     11
     12});
     13</script>
     14{/literal}
     15
    116<script type="text/javascript" src="{$plugin_path}/include/upload.js"></script>
    217
     
    3247        <td>{'Drop into category'|@translate}</td>
    3348        <td>
    34           <select class="categoryDropDown" name="category">
    35             <option value="0">------------</option>
    36             {html_options options=$category_options}
    37           </select>
     49          <label><input type="radio" name="category_type" value="existing" checked="checked"> {'existing category'|@translate}</label>
     50          <label><input type="radio" name="category_type" value="new"> {'create a new category'|@translate}</label>
     51
     52          <div id="category_type_existing">
     53            <select class="categoryDropDown" name="category">
     54              {html_options options=$category_options}
     55            </select>
     56          </div>
     57
     58          <div id="category_type_new" style="display:none">
     59            <table>
     60              <tr>
     61                <td>{'Parent category'|@translate}</td>
     62                <td>
     63                  <select class="categoryDropDown" name="category_parent">
     64                    <option value="0">------------</option>
     65                    {html_options options=$category_options}
     66                  </select>
     67                </td>
     68              </tr>
     69              <tr>
     70                <td>{'Category name'|@translate}</td>
     71                <td>
     72                  <input type="text" name="category_name" value="{$F_CATEGORY_NAME}"
     73                </td>
     74              </tr>
     75            </table>
     76          </div>
     77
    3878        </td>
    3979      </tr>
Note: See TracChangeset for help on using the changeset viewer.