|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Created on: <17-Apr-2007 11:07:53 bjorn> 00004 // 00005 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00006 // SOFTWARE NAME: eZ Publish 00007 // SOFTWARE RELEASE: 4.0.x 00008 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00009 // SOFTWARE LICENSE: GNU General Public License v2.0 00010 // NOTICE: > 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of version 2.0 of the GNU General 00013 // Public License as published by the Free Software Foundation. 00014 // 00015 // This program is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of version 2.0 of the GNU General 00021 // Public License along with this program; if not, write to the Free 00022 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00023 // MA 02110-1301, USA. 00024 // 00025 // 00026 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00027 // 00028 00029 /*! \file ezisbngroup.php 00030 */ 00031 00032 /*! 00033 \class eZISBNGroup ezisbngroup.php 00034 \brief The class eZISBNGroup handles ISBN Registration groups. 00035 00036 Contains a list of registration numbers that exists for each area. The registration group is 00037 the second field of an ISBN-13 number. Example: 978-0-11-000222-4 where 0 is the registration 00038 group number. 00039 00040 The different Registration numbers are described in more detail at 00041 http://www.isbn-international.org 00042 */ 00043 00044 //include_once( 'kernel/classes/ezpersistentobject.php' ); 00045 00046 class eZISBNGroup extends eZPersistentObject 00047 { 00048 /*! 00049 Constructor 00050 */ 00051 function eZISBNGroup( $row ) 00052 { 00053 $this->eZPersistentObject( $row ); 00054 } 00055 00056 /*! 00057 \static 00058 returns a definition of the ISBN group. 00059 */ 00060 static function definition() 00061 { 00062 return array( 'fields' => array( 'id' => array( 'name' => 'ID', 00063 'datatype' => 'integer', 00064 'default' => 0, 00065 'required' => true ), 00066 'description' => array( 'name' => 'Description', 00067 'datatype' => 'string', 00068 'default' => '', 00069 'required' => false ), 00070 'group_number' => array( 'name' => 'GroupNumber', 00071 'datatype' => 'integer', 00072 'default' => 0, 00073 'required' => true ), 00074 ), 00075 'keys' => array( 'id' ), 00076 'increment_key' => 'id', 00077 'class_name' => 'eZISBNGroup', 00078 'name' => 'ezisbn_group' ); 00079 } 00080 00081 /*! 00082 \static 00083 Create a new area for an ISBN number. 00084 \param $groupNumber is the unique identifier for the area. Could be from 1 to 5 digits. 00085 \param $description a small description of the registration group area. 00086 \return a new eZISBNGroup object containing group number and a description. 00087 */ 00088 static function create( $groupNumber, $description = "" ) 00089 { 00090 $row = array( 'id' => null, 00091 'description' => $description, 00092 'group_number' => $groupNumber ); 00093 return new eZISBNGroup( $row ); 00094 } 00095 00096 00097 /*! 00098 \static 00099 Removes the ISBN group based on ID \a $id. 00100 \param $id is the id the object will be removed based on. 00101 */ 00102 static function removeByID( $id ) 00103 { 00104 eZPersistentObject::removeObject( eZISBNGroup::definition(), 00105 array( 'id' => $id ) ); 00106 } 00107 00108 /*! 00109 \static 00110 \param $count The count of the result. 00111 \param $asObject Whether if the result should be sent back as objects or an array. 00112 \return the group range list for ISBN groups. 00113 */ 00114 static function fetchList( $asObject = true ) 00115 { 00116 $sortArray = array( 'id' => 'asc' ); 00117 return eZPersistentObject::fetchObjectList( eZISBNGroup::definition(), 00118 null, null, $sortArray, null, 00119 $asObject ); 00120 } 00121 00122 /*! 00123 \static 00124 \param $groupNumber is the unique number of the Registration group area. 00125 \param $asObject Whether if the result should be sent back as objects or an array. 00126 \return the group range list for ISBN groups. 00127 */ 00128 static function fetchByGroup( $groupNumber, $asObject = true ) 00129 { 00130 $conditions = array( 'group_number' => $groupNumber ); 00131 $group = false; 00132 $groupArray = eZPersistentObject::fetchObjectList( eZISBNGroup::definition(), 00133 null, $conditions, null, null, 00134 $asObject ); 00135 if ( count( $groupArray ) == 1 ) 00136 { 00137 $group = $groupArray[0]; 00138 } 00139 return $group; 00140 } 00141 00142 /*! 00143 \static 00144 Removes all ISBN groups from the database. 00145 */ 00146 static function cleanAll() 00147 { 00148 $db = eZDB::instance(); 00149 $definition = eZISBNGroup::definition(); 00150 $table = $definition['name']; 00151 $sql = "TRUNCATE TABLE " . $table; 00152 $db->query( $sql ); 00153 } 00154 } 00155 00156 ?>