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.

References $ar.

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

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

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static
Returns
array

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

Referenced by arField\getAttributesForConnector().

108  {
109  return self::$allowed_connector_fields;
110  }
+ Here is the caller graph for this function:

◆ getAllowedDescriptionFields()

static arFieldList::getAllowedDescriptionFields ( )
static
Returns
array

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

Referenced by arField\getAttributesForDescription().

117  {
118  return self::$allowed_description_fields;
119  }
+ Here is the caller graph for this function:

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )
Returns
array

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

References array, and getFields().

158  {
159  $return = array();
160  foreach ($this->getFields() as $field) {
161  $return[$field->getName()] = $field->getAttributesForConnector();
162  }
163 
164  return $return;
165  }
Create styles array
The data for the language used.
+ 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.

References getFields().

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  }
+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

References $fields.

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

319  {
320  return $this->fields;
321  }
+ Here is the caller graph for this function:

◆ getInstance()

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

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

References $ar.

Referenced by arFieldCache\store().

129  {
130  $arFieldList = new self($ar);
131  $arFieldList->initRawFields($ar);
132  $arFieldList->initFields();
133 
134  return $arFieldList;
135  }
+ Here is the caller graph for this function:

◆ getInstanceFromStorage()

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

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

References $ar.

Referenced by arFieldCache\storeFromStorage().

145  {
146  $arFieldList = new self();
147  $arFieldList->initRawFields($ar);
148  $arFieldList->initFields();
149 
150  return $arFieldList;
151  }
+ Here is the caller graph for this function:

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns

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

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

337  {
338  return $this->primary_field;
339  }
+ Here is the caller graph for this function:

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )
Returns
string

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

References getPrimaryField().

229  {
230  return $this->getPrimaryField()->getName();
231  }
+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
array

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

References $primary_fields.

373  {
374  return $this->primary_fields;
375  }

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )
Returns
mixed

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

References getPrimaryField().

238  {
239  return $this->getPrimaryField()->getFieldType();
240  }
+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
array

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

References $raw_fields.

Referenced by initFields().

355  {
356  return $this->raw_fields;
357  }
+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

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

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

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  }
Class arField.
$attributes
setPrimaryField($primary_field)
$errors fields
Definition: imgupload.php:51
+ 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.

References $raw_fields, array, setRawFields(), and string.

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 
270  $this->setRawFields($raw_fields);
271  }
Add rich text string
setRawFields($raw_fields)
Create styles array
The data for the language used.
+ 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.

References array.

280  {
281  return in_array($attribute_name, array_merge(self::$allowed_description_fields, array( self::HAS_FIELD )));
282  }
Create styles array
The data for the language used.

◆ isField()

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

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

References getFields().

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  }
+ 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.

References $key.

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

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
+ Here is the caller graph for this function:

◆ setFields()

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

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

References $fields, and fields.

310  {
311  $this->fields = $fields;
312  }
$errors fields
Definition: imgupload.php:51

◆ setPrimaryField()

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

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

References $primary_field.

Referenced by initFields().

328  {
329  $this->primary_field = $primary_field;
330  }
+ 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.

References $primary_fields.

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

◆ setRawFields()

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

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

References $raw_fields.

Referenced by initRawFields().

346  {
347  $this->raw_fields = $raw_fields;
348  }
+ Here is the caller graph for this function:

Field Documentation

◆ $allowed_connector_fields

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

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

◆ $allowed_description_fields

arFieldList::$allowed_description_fields
staticprotected
Initial value:
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.

◆ $ar

arFieldList::$ar
protected

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

Referenced by __construct(), getInstance(), and getInstanceFromStorage().

◆ $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:
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'

◆ HAS_FIELD

const arFieldList::HAS_FIELD = 'has_field'

◆ 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.

Referenced by arConverter\returnAttributesForField().

◆ IS_PRIMARY

const arFieldList::IS_PRIMARY = 'is_primary'

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

Referenced by arConverter\returnAttributesForField().

◆ IS_UNIQUE

const arFieldList::IS_UNIQUE = 'is_unique'

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

Referenced by arConverter\returnAttributesForField().

◆ LENGTH

const arFieldList::LENGTH = 'length'

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

Referenced by arConverter\returnAttributesForField().

◆ 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: