1
<?xml version="1.0" encoding="utf-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
<xsl:output method="text"/>
7
<xsl:template match="class"><?php
9
* $RCSfile: ClassCode.xsl,v $
11
* Gallery - a web based photo album viewer and editor
12
* Copyright (C) 2000-2005 Bharat Mediratta
14
* This program is free software; you can redistribute it and/or modify
15
* it under the terms of the GNU General Public License as published by
16
* the Free Software Foundation; either version 2 of the License, or (at
17
* your option) any later version.
19
* This program is distributed in the hope that it will be useful, but
20
* WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22
* General Public License for more details.
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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
29
* @package @@package@@
30
* @subpackage ClassInterfaces
31
* @version $Revision: 1.30 $ $Date: 2005/08/23 03:49:04 $
32
* @author Bharat Mediratta <bharat@menalto.com>
36
* Interface class for the <xsl:value-of select="class-name"/> class.
37
* (Class schema version: <xsl:value-of select="schema/schema-major"/>.<xsl:value-of select="schema/schema-minor"/>)
39
* This file is automatically generated from XML embedded in the
40
* class, combined with the ClassCode.xsl file. You should not modify
41
* it by hand, as your changes will be lost next time this file is
42
* rebuilt. If you want to add more getters/setters, you should add
43
* them in the core class. If you want to change the format of this
44
* file, then you should edit the XSL template.
46
* @package @@package@@
49
class <xsl:value-of select="class-name"/> extends <xsl:value-of select="class-name"/>_core {
50
<xsl:if test="/class/member">
52
* Return meta information about the members of this class
54
* @return array member => array(type, class)
56
function getPersistentMemberInfo() {
57
$meta = parent::getPersistentMemberInfo();<xsl:for-each select="member">
58
$meta['members']['<xsl:value-of select="member-name"/>'] = array('class' => '<xsl:value-of select="/class/class-name"/>', 'type' => STORAGE_TYPE_<xsl:value-of select="member-type"/><xsl:if test="id"> | STORAGE_TYPE_ID</xsl:if>);
64
* Get the data from this persistent object as an associative array
66
* @return array memberName => memberValue
68
function getMemberData() {
69
$data = parent::getMemberData();<xsl:for-each select="member">
70
<xsl:if test="linked">if (isset($this->_linkedEntity)) {
71
$data['<xsl:value-of select="member-name"/>'] = isset($this->_linkedEntity->_<xsl:value-of select="member-name"/>) ? $this->_linkedEntity->_<xsl:value-of select="member-name"/> : null;
73
$data['<xsl:value-of select="member-name"/>'] = isset($this->_<xsl:value-of select="member-name"/>) ? $this->_<xsl:value-of select="member-name"/> : null;
75
</xsl:if><xsl:if test="not(linked)">
76
$data['<xsl:value-of select="member-name"/>'] = isset($this->_<xsl:value-of select="member-name"/>) ? $this->_<xsl:value-of select="member-name"/> : null;</xsl:if>
82
* Return the name of this class with the proper mix of uppercase and
83
* lowercase (get_class() always returns lowercase)
85
* @return string class name
87
function getClassName() {
88
return '<xsl:value-of select="class-name"/>';
92
* Return the path to the PHP file for this class, relative to the gallery2 dir
96
function getClassFile() {
98
basename(dirname(dirname(dirname(__FILE__)))) .
99
'/classes/<xsl:value-of select="class-name"/>.class';
101
<xsl:apply-templates select="map" />
102
<xsl:apply-templates select="member" />
107
<xsl:template match="map">
109
* Get meta information about this class' map
111
* @return array map member => type
113
function getMapInfo() {
114
$info = array();<xsl:for-each select="member">
115
$info['members']['<xsl:value-of select="member-name"/>'] = STORAGE_TYPE_<xsl:value-of select="member-type"/>;</xsl:for-each>
120
* Add an entry to this map
122
* @param array an associative array of the entry data
123
* @return object GalleryStatus a status code
126
function addMapEntry($data) {
128
foreach (array(<xsl:for-each select="member/member-name">'<xsl:value-of select="."/>', </xsl:for-each>) as $key) {
129
if (!array_key_exists($key, $data)) {
130
return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__,
131
'Missing parameter: ' . $key);
135
$storage =& $gallery->getStorage();
136
$ret = $storage->addMapEntry('<xsl:value-of select="/class/class-name"/>', $data);
137
if ($ret->isError()) {
138
return $ret->wrap(__FILE__, __LINE__);
140
return GalleryStatus::success();
144
* Remove an entry from this map
146
* @param array an associative array of the entry data to match and remove
147
* @return object GalleryStatus a status code
150
function removeMapEntry($data) {
153
if (sizeof($data) == 0) {
154
return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__);
157
$storage =& $gallery->getStorage();
158
$ret = $storage->removeMapEntry('<xsl:value-of select="/class/class-name"/>', $data);
159
if ($ret->isError()) {
160
return $ret->wrap(__FILE__, __LINE__);
162
return GalleryStatus::success();
166
* Remove ALL entries from this map.. use with caution!
168
* @return object GalleryStatus a status code
171
function removeAllMapEntries() {
174
$storage =& $gallery->getStorage();
175
$ret = $storage->removeAllMapEntries('<xsl:value-of select="/class/class-name"/>');
176
if ($ret->isError()) {
177
return $ret->wrap(__FILE__, __LINE__);
179
return GalleryStatus::success();
183
* Update an entry in this map
185
* @param array the entry to match
186
* @param array the values to change
187
* @return object GalleryStatus a status code
190
function updateMapEntry($match, $change) {
193
if (sizeof($match) == 0 || sizeof($change) == 0) {
194
return GalleryStatus::error(ERROR_BAD_PARAMETER, __FILE__, __LINE__);
197
$storage =& $gallery->getStorage();
198
$ret = $storage->updateMapEntry('<xsl:value-of select="/class/class-name"/>', $match, $change);
199
if ($ret->isError()) {
200
return $ret->wrap(__FILE__, __LINE__);
202
return GalleryStatus::success();
206
<xsl:template match="member">
208
* Get the value of <xsl:value-of select="member-name"/>
210
* @return <xsl:value-of select="member-type"/> the value
212
function get<xsl:value-of select="member-name"/>() {<xsl:if test="linked">
213
$linkedEntity = $this->getLinkedEntity();
214
if (isset($linkedEntity)) {
215
return $linkedEntity->get<xsl:value-of select="member-name"/>();
218
if (!isset($this->_<xsl:value-of select="member-name"/>)) {
221
return $this->_<xsl:value-of select="member-name"/>;
225
* Set the value of <xsl:value-of select="member-name"/>
227
* @param <xsl:value-of select="member-type"/> the value
229
function set<xsl:value-of select="member-name"/>($value) {<xsl:choose>
230
<xsl:when test="member-type='BOOLEAN'">
231
/* Set the incoming value to be a 1 or 0 */
232
$value = empty($value) ? 0 : 1;
234
<xsl:when test="member-type='INTEGER'">
235
/* Type cast the incoming value to be an integer */
236
if ($value != null) {
237
$value = (int)$value;
241
/* Convert unset values to null, to avoid generating warnings. */
242
$value = isset($value) ? $value : null;
243
<xsl:if test="member-type='STRING'"> $value = $this->_truncateString($value, <xsl:choose>
244
<xsl:when test="member-size='SMALL'">32</xsl:when>
245
<xsl:when test="member-size='MEDIUM' or not(member-size)">128</xsl:when>
246
<xsl:when test="member-size='LARGE'">255</xsl:when>
247
</xsl:choose>);</xsl:if>
248
$orig = isset($this->_<xsl:value-of select="member-name"/>) ? $this->_<xsl:value-of select="member-name"/> : null;
250
/* Only take action if the value actually changes */
252
<xsl:when test="member-type='INTEGER'">if ($value !== $orig) {</xsl:when>
253
<xsl:when test="member-type='BOOLEAN'">if ($value !== $orig) {</xsl:when>
254
<xsl:otherwise>if ($value != $orig) {</xsl:otherwise>
256
$this->setModifiedFlag('<xsl:value-of select="member-name"/>', $value);
257
$this->_<xsl:value-of select="member-name"/> = $value;