allow rotation either CW or CCW

This commit is contained in:
Zach Prezkuta 2012-06-20 20:36:10 -06:00
parent 75e82dc077
commit 54c76ca822
2 changed files with 18 additions and 11 deletions

View File

@ -306,7 +306,8 @@ function photos_post(&$a) {
$albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'); $albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
if((x($_POST,'rotate') !== false) && (intval($_POST['rotate']) == 1)) { if((x($_POST,'rotate') !== false) &&
( (intval($_POST['rotate']) == 1) || (intval($_POST['rotate']) == 2) )) {
logger('rotate'); logger('rotate');
$r = q("select * from photo where `resource-id` = '%s' and uid = %d and scale = 0 limit 1", $r = q("select * from photo where `resource-id` = '%s' and uid = %d and scale = 0 limit 1",
@ -316,7 +317,8 @@ function photos_post(&$a) {
if(count($r)) { if(count($r)) {
$ph = new Photo($r[0]['data'], $r[0]['type']); $ph = new Photo($r[0]['data'], $r[0]['type']);
if($ph->is_valid()) { if($ph->is_valid()) {
$ph->rotate(270); $rotate_deg = ( (intval($_POST['rotate']) == 1) ? 270 : 90 );
$ph->rotate($rotate_deg);
$width = $ph->getWidth(); $width = $ph->getWidth();
$height = $ph->getHeight(); $height = $ph->getHeight();
@ -1251,7 +1253,8 @@ function photos_content(&$a) {
$edit_tpl = get_markup_template('photo_edit.tpl'); $edit_tpl = get_markup_template('photo_edit.tpl');
$edit = replace_macros($edit_tpl, array( $edit = replace_macros($edit_tpl, array(
'$id' => $ph[0]['id'], '$id' => $ph[0]['id'],
'$rotate' => t('Rotate CW'), '$rotatecw' => t('Rotate CW (right)'),
'$rotateccw' => t('Rotate CCW (left)'),
'$album' => template_escape($ph[0]['album']), '$album' => template_escape($ph[0]['album']),
'$newalbum' => t('New album name'), '$newalbum' => t('New album name'),
'$nickname' => $a->data['user']['nickname'], '$nickname' => $a->data['user']['nickname'],

View File

@ -18,8 +18,12 @@
<div id="photo-edit-tags-end"></div> <div id="photo-edit-tags-end"></div>
<div id="photo-edit-rotate-wrapper"> <div id="photo-edit-rotate-wrapper">
<div id="photo-edit-rotate-label">$rotate</div> <div id="photo-edit-rotate-label">
<input type="checkbox" name="rotate" value="1" /> $rotatecw<br>
$rotateccw
</div>
<input type="radio" name="rotate" value="1" /><br>
<input type="radio" name="rotate" value="2" />
</div> </div>
<div id="photo-edit-rotate-end"></div> <div id="photo-edit-rotate-end"></div>