Dotclear

Changeset 3153:942a906c0986


Ignore:
Timestamp:
01/05/16 06:57:46 (10 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Children:
3154:5a75530f30db, 3155:c27a63c514e9
Message:

Media selection mode (single or multiple), first step

Location:
admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_media.js

    r3116 r3153  
    138138     }); 
    139139 
    140      $('#form-medias').submit(function() { 
    141           var count_checked = $('input[name="medias[]"]:checked', $(this)).length; 
    142           if (count_checked==0) { 
     140     $('#form-medias #delete_medias').click(function(e) { 
     141          var count_checked = $('input[name="medias[]"]:checked', $('#form-medias')).length; 
     142          if (count_checked == 0) { 
     143               e.preventDefault(); 
    143144               return false; 
    144145          } 
    145  
    146146          return window.confirm(dotclear.msg.confirm_delete_medias.replace('%d',count_checked)); 
    147147     }); 
  • admin/media.php

    r3152 r3153  
    5656} 
    5757 
    58 # Get query in any 
     58# Get query if any 
    5959$q = isset($_REQUEST['q']) ? $_REQUEST['q'] : null; 
    6060 
     
    8383 
    8484$popup = (integer) !empty($_REQUEST['popup']); 
    85  
    86 $page_url_params = new ArrayObject(array('popup' => $popup,'post_id' => $post_id)); 
     85$select = !empty($_REQUEST['select']) ? (integer)$_REQUEST['select'] : 0;  // 0 : none, 1 : single media, >1 : multiple medias 
     86 
     87$page_url_params = new ArrayObject(array('popup' => $popup,'select' => $select,'post_id' => $post_id)); 
    8788if ($d) { 
    8889     $page_url_params['d'] = $d; 
     
    474475} 
    475476 
    476 if ($post_id) { 
    477      echo '<div class="form-note info"><p>'.sprintf(__('Choose a file to attach to entry %s by clicking on %s'), 
    478           '<a href="'.$core->getPostAdminURL($post_type,$post_id).'">'.html::escapeHTML($post_title).'</a>', 
    479           '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />'); 
     477if ($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     } 
    480485     if ($core_media_writable) { 
    481486          echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file')); 
    482487     } 
    483488     echo '</p></div>'; 
    484 } 
    485 if ($popup) { 
    486      echo '<div class="info"><p>'.sprintf(__('Choose a file to insert into entry by clicking on %s'), 
    487           '<img src="images/plus.png" alt="'.__('Attach this file to entry').'" />'); 
    488      if ($core_media_writable) { 
    489           echo ' '.__('or').' '.sprintf('<a href="#fileupload">%s</a>',__('upload a new file')); 
    490      } 
    491      echo '</p></div>'; 
     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>'; 
     498     } 
     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     } 
    492507} 
    493508 
     
    512527     '</p>'; 
    513528 
    514 if (!$popup) { 
     529if (!$popup || $select > 1) { 
     530     // Checkboxes and action 
    515531     $fmt_form_media .= 
    516      '<div class="medias-delete%s">'. 
     532     '<div class="'.(!$popup ? 'medias-delete' : '').' '.($select > 1 ? 'medias-select' : '').'">'. 
    517533     '<p class="checkboxes-helpers"></p>'. 
    518      '<p><input type="submit" class="delete" name="delete_medias" value="'.__('Remove selected medias').'"/></p>'. 
     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>'. 
    519545     '</div>'; 
    520546} 
     
    531557     '<span class="form-note">'.__('Will search into media filename (including path), title and description').'</span>'. 
    532558     form::hidden(array('popup'),$popup). 
     559     form::hidden(array('select'),$select). 
    533560     form::hidden(array('plugin_id'),$plugin_id). 
    534561     form::hidden(array('post_id'),$post_id). 
     
    562589     '<input type="submit" value="'.__('OK').'" />'. 
    563590     form::hidden(array('popup'),$popup). 
     591     form::hidden(array('select'),$select). 
    564592     form::hidden(array('plugin_id'),$plugin_id). 
    565593     form::hidden(array('post_id'),$post_id). 
     
    746774function mediaItemLine($f,$i,$query,$table=false) 
    747775{ 
    748      global $core, $page_url, $popup, $post_id, $plugin_id,$page_url_params; 
     776     global $core, $page_url, $popup, $select, $post_id, $plugin_id, $page_url_params; 
    749777 
    750778     $fname = $f->basename; 
     
    754782 
    755783     if ($f->d) { 
    756  
     784          // Folder 
    757785          $link = $core->adminurl->get('admin.media',array_merge($page_url_params,array('d' => html::sanitizeURL($f->relname) ))); 
    758786          if ($f->parent) { 
     
    763791          } 
    764792     } else { 
     793          // Item 
    765794          $params = new ArrayObject( 
    766795               array( 
     
    768797                    'plugin_id' => $plugin_id, 
    769798                    'popup' => $popup, 
     799                    'select' => $select, 
    770800                    'post_id' => $post_id 
    771801               ) 
     
    784814 
    785815     $act = ''; 
    786      if ($post_id && !$f->d) { 
    787           // Media attachment button 
    788           $act .= 
    789           '<a class="attach-media" title="'.__('Attach this file to entry').'" href="'. 
    790           $core->adminurl->get("admin.post.media", array('media_id' => $f->media_id, 'post_id' => $post_id,'attach' => 1)). 
    791           '">'. 
    792           '<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'. 
    793           '</a>'; 
    794      } 
    795      if ($popup && !$f->d) { 
    796           // Media insertion button 
    797           $act .= '<a href="'.$link.'"><img src="images/plus.png" alt="'.__('Insert this file into entry').'" '. 
    798           'title="'.__('Insert this file into entry').'" /></a> '; 
     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          } 
    799843     } 
    800844     if ($f->del) { 
    801845          // Deletion button or checkbox 
    802846          if (!$popup && !$f->d) { 
    803                $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file); 
     847               if ($select < 2) { 
     848                    // Already set for multiple media selection 
     849                    $act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file); 
     850               } 
    804851          } else { 
    805852               $act .= '<a class="media-remove" '. 
     
    813860     } 
    814861 
     862     // Render markup 
    815863     if (!$table) { 
    816864          $res = 
  • admin/media_item.php

    r3138 r3153  
    2929$file = null; 
    3030$popup = (integer) !empty($_REQUEST['popup']); 
     31$select = !empty($_REQUEST['select']) ? (integer)$_REQUEST['select'] : 0;  // 0 : none, 1 : single media, >1 : multiple medias 
    3132$plugin_id = isset($_REQUEST['plugin_id']) ? html::sanitizeURL($_REQUEST['plugin_id']) : ''; 
    32 $page_url_params = array('popup' => $popup,'post_id' => $post_id); 
    33 $media_page_url_params = array('popup' => $popup,'post_id' => $post_id); 
     33$page_url_params = array('popup' => $popup,'select' => $select,'post_id' => $post_id); 
     34$media_page_url_params = array('popup' => $popup,'select' => $select,'post_id' => $post_id); 
    3435 
    3536if ($plugin_id != '') { 
     
    280281$file_type = explode('/',$file->type); 
    281282 
     283# Selection mode 
     284if ($select) { 
     285     // Let user choose thumbnail size if image 
     286     $media_desc = $file->media_title; 
     287 
     288     echo 
     289     '<div id="media-select" class="multi-part" title="'.__('Select media item').'">'. 
     290     '<h3>'.__('Select media item').'</h3>'. 
     291     '<form id="media-select-form" action="" method="get">'; 
     292 
     293     $media_img_default_size = $core->blog->settings->system->media_img_default_size; 
     294     if ($media_img_default_size == '') { 
     295          $media_img_default_size = 'm'; 
     296     } 
     297     $media_img_default_alignment = $core->blog->settings->system->media_img_default_alignment; 
     298     if ($media_img_default_alignment == '') { 
     299          $media_img_default_alignment = 'none'; 
     300     } 
     301     $media_img_default_link = (boolean)$core->blog->settings->system->media_img_default_link; 
     302 
     303     if ($file->media_type == 'image') 
     304     { 
     305          $media_type = 'image'; 
     306          $media_desc = dcGetImageTitle($file, 
     307               $core->blog->settings->system->media_img_title_pattern, 
     308               $core->blog->settings->system->media_img_use_dto_first, 
     309               $core->blog->settings->system->media_img_no_date_alone); 
     310          if ($media_desc == $file->basename) { 
     311               $media_desc = ''; 
     312          } 
     313 
     314          echo 
     315          '<h3>'.__('Image size:').'</h3> '; 
     316 
     317          $s_checked = false; 
     318          echo '<p>'; 
     319          foreach (array_reverse($file->media_thumb) as $s => $v) { 
     320               $s_checked = ($s == $media_img_default_size); 
     321               echo '<label class="classic">'. 
     322               form::radio(array('src'),html::escapeHTML($v),$s_checked).' '. 
     323               $core->media->thumb_sizes[$s][2].'</label><br /> '; 
     324          } 
     325          $s_checked = (!isset($file->media_thumb[$media_img_default_size])); 
     326          echo '<label class="classic">'. 
     327          form::radio(array('src'),$file->file_url,$s_checked).' '.__('original').'</label><br /> '; 
     328          echo '</p>'; 
     329 
     330     } elseif ($file_type[0] == 'audio') { 
     331          $media_type = 'mp3'; 
     332     } elseif ($file_type[0] == 'video') { 
     333          $media_type = 'flv'; 
     334     } else { 
     335          $media_type = 'default'; 
     336     } 
     337 
     338     echo 
     339     '<p>'. 
     340     '<a id="media-select-ok" class="button submit" href="#">'.__('Select').'</a> '. 
     341     '<a id="media-select-cancel" class="button" href="#">'.__('Cancel').'</a>'. 
     342     form::hidden(array('type'),html::escapeHTML($media_type)). 
     343     form::hidden(array('title'),html::escapeHTML($file->media_title)). 
     344     form::hidden(array('description'),html::escapeHTML($media_desc)). 
     345     form::hidden(array('url'),$file->file_url). 
     346     '</p>'; 
     347 
     348     echo '</form>'; 
     349     echo '</div>'; 
     350} 
     351 
    282352# Insertion popup 
    283 if ($popup) 
     353if ($popup && !$select) 
    284354{ 
    285355     $media_desc = $file->media_title; 
     
    459529} 
    460530 
    461 if ($popup) { 
     531if ($popup || $select) { 
    462532     echo 
    463533     '<div class="multi-part" title="'.__('Media details').'" id="media-details-tab">'; 
     
    728798echo 
    729799'</div>'; 
    730 if ($popup) { 
     800if ($popup || $select) { 
    731801     echo 
    732802     '</div>'; 
  • admin/style/default.css

    r3136 r3153  
    19561956     border-bottom: none; 
    19571957     } 
    1958 .medias-delete { 
     1958.medias-delete, .medias-select { 
    19591959     text-align: right; 
    19601960     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map