Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezformelementtype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezformelementtype.php 7709 2001-10-09 08:06:02Z ce $
5 //
6 // ezformelementtype 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( "ezform/classes/ezform.php" );
40
41 class eZFormElementType
42 {
43
50 function __construct( $id=-1 )
51 {
52 if ( is_array( $id ) )
53 {
54 $this->fill( $id );
55 }
56 else if ( $id != -1 )
57 {
58 $this->ID = $id;
59 $this->get( $this->ID );
60 }
61 }
62
66 function store()
67 {
68 $db =& eZDB::globalDatabase();
69 $db->begin();
70
71 $name = $db->escapeString( $this->Name );
72 $description = $db->escapeString( $this->Description );
73
74 if ( empty( $this->ID ) )
75 {
76 $db->lock( "eZForm_FormElementType" );
77 $nextID = $db->nextID( "eZForm_FormElementType", "ID" );
78 $res[] = $db->query( "INSERT INTO eZForm_FormElementType
79 ( ID, Name, Description )
80 VALUES
81 ( '$nextID', '$name', '$description' )" );
82
83 $this->ID = $nextID;
84 }
85 elseif ( is_numeric( $this->ID ) )
86 {
87 $res[] = $db->query( "UPDATE eZForm_FormElementType SET $setValues WHERE ID='$this->ID'" );
88 }
89 eZDB::finish( $res, $db );
90 return true;
91 }
92
96 function delete( $formID=-1 )
97 {
98 if ( $formID == -1 )
99 $formID = $this->ID;
100
101 $db =& eZDB::globalDatabase();
102 $db->begin();
103
104 $formElements =& $this->formElements();
105 if ( is_array ( $formElements ) )
106 {
107 foreach( $formElements as $element )
108 {
109 $formElements->delete();
110 }
111 }
112
113 $res[] = $db->query( "DELETE FROM eZForm_FormElementType WHERE ID=$formID" );
114 eZDB::finish( $res, $db );
115
116 }
117
123 function get( $id=-1 )
124 {
125 $db =& eZDB::globalDatabase();
126
127 $ret = false;
128 if ( $id != "-1" )
129 {
130 $db->array_query( $formArray, "SELECT * FROM eZForm_FormElementType WHERE ID='$id'",
131 0, 1 );
132
133 if( count( $formArray ) == 1 )
134 {
135 $this->fill( $formArray[0] );
136 $ret = true;
137 }
138 elseif( count( $formArray ) != 1 )
139 {
140 $this->ID = 0;
141 }
142 }
143 return $ret;
144 }
145
149 function fill( &$formArray )
150 {
151 $db =& eZDB::globalDatabase();
152 $this->ID = $formArray[$db->fieldName( "ID" )];
153 $this->Name = $formArray[$db->fieldName( "Name" )];
154 $this->Description = $formArray[$db->fieldName( "Description" )];
155 }
156
162 function &getAll( $offset=0, $limit=20 )
163 {
164 $db =& eZDB::globalDatabase();
165
166 $returnArray = array();
167 $formArray = array();
168
169 if ( $limit == false )
170 {
171 $db->array_query( $formArray, "SELECT ID
172 FROM eZForm_FormElementType
173 ORDER BY Name DESC
174 " );
175
176 }
177 else
178 {
179 $db->array_query( $formArray, "SELECT ID
180 FROM eZForm_FormElementType
181 ORDER BY Name DESC",
182 array( "Limit" => $limit, "Offset" => $offset ) );
183 }
184
185 for ( $i=0; $i < count($formArray); $i++ )
186 {
187 $returnArray[$i] = new eZFormElementType( $formArray[$i][$db->fieldName( "ID" )] );
188 }
189
190 return $returnArray;
191 }
192
196 function count()
197 {
198 $db =& eZDB::globalDatabase();
199 $ret = false;
200
201 $db->query_single( $result, "SELECT COUNT(ID) as Count
202 FROM eZForm_FormElementType" );
203 $ret = $result[$db->fieldName( "Count" )];
204 return $ret;
205 }
206
210 function id()
211 {
212 return $this->ID;
213 }
214
218 function &name()
219 {
220 return htmlspecialchars( $this->Name );
221 }
222
226 function &description()
227 {
228 return htmlspecialchars( $this->Description );
229 }
230
231
232
236 function setName( &$value )
237 {
238 $this->Name = $value;
239 }
240
244 function setDescription( &$value )
245 {
246 $this->Description = $value;
247 }
248
253 function &formElements()
254 {
255 $returnArray = array();
256 $formArray = array();
257
258 $db =& eZDB::globalDatabase();
259 $db->array_query( $formArray, "SELECT ID FROM eZForm_FormElement WHERE ElementTypeID='$this->ID'" );
260
261 for ( $i=0; $i < count($formArray); $i++ )
262 {
263 $returnArray[$i] = new eZFormElement( $formArray[$i][$db->fieldName( "ID" )], true );
264 }
265 return $returnArray;
266 }
267
271 function &numberOfTypes()
272 {
273 $db =& eZDB::globalDatabase();
274 $ret = false;
275
276 $db->query_single( $result, "SELECT COUNT(ID) as Count
277 FROM eZForm_FormElementType" );
278 $ret = $result[$db->fieldName( "Count" )];
279
280 return $ret;
281 }
282
283 var $ID;
284 var $Name;
285 var $Description;
286 }
287
288 ?>
$i
$i
Definition: admin/adlist.php:91
eZDB\finish
static finish(&$resultArray, &$db)
Definition: ezdb.php:204
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZFormElementType
Definition: ezformelementtype.php:42
eZFormElementType\numberOfTypes
& numberOfTypes()
Definition: ezformelementtype.php:271
eZFormElementType\__construct
__construct( $id=-1)
Definition: ezformelementtype.php:50
eZFormElementType\$ID
$ID
Definition: ezformelementtype.php:283
eZFormElementType\formElements
& formElements()
Definition: ezformelementtype.php:253
eZFormElementType\$Description
$Description
Definition: ezformelementtype.php:285
eZFormElementType\$Name
$Name
Definition: ezformelementtype.php:284
eZFormElementType\store
store()
Definition: ezformelementtype.php:66
eZFormElementType\description
& description()
Definition: ezformelementtype.php:226
eZFormElementType\setName
setName(&$value)
Definition: ezformelementtype.php:236
eZFormElementType\id
id()
Definition: ezformelementtype.php:210
eZFormElementType\setDescription
setDescription(&$value)
Definition: ezformelementtype.php:244
eZFormElementType\name
& name()
Definition: ezformelementtype.php:218
eZFormElementType\getAll
& getAll( $offset=0, $limit=20)
Definition: ezformelementtype.php:162
eZFormElementType\fill
fill(&$formArray)
Definition: ezformelementtype.php:149
eZFormElementType\count
count()
Definition: ezformelementtype.php:196
eZFormElement
Definition: ezformelement.php:44
$result
$result
Definition: companysearch.php:94
$name
$name
Definition: companytypelist.php:194
$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
$res
$res
Definition: ezstats/admin/cron.php:45
$offset
$offset
Definition: ezstats/admin/cron.php:51
$element
if(! $parent) $element
Definition: folder.php:64
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
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.