Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

adedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: adedit.php 9307 2002-02-27 16:53:26Z master $
5 //
6 // Created on: <16-Nov-2000 13:02:32 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/ezlocale.php" );
30 // include_once( "classes/ezimagefile.php" );
31 // include_once( "classes/ezlog.php" );
32 // include_once( "classes/ezhttptool.php" );
33
34 // include_once( "classes/ezdatetime.php" );
35
36 // include_once( "ezad/classes/ezad.php" );
37 // include_once( "ezad/classes/ezadcategory.php" );
38
39 if ( isset ( $DeleteAds ) )
40 {
41 $Action = "DeleteAds";
42 }
43
44 if ( isset ( $Preview ) )
45 {
46 if ( is_numeric ( $AdID ) && ( $AdID != 0 ) )
47 {
48 $Action = "Update";
49 }
50 else
51 {
52 $Action = "Insert";
53 }
54 }
55
56 if( isset( $AdURL ) )
57 $adUrl = trim( $AdURL );
58
59 // Get images from the image browse function.
60 if ( ( isset ( $AddImages ) ) and ( is_numeric( $AdID ) ) and ( is_numeric ( $AdID ) ) )
61 {
62 $image = new eZImage( $ImageID );
63 $ad = new eZAd( $AdID );
64 $ad->setImage( $image );
65 $ad->store();
66 $Action = "Edit";
67 }
68
69 if ( $Action == "Insert" )
70 {
71 $category = new eZAdCategory( $CategoryID );
72
73 $ad = new eZAd( );
74
75 $ad->setName( $AdTitle );
76 $ad->setDescription( $AdDescription );
77
78 if ( $IsActive == "on" )
79 {
80 $ad->setIsActive( true );
81 }
82 else
83 {
84 $ad->setIsActive( false );
85 }
86
87 if ( $UseHTML == "on" )
88 {
89 $ad->setUseHTML( true );
90 }
91 else
92 {
93 $ad->setUseHTML( false );
94 }
95
96 $ad->setHTMLBanner( $HTMLBanner );
97
98 // Why we cant make internal banners without http:// ? -- EP ---
99 // if ( !preg_match( "/^([a-z]+:\/\/)/", $adUrl ) )
100 // {
101 // if( !preg_match( "/^(ftp\.)/", $adUrl ) )
102 // $real_url = "http://" . $adUrl;
103 // else
104 // $real_url = "ftp://" . $adUrl;
105 // }
106 // else
107 // {
108 // $real_url = $adUrl;
109 // }
110 $real_url = $adUrl;
111
112 $ad->setURL( $real_url );
113
114 $ad->setClickPrice( $ClickPrice );
115 $ad->setViewPrice( $ViewPrice );
116
117 $file = new eZPBImageFile();
118
119 if ( $file->getUploadedFile( "AdImage" ) )
120 {
121 $image = new eZImage();
122 $image->setName( $Name );
123 $image->setCaption( $Caption );
124
125 $image->setImage( $file );
126
127 $image->store();
128
129 $ad->setImage( $image );
130
131 eZPBLog::writeNotice( "Picture added to ad: $AdID from IP: $REMOTE_ADDR" );
132 }
133
134 // $dateTime = new eZDateTime( 2000, 11, 13, 14, 0, 15 );
135 // $ad->setOriginalPublishingDate( $dateTime );
136
137 $ad->store();
138
139 $category->addAd( $ad );
140
141 if ( isset ( $Browse ) )
142 {
143 $adID = $ad->id();
144
145 $session =& eZSession::globalSession();
146 $session->setVariable( "SelectImages", "single" );
147 $session->setVariable( "ImageListReturnTo", "/ad/ad/edit/$adID/" );
148 $session->setVariable( "NameInBrowse", $ad->name() );
149 eZHTTPTool::header( "Location: /imagecatalogue/browse/" );
150 exit();
151 }
152 if ( isset( $Preview ) )
153 {
154 $Action = "Edit";
155 $AdID = $ad->id();
156 }
157 else
158 {
159 eZHTTPTool::header( "Location: /ad/archive/$CategoryID/" );
160 exit();
161 }
162
163 }
164
165 if ( $Action == "Update" )
166 {
167 $category = new eZAdCategory( $CategoryID );
168
169 $ad = new eZAd( $AdID );
170
171 $ad->setName( $AdTitle );
172 $ad->setDescription( $AdDescription );
173
174
175
176 if ( $IsActive == "on" )
177 {
178 $ad->setIsActive( true );
179 }
180 else
181 {
182 $ad->setIsActive( false );
183 }
184
185 if ( $UseHTML == "on" )
186 {
187 $ad->setUseHTML( true );
188 }
189 else
190 {
191 $ad->setUseHTML( false );
192 }
193
194 $ad->setHTMLBanner( $HTMLBanner );
195
196 // if ( !preg_match( "/^([a-z]+:\/\/)/", $adUrl ) )
197 // {
198 // if( !preg_match( "/^(ftp\.)/", $adUrl ) )
199 // $real_url = "http://" . $adUrl;
200 // else
201 // $real_url = "ftp://" . $adUrl;
202 // }
203 // else
204 // {
205 // $real_url = $adUrl;
206 // }
207
208 $real_url = $adUrl;
209
210 $ad->setURL( $real_url );
211
212 $ad->setClickPrice( $ClickPrice );
213 $ad->setViewPrice( $ViewPrice );
214
215 // $dateTime = new eZDateTime( 2000, 11, 13, 14, 0, 15 );
216 // $ad->setOriginalPublishingDate( $dateTime );
217
218 $file = new eZPBImageFile();
219
220 if ( $file->getUploadedFile( "AdImage" ) )
221 {
222 $image = new eZImage();
223 $image->setName( $Name );
224 $image->setCaption( $Caption );
225
226 $image->setImage( $file );
227
228 $image->store();
229
230 $ad->setImage( $image );
231
232 eZPBLog::writeNotice( "Picture added to ad: $AdID from IP: $REMOTE_ADDR" );
233 }
234
235 $ad->store();
236
237 $ad->removeFromCategories();
238 $category->addAd( $ad );
239
240 if ( isset ( $Browse ) )
241 {
242 $adID = $ad->id();
243
244 $session =& eZSession::globalSession();
245 $session->setVariable( "SelectImages", "single" );
246 $session->setVariable( "ImageListReturnTo", "/ad/ad/edit/$adID/" );
247 $session->setVariable( "NameInBrowse", $ad->name() );
248 eZHTTPTool::header( "Location: /imagecatalogue/browse/" );
249 exit();
250 }
251 if ( isset( $Preview ) )
252 {
253 $Action = "Edit";
254 }
255 else
256 {
257 eZHTTPTool::header( "Location: /ad/archive/$CategoryID/" );
258 exit();
259 }
260 }
261
262 if ( $Action == "Delete" )
263 {
264 $ad = new eZAd( $AdID );
265 $ad->delete();
266
267 eZHTTPTool::header( "Location: /ad/archive/$CategoryID/" );
268 exit();
269 }
270
271 if ( $Action == "DeleteAds" )
272 {
273 if ( count ( $AdArrayID ) != 0 )
274 {
275 foreach( $AdArrayID as $AdID )
276 {
277 $ad = new eZAd( $AdID );
278 $cat = $ad->categories();
279 $CategoryID = $cat[0]->id();
280 $ad->delete();
281 }
282 }
283
284 eZHTTPTool::header( "Location: /ad/archive/$CategoryID/" );
285 exit();
286 }
287
288
289 $ini =& eZINI::instance( 'site.ini' );
290 $Language = $ini->variable( "eZAdMain", "Language" );
291 $ImageDir = $ini->variable( "eZAdMain", "ImageDir" );
292
293 $t = new eZTemplate( "kernel/ezad/admin/" . $ini->variable( "eZAdMain", "AdminTemplateDir" ),
294 "kernel/ezad/admin/intl/", $Language, "adedit.php" );
295
296 $t->setAllStrings();
297
298 $t->set_file( array(
299 "ad_edit_page_tpl" => "adedit.tpl"
300 ) );
301
302 $t->set_block( "ad_edit_page_tpl", "value_tpl", "value" );
303 $t->set_block( "ad_edit_page_tpl", "image_tpl", "image" );
304
305
306 $t->set_var( "action_value", "insert" );
307
308 $t->set_var( "ad_title_value", "" );
309 $t->set_var( "ad_date_value", "" );
310 $t->set_var( "ad_description_value", "" );
311 $t->set_var( "ad_url_value", "" );
312 $t->set_var( "ad_click_price_value", "" );
313 $t->set_var( "ad_view_price_value", "" );
314 $t->set_var( "ad_id", "" );
315 $t->set_var( "image", "" );
316 $t->set_var( "html_banner", "" );
317 $t->set_var( "use_html", "" );
318
319 if ( $Action == "Edit" )
320 {
321 $ad = new eZAd( $AdID );
322
323 $t->set_var( "ad_title_value", $ad->name() );
324 $t->set_var( "ad_description_value", $ad->description() );
325 $t->set_var( "ad_url_value", $ad->url() );
326 $t->set_var( "ad_id", $ad->id() );
327 $t->set_var( "action_value", "update" );
328
329 $t->set_var( "ad_click_price_value", $ad->clickPrice() );
330 $t->set_var( "ad_view_price_value", $ad->viewPrice() );
331
332 $t->set_var( "html_banner", $ad->htmlBanner() );
333
334
335 if ( $ad->isActive() == true )
336 {
337 $t->set_var( "ad_is_active", "checked" );
338 }
339 else
340 {
341 $t->set_var( "ad_is_active", "" );
342 }
343
344 if ( $ad->useHTML() == true )
345 {
346 $t->set_var( "use_html", "checked" );
347 }
348 else
349 {
350 $t->set_var( "use_html", "" );
351 }
352
353 $image = $ad->image();
354
355
356 if ( $image )
357 {
358 $t->set_var( "image_src", $image->filePath() );
359 $t->set_var( "image_width", $image->width() );
360 $t->set_var( "image_height", $image->height() );
361 $t->set_var( "image_file_name", $image->originalFileName() );
362 $t->parse( "image", "image_tpl" );
363 }
364 else
365 {
366 $t->set_var( "image", "" );
367 }
368
369
370
371 $cats = $ad->categories();
372
373 $defCat = $cats[0];
374 }
375
376
377 // category select
378 $category = new eZAdCategory();
379 $categoryArray = $category->getTree();
380
381 foreach ( $categoryArray as $catItem )
382 {
383 if ( $Action == "Edit" )
384 {
385 if ( $defCat->id() == $catItem[0]->id() )
386 {
387 $t->set_var( "selected", "selected" );
388 }
389 else
390 {
391 $t->set_var( "selected", "" );
392 }
393 }
394 else
395 {
396 $t->set_var( "selected", "" );
397 }
398
399 if ( $catItem[1] > 0 )
400 $t->set_var( "option_level", str_repeat( "&nbsp;", $catItem[1] ) );
401 else
402 $t->set_var( "option_level", "" );
403
404 $t->set_var( "option_value", $catItem[0]->id() );
405 $t->set_var( "option_name", $catItem[0]->name() );
406
407 $t->parse( "value", "value_tpl", true );
408 }
409
410
411 $t->pparse( "output", "ad_edit_page_tpl" );
412
413 ?>
$ImageDir
$ImageDir
Definition: adedit.php:291
$t
$t
Definition: adedit.php:293
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$Language
$Language
Definition: adedit.php:290
$ini
if((isset( $AddImages)) and(is_numeric( $AdID)) and(is_numeric( $AdID))) if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") if( $Action=="DeleteAds") $ini
Definition: adedit.php:289
$categoryArray
$categoryArray
Definition: adedit.php:379
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$session
$session
Definition: admin/articlelist.php:44
$ad
$ad
Definition: adstatistics.php:56
eZAdCategory
Definition: ezadcategory.php:44
eZAd
Definition: ezad.php:46
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
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$ImageID
$ImageID
Definition: companytypelist.php:201
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
$Preview
$Preview
Definition: ezmessage/user/messageedit.php:121
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+.