Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztip.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: eztip.php,v 1.28.2.1 2001/11/23 09:39:00 br Exp $
5 //
6 // Definition of eZTip class
7 //
8 // Created on: <22-Nov-2000 20:01:05 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
40 // include_once( "classes/ezdb.php" );
41 // include_once( "classes/ezdatetime.php" );
42
43 // include_once( "ezimagecatalogue/classes/ezimage.php" );
44
45 class eZTip
46 {
53 function __construct( $id="" )
54 {
55 $this->ImageID = 0;
56 $this->IsActive = 1;
57 $this->UseHTML = 0;
58 $this->ViewStartDate = 0;
59 $this->HTMLBanner = "";
60 $this->Name = "";
61 $this->Description = "";
62 $this->URL = "";
63 $this->ViewRule = "clicks"; // default view rule is clicks.
64
65 if ( $id != "" )
66 {
67 $this->ID = $id;
68 $this->get( $this->ID );
69 }
70 }
71
75 function store()
76 {
77 $db =& eZDB::globalDatabase();
78
79 $db->begin( );
80 $res = $db->query( "UPDATE eZTip_View
81 SET ViewOffsetCount = 1" );
82
83 $name = $db->escapeString( $this->Name );
84 $description = $db->escapeString( $this->Description );
85 $url = $db->escapeString( $this->URL );
86 $htmlbanner = $db->escapeString( $this->HTMLBanner );
87
88 if ( !isset( $this->ID ) )
89 {
90 $db->lock( "eZTip_Tip" );
91
92 $nextID = $db->nextID( "eZTip_Tip", "ID" );
93
94 $res = $db->query( "INSERT INTO eZTip_Tip
95 ( ID,
96 Name,
97 Description,
98 ImageID,
99 IsActive,
100 URL,
101 HTMLBanner,
102 UseHTML )
103 VALUES
104 ( '$nextID',
105 '$name',
106 '$description',
107 '$this->ImageID',
108 '$this->IsActive',
109 '$url',
110 '$htmlbanner',
111 '$this->UseHTML' )
112 " );
113
114
115 $this->ID = $nextID;
116
117 $this->addPageView( );
118 $db->unlock();
119 }
120 else
121 {
122 $res = $db->query( "UPDATE eZTip_Tip SET
123 Name='$name',
124 Description='$description',
125 ImageID='$this->ImageID',
126 IsActive='$this->IsActive',
127 URL='$url',
128 HTMLBanner='$htmlbanner',
129 UseHTML='$this->UseHTML'
130 WHERE ID='$this->ID'
131 " );
132 }
133
134
135 if ( $res == false )
136 $db->rollback( );
137 else
138 $db->commit();
139
140
141 return true;
142 }
143
147 function get( $id="" )
148 {
149 $db =& eZDB::globalDatabase();
150
151 $ret = false;
152
153 if ( $id != "" )
154 {
155 $db->array_query( $tip_array, "SELECT * FROM eZTip_Tip WHERE ID='$id'" );
156 if ( count( $tip_array ) > 1 )
157 {
158 die( "Error: Tip's with the same ID was found in the database. This shouldent happen." );
159 }
160 else if( count( $tip_array ) == 1 )
161 {
162 $this->ID =& $tip_array[0][$db->fieldName("ID")];
163 $this->Name =& $tip_array[0][$db->fieldName("Name")];
164 $this->Description =& $tip_array[0][$db->fieldName("Description")];
165 $this->IsActive =& $tip_array[0][$db->fieldName("IsActive")];
166 $this->URL =& $tip_array[0][$db->fieldName("URL")];
167 $this->ImageID =& $tip_array[0][$db->fieldName("ImageID")];
168 $this->HTMLBanner =& $tip_array[0][$db->fieldName("HTMLBanner")];
169 $this->UseHTML =& $tip_array[0][$db->fieldName("UseHTML")];
170
171 $ret = true;
172 }
173 }
174 return $ret;
175 }
176
180 function delete()
181 {
182 $db =& eZDB::globalDatabase();
183
184 if ( isset( $this->ID ) )
185 {
186 $db->query( "DELETE FROM eZTip_View WHERE TipID='$this->ID'" );
187 $db->query( "DELETE FROM eZTip_Click WHERE TipID='$this->ID'" );
188
189 $db->query( "DELETE FROM eZTip_TipCategoryLink WHERE TipID='$this->ID'" );
190 $db->query( "DELETE FROM eZTip_Tip WHERE ID='$this->ID'" );
191 }
192
193 return true;
194 }
195
199 function id()
200 {
201 return $this->ID;
202 }
203
207 function &name()
208 {
209 return htmlspecialchars( $this->Name );
210 }
211
215 function &description()
216 {
217 return htmlspecialchars( $this->Description );
218 }
219
223 function &url()
224 {
225 return $this->URL;
226 }
227
231 function &clickPrice()
232 {
233 return $this->ClickPrice;
234 }
235
239 function &viewPrice()
240 {
241 return $this->ViewPrice;
242 }
243
247 function isActive()
248 {
249 $ret = false;
250
251 if ( $this->IsActive == "1" )
252 {
253 $ret = true;
254 }
255 return $ret;
256 }
257
261 function useHTML()
262 {
263 $ret = false;
264
265 if ( $this->UseHTML == 1 )
266 {
267 $ret = true;
268 }
269 return $ret;
270 }
271
275 function &htmlBanner()
276 {
277 return $this->HTMLBanner;
278 }
279
283 function &viewStartDate()
284 {
285 $dateTime = new eZDateTime();
286 $dateTime->setTimeStamp( $this->ViewStartDate );
287
288 return $dateTime;
289 }
290
294 function &viewStopDate()
295 {
296 $dateTime = new eZDateTime();
297 $dateTime->setTimeStamp( $this->ViewStopDate );
298
299 return $dateTime;
300 }
301
305 function setName( $value )
306 {
307 $this->Name = $value;
308 }
309
313 function setDescription( $value )
314 {
315 $this->Description = $value;
316 }
317
321 function setURL( $value )
322 {
323 $this->URL = $value;
324 }
325
326
330 function setIsActive( $value )
331 {
332 if ( $value == true )
333 {
334 $this->IsActive = 1;
335 }
336 else
337 {
338 $this->IsActive = 0;
339 }
340 }
341
345 function setHTMLBanner( $value )
346 {
347 $this->HTMLBanner = $value;
348 }
349
353 function setUseHTML( $value )
354 {
355 if ( $value == true )
356 {
357 $this->UseHTML = 1;
358 }
359 else
360 {
361 $this->UseHTML = 0;
362 }
363 }
364
370 function &categories()
371 {
372 $db =& eZDB::globalDatabase();
373
374 $ret = array();
375 $db->array_query( $category_array, "SELECT * FROM
376 eZTip_TipCategoryLink
377 WHERE TipID='$this->ID'" );
378 foreach ( $category_array as $category )
379 {
380 $ret[] = new eZTipCategory( $category[$db->fieldName("CategoryID")] );
381 }
382
383 return $ret;
384 }
385
389 function removeFromCategories()
390 {
391 $db =& eZDB::globalDatabase();
392
393 $db->query( "DELETE FROM eZTip_TipCategoryLink
394 WHERE TipID='$this->ID'" );
395 }
396
400 function setImage( $value )
401 {
402 if ( get_class( $value ) == "ezimage" )
403 {
404 $db =& eZDB::globalDatabase();
405
406 $this->ImageID = $value->id();
407 }
408 }
409
415 function deleteImage( $value )
416 {
417 if ( get_class( $value ) == "ezimage" )
418 {
419 $db =& eZDB::globalDatabase();
420
421 $imageID = $value->id();
422
423 $image = new eZImage( $imageID );
424 $image->delete();
425 }
426 }
427
431 function image()
432 {
433 $db =& eZDB::globalDatabase();
434
435 $ret = false;
436 $img = new eZImage( );
437
438 if ( $img->get( $this->ImageID ) )
439 {
440 $ret = $img;
441 }
442
443 return $ret;
444 }
445
449 function addPageView( )
450 {
451 $db =& eZDB::globalDatabase();
452
453 $db->begin();
454
455 $dateTime = new eZDateTime();
456 $date = $dateTime->timeStamp( true );
457
458 $db->lock( "eZTip_View" );
459
460 $db->array_query( $view_result, "SELECT * FROM
461 eZTip_View
462 WHERE TipID='$this->ID'" );
463 if ( count( $view_result ) == 0 )
464 {
465
466 $nextID = $db->nextID( "eZTip_View", "ID" );
467
468 // get the lowest
469 $db->array_query( $view_offset, "SELECT * FROM
470 eZTip_View
471 ORDER BY ViewOffsetCount" );
472
473 // set all offsets to 1.
474 $db->query( "UPDATE eZTip_View
475 SET ViewOffsetCount='1'" );
476
477 if ( count( $view_offset ) > 0 )
478 $offs = $view_offset[0][$db->fieldName("ViewOffsetCount")];
479 else
480 $offs = 1;
481
482 $dateTime = new eZDateTime();
483 $timeStamp= $dateTime->timeStamp( true );
484
485 $res = $db->query( "INSERT INTO eZTip_View
486 ( ID,
487 TipID,
488 ViewCount,
489 ViewOffsetCount,
490 Date )
491 VALUES
492 ( '$nextID',
493 '$this->ID',
494 '1',
495 '$offs',
496 '$timeStamp' )" );
497 }
498 else
499 {
500 $query = "UPDATE eZTip_View SET
501 ViewCount=(ViewCount + 1),
502 ViewOffsetCount=(ViewOffsetCount + 1)
503 WHERE TipID='$this->ID'";
504
505 $res = $db->query( $query );
506 }
507
508 $db->unlock();
509
510 if ( $res == false )
511 {
512 $db->rollback( );
513 }
514 else
515 {
516 $db->commit();
517 }
518
519 }
520
524 function viewCount( )
525 {
526 $db =& eZDB::globalDatabase();
527
528 $db->array_query( $view_result, "SELECT sum(ViewCount) as ViewCount FROM
529 eZTip_View
530 WHERE TipID='$this->ID'" );
531
532 return $view_result[0][$db->fieldName("ViewCount")];
533 }
534
538 function clickCount( )
539 {
540 $db =& eZDB::globalDatabase();
541
542 $db->array_query( $click_result, "SELECT count(*) AS Count FROM
543 eZTip_Click
544 WHERE TipID='$this->ID'" );
545
546 return $click_result[0][$db->fieldName("Count")];
547 }
548
549
550 var $ID;
551 var $Name;
552 var $Description;
553 var $ImageID;
554 var $ViewStartDate;
555 var $HTMLBanner;
556 var $UseHTML;
557
559 var $IsActive;
560
562 var $ViewRule;
563
565 var $URL;
566 var $ClickPrice;
567 var $ViewPrice;
568
569 }
570
571 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$dateTime
$dateTime
Definition: authorview.php:77
$date
$date
Definition: bugpreview.php:66
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZImage
Definition: ezimage.php:95
eZTipCategory
Definition: eztipcategory.php:44
eZTip
Definition: eztip.php:46
eZTip\name
& name()
Definition: eztip.php:207
eZTip\$ID
$ID
Definition: eztip.php:550
eZTip\setDescription
setDescription( $value)
Definition: eztip.php:313
eZTip\url
& url()
Definition: eztip.php:223
eZTip\__construct
__construct( $id="")
Definition: eztip.php:53
eZTip\store
store()
Definition: eztip.php:75
eZTip\setImage
setImage( $value)
Definition: eztip.php:400
eZTip\setHTMLBanner
setHTMLBanner( $value)
Definition: eztip.php:345
eZTip\$ImageID
$ImageID
Definition: eztip.php:553
eZTip\$ViewRule
$ViewRule
Indicates if the banner should be viewed by date or by clicks.
Definition: eztip.php:562
eZTip\isActive
isActive()
Definition: eztip.php:247
eZTip\clickPrice
& clickPrice()
Definition: eztip.php:231
eZTip\setUseHTML
setUseHTML( $value)
Definition: eztip.php:353
eZTip\clickCount
clickCount()
Definition: eztip.php:538
eZTip\removeFromCategories
removeFromCategories()
Definition: eztip.php:389
eZTip\setURL
setURL( $value)
Definition: eztip.php:321
eZTip\useHTML
useHTML()
Definition: eztip.php:261
eZTip\viewStopDate
& viewStopDate()
Definition: eztip.php:294
eZTip\categories
& categories()
Definition: eztip.php:370
eZTip\id
id()
Definition: eztip.php:199
eZTip\$HTMLBanner
$HTMLBanner
Definition: eztip.php:555
eZTip\htmlBanner
& htmlBanner()
Definition: eztip.php:275
eZTip\$ViewStartDate
$ViewStartDate
Definition: eztip.php:554
eZTip\$IsActive
$IsActive
Indicates if the banner is active or not.
Definition: eztip.php:559
eZTip\$ViewPrice
$ViewPrice
Definition: eztip.php:567
eZTip\viewStartDate
& viewStartDate()
Definition: eztip.php:283
eZTip\$Name
$Name
Definition: eztip.php:551
eZTip\addPageView
addPageView()
Definition: eztip.php:449
eZTip\$UseHTML
$UseHTML
Definition: eztip.php:556
eZTip\deleteImage
deleteImage( $value)
Definition: eztip.php:415
eZTip\image
image()
Definition: eztip.php:431
eZTip\description
& description()
Definition: eztip.php:215
eZTip\setIsActive
setIsActive( $value)
Definition: eztip.php:330
eZTip\$ClickPrice
$ClickPrice
Definition: eztip.php:566
eZTip\$Description
$Description
Definition: eztip.php:552
eZTip\viewCount
viewCount()
Definition: eztip.php:524
eZTip\setName
setName( $value)
Definition: eztip.php:305
eZTip\viewPrice
& viewPrice()
Definition: eztip.php:239
eZTip\$URL
$URL
The URL to go to when the banner is clicked.
Definition: eztip.php:565
$name
$name
Definition: companytypelist.php:194
$id
$id
Definition: companytypelist.php:193
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
$url
$url
Definition: messagereviewlist.php:153
Name
if($user) if(isset( $next) && $next)<?=isset($all_fields_error) &&$all_fields_error ?><?=isset($password_error) &&$password_error ?></p ><? endif;?>< form method="post">< table border="0" cellspacing="2" cellpadding="2" class="boxtext" style="font-size=13;">< tr >< td style="color:<?= isset( $error['first_name'] ) ?> First Name
Definition: step1.php:127
$category_array
$category_array
Definition: todoedit.php:604
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.