Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

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