Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezproductform.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezproductform.php 7602 2001-10-01 10:27:12Z pkej $
5 //
6 // ezproductform class
7 //
8 // Created on: <11-Jun-2001 12:07:57 pkej>
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
39 // include_once( "eztrade/classes/ezproduct.php" );
40
41 class eZProductForm
42 {
43
50 function __construct( $id=-1, $fetch=true )
51 {
52 if ( is_array( $id ) )
53 {
54 $this->fill( $id );
55 }
56 else if ( $id != -1 )
57 {
58 $this->ID = $id;
59 if ( $fetch == true )
60 {
61 $this->get( $this->ID );
62 }
63 }
64 }
65
69 function store()
70 {
71 $db =& eZDB::globalDatabase();
72
73 if( is_a( $this->Form, "eZForm" ) )
74 {
75 $FormID = $this->Form->id();
76 }
77
78 if( is_a( $this->Product, "eZProduct" ) )
79 {
80 $ProductID = $this->Product->id();
81 }
82
83 $setValues = "
84 FormID='$FormID',
85 ProductID='$ProductID'
86 ";
87
88 if ( empty( $this->ID ) )
89 {
90 $db->query( "INSERT INTO eZTrade_ProductFormDict SET $setValues" );
91
92 $this->ID = $db->insertID();
93 }
94 elseif ( is_numeric( $this->ID ) )
95 {
96 $db->query( "UPDATE eZTrade_ProductFormDict SET $setValues WHERE ID='$this->ID'" );
97 }
98 return true;
99 }
100
104 function delete( $formID=-1 )
105 {
106 if ( $formID == -1 )
107 $formID = $this->ID;
108
109 $db =& eZDB::globalDatabase();
110
111 $db->query( "DELETE FROM eZTrade_ProductFormDict WHERE ID=$formID" );
112 }
113
119 function get( $id=-1 )
120 {
121 $db =& eZDB::globalDatabase();
122
123 $ret = false;
124 if ( $id != "" )
125 {
126 $db->array_query( $formArray, "SELECT * FROM eZTrade_ProductFormDict WHERE ID='$id'",
127 0, 1 );
128 if( count( $formArray ) == 1 )
129 {
130 $this->fill( &$formArray[0] );
131 $ret = true;
132 }
133 elseif( count( $formArray ) != 1 )
134 {
135 $this->ID = 0;
136 }
137 }
138 return $ret;
139 }
140
144 function fill( &$formArray )
145 {
146 $this->ID =& $formArray[ "ID" ];
147
148 $this->Product =& new eZProduct( $formArray[ "ProductID" ] );
149 $this->Form =& new eZForm( $formArray[ "FormID" ] );
150 }
151
158 function &getAll( $offset=0, $limit=20 )
159 {
160 $db =& eZDB::globalDatabase();
161
162 $returnArray = array();
163 $formArray = array();
164
165 if ( $limit == false )
166 {
167 $db->array_query( $formArray, "SELECT ID
168 FROM eZTrade_ProductFormDict
169 " );
170
171 }
172 else
173 {
174 $db->array_query( $formArray, "SELECT ID
175 FROM eZTrade_ProductFormDict
176 LIMIT $offset, $limit" );
177 }
178
179 for ( $i=0; $i < count($formArray); $i++ )
180 {
181 $returnArray[$i] = new eZProductForm( $formArray[$i]["ID"] );
182 }
183
184 return $returnArray;
185 }
186
191 function count()
192 {
193 $db =& eZDB::globalDatabase();
194 $ret = false;
195
196 $db->query_single( $result, "SELECT COUNT(ID) as Count
197 FROM eZTrade_ProductFormDict" );
198 $ret = $result["Count"];
199 return $ret;
200 }
201
205 function id()
206 {
207 return $this->ID;
208 }
209
213 function &form()
214 {
215 return $this->Form;
216 }
217
221 function &receiver()
222 {
223 return $this->Product;
224 }
225
229 function setProduct( &$object )
230 {
231 if( is_a( $object, "eZProduct" ) )
232 {
233 $this->Product = $object;
234 }
235 }
236
240 function setForm( &$object )
241 {
242 if( is_a( $object, "eZForm" ) )
243 {
244 $this->Form = $object;
245 }
246 }
247
255 function &productHasForm( &$object )
256 {
257 $returnArray = array();
258 $formArray = array();
259
260 if( is_a( $object, "eZProduct" ) )
261 {
262 $ProductID = $object->id();
263 }
264
265 $db =& eZDB::globalDatabase();
266 $db->query_single( $qry, "SELECT FormID FROM eZTrade_ProductFormDict WHERE ProductID='$ProductID'" );
267
268 $ret =& new eZForm( $qry["FormID"] );
269
270 return $ret;
271 }
272
280 function &formHasProduct( &$object )
281 {
282 $returnArray = array();
283 $formArray = array();
284
285 if( is_a( $object, "eZForm" ) )
286 {
287 $FormID = $object->id();
288 }
289
290 $db =& eZDB::globalDatabase();
291 $db->query_single( $qry, "SELECT ProductID FROM eZTrade_ProductFormDict WHERE FormID='$FormID'" );
292
293 $ret =& eZProduct( $qry["ProductID"] );
294
295 return $ret;
296 }
297
298 var $ID;
299 var $Form;
300 var $Product;
301 }
302
303 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZForm
Definition: ezform.php:42
eZProductForm
Definition: ezproductform.php:42
eZProductForm\setForm
setForm(&$object)
Definition: ezproductform.php:240
eZProductForm\receiver
& receiver()
Definition: ezproductform.php:221
eZProductForm\store
store()
Definition: ezproductform.php:69
eZProductForm\id
id()
Definition: ezproductform.php:205
eZProductForm\form
& form()
Definition: ezproductform.php:213
eZProductForm\productHasForm
& productHasForm(&$object)
Definition: ezproductform.php:255
eZProductForm\getAll
& getAll( $offset=0, $limit=20)
Definition: ezproductform.php:158
eZProductForm\count
count()
Definition: ezproductform.php:191
eZProductForm\formHasProduct
& formHasProduct(&$object)
Definition: ezproductform.php:280
eZProductForm\__construct
__construct( $id=-1, $fetch=true)
Definition: ezproductform.php:50
eZProductForm\setProduct
setProduct(&$object)
Definition: ezproductform.php:229
eZProductForm\$Form
$Form
Definition: ezproductform.php:299
eZProductForm\$Product
$Product
Definition: ezproductform.php:300
eZProductForm\$ID
$ID
Definition: ezproductform.php:298
eZProductForm\fill
fill(&$formArray)
Definition: ezproductform.php:144
eZProduct
Definition: ezproduct.php:71
$result
$result
Definition: companysearch.php:94
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$limit
$limit
Definition: ezimagecatalogue/admin/imagelist.php:312
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$offset
$offset
Definition: ezstats/admin/cron.php:51
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.