Changeset 3491:9aba899e5494 for admin/media.php
- Timestamp:
- 01/02/17 17:03:59 (9 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/media.php
r3440 r3491 385 385 $core->auth->user_prefs->addWorkspace('interface'); 386 386 $user_ui_enhanceduploader = $core->auth->user_prefs->interface->enhanceduploader; 387 388 $mediaItemLine = function($f,$i,$query,$table=false) 389 { 390 global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params, $link_type; 391 392 $fname = $f->basename; 393 $file = $query ? $f->relname : $f->basename; 394 395 $class = $table ? '' : 'media-item media-col-'.($i%2); 396 397 if ($f->d) { 398 // Folder 399 $link = $core->adminurl->get('admin.media',array_merge($page_url_params,array('d' => html::sanitizeURL($f->relname) ))); 400 if ($f->parent) { 401 $fname = '..'; 402 $class .= ' media-folder-up'; 403 } else { 404 $class .= ' media-folder'; 405 } 406 } else { 407 // Item 408 $params = new ArrayObject( 409 array( 410 'id' => $f->media_id, 411 'plugin_id' => $plugin_id, 412 'popup' => $popup, 413 'select' => $select, 414 'post_id' => $post_id, 415 'link_type' => $link_type 416 ) 417 ); 418 $core->callBehavior('adminMediaURLParams',$params); 419 $params = (array) $params; 420 $link = $core->adminurl->get( 421 'admin.media.item', $params 422 ); 423 } 424 425 $maxchars = 36; 426 if (strlen($fname) > $maxchars) { 427 $fname = substr($fname, 0, $maxchars-4).'...'.($f->d ? '' : files::getExtension($fname)); 428 } 429 430 $act = ''; 431 if (!$f->d) { 432 if ($select > 0) { 433 if ($select == 1) { 434 // Single media selection button 435 $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Select this file').'" '. 436 'title="'.__('Select this file').'" /></a> '; 437 } else { 438 // Multiple media selection checkbox 439 $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file); 440 } 441 } else { 442 // Item 443 if ($post_id) { 444 // Media attachment button 445 $act .= 446 '<a class="attach-media" title="'.__('Attach this file to entry').'" href="'. 447 $core->adminurl->get("admin.post.media", 448 array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1,'link_type' => $link_type)). 449 '">'. 450 '<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'. 451 '</a>'; 452 } 453 if ($popup) { 454 // Media insertion button 455 $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '. 456 'title="'.__('Insert this file into entry').'" /></a> '; 457 } 458 } 459 } 460 if ($f->del) { 461 // Deletion button or checkbox 462 if (!$popup && !$f->d) { 463 if ($select < 2) { 464 // Already set for multiple media selection 465 $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file); 466 } 467 } else { 468 $act .= '<a class="media-remove" '. 469 'href="'.html::escapeURL($page_url). 470 '&plugin_id='.$plugin_id. 471 '&d='.rawurlencode($GLOBALS['d']). 472 '&q='.rawurlencode($GLOBALS['q']). 473 '&remove='.rawurlencode($file).'">'. 474 '<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>'; 475 } 476 } 477 478 $file_type = explode('/',$f->type); 479 $class_open = 'class="modal-'.$file_type[0].'" '; 480 481 // Render markup 482 if (!$table) { 483 $res = 484 '<div class="'.$class.'"><p><a class="media-icon media-link" href="'.rawurldecode($link).'">'. 485 '<img src="'.$f->media_icon.'" alt="" />'.($query ? $file : $fname).'</a></p>'; 486 487 $lst = ''; 488 if (!$f->d) { 489 $lst .= 490 '<li>'.$f->media_title.'</li>'. 491 '<li>'. 492 $f->media_dtstr.' - '. 493 files::size($f->size).' - '. 494 '<a '.$class_open.'href="'.$f->file_url.'">'.__('open').'</a>'. 495 '</li>'; 496 } 497 $lst .= ($act != '' ? '<li class="media-action"> '.$act.'</li>' : ''); 498 499 // Show player if relevant 500 if ($file_type[0] == 'audio') 501 { 502 $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>'; 503 } 504 505 $res .= ($lst != '' ? '<ul>'.$lst.'</ul>' : ''); 506 $res .= '</div>'; 507 } else { 508 $res = '<tr class="'.$class.'">'; 509 $res .= '<td class="media-action">'.$act.'</td>'; 510 $res .= '<td class="maximal" scope="row"><a class="media-flag media-link" href="'.rawurldecode($link).'">'. 511 '<img src="'.$f->media_icon.'" alt="" />'.($query ? $file : $fname).'</a>'. 512 '<br />'.($f->d ? '' : $f->media_title).'</td>'; 513 $res .= '<td class="nowrap count">'.($f->d ? '' : $f->media_dtstr).'</td>'; 514 $res .= '<td class="nowrap count">'.($f->d ? '' : files::size($f->size).' - '. 515 '<a '.$class_open.'href="'.$f->file_url.'">'.__('open').'</a>').'</td>'; 516 $res .= '</tr>'; 517 } 518 519 return $res; 520 }; 387 521 388 522 if (!isset($core->media)) { … … 704 838 { 705 839 if ($items[$i]->d) { 706 $dlist .= mediaItemLine($items[$i],$j,$query,true);840 $dlist .= $mediaItemLine($items[$i],$j,$query,true); 707 841 } else { 708 $flist .= mediaItemLine($items[$i],$j,$query,true);842 $flist .= $mediaItemLine($items[$i],$j,$query,true); 709 843 } 710 844 } … … 720 854 { 721 855 if ($items[$i]->d) { 722 $dgroup .= mediaItemLine($items[$i],$j,$query);856 $dgroup .= $mediaItemLine($items[$i],$j,$query); 723 857 } else { 724 $fgroup .= mediaItemLine($items[$i],$j,$query);858 $fgroup .= $mediaItemLine($items[$i],$j,$query); 725 859 } 726 860 } … … 875 1009 876 1010 call_user_func($close_f); 877 878 /* ----------------------------------------------------- */879 function mediaItemLine($f,$i,$query,$table=false)880 {881 global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params, $link_type;882 883 $fname = $f->basename;884 $file = $query ? $f->relname : $f->basename;885 886 $class = $table ? '' : 'media-item media-col-'.($i%2);887 888 if ($f->d) {889 // Folder890 $link = $core->adminurl->get('admin.media',array_merge($page_url_params,array('d' => html::sanitizeURL($f->relname) )));891 if ($f->parent) {892 $fname = '..';893 $class .= ' media-folder-up';894 } else {895 $class .= ' media-folder';896 }897 } else {898 // Item899 $params = new ArrayObject(900 array(901 'id' => $f->media_id,902 'plugin_id' => $plugin_id,903 'popup' => $popup,904 'select' => $select,905 'post_id' => $post_id,906 'link_type' => $link_type907 )908 );909 $core->callBehavior('adminMediaURLParams',$params);910 $params = (array) $params;911 $link = $core->adminurl->get(912 'admin.media.item', $params913 );914 }915 916 $maxchars = 36;917 if (strlen($fname) > $maxchars) {918 $fname = substr($fname, 0, $maxchars-4).'...'.($f->d ? '' : files::getExtension($fname));919 }920 921 $act = '';922 if (!$f->d) {923 if ($select > 0) {924 if ($select == 1) {925 // Single media selection button926 $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Select this file').'" '.927 'title="'.__('Select this file').'" /></a> ';928 } else {929 // Multiple media selection checkbox930 $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file);931 }932 } else {933 // Item934 if ($post_id) {935 // Media attachment button936 $act .=937 '<a class="attach-media" title="'.__('Attach this file to entry').'" href="'.938 $core->adminurl->get("admin.post.media",939 array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1,'link_type' => $link_type)).940 '">'.941 '<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'.942 '</a>';943 }944 if ($popup) {945 // Media insertion button946 $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '.947 'title="'.__('Insert this file into entry').'" /></a> ';948 }949 }950 }951 if ($f->del) {952 // Deletion button or checkbox953 if (!$popup && !$f->d) {954 if ($select < 2) {955 // Already set for multiple media selection956 $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file);957 }958 } else {959 $act .= '<a class="media-remove" '.960 'href="'.html::escapeURL($page_url).961 '&plugin_id='.$plugin_id.962 '&d='.rawurlencode($GLOBALS['d']).963 '&q='.rawurlencode($GLOBALS['q']).964 '&remove='.rawurlencode($file).'">'.965 '<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>';966 }967 }968 969 $file_type = explode('/',$f->type);970 $class_open = 'class="modal-'.$file_type[0].'" ';971 972 // Render markup973 if (!$table) {974 $res =975 '<div class="'.$class.'"><p><a class="media-icon media-link" href="'.rawurldecode($link).'">'.976 '<img src="'.$f->media_icon.'" alt="" />'.($query ? $file : $fname).'</a></p>';977 978 $lst = '';979 if (!$f->d) {980 $lst .=981 '<li>'.$f->media_title.'</li>'.982 '<li>'.983 $f->media_dtstr.' - '.984 files::size($f->size).' - '.985 '<a '.$class_open.'href="'.$f->file_url.'">'.__('open').'</a>'.986 '</li>';987 }988 $lst .= ($act != '' ? '<li class="media-action"> '.$act.'</li>' : '');989 990 // Show player if relevant991 if ($file_type[0] == 'audio')992 {993 $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>';994 }995 996 $res .= ($lst != '' ? '<ul>'.$lst.'</ul>' : '');997 $res .= '</div>';998 } else {999 $res = '<tr class="'.$class.'">';1000 $res .= '<td class="media-action">'.$act.'</td>';1001 $res .= '<td class="maximal" scope="row"><a class="media-flag media-link" href="'.rawurldecode($link).'">'.1002 '<img src="'.$f->media_icon.'" alt="" />'.($query ? $file : $fname).'</a>'.1003 '<br />'.($f->d ? '' : $f->media_title).'</td>';1004 $res .= '<td class="nowrap count">'.($f->d ? '' : $f->media_dtstr).'</td>';1005 $res .= '<td class="nowrap count">'.($f->d ? '' : files::size($f->size).' - '.1006 '<a '.$class_open.'href="'.$f->file_url.'">'.__('open').'</a>').'</td>';1007 $res .= '</tr>';1008 }1009 1010 return $res;1011 }
Note: See TracChangeset
for help on using the changeset viewer.