Changeset 24623 for extensions/photo_update/admin.php
- Timestamp:
- Sep 25, 2013, 10:28:20 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/photo_update/admin.php
r16982 r24623 69 69 else 70 70 { 71 add_uploaded_file( 72 $_FILES['photo_update']['tmp_name'], 73 $_FILES['photo_update']['name'], 74 null, 75 null, 76 $_GET['image_id'] 77 ); 78 79 $page['photo_update_refresh_thumbnail'] = true; 80 81 array_push( 82 $page['infos'], 83 l10n('The photo was updated') 84 ); 71 $file_to_update = 'main'; 72 if (isset($_POST['file_to_update']) and in_array($_POST['file_to_update'], array('main', 'representative'))) 73 { 74 $file_to_update = $_POST['file_to_update']; 75 } 76 77 $image_id = $_GET['image_id']; 78 79 $query = ' 80 SELECT 81 id, path, representative_ext 82 FROM '.IMAGES_TABLE.' 83 WHERE id = '.$image_id.' 84 ;'; 85 $result = pwg_query($query); 86 $row = pwg_db_fetch_assoc($result); 87 88 if ('main' == $file_to_update) 89 { 90 add_uploaded_file( 91 $_FILES['photo_update']['tmp_name'], 92 $_FILES['photo_update']['name'], 93 null, 94 null, 95 $_GET['image_id'] 96 ); 97 98 array_push( 99 $page['infos'], 100 l10n('The photo was updated') 101 ); 102 } 103 104 if ('representative' == $file_to_update) 105 { 106 $file_path = $row['path']; 107 108 // move the uploaded file to pwg_representative sub-directory 109 $representative_file_path = dirname($file_path).'/pwg_representative/'; 110 $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; 111 112 $old_representative_file_path = $representative_file_path.$row['representative_ext']; 113 114 $representative_ext = get_extension($_FILES['photo_update']['name']); 115 116 // in case we replace a *.jpg by *.png we have to safely remove the 117 // *.jpg becase move_uploaded_file won't remove it 118 if ($representative_ext != $row['representative_ext']) 119 { 120 @unlink($representative_file_path.$row['representative_ext']); 121 } 122 123 $representative_file_path.= $representative_ext; 124 125 prepare_directory(dirname($representative_file_path)); 126 127 move_uploaded_file($_FILES['photo_update']['tmp_name'], $representative_file_path); 128 129 $file_infos = pwg_image_infos($representative_file_path); 130 131 single_update( 132 IMAGES_TABLE, 133 array( 134 'representative_ext' => $representative_ext, 135 'width' => $file_infos['width'], 136 'height' => $file_infos['height'], 137 ), 138 array('id' => $image_id) 139 ); 140 141 array_push( 142 $page['infos'], 143 l10n('The representative picture was updated') 144 ); 145 } 146 147 // force refresh of multiple sizes 148 delete_element_derivatives($row); 85 149 } 86 150 } … … 117 181 $row = pwg_db_fetch_assoc(pwg_query($query)); 118 182 183 if (!in_array(get_extension($row['path']), $conf['picture_ext']) or !empty($row['representative_ext'])) 184 { 185 $template->assign('show_file_to_update', true); 186 } 187 119 188 $template->assign( 120 189 array( 121 'TN_SRC' => DerivativeImage::thumb_url($row).(isset($_FILES['photo_update']) ? '?'.time() : ''), 190 'TN_SRC' => DerivativeImage::thumb_url($row), 191 'original_filename' => $row['file'], 122 192 'TITLE' => render_element_name($row), 123 193 )
Note: See TracChangeset
for help on using the changeset viewer.