Dotclear


Ignore:
Timestamp:
03/08/18 17:58:39 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Code formatting (PSR-2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/post_media.php

    r3167 r3730  
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    1212 
    13 require dirname(__FILE__).'/../inc/admin/prepend.php'; 
     13require dirname(__FILE__) . '/../inc/admin/prepend.php'; 
    1414 
    1515dcPage::check('usage,contentadmin'); 
    1616 
    17 $post_id = !empty($_REQUEST['post_id']) ? (integer) $_REQUEST['post_id'] : null; 
    18 $media_id = !empty($_REQUEST['media_id']) ? (integer) $_REQUEST['media_id'] : null; 
     17$post_id   = !empty($_REQUEST['post_id']) ? (integer) $_REQUEST['post_id'] : null; 
     18$media_id  = !empty($_REQUEST['media_id']) ? (integer) $_REQUEST['media_id'] : null; 
    1919$link_type = !empty($_REQUEST['link_type']) ? $_REQUEST['link_type'] : null; 
    2020 
    2121if (!$post_id) { 
    22      exit; 
     22    exit; 
    2323} 
    24 $rs = $core->blog->getPosts(array('post_id' => $post_id,'post_type'=>'')); 
     24$rs = $core->blog->getPosts(array('post_id' => $post_id, 'post_type' => '')); 
    2525if ($rs->isEmpty()) { 
    26      exit; 
     26    exit; 
    2727} 
    2828 
    2929try { 
    30      if ($post_id && $media_id && !empty($_REQUEST['attach'])) 
    31      { 
    32           $core->media = new dcMedia($core); 
    33           $core->media->addPostMedia($post_id,$media_id,$link_type); 
     30    if ($post_id && $media_id && !empty($_REQUEST['attach'])) { 
     31        $core->media = new dcMedia($core); 
     32        $core->media->addPostMedia($post_id, $media_id, $link_type); 
    3433        if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { 
    3534            header('Content-type: application/json'); 
    36             echo json_encode(array('url' => $core->getPostAdminURL($rs->post_type,$post_id,false))); 
     35            echo json_encode(array('url' => $core->getPostAdminURL($rs->post_type, $post_id, false))); 
    3736            exit(); 
    3837        } else { 
    39             http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false)); 
     38            http::redirect($core->getPostAdminURL($rs->post_type, $post_id, false)); 
    4039        } 
    41      } 
     40    } 
    4241 
    43      $core->media = new dcMedia($core); 
    44      $f = $core->media->getPostMedia($post_id,$media_id,$link_type); 
    45      if (empty($f)) { 
    46           $post_id = $media_id = null; 
    47           throw new Exception(__('This attachment does not exist')); 
    48      } 
    49      $f = $f[0]; 
     42    $core->media = new dcMedia($core); 
     43    $f           = $core->media->getPostMedia($post_id, $media_id, $link_type); 
     44    if (empty($f)) { 
     45        $post_id = $media_id = null; 
     46        throw new Exception(__('This attachment does not exist')); 
     47    } 
     48    $f = $f[0]; 
    5049} catch (Exception $e) { 
    51      $core->error->add($e->getMessage()); 
     50    $core->error->add($e->getMessage()); 
    5251} 
    5352 
    5453# Remove a media from en 
    55 if (($post_id && $media_id) || $core->error->flag()) 
    56 { 
    57      if (!empty($_POST['remove'])) 
    58      { 
    59           $core->media->removePostMedia($post_id,$media_id,$link_type); 
     54if (($post_id && $media_id) || $core->error->flag()) { 
     55    if (!empty($_POST['remove'])) { 
     56        $core->media->removePostMedia($post_id, $media_id, $link_type); 
    6057 
    61           dcPage::addSuccessNotice(__('Attachment has been successfully removed.')); 
    62           http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false)); 
    63      } 
    64      elseif (isset($_POST['post_id'])) { 
    65           http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false)); 
    66      } 
     58        dcPage::addSuccessNotice(__('Attachment has been successfully removed.')); 
     59        http::redirect($core->getPostAdminURL($rs->post_type, $post_id, false)); 
     60    } elseif (isset($_POST['post_id'])) { 
     61        http::redirect($core->getPostAdminURL($rs->post_type, $post_id, false)); 
     62    } 
    6763 
    68      if (!empty($_GET['remove'])) 
    69      { 
    70           dcPage::open(__('Remove attachment')); 
     64    if (!empty($_GET['remove'])) { 
     65        dcPage::open(__('Remove attachment')); 
    7166 
    72           echo '<h2>'.__('Attachment').' &rsaquo; <span class="page-title">'.__('confirm removal').'</span></h2>'; 
     67        echo '<h2>' . __('Attachment') . ' &rsaquo; <span class="page-title">' . __('confirm removal') . '</span></h2>'; 
    7368 
    74           echo 
    75           '<form action="'.$core->adminurl->get("admin.post.media").'" method="post">'. 
    76           '<p>'.__('Are you sure you want to remove this attachment?').'</p>'. 
    77           '<p><input type="submit" class="reset" value="'.__('Cancel').'" /> '. 
    78           ' &nbsp; <input type="submit" class="delete" name="remove" value="'.__('Yes').'" />'. 
    79           form::hidden('post_id',$post_id). 
    80           form::hidden('media_id',$media_id). 
    81           $core->formNonce().'</p>'. 
    82           '</form>'; 
     69        echo 
     70        '<form action="' . $core->adminurl->get("admin.post.media") . '" method="post">' . 
     71        '<p>' . __('Are you sure you want to remove this attachment?') . '</p>' . 
     72        '<p><input type="submit" class="reset" value="' . __('Cancel') . '" /> ' . 
     73        ' &nbsp; <input type="submit" class="delete" name="remove" value="' . __('Yes') . '" />' . 
     74        form::hidden('post_id', $post_id) . 
     75        form::hidden('media_id', $media_id) . 
     76        $core->formNonce() . '</p>' . 
     77            '</form>'; 
    8378 
    84           dcPage::close(); 
    85           exit; 
    86      } 
     79        dcPage::close(); 
     80        exit; 
     81    } 
    8782} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map