ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

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

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.

Referenced by arField\getAttributesForConnector().

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

◆ getAllowedDescriptionFields()

static arFieldList::getAllowedDescriptionFields ( )
static
Returns
array

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

Referenced by arField\getAttributesForDescription().

113  {
114  return self::$allowed_description_fields;
115  }
+ Here is the caller graph for this function:

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )
Returns
array

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

References array, and getFields().

151  {
152  $return = array();
153  foreach ($this->getFields() as $field) {
154  $return[$field->getName()] = $field->getAttributesForConnector();
155  }
156 
157  return $return;
158  }
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 181 of file class.arFieldList.php.

References getFields().

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

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

References $fields.

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

302  {
303  return $this->fields;
304  }
+ Here is the caller graph for this function:

◆ getInstance()

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

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

References $ar.

Referenced by arFieldCache\store().

124  {
125  $arFieldList = new self($ar);
126  $arFieldList->initRawFields($ar);
127  $arFieldList->initFields();
128 
129  return $arFieldList;
130  }
+ Here is the caller graph for this function:

◆ getInstanceFromStorage()

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

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

References $ar.

Referenced by arFieldCache\storeFromStorage().

139  {
140  $arFieldList = new self();
141  $arFieldList->initRawFields($ar);
142  $arFieldList->initFields();
143 
144  return $arFieldList;
145  }
+ Here is the caller graph for this function:

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns

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

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

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

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )
Returns
string

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

References getPrimaryField().

218  {
219  return $this->getPrimaryField()->getName();
220  }
+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
array

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

References $primary_fields.

350  {
351  return $this->primary_fields;
352  }

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )
Returns
mixed

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

References getPrimaryField().

226  {
227  return $this->getPrimaryField()->getFieldType();
228  }
+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
array

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

References $raw_fields.

Referenced by initFields().

334  {
335  return $this->raw_fields;
336  }
+ Here is the caller graph for this function:

◆ initFields()

arFieldList::initFields ( )
protected

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

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

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

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

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 
257  $this->setRawFields($raw_fields);
258  }
setRawFields($raw_fields)
Add rich text string
The name of the decorator.
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 266 of file class.arFieldList.php.

References array.

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

◆ isField()

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

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

References getFields().

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

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

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

◆ setFields()

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

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

References $fields, and fields.

294  {
295  $this->fields = $fields;
296  }
$errors fields
Definition: imgupload.php:52

◆ setPrimaryField()

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

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

References $primary_field.

Referenced by initFields().

310  {
311  $this->primary_field = $primary_field;
312  }
+ 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.

References $primary_fields.

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

◆ setRawFields()

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

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

References $raw_fields.

Referenced by initRawFields().

326  {
327  $this->raw_fields = $raw_fields;
328  }
+ 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: