Changeset 4875
- Timestamp:
- Feb 11, 2010, 12:29:29 AM (14 years ago)
- Location:
- extensions/upload_form
- Files:
-
- 7 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/upload_form/include/functions_upload.inc.php
r4829 r4875 84 84 'date_available' => $dbnow, 85 85 'tn_ext' => 'jpg', 86 'path' => $file_path,86 'path' => preg_replace('/^.*?upload/', './upload', $file_path), 87 87 'filesize' => $file_infos['filesize'], 88 88 'width' => $file_infos['width'], -
extensions/upload_form/upload.php
r4829 r4875 76 76 if (isset($_POST['submit_upload'])) 77 77 { 78 // echo '<pre>POST'."\n"; print_r($_POST); echo '</pre>'; 79 // echo '<pre>FILES'."\n"; print_r($_FILES); echo '</pre>'; 80 // echo '<pre>SESSION'."\n"; print_r($_SESSION); echo '</pre>'; 81 // exit(); 82 78 83 $category_id = null; 79 84 if ('existing' == $_POST['category_type']) … … 112 117 113 118 $image_ids = array(); 114 $page['thumbnails'] = array(); 115 116 $starttime = get_moment(); 117 119 120 if (isset($_FILES) and !empty($_FILES['image_upload'])) 121 { 122 $starttime = get_moment(); 123 118 124 foreach ($_FILES['image_upload']['error'] as $idx => $error) 119 125 { … … 197 203 198 204 // TODO: if $image_id is not an integer, something went wrong 199 200 // we could return the list of properties from the add_uploaded_file 201 // function, but I like the "double check". And it costs nothing 202 // compared to the upload process. 203 $thumbnail = array(); 205 } 206 } 207 } 208 209 $endtime = get_moment(); 210 $elapsed = ($endtime - $starttime) * 1000; 211 // printf('%.2f ms', $elapsed); 212 213 } // if (!empty($_FILES)) 214 215 if (isset($_POST['upload_id'])) 216 { 217 // we're on a multiple upload, with uploadify and so on 218 $image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ]; 219 220 associate_images_to_categories( 221 $image_ids, 222 array($category_id) 223 ); 224 225 $query = ' 226 UPDATE '.IMAGES_TABLE.' 227 SET level = '.$_POST['level'].' 228 WHERE id IN ('.implode(', ', $image_ids).') 229 ;'; 230 pwg_query($query); 231 232 invalidate_user_cache(); 233 } 234 235 $page['thumbnails'] = array(); 236 foreach ($image_ids as $image_id) 237 { 238 // we could return the list of properties from the add_uploaded_file 239 // function, but I like the "double check". And it costs nothing 240 // compared to the upload process. 241 $thumbnail = array(); 204 242 205 243 $query = ' 206 244 SELECT 207 245 file, … … 211 249 WHERE id = '.$image_id.' 212 250 ;'; 213 $image_infos = mysql_fetch_assoc(pwg_query($query)); 214 215 $thumbnail['file'] = $image_infos['file']; 216 217 $thumbnail['src'] = get_thumbnail_location( 218 array( 219 'path' => $image_infos['path'], 220 'tn_ext' => $image_infos['tn_ext'], 221 ) 222 ); 223 224 // TODO: when implementing this plugin in Piwigo core, we should have 225 // a function get_image_name($name, $file) (if name is null, then 226 // compute a temporary name from filename) that would be also used in 227 // picture.php. UPDATE: in fact, "get_name_from_file($file)" already 228 // exists and is used twice (element_set_unit + comments, but not in 229 // picture.php I don't know why) with the same pattern if 230 // (empty($name)) {$name = get_name_from_file($file)}, a clean 231 // function get_image_name($name, $file) would be better 232 $thumbnail['title'] = get_name_from_file($image_infos['file']); 233 234 $thumbnail['link'] = PHPWG_ROOT_PATH.'admin.php?page=picture_modify' 235 .'&image_id='.$image_id 236 .'&cat_id='.$category_id 237 ; 238 239 array_push($page['thumbnails'], $thumbnail); 240 } 241 } 251 $image_infos = mysql_fetch_assoc(pwg_query($query)); 252 253 $thumbnail['file'] = $image_infos['file']; 254 255 $thumbnail['src'] = get_thumbnail_location( 256 array( 257 'path' => $image_infos['path'], 258 'tn_ext' => $image_infos['tn_ext'], 259 ) 260 ); 261 262 // TODO: when implementing this plugin in Piwigo core, we should have 263 // a function get_image_name($name, $file) (if name is null, then 264 // compute a temporary name from filename) that would be also used in 265 // picture.php. UPDATE: in fact, "get_name_from_file($file)" already 266 // exists and is used twice (element_set_unit + comments, but not in 267 // picture.php I don't know why) with the same pattern if 268 // (empty($name)) {$name = get_name_from_file($file)}, a clean 269 // function get_image_name($name, $file) would be better 270 $thumbnail['title'] = get_name_from_file($image_infos['file']); 271 272 $thumbnail['link'] = PHPWG_ROOT_PATH.'admin.php?page=picture_modify' 273 .'&image_id='.$image_id 274 .'&cat_id='.$category_id 275 ; 276 277 array_push($page['thumbnails'], $thumbnail); 242 278 } 243 279 244 $endtime = get_moment();245 $elapsed = ($endtime - $starttime) * 1000;246 // printf('%.2f ms', $elapsed);247 248 280 if (!empty($page['thumbnails'])) 249 281 { … … 312 344 ); 313 345 346 $template->assign( 347 array( 348 'upload_mode' => 'multiple', 349 'upload_id' => md5(rand()), 350 'session_id' => session_id(), 351 'pwg_token' => get_pwg_token(), 352 ) 353 ); 354 355 $template->append( 356 'head_elements', 357 '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'uploadify/uploadify.css">'."\n" 358 ); 359 314 360 if (isset($page['thumbnails'])) 315 361 { -
extensions/upload_form/upload.tpl
r4829 r4875 14 14 {/literal} 15 15 16 <script type="text/javascript" src="{$plugin_path}/include/upload.js"></script> 16 {if $upload_mode eq 'html'} 17 <script type="text/javascript" src="{$plugin_path}include/upload.js"></script> 18 {elseif $upload_mode eq 'multiple'} 19 <script type="text/javascript" src="{$plugin_path}uploadify/swfobject.js"></script> 20 <script type="text/javascript" src="{$plugin_path}uploadify/jquery.uploadify.v2.1.0.min.js"></script> 21 22 <script type="text/javascript"> 23 var basepath = '{$plugin_path}'; 24 var upload_id = '{$upload_id}'; 25 var session_id = '{$session_id}'; 26 var pwg_token = '{$pwg_token}'; 27 var buttonText = '{"Select files"|@translate}'; 28 29 {literal} 30 jQuery(document).ready(function() { 31 jQuery("#uploadify").uploadify({ 32 'uploader' : basepath + 'uploadify/uploadify.swf', 33 'script' : basepath + 'uploadify/uploadify.php', 34 'scriptData' : { 35 'upload_id' : upload_id, 36 'session_id' : session_id, 37 'pwg_token' : pwg_token, 38 }, 39 'cancelImg' : basepath + 'uploadify/cancel.png', 40 'queueID' : 'fileQueue', 41 'auto' : false, 42 'displayData' : 'speed', 43 'buttonText' : buttonText, 44 'multi' : true, 45 'onAllComplete' : function(event, data) { 46 if (data.errors) { 47 return false; 48 } 49 else { 50 $("input[name=submit_upload]").click(); 51 } 52 } 53 }); 54 }); 55 {/literal} 56 </script> 57 {/if} 17 58 18 59 {literal} … … 59 100 60 101 61 <form enctype="multipart/form-data" method="post" action="{$F_ACTION}" class="properties"> 102 <form id="uploadForm" enctype="multipart/form-data" method="post" action="{$F_ACTION}" class="properties"> 103 {if $upload_mode eq 'multiple'} 104 <input name="upload_id" value="{$upload_id}" type="hidden"> 105 {/if} 62 106 <fieldset> 63 107 <legend>{'Upload Photos'|@translate}</legend> … … 108 152 </tr> 109 153 154 {if $upload_mode eq 'html'} 110 155 <tr> 111 156 <td colspan="2"> … … 126 171 <input class="submit" type="submit" name="submit_upload" value="{'Upload'|@translate}" {$TAG_INPUT_ENABLED}/> 127 172 </p> 173 {elseif $upload_mode eq 'multiple'} 174 </table> 175 176 <p> 177 <input type="file" name="uploadify" id="uploadify" /> 178 </p> 179 180 <div id="fileQueue"></div> 181 182 <p> 183 <input class="submit" type="button" value="{'Upload'|@translate}" onclick="javascript:jQuery('#uploadify').uploadifyUpload()"/> 184 <input type="submit" name="submit_upload" style="display:none"/> 185 </p> 186 {/if} 128 187 </fieldset> 129 188 </form>
Note: See TracChangeset
for help on using the changeset viewer.