Changeset 11962 for trunk/admin


Ignore:
Timestamp:
Aug 17, 2011, 9:56:07 PM (13 years ago)
Author:
plg
Message:

feature 2406 added: if the user wants a new album in the upload form, the album
is created before the start of the upload. The ergonomy is now simpler, the
page is smaller and cleaner.

bug 2373 fixed: now that album is created before upload, uploadify.php gets the
category_id and the level: as soon as it is uploaded (function add_uploaded_file)
the photo gets its final privacy level and is directly associated to the album.
This way, we can have an error on a photo without making orphan all photos of
the same upload group.

feature 2405 added: as soon as a photo is uploaded, its thumbnail is displayed
in the "Uploaded Photos" fieldset, without waiting for other photos to be
uploaded. The latest photos comes first.

I have slighlty changed the integration of colorbox in core. Now we have 2
styles available and by default, we use style2 (overlay in black, title and
control icons outside the popup). It is also used for zooming on bulk manager
in unit mode.

display change: on each uploading photos, instead of showing the transfer
speed, we display the transfer progression in %

bug fixed: the color of the "Start Upload" button was not correct because the
button was not a submit button but a simple type=button.

language: "Upload" button becomes "Start Upload" button.

Location:
trunk/admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/photos_add_direct_process.inc.php

    r8734 r11962  
    4444  }
    4545 
    46   $category_id = null;
    47   if (!isset($_POST['category_type']))
    48   {
    49     // nothing to do, we certainly have the post_max_size issue
    50   }
    51   elseif ('existing' == $_POST['category_type'])
    52   {
    53     $category_id = $_POST['category'];
    54   }
    55   elseif ('new' == $_POST['category_type'])
    56   {
    57     $output_create = create_virtual_category(
    58       $_POST['category_name'],
    59       (0 == $_POST['category_parent'] ? null : $_POST['category_parent'])
    60       );
    61    
    62     $category_id = $output_create['id'];
    63 
    64     if (isset($output_create['error']))
    65     {
    66       array_push($page['errors'], $output_create['error']);
    67     }
    68     else
    69     {
    70       $category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=cat_modify&cat_id=');
    71       // information
    72       array_push(
    73         $page['infos'],
    74         sprintf(
    75           l10n('Album "%s" has been added'),
    76           '<em>'.$category_name.'</em>'
    77           )
    78         );
    79       // TODO: add the onclick="window.open(this.href); return false;"
    80       // attribute with jQuery on upload.tpl side for href containing
    81       // "cat_modify"
    82     }
    83   }
     46  $category_id = $_POST['category'];
    8447
    8548  $image_ids = array();
     
    207170    {
    208171      $image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ];
    209 
    210       associate_images_to_categories(
    211         $image_ids,
    212         array($category_id)
    213         );
    214 
    215       $query = '
    216 UPDATE '.IMAGES_TABLE.'
    217   SET level = '.$_POST['level'].'
    218   WHERE id IN ('.implode(', ', $image_ids).')
    219 ;';
    220       pwg_query($query);
    221    
    222       invalidate_user_cache();
    223172    }
    224173  }
     
    292241    }
    293242
    294     if ('existing' == $_POST['category_type'])
    295     {
    296       $query = '
     243    $query = '
    297244SELECT
    298245    COUNT(*)
     
    300247  WHERE category_id = '.$category_id.'
    301248;';
    302       list($count) = pwg_db_fetch_row(pwg_query($query));
    303       $category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=cat_modify&amp;cat_id=');
    304      
    305       // information
    306       array_push(
    307         $page['infos'],
    308         sprintf(
    309           l10n('Album "%s" now contains %d photos'),
    310           '<em>'.$category_name.'</em>',
    311           $count
    312           )
    313         );
    314     }
    315 
     249    list($count) = pwg_db_fetch_row(pwg_query($query));
     250    $category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=cat_modify&amp;cat_id=');
     251   
     252    // information
     253    array_push(
     254      $page['infos'],
     255      sprintf(
     256        l10n('Album "%s" now contains %d photos'),
     257        '<em>'.$category_name.'</em>',
     258        $count
     259        )
     260      );
     261   
    316262    $page['batch_link'] = PHOTOS_ADD_BASE_URL.'&batch='.implode(',', $image_ids);
    317263  }
  • trunk/admin/include/uploadify/uploadify.php

    r6625 r11962  
    2020$tmp = ob_get_contents();
    2121ob_end_clean();
    22 // error_log($tmp, 3, "/tmp/php-".date('YmdHis').'-'.sprintf('%020u', rand()).".log");
     22error_log($tmp, 3, "/tmp/php-".date('YmdHis').'-'.sprintf('%020u', rand()).".log");
    2323
    2424if ($_FILES['Filedata']['error'] !== UPLOAD_ERR_OK)
     
    4444  $_FILES['Filedata']['tmp_name'],
    4545  $_FILES['Filedata']['name'],
    46   null,
    47   8
     46  array($_POST['category_id']),
     47  $_POST['level']
    4848  );
    4949
     
    6363  );
    6464
     65$query = '
     66SELECT
     67    id,
     68    path,
     69    tn_ext
     70  FROM '.IMAGES_TABLE.'
     71  WHERE id = '.$image_id.'
     72;';
     73$image_infos = pwg_db_fetch_assoc(pwg_query($query));
     74
     75$thumbnail_url = preg_replace('#^'.PHPWG_ROOT_PATH.'#', './', get_thumbnail_url($image_infos));
     76
     77$return = array(
     78  'image_id' => $image_id,
     79  'category_id' => $_POST['category_id'],
     80  'thumbnail_url' => $thumbnail_url,
     81  );
     82
    6583$output = ob_get_contents();
    6684ob_end_clean();
     
    6886{
    6987  add_upload_error($_POST['upload_id'], $output);
     88  $return['error_message'] = $output;
    7089}
    7190
    72 echo "1";
     91echo json_encode($return);
    7392?>
  • trunk/admin/themes/clear/theme.css

    r11393 r11962  
    2121INPUT, select, textarea { color:#666; background-color: #ccc; }
    2222input[type="radio"], input[type="checkbox"] { background-color: transparent; }
    23 INPUT[type="submit"], INPUT[type="reset"]  { color:#666; border: 1px solid #777; background-color: #bbb; padding: 1px 15px; }
     23INPUT[type="submit"], INPUT[type="button"], INPUT[type="reset"]  { color:#666; border: 1px solid #777; background-color: #bbb; padding: 1px 15px; }
    2424legend, h3 { color: #777; }
    2525h2 { color: #777; }
     
    5151
    5252input[type="button"]:hover, input[type="submit"]:hover, input[type="reset"]:hover {
     53  cursor:pointer;
    5354  color:#666;
    5455  border-color: #999;
  • trunk/admin/themes/default/template/include/colorbox.inc.tpl

    r11467 r11962  
    11{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
    2 {combine_css path="themes/default/js/plugins/jquery.colorbox.css"}
     2{combine_css path="themes/default/js/plugins/colorbox/style2/colorbox.css"}
  • trunk/admin/themes/default/template/photos_add_direct.tpl

    r9586 r11962  
    77{/if}
    88
     9{include file='include/colorbox.inc.tpl'}
     10
    911{footer_script}{literal}
    1012jQuery(document).ready(function(){
     
    1416    jQuery("#formErrors li").hide();
    1517
    16     if (jQuery("input[name=category_type]:checked").val() == "new" && jQuery("input[name=category_name]").val() == "") {
    17       jQuery("#formErrors #emptyCategoryName").show();
    18       nbErrors++;
    19     }
    20 
    2118    var nbFiles = 0;
    2219    if (jQuery("#uploadBoxes").size() == 1) {
     
    6663  }
    6764
    68   if (jQuery("select[name=category] option").length == 0) {
    69     jQuery('input[name=category_type][value=existing]').attr('disabled', true);
    70     jQuery('input[name=category_type]').attr('checked', false);
    71     jQuery('input[name=category_type][value=new]').attr('checked', true);
     65  function fillCategoryListbox(selectId, selectedValue) {
     66    jQuery.getJSON(
     67      "ws.php?format=json&method=pwg.categories.getList",
     68      {
     69        recursive: true,
     70        fullname: true,
     71        format: "json",
     72      },
     73      function(data) {
     74        jQuery.each(
     75          data.result.categories,
     76          function(i,category) {
     77            var selected = "";
     78            if (category.id == selectedValue) {
     79              selected = "selected";
     80            }
     81           
     82            jQuery("<option/>")
     83              .attr("value", category.id)
     84              .attr("selected", selected)
     85              .text(category.name)
     86              .appendTo("#"+selectId)
     87              ;
     88          }
     89        );
     90      }
     91    );
    7292  }
    7393
    74   jQuery("input[name=category_type]").click(function () {
    75     jQuery("[id^=category_type_]").hide();
    76     jQuery("#category_type_"+jQuery(this).attr("value")).show();
     94/*
     95  jQuery("#albumSelect").find("option").remove();
     96  fillCategoryListbox("albumSelect");
     97  fillCategoryListbox("category_parent");
     98*/
     99 
     100  jQuery(".addAlbumOpen").colorbox({inline:true, href:"#addAlbumForm"});
     101
     102  jQuery("#addAlbumForm form").submit(function(){
     103      jQuery("#categoryNameError").text("");
     104
     105      jQuery.ajax({
     106        url: "ws.php?format=json&method=pwg.categories.add",
     107        data: {
     108          parent: jQuery("select[name=category_parent] option:selected").val(),
     109          name: jQuery("input[name=category_name]").val(),
     110        },
     111        beforeSend: function() {
     112          jQuery("#albumCreationLoading").show();
     113        },
     114        success:function(html) {
     115          jQuery("#albumCreationLoading").hide();
     116
     117          var newAlbum = jQuery.parseJSON(html).result.id;
     118          jQuery(".addAlbumOpen").colorbox.close();
     119
     120          jQuery("#albumSelect").find("option").remove();
     121          fillCategoryListbox("albumSelect", newAlbum);
     122
     123          /* we refresh the album creation form, in case the user wants to create another album */
     124          jQuery("#category_parent").find("option").remove();
     125          fillCategoryListbox("category_parent", newAlbum);
     126
     127          jQuery("#addAlbumForm form input[name=category_name]").val('');
     128
     129          return true;
     130        },
     131        error:function(XMLHttpRequest, textStatus, errorThrows) {
     132            jQuery("#albumCreationLoading").hide();
     133            jQuery("#categoryNameError").text(errorThrows).css("color", "red");
     134        }
     135      });
     136
     137      return false;
    77138  });
    78139
     
    121182    'queueID'        : 'fileQueue',
    122183    'auto'           : false,
    123     'displayData'    : 'speed',
    124184    'buttonText'     : buttonText,
    125185    'multi'          : true,
     
    197257      );
    198258    },
    199     onComplete: function (a, b ,c, d, e) {
     259    onComplete: function (a, b ,c, response, e) {
    200260      var size = Math.round(c.size/1024);
     261
     262      var response = jQuery.parseJSON(response);
     263
     264      jQuery("#uploadedPhotos").parent("fieldset").show();
     265      jQuery("#uploadedPhotos").prepend('<img src="'+response.thumbnail_url+'" class="thumbnail"> ');
     266
    201267      jQuery.jGrowl(
    202268        '<p></p>'+c.name+' - '+size+'KB',
     
    215281      return false;
    216282    }
     283
     284    jQuery("#uploadify").uploadifySettings(
     285      'scriptData',
     286      {
     287        'category_id' : jQuery("select[name=category] option:selected").val(),
     288        'level' : jQuery("select[name=level] option:selected").val(),
     289      }
     290    );
    217291
    218292    jQuery("#uploadify").uploadifyUpload();
     
    269343<div id="formErrors" class="errors" style="display:none">
    270344  <ul>
    271     <li id="emptyCategoryName">{'The name of an album must not be empty'|@translate}</li>
    272345    <li id="noPhoto">{'Select at least one photo'|@translate}</li>
    273346  </ul>
     
    275348</div>
    276349
     350<div style="display:none">
     351  <div id="addAlbumForm" style="text-align:left;padding:1em;">
     352    <form>
     353      {'Parent album'|@translate}<br>
     354      <select id ="category_parent" name="category_parent">
     355        <option value="0">------------</option>
     356        {html_options options=$category_parent_options selected=$category_parent_options_selected}
     357      </select>
     358
     359      <br><br>{'Album name'|@translate}<br><input name="category_name" type="text"> <span id="categoryNameError"></span>
     360      <br><br><br><input type="submit" value="{'Create'|@translate}"> <span id="albumCreationLoading" style="display:none"><img src="themes/default/images/ajax-loader-small.gif"></span>
     361    </form>
     362  </div>
     363</div>
     364
    277365<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties">
     366{if $upload_mode eq 'multiple'}
     367    <input name="upload_id" value="{$upload_id}" type="hidden">
     368{/if}
     369
    278370    <fieldset>
    279371      <legend>{'Drop into album'|@translate}</legend>
    280       {if $upload_mode eq 'multiple'}
    281       <input name="upload_id" value="{$upload_id}" type="hidden">
    282       {/if}
    283 
    284       <label><input type="radio" name="category_type" value="existing"> {'existing album'|@translate}</label>
    285       <label><input type="radio" name="category_type" value="new" checked="checked"> {'create a new album'|@translate}</label>
    286 
    287       <div id="category_type_existing" style="display:none" class="category_selection">
    288         <select class="categoryDropDown" name="category">
    289           {html_options options=$category_options selected=$category_options_selected}
    290         </select>
    291       </div>
    292 
    293       <div id="category_type_new" class="category_selection">
    294         <table>
    295           <tr>
    296             <td>{'Parent album'|@translate}</td>
    297             <td>
    298               <select class="categoryDropDown" name="category_parent">
    299                 <option value="0">------------</option>
    300                 {html_options options=$category_parent_options selected=$category_parent_options_selected}
    301               </select>
    302             </td>
    303           </tr>
    304           <tr>
    305             <td>{'Album name'|@translate}</td>
    306             <td>
    307               <input type="text" name="category_name" value="{$F_CATEGORY_NAME}" style="width:400px">
    308             </td>
    309           </tr>
    310         </table>
    311       </div>
     372
     373      <select id="albumSelect" name="category">
     374        {html_options options=$category_options selected=$category_options_selected}
     375      </select>
     376      <br>{'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
     377     
    312378    </fieldset>
    313379
     
    349415    </fieldset>
    350416    <p>
    351       <input class="submit" type="button" value="{'Upload'|@translate}">
     417      <input class="submit" type="button" value="{'Start Upload'|@translate}">
    352418      <input type="submit" name="submit_upload" style="display:none">
    353419    </p>
    354420{/if}
    355421</form>
     422
     423<fieldset style="display:none">
     424  <legend>{'Uploaded Photos'|@translate}</legend>
     425  <div id="uploadedPhotos"></div>
     426</fieldset>
     427
    356428{/if} {* empty($thumbnails) *}
    357429{/if} {* $setup_errors *}
  • trunk/admin/themes/default/theme.css

    r11588 r11962  
    606606}
    607607
     608#photosAddContent {
     609  text-align:left;
     610}
     611
    608612#photosAddContent FIELDSET {
    609613  width:650px;
Note: See TracChangeset for help on using the changeset viewer.