| [0] | 1 | <?php | 
|---|
|  | 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- | 
|---|
|  | 3 | # | 
|---|
|  | 4 | # This file is part of Dotclear 2. | 
|---|
|  | 5 | # | 
|---|
| [1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear | 
|---|
| [0] | 7 | # Licensed under the GPL version 2.0 license. | 
|---|
|  | 8 | # See LICENSE file or | 
|---|
|  | 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | 
|---|
|  | 10 | # | 
|---|
|  | 11 | # -- END LICENSE BLOCK ----------------------------------------- | 
|---|
|  | 12 |  | 
|---|
|  | 13 | /* HTML page | 
|---|
|  | 14 | -------------------------------------------------------- */ | 
|---|
|  | 15 | require dirname(__FILE__).'/../inc/admin/prepend.php'; | 
|---|
|  | 16 |  | 
|---|
|  | 17 | dcPage::check('media,media_admin'); | 
|---|
|  | 18 |  | 
|---|
|  | 19 | $post_id = !empty($_GET['post_id']) ? (integer) $_GET['post_id'] : null; | 
|---|
|  | 20 | if ($post_id) { | 
|---|
| [408] | 21 | $post = $core->blog->getPosts(array('post_id'=>$post_id,'post_type'=>'')); | 
|---|
| [0] | 22 | if ($post->isEmpty()) { | 
|---|
|  | 23 | $post_id = null; | 
|---|
|  | 24 | } | 
|---|
|  | 25 | $post_title = $post->post_title; | 
|---|
|  | 26 | $post_type = $post->post_type; | 
|---|
|  | 27 | unset($post); | 
|---|
|  | 28 | } | 
|---|
|  | 29 | $d = isset($_REQUEST['d']) ? $_REQUEST['d'] : null; | 
|---|
|  | 30 | $dir = null; | 
|---|
|  | 31 |  | 
|---|
| [1912] | 32 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; | 
|---|
| [0] | 33 | $nb_per_page =  30; | 
|---|
|  | 34 |  | 
|---|
|  | 35 | # We are on home not comming from media manager | 
|---|
|  | 36 | if ($d === null && isset($_SESSION['media_manager_dir'])) { | 
|---|
|  | 37 | # We get session information | 
|---|
|  | 38 | $d = $_SESSION['media_manager_dir']; | 
|---|
|  | 39 | } | 
|---|
|  | 40 |  | 
|---|
|  | 41 | if (!isset($_GET['page']) && isset($_SESSION['media_manager_page'])) { | 
|---|
|  | 42 | $page = $_SESSION['media_manager_page']; | 
|---|
|  | 43 | } | 
|---|
|  | 44 |  | 
|---|
|  | 45 | # We set session information about directory and page | 
|---|
|  | 46 | if ($d) { | 
|---|
|  | 47 | $_SESSION['media_manager_dir'] = $d; | 
|---|
|  | 48 | } else { | 
|---|
|  | 49 | unset($_SESSION['media_manager_dir']); | 
|---|
|  | 50 | } | 
|---|
|  | 51 | if ($page != 1) { | 
|---|
|  | 52 | $_SESSION['media_manager_page'] = $page; | 
|---|
|  | 53 | } else { | 
|---|
|  | 54 | unset($_SESSION['media_manager_page']); | 
|---|
|  | 55 | } | 
|---|
|  | 56 |  | 
|---|
|  | 57 | # Sort combo | 
|---|
|  | 58 | $sort_combo = array( | 
|---|
|  | 59 | __('By names, in ascending order') => 'name-asc', | 
|---|
|  | 60 | __('By names, in descending order') => 'name-desc', | 
|---|
|  | 61 | __('By dates, in ascending order') => 'date-asc', | 
|---|
|  | 62 | __('By dates, in descending order') => 'date-desc' | 
|---|
| [1161] | 63 | ); | 
|---|
| [0] | 64 |  | 
|---|
|  | 65 | if (!empty($_GET['file_sort']) && in_array($_GET['file_sort'],$sort_combo)) { | 
|---|
|  | 66 | $_SESSION['media_file_sort'] = $_GET['file_sort']; | 
|---|
|  | 67 | } | 
|---|
|  | 68 | $file_sort = !empty($_SESSION['media_file_sort']) ? $_SESSION['media_file_sort'] : null; | 
|---|
|  | 69 |  | 
|---|
|  | 70 | $popup = (integer) !empty($_GET['popup']); | 
|---|
|  | 71 |  | 
|---|
|  | 72 | $page_url = 'media.php?popup='.$popup.'&post_id='.$post_id; | 
|---|
|  | 73 |  | 
|---|
|  | 74 | if ($popup) { | 
|---|
|  | 75 | $open_f = array('dcPage','openPopup'); | 
|---|
|  | 76 | $close_f = array('dcPage','closePopup'); | 
|---|
|  | 77 | } else { | 
|---|
|  | 78 | $open_f = array('dcPage','open'); | 
|---|
|  | 79 | $close_f = create_function('',"dcPage::helpBlock('core_media'); dcPage::close();"); | 
|---|
|  | 80 | } | 
|---|
|  | 81 |  | 
|---|
|  | 82 | $core_media_writable = false; | 
|---|
|  | 83 | try { | 
|---|
|  | 84 | $core->media = new dcMedia($core); | 
|---|
|  | 85 | if ($file_sort) { | 
|---|
|  | 86 | $core->media->setFileSort($file_sort); | 
|---|
|  | 87 | } | 
|---|
|  | 88 | $core->media->chdir($d); | 
|---|
|  | 89 | $core->media->getDir(); | 
|---|
|  | 90 | $core_media_writable = $core->media->writable(); | 
|---|
|  | 91 | $dir =& $core->media->dir; | 
|---|
|  | 92 | if  (!$core_media_writable) { | 
|---|
| [1725] | 93 | //        throw new Exception('you do not have sufficient permissions to write to this folder: '); | 
|---|
| [0] | 94 | } | 
|---|
|  | 95 | } catch (Exception $e) { | 
|---|
|  | 96 | $core->error->add($e->getMessage()); | 
|---|
|  | 97 | } | 
|---|
|  | 98 |  | 
|---|
|  | 99 | # Zip download | 
|---|
|  | 100 | if (!empty($_GET['zipdl']) && $core->auth->check('media_admin',$core->blog->id)) | 
|---|
|  | 101 | { | 
|---|
|  | 102 | try | 
|---|
|  | 103 | { | 
|---|
|  | 104 | @set_time_limit(300); | 
|---|
|  | 105 | $fp = fopen('php://output','wb'); | 
|---|
|  | 106 | $zip = new fileZip($fp); | 
|---|
|  | 107 | $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#'); | 
|---|
|  | 108 | $zip->addDirectory($core->media->root.'/'.$d,'',true); | 
|---|
|  | 109 |  | 
|---|
|  | 110 | header('Content-Disposition: attachment;filename='.($d ? $d : 'media').'.zip'); | 
|---|
|  | 111 | header('Content-Type: application/x-zip'); | 
|---|
|  | 112 | $zip->write(); | 
|---|
|  | 113 | unset($zip); | 
|---|
|  | 114 | exit; | 
|---|
|  | 115 | } | 
|---|
|  | 116 | catch (Exception $e) | 
|---|
|  | 117 | { | 
|---|
|  | 118 | $core->error->add($e->getMessage()); | 
|---|
|  | 119 | } | 
|---|
|  | 120 | } | 
|---|
|  | 121 |  | 
|---|
|  | 122 | # New directory | 
|---|
|  | 123 | if ($dir && !empty($_POST['newdir'])) | 
|---|
|  | 124 | { | 
|---|
|  | 125 | try { | 
|---|
|  | 126 | $core->media->makeDir($_POST['newdir']); | 
|---|
|  | 127 | http::redirect($page_url.'&d='.rawurlencode($d).'&mkdok=1'); | 
|---|
|  | 128 | } catch (Exception $e) { | 
|---|
|  | 129 | $core->error->add($e->getMessage()); | 
|---|
|  | 130 | } | 
|---|
|  | 131 | } | 
|---|
|  | 132 |  | 
|---|
|  | 133 | # Adding a file | 
|---|
| [1159] | 134 | if ($dir && !empty($_FILES['upfile'])) { | 
|---|
|  | 135 | // only one file per request : @see option singleFileUploads in admin/js/jsUpload/jquery.fileupload | 
|---|
| [1161] | 136 | $upfile = array('name' => $_FILES['upfile']['name'][0], | 
|---|
|  | 137 | 'type' => $_FILES['upfile']['type'][0], | 
|---|
|  | 138 | 'tmp_name' => $_FILES['upfile']['tmp_name'][0], | 
|---|
|  | 139 | 'error' => $_FILES['upfile']['error'][0], | 
|---|
|  | 140 | 'size' => $_FILES['upfile']['size'][0] | 
|---|
|  | 141 | ); | 
|---|
| [1144] | 142 |  | 
|---|
| [1161] | 143 | if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { | 
|---|
|  | 144 | header('Content-type: application/json'); | 
|---|
|  | 145 | $message = array(); | 
|---|
| [1144] | 146 |  | 
|---|
| [1161] | 147 | try { | 
|---|
|  | 148 | files::uploadStatus($upfile); | 
|---|
|  | 149 | $new_file_id = $core->media->uploadFile($upfile['tmp_name'], $upfile['name']); | 
|---|
| [1144] | 150 |  | 
|---|
| [1161] | 151 | $message['files'][] = array('name' => $upfile['name'], | 
|---|
|  | 152 | 'size' => $upfile['size'], | 
|---|
|  | 153 | 'html' => mediaItemLine($core->media->getFile($new_file_id), 1) | 
|---|
|  | 154 | ); | 
|---|
|  | 155 | } catch (Exception $e) { | 
|---|
|  | 156 | $message['files'][] = array('name' => $upfile['name'], | 
|---|
| [1162] | 157 | 'size' => $upfile['size'], | 
|---|
| [1161] | 158 | 'error' => $e->getMessage() | 
|---|
|  | 159 | ); | 
|---|
|  | 160 | } | 
|---|
|  | 161 | echo json_encode($message); | 
|---|
|  | 162 | exit(); | 
|---|
|  | 163 | } else { | 
|---|
|  | 164 | try { | 
|---|
|  | 165 | files::uploadStatus($upfile); | 
|---|
| [1159] | 166 |  | 
|---|
| [1161] | 167 | $f_title = (isset($_POST['upfiletitle']) ? $_POST['upfiletitle'] : ''); | 
|---|
|  | 168 | $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false); | 
|---|
| [1159] | 169 |  | 
|---|
| [1161] | 170 | $core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $f_title, $f_private); | 
|---|
|  | 171 | http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1'); | 
|---|
|  | 172 | } catch (Exception $e) { | 
|---|
|  | 173 | $core->error->add($e->getMessage()); | 
|---|
|  | 174 | } | 
|---|
|  | 175 | } | 
|---|
| [0] | 176 | } | 
|---|
|  | 177 |  | 
|---|
|  | 178 | # Removing item | 
|---|
|  | 179 | if ($dir && !empty($_POST['rmyes']) && !empty($_POST['remove'])) | 
|---|
|  | 180 | { | 
|---|
|  | 181 | $_POST['remove'] = rawurldecode($_POST['remove']); | 
|---|
|  | 182 |  | 
|---|
|  | 183 | try { | 
|---|
|  | 184 | $core->media->removeItem($_POST['remove']); | 
|---|
|  | 185 | http::redirect($page_url.'&d='.rawurlencode($d).'&rmfok=1'); | 
|---|
|  | 186 | } catch (Exception $e) { | 
|---|
|  | 187 | $core->error->add($e->getMessage()); | 
|---|
|  | 188 | } | 
|---|
|  | 189 | } | 
|---|
|  | 190 |  | 
|---|
|  | 191 | # Rebuild directory | 
|---|
|  | 192 | if ($dir && $core->auth->isSuperAdmin() && !empty($_POST['rebuild'])) | 
|---|
|  | 193 | { | 
|---|
|  | 194 | try { | 
|---|
|  | 195 | $core->media->rebuild($d); | 
|---|
|  | 196 | http::redirect($page_url.'&d='.rawurlencode($d).'&rebuildok=1'); | 
|---|
|  | 197 | } catch (Exception $e) { | 
|---|
|  | 198 | $core->error->add($e->getMessage()); | 
|---|
|  | 199 | } | 
|---|
|  | 200 | } | 
|---|
|  | 201 |  | 
|---|
|  | 202 | # DISPLAY confirm page for rmdir & rmfile | 
|---|
| [947] | 203 | if ($dir && !empty($_GET['remove']) && empty($_GET['noconfirm'])) | 
|---|
| [0] | 204 | { | 
|---|
| [1358] | 205 | call_user_func($open_f,__('Media manager'),'', | 
|---|
|  | 206 | dcPage::breadcrumb( | 
|---|
|  | 207 | array( | 
|---|
|  | 208 | html::escapeHTML($core->blog->name) => '', | 
|---|
|  | 209 | __('Media manager') => '', | 
|---|
|  | 210 | '<span class="page-title">'.__('confirm removal').'</span>' => '' | 
|---|
|  | 211 | ),!$popup) | 
|---|
|  | 212 | ); | 
|---|
| [0] | 213 |  | 
|---|
|  | 214 | echo | 
|---|
|  | 215 | '<form action="'.html::escapeURL($page_url).'" method="post">'. | 
|---|
|  | 216 | '<p>'.sprintf(__('Are you sure you want to remove %s?'), | 
|---|
| [1161] | 217 | html::escapeHTML($_GET['remove'])).'</p>'. | 
|---|
| [557] | 218 | '<p><input type="submit" value="'.__('Cancel').'" /> '. | 
|---|
|  | 219 | '   <input type="submit" name="rmyes" value="'.__('Yes').'" />'. | 
|---|
| [0] | 220 | form::hidden('d',$d). | 
|---|
|  | 221 | $core->formNonce(). | 
|---|
|  | 222 | form::hidden('remove',html::escapeHTML($_GET['remove'])).'</p>'. | 
|---|
|  | 223 | '</form>'; | 
|---|
|  | 224 |  | 
|---|
|  | 225 | call_user_func($close_f); | 
|---|
|  | 226 | exit; | 
|---|
|  | 227 | } | 
|---|
|  | 228 |  | 
|---|
|  | 229 | /* DISPLAY Main page | 
|---|
|  | 230 | -------------------------------------------------------- */ | 
|---|
| [240] | 231 | $core->auth->user_prefs->addWorkspace('interface'); | 
|---|
|  | 232 | $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; | 
|---|
|  | 233 |  | 
|---|
| [1358] | 234 | if (!isset($core->media)) { | 
|---|
|  | 235 | $breadcrumb = dcPage::breadcrumb( | 
|---|
|  | 236 | array( | 
|---|
|  | 237 | html::escapeHTML($core->blog->name) => '', | 
|---|
|  | 238 | '<span class="page-title">'.__('Media manager').'</span>' => '' | 
|---|
|  | 239 | ),!$popup); | 
|---|
|  | 240 | } else { | 
|---|
|  | 241 | $breadcrumb_media = $core->media->breadCrumb(html::escapeURL($page_url).'&d=%s','<span class="page-title">%s</span>'); | 
|---|
|  | 242 | if ($breadcrumb_media == '') { | 
|---|
|  | 243 | $breadcrumb = dcPage::breadcrumb( | 
|---|
|  | 244 | array( | 
|---|
|  | 245 | html::escapeHTML($core->blog->name) => '', | 
|---|
|  | 246 | '<span class="page-title">'.__('Media manager').'</span>' => '' | 
|---|
|  | 247 | ),!$popup); | 
|---|
|  | 248 | } else { | 
|---|
|  | 249 | $breadcrumb = dcPage::breadcrumb( | 
|---|
|  | 250 | array( | 
|---|
|  | 251 | html::escapeHTML($core->blog->name) => '', | 
|---|
|  | 252 | __('Media manager') => html::escapeURL($page_url.'&d='), | 
|---|
|  | 253 | $breadcrumb_media => '' | 
|---|
|  | 254 | ),!$popup); | 
|---|
|  | 255 | } | 
|---|
|  | 256 | } | 
|---|
|  | 257 |  | 
|---|
| [0] | 258 | call_user_func($open_f,__('Media manager'), | 
|---|
|  | 259 | dcPage::jsLoad('js/_media.js'). | 
|---|
| [1358] | 260 | ($core_media_writable ? dcPage::jsUpload(array('d='.$d)) : ''), | 
|---|
|  | 261 | $breadcrumb | 
|---|
| [240] | 262 | ); | 
|---|
| [0] | 263 |  | 
|---|
| [1725] | 264 | if (!$core_media_writable) { | 
|---|
|  | 265 | dcPage::warning(__('You do not have sufficient permissions to write to this folder.')); | 
|---|
|  | 266 | } | 
|---|
|  | 267 |  | 
|---|
| [0] | 268 | if (!empty($_GET['mkdok'])) { | 
|---|
| [1553] | 269 | dcPage::success(__('Directory has been successfully created.')); | 
|---|
| [0] | 270 | } | 
|---|
|  | 271 |  | 
|---|
|  | 272 | if (!empty($_GET['upok'])) { | 
|---|
| [1553] | 273 | dcPage::success(__('Files have been successfully uploaded.')); | 
|---|
| [0] | 274 | } | 
|---|
|  | 275 |  | 
|---|
|  | 276 | if (!empty($_GET['rmfok'])) { | 
|---|
| [1553] | 277 | dcPage::success(__('File has been successfully removed.')); | 
|---|
| [0] | 278 | } | 
|---|
|  | 279 |  | 
|---|
|  | 280 | if (!empty($_GET['rmdok'])) { | 
|---|
| [1553] | 281 | dcPage::success(__('Directory has been successfully removed.')); | 
|---|
| [0] | 282 | } | 
|---|
|  | 283 |  | 
|---|
|  | 284 | if (!empty($_GET['rebuildok'])) { | 
|---|
| [1553] | 285 | dcPage::success(__('Directory has been successfully rebuilt.')); | 
|---|
| [0] | 286 | } | 
|---|
|  | 287 |  | 
|---|
|  | 288 | if (!empty($_GET['unzipok'])) { | 
|---|
| [1553] | 289 | dcPage::success(__('Zip file has been successfully extracted.')); | 
|---|
| [0] | 290 | } | 
|---|
|  | 291 |  | 
|---|
|  | 292 | if (!$dir) { | 
|---|
|  | 293 | call_user_func($close_f); | 
|---|
|  | 294 | exit; | 
|---|
|  | 295 | } | 
|---|
|  | 296 |  | 
|---|
|  | 297 | if ($post_id) { | 
|---|
| [1605] | 298 | echo '<p class="form-note info">'.sprintf(__('Choose a file to attach to entry %s by clicking on %s.'), | 
|---|
| [1161] | 299 | '<a href="'.$core->getPostAdminURL($post_type,$post_id).'">'.html::escapeHTML($post_title).'</a>', | 
|---|
| [1605] | 300 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />').'</p>'; | 
|---|
| [0] | 301 | } | 
|---|
|  | 302 | if ($popup) { | 
|---|
| [1605] | 303 | echo '<p class="form-note info">'.sprintf(__('Choose a file to insert into entry by clicking on %s.'), | 
|---|
|  | 304 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />').'</p>'; | 
|---|
| [0] | 305 | } | 
|---|
|  | 306 |  | 
|---|
|  | 307 |  | 
|---|
|  | 308 | $items = array_values(array_merge($dir['dirs'],$dir['files'])); | 
|---|
| [1160] | 309 | echo '<div class="media-list">'; | 
|---|
| [0] | 310 | if (count($items) == 0) | 
|---|
|  | 311 | { | 
|---|
| [1636] | 312 | echo '<p>'.__('No file.').'</p>'; | 
|---|
| [0] | 313 | } | 
|---|
|  | 314 | else | 
|---|
|  | 315 | { | 
|---|
|  | 316 | $pager = new pager($page,count($items),$nb_per_page,10); | 
|---|
|  | 317 | $pager->html_prev = __($pager->html_prev); | 
|---|
|  | 318 | $pager->html_next = __($pager->html_next); | 
|---|
|  | 319 |  | 
|---|
|  | 320 | echo | 
|---|
|  | 321 | '<form action="media.php" method="get">'. | 
|---|
| [1399] | 322 | '<p><label for="file_sort" class="classic">'.__('Sort files:').'</label> '. | 
|---|
|  | 323 | form::combo('file_sort',$sort_combo,$file_sort). | 
|---|
| [0] | 324 | form::hidden(array('popup'),$popup). | 
|---|
|  | 325 | form::hidden(array('post_id'),$post_id). | 
|---|
| [557] | 326 | '<input type="submit" value="'.__('Sort').'" /></p>'. | 
|---|
| [0] | 327 | '</form>'. | 
|---|
|  | 328 |  | 
|---|
| [1416] | 329 | '<p class="pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; | 
|---|
| [1855] | 330 |  | 
|---|
|  | 331 | $dgroup = ''; | 
|---|
|  | 332 | $fgroup = ''; | 
|---|
|  | 333 | for ($i=$pager->index_start, $j=0; $i<=$pager->index_end; $i++,$j++) | 
|---|
| [0] | 334 | { | 
|---|
| [1855] | 335 | if ($items[$i]->d) { | 
|---|
|  | 336 | $dgroup .= mediaItemLine($items[$i],$j); | 
|---|
|  | 337 | } else { | 
|---|
|  | 338 | $fgroup .= mediaItemLine($items[$i],$j); | 
|---|
|  | 339 | } | 
|---|
| [0] | 340 | } | 
|---|
| [1855] | 341 | echo | 
|---|
|  | 342 | ($dgroup != '' ? '<div class="folders-group">'.$dgroup.'</div>' : ''). | 
|---|
|  | 343 | ($fgroup != '' ? '<div class="files-group">'.$fgroup.'</div>' : ''); | 
|---|
| [0] | 344 |  | 
|---|
|  | 345 | echo | 
|---|
| [1416] | 346 | '<p class="clear pagination">'.__('Page(s)').' : '.$pager->getLinks().'</p>'; | 
|---|
| [0] | 347 | } | 
|---|
| [1162] | 348 | if (!isset($pager)) { | 
|---|
|  | 349 | echo | 
|---|
|  | 350 | '<p class="clear"></p>'; | 
|---|
|  | 351 | } | 
|---|
| [1160] | 352 | echo | 
|---|
| [1161] | 353 | '</div>'; | 
|---|
| [1144] | 354 |  | 
|---|
| [0] | 355 | if ($core_media_writable) | 
|---|
|  | 356 | { | 
|---|
| [1681] | 357 | echo | 
|---|
| [1725] | 358 | '<h3 class="hidden">'.sprintf(__('In %s:'),($d == '' ? '“'.__('Media manager').'”' : '“'.$d.'”')).'</h3>'. | 
|---|
| [1760] | 359 | '<div class="two-boxes odd fieldset">'; | 
|---|
| [0] | 360 |  | 
|---|
| [1161] | 361 | if ($user_ui_enhanceduploader) { | 
|---|
|  | 362 | echo | 
|---|
| [1681] | 363 | '<div class="enhanced_uploader">'; | 
|---|
| [1161] | 364 | } else { | 
|---|
|  | 365 | echo | 
|---|
| [1681] | 366 | '<div>'; | 
|---|
| [1161] | 367 | } | 
|---|
| [1159] | 368 |  | 
|---|
| [1161] | 369 | echo | 
|---|
| [1681] | 370 | '<h4>'.__('Add files').'</h4>'. | 
|---|
| [1161] | 371 | '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. | 
|---|
| [1519] | 372 | '<form id="fileupload" action="'.html::escapeURL($page_url).'" method="post" enctype="multipart/form-data" aria-disabled="false">'. | 
|---|
| [1450] | 373 | '<p>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). | 
|---|
|  | 374 | $core->formNonce().'</p>'. | 
|---|
|  | 375 | '<div class="fileupload-ctrl"><p class="queue-message"></p><ul class="files"></ul></div>'; | 
|---|
| [1159] | 376 |  | 
|---|
| [1161] | 377 | echo | 
|---|
| [1519] | 378 | '<div class="fileupload-buttonbar clear">'; | 
|---|
| [1162] | 379 |  | 
|---|
|  | 380 | echo | 
|---|
| [1450] | 381 | '<p><label for="upfile">'.'<span class="add-label one-file">'.__('Choose file').'</span>'.'</label>'. | 
|---|
| [1852] | 382 | '<button class="button choose_files">'.__('Choose files').'</button>'. | 
|---|
| [1450] | 383 | '<input type="file" id="upfile" name="upfile[]"'.($user_ui_enhanceduploader?' multiple="mutiple"':'').' data-url="'.html::escapeURL($page_url).'" /></p>'; | 
|---|
| [1159] | 384 |  | 
|---|
| [1161] | 385 | echo | 
|---|
| [1854] | 386 | '<p class="max-sizer form-note"> '.__('Maximum file size allowed:').' '.files::size(DC_MAX_UPLOAD_SIZE).'</p>'; | 
|---|
|  | 387 |  | 
|---|
|  | 388 | echo | 
|---|
| [1450] | 389 | '<p class="one-file"><label for="upfiletitle">'.__('Title:').'</label>'.form::field(array('upfiletitle','upfiletitle'),35,255).'</p>'. | 
|---|
| [1452] | 390 | '<p class="one-file"><label for="upfilepriv" class="classic">'.__('Private').'</label> '. | 
|---|
| [1450] | 391 | form::checkbox(array('upfilepriv','upfilepriv'),1).'</p>'; | 
|---|
| [1159] | 392 |  | 
|---|
| [1854] | 393 |  | 
|---|
|  | 394 |  | 
|---|
| [1161] | 395 | if (!$user_ui_enhanceduploader) { | 
|---|
|  | 396 | echo | 
|---|
|  | 397 | '<p class="one-file form-help info">'.__('To send several files at the same time, you can activate the enhanced uploader in'). | 
|---|
|  | 398 | ' <a href="preferences.php?tab=user-options">'.__('My preferences').'</a></p>'; | 
|---|
|  | 399 | } | 
|---|
| [1159] | 400 |  | 
|---|
| [1161] | 401 | echo | 
|---|
| [1526] | 402 | '<p class="clear"><button class="button clean">'.__('Refresh').'</button>'. | 
|---|
| [1183] | 403 | '<input class="button cancel one-file" type="reset" value="'.__('Clear all').'"/>'. | 
|---|
| [1450] | 404 | '<input class="button start" type="submit" value="'.__('Upload').'"/></p>'. | 
|---|
| [1161] | 405 | '</div>'; | 
|---|
| [1159] | 406 |  | 
|---|
| [1161] | 407 | echo | 
|---|
| [1526] | 408 | '<p style="clear:both;">'.form::hidden(array('d'),$d).'</p>'. | 
|---|
| [1161] | 409 | '</form>'. | 
|---|
| [1681] | 410 | '</div>'. | 
|---|
|  | 411 | '</div>'; | 
|---|
| [1725] | 412 | } | 
|---|
| [1450] | 413 |  | 
|---|
| [1725] | 414 | $core_media_archivable = $core->auth->check('media_admin',$core->blog->id) && | 
|---|
|  | 415 | !(count($items) == 0 || (count($items) == 1 && $items[0]->parent)); | 
|---|
|  | 416 |  | 
|---|
|  | 417 | if ($core_media_writable || $core_media_archivable) { | 
|---|
|  | 418 |  | 
|---|
| [1760] | 419 | echo '<div class="two-boxes even fieldset">'; | 
|---|
| [1725] | 420 |  | 
|---|
|  | 421 | # Create directory | 
|---|
|  | 422 | if ($core_media_writable) | 
|---|
|  | 423 | { | 
|---|
|  | 424 | echo | 
|---|
|  | 425 | '<form action="'.html::escapeURL($page_url).'" method="post">'. | 
|---|
|  | 426 | '<div id="new-dir-f">'. | 
|---|
|  | 427 | '<h4>'.__('Create new directory').'</h4>'. | 
|---|
|  | 428 | $core->formNonce(). | 
|---|
|  | 429 | '<p><label for="newdir">'.__('Directory Name:').'</label>'. | 
|---|
|  | 430 | form::field(array('newdir','newdir'),35,255).'</p>'. | 
|---|
|  | 431 | '<p><input type="submit" value="'.__('Create').'" />'. | 
|---|
|  | 432 | form::hidden(array('d'),html::escapeHTML($d)).'</p>'. | 
|---|
|  | 433 | '</div>'. | 
|---|
|  | 434 | '</form>'; | 
|---|
| [1681] | 435 | } | 
|---|
| [0] | 436 |  | 
|---|
| [1725] | 437 | # Get zip directory | 
|---|
|  | 438 | if ($core_media_archivable) | 
|---|
|  | 439 | { | 
|---|
|  | 440 | echo | 
|---|
|  | 441 | '<h4>'.__('Backup content').'</h4>'. | 
|---|
|  | 442 | '<p>'.__('Compress this directory with its content as a zip file and download it.').'</p>'. | 
|---|
| [1760] | 443 | '<p><a class="button submit" href="'.html::escapeURL($page_url).'&zipdl=1">'. | 
|---|
| [1725] | 444 | __('Download').'</a></p>'; | 
|---|
|  | 445 | } | 
|---|
|  | 446 |  | 
|---|
|  | 447 | echo '</div>'; | 
|---|
|  | 448 | } | 
|---|
|  | 449 |  | 
|---|
| [0] | 450 | # Empty remove form (for javascript actions) | 
|---|
|  | 451 | echo | 
|---|
| [1681] | 452 | '<form id="media-remove-hide" action="'.html::escapeURL($page_url).'" method="post" class="hidden">'. | 
|---|
|  | 453 | '<div>'. | 
|---|
| [0] | 454 | form::hidden('rmyes',1).form::hidden('d',html::escapeHTML($d)). | 
|---|
|  | 455 | form::hidden('remove',''). | 
|---|
|  | 456 | $core->formNonce(). | 
|---|
| [1681] | 457 | '</div>'. | 
|---|
|  | 458 | '</form>'; | 
|---|
| [0] | 459 |  | 
|---|
|  | 460 | call_user_func($close_f); | 
|---|
|  | 461 |  | 
|---|
|  | 462 | /* ----------------------------------------------------- */ | 
|---|
|  | 463 | function mediaItemLine($f,$i) | 
|---|
|  | 464 | { | 
|---|
|  | 465 | global $core, $page_url, $popup, $post_id; | 
|---|
|  | 466 |  | 
|---|
|  | 467 | $fname = $f->basename; | 
|---|
|  | 468 |  | 
|---|
| [1849] | 469 | $class = 'media-item media-col-'.($i%2); | 
|---|
|  | 470 |  | 
|---|
| [0] | 471 | if ($f->d) { | 
|---|
|  | 472 | $link = html::escapeURL($page_url).'&d='.html::sanitizeURL($f->relname); | 
|---|
|  | 473 | if ($f->parent) { | 
|---|
|  | 474 | $fname = '..'; | 
|---|
| [1849] | 475 | $class .= ' media-folder-up'; | 
|---|
|  | 476 | } else { | 
|---|
|  | 477 | $class .= ' media-folder'; | 
|---|
| [0] | 478 | } | 
|---|
|  | 479 | } else { | 
|---|
|  | 480 | $link = | 
|---|
|  | 481 | 'media_item.php?id='.$f->media_id.'&popup='.$popup.'&post_id='.$post_id; | 
|---|
|  | 482 | } | 
|---|
|  | 483 |  | 
|---|
|  | 484 | $res = | 
|---|
| [1855] | 485 | '<div class="'.$class.'"><p><a class="media-icon media-link" href="'.$link.'">'. | 
|---|
|  | 486 | '<img src="'.$f->media_icon.'" alt="" />'.$fname.'</a></p>'; | 
|---|
|  | 487 |  | 
|---|
|  | 488 | $lst = ''; | 
|---|
| [0] | 489 |  | 
|---|
|  | 490 | if (!$f->d) { | 
|---|
| [1855] | 491 | $lst .= | 
|---|
| [0] | 492 | '<li>'.$f->media_title.'</li>'. | 
|---|
|  | 493 | '<li>'. | 
|---|
|  | 494 | $f->media_dtstr.' - '. | 
|---|
|  | 495 | files::size($f->size).' - '. | 
|---|
|  | 496 | '<a href="'.$f->file_url.'">'.__('open').'</a>'. | 
|---|
|  | 497 | '</li>'; | 
|---|
|  | 498 | } | 
|---|
|  | 499 |  | 
|---|
| [1855] | 500 | $act = ''; | 
|---|
| [0] | 501 |  | 
|---|
|  | 502 | if ($post_id && !$f->d) { | 
|---|
| [1855] | 503 | $act .= | 
|---|
|  | 504 | '<form action="post_media.php" method="post">'. | 
|---|
| [0] | 505 | '<input type="image" src="images/plus.png" alt="'.__('Attach this file to entry').'" '. | 
|---|
|  | 506 | 'title="'.__('Attach this file to entry').'" /> '. | 
|---|
|  | 507 | form::hidden('media_id',$f->media_id). | 
|---|
|  | 508 | form::hidden('post_id',$post_id). | 
|---|
|  | 509 | form::hidden('attach',1). | 
|---|
|  | 510 | $core->formNonce(). | 
|---|
|  | 511 | '</form>'; | 
|---|
|  | 512 | } | 
|---|
|  | 513 |  | 
|---|
|  | 514 | if ($popup && !$f->d) { | 
|---|
| [1855] | 515 | $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '. | 
|---|
| [0] | 516 | 'title="'.__('Insert this file into entry').'" /></a> '; | 
|---|
|  | 517 | } | 
|---|
|  | 518 |  | 
|---|
|  | 519 | if ($f->del) { | 
|---|
| [1855] | 520 | $act .= '<a class="media-remove" '. | 
|---|
| [0] | 521 | 'href="'.html::escapeURL($page_url).'&d='. | 
|---|
|  | 522 | rawurlencode($GLOBALS['d']).'&remove='.rawurlencode($f->basename).'">'. | 
|---|
| [747] | 523 | '<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>'; | 
|---|
| [0] | 524 | } | 
|---|
|  | 525 |  | 
|---|
| [1855] | 526 | $lst .= ($act != '' ? '<li class="media-action"> '.$act.'</li>' : ''); | 
|---|
| [0] | 527 |  | 
|---|
|  | 528 | if ($f->type == 'audio/mpeg3') { | 
|---|
| [1855] | 529 | $lst .= '<li>'.dcMedia::mp3player($f->file_url,'index.php?pf=player_mp3.swf').'</li>'; | 
|---|
| [0] | 530 | } | 
|---|
|  | 531 |  | 
|---|
| [1855] | 532 | $res .=   ($lst != '' ? '<ul>'.$lst.'</ul>' : ''); | 
|---|
|  | 533 |  | 
|---|
|  | 534 | $res .= '</div>'; | 
|---|
| [0] | 535 |  | 
|---|
|  | 536 | return $res; | 
|---|
|  | 537 | } | 
|---|
| [1452] | 538 | ?> | 
|---|