ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
arFieldList Class Reference

Class arFieldList. More...

+ Collaboration diagram for arFieldList:

Public Member Functions

 __construct (ActiveRecord $ar)
 arFieldList constructor. More...
 
 getArrayForConnector ()
 
 getFieldByName ($field_name)
 
 isField ($field_name)
 
 getPrimaryFieldName ()
 
 getPrimaryFieldType ()
 
 setFields ($fields)
 
 getFields ()
 
 setPrimaryField ($primary_field)
 
 getPrimaryField ()
 
 setRawFields ($raw_fields)
 
 getRawFields ()
 
 setPrimaryFields ($primary_fields)
 
 getPrimaryFields ()
 

Static Public Member Functions

static mapKey ($key)
 
static getAllowedConnectorFields ()
 
static getAllowedDescriptionFields ()
 
static getInstance (ActiveRecord $ar)
 
static getInstanceFromStorage ($ar)
 

Data Fields

const HAS_FIELD = 'has_field'
 
const IS_UNIQUE = 'is_unique'
 
const IS_PRIMARY = 'is_primary'
 
const IS_NOTNULL = 'is_notnull'
 
const FIELDTYPE = 'fieldtype'
 
const LENGTH = 'length'
 
const SEQUENCE = 'sequence'
 
const INDEX = 'index'
 

Protected Member Functions

 initFields ()
 
 initRawFields (arStorageInterface $ar)
 

Static Protected Member Functions

static isAllowedAttribute ($attribute_name)
 
static checkAttributes (array $attributes)
 

Protected Attributes

 $primary_field
 
 $primary_fields = array()
 
 $raw_fields = array()
 
 $fields = array()
 
 $ar
 

Static Protected Attributes

static $prefixes = array( 'db', 'con' )
 
static $protected_names = array( 'arConnector', 'arFieldList' )
 
static $allowed_description_fields
 
static $allowed_connector_fields
 
static $key_maps
 

Detailed Description

Class arFieldList.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
2.0.7

Definition at line 11 of file class.arFieldList.php.

Constructor & Destructor Documentation

◆ __construct()

arFieldList::__construct ( ActiveRecord  $ar)

arFieldList constructor.

Parameters
ActiveRecord$ar

Definition at line 83 of file class.arFieldList.php.

83 {
84 $this->ar = $ar;
85 }

References $ar.

Member Function Documentation

◆ checkAttributes()

static arFieldList::checkAttributes ( array  $attributes)
staticprotected
Parameters
array$attributes
Returns
bool

Definition at line 276 of file class.arFieldList.php.

276 {
277 if ($attributes[self::HAS_FIELD] === 'true') {
278 foreach (array_keys($attributes) as $atr) {
279 if (!self::isAllowedAttribute($atr)) {
280 return false;
281 }
282 }
283 } else {
284 return false;
285 }
286
287 return true;
288 }

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static
Returns
array

Definition at line 105 of file class.arFieldList.php.

105 {
107 }
static $allowed_connector_fields

References $allowed_connector_fields.

Referenced by arField\getAttributesForConnector().

+ Here is the caller graph for this function:

◆ getAllowedDescriptionFields()

static arFieldList::getAllowedDescriptionFields ( )
static
Returns
array

Definition at line 113 of file class.arFieldList.php.

113 {
115 }
static $allowed_description_fields

References $allowed_description_fields.

Referenced by arField\getAttributesForDescription().

+ Here is the caller graph for this function:

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )
Returns
array

Definition at line 151 of file class.arFieldList.php.

151 {
152 $return = array();
153 foreach ($this->getFields() as $field) {
154 $return[$field->getName()] = $field->getAttributesForConnector();
155 }
156
157 return $return;
158 }

References getFields().

+ Here is the call graph for this function:

◆ getFieldByName()

arFieldList::getFieldByName (   $field_name)
Parameters
$field_name
Returns
arField

Definition at line 181 of file class.arFieldList.php.

181 {
182 $field = NULL;
183 static $field_map;
184 $field_key = $this->ar->getConnectorContainerName() . '.' . $field_name;
185 if ($field_map[$field_key]) {
186 return $field_map[$field_key];
187 }
188 foreach ($this->getFields() as $field) {
189 if ($field->getName() == $field_name) {
190 $field_map[$field_key] = $field;
191
192 return $field;
193 }
194 }
195 }

References getFields().

+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

Definition at line 302 of file class.arFieldList.php.

302 {
303 return $this->fields;
304 }

References $fields.

Referenced by getArrayForConnector(), getFieldByName(), and isField().

+ Here is the caller graph for this function:

◆ getInstance()

static arFieldList::getInstance ( ActiveRecord  $ar)
static
Parameters
ActiveRecord$ar
Returns
\arFieldList

Definition at line 124 of file class.arFieldList.php.

124 {
125 $arFieldList = new self($ar);
126 $arFieldList->initRawFields($ar);
127 $arFieldList->initFields();
128
129 return $arFieldList;
130 }

References $ar.

Referenced by arFieldCache\store().

+ Here is the caller graph for this function:

◆ getInstanceFromStorage()

static arFieldList::getInstanceFromStorage (   $ar)
static
Parameters
ActiveRecord$ar
Deprecated:
Returns
\arFieldList

Definition at line 139 of file class.arFieldList.php.

139 {
140 $arFieldList = new self();
141 $arFieldList->initRawFields($ar);
142 $arFieldList->initFields();
143
144 return $arFieldList;
145 }

References $ar.

Referenced by arFieldCache\storeFromStorage().

+ Here is the caller graph for this function:

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns
\arField

Definition at line 318 of file class.arFieldList.php.

318 {
320 }

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

+ Here is the caller graph for this function:

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )
Returns
string

Definition at line 218 of file class.arFieldList.php.

218 {
219 return $this->getPrimaryField()->getName();
220 }

References getPrimaryField().

+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
array

Definition at line 350 of file class.arFieldList.php.

350 {
352 }

References $primary_fields.

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )
Returns
mixed

Definition at line 226 of file class.arFieldList.php.

226 {
227 return $this->getPrimaryField()->getFieldType();
228 }

References getPrimaryField().

+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
array

Definition at line 334 of file class.arFieldList.php.

334 {
335 return $this->raw_fields;
336 }

References $raw_fields.

Referenced by initFields().

+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

Definition at line 161 of file class.arFieldList.php.

161 {
162 foreach ($this->getRawFields() as $fieldname => $attributes) {
163 if (self::checkAttributes($attributes)) {
164 $arField = new arField();
165 $arField->getHasField(true);
166 $arField->loadFromArray($fieldname, $attributes);
167 $this->fields[] = $arField;
168 if ($arField->getPrimary()) {
169 $this->setPrimaryField($arField);
170 }
171 }
172 }
173 }
setPrimaryField($primary_field)
Class arField.
$errors fields
Definition: imgupload.php:48

References fields, getRawFields(), and setPrimaryField().

+ Here is the call graph for this function:

◆ initRawFields()

arFieldList::initRawFields ( arStorageInterface  $ar)
protected
Parameters
\ActiveRecord | \arStorageInterface$ar
Returns
array

Definition at line 236 of file class.arFieldList.php.

236 {
237 $regex = "/[ ]*\\* @(" . implode('|', self::$prefixes) . ")_([a-zA-Z0-9_]*)[ ]*([a-zA-Z0-9_]*)/u";
238 $reflectionClass = new ReflectionClass($ar);
239 $raw_fields = array();
240 foreach ($reflectionClass->getProperties() as $property) {
241 if (in_array($property->getName(), self::$protected_names)) {
242 continue;
243 }
244 $properties_array = array();
245 $has_property = false;
246 foreach (explode("\n", $property->getDocComment()) as $line) {
247 if (preg_match($regex, $line, $matches)) {
248 $has_property = true;
249 $properties_array[(string)$matches[2]] = $matches[3];
250 }
251 }
252 if ($has_property) {
253 $raw_fields[$property->getName()] = $properties_array;
254 }
255 }
256
258 }
setRawFields($raw_fields)

References $ar, $raw_fields, and setRawFields().

+ Here is the call graph for this function:

◆ isAllowedAttribute()

static arFieldList::isAllowedAttribute (   $attribute_name)
staticprotected
Parameters
$attribute_name
Returns
bool

Definition at line 266 of file class.arFieldList.php.

266 {
267 return in_array($attribute_name, array_merge(self::$allowed_description_fields, array( self::HAS_FIELD )));
268 }

◆ isField()

arFieldList::isField (   $field_name)
Parameters
$field_name
Returns
bool

Definition at line 203 of file class.arFieldList.php.

203 {
204 $is_field = false;
205 foreach ($this->getFields() as $field) {
206 if ($field->getName() == $field_name) {
207 $is_field = true;
208 }
209 }
210
211 return $is_field;
212 }

References getFields().

+ Here is the call graph for this function:

◆ mapKey()

static arFieldList::mapKey (   $key)
static
Parameters
$key
Returns
mixed

Definition at line 93 of file class.arFieldList.php.

93 {
94 if (isset(self::$key_maps[$key])) {
95 return self::$key_maps[$key];
96 }
97
98 return $key;
99 }

