Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztrade/admin/imageedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: imageedit.php 6233 2001-07-20 11:42:02Z jakobn $
5 //
6 // Created on: <21-Sep-2000 10:32:36 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlog.php" );
30
31 // include_once( "classes/ezimagefile.php" );
32
33 // include_once( "ezimagecatalogue/classes/ezimage.php" );
34
35 $ini =& eZINI::instance( 'site.ini' );
36 $Language = $ini->variable( "eZTradeMain", "Language" );
37
38 // include_once( "eztrade/classes/ezproductcategory.php" );
39 // include_once( "eztrade/classes/ezproduct.php" );
40
41 if ( $Action == "Insert" )
42 {
43 $file = new eZPBImageFile();
44
45 if ( $file->getUploadedFile( "userfile" ) )
46 {
47 $product = new eZProduct( $ProductID );
48 $image = new eZImage();
49 $image->setName( $Name );
50 $image->setCaption( $Caption );
51
52 $image->setImage( $file );
53
54 $image->store();
55
56 $product->addImage( $image );
57
58 if ( count( $product->images() ) == 1 )
59 {
60 $product->setThumbnailImage( $image );
61 $product->setMainImage( $image );
62 }
63
64 $objectPermission = new eZObjectPermission();
65 eZObjectPermission::setPermission( -1, $image->id(), "imagecatalogue_image", "r" );
66 eZObjectPermission::setPermission( 1, $image->id(), "imagecatalogue_image", "w" );
67
68 eZPBLog::writeNotice( "Picture added to product: $ProductID from IP: $REMOTE_ADDR" );
69 }
70 else
71 {
72 print( $file->name() . " not uploaded successfully" );
73 }
74
75 // include_once( "classes/ezhttptool.php" );
76 eZHTTPTool::header( "Location: /trade/productedit/imagelist/" . $ProductID . "/" );
77 exit();
78 }
79
80 if ( $Action == "Update" )
81 {
82 $file = new eZPBImageFile();
83
84 if ( $file->getUploadedFile( "userfile" ) )
85 {
86 $product = new eZProduct( $ProductID );
87
88 $oldImage = new eZImage( $ImageID );
89 $product->deleteImage( $oldImage );
90
91 $image = new eZImage();
92 $image->setName( $Name );
93 $image->setCaption( $Caption );
94
95 $image->setImage( $file );
96
97 $image->store();
98
99 $product->addImage( $image );
100 }
101 else
102 {
103 $image = new eZImage( $ImageID );
104 $image->setName( $Name );
105 $image->setCaption( $Caption );
106 $image->store();
107 }
108
109 // include_once( "classes/ezhttptool.php" );
110 eZHTTPTool::header( "Location: /trade/productedit/imagelist/" . $ProductID . "/" );
111 exit();
112 }
113
114
115 if ( $Action == "Delete" )
116 {
117 $product = new eZProduct( $ProductID );
118
119 if ( count ( $ImageArrayID ) != 0 )
120 {
121 foreach( $ImageArrayID as $ImageID )
122 {
123 $image = new eZImage( $ImageID );
124 $product->deleteImage( $image );
125 }
126 }
127
128 // include_once( "classes/ezhttptool.php" );
129 eZHTTPTool::header( "Location: /trade/productedit/imagelist/" . $ProductID . "/" );
130 exit();
131 }
132
133 // update captions
134
135 if ( $Action == "UpdateImages" )
136
137 {
138 for ( $i = 0; $i < count( $ImageUpdateArrayID ); $i++ )
139 {
140 if ( $NewCaption[$i] != $OldCaption[$i] )
141 {
142 $image = new eZImage($ImageUpdateArrayID[$i]);
143 $image->setCaption( $NewCaption[$i] );
144 $image->store();
145 }
146 }
147
148 include_once( "classes/ezhttptool.php" );
149 eZHTTPTool::header( "Location: /trade/productedit/imagelist/" . $ProductID . "/" );
150 exit();
151 }
152
153
154
155 // store the image definition
156 if ( $Action == "StoreDef" )
157 {
158 $product = new eZProduct( $ProductID );
159
160 for ( $i = 0; $i < count( $ImageUpdateArrayID ); $i++ )
161 {
162 if ( $NewCaption[$i] != $OldCaption[$i] )
163 {
164 $image = new eZImage($ImageUpdateArrayID[$i]);
165 $image->setCaption( $NewCaption[$i] );
166 $image->store();
167 }
168 }
169
170 // Unset main page image radiobutton
171 if ( isset( $NoMainImage ) )
172 {
173 $product->setMainImage( false );
174 // include_once( "classes/ezhttptool.php" );
175 eZHTTPTool::header( "Location: /trade/productedit/imagelist/" . $ProductID . "/" );
176 exit();
177 }
178
179 // Unset mini page image radiobutton
180 if ( isset( $NoMiniImage ) )
181 {
182 $product->setThumbnailImage( false );
183 // include_once( "classes/ezhttptool.php" );
184 eZHTTPTool::header( "Location: /trade/productedit/imagelist/" . $ProductID . "/" );
185 exit();
186 }
187
188 if ( isset( $ThumbnailImageID ) && ( $ThumbnailImageID != 0 ) && ( $ThumbnailImageID != "" ) )
189 {
190 $thumbnail = new eZImage( $ThumbnailImageID );
191 $product->setThumbnailImage( $thumbnail );
192 }
193
194 if ( isset( $MainImageID ) && ( $MainImageID != 0 ) && ( $MainImageID != "" ) )
195 {
196 $main = new eZImage( $MainImageID );
197 $product->setMainImage( $main );
198 }
199
200 if ( isset( $NewImage ) )
201 {
202 print( "new image" );
203 // include_once( "classes/ezhttptool.php" );
204 eZHTTPTool::header( "Location: /trade/productedit/imageedit/new/$ProductID/" );
205 exit();
206 }
207
208 // include_once( "classes/ezhttptool.php" );
209 eZHTTPTool::header( "Location: /trade/productedit/edit/" . $ProductID . "/" );
210 exit();
211 }
212
213 $t = new eZTemplate( "kernel/eztrade/admin/" . $ini->variable( "eZTradeMain", "AdminTemplateDir" ),
214 "kernel/eztrade/admin/intl/", $Language, "imageedit.php" );
215
216 $t->setAllStrings();
217
218 $t->set_file( array(
219 "image_edit_page" => "imageedit.tpl",
220 ) );
221
222
223 $t->set_block( "image_edit_page", "image_tpl", "image" );
224
225 //default values
226 $t->set_var( "name_value", "" );
227 $t->set_var( "caption_value", "" );
228 $t->set_var( "action_value", "Insert" );
229 $t->set_var( "option_id", "" );
230 $t->set_var( "image", "" );
231
232 if ( $Action == "Edit" )
233 {
234 $product = new eZProduct( $ProductID );
235 $image = new eZImage( $ImageID );
236
237 $t->set_var( "image_id", $image->id() );
238 $t->set_var( "name_value", $image->name() );
239 $t->set_var( "caption_value", $image->caption() );
240 $t->set_var( "action_value", "Update" );
241
242
243 $t->set_var( "image_alt", $image->caption() );
244
245 $variation = $image->requestImageVariation( 150, 150 );
246
247 $t->set_var( "image_src", "/" .$variation->imagePath() );
248 $t->set_var( "image_width", $variation->width() );
249 $t->set_var( "image_height", $variation->height() );
250 $t->set_var( "image_file_name", $image->originalFileName() );
251 $t->parse( "image", "image_tpl" );
252 }
253
254 $product = new eZProduct( $ProductID );
255
256 $t->set_var( "product_name", $product->name() );
257 $t->set_var( "product_id", $product->id() );
258
259 $t->pparse( "output", "image_edit_page" );
260
261 ?>
$i
$i
Definition: admin/adlist.php:91
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZImage
Definition: ezimage.php:95
eZObjectPermission
Definition: ezobjectpermission.php:55
eZObjectPermission\setPermission
static setPermission( $group, $objectID, $moduleTable, $permission)
Definition: ezobjectpermission.php:236
eZPBImageFile
Definition: ezpbimagefile.php:71
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZProduct
Definition: ezproduct.php:71
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$ImageID
$ImageID
Definition: companytypelist.php:201
$thumbnail
$thumbnail
Definition: ezarticle/admin/imagelist.php:59
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$product
if( $Action=="Edit") $product
Definition: eztrade/admin/imageedit.php:254
$t
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") if( $Action=="UpdateImages") if( $Action=="StoreDef") $t
Definition: eztrade/admin/imageedit.php:213
$Language
$Language
Definition: eztrade/admin/imageedit.php:36
$ini
$ini
Definition: eztrade/admin/imageedit.php:35
$main
$main
Definition: eztrade/admin/imagelist.php:62
exit
exit
Definition: folder.php:81
$Name
$Name
Definition: polledit.php:250
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.