Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezlinktype.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezlinktype.php 6220 2001-07-20 11:15:21Z jakobn $
5 //
6 // Definition of eZLinkType class
7 //
8 // Created on: <29-Jun-2001 11:13:12 jhe>
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
29 // include_once( "classes/ezdb.php" );
30 // include_once( "ezlink/classes/ezlinkattribute.php" );
31
32 class eZLinkType
33 {
38 function __construct( $id=-1 )
39 {
40 if ( $id != -1 )
41 {
42 $this->ID = $id;
43 $this->get( $this->ID );
44 }
45 }
46
50 function store()
51 {
52 $db =& eZDB::globalDatabase();
53
54 if ( !isset( $this->ID ) )
55 {
56 $db->lock( "eZLink_Type" );
57
58 $this->ID = $db->nextID( "eZLink_Type", "ID" );
59
60 $res = $db->query( "INSERT INTO eZLink_Type (ID,Name) VALUES
61 ('$this->ID','$this->Name')" );
62 $db->unlock();
63 }
64 else
65 {
66 $db->query( "UPDATE eZLink_Type SET
67 Name='$this->Name' WHERE ID='$this->ID'" );
68 }
69
70
71 if ( $res == false )
72 $db->rollback( );
73 else
74 $db->commit();
75
76 return true;
77 }
78
82 function get( $id=-1 )
83 {
84 $db =& eZDB::globalDatabase();
85
86 $ret = false;
87 if ( $id != -1 )
88 {
89 $db->array_query( $type_array, "SELECT * FROM eZLink_Type WHERE ID='$id'" );
90
91 if ( count( $type_array ) > 1 )
92 {
93 die( "Error: Link types with the same ID was found in the database. This shouldent happen." );
94 }
95 else if( count( $type_array ) == 1 )
96 {
97 $this->ID =& $type_array[0][$db->fieldName("ID")];
98 $this->Name =& $type_array[0][$db->fieldName("Name")];
99 $ret = true;
100 }
101 }
102
103 return $ret;
104 }
105
109 function &getAll()
110 {
111 $db =& eZDB::globalDatabase();
112
113 $return_array = array();
114 $type_array = array();
115
116 $db->array_query( $type_array, "SELECT ID FROM eZLink_Type ORDER BY Name" );
117
118 for ( $i=0; $i<count($type_array); $i++ )
119 {
120 $return_array[$i] = new eZLinkType( $type_array[$i][$db->fieldName("ID")], 0 );
121 }
122
123 return $return_array;
124 }
125
129 function delete()
130 {
131 $db =& eZDB::globalDatabase();
132
133 // delete all attributes and values
134 $attributes = $this->attributes();
135 foreach ( $attributes as $attribute )
136 {
137 $attribute->delete();
138 }
139
140 $db->query( "DELETE FROM eZLink_TypeLink WHERE TypeID='$this->ID'" );
141 $db->query( "DELETE FROM eZLink_Type WHERE ID='$this->ID'" );
142 }
143
147 function id()
148 {
149 return $this->ID;
150 }
151
155 function name()
156 {
157 return $this->Name;
158 }
159
163 function description()
164 {
165 return $this->Description;
166 }
167
171 function setName( $value )
172 {
173 $this->Name = $value;
174 }
175
179 function setDescription( $value )
180 {
181 $this->Description = $value;
182 }
183
188 function attributes( )
189 {
190 $db =& eZDB::globalDatabase();
191
192 $return_array = array();
193 $attribute_array = array();
194
195 $db->array_query( $attribute_array, "SELECT ID
196 FROM eZLink_Attribute
197 WHERE TypeID='$this->ID' ORDER BY Placement" );
198
199 for ( $i=0; $i<count($attribute_array); $i++ )
200 {
201 $return_array[$i] = new eZLinkAttribute( $attribute_array[$i][$db->fieldName("ID")], false );
202 }
203
204 return $return_array;
205 }
206
207 var $ID;
208 var $Name;
209
210 }
211
212 ?>
$i
$i
Definition: admin/adlist.php:91
$Description
$Description
Definition: articlelistrss.php:38
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZLinkAttribute
Definition: ezlinkattribute.php:33
eZLinkType
Definition: ezlinktype.php:33
eZLinkType\setName
setName( $value)
Definition: ezlinktype.php:171
eZLinkType\description
description()
Definition: ezlinktype.php:163
eZLinkType\store
store()
Definition: ezlinktype.php:50
eZLinkType\$Name
$Name
Definition: ezlinktype.php:208
eZLinkType\id
id()
Definition: ezlinktype.php:147
eZLinkType\$ID
$ID
Definition: ezlinktype.php:207
eZLinkType\getAll
& getAll()
Definition: ezlinktype.php:109
eZLinkType\setDescription
setDescription( $value)
Definition: ezlinktype.php:179
eZLinkType\attributes
attributes()
Definition: ezlinktype.php:188
eZLinkType\name
name()
Definition: ezlinktype.php:155
eZLinkType\__construct
__construct( $id=-1)
Definition: ezlinktype.php:38
$id
$id
Definition: companytypelist.php:193
$db
$db
Definition: ezarticle/user/authorlist.php:53
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$res
$res
Definition: ezstats/admin/cron.php:45
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+.