1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
<?php
/**
* @version $Header: /cvsroot/bitweaver/_bit_fisheye/image_order.php,v 1.4 2005/08/01 18:40:07 squareing Exp $
* @package fisheye
* @subpackage functions
*/
/**
* required setup
*/
require_once( '../bit_setup_inc.php' );
require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
global $gBitSystem;
include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
global $gGatekeeper;
$gBitSmarty->assign( 'securities', $gGatekeeper->getSecurityList( $gBitUser->mUserId ) );
}
// Ensure the user has the permission to create new image galleries
if( !$gContent->hasUserPermission( 'bit_p_edit_fisheye' ) ) {
// This user does not own this gallery and they have not been granted the permission to edit this gallery
$gBitSystem->fatalError( tra( "You cannot edit this image gallery" ) );
}
if (!empty($_REQUEST['cancel'])) {
header( 'Location: '.$gContent->getDisplayUrl() );
die;
} elseif (!empty($_REQUEST['updateImageOrder'])) {
if( !empty( $_REQUEST['batch'] ) ) {
// flip so we can do instant has lookup
$batchCon = array_flip( $_REQUEST['batch'] );
}
if( !empty( $_REQUEST['reorder_gallery'] ) && $gContent->loadImages() ) {
switch( $_REQUEST['reorder_gallery'] ){
case 'upload_date':
foreach( array_keys( $gContent->mItems ) as $imageId ) {
$reorder[$gContent->mItems[$imageId]->mContentId] = $gContent->mItems[$imageId]->mInfo['created'];
}
break;
case 'caption':
foreach( array_keys( $gContent->mItems ) as $imageId ) {
$reorder[$gContent->mItems[$imageId]->mContentId] = $gContent->mItems[$imageId]->mInfo['title'];
}
break;
case 'file_name':
foreach( array_keys( $gContent->mItems ) as $imageId ) {
$reorder[$gContent->mItems[$imageId]->mContentId] = $gContent->mItems[$imageId]->mInfo['image_file']['filename'];
}
break;
}
asort( $reorder );
$sortPos = 100;
foreach( $reorder as $conId => $sortVal ) {
$newOrder[$conId] = $sortPos;
$sortPos += 10;
}
}
foreach ($_REQUEST['imagePosition'] as $contentId=>$newPos) {
$galleryItem = $gLibertySystem->getLibertyObject( $contentId );
if( $galleryItem->load() ) {
if( isset( $batchCon[$contentId] ) ) {
if( !empty( $_REQUEST['batch_command'] ) ) {
list( $batchCommand, $batchParam ) = @split( ':', $_REQUEST['batch_command'] );
switch( $batchCommand ) {
case 'delete':
$galleryItem->expunge();
$galleryItem = NULL;
break;
case 'rotate':
$galleryItem->rotateImage( $batchParam );
$feedback['success'] = tra( "Images rotated" );
break;
case 'thumbnail':
$galleryItem->generateThumbnails();
$feedback['success'] = tra( "Thumbnail regeneration queued" );
break;
case 'security':
$storageHash['security_id'] = $batchParam;
$feedback['success'] = tra( "Items security assigned" );
break;
case 'gallerymove':
if( empty( $destGallery ) ) {
$destGallery = new FisheyeGallery( NULL, $batchParam );
$destGallery->load();
}
if( $batchParam != $contentId ) {
$gContent->removeItem( $contentId );
}
case 'gallerycopy':
if( empty( $destGallery ) ) {
$destGallery = new FisheyeGallery( NULL, $batchParam );
$destGallery->load();
}
if( $destGallery->addItem( $contentId ) ) {
$feedback['success'][] = $galleryItem->getTitle().' '.tra( "added to" ).' '.$destGallery->getTitle();
} else {
$feedback['error'][] = $galleryItem->getTitle().' '.tra( "could not be added to" ).' '.$destGallery->getTitle();
}
break;
}
}
}
if( is_object( $galleryItem ) ) {
if( !empty( $_REQUEST['batch_security_id'] ) ) {
}
// if we are reordered, that takes precident
$newPos = (!empty( $newOrder[$contentId] ) ? $newOrder[$contentId] : $newPos);
if ($galleryItem->mInfo['title'] != $_REQUEST['imageTitle'][$contentId]) {
$storageHash = array('title' => $_REQUEST['imageTitle'][$contentId]);
}
if( !empty( $storageHash ) ) {
$galleryItem->store($storageHash);
}
$galleryItem->updatePosition($gContent->mContentId, $newPos);
}
}
unset( $storageHash );
}
if ($gContent->storeGalleryThumbnail($_REQUEST['gallery_preview_content_id'])) {
$gContent->mInfo['preview_content_id'] = $_REQUEST['gallery_preview_content_id'];
}
}
// Get a list of all existing galleries
$listHash = array( 'user_id'=>$gBitUser->mUserId );
$galleryList = $gContent->getList( $listHash );
$gBitSmarty->assign_by_ref('galleryList', $galleryList);
$gContent->loadImages();
$gBitSmarty->assign_by_ref('galleryImages', $gContent->mItems);
$gBitSmarty->assign_by_ref('formfeedback', $feedback);
$gBitSystem->display( 'bitpackage:fisheye/image_order.tpl', 'Edit Gallery Images: '.$gContent->getTitle() );
?>
|