3
* $RCSfile: CustomFieldMap.inc,v $
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2005 Bharat Mediratta
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or (at
11
* your option) any later version.
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23
* @package CustomField
24
* @subpackage ClassInterfaces
25
* @version $Revision: 1.9 $ $Date: 2005/08/23 03:49:37 $
26
* @author Bharat Mediratta <bharat@menalto.com>
30
* Interface class for the CustomFieldMap class.
31
* (Class schema version: 1.0)
33
* This file is automatically generated from XML embedded in the
34
* class, combined with the ClassCode.xsl file. You should not modify
35
* it by hand, as your changes will be lost next time this file is
36
* rebuilt. If you want to add more getters/setters, you should add
37
* them in the core class. If you want to change the format of this
38
* file, then you should edit the XSL template.
40
* @package CustomField
43
class CustomFieldMap extends CustomFieldMap_core {
46
* Return the name of this class with the proper mix of uppercase and
47
* lowercase (get_class() always returns lowercase)
49
* @return string class name
51
function getClassName() {
52
return 'CustomFieldMap';
56
* Return the path to the PHP file for this class, relative to the gallery2 dir
60
function getClassFile() {
62
basename(dirname(dirname(dirname(__FILE__)))) .
63
'/classes/CustomFieldMap.class';
67
* Get meta information about this class' map
69
* @return array map member => type
71
function getMapInfo() {
73
$info['members']['itemId'] = STORAGE_TYPE_INTEGER;
74
$info['members']['field'] = STORAGE_TYPE_STRING;
75
$info['members']['value'] = STORAGE_TYPE_STRING;
76
$info['members']['setId'] = STORAGE_TYPE_INTEGER;
77
$info['members']['setType'] = STORAGE_TYPE_INTEGER;
82
* Add an entry to this map
84
* @param array an associative array of the entry data
85
* @return object GalleryStatus a status code
88
function addMapEntry($data) {
90
foreach (array('itemId', 'field', 'value', 'setId', 'setType', ) as $key) {
91
if (!array_key_exists($key, $data)) {
92
return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__,
93
'Missing parameter: ' . $key);
97
$storage =& $gallery->getStorage();
98
$ret = $storage->addMapEntry('CustomFieldMap', $data);
99
if ($ret->isError()) {
100
return $ret->wrap(__FILE__, __LINE__);
102
return GalleryStatus::success();
106
* Remove an entry from this map
108
* @param array an associative array of the entry data to match and remove
109
* @return object GalleryStatus a status code
112
function removeMapEntry($data) {
115
if (sizeof($data) == 0) {
116
return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__);
119
$storage =& $gallery->getStorage();
120
$ret = $storage->removeMapEntry('CustomFieldMap', $data);
121
if ($ret->isError()) {
122
return $ret->wrap(__FILE__, __LINE__);
124
return GalleryStatus::success();
128
* Remove ALL entries from this map.. use with caution!
130
* @return object GalleryStatus a status code
133
function removeAllMapEntries() {
136
$storage =& $gallery->getStorage();
137
$ret = $storage->removeAllMapEntries('CustomFieldMap');
138
if ($ret->isError()) {
139
return $ret->wrap(__FILE__, __LINE__);
141
return GalleryStatus::success();
145
* Update an entry in this map
147
* @param array the entry to match
148
* @param array the values to change
149
* @return object GalleryStatus a status code
152
function updateMapEntry($match, $change) {
155
if (sizeof($match) == 0 || sizeof($change) == 0) {
156
return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__);
159
$storage =& $gallery->getStorage();
160
$ret = $storage->updateMapEntry('CustomFieldMap', $match, $change);
161
if ($ret->isError()) {
162
return $ret->wrap(__FILE__, __LINE__);
164
return GalleryStatus::success();