[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 | |
---|
[2889] | 19 | $post_id = !empty($_REQUEST['post_id']) ? (integer) $_REQUEST['post_id'] : null; |
---|
[0] | 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; |
---|
[2751] | 30 | $plugin_id = isset($_REQUEST['plugin_id']) ? html::sanitizeURL($_REQUEST['plugin_id']) : ''; |
---|
[0] | 31 | $dir = null; |
---|
| 32 | |
---|
[3167] | 33 | // Attachement type if any |
---|
[3295] | 34 | $link_type = !empty($_REQUEST['link_type']) ? html::escapeHTML($_REQUEST['link_type']) : null; |
---|
[3167] | 35 | |
---|
[1912] | 36 | $page = !empty($_GET['page']) ? max(1,(integer) $_GET['page']) : 1; |
---|
[3340] | 37 | $nb_per_page = ((integer) $core->auth->user_prefs->interface->media_by_page ?: 30); |
---|
[0] | 38 | |
---|
| 39 | # We are on home not comming from media manager |
---|
| 40 | if ($d === null && isset($_SESSION['media_manager_dir'])) { |
---|
| 41 | # We get session information |
---|
| 42 | $d = $_SESSION['media_manager_dir']; |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | if (!isset($_GET['page']) && isset($_SESSION['media_manager_page'])) { |
---|
| 46 | $page = $_SESSION['media_manager_page']; |
---|
| 47 | } |
---|
| 48 | |
---|
[3100] | 49 | # We set session information about directory, page and display mode |
---|
[0] | 50 | if ($d) { |
---|
| 51 | $_SESSION['media_manager_dir'] = $d; |
---|
| 52 | } else { |
---|
| 53 | unset($_SESSION['media_manager_dir']); |
---|
| 54 | } |
---|
| 55 | if ($page != 1) { |
---|
| 56 | $_SESSION['media_manager_page'] = $page; |
---|
| 57 | } else { |
---|
| 58 | unset($_SESSION['media_manager_page']); |
---|
| 59 | } |
---|
| 60 | |
---|
[3153] | 61 | # Get query if any |
---|
[3295] | 62 | $q = isset($_REQUEST['q']) ? html::escapeHTML($_REQUEST['q']) : null; |
---|
[3099] | 63 | |
---|
[0] | 64 | # Sort combo |
---|
| 65 | $sort_combo = array( |
---|
| 66 | __('By names, in ascending order') => 'name-asc', |
---|
| 67 | __('By names, in descending order') => 'name-desc', |
---|
| 68 | __('By dates, in ascending order') => 'date-asc', |
---|
| 69 | __('By dates, in descending order') => 'date-desc' |
---|
[1161] | 70 | ); |
---|
[0] | 71 | |
---|
[3100] | 72 | if (!empty($_GET['file_mode'])) { |
---|
| 73 | $_SESSION['media_file_mode'] = $_GET['file_mode']; |
---|
| 74 | } |
---|
[3141] | 75 | $file_mode = !empty($_SESSION['media_file_mode']) ? $_SESSION['media_file_mode'] : 'grid'; |
---|
[3100] | 76 | |
---|
[3325] | 77 | $file_sort = null; |
---|
| 78 | if (!empty($_GET['file_sort'])) { |
---|
| 79 | $file_sort = $_SESSION['media_file_sort'] = $_GET['file_sort']; |
---|
| 80 | setcookie('dc_media_sort',json_encode($file_sort)); |
---|
| 81 | } elseif (isset($_COOKIE['dc_media_sort'])) { |
---|
| 82 | $file_sort = json_decode($_COOKIE['dc_media_sort']); |
---|
| 83 | } elseif (!empty($_SESSION['media_file_sort'])) { |
---|
| 84 | $file_sort = $_SESSION['media_file_sort']; |
---|
[0] | 85 | } |
---|
[3325] | 86 | $file_sort = in_array($file_sort,$sort_combo) ? $file_sort : null; |
---|
[3100] | 87 | |
---|
[2090] | 88 | $nb_per_page = !empty($_SESSION['nb_per_page']) ? (integer)$_SESSION['nb_per_page'] : $nb_per_page; |
---|
| 89 | if (!empty($_GET['nb_per_page']) && (integer)$_GET['nb_per_page'] > 0) { |
---|
| 90 | $nb_per_page = $_SESSION['nb_per_page'] = (integer)$_GET['nb_per_page']; |
---|
| 91 | } |
---|
[0] | 92 | |
---|
[2884] | 93 | $popup = (integer) !empty($_REQUEST['popup']); |
---|
[3153] | 94 | $select = !empty($_REQUEST['select']) ? (integer)$_REQUEST['select'] : 0; // 0 : none, 1 : single media, >1 : multiple medias |
---|
[0] | 95 | |
---|
[3167] | 96 | $page_url_params = new ArrayObject(array('popup' => $popup,'select' => $select,'post_id' => $post_id,'link_type' => $link_type)); |
---|
[2852] | 97 | if ($d) { |
---|
[2873] | 98 | $page_url_params['d'] = $d; |
---|
[2629] | 99 | } |
---|
[2852] | 100 | if ($plugin_id != '') { |
---|
[2873] | 101 | $page_url_params['plugin_id'] = $plugin_id; |
---|
[2852] | 102 | } |
---|
[3099] | 103 | if ($q) { |
---|
| 104 | $page_url_params['q'] = $q; |
---|
| 105 | } |
---|
[2852] | 106 | |
---|
| 107 | $core->callBehavior('adminMediaURLParams',$page_url_params); |
---|
| 108 | $page_url_params = (array) $page_url_params; |
---|
[2664] | 109 | |
---|
[0] | 110 | if ($popup) { |
---|
| 111 | $open_f = array('dcPage','openPopup'); |
---|
| 112 | $close_f = array('dcPage','closePopup'); |
---|
| 113 | } else { |
---|
| 114 | $open_f = array('dcPage','open'); |
---|
| 115 | $close_f = create_function('',"dcPage::helpBlock('core_media'); dcPage::close();"); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | $core_media_writable = false; |
---|
| 119 | try { |
---|
| 120 | $core->media = new dcMedia($core); |
---|
| 121 | if ($file_sort) { |
---|
| 122 | $core->media->setFileSort($file_sort); |
---|
| 123 | } |
---|
[3099] | 124 | $query = false; |
---|
| 125 | if ($q) { |
---|
| 126 | $query = $core->media->searchMedia($q); |
---|
| 127 | } |
---|
| 128 | if (!$query) { |
---|
[3136] | 129 | $try_d = $d; |
---|
| 130 | // Reset current dir |
---|
| 131 | $d = null; |
---|
| 132 | // Change directory (may cause an exception if directory doesn't exist) |
---|
| 133 | $core->media->chdir($try_d); |
---|
| 134 | // Restore current dir variable |
---|
| 135 | $d = $try_d; |
---|
[3099] | 136 | $core->media->getDir(); |
---|
| 137 | } else { |
---|
| 138 | $d = null; |
---|
| 139 | $core->media->chdir($d); |
---|
| 140 | } |
---|
[0] | 141 | $core_media_writable = $core->media->writable(); |
---|
| 142 | $dir =& $core->media->dir; |
---|
| 143 | if (!$core_media_writable) { |
---|
[1725] | 144 | // throw new Exception('you do not have sufficient permissions to write to this folder: '); |
---|
[0] | 145 | } |
---|
| 146 | } catch (Exception $e) { |
---|
| 147 | $core->error->add($e->getMessage()); |
---|
| 148 | } |
---|
| 149 | |
---|
[3501] | 150 | // Local functions |
---|
[240] | 151 | |
---|
[3491] | 152 | $mediaItemLine = function($f,$i,$query,$table=false) |
---|
| 153 | { |
---|
| 154 | global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params, $link_type; |
---|
| 155 | |
---|
| 156 | $fname = $f->basename; |
---|
| 157 | $file = $query ? $f->relname : $f->basename; |
---|
| 158 | |
---|
| 159 | $class = $table ? '' : 'media-item media-col-'.($i%2); |
---|
| 160 | |
---|
| 161 | if ($f->d) { |
---|
| 162 | // Folder |
---|
| 163 | $link = $core->adminurl->get('admin.media',array_merge($page_url_params,array('d' => html::sanitizeURL($f->relname) ))); |
---|
| 164 | if ($f->parent) { |
---|
| 165 | $fname = '..'; |
---|
| 166 | $class .= ' media-folder-up'; |
---|
| 167 | } else { |
---|
| 168 | $class .= ' media-folder'; |
---|
| 169 | } |
---|
| 170 | } else { |
---|
| 171 | // Item |
---|
| 172 | $params = new ArrayObject( |
---|
| 173 | array( |
---|
| 174 | 'id' => $f->media_id, |
---|
| 175 | 'plugin_id' => $plugin_id, |
---|
| 176 | 'popup' => $popup, |
---|
| 177 | 'select' => $select, |
---|
| 178 | 'post_id' => $post_id, |
---|
| 179 | 'link_type' => $link_type |
---|
| 180 | ) |
---|
| 181 | ); |
---|
| 182 | $core->callBehavior('adminMediaURLParams',$params); |
---|
| 183 | $params = (array) $params; |
---|
| 184 | $link = $core->adminurl->get( |
---|
| 185 | 'admin.media.item', $params |
---|
| 186 | ); |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | $maxchars = 36; |
---|
| 190 | if (strlen($fname) > $maxchars) { |
---|
| 191 | $fname = substr($fname, 0, $maxchars-4).'...'.($f->d ? '' : files::getExtension($fname)); |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | $act = ''; |
---|
| 195 | if (!$f->d) { |
---|
| 196 | if ($select > 0) { |
---|
| 197 | if ($select == 1) { |
---|
| 198 | // Single media selection button |
---|
| 199 | $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Select this file').'" '. |
---|
| 200 | 'title="'.__('Select this file').'" /></a> '; |
---|
| 201 | } else { |
---|
| 202 | // Multiple media selection checkbox |
---|
| 203 | $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file); |
---|
| 204 | } |
---|
| 205 | } else { |
---|
| 206 | // Item |
---|
| 207 | if ($post_id) { |
---|
| 208 | // Media attachment button |
---|
| 209 | $act .= |
---|
| 210 | '<a class="attach-media" title="'.__('Attach this file to entry').'" href="'. |
---|
| 211 | $core->adminurl->get("admin.post.media", |
---|
| 212 | array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1,'link_type' => $link_type)). |
---|
| 213 | '">'. |
---|
| 214 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'. |
---|
| 215 | '</a>'; |
---|
| 216 | } |
---|
| 217 | if ($popup) { |
---|
| 218 | // Media insertion button |
---|
| 219 | $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '. |
---|
| 220 | 'title="'.__('Insert this file into entry').'" /></a> '; |
---|
| 221 | } |
---|
| 222 | } |
---|
| 223 | } |
---|
| 224 | if ($f->del) { |
---|
| 225 | // Deletion button or checkbox |
---|
| 226 | if (!$popup && !$f->d) { |
---|
| 227 | if ($select < 2) { |
---|
| 228 | // Already set for multiple media selection |
---|
| 229 | $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file); |
---|
| 230 | } |
---|
| 231 | } else { |
---|
| 232 | $act .= '<a class="media-remove" '. |
---|
| 233 | 'href="'.html::escapeURL($page_url). |
---|
| 234 | '&plugin_id='.$plugin_id. |
---|
| 235 | '&d='.rawurlencode($GLOBALS['d']). |
---|
| 236 | '&q='.rawurlencode($GLOBALS['q']). |
---|
| 237 | '&remove='.rawurlencode($file).'">'. |
---|
| 238 | '<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>'; |
---|
| 239 | } |
---|
| 240 | } |
---|
| 241 | |
---|
| 242 | $file_type = explode('/',$f->type); |
---|
| 243 | $class_open = 'class="modal-'.$file_type[0].'" '; |
---|
| 244 | |
---|
| 245 | // Render markup |
---|
| 246 | if (!$table) { |
---|
| 247 | $res = |
---|
| 248 | '<div class="'.$class.'"><p><a class="media-icon media-link" href="'.rawurldecode($link).'">'. |
---|
| 249 | '<img src="'.$f->media_icon.'" alt="" />'.($query ? $file : $fname).'</a></p>'; |
---|
| 250 | |
---|
| 251 | $lst = ''; |
---|
| 252 | if (!$f->d) { |
---|
| 253 | $lst .= |
---|
| 254 | '<li>'.$f->media_title.'</li>'. |
---|
| 255 | '<li>'. |
---|
| 256 | $f->media_dtstr.' - '. |
---|
| 257 | files::size($f->size).' - '. |
---|
| 258 | '<a '.$class_open.'href="'.$f->file_url.'">'.__('open').'</a>'. |
---|
| 259 | '</li>'; |
---|
| 260 | } |
---|
| 261 | $lst .= ($act != '' ? '<li class="media-action"> '.$act.'</li>' : ''); |
---|
| 262 | |
---|
| 263 | // Show player if relevant |
---|
| 264 | if ($file_type[0] == 'audio') |
---|
| 265 | { |
---|
| 266 | $lst .= '<li>'.dcMedia::audioPlayer($f->type,$f->file_url,$core->adminurl->get("admin.home",array('pf' => 'player_mp3.swf')),null,$core->blog->settings->system->media_flash_fallback,false).'</li>'; |
---|
| 267 | } |
---|
| 268 | |
---|
| 269 | $res .= ($lst != '' ? '<ul>'.$lst.'</ul>' : ''); |
---|
| 270 | $res .= '</div>'; |
---|
| 271 | } else { |
---|
| 272 | $res = '<tr class="'.$class.'">'; |
---|
| 273 | $res .= '<td class="media-action">'.$act.'</td>'; |
---|
| 274 | $res .= '<td class="maximal" scope="row"><a class="media-flag media-link" href="'.rawurldecode($link).'">'. |
---|
| 275 | '<img src="'.$f->media_icon.'" alt="" />'.($query ? $file : $fname).'</a>'. |
---|
| 276 | '<br />'.($f->d ? '' : $f->media_title).'</td>'; |
---|
| 277 | $res .= '<td class="nowrap count">'.($f->d ? '' : $f->media_dtstr).'</td>'; |
---|
| 278 | $res .= '<td class="nowrap count">'.($f->d ? '' : files::size($f->size).' - '. |
---|
| 279 | '<a '.$class_open.'href="'.$f->file_url.'">'.__('open').'</a>').'</td>'; |
---|
| 280 | $res .= '</tr>'; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | return $res; |
---|
| 284 | }; |
---|
| 285 | |
---|
[3501] | 286 | // Actions |
---|
| 287 | |
---|
| 288 | # Zip download |
---|
| 289 | if (!empty($_GET['zipdl']) && $core->auth->check('media_admin',$core->blog->id)) |
---|
| 290 | { |
---|
| 291 | try |
---|
| 292 | { |
---|
| 293 | if (strpos(realpath($core->media->root.'/'.$d),realpath($core->media->root)) === 0) { |
---|
| 294 | // Media folder or one of it's sub-folder(s) |
---|
| 295 | @set_time_limit(300); |
---|
| 296 | $fp = fopen('php://output','wb'); |
---|
| 297 | $zip = new fileZip($fp); |
---|
| 298 | $zip->addExclusion('#(^|/).(.*?)_(m|s|sq|t).jpg$#'); |
---|
| 299 | $zip->addDirectory($core->media->root.'/'.$d,'',true); |
---|
| 300 | |
---|
| 301 | header('Content-Disposition: attachment;filename='.date('Y-m-d').'-'.$core->blog->id.'-'.($d ?: 'media').'.zip'); |
---|
| 302 | header('Content-Type: application/x-zip'); |
---|
| 303 | $zip->write(); |
---|
| 304 | unset($zip); |
---|
| 305 | exit; |
---|
| 306 | } else { |
---|
| 307 | $d = null; |
---|
| 308 | $core->media->chdir($d); |
---|
| 309 | throw new Exception(__('Not a valid directory')); |
---|
| 310 | } |
---|
| 311 | } |
---|
| 312 | catch (Exception $e) |
---|
| 313 | { |
---|
| 314 | $core->error->add($e->getMessage()); |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | |
---|
| 318 | # Cope with fav/unfav dir |
---|
| 319 | $fav_dirs = null; |
---|
| 320 | if (!empty($_GET['fav'])) { |
---|
| 321 | if (!$q) { // Ignore search results |
---|
| 322 | $fav_dir = rtrim($d,'/'); |
---|
| 323 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 324 | $nb_last_dirs = (integer)($core->auth->user_prefs->interface->media_nb_last_dirs); |
---|
| 325 | if ($nb_last_dirs > 0) { |
---|
| 326 | $fav_dirs = $core->auth->user_prefs->interface->media_fav_dirs; |
---|
| 327 | if (!is_array($fav_dirs)) { |
---|
| 328 | $fav_dirs = array(); |
---|
| 329 | } |
---|
| 330 | if (!in_array($fav_dir,$fav_dirs) && $_GET['fav'] == 'y') { |
---|
| 331 | // Add directory in favorites |
---|
| 332 | array_unshift($fav_dirs,$fav_dir); |
---|
| 333 | } elseif (in_array($fav_dir,$fav_dirs) && $_GET['fav'] == 'n') { |
---|
| 334 | // Remove directory from favorites |
---|
| 335 | unset($fav_dirs[array_search($fav_dir,$fav_dirs)]); |
---|
| 336 | } |
---|
| 337 | // Store new list |
---|
| 338 | $core->auth->user_prefs->interface->put('media_fav_dirs',$fav_dirs,'array'); |
---|
| 339 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
| 340 | } |
---|
| 341 | } |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | # Recent media dirs |
---|
| 345 | $last_dirs = null; |
---|
| 346 | if (!$q) { // Ignore search results |
---|
| 347 | $recent_dir = rtrim($d,'/'); |
---|
| 348 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 349 | $nb_last_dirs = (integer)($core->auth->user_prefs->interface->media_nb_last_dirs); |
---|
| 350 | if ($nb_last_dirs > 0) { |
---|
| 351 | $last_dirs = $core->auth->user_prefs->interface->media_last_dirs; |
---|
| 352 | if (!is_array($last_dirs)) { |
---|
| 353 | $last_dirs = array(); |
---|
| 354 | } |
---|
| 355 | if (!in_array($recent_dir,$last_dirs)) { |
---|
| 356 | // Add new dir at the top of the list |
---|
| 357 | array_unshift($last_dirs,$recent_dir); |
---|
| 358 | // Remove oldest dir(s) |
---|
| 359 | while (count($last_dirs) > $nb_last_dirs) { |
---|
| 360 | array_pop($last_dirs); |
---|
| 361 | } |
---|
| 362 | } else { |
---|
| 363 | // Move current dir at the top of list |
---|
| 364 | unset($last_dirs[array_search($recent_dir,$last_dirs)]); |
---|
| 365 | array_unshift($last_dirs,$recent_dir); |
---|
| 366 | } |
---|
| 367 | // Store new list |
---|
| 368 | $core->auth->user_prefs->interface->put('media_last_dirs',$last_dirs,'array'); |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | # New directory |
---|
| 373 | if ($dir && !empty($_POST['newdir'])) |
---|
| 374 | { |
---|
| 375 | try { |
---|
| 376 | $core->media->makeDir($_POST['newdir']); |
---|
| 377 | dcPage::addSuccessNotice(sprintf( |
---|
| 378 | __('Directory "%s" has been successfully created.'), |
---|
| 379 | html::escapeHTML($_POST['newdir'])) |
---|
| 380 | ); |
---|
| 381 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
| 382 | } catch (Exception $e) { |
---|
| 383 | $core->error->add($e->getMessage()); |
---|
| 384 | } |
---|
| 385 | } |
---|
| 386 | |
---|
| 387 | # Adding a file |
---|
| 388 | if ($dir && !empty($_FILES['upfile'])) { |
---|
| 389 | // only one file per request : @see option singleFileUploads in admin/js/jsUpload/jquery.fileupload |
---|
| 390 | $upfile = array('name' => $_FILES['upfile']['name'][0], |
---|
| 391 | 'type' => $_FILES['upfile']['type'][0], |
---|
| 392 | 'tmp_name' => $_FILES['upfile']['tmp_name'][0], |
---|
| 393 | 'error' => $_FILES['upfile']['error'][0], |
---|
| 394 | 'size' => $_FILES['upfile']['size'][0] |
---|
| 395 | ); |
---|
| 396 | |
---|
| 397 | if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
---|
| 398 | header('Content-type: application/json'); |
---|
| 399 | $message = array(); |
---|
| 400 | |
---|
| 401 | try { |
---|
| 402 | files::uploadStatus($upfile); |
---|
| 403 | $new_file_id = $core->media->uploadFile($upfile['tmp_name'], $upfile['name']); |
---|
| 404 | |
---|
| 405 | $message['files'][] = array( |
---|
| 406 | 'name' => $upfile['name'], |
---|
| 407 | 'size' => $upfile['size'], |
---|
| 408 | 'html' => $mediaItemLine($core->media->getFile($new_file_id),1,$query) |
---|
| 409 | ); |
---|
| 410 | } catch (Exception $e) { |
---|
| 411 | $message['files'][] = array('name' => $upfile['name'], |
---|
| 412 | 'size' => $upfile['size'], |
---|
| 413 | 'error' => $e->getMessage() |
---|
| 414 | ); |
---|
| 415 | } |
---|
| 416 | echo json_encode($message); |
---|
| 417 | exit(); |
---|
| 418 | } else { |
---|
| 419 | try { |
---|
| 420 | files::uploadStatus($upfile); |
---|
| 421 | |
---|
| 422 | $f_title = (isset($_POST['upfiletitle']) ? html::escapeHTML($_POST['upfiletitle']) : ''); |
---|
| 423 | $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false); |
---|
| 424 | |
---|
| 425 | $core->media->uploadFile($upfile['tmp_name'],$upfile['name'],$f_title,$f_private); |
---|
| 426 | |
---|
| 427 | dcPage::addSuccessNotice(__('Files have been successfully uploaded.')); |
---|
| 428 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
| 429 | } catch (Exception $e) { |
---|
| 430 | $core->error->add($e->getMessage()); |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | } |
---|
| 434 | |
---|
| 435 | # Removing items |
---|
| 436 | if ($dir && !empty($_POST['medias']) && !empty($_POST['delete_medias'])) { |
---|
| 437 | try { |
---|
| 438 | foreach ($_POST['medias'] as $media) { |
---|
| 439 | $core->media->removeItem(rawurldecode($media)); |
---|
| 440 | } |
---|
| 441 | dcPage::addSuccessNotice( |
---|
| 442 | sprintf(__('Successfully delete one media.', |
---|
| 443 | 'Successfully delete %d medias.', |
---|
| 444 | count($_POST['medias']) |
---|
| 445 | ), |
---|
| 446 | count($_POST['medias']) |
---|
| 447 | ) |
---|
| 448 | ); |
---|
| 449 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
| 450 | } catch (Exception $e) { |
---|
| 451 | $core->error->add($e->getMessage()); |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | |
---|
| 455 | # Removing item from popup only |
---|
| 456 | if ($dir && !empty($_POST['rmyes']) && !empty($_POST['remove'])) |
---|
| 457 | { |
---|
| 458 | $_POST['remove'] = rawurldecode($_POST['remove']); |
---|
| 459 | |
---|
| 460 | try { |
---|
| 461 | if (is_dir(path::real($core->media->getPwd().'/'.path::clean($_POST['remove'])))) { |
---|
| 462 | $msg = __('Directory has been successfully removed.'); |
---|
| 463 | } else { |
---|
| 464 | $msg = __('File has been successfully removed.'); |
---|
| 465 | } |
---|
| 466 | $core->media->removeItem($_POST['remove']); |
---|
| 467 | dcPage::addSuccessNotice($msg); |
---|
| 468 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
| 469 | } catch (Exception $e) { |
---|
| 470 | $core->error->add($e->getMessage()); |
---|
| 471 | } |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | # Rebuild directory |
---|
| 475 | if ($dir && $core->auth->isSuperAdmin() && !empty($_POST['rebuild'])) |
---|
| 476 | { |
---|
| 477 | try { |
---|
| 478 | $core->media->rebuild($d); |
---|
| 479 | |
---|
| 480 | dcPage::success(sprintf( |
---|
| 481 | __('Directory "%s" has been successfully rebuilt.'), |
---|
| 482 | html::escapeHTML($d)) |
---|
| 483 | ); |
---|
| 484 | $core->adminurl->redirect('admin.media',$page_url_params); |
---|
| 485 | } catch (Exception $e) { |
---|
| 486 | $core->error->add($e->getMessage()); |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | |
---|
| 490 | # DISPLAY confirm page for rmdir & rmfile |
---|
| 491 | if ($dir && !empty($_GET['remove']) && empty($_GET['noconfirm'])) |
---|
| 492 | { |
---|
| 493 | call_user_func($open_f,__('Media manager'),'', |
---|
| 494 | dcPage::breadcrumb( |
---|
| 495 | array( |
---|
| 496 | html::escapeHTML($core->blog->name) => '', |
---|
| 497 | __('Media manager') => '', |
---|
| 498 | __('confirm removal') => '' |
---|
| 499 | ), |
---|
| 500 | array('home_link' => !$popup) |
---|
| 501 | ) |
---|
| 502 | ); |
---|
| 503 | |
---|
| 504 | echo |
---|
| 505 | '<form action="'.html::escapeURL($core->adminurl->get('admin.media')).'" method="post">'. |
---|
| 506 | '<p>'.sprintf(__('Are you sure you want to remove %s?'), |
---|
| 507 | html::escapeHTML($_GET['remove'])).'</p>'. |
---|
| 508 | '<p><input type="submit" value="'.__('Cancel').'" /> '. |
---|
| 509 | ' <input type="submit" name="rmyes" value="'.__('Yes').'" />'. |
---|
| 510 | form::hidden('d',$d). |
---|
| 511 | form::hidden('q',$q). |
---|
| 512 | $core->adminurl->getHiddenFormFields('admin.media',$page_url_params). |
---|
| 513 | $core->formNonce(). |
---|
| 514 | form::hidden('remove',html::escapeHTML($_GET['remove'])).'</p>'. |
---|
| 515 | '</form>'; |
---|
| 516 | |
---|
| 517 | call_user_func($close_f); |
---|
| 518 | exit; |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | /* DISPLAY Main page |
---|
| 522 | -------------------------------------------------------- */ |
---|
| 523 | $core->auth->user_prefs->addWorkspace('interface'); |
---|
| 524 | $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; |
---|
| 525 | |
---|
[1358] | 526 | if (!isset($core->media)) { |
---|
| 527 | $breadcrumb = dcPage::breadcrumb( |
---|
| 528 | array( |
---|
| 529 | html::escapeHTML($core->blog->name) => '', |
---|
[2166] | 530 | __('Media manager') => '' |
---|
| 531 | ), |
---|
| 532 | array('home_link' => !$popup) |
---|
| 533 | ); |
---|
[1358] | 534 | } else { |
---|
[3136] | 535 | $home_params = $page_url_params; |
---|
| 536 | $home_params['d']=''; |
---|
| 537 | $home_params['q']=''; |
---|
[3099] | 538 | if ($query || (!$query && $q)) { |
---|
| 539 | $count = $query ? count($dir['files']) : 0; |
---|
[1358] | 540 | $breadcrumb = dcPage::breadcrumb( |
---|
| 541 | array( |
---|
| 542 | html::escapeHTML($core->blog->name) => '', |
---|
[3099] | 543 | __('Media manager') => $core->adminurl->get('admin.media',$home_params), |
---|
| 544 | __('Search:').' '.$q.' ('.sprintf(__('%s file found','%s files found',$count),$count).')' => '' |
---|
[2166] | 545 | ), |
---|
| 546 | array('home_link' => !$popup) |
---|
| 547 | ); |
---|
[1358] | 548 | } else { |
---|
[3099] | 549 | $temp_params = $page_url_params; |
---|
| 550 | $temp_params['d']='%s'; |
---|
| 551 | $bc_template = $core->adminurl->get('admin.media',$temp_params,'&',true); |
---|
| 552 | $breadcrumb_media = $core->media->breadCrumb($bc_template,'<span class="page-title">%s</span>'); |
---|
| 553 | if ($breadcrumb_media == '') { |
---|
| 554 | $breadcrumb = dcPage::breadcrumb( |
---|
| 555 | array( |
---|
| 556 | html::escapeHTML($core->blog->name) => '', |
---|
[3136] | 557 | __('Media manager') => $core->adminurl->get('admin.media',$home_params) |
---|
[3099] | 558 | ), |
---|
| 559 | array('home_link' => !$popup) |
---|
| 560 | ); |
---|
| 561 | } else { |
---|
| 562 | $home_params = $page_url_params; |
---|
| 563 | $home_params['d']=''; |
---|
[2852] | 564 | |
---|
[3099] | 565 | $breadcrumb = dcPage::breadcrumb( |
---|
| 566 | array( |
---|
| 567 | html::escapeHTML($core->blog->name) => '', |
---|
| 568 | __('Media manager') => $core->adminurl->get('admin.media',$home_params), |
---|
| 569 | $breadcrumb_media => '' |
---|
| 570 | ), |
---|
| 571 | array( |
---|
| 572 | 'home_link' => !$popup, |
---|
| 573 | 'hl' => false |
---|
| 574 | ) |
---|
| 575 | ); |
---|
| 576 | } |
---|
[1358] | 577 | } |
---|
| 578 | } |
---|
| 579 | |
---|
[3136] | 580 | // Recent media folders |
---|
| 581 | $last_folders = ''; |
---|
| 582 | $last_folders_item = ''; |
---|
[3245] | 583 | $fav_url = ''; |
---|
| 584 | $fav_img = ''; |
---|
| 585 | $fav_alt = ''; |
---|
[3136] | 586 | $nb_last_dirs = (integer)($core->auth->user_prefs->interface->media_nb_last_dirs); |
---|
| 587 | if ($nb_last_dirs > 0) { |
---|
[3245] | 588 | // Favorites directories |
---|
| 589 | $fav_dirs = $core->auth->user_prefs->interface->media_fav_dirs; |
---|
| 590 | if (!is_array($fav_dirs)) { |
---|
| 591 | $fav_dirs = array(); |
---|
| 592 | } |
---|
| 593 | foreach ($fav_dirs as $ld) { |
---|
| 594 | // Add favorites dirs on top of combo |
---|
| 595 | $ld_params = $page_url_params; |
---|
| 596 | $ld_params['d'] = $ld; |
---|
| 597 | $ld_params['q'] = ''; // Reset search |
---|
| 598 | $last_folders_item .= |
---|
| 599 | '<option value="'.urldecode($core->adminurl->get('admin.media',$ld_params)).'"'. |
---|
| 600 | ($ld == rtrim($d,'/') ? ' selected="selected"' : '').'>'. |
---|
| 601 | '/'.$ld.'</option>'."\n"; |
---|
| 602 | if ($ld == rtrim($d,'/')) { |
---|
| 603 | // Current directory is a favorite → button will un-fav |
---|
| 604 | $ld_params['fav'] = 'n'; |
---|
| 605 | $fav_url = urldecode($core->adminurl->get('admin.media',$ld_params)); |
---|
| 606 | unset($ld_params['fav']); |
---|
| 607 | $fav_img = 'images/fav-on.png'; |
---|
| 608 | $fav_alt = __('Remove this folder from your favorites'); |
---|
| 609 | } |
---|
| 610 | } |
---|
| 611 | if ($last_folders_item != '') { |
---|
| 612 | // add a separator between favorite dirs and recent dirs |
---|
| 613 | $last_folders_item .= '<option disabled>_________</option>'; |
---|
| 614 | } |
---|
| 615 | // Recent directories |
---|
[3136] | 616 | if (!is_array($last_dirs)) { |
---|
[3161] | 617 | $last_dirs = $core->auth->user_prefs->interface->media_last_dirs; |
---|
[3136] | 618 | } |
---|
| 619 | if (is_array($last_dirs)) { |
---|
| 620 | foreach ($last_dirs as $ld) { |
---|
[3245] | 621 | if (!in_array($ld,$fav_dirs)) { |
---|
| 622 | $ld_params = $page_url_params; |
---|
| 623 | $ld_params['d'] = $ld; |
---|
| 624 | $ld_params['q'] = ''; // Reset search |
---|
| 625 | $last_folders_item .= |
---|
| 626 | '<option value="'.urldecode($core->adminurl->get('admin.media',$ld_params)).'"'. |
---|
| 627 | ($ld == rtrim($d,'/') ? ' selected="selected"' : '').'>'. |
---|
| 628 | '/'.$ld.'</option>'."\n"; |
---|
| 629 | if ($ld == rtrim($d,'/')) { |
---|
| 630 | // Current directory is not a favorite → button will fav |
---|
| 631 | $ld_params['fav'] = 'y'; |
---|
| 632 | $fav_url = urldecode($core->adminurl->get('admin.media',$ld_params)); |
---|
| 633 | unset($ld_params['fav']); |
---|
| 634 | $fav_img = 'images/fav-off.png'; |
---|
| 635 | $fav_alt = __('Add this folder to your favorites'); |
---|
| 636 | } |
---|
| 637 | } |
---|
[3136] | 638 | } |
---|
[3245] | 639 | } |
---|
| 640 | if ($last_folders_item != '') { |
---|
| 641 | $last_folders = |
---|
| 642 | '<p class="media-recent hidden-if-no-js">'. |
---|
| 643 | '<label class="classic" for="switchfolder">'.__('Goto recent folder:').'</label> '. |
---|
| 644 | '<select name="switchfolder" id="switchfolder">'. |
---|
| 645 | $last_folders_item. |
---|
| 646 | '</select>'. |
---|
| 647 | '<script type="text/javascript">var urlmenu = document.getElementById(\'switchfolder\'); |
---|
| 648 | urlmenu.onchange = function() { window.location = this.options[this.selectedIndex].value; }; |
---|
| 649 | </script>'. |
---|
| 650 | ' <a id="media-fav-dir" href="'.$fav_url.'" title="'.$fav_alt.'"><img src="'.$fav_img.'" alt="'.$fav_alt.'" /></a>'. |
---|
| 651 | '</p>'; |
---|
[3136] | 652 | } |
---|
| 653 | } |
---|
| 654 | |
---|
[0] | 655 | call_user_func($open_f,__('Media manager'), |
---|
[3369] | 656 | dcPage::jsModal(). |
---|
[0] | 657 | dcPage::jsLoad('js/_media.js'). |
---|
[1358] | 658 | ($core_media_writable ? dcPage::jsUpload(array('d='.$d)) : ''), |
---|
| 659 | $breadcrumb |
---|
[240] | 660 | ); |
---|
[0] | 661 | |
---|
[2529] | 662 | if ($popup) { |
---|
| 663 | // Display notices |
---|
| 664 | echo dcPage::notices(); |
---|
| 665 | } |
---|
| 666 | |
---|
[1725] | 667 | if (!$core_media_writable) { |
---|
| 668 | dcPage::warning(__('You do not have sufficient permissions to write to this folder.')); |
---|
| 669 | } |
---|
| 670 | |
---|
[0] | 671 | if (!empty($_GET['mkdok'])) { |
---|
[1553] | 672 | dcPage::success(__('Directory has been successfully created.')); |
---|
[0] | 673 | } |
---|
| 674 | |
---|
| 675 | if (!empty($_GET['upok'])) { |
---|
[1553] | 676 | dcPage::success(__('Files have been successfully uploaded.')); |
---|
[0] | 677 | } |
---|
| 678 | |
---|
| 679 | if (!empty($_GET['rmfok'])) { |
---|
[1553] | 680 | dcPage::success(__('File has been successfully removed.')); |
---|
[0] | 681 | } |
---|
| 682 | |
---|
| 683 | if (!empty($_GET['rmdok'])) { |
---|
[1553] | 684 | dcPage::success(__('Directory has been successfully removed.')); |
---|
[0] | 685 | } |
---|
| 686 | |
---|
| 687 | if (!empty($_GET['rebuildok'])) { |
---|
[1553] | 688 | dcPage::success(__('Directory has been successfully rebuilt.')); |
---|
[0] | 689 | } |
---|
| 690 | |
---|
| 691 | if (!empty($_GET['unzipok'])) { |
---|
[1553] | 692 | dcPage::success(__('Zip file has been successfully extracted.')); |
---|
[0] | 693 | } |
---|
| 694 | |
---|
| 695 | if (!$dir) { |
---|
| 696 | call_user_func($close_f); |
---|
| 697 | exit; |
---|
| 698 | } |
---|
| 699 | |
---|
[3153] | 700 | if ($select) { |
---|
| 701 | // Select mode (popup or not) |
---|
| 702 | echo '<div class="'.($popup ? 'form-note ' : '').'info"><p>'; |
---|
| 703 | if ($select == 1) { |
---|
| 704 | echo sprintf(__('Select a file by clicking on %s'),'<img src="images/plus.png" alt="'.__('Select this file').'" />'); |
---|
| 705 | } else { |
---|
| 706 | echo sprintf(__('Select files and click on <strong>%s</strong> button'),__('Choose selected medias')); |
---|
| 707 | } |
---|
[3094] | 708 | if ($core_media_writable) { |
---|
| 709 | echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file')); |
---|
| 710 | } |
---|
| 711 | echo '</p></div>'; |
---|
[3153] | 712 | } else { |
---|
| 713 | if ($post_id) { |
---|
| 714 | echo '<div class="form-note info"><p>'.sprintf(__('Choose a file to attach to entry %s by clicking on %s'), |
---|
| 715 | '<a href="'.$core->getPostAdminURL($post_type,$post_id).'">'.html::escapeHTML($post_title).'</a>', |
---|
| 716 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />'); |
---|
| 717 | if ($core_media_writable) { |
---|
| 718 | echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file')); |
---|
| 719 | } |
---|
| 720 | echo '</p></div>'; |
---|
[3094] | 721 | } |
---|
[3153] | 722 | if ($popup) { |
---|
| 723 | echo '<div class="info"><p>'.sprintf(__('Choose a file to insert into entry by clicking on %s'), |
---|
| 724 | '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />'); |
---|
| 725 | if ($core_media_writable) { |
---|
| 726 | echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file')); |
---|
| 727 | } |
---|
| 728 | echo '</p></div>'; |
---|
| 729 | } |
---|
[0] | 730 | } |
---|
| 731 | |
---|
[2582] | 732 | // Remove hidden directories (unless DC_SHOW_HIDDEN_DIRS is set to true) |
---|
| 733 | if (!defined('DC_SHOW_HIDDEN_DIRS') || (DC_SHOW_HIDDEN_DIRS == false)) { |
---|
| 734 | for ($i = count($dir['dirs']) - 1; $i >= 0; $i--) { |
---|
| 735 | if ($dir['dirs'][$i]->d) { |
---|
| 736 | if (strpos($dir['dirs'][$i]->relname,'.') !== false) { |
---|
| 737 | unset($dir['dirs'][$i]); |
---|
| 738 | } |
---|
| 739 | } |
---|
| 740 | } |
---|
| 741 | } |
---|
[0] | 742 | $items = array_values(array_merge($dir['dirs'],$dir['files'])); |
---|
[2202] | 743 | |
---|
[2720] | 744 | $fmt_form_media = '<form action="'.$core->adminurl->get("admin.media").'" method="post" id="form-medias">'. |
---|
[2202] | 745 | '<div class="files-group">%s</div>'. |
---|
[3099] | 746 | '<p class="hidden">'.$core->formNonce(). |
---|
| 747 | form::hidden(array('d'),$d). |
---|
| 748 | form::hidden(array('q'),$q). |
---|
[3212] | 749 | form::hidden(array('popup'),$popup). |
---|
| 750 | form::hidden(array('select'),$select). |
---|
[3099] | 751 | form::hidden(array('plugin_id'),$plugin_id). |
---|
[3212] | 752 | form::hidden(array('post_id'),$post_id). |
---|
| 753 | form::hidden(array('link_type'),$link_type). |
---|
[3099] | 754 | '</p>'; |
---|
[2204] | 755 | |
---|
[3153] | 756 | if (!$popup || $select > 1) { |
---|
| 757 | // Checkboxes and action |
---|
[2204] | 758 | $fmt_form_media .= |
---|
[3153] | 759 | '<div class="'.(!$popup ? 'medias-delete' : '').' '.($select > 1 ? 'medias-select' : '').'">'. |
---|
[2263] | 760 | '<p class="checkboxes-helpers"></p>'. |
---|
[3153] | 761 | '<p>'; |
---|
| 762 | if ($select > 1) { |
---|
| 763 | $fmt_form_media .= |
---|
| 764 | '<input type="submit" class="select" id="select_medias" name="select_medias" value="'.__('Choose selected medias').'"/> '; |
---|
| 765 | } |
---|
| 766 | if (!$popup) { |
---|
| 767 | $fmt_form_media .= |
---|
| 768 | '<input type="submit" class="delete" id="delete_medias" name="delete_medias" value="'.__('Remove selected medias').'"/>'; |
---|
| 769 | } |
---|
| 770 | $fmt_form_media .= |
---|
| 771 | '</p>'. |
---|
[2204] | 772 | '</div>'; |
---|
| 773 | } |
---|
| 774 | $fmt_form_media .= |
---|
[2202] | 775 | '</form>'; |
---|
| 776 | |
---|
[1160] | 777 | echo '<div class="media-list">'; |
---|
[3136] | 778 | echo $last_folders; |
---|
[3140] | 779 | echo // Search form |
---|
| 780 | '<form action="'.$core->adminurl->get("admin.media").'" method="get" id="search-form">'. |
---|
| 781 | '<p><label for="search" class="classic">'.__('Search:').'</label> '. |
---|
| 782 | form::field('q',20,255,$q).' '. |
---|
| 783 | '<input type="submit" value="'.__('OK').'" />'.' '. |
---|
| 784 | '<span class="form-note">'.__('Will search into media filename (including path), title and description').'</span>'. |
---|
| 785 | form::hidden(array('popup'),$popup). |
---|
[3153] | 786 | form::hidden(array('select'),$select). |
---|
[3140] | 787 | form::hidden(array('plugin_id'),$plugin_id). |
---|
| 788 | form::hidden(array('post_id'),$post_id). |
---|
[3212] | 789 | form::hidden(array('link_type'),$link_type). |
---|
[3140] | 790 | '</p>'. |
---|
| 791 | '</form>'; |
---|
[3136] | 792 | |
---|
[0] | 793 | if (count($items) == 0) |
---|
| 794 | { |
---|
[2512] | 795 | echo |
---|
[1982] | 796 | '<p>'.__('No file.').'</p>'. |
---|
[2202] | 797 | sprintf($fmt_form_media,'',' hide'); // need for jsUpload to append new media |
---|
[0] | 798 | } |
---|
| 799 | else |
---|
| 800 | { |
---|
[1926] | 801 | $pager = new dcPager($page,count($items),$nb_per_page,10); |
---|
[2512] | 802 | |
---|
[0] | 803 | echo |
---|
[2720] | 804 | '<form action="'.$core->adminurl->get("admin.media").'" method="get" id="filters-form">'. |
---|
[3101] | 805 | '<span class="media-file-mode">'. |
---|
| 806 | '<a href="'.$core->adminurl->get("admin.media",array_merge($page_url_params,array('file_mode' => 'grid'))).'" title="'.__('Grid display mode').'">'. |
---|
| 807 | '<img src="images/grid-'.($file_mode == 'grid' ? 'on' : 'off').'.png" alt="'.__('Grid display mode').'" />'. |
---|
| 808 | '</a>'. |
---|
| 809 | '<a href="'.$core->adminurl->get("admin.media",array_merge($page_url_params,array('file_mode' => 'list'))).'" title="'.__('List display mode').'">'. |
---|
| 810 | '<img src="images/list-'.($file_mode == 'list' ? 'on' : 'off').'.png" alt="'.__('List display mode').'" />'. |
---|
| 811 | '</a>'. |
---|
| 812 | '</span>'. |
---|
[3100] | 813 | '<p class="three-boxes"><label for="file_sort" class="classic">'.__('Sort files:').'</label> '. |
---|
[2224] | 814 | form::combo('file_sort',$sort_combo,$file_sort).'</p>'. |
---|
[3100] | 815 | '<p class="three-boxes"><label for="nb_per_page" class="classic">'.__('Number of elements displayed per page:').'</label> '. |
---|
[2090] | 816 | form::field('nb_per_page',5,3,(integer) $nb_per_page).' '. |
---|
| 817 | '<input type="submit" value="'.__('OK').'" />'. |
---|
[0] | 818 | form::hidden(array('popup'),$popup). |
---|
[3153] | 819 | form::hidden(array('select'),$select). |
---|
[2751] | 820 | form::hidden(array('plugin_id'),$plugin_id). |
---|
[0] | 821 | form::hidden(array('post_id'),$post_id). |
---|
[3212] | 822 | form::hidden(array('link_type'),$link_type). |
---|
[3099] | 823 | form::hidden(array('q'),$q). |
---|
[2090] | 824 | '</p>'. |
---|
[0] | 825 | '</form>'. |
---|
[1926] | 826 | $pager->getLinks(); |
---|
[1855] | 827 | |
---|
[3100] | 828 | if ($file_mode == 'list') { |
---|
| 829 | $table = |
---|
| 830 | '<div class="table-outer">'. |
---|
| 831 | '<table>'. |
---|
| 832 | '<caption class="hidden">'.__('Media list').'</caption>'. |
---|
| 833 | '<tr>'. |
---|
| 834 | '<th colspan="2" class="first">'.__('Name').'</th>'. |
---|
| 835 | '<th scope="col">'.__('Date').'</th>'. |
---|
| 836 | '<th scope="col">'.__('Size').'</th>'. |
---|
| 837 | '</tr>'; |
---|
| 838 | |
---|
| 839 | $dlist = ''; |
---|
| 840 | $flist = ''; |
---|
| 841 | for ($i=$pager->index_start, $j=0; $i<=$pager->index_end; $i++,$j++) |
---|
| 842 | { |
---|
| 843 | if ($items[$i]->d) { |
---|
[3491] | 844 | $dlist .= $mediaItemLine($items[$i],$j,$query,true); |
---|
[3100] | 845 | } else { |
---|
[3491] | 846 | $flist .= $mediaItemLine($items[$i],$j,$query,true); |
---|
[3100] | 847 | } |
---|
[1855] | 848 | } |
---|
[3100] | 849 | $table .= $dlist.$flist; |
---|
| 850 | |
---|
| 851 | $table .= |
---|
| 852 | '</table></div>'; |
---|
| 853 | echo sprintf($fmt_form_media,$table,''); |
---|
| 854 | } else { |
---|
| 855 | $dgroup = ''; |
---|
| 856 | $fgroup = ''; |
---|
| 857 | for ($i=$pager->index_start, $j=0; $i<=$pager->index_end; $i++,$j++) |
---|
| 858 | { |
---|
| 859 | if ($items[$i]->d) { |
---|
[3491] | 860 | $dgroup .= $mediaItemLine($items[$i],$j,$query); |
---|
[3100] | 861 | } else { |
---|
[3491] | 862 | $fgroup .= $mediaItemLine($items[$i],$j,$query); |
---|
[3100] | 863 | } |
---|
| 864 | } |
---|
| 865 | echo |
---|
| 866 | ($dgroup != '' ? '<div class="folders-group">'.$dgroup.'</div>' : ''). |
---|
| 867 | sprintf($fmt_form_media,$fgroup,''); |
---|
[0] | 868 | } |
---|
[2512] | 869 | |
---|
[1926] | 870 | echo $pager->getLinks(); |
---|
[0] | 871 | } |
---|
[1162] | 872 | if (!isset($pager)) { |
---|
| 873 | echo |
---|
| 874 | '<p class="clear"></p>'; |
---|
| 875 | } |
---|
[1160] | 876 | echo |
---|
[1161] | 877 | '</div>'; |
---|
[1144] | 878 | |
---|
[2649] | 879 | $core_media_archivable = $core->auth->check('media_admin',$core->blog->id) && |
---|
| 880 | !(count($items) == 0 || (count($items) == 1 && $items[0]->parent)); |
---|
| 881 | |
---|
[3099] | 882 | if ((!$query) && ($core_media_writable || $core_media_archivable)) { |
---|
[1979] | 883 | echo |
---|
| 884 | '<div class="vertical-separator">'. |
---|
[2512] | 885 | '<h3 class="out-of-screen-if-js">'.sprintf(__('In %s:'),($d == '' ? '“'.__('Media manager').'”' : '“'.$d.'”')).'</h3>'; |
---|
[1979] | 886 | } |
---|
| 887 | |
---|
[3099] | 888 | if ((!$query) && ($core_media_writable || $core_media_archivable)) { |
---|
[2512] | 889 | echo |
---|
[1979] | 890 | '<div class="two-boxes odd">'; |
---|
| 891 | |
---|
| 892 | # Create directory |
---|
| 893 | if ($core_media_writable) |
---|
| 894 | { |
---|
| 895 | echo |
---|
[2852] | 896 | '<form action="'.$core->adminurl->getBase('admin.media').'" method="post" class="fieldset">'. |
---|
[1979] | 897 | '<div id="new-dir-f">'. |
---|
| 898 | '<h4 class="pretty-title">'.__('Create new directory').'</h4>'. |
---|
| 899 | $core->formNonce(). |
---|
| 900 | '<p><label for="newdir">'.__('Directory Name:').'</label>'. |
---|
| 901 | form::field(array('newdir','newdir'),35,255).'</p>'. |
---|
| 902 | '<p><input type="submit" value="'.__('Create').'" />'. |
---|
[2852] | 903 | $core->adminurl->getHiddenFormFields('admin.media',$page_url_params). |
---|
| 904 | '</p>'. |
---|
[1979] | 905 | '</div>'. |
---|
| 906 | '</form>'; |
---|
| 907 | } |
---|
| 908 | |
---|
| 909 | # Get zip directory |
---|
[2263] | 910 | if ($core_media_archivable && !$popup) |
---|
[1979] | 911 | { |
---|
| 912 | echo |
---|
| 913 | '<div class="fieldset">'. |
---|
| 914 | '<h4 class="pretty-title">'.sprintf(__('Backup content of %s'),($d == '' ? '“'.__('Media manager').'”' : '“'.$d.'”')).'</h4>'. |
---|
[2852] | 915 | '<p><a class="button submit" href="'.$core->adminurl->get('admin.media', |
---|
| 916 | array_merge($page_url_params,array('zipdl' => 1))).'">'.__('Download zip file').'</a></p>'. |
---|
[1979] | 917 | '</div>'; |
---|
| 918 | } |
---|
| 919 | |
---|
[2512] | 920 | echo |
---|
[1979] | 921 | '</div>'; |
---|
| 922 | } |
---|
| 923 | |
---|
[3099] | 924 | if (!$query && $core_media_writable) |
---|
[0] | 925 | { |
---|
[1979] | 926 | echo |
---|
[2512] | 927 | '<div class="two-boxes fieldset even">'; |
---|
[1161] | 928 | if ($user_ui_enhanceduploader) { |
---|
| 929 | echo |
---|
[1681] | 930 | '<div class="enhanced_uploader">'; |
---|
[1161] | 931 | } else { |
---|
| 932 | echo |
---|
[1681] | 933 | '<div>'; |
---|
[1161] | 934 | } |
---|
[1159] | 935 | |
---|
[1161] | 936 | echo |
---|
[1681] | 937 | '<h4>'.__('Add files').'</h4>'. |
---|
[3398] | 938 | '<p class="more-info">'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'. |
---|
[3165] | 939 | '<form id="fileupload" action="'.html::escapeURL($core->adminurl->get('admin.media',$page_url_params)).'" method="post" enctype="multipart/form-data" aria-disabled="false">'. |
---|
[1450] | 940 | '<p>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE). |
---|
| 941 | $core->formNonce().'</p>'. |
---|
| 942 | '<div class="fileupload-ctrl"><p class="queue-message"></p><ul class="files"></ul></div>'; |
---|
[1159] | 943 | |
---|
[1161] | 944 | echo |
---|
[1519] | 945 | '<div class="fileupload-buttonbar clear">'; |
---|
[1162] | 946 | |
---|
| 947 | echo |
---|
[1450] | 948 | '<p><label for="upfile">'.'<span class="add-label one-file">'.__('Choose file').'</span>'.'</label>'. |
---|
[1852] | 949 | '<button class="button choose_files">'.__('Choose files').'</button>'. |
---|
[3165] | 950 | '<input type="file" id="upfile" name="upfile[]"'.($user_ui_enhanceduploader?' multiple="mutiple"':'').' data-url="'.html::escapeURL($core->adminurl->get('admin.media',$page_url_params)).'" /></p>'; |
---|
[1159] | 951 | |
---|
[1161] | 952 | echo |
---|
[1854] | 953 | '<p class="max-sizer form-note"> '.__('Maximum file size allowed:').' '.files::size(DC_MAX_UPLOAD_SIZE).'</p>'; |
---|
| 954 | |
---|
| 955 | echo |
---|
[1450] | 956 | '<p class="one-file"><label for="upfiletitle">'.__('Title:').'</label>'.form::field(array('upfiletitle','upfiletitle'),35,255).'</p>'. |
---|
[1452] | 957 | '<p class="one-file"><label for="upfilepriv" class="classic">'.__('Private').'</label> '. |
---|
[1450] | 958 | form::checkbox(array('upfilepriv','upfilepriv'),1).'</p>'; |
---|
[1159] | 959 | |
---|
[1161] | 960 | if (!$user_ui_enhanceduploader) { |
---|
| 961 | echo |
---|
| 962 | '<p class="one-file form-help info">'.__('To send several files at the same time, you can activate the enhanced uploader in'). |
---|
[2720] | 963 | ' <a href="'.$core->adminurl->get("admin.user.preferences",array('tab' => 'user-options')).'">'.__('My preferences').'</a></p>'; |
---|
[1161] | 964 | } |
---|
[1159] | 965 | |
---|
[1161] | 966 | echo |
---|
[1526] | 967 | '<p class="clear"><button class="button clean">'.__('Refresh').'</button>'. |
---|
[1183] | 968 | '<input class="button cancel one-file" type="reset" value="'.__('Clear all').'"/>'. |
---|
[1450] | 969 | '<input class="button start" type="submit" value="'.__('Upload').'"/></p>'. |
---|
[1161] | 970 | '</div>'; |
---|
[1159] | 971 | |
---|
[1161] | 972 | echo |
---|
[3187] | 973 | '<p style="clear:both;">'. |
---|
[3212] | 974 | form::hidden(array('d'),$d). |
---|
| 975 | form::hidden(array('q'),$q). |
---|
| 976 | form::hidden(array('popup'),$popup). |
---|
| 977 | form::hidden(array('select'),$select). |
---|
| 978 | form::hidden(array('plugin_id'),$plugin_id). |
---|
| 979 | form::hidden(array('post_id'),$post_id). |
---|
| 980 | form::hidden(array('link_type'),$link_type). |
---|
[3187] | 981 | '</p>'. |
---|
[1161] | 982 | '</form>'. |
---|
[1681] | 983 | '</div>'. |
---|
| 984 | '</div>'; |
---|
[1725] | 985 | } |
---|
[1450] | 986 | |
---|
[0] | 987 | # Empty remove form (for javascript actions) |
---|
| 988 | echo |
---|
[3165] | 989 | '<form id="media-remove-hide" action="'.html::escapeURL($core->adminurl->get('admin.media',$page_url_params)).'" method="post" class="hidden">'. |
---|
[1681] | 990 | '<div>'. |
---|
[3212] | 991 | form::hidden('rmyes',1). |
---|
| 992 | form::hidden('d',html::escapeHTML($d)). |
---|
[3099] | 993 | form::hidden(array('q'),$q). |
---|
[3212] | 994 | form::hidden(array('popup'),$popup). |
---|
| 995 | form::hidden(array('select'),$select). |
---|
| 996 | form::hidden(array('plugin_id'),$plugin_id). |
---|
| 997 | form::hidden(array('post_id'),$post_id). |
---|
| 998 | form::hidden(array('link_type'),$link_type). |
---|
| 999 | form::hidden('remove',''). |
---|
[0] | 1000 | $core->formNonce(). |
---|
[1681] | 1001 | '</div>'. |
---|
| 1002 | '</form>'; |
---|
[0] | 1003 | |
---|
[3099] | 1004 | if ((!$query) && ($core_media_writable || $core_media_archivable)) { |
---|
[2512] | 1005 | echo |
---|
[1979] | 1006 | '</div>'; |
---|
| 1007 | } |
---|
| 1008 | |
---|
[2224] | 1009 | if (!$popup) { |
---|
| 1010 | echo '<div class="info"><p>'.sprintf(__('Current settings for medias and images are defined in %s'), |
---|
[2720] | 1011 | '<a href="'.$core->adminurl->get("admin.blog.pref").'#medias-settings">'.__('Blog parameters').'</a>').'</p></div>'; |
---|
[2224] | 1012 | } |
---|
| 1013 | |
---|
[0] | 1014 | call_user_func($close_f); |
---|