Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/admin/imageedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: imageedit.php 7089 2001-09-07 17:33:55Z fh $
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( "eZArticleMain", "Language" );
37
38 // include_once( "ezarticle/classes/ezarticlecategory.php" );
39 // include_once( "ezarticle/classes/ezarticle.php" );
40 // include_once( "ezuser/classes/ezauthor.php" );
41
42 if ( $Action == "Insert" )
43 {
44 $file = new eZPBImageFile();
45
46 if ( $file->getUploadedFile( "userfile" ) )
47 {
48 $article = new eZArticle( $ArticleID );
49 $image = new eZImage();
50 $image->setName( $Name );
51 $image->setCaption( $Caption );
52
53 if ( trim( $NewPhotographerName ) != "" &&
54 trim( $NewPhotographerEmail ) != ""
55 )
56 {
57 $author = new eZAuthor( );
58 $author->setName( $NewPhotographerName );
59 $author->setEmail( $NewPhotographerEmail );
60 $author->store();
61 $image->setPhotographer( $author );
62 }
63 else
64 {
65 $image->setPhotographer( $PhotoID );
66 }
67
68
69 if( $image->checkImage( $file ) && $image->setImage( $file ) )
70 {
71 $image->store();
72 $article->addImage( $image );
73 if ( count( $article->images() ) == 1 )
74 {
75 $article->setThumbnailImage( $image );
76 }
77
78 $objectPermission = new eZObjectPermission();
79
80 eZObjectPermission::setPermission( -1, $image->id(), "imagecatalogue_image", "r" );
81 eZObjectPermission::setPermission( 1, $image->id(), "imagecatalogue_image", "w" );
82
83 eZPBLog::writeNotice( "Picture added to article: $ArticleID from IP: $REMOTE_ADDR" );
84 }
85 }
86 else
87 {
88 print( $file->name() . " not uploaded successfully" );
89 }
90
91 // include_once( "classes/ezhttptool.php" );
92 eZHTTPTool::header( "Location: /article/articleedit/imagelist/" . $ArticleID . "/" );
93 exit();
94 }
95
96 if ( $Action == "Update" )
97 {
98 $file = new eZPBImageFile();
99 $image = new eZImage( $ImageID );
100
101 if ( trim( $NewPhotographerName ) != "" &&
102 trim( $NewPhotographerEmail ) != ""
103 )
104 {
105 $author = new eZAuthor( );
106 $author->setName( $NewPhotographerName );
107 $author->setEmail( $NewPhotographerEmail );
108 $author->store();
109 $image->setPhotographer( $author );
110 }
111 else
112 {
113 $image->setPhotographer( $PhotoID );
114 }
115
116 if ( $file->getUploadedFile( "userfile" ) )
117 {
118 $article = new eZArticle( $ArticleID );
119
120
121 $variations =& $image->variations();
122
123 if( $image->checkImage( $file ) && $image->setImage( $file ) )
124 {
125 if ( count ( $variations ) > 0 )
126 {
127 foreach( $variations as $variation )
128 $variation->delete();
129 }
130 // $oldImage = new eZImage( $ImageID );
131 // $article->deleteImage( $oldImage );
132
133 $image->setName( $Name );
134 $image->setCaption( $Caption );
135
136 $image->store();
137
138 // $article->addImage( $image );
139 }
140 }
141 else
142 {
143 // $image = new eZImage( $ImageID );
144 $image->setName( $Name );
145 $image->setCaption( $Caption );
146 $image->store();
147 }
148
149 // include_once( "classes/ezhttptool.php" );
150 eZHTTPTool::header( "Location: /article/articleedit/imagelist/" . $ArticleID . "/" );
151 exit();
152 }
153
154
155 if ( $Action == "Delete" )
156 {
157 $article = new eZArticle( $ArticleID );
158
159 if ( count ( $ImageArrayID ) != 0 )
160 {
161 foreach( $ImageArrayID as $ImageID )
162 {
163 $image = new eZImage( $ImageID );
164 $article->deleteImage( $image );
165 }
166 }
167
168 // include_once( "classes/ezhttptool.php" );
169 eZHTTPTool::header( "Location: /article/articleedit/imagelist/" . $ArticleID . "/" );
170 exit();
171 }
172
173 // store the image definition
174 if ( $Action == "StoreDef" )
175 {
176 $article = new eZArticle( $ArticleID );
177
178 // Unset frontpage image radiobutton
179 if ( isset( $NoFrontImage ) )
180 {
181 $article->setThumbnailImage( false );
182 // include_once( "classes/ezhttptool.php" );
183 eZHTTPTool::header( "Location: /article/articleedit/imagelist/" . $ArticleID . "/" );
184 exit();
185 }
186
187 if ( isset( $ThumbnailImageID ) && ( $ThumbnailImageID != 0 ) && ( $ThumbnailImageID != "" ) )
188 {
189 $thumbnail = new eZImage( $ThumbnailImageID );
190 $article->setThumbnailImage( $thumbnail );
191 }
192
193 if ( isset( $NewImage ) )
194 {
195 // include_once( "classes/ezhttptool.php" );
196 eZHTTPTool::header( "Location: /article/articleedit/imageedit/new/$ArticleID/" );
197 exit();
198 }
199
200 // include_once( "classes/ezhttptool.php" );
201 eZHTTPTool::header( "Location: /article/articleedit/edit/" . $ArticleID . "/" );
202 exit();
203 }
204
205 $t = new eZTemplate( "kernel/ezarticle/admin/" . $ini->variable( "eZArticleMain", "AdminTemplateDir" ),
206 "kernel/ezarticle/admin/intl/", $Language, "imageedit.php" );
207
208 $t->setAllStrings();
209
210 $t->set_file( array(
211 "image_edit_page" => "imageedit.tpl",
212 ) );
213
214
215 $t->set_block( "image_edit_page", "image_tpl", "image" );
216 $t->set_block( "image_edit_page", "photographer_item_tpl", "photographer_item" );
217
218 //default values
219 $t->set_var( "name_value", "" );
220 $t->set_var( "caption_value", "" );
221 $t->set_var( "action_value", "Insert" );
222 $t->set_var( "option_id", "" );
223 $t->set_var( "image", "" );
224
225 if ( $Action == "Edit" )
226 {
227 $article = new eZArticle( $ArticleID );
228 $image = new eZImage( $ImageID );
229 $photographer = $image->photographer();
230 $photographerID = $photographer->id();
231
232
233 $t->set_var( "image_id", $image->id() );
234 $t->set_var( "name_value", $image->name() );
235 $t->set_var( "caption_value", $image->caption() );
236 $t->set_var( "action_value", "Update" );
237
238
239 $t->set_var( "image_alt", $image->caption() );
240
241 $variation = $image->requestImageVariation( 150, 150 );
242
243 $t->set_var( "image_src", "/" .$variation->imagePath() );
244 $t->set_var( "image_width", $variation->width() );
245 $t->set_var( "image_height", $variation->height() );
246 $t->set_var( "image_file_name", $image->originalFileName() );
247 $t->parse( "image", "image_tpl" );
248 }
249
250
251 $author = new eZAuthor();
252 $authorArray = $author->getAll();
253 foreach ( $authorArray as $author )
254 {
255 if ( $photographerID == $author->id() )
256 {
257 $t->set_var( "selected", "selected" );
258 }
259 else
260 {
261 $t->set_var( "selected", "" );
262 }
263
264 $t->set_var( "photo_id", $author->id() );
265 $t->set_var( "photo_name", $author->name() );
266 $t->parse( "photographer_item", "photographer_item_tpl", true );
267 }
268
269 $article = new eZArticle( $ArticleID );
270
271 $t->set_var( "article_name", $article->name() );
272 $t->set_var( "article_id", $article->id() );
273
274 $t->pparse( "output", "image_edit_page" );
275
276 ?>
eZArticle
Definition: ezarticle.php:82
eZAuthor
Definition: ezauthor.php:40
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
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$ImageID
$ImageID
Definition: companytypelist.php:201
$ArticleID
$ArticleID
Definition: export.php:48
$article
foreach( $authorArray as $author) $article
Definition: ezarticle/admin/imageedit.php:269
$t
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") if( $Action=="StoreDef") $t
Definition: ezarticle/admin/imageedit.php:205
$authorArray
$authorArray
Definition: ezarticle/admin/imageedit.php:252
$Language
$Language
Definition: ezarticle/admin/imageedit.php:36
$ini
$ini
Definition: ezarticle/admin/imageedit.php:35
$author
if( $Action=="Edit") $author
Definition: ezarticle/admin/imageedit.php:251
$thumbnail
$thumbnail
Definition: ezarticle/admin/imagelist.php:59
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
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+.