ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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_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 82 of file class.arFieldList.php.

References $ar.

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

Member Function Documentation

◆ checkAttributes()

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

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

290  {
291  if (isset($attributes[self::HAS_FIELD]) && $attributes[self::HAS_FIELD] === 'true') {
292  foreach (array_keys($attributes) as $atr) {
293  if (!self::isAllowedAttribute($atr)) {
294  return false;
295  }
296  }
297  } else {
298  return false;
299  }
300 
301  return true;
302  }
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static
Returns
array

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

Referenced by arField\getAttributesForConnector().

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

◆ getAllowedDescriptionFields()

static arFieldList::getAllowedDescriptionFields ( )
static
Returns
array

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

Referenced by arField\getAttributesForDescription().

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

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )
Returns
array

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

References getFields().

157  {
158  $return = array();
159  foreach ($this->getFields() as $field) {
160  $return[$field->getName()] = $field->getAttributesForConnector();
161  }
162 
163  return $return;
164  }
+ Here is the call graph for this function:

◆ getFieldByName()

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

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

References getFields().

189  {
190  $field = null;
191  static $field_map;
192  $field_key = $this->ar->getConnectorContainerName() . '.' . $field_name;
193  if (is_array($field_map) && array_key_exists($field_key, $field_map)) {
194  return $field_map[$field_key];
195  }
196  foreach ($this->getFields() as $field) {
197  if ($field->getName() == $field_name) {
198  $field_map[$field_key] = $field;
199 
200  return $field;
201  }
202  }
203  }
+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

References $fields.

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

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

◆ getInstance()

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

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

References $ar.

Referenced by arFieldCache\store().

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

◆ getInstanceFromStorage()

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

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

References $ar.

Referenced by arFieldCache\storeFromStorage().

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

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns

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

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

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

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )
Returns
string

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

References getPrimaryField().

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

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
array

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

References $primary_fields.

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

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )
Returns
mixed

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

References getPrimaryField().

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

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
array

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

References $raw_fields.

Referenced by initFields().

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

◆ initFields()

arFieldList::initFields ( )
protected

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

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

168  {
169  foreach ($this->getRawFields() as $fieldname => $attributes) {
170  if (self::checkAttributes($attributes)) {
171  $arField = new arField();
172  $arField->getHasField();
173  $arField->loadFromArray($fieldname, $attributes);
174  $this->fields[] = $arField;
175  if ($arField->getPrimary()) {
176  $this->setPrimaryField($arField);
177  }
178  }
179  }
180  }
Class arField.
setPrimaryField($primary_field)
$errors fields
Definition: imgupload.php:51
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
+ Here is the call graph for this function:

◆ initRawFields()

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

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

References $raw_fields, and setRawFields().

248  {
249  $regex = "/[ ]*\\* @(" . implode('|', self::$prefixes) . ")_([a-zA-Z0-9_]*)[ ]*([a-zA-Z0-9_]*)/u";
250  $reflectionClass = new ReflectionClass($ar);
251  $raw_fields = array();
252  foreach ($reflectionClass->getProperties() as $property) {
253  if (in_array($property->getName(), self::$protected_names)) {
254  continue;
255  }
256  $properties_array = array();
257  $has_property = false;
258  foreach (explode("\n", $property->getDocComment()) as $line) {
259  if (preg_match($regex, $line, $matches)) {
260  $has_property = true;
261  $properties_array[(string) $matches[2]] = $matches[3];
262  }
263  }
264  if ($has_property) {
265  $raw_fields[$property->getName()] = $properties_array;
266  }
267  }
268 
269  $this->setRawFields($raw_fields);
270  }
setRawFields($raw_fields)
+ Here is the call graph for this function:

◆ isAllowedAttribute()

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

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

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

◆ isField()

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

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

References getFields().

212  {
213  $is_field = false;
214  foreach ($this->getFields() as $field) {
215  if ($field->getName() == $field_name) {
216  $is_field = true;
217  }
218  }
219 
220  return $is_field;
221  }
+ 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.

References $key.

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

94  {
95  if (isset(self::$key_maps[$key])) {
96  return self::$key_maps[$key];
97  }
98 
99  return $key;
100  }
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ setFields()

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

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

References $fields, and fields.

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

◆ setPrimaryField()

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

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

References $primary_field.

Referenced by initFields().

327  {
328  $this->primary_field = $primary_field;
329  }
+ Here is the caller graph for this function:

◆ setPrimaryFields()

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

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

References $primary_fields.

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

◆ setRawFields()

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

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

References $raw_fields.

Referenced by initRawFields().

345  {
346  $this->raw_fields = $raw_fields;
347  }
+ 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 43 of file class.arFieldList.php.

◆ $allowed_description_fields

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

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

◆ $ar

arFieldList::$ar
protected

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

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

◆ $fields

arFieldList::$fields = array()
protected

Definition at line 63 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 71 of file class.arFieldList.php.

◆ $prefixes

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

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

◆ $primary_field

arFieldList::$primary_field
protected

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

Referenced by getPrimaryField(), and setPrimaryField().

◆ $primary_fields

arFieldList::$primary_fields = array()
protected

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

Referenced by getPrimaryFields(), and setPrimaryFields().

◆ $protected_names

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

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

◆ $raw_fields

arFieldList::$raw_fields = array()
protected

Definition at line 59 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 19 of file class.arFieldList.php.

◆ IS_NOTNULL

const arFieldList::IS_NOTNULL = 'is_notnull'

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

Referenced by arConverter\returnAttributesForField().

◆ IS_PRIMARY

const arFieldList::IS_PRIMARY = 'is_primary'

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

Referenced by arConverter\returnAttributesForField().

◆ LENGTH

const arFieldList::LENGTH = 'length'

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

Referenced by arConverter\returnAttributesForField().

◆ SEQUENCE

const arFieldList::SEQUENCE = 'sequence'

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


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