/
edit.php
123 lines (104 loc) · 4.84 KB
/
edit.php
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
<?php
/**
* @package fisheye
* @subpackage functions
*/
/**
* required setup
*/
require_once( '../kernel/includes/setup_inc.php' );
require_once( FISHEYE_PKG_CLASS_PATH.'FisheyeGallery.php');
require_once( FISHEYE_PKG_CLASS_PATH.'FisheyeImage.php');
global $gBitSystem;
include_once( FISHEYE_PKG_INCLUDE_PATH.'gallery_lookup_inc.php' );
// Ensure the user has the permission to create new image galleries
if( $gContent->isValid() ){
$gContent->verifyUpdatePermission();
}else{
$gContent->verifyCreatePermission();
}
if( $gBitUser->hasPermission( 'p_fisheye_change_thumb_size' ) ) {
$gBitSmarty->assign( 'thumbnailSizes', get_image_size_options( NULL ));
}
$gBitSmarty->assign( 'galleryPaginationTypes', $gContent::getAllLayouts() );
if( !empty( $_REQUEST['savegallery'] ) ) {
if( $_REQUEST['gallery_pagination'] == 'auto_flow' ) {
$_REQUEST['rows_per_page'] = $_REQUEST['total_per_page'];
$_REQUEST['cols_per_page'] = '1';
} elseif ( $_REQUEST['gallery_pagination'] == 'simple_list' ) {
$_REQUEST['rows_per_page'] = $_REQUEST['lines_per_page'];
$_REQUEST['cols_per_page'] = '1';
} elseif ( $_REQUEST['gallery_pagination'] == 'matteo' ) {
$_REQUEST['rows_per_page'] = $_REQUEST['images_per_page'];
$_REQUEST['cols_per_page'] = '1';
}
if( $gContent->store( $_REQUEST ) ) {
$gContent->storePreference( 'is_public', !empty( $_REQUEST['is_public'] ) ? $_REQUEST['is_public'] : NULL );
$gContent->storePreference( 'allow_comments', !empty( $_REQUEST['allow_comments'] ) ? $_REQUEST['allow_comments'] : NULL );
$gContent->storePreference( 'gallery_pagination', !empty( $_REQUEST['gallery_pagination'] ) ? $_REQUEST['gallery_pagination'] : NULL );
$gContent->storePreference( 'link_original_images', !empty( $_REQUEST['link_original_images'] ) ? $_REQUEST['link_original_images'] : NULL );
// make sure var is fully stuffed with current data
$gContent->load();
// set the mappings, or if nothing checked, nuke them all
$gContent->addToGalleries( !empty( $_REQUEST['gallery_additions'] ) ? $_REQUEST['gallery_additions'] : NULL );
if( !empty( $_REQUEST['generate_thumbnails'] ) ) {
$gContent->generateThumbnails();
}
header("location: ".$gContent->getDisplayUrl() );
die();
}
} elseif( !empty( $_REQUEST['delete'] ) ) {
$gContent->hasUserPermission( 'p_fisheye_admin', TRUE, tra( "You do not have permission to delete this image gallery" ) );
if( !empty( $_REQUEST['cancel'] ) ) {
// user cancelled - just continue on, doing nothing
} elseif( empty( $_REQUEST['confirm'] ) ) {
$formHash['delete'] = TRUE;
$formHash['gallery_id'] = $gContent->mGalleryId;
$formHash['input'] = array(
'<label><input name="recurse" value="" type="radio" checked="checked" /> '.tra( 'Delete only images in this gallery. Sub-galleries will not be removed.' ).'</label>',
'<label><input name="recurse" value="all" type="radio" /> '.tra( 'Permanently delete all contents, even if they appear in other galleries.' ).'</label>',
);
$gBitSystem->confirmDialog( $formHash,
array(
'warning' => tra('Are you sure you want to delete this gallery?') . ' ' . $gContent->getTitle(),
'error' => tra('This cannot be undone!'),
)
);
} else {
$userId = $gContent->getField( 'user_id' );
$recurseDelete = (!empty( $_REQUEST['recurse'] ) && ($_REQUEST['recurse'] == 'all') );
if( $gContent->expunge( $recurseDelete ) ) {
header( "Location: ".FISHEYE_PKG_URL.'?user_id='.$userId );
}
}
} elseif( !empty($_REQUEST['cancelgallery'] ) ) {
header( 'Location: '.$gContent->getDisplayUrl() );
die();
}
// Initalize the errors list which contains any errors which occured during storage
$errors = (!empty($gContent->mErrors) ? $gContent->mErrors : array());
$gBitSmarty->assignByRef('errors', $errors);
$gBitSystem->setOnloadScript( 'updateGalleryPagination();' );
$gallery = $gContent->getParentGalleries();
$gBitSmarty->assignByRef( 'parentGalleries', $gallery );
$getHash = array(
'user_id' => $gBitUser->mUserId,
// 'max_records' => -1,
// 'no_thumbnails' => TRUE,
// 'sort_mode' => 'title_asc',
// 'show_empty' => TRUE,
);
if( $gContent->mContentId ) {
$getHash['contain_item'] = $gContent->mContentId;
}
// modify listHash according to global preferences
if( $gBitSystem->isFeatureActive( 'fisheye_show_all_to_admins' ) && $gBitUser->hasPermission( 'p_fisheye_admin' ) ) {
unset( $getHash['user_id'] );
} elseif( $gBitSystem->isFeatureActive( 'fisheye_show_public_on_upload' ) ) {
// $getHash['show_public'] = TRUE;
}
$galleryTree = $gContent->generateList( $getHash, array( 'name' => "gallery_id", 'id' => "gallerylist", 'item_attributes' => array( 'class'=>'listingtitle'), 'radio_checkbox' => TRUE, ) );
$gBitSmarty->assignByRef( 'galleryTree', $galleryTree );
$gContent->invokeServices( 'content_edit_function' );
$gBitSystem->display( 'bitpackage:fisheye/edit_gallery.tpl', tra('Edit Gallery: ').$gContent->getTitle() , array( 'display_mode' => 'edit' ));
?>