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