This mod will allow users to rotate some/all of the images in an album at once, without editing each picture.
The site admin can decide which user groups will be allowed to rotate the images in an album (See disclaimer below)
See screenshot below
DISCLAIMER: Rotating multiple images at once may stress the server. Your web host company may warn you not to do this.
Edited 8/28. If you already applied this mod, see my additions below, or reapply the whole thing here.
editPics.php
FIND:
require('include/init.inc.php');
ADD:
require('include/picmgmt.inc.php');
//ADDED 8/28
if($CONFIG['read_exif_data'] ){
include("include/exif_php.inc.php");
}
if($CONFIG['read_iptc_data'] ){
include("include/iptc.inc.php");
}
define('IMG_DIR', $CONFIG['fullpath'].'edit/');
FIND:
if (count($HTTP_POST_VARS)) process_post_data();
Replace with:
if (count($HTTP_POST_VARS)) {
process_post_data();
header("location: " . $_SERVER['REQUEST_URI']);
}
FIND:
if (isset($HTTP_GET_VARS['album'])) {
$album_id = (int)$HTTP_GET_VARS['album'];
} elseif (isset($HTTP_GET_VARS['album'])) {
$album_id = (int)$HTTP_POST_VARS['album'];
} else {
$album_id = -1;
}
ADD:
//Garbage collection run at an probability of 25% and delete all files older than one hour
if (rand(1,100) < 25){
$d = opendir(IMG_DIR);
while ($file = readdir($d)){
if (is_file(IMG_DIR.$file) && ((time() - filemtime(IMG_DIR.$file))/60) > 60 && $file !="index.html" ){
@unlink(IMG_DIR.$file);
}
}
}
//Include the proper class for image Object
if ($CONFIG['thumb_method']=="gd2"){
require("include/imageObjectGD.class.php");
}elseif ($CONFIG['thumb_method']=="im"){
require("include/imageObjectIM.class.php");
}else{
die ("Editor class for your resize method not implemented");
}
FIND:
$data = array(
array($lang_editpics_php['pic_info'], '', 3),
array($lang_editpics_php['album'], 'aid', 1),
array($lang_editpics_php['title'], 'title', 0, 255),
Add:
array($lang_editpics_php['angle'], 'angle',5),
FIND:
case 4 :
form_options();
break;
ADD:
case 5 :
form_rotate($element[0],$element[1]);
break;
FIND:
function create_form(&$data)
ADD above:
function form_rotate($text, $name) {
global $CURRENT_PIC;
$name .= $CURRENT_PIC['pid'];
echo <<<EOT
<tr>
<td class="tableb" valign="top" style="white-space: nowrap;">
$text
</td>
<td class="tableb" valign="top">
<select name="$name" class="listbox">
<option value="0" selected>$text
<option value="90">CW 90°
<option value="180">180°
<option value="270">CCW 90°
</select>
</td>
</tr>
EOT;
}
FIND:
$aid = (int)get_post_var('aid', $pid);
$title = get_post_var('title', $pid);
$caption = get_post_var('caption', $pid);
$keywords = get_post_var('keywords', $pid);
$user1 = get_post_var('user1', $pid);
$user2 = get_post_var('user2', $pid);
$user3 = get_post_var('user3', $pid);
$user4 = get_post_var('user4', $pid);
ADD:
$angle = get_post_var('angle', $pid);
FIND:
$update .= ", user2 = '".addslashes($user2)."'";
$update .= ", user3 = '".addslashes($user3)."'";
$update .= ", user4 = '".addslashes($user4)."'";
ADD:
//Only rotate the image if the user specified
if ($angle != 0) {
if (is_array($pic)) {
if (!is_movie($pic['filename'])) {
if (!$img_dir) $img_dir = IMG_DIR;
//Copy the Image file to the editing directory
if (copy($CONFIG['fullpath'].$pic['filepath'].$pic['filename'],$img_dir.$pic['filename']))
//ADDED 8/28 put the exif and iptc data in the table if it's not already there
$path_to_pic = $CONFIG['fullpath'] . $pic['filepath'] . $pic['filename'];
if ($CONFIG['read_exif_data']) $exif = exif_parse_file($path_to_pic);
if ($CONFIG['read_iptc_data']) $iptc = get_IPTC($path_to_pic);
//rotate the image
$newimage = $pic['filename'];
$imgObj = new imageObject($img_dir,$newimage);
$imgObj->quality = 100;
$imgObj = $imgObj->rotateImage($angle);
//save the new image
$width=$imgObj->width;
$height=$imgObj->height;
$normal = $CONFIG['fullpath'] . $pic['filepath'] . $CONFIG['normal_pfx'] . $pic['filename'];
$thumbnail = $CONFIG['fullpath'] . $pic['filepath'] . $CONFIG['thumb_pfx'] . $pic['filename'];
$filesize = @filesize($img_dir.$newimage);
//Full image replace
copy($img_dir.$newimage,$CONFIG['fullpath'].$pic['filepath'].$pic['filename']);
// Normal image resized and replace, use the CPG resize method instead of the object resizeImage
// as using the object resizeImage will make the final display of image to be a thumbnail in the editor
if (max($width, $height) > $CONFIG['picture_width'] && $CONFIG['make_intermediate']) {
resize_image($img_dir.$newimage, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
} else {
@unlink($normal);
}
//thumbnail resized and replace
resize_image($img_dir.$newimage, $thumbnail, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']);
$total_filesize = $filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumbnail);
//Update the image size in the DB
db_query("UPDATE {$CONFIG['TABLE_PICTURES']}
SET pheight = $height,
pwidth = $width,
filesize = $filesize,
total_filesize = $total_filesize
WHERE pid = '$pid'");
}
}
}
FIND:
<a href="$thumb_link" target="_blank"><img src="$thumb_url" class="image" border="0"><br /></a>
Replace with:
<a href="$thumb_link" target="_blank"><img src="$thumb_url" id="img_{$CURRENT_PIC['pid']}" class="image" border="0"><br /></a>
lang/english.php
FIND:
if (defined('EDITPICS_PHP')) $lang_editpics_php = array(
ADD:
'angle' => 'Rotate', //Mark Stralka 8/27/04
To make this group-configurable (Turn it on or off for each group in groupmgr.php), do the following.
Database modification:
ALTER TABLE `cpg132_usergroups` ADD `can_rotate_images` TINYINT( 4 ) DEFAULT '0' NOT NULL ;
groupmgr.php
FIND:
$field_list = array('can_rate_pictures', 'can_send_ecards', 'can_post_comments', 'can_upload_pictures', 'pub_upl_need_approval', 'can_create_albums', 'priv_upl_need_approval');
Replace with:
$field_list = array('can_rate_pictures', 'can_send_ecards', 'can_post_comments', 'can_upload_pictures', 'pub_upl_need_approval', 'can_create_albums', 'priv_upl_need_approval', 'can_rotate_images');
FIND:
$field_list = array('group_name', 'group_quota', 'can_rate_pictures', 'can_send_ecards', 'can_post_comments', 'can_upload_pictures', 'pub_upl_need_approval', 'can_create_albums', 'priv_upl_need_approval', 'upload_form_config', 'custom_user_upload', 'num_file_upload', 'num_URI_upload');
Replace with:
$field_list = array('group_name', 'group_quota', 'can_rate_pictures', 'can_send_ecards', 'can_post_comments', 'can_upload_pictures', 'pub_upl_need_approval', 'can_create_albums', 'priv_upl_need_approval', 'can_rotate_images', 'upload_form_config', 'custom_user_upload', 'num_file_upload', 'num_URI_upload');
FIND:
<tr>
<td class="tableh1" colspan="2"><b><span class="statlink">{$lang_groupmgr_php['group_name']}</span></b></td>
<td class="tableh1"><b><span class="statlink">{$lang_groupmgr_php['disk_quota']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_rate']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_send_ecards']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_post_com']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_upload']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['approval_1']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_have_gallery']}</span></b></td>
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['approval_2']}</span></b></td>
Add:
<td class="tableh1" align="center"><b><span class="statlink">{$lang_groupmgr_php['can_rotate_images']}</span></b></td>
FIND all instances (your number may vary):
colspan="15"
Replace with:
colspan="16"
lang/english.php
FIND:
if (defined('GROUPMGR_PHP')) $lang_groupmgr_php = array(
ADD:
'can_rotate_images' => 'Can rotate images', //Mark Stralka
include/init.inc.php
FIND:
$result = db_query("SELECT MAX(group_quota) as disk_max, MIN(group_quota) as disk_min, " .
"MAX(can_rate_pictures) as can_rate_pictures, MAX(can_send_ecards) as can_send_ecards, " .
"MAX(upload_form_config) as ufc_max, MIN(upload_form_config) as ufc_min, " .
"MAX(custom_user_upload) as custom_user_upload, MAX(num_file_upload) as num_file_upload, " .
"MAX(num_URI_upload) as num_URI_upload, " .
"MAX(can_post_comments) as can_post_comments, MAX(can_upload_pictures) as can_upload_pictures, " .
"MAX(can_create_albums) as can_create_albums, " .
"MAX(has_admin_access) as has_admin_access, " .
"MIN(pub_upl_need_approval) as pub_upl_need_approval, MIN( priv_upl_need_approval) as priv_upl_need_approval, ".
ADD:
"MAX(can_rotate_images) as can_rotate_images " .
FIND (2 times in file):
define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
ADD:
define('USER_CAN_ROTATE_IMAGES',(int)$USER_DATA['can_rotate_images']);
editpics.php:
FIND:
$data = array(
array($lang_editpics_php['pic_info'], '', 3),
array($lang_editpics_php['album'], 'aid', 1),
array($lang_editpics_php['title'], 'title', 0, 255),
array($lang_editpics_php['angle'], 'angle',5),
array($captionLabel, 'caption', 2, $CONFIG['max_img_desc_length']),
array($lang_editpics_php['keywords'], 'keywords', 0, 255),
array($CONFIG['user_field1_name'], 'user1', 0, 255),
array($CONFIG['user_field2_name'], 'user2', 0, 255),
array($CONFIG['user_field3_name'], 'user3', 0, 255),
array($CONFIG['user_field4_name'], 'user4', 0, 255),
array('', '', 4)
);
Replace with:
$data = array(
array($lang_editpics_php['pic_info'], '', 3),
array($lang_editpics_php['album'], 'aid', 1),
array($lang_editpics_php['title'], 'title', 0, 255)
);
if (USER_CAN_ROTATE_IMAGES) {
$data[] = array($lang_editpics_php['angle'], 'angle',5);
}
$data[] = array($captionLabel, 'caption', 2, $CONFIG['max_img_desc_length']);
$data[] = array($lang_editpics_php['keywords'], 'keywords', 0, 255);
$data[] = array($CONFIG['user_field1_name'], 'user1', 0, 255);
$data[] = array($CONFIG['user_field2_name'], 'user2', 0, 255);
$data[] = array($CONFIG['user_field3_name'], 'user3', 0, 255);
$data[] = array($CONFIG['user_field4_name'], 'user4', 0, 255);
$data[] = array('', '', 4);
FIND:
$angle = (int) get_post_var('angle', $pid);
Replace with:
if (USER_CAN_ROTATE_IMAGES) {
$angle = (int) get_post_var('angle', $pid);
}