Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

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