Dotclear

Changeset 2320:89c91e538879


Ignore:
Timestamp:
10/09/13 09:30:33 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Children:
2322:a75984c93a86, 2406:325f49056c79
Message:

Fix invalid html for media page (in attachment context) because of nested form.
Closes #1761

Location:
admin
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_media.js

    r2266 r2320  
    144144     }); 
    145145 
     146     // attach media 
     147     $('#form-medias').on('click', '.media-item .attach-media', function(e) { 
     148          var parts = $(this).prop('href').split('?'); 
     149          var str_params = parts[1].split('&'); 
     150          var postData = {}; 
     151 
     152          for (var n=0;n<str_params.length;n++) { 
     153               kv = str_params[n].split('='); 
     154               postData[kv[0]] = kv[1]; 
     155          } 
     156          postData.xd_check = dotclear.nonce; 
     157 
     158          $.post(parts[0], postData, function(data) { 
     159               if (data.url !== undefined) { 
     160                    document.location = data.url; 
     161               } 
     162          }); 
     163 
     164          e.preventDefault(); 
     165     }); 
     166 
    146167     // Replace remove links by a POST on hidden form 
    147168     fileRemoveAct(); 
  • admin/media.php

    r2263 r2320  
    584584     if ($post_id && !$f->d) { 
    585585          $act .=  
    586           '<form action="post_media.php" method="post">'. 
    587           '<input type="image" src="images/plus.png" alt="'.__('Attach this file to entry').'" '. 
    588           'title="'.__('Attach this file to entry').'" /> '. 
    589           form::hidden('media_id',$f->media_id). 
    590           form::hidden('post_id',$post_id). 
    591           form::hidden('attach',1). 
    592           $core->formNonce(). 
    593           '</form>'; 
     586          '<a class="attach-media" title="'.__('Attach this file to entry').'" href="post_media.php?media_id='.$f->media_id. 
     587          '&amp;post_id='.$post_id.'&amp;attach=1">'. 
     588          '<img src="images/plus.png" alt="'.__('Attach this file to entry').'"/>'. 
     589          '</a>'; 
    594590     } 
    595591      
     
    622618     return $res; 
    623619} 
    624 ?> 
  • admin/post_media.php

    r2256 r2320  
    2727 
    2828try { 
    29      if ($post_id && $media_id && !empty($_POST['attach'])) 
     29     if ($post_id && $media_id && !empty($_REQUEST['attach'])) 
    3030     { 
    3131          $core->media = new dcMedia($core); 
    3232          $core->media->addPostMedia($post_id,$media_id); 
    33           http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false)); 
     33        if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { 
     34            header('Content-type: application/json'); 
     35            echo json_encode(array('url' => $core->getPostAdminURL($rs->post_type,$post_id,false))); 
     36            exit(); 
     37        } else { 
     38            http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false)); 
     39        } 
    3440     } 
    3541 
     
    7985     } 
    8086} 
    81 ?> 
  • admin/style/default.css

    r2308 r2320  
    17951795     border: none; 
    17961796     } 
     1797li.media-action a.attach-media { 
     1798     margin-right: 5px; 
     1799     } 
    17971800li.media-action form { 
    17981801     display: inline; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map