ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

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

References $ar.

Member Function Documentation

◆ checkAttributes()

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

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

291 {
292 if (isset($attributes[self::HAS_FIELD]) && $attributes[self::HAS_FIELD] === 'true') {
293 foreach (array_keys($attributes) as $atr) {
294 if (!self::isAllowedAttribute($atr)) {
295 return false;
296 }
297 }
298 } else {
299 return false;
300 }
301
302 return true;
303 }
$attributes

References $attributes.

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static
Returns
array

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

108 {
110 }
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 116 of file class.arFieldList.php.

117 {
119 }
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 157 of file class.arFieldList.php.

158 {
159 $return = array();
160 foreach ($this->getFields() as $field) {
161 $return[$field->getName()] = $field->getAttributesForConnector();
162 }
163
164 return $return;
165 }

References getFields().

+ Here is the call graph for this function:

◆ getFieldByName()

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

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

190 {
191 $field = null;
192 static $field_map;
193 $field_key = $this->ar->getConnectorContainerName() . '.' . $field_name;
194 if ($field_map[$field_key]) {
195 return $field_map[$field_key];
196 }
197 foreach ($this->getFields() as $field) {
198 if ($field->getName() == $field_name) {
199 $field_map[$field_key] = $field;
200
201 return $field;
202 }
203 }
204 }

References getFields().

+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

319 {
320 return $this->fields;
321 }

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 128 of file class.arFieldList.php.

129 {
130 $arFieldList = new self($ar);
131 $arFieldList->initRawFields($ar);
132 $arFieldList->initFields();
133
134 return $arFieldList;
135 }

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 144 of file class.arFieldList.php.

145 {
146 $arFieldList = new self();
147 $arFieldList->initRawFields($ar);
148 $arFieldList->initFields();
149
150 return $arFieldList;
151 }

References $ar.

Referenced by arFieldCache\storeFromStorage().

+ Here is the caller graph for this function:

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns
\arField

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

337 {
339 }

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

+ Here is the caller graph for this function:

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )
Returns
string

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

229 {
230 return $this->getPrimaryField()->getName();
231 }

References getPrimaryField().

+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
array

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

373 {
375 }

References $primary_fields.

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )
Returns
mixed

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

238 {
239 return $this->getPrimaryField()->getFieldType();
240 }

References getPrimaryField().

+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
array

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

355 {
356 return $this->raw_fields;
357 }

References $raw_fields.

Referenced by initFields().

+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

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

169 {
170 foreach ($this->getRawFields() as $fieldname => $attributes) {
171 if (self::checkAttributes($attributes)) {
172 $arField = new arField();
173 $arField->getHasField(true);
174 $arField->loadFromArray($fieldname, $attributes);
175 $this->fields[] = $arField;
176 if ($arField->getPrimary()) {
177 $this->setPrimaryField($arField);
178 }
179 }
180 }
181 }
setPrimaryField($primary_field)
Class arField.
$errors fields
Definition: imgupload.php:51

References $attributes, 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 248 of file class.arFieldList.php.

249 {
250 $regex = "/[ ]*\\* @(" . implode('|', self::$prefixes) . ")_([a-zA-Z0-9_]*)[ ]*([a-zA-Z0-9_]*)/u";
251 $reflectionClass = new ReflectionClass($ar);
252 $raw_fields = array();
253 foreach ($reflectionClass->getProperties() as $property) {
254 if (in_array($property->getName(), self::$protected_names)) {
255 continue;
256 }
257 $properties_array = array();
258 $has_property = false;
259 foreach (explode("\n", $property->getDocComment()) as $line) {
260 if (preg_match($regex, $line, $matches)) {
261 $has_property = true;
262 $properties_array[(string) $matches[2]] = $matches[3];
263 }
264 }
265 if ($has_property) {
266 $raw_fields[$property->getName()] = $properties_array;
267 }
268 }
269
271 }
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 279 of file class.arFieldList.php.

280 {
281 return in_array($attribute_name, array_merge(self::$allowed_description_fields, array( self::HAS_FIELD )));
282 }

◆ isField()

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

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

213 {
214 $is_field = false;
215 foreach ($this->getFields() as $field) {
216 if ($field->getName() == $field_name) {
217 $is_field = true;
218 }
219 }
220
221 return $is_field;
222 }

References getFields().

+ Here is the call graph for this function:

◆ mapKey()

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

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

95 {
96 if (isset(self::$key_maps[$key])) {
97 return self::$key_maps[$key];
98 }
99
100 return $key;
101 }
$key
Definition: croninfo.php:18

References $key.

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 309 of file class.arFieldList.php.

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

References $fields, and fields.

◆ setPrimaryField()

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

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

328 {
329 $this->primary_field = $primary_field;
330 }

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 363 of file class.arFieldList.php.

364 {
365 $this->primary_fields = $primary_fields;
366 }

References $primary_fields.

◆ setRawFields()

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

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

346 {
347 $this->raw_fields = $raw_fields;
348 }

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: