Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezemailtype.php
Go to the documentation of this file.
1 <?php
18 class eZEmailType extends eZDataType
19 {
20 const DATA_TYPE_STRING = "ezemail";
21
22 public function __construct()
23 {
24 parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', "Email", 'Datatype name' ),
25 array( 'serialize_supported' => true,
26 'object_serialize_map' => array( 'data_text' => 'email' ) ) );
27 }
28
32 function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
33 {
34 if ( $currentVersion != false )
35 {
36 $dataText = $originalContentObjectAttribute->attribute( "data_text" );
37 $contentObjectAttribute->setAttribute( "data_text", $dataText );
38 }
39 }
40
41 /*
42 Private method, only for using inside this class.
43 */
44 function validateEMailHTTPInput( $email, $contentObjectAttribute )
45 {
46 if ( !eZMail::validate( $email ) )
47 {
48 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
49 'The email address is not valid.' ) );
50 return eZInputValidator::STATE_INVALID;
51 }
52 return eZInputValidator::STATE_ACCEPTED;
53 }
54
59 function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
60 {
61 $classAttribute = $contentObjectAttribute->contentClassAttribute();
62 if ( $http->hasPostVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) )
63 {
64 $email = $http->postVariable( $base . '_data_text_' . $contentObjectAttribute->attribute( 'id' ) );
65
66 $trimmedEmail = trim( $email );
67
68 if ( $trimmedEmail == "" )
69 {
70 // we require user to enter an address only if the attribute is not an informationcollector
71 if ( !$classAttribute->attribute( 'is_information_collector' ) and
72 $contentObjectAttribute->validateIsRequired() )
73 {
74 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
75 'The email address is empty.' ) );
76 return eZInputValidator::STATE_INVALID;
77 }
78 }
79 else
80 {
81 // if the entered address is not empty then we should validate it in any case
82 return $this->validateEMailHTTPInput( $trimmedEmail, $contentObjectAttribute );
83 }
84 }
85 else if ( !$classAttribute->attribute( 'is_information_collector' ) and $contentObjectAttribute->validateIsRequired() )
86 {
87 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes', 'Missing email input.' ) );
88 return eZInputValidator::STATE_INVALID;
89 }
90
91 return eZInputValidator::STATE_ACCEPTED;
92 }
93
97 function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
98 {
99 if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) )
100 {
101 $data = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) );
102 $contentObjectAttribute->setAttribute( "data_text", $data );
103 return true;
104 }
105 return false;
106 }
107
108 function validateCollectionAttributeHTTPInput( $http, $base, $contentObjectAttribute )
109 {
110 if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) )
111 {
112 $email = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) );
113 $classAttribute = $contentObjectAttribute->contentClassAttribute();
114
115 $trimmedEmail = trim( $email );
116
117 if ( $trimmedEmail == "" )
118 {
119 // if entered email is empty and required then return state invalid
120 if ( $contentObjectAttribute->validateIsRequired() )
121 {
122 $contentObjectAttribute->setValidationError( ezpI18n::tr( 'kernel/classes/datatypes',
123 'The email address is empty.' ) );
124 return eZInputValidator::STATE_INVALID;
125 }
126 else
127 return eZInputValidator::STATE_ACCEPTED;
128 }
129 else
130 {
131 // if entered email is not empty then we should validate it in any case
132 return $this->validateEMailHTTPInput( $trimmedEmail, $contentObjectAttribute );
133 }
134 }
135 else
136 return eZInputValidator::STATE_INVALID;
137 }
138
142 function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute )
143 {
144 if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) )
145 {
146 $dataText = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) );
147 $collectionAttribute->setAttribute( 'data_text', $dataText );
148 return true;
149 }
150 return false;
151 }
152
156 function storeObjectAttribute( $attribute )
157 {
158 }
159
163 function objectAttributeContent( $contentObjectAttribute )
164 {
165 return $contentObjectAttribute->attribute( "data_text" );
166 }
167
168 function isIndexable()
169 {
170 return true;
171 }
172
176 function metaData( $contentObjectAttribute )
177 {
178 return $contentObjectAttribute->attribute( "data_text" );
179 }
180
185 function toString( $contentObjectAttribute )
186 {
187 return $contentObjectAttribute->attribute( 'data_text' );
188 }
189
190 function fromString( $contentObjectAttribute, $string )
191 {
192 return $contentObjectAttribute->setAttribute( 'data_text', $string );
193 }
194
198 function title( $contentObjectAttribute, $name = null )
199 {
200 return $contentObjectAttribute->attribute( "data_text" );
201 }
202
203 function hasObjectAttributeContent( $contentObjectAttribute )
204 {
205 return trim( $contentObjectAttribute->attribute( "data_text" ) ) != '';
206 }
207
208 function isInformationCollector()
209 {
210 return true;
211 }
212
213 function sortKey( $contentObjectAttribute )
214 {
215 return strtolower( $contentObjectAttribute->attribute( 'data_text' ) );
216 }
217
218 function sortKeyType()
219 {
220 return 'string';
221 }
222
223 function supportsBatchInitializeObjectAttribute()
224 {
225 return true;
226 }
227 }
228
229 eZDataType::register( eZEmailType::DATA_TYPE_STRING, "eZEmailType" );
230
231 ?>
eZDataType
Base class for content datatypes.
Definition: ezdatatype.php:46
eZDataType\register
static register( $dataTypeString, $className)
Definition: ezdatatype.php:203
eZEmailType
Stores an email address.
Definition: ezemailtype.php:19
eZEmailType\storeObjectAttribute
storeObjectAttribute( $attribute)
Definition: ezemailtype.php:156
eZEmailType\title
title( $contentObjectAttribute, $name=null)
Definition: ezemailtype.php:198
eZEmailType\fetchCollectionAttributeHTTPInput
fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute)
Definition: ezemailtype.php:142
eZEmailType\supportsBatchInitializeObjectAttribute
supportsBatchInitializeObjectAttribute()
Definition: ezemailtype.php:223
eZEmailType\validateObjectAttributeHTTPInput
validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezemailtype.php:59
eZEmailType\isInformationCollector
isInformationCollector()
Definition: ezemailtype.php:208
eZEmailType\validateCollectionAttributeHTTPInput
validateCollectionAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezemailtype.php:108
eZEmailType\sortKeyType
sortKeyType()
Definition: ezemailtype.php:218
eZEmailType\__construct
__construct()
Definition: ezemailtype.php:22
eZEmailType\fromString
fromString( $contentObjectAttribute, $string)
Definition: ezemailtype.php:190
eZEmailType\toString
toString( $contentObjectAttribute)
Definition: ezemailtype.php:185
eZEmailType\validateEMailHTTPInput
validateEMailHTTPInput( $email, $contentObjectAttribute)
Definition: ezemailtype.php:44
eZEmailType\hasObjectAttributeContent
hasObjectAttributeContent( $contentObjectAttribute)
Definition: ezemailtype.php:203
eZEmailType\objectAttributeContent
objectAttributeContent( $contentObjectAttribute)
Definition: ezemailtype.php:163
eZEmailType\fetchObjectAttributeHTTPInput
fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezemailtype.php:97
eZEmailType\metaData
metaData( $contentObjectAttribute)
Definition: ezemailtype.php:176
eZEmailType\sortKey
sortKey( $contentObjectAttribute)
Definition: ezemailtype.php:213
eZEmailType\isIndexable
isIndexable()
Definition: ezemailtype.php:168
eZEmailType\DATA_TYPE_STRING
const DATA_TYPE_STRING
Definition: ezemailtype.php:20
eZEmailType\initializeObjectAttribute
initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute)
Definition: ezemailtype.php:32
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZInputValidator\STATE_INVALID
const STATE_INVALID
Definition: ezinputvalidator.php:81
eZMail\validate
static validate( $address)
Definition: ezmail.php:747
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.