Dotclear


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 = 
Note: See TracChangeset for help on using the changeset viewer.

Sites map