Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezisbnregistrantrange.php
Go to the documentation of this file.
1 <?php
29 class eZISBNRegistrantRange extends eZPersistentObject
30 {
34 static function definition()
35 {
36 return array( 'fields' => array( 'id' => array( 'name' => 'ID',
37 'datatype' => 'integer',
38 'default' => 0,
39 'required' => true ),
40 'from_number' => array( 'name' => 'FromNumber',
41 'datatype' => 'integer',
42 'default' => 0,
43 'required' => true ),
44 'to_number' => array( 'name' => 'ToNumber',
45 'datatype' => 'integer',
46 'default' => 0,
47 'required' => true ),
48 'registrant_from' => array( 'name' => 'RegistrantFrom',
49 'datatype' => 'string',
50 'default' => '',
51 'required' => true ),
52 'registrant_to' => array( 'name' => 'RegistrantTo',
53 'datatype' => 'string',
54 'default' => '',
55 'required' => true ),
56 'registrant_length' => array( 'name' => 'RegistrantLength',
57 'datatype' => 'integer',
58 'default' => 0,
59 'required' => true ),
60 'isbn_group_id' => array( 'name' => 'ISBNGroupID',
61 'datatype' => 'integer',
62 'default' => 0,
63 'required' => true,
64 'foreign_class' => 'eZISBNGroup',
65 'foreign_attribute' => 'id',
66 'multiplicity' => '1..*' ),
67 ),
68 'keys' => array( 'id' ),
69 'increment_key' => 'id',
70 'class_name' => 'eZISBNRegistrantRange',
71 'name' => 'ezisbn_registrant_range' );
72 }
73
92 static function create( $ISBNGroupID, $fromNumber, $toNumber, $registrantFrom, $registrantTo, $length )
93 {
94 $row = array(
95 'id' => null,
96 'from_number' => $fromNumber,
97 'to_number' => $toNumber,
98 'registrant_from' => $registrantFrom,
99 'registrant_to' => $registrantTo,
100 'registrant_length' => $length,
101 'isbn_group_id' => $ISBNGroupID );
102 return new eZISBNRegistrantRange( $row );
103 }
104
105
110 static function removeByID( $id )
111 {
112 eZPersistentObject::removeObject( eZISBNRegistrantRange::definition(),
113 array( 'id' => $id ) );
114 }
115
126 static function fetchListByGroupID( $groupID, $asObject = true )
127 {
128 $conditions = array( 'isbn_group_id' => $groupID );
129 $sortArray = array( array( 'from_number' => 'asc' ) );
130 return eZPersistentObject::fetchObjectList( eZISBNRegistrantRange::definition(),
131 null, $conditions, $sortArray, null,
132 $asObject );
133 }
134
151 static function extractRegistrant( $isbnNr, $group, $groupRange, &$registrantLength )
152 {
153 $registrant = false;
154 if ( $group instanceof eZISBNGroup and
155 $groupRange instanceof eZISBNGroupRange )
156 {
157 $groupLength = $groupRange->attribute( 'group_length' );
158 $groupID = $group->attribute( 'id' );
159
160 $registrantOffset = 3 + $groupLength;
161 $testSegment = substr( $isbnNr, $registrantOffset, 5 );
162 if ( is_numeric( $testSegment ) )
163 {
164 $conditions = array( 'from_number' => array( '<=', $testSegment ),
165 'to_number' => array( '>=', $testSegment ),
166 'isbn_group_id' => $groupID );
167 $groupRangeArray = eZPersistentObject::fetchObjectList( eZISBNRegistrantRange::definition(),
168 null, $conditions, null, null,
169 true );
170 if ( count( $groupRangeArray ) == 1 )
171 {
172 $length = $groupRangeArray[0]->attribute( 'registrant_length' );
173
174 // Copy the length to send it back as a reference.
175 $registrantLength = $length;
176 $registrant = $groupRangeArray[0];
177 }
178 }
179 }
180 return $registrant;
181 }
182
187 static function cleanAll()
188 {
189 $db = eZDB::instance();
190 $definition = eZISBNRegistrantRange::definition();
191 $table = $definition['name'];
192 if ( $db->DatabaseName() == 'sqlite' )
193 $sql = "DELETE FROM " . $table;
194 else
195 {
196 $sql = "TRUNCATE TABLE " . $table;
197 }
198 $db->query( $sql );
199 }
200 }
201
202 ?>
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
eZISBNGroupRange
The class eZISBNGroupRange handle registration group ranges.
Definition: ezisbngrouprange.php:26
eZISBNGroup
The class eZISBNGroup handles ISBN Registration groups.
Definition: ezisbngroup.php:24
eZISBNRegistrantRange
The class eZISBNRegistrantRange handles Registrant ranges.
Definition: ezisbnregistrantrange.php:30
eZISBNRegistrantRange\definition
static definition()
Definition: ezisbnregistrantrange.php:34
eZISBNRegistrantRange\extractRegistrant
static extractRegistrant( $isbnNr, $group, $groupRange, &$registrantLength)
Definition: ezisbnregistrantrange.php:151
eZISBNRegistrantRange\cleanAll
static cleanAll()
Definition: ezisbnregistrantrange.php:187
eZISBNRegistrantRange\fetchListByGroupID
static fetchListByGroupID( $groupID, $asObject=true)
Definition: ezisbnregistrantrange.php:126
eZISBNRegistrantRange\create
static create( $ISBNGroupID, $fromNumber, $toNumber, $registrantFrom, $registrantTo, $length)
Definition: ezisbnregistrantrange.php:92
eZISBNRegistrantRange\removeByID
static removeByID( $id)
Definition: ezisbnregistrantrange.php:110
eZPersistentObject
Definition: ezpersistentobject.php:33
eZPersistentObject\removeObject
static removeObject( $def, $conditions=null, $extraConditions=null)
Definition: ezpersistentobject.php:271
eZPersistentObject\count
static count( $def, $conds=null, $field=null)
Definition: ezpersistentobject.php:187
eZPersistentObject\fetchObjectList
static fetchObjectList( $def, $field_filters=null, $conds=null, $sorts=null, $limit=null, $asObject=true, $grouping=false, $custom_fields=null, $custom_tables=null, $custom_conds=null)
Definition: ezpersistentobject.php:806
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.