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