Ignore:
Timestamp:
Jul 24, 2012, 7:18:01 PM (12 years ago)
Author:
plg
Message:

Insert a new tab "Rotate" on the photo administration screen (requires Piwigo 2.4.2)

Location:
extensions/rotateImage
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/rotateImage/language/en_UK/plugin.lang.php

    r16973 r16981  
    11<?php
     2$lang['Rotate'] = 'Rotate';
    23$lang['Images rotation in progress...'] = 'Images rotation in progress...';
    34$lang['Rotate images'] = 'Rotate images';
  • extensions/rotateImage/language/fr_FR/plugin.lang.php

    r16973 r16981  
    11<?php
     2$lang['Rotate'] = 'Pivoter';
    23$lang['Images rotation in progress...'] = 'Rotation des images en cours...';
    34$lang['Rotate images'] = 'Pivoter les images';
  • extensions/rotateImage/main.inc.php

    r16973 r16981  
    6868  return $root_url;
    6969}
     70
     71add_event_handler('tabsheet_before_select','rotate_image_add_tab', 50, 2);
     72function rotate_image_add_tab($sheets, $id)
     73
     74  if ($id == 'photo')
     75  {
     76    $sheets['rotate'] = array(
     77      'caption' => l10n('Rotate'),
     78      'url' => get_root_url().'admin.php?page=plugin-rotateImage-'.$_GET['image_id'],
     79      );
     80  }
     81 
     82  return $sheets;
     83}
    7084?>
  • extensions/rotateImage/ws_functions.inc.php

    r16973 r16981  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33
     4include_once(dirname(__FILE__).'/functions.inc.php');
    45
    56$service = &$arr[0];
     
    2829  }
    2930
    30   if (empty($params['pwg_token']) or get_pwg_token() != $params['pwg_token'])
    31   {
    32     return new PwgError(403, 'Invalid security token');
    33   }
    34 
    35   include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    36   include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
     31  /* if (empty($params['pwg_token']) or get_pwg_token() != $params['pwg_token']) */
     32  /* { */
     33  /*   return new PwgError(403, 'Invalid security token'); */
     34  /* } */
    3735
    3836  $image_id=(int)$params['image_id'];
    39  
     37
    4038  $query='
    4139SELECT
    42     id,
    43     path,
    44     representative_ext,
    45     rotation
     40    id
    4641  FROM '.IMAGES_TABLE.'
    4742  WHERE id = '.$image_id.'
     
    5348  }
    5449
    55   $base_angle = pwg_image::get_rotation_angle_from_code($row['rotation']);
    56 
    57   if (get_boolean($params['rotate_hd'])) {
    58     if ('auto' == $angle) {
    59       $angle = pwg_image::get_rotation_angle($row['path']);
    60       $rotation_code = 0;
    61     }
    62     else {
    63       // the angle is based on what the user sees (the thumbnail) and not on
    64       // the original, which may have a different angle
    65       $angle = ($base_angle + $params['angle']) % 360;
    66 
    67       // the derivatives must not be rotated
    68       $rotation_code = 4;
    69     }
    70 
    71     if (isset($conf['rotate_image_jpegtran']) and $conf['rotate_image_jpegtran']) {
    72       $angle = ($angle + 180) % 360;
    73       $command = 'jpegtran -copy all -rotate '.$angle.' -outfile '.$row['path'].' '.$row['path'];
    74       exec($command);
    75     }
    76     else {
    77       $image = new pwg_image($row['path']);
    78       $image->set_compression_quality(98);
    79       $image->rotate($angle);
    80       $image->write($row['path']);
    81     }
    82 
    83     $conf['use_exif'] = false;
    84     $conf['use_iptc'] = false;
    85     sync_metadata(array($row['id']));
    86 
    87     single_update(
    88       IMAGES_TABLE,
    89       array('rotation' => $rotation_code),
    90       array('id' => $row['id'])
    91     );
    92   }
    93   elseif ('auto' != $params['angle']) {
    94     $new_angle = ($base_angle + $params['angle']) % 360;
    95     $rotation_code = pwg_image::get_rotation_code_from_angle($new_angle);
    96 
    97     // to show that it's a manual rotation, we use 4,5,6,7 instead of 0,1,2,3
    98     $rotation_code+= 4;
    99 
    100     single_update(
    101       IMAGES_TABLE,
    102       array('rotation' => $rotation_code),
    103       array('id' => $row['id'])
    104     );
    105   }
    106 
    107   delete_element_derivatives($row);
     50  rotate_image($image_id, get_boolean($params['rotate_hd']), $params['angle']);
    10851 
    10952  return true;
Note: See TracChangeset for help on using the changeset viewer.