Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticleform.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezarticleform.php 6206 2001-07-19 12:19:22Z jakobn $
5 //
6 // ezarticleform 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( "ezarticle/classes/ezarticle.php" );
40
41 class eZArticleForm
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->Article, "eZArticle" ) )
79 {
80 $ArticleID = $this->Article->id();
81 }
82
83 $setValues = "
84 FormID='$FormID',
85 ArticleID='$ArticleID'
86 ";
87
88 if ( empty( $this->ID ) )
89 {
90 $db->query( "INSERT INTO eZArticle_ArticleFormDict SET $setValues" );
91
92 $this->ID = $db->insertID();
93 }
94 elseif ( is_numeric( $this->ID ) )
95 {
96 $db->query( "UPDATE eZArticle_ArticleFormDict 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 eZArticle_ArticleFormDict 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 eZArticle_ArticleFormDict 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->Article = new eZArticle( $formArray[ "ArticleID" ] );
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 eZArticle_ArticleFormDict
169 " );
170
171 }
172 else
173 {
174 $db->array_query( $formArray, "SELECT ID
175 FROM eZArticle_ArticleFormDict
176 LIMIT $offset, $limit" );
177 }
178
179 for ( $i=0; $i < count($formArray); $i++ )
180 {
181 $returnArray[$i] = new eZArticleForm( $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 eZArticle_ArticleFormDict" );
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->Article;
224 }
225
229 function setArticle( &$object )
230 {
231 if( is_a( $object, "eZArticle" ) )
232 {
233 $this->Article = $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 &articleHasForm( &$object )
256 {
257 $returnArray = array();
258 $formArray = array();
259
260 if( is_a( $object, "eZArticle" ) )
261 {
262 $ArticleID = $object->id();
263 }
264
265 $db = eZDB::globalDatabase();
266 $db->query_single( $qry, "SELECT FormID FROM eZArticle_ArticleFormDict WHERE ArticleID='$ArticleID'" );
267
268 if (is_array($qry)) {
269 $ret = new eZForm( $qry["FormID"] );
270 } else {
271 $ret = new eZForm( );
272 }
273
274 return $ret;
275 }
276
284 function &formHasArticle( &$object )
285 {
286 $returnArray = array();
287 $formArray = array();
288
289 if( is_a( $object, "eZForm" ) )
290 {
291 $FormID = $object->id();
292 }
293
294 $db =& eZDB::globalDatabase();
295 $db->query_single( $qry, "SELECT ArticleID FROM eZArticle_ArticleFormDict WHERE FormID='$FormID'" );
296
297 $ret =& eZArticle( $qry["ArticleID"] );
298
299 return $ret;
300 }
301
302 var $ID;
303 var $Form;
304 var $Article;
305 }
306
307 ?>
$i
$i
Definition: admin/adlist.php:91
eZArticleForm
Definition: ezarticleform.php:42
eZArticleForm\setForm
setForm(&$object)
Definition: ezarticleform.php:240
eZArticleForm\formHasArticle
& formHasArticle(&$object)
Definition: ezarticleform.php:284
eZArticleForm\getAll
& getAll( $offset=0, $limit=20)
Definition: ezarticleform.php:158
eZArticleForm\form
& form()
Definition: ezarticleform.php:213
eZArticleForm\$Article
$Article
Definition: ezarticleform.php:304
eZArticleForm\id
id()
Definition: ezarticleform.php:205
eZArticleForm\$Form
$Form
Definition: ezarticleform.php:303
eZArticleForm\fill
fill(&$formArray)
Definition: ezarticleform.php:144
eZArticleForm\receiver
& receiver()
Definition: ezarticleform.php:221
eZArticleForm\store
store()
Definition: ezarticleform.php:69
eZArticleForm\$ID
$ID
Definition: ezarticleform.php:302
eZArticleForm\articleHasForm
& articleHasForm(&$object)
Definition: ezarticleform.php:255
eZArticleForm\__construct
__construct( $id=-1, $fetch=true)
Definition: ezarticleform.php:50
eZArticleForm\count
count()
Definition: ezarticleform.php:191
eZArticleForm\setArticle
setArticle(&$object)
Definition: ezarticleform.php:229
eZArticle
Definition: ezarticle.php:82
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZForm
Definition: ezform.php:42
$result
$result
Definition: companysearch.php:94
$id
$id
Definition: companytypelist.php:193
$ArticleID
$ArticleID
Definition: export.php:48
$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+.