Ignore:
Timestamp:
01/31/10 01:54:55 (10 years ago)
Author:
plg
Message:

feature 1411 added: display many informations about upload result. With
thumbnails and links to administer uploaded photos.

Location:
extensions/upload_form
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/upload_form/include/functions_upload.inc.php

    r4805 r4807  
    122122   
    123123  invalidate_user_cache(); 
     124 
     125  return $image_id; 
    124126} 
    125127 
  • extensions/upload_form/language/en_UK/plugin.lang.php

    r4796 r4807  
    3131$lang['Category name'] = 'Category name'; 
    3232$lang['Category "%s" has been added'] = 'Category "%s" has been added'; 
     33$lang['Uploaded Photos'] = 'Uploaded Photos'; 
     34$lang['%d photos uploaded'] = '%d photos uploaded'; 
     35$lang['Privacy level set to "%s"'] = 'Privacy level set to "%s"'; 
     36$lang['Category "%s" now contains %d photos'] = 'Category "%s" now contains %d photos'; 
    3337?> 
  • extensions/upload_form/language/fr_FR/plugin.lang.php

    r4796 r4807  
    3131$lang['Category name'] = 'Nom de la catégorie'; 
    3232$lang['Category "%s" has been added'] = 'La catégorie "%s" a été ajoutée'; 
     33$lang['Uploaded Photos'] = 'Photos ajoutées '; 
     34$lang['%d photos uploaded'] = '%d photos ajoutées'; 
     35$lang['Privacy level set to "%s"'] = 'Niveau de confidentialité "%s"'; 
     36$lang['Category "%s" now contains %d photos'] = 'La catégorie "%s" contient désormais %d photos'; 
    3337?> 
  • extensions/upload_form/upload.php

    r4806 r4807  
    3030 
    3131$admin_base_url = get_root_url().'admin.php?page=plugin&section=upload_form%2Fupload.php'; 
     32$thumbnails = array(); 
    3233 
    3334// +-----------------------------------------------------------------------+ 
     
    5354      (0 == $_POST['category_parent'] ? null : $_POST['category_parent']) 
    5455      ); 
     56     
     57    $category_id = $output_create['id']; 
    5558 
    5659    if (isset($output_create['error'])) 
     
    6063    else 
    6164    { 
     65      $category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=cat_modify&cat_id='); 
    6266      // information 
    6367      array_push( 
     
    6569        sprintf( 
    6670          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']; 
     71          '<em>'.$category_name.'</em>' 
     72          ) 
     73        ); 
     74      // TODO: add the onclick="window.open(this.href); return false;" 
     75      // attribute with jQuery on upload.tpl side for href containing 
     76      // "cat_modify" 
     77    } 
    7378  } 
    7479   
     
    8186      $source_filepath = $_FILES['image_upload']['tmp_name'][$idx]; 
    8287      $original_filename = $_FILES['image_upload']['name'][$idx]; 
    83       add_uploaded_file($source_filepath, $original_filename, array($category_id), $_POST['level']); 
     88       
     89      $image_id = add_uploaded_file( 
     90        $source_filepath, 
     91        $original_filename, 
     92        array($category_id), 
     93        $_POST['level'] 
     94        ); 
     95 
     96      // TODO: if $image_id is not an integer, something went wrong 
     97 
     98      // we could return the list of properties from the add_uploaded_file 
     99      // function, but I like the "double check". And it costs nothing 
     100      // compared to the upload process. 
     101      $thumbnail = array(); 
     102       
     103      $query = ' 
     104SELECT 
     105    file, 
     106    path, 
     107    tn_ext 
     108  FROM '.IMAGES_TABLE.' 
     109  WHERE id = '.$image_id.' 
     110;'; 
     111      $image_infos = mysql_fetch_assoc(pwg_query($query)); 
     112 
     113      $thumbnail['file'] = $image_infos['file']; 
     114       
     115      $thumbnail['src'] = get_thumbnail_location( 
     116        array( 
     117          'path' => $image_infos['path'], 
     118          'tn_ext' => $image_infos['tn_ext'], 
     119          ) 
     120        ); 
     121 
     122      // TODO: when implementing this plugin in Piwigo core, we should have 
     123      // a function get_image_name($name, $file) (if name is null, then 
     124      // compute a temporary name from filename) that would be also used in 
     125      // picture.php. UPDATE: in fact, "get_name_from_file($file)" already 
     126      // exists and is used twice (element_set_unit + comments, but not in 
     127      // picture.php I don't know why) with the same pattern if 
     128      // (empty($name)) {$name = get_name_from_file($file)}, a clean 
     129      // function get_image_name($name, $file) would be better 
     130      $thumbnail['title'] = get_name_from_file($image_infos['file']); 
     131 
     132      $thumbnail['link'] = PHPWG_ROOT_PATH.'admin.php?page=picture_modify' 
     133        .'&amp;image_id='.$image_id 
     134        .'&amp;cat_id='.$category_id 
     135        ; 
     136 
     137      array_push($thumbnails, $thumbnail); 
    84138    } 
    85139  } 
     
    88142  $elapsed = ($endtime - $starttime) * 1000; 
    89143  // printf('%.2f ms', $elapsed); 
     144 
     145  if (!empty($thumbnails)) 
     146  { 
     147    array_push( 
     148      $page['infos'], 
     149      sprintf( 
     150        l10n('%d photos uploaded'), 
     151        count($thumbnails) 
     152        ) 
     153      ); 
     154     
     155    if (0 != $_POST['level']) 
     156    { 
     157      array_push( 
     158        $page['infos'], 
     159        sprintf( 
     160          l10n('Privacy level set to "%s"'), 
     161          l10n( 
     162            sprintf('Level %d', $_POST['level']) 
     163            ) 
     164          ) 
     165        ); 
     166    } 
     167 
     168    if ('existing' == $_POST['category_type']) 
     169    { 
     170      $query = ' 
     171SELECT 
     172    COUNT(*) 
     173  FROM '.IMAGE_CATEGORY_TABLE.' 
     174  WHERE category_id = '.$category_id.' 
     175;'; 
     176      list($count) = mysql_fetch_row(pwg_query($query)); 
     177      $category_name = get_cat_display_name_from_id($category_id, 'admin.php?page=cat_modify&amp;cat_id='); 
     178       
     179      // information 
     180      array_push( 
     181        $page['infos'], 
     182        sprintf( 
     183          l10n('Category "%s" now contains %d photos'), 
     184          '<em>'.$category_name.'</em>', 
     185          $count 
     186          ) 
     187        ); 
     188    } 
     189  } 
    90190} 
    91191 
     
    104204      'F_ADD_ACTION'=> $admin_base_url, 
    105205      'plugin_path' => UPLOAD_FORM_PATH, 
     206      'thumbnails' => $thumbnails, 
    106207    ) 
    107208  ); 
     
    131232    ) 
    132233  ); 
    133  
    134234 
    135235// +-----------------------------------------------------------------------+ 
  • extensions/upload_form/upload.tpl

    r4805 r4807  
    3939</div> 
    4040{else} 
     41 
     42{if !empty($thumbnails)} 
     43<fieldset> 
     44  <legend>{'Uploaded Photos'|@translate}</legend> 
     45  <div> 
     46  {foreach from=$thumbnails item=thumbnail} 
     47    <a href="{$thumbnail.link}" onclick="window.open(this.href); return false;"> 
     48      <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail"> 
     49    </a> 
     50  {/foreach} 
     51  </div> 
     52</fieldset> 
     53{/if} 
     54 
     55 
    4156<form enctype="multipart/form-data" method="post" action="{$F_ACTION}" class="properties"> 
    4257  <fieldset> 
Note: See TracChangeset for help on using the changeset viewer.