Referenced by arBuilder\generateDBUpdateForInstallation(), arField\getAttributesForConnector(), and arField\getAttributesForDescription().

+ Here is the caller graph for this function:

◆ setFields()

arFieldList::setFields (   $fields)
Parameters
array$fields

Definition at line 294 of file class.arFieldList.php.

294 {
295 $this->fields = $fields;
296 }

References $fields, and fields.

◆ setPrimaryField()

arFieldList::setPrimaryField (   $primary_field)
Parameters
\arField$primary_field

Definition at line 310 of file class.arFieldList.php.

310 {
311 $this->primary_field = $primary_field;
312 }

References $primary_field.

Referenced by initFields().

+ Here is the caller graph for this function:

◆ setPrimaryFields()

arFieldList::setPrimaryFields (   $primary_fields)
Parameters
array$primary_fields

Definition at line 342 of file class.arFieldList.php.

342 {
343 $this->primary_fields = $primary_fields;
344 }

References $primary_fields.

◆ setRawFields()

arFieldList::setRawFields (   $raw_fields)
Parameters
array$raw_fields

Definition at line 326 of file class.arFieldList.php.

326 {
327 $this->raw_fields = $raw_fields;
328 }

References $raw_fields.

Referenced by initRawFields().

+ Here is the caller graph for this function:

Field Documentation

◆ $allowed_connector_fields

arFieldList::$allowed_connector_fields
staticprotected
Initial value:
= array(
self::IS_NOTNULL,
self::FIELDTYPE,
self::LENGTH,
)

Definition at line 44 of file class.arFieldList.php.

Referenced by getAllowedConnectorFields().

◆ $allowed_description_fields

arFieldList::$allowed_description_fields
staticprotected
Initial value:
= array(
self::IS_UNIQUE,
self::IS_PRIMARY,
self::IS_NOTNULL,
self::FIELDTYPE,
self::LENGTH,
self::SEQUENCE,
self::INDEX,
)

Definition at line 32 of file class.arFieldList.php.

Referenced by getAllowedDescriptionFields().

◆ $ar

arFieldList::$ar
protected

◆ $fields

arFieldList::$fields = array()
protected

Definition at line 64 of file class.arFieldList.php.

Referenced by getFields(), and setFields().

◆ $key_maps

arFieldList::$key_maps
staticprotected
Initial value:
= array(
self::FIELDTYPE => 'type',
self::IS_NOTNULL => 'notnull',
)

Definition at line 72 of file class.arFieldList.php.

◆ $prefixes

arFieldList::$prefixes = array( 'db', 'con' )
staticprotected

Definition at line 24 of file class.arFieldList.php.

◆ $primary_field

arFieldList::$primary_field
protected

Definition at line 52 of file class.arFieldList.php.

Referenced by getPrimaryField(), and setPrimaryField().

◆ $primary_fields

arFieldList::$primary_fields = array()
protected

Definition at line 56 of file class.arFieldList.php.

Referenced by getPrimaryFields(), and setPrimaryFields().

◆ $protected_names

arFieldList::$protected_names = array( 'arConnector', 'arFieldList' )
staticprotected

Definition at line 28 of file class.arFieldList.php.

◆ $raw_fields

arFieldList::$raw_fields = array()
protected

Definition at line 60 of file class.arFieldList.php.

Referenced by getRawFields(), initRawFields(), and setRawFields().

◆ FIELDTYPE

const arFieldList::FIELDTYPE = 'fieldtype'

Definition at line 17 of file class.arFieldList.php.

Referenced by arField\isAllowedAttribute().

◆ HAS_FIELD

const arFieldList::HAS_FIELD = 'has_field'

Definition at line 13 of file class.arFieldList.php.

Referenced by arField\isAllowedAttribute().

◆ INDEX

const arFieldList::INDEX = 'index'

Definition at line 20 of file class.arFieldList.php.

◆ IS_NOTNULL

const arFieldList::IS_NOTNULL = 'is_notnull'

Definition at line 16 of file class.arFieldList.php.

◆ IS_PRIMARY

const arFieldList::IS_PRIMARY = 'is_primary'

Definition at line 15 of file class.arFieldList.php.

◆ IS_UNIQUE

const arFieldList::IS_UNIQUE = 'is_unique'

Definition at line 14 of file class.arFieldList.php.

◆ LENGTH

const arFieldList::LENGTH = 'length'

Definition at line 18 of file class.arFieldList.php.

◆ SEQUENCE

const arFieldList::SEQUENCE = 'sequence'

Definition at line 19 of file class.arFieldList.php.


The documentation for this class was generated from the following file: