ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
arFieldList Class Reference

Class arFieldList. More...

+ Collaboration diagram for arFieldList:

Public Member Functions

 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()
 

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.

Member Function Documentation

◆ checkAttributes()

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

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

260  {
261  if ($attributes[self::HAS_FIELD] === 'true') {
262  foreach (array_keys($attributes) as $atr) {
263  if (!self::isAllowedAttribute($atr)) {
264  return false;
265  }
266  }
267  } else {
268  return false;
269  }
270 
271  return true;
272  }

◆ getAllowedConnectorFields()

static arFieldList::getAllowedConnectorFields ( )
static
Returns
array

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

Referenced by arField\getAttributesForConnector().

91  {
92  return self::$allowed_connector_fields;
93  }
+ Here is the caller graph for this function:

◆ getAllowedDescriptionFields()

static arFieldList::getAllowedDescriptionFields ( )
static
Returns
array

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

Referenced by arField\getAttributesForDescription().

99  {
100  return self::$allowed_description_fields;
101  }
+ Here is the caller graph for this function:

◆ getArrayForConnector()

arFieldList::getArrayForConnector ( )
Returns
array

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

References getFields().

136  {
137  $return = array();
138  foreach ($this->getFields() as $field) {
139  $return[$field->getName()] = $field->getAttributesForConnector();
140  }
141 
142  return $return;
143  }
+ Here is the call graph for this function:

◆ getFieldByName()

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

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

References getFields().

166  {
167  $field = NULL;
168  static $field_map;
169  if ($field_map[$field_name]) {
170  return $field_map[$field_name];
171  }
172  foreach ($this->getFields() as $field) {
173  if ($field->getName() == $field_name) {
174  $field_map[$field_name] = $field;
175 
176  return $field;
177  }
178  }
179  }
+ Here is the call graph for this function:

◆ getFields()

arFieldList::getFields ( )
Returns
arField[]

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

References $fields.

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

286  {
287  return $this->fields;
288  }
+ Here is the caller graph for this function:

◆ getInstance()

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

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

Referenced by arFieldCache\store().

109  {
110  $arFieldList = new self();
111  $arFieldList->initRawFields($ar);
112  $arFieldList->initFields();
113 
114  return $arFieldList;
115  }
+ Here is the caller graph for this function:

◆ getInstanceFromStorage()

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

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

Referenced by arFieldCache\storeFromStorage().

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

◆ getPrimaryField()

arFieldList::getPrimaryField ( )
Returns

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

References $primary_field.

Referenced by getPrimaryFieldName(), and getPrimaryFieldType().

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

◆ getPrimaryFieldName()

arFieldList::getPrimaryFieldName ( )
Returns
string

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

References getPrimaryField().

202  {
203  return $this->getPrimaryField()->getName();
204  }
+ Here is the call graph for this function:

◆ getPrimaryFields()

arFieldList::getPrimaryFields ( )
Returns
array

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

References $primary_fields.

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

◆ getPrimaryFieldType()

arFieldList::getPrimaryFieldType ( )
Returns
mixed

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

References getPrimaryField().

210  {
211  return $this->getPrimaryField()->getFieldType();
212  }
+ Here is the call graph for this function:

◆ getRawFields()

arFieldList::getRawFields ( )
Returns
array

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

References $raw_fields.

Referenced by initFields().

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

◆ initFields()

arFieldList::initFields ( )
protected

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

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

146  {
147  foreach ($this->getRawFields() as $fieldname => $attributes) {
148  if (self::checkAttributes($attributes)) {
149  $arField = new arField();
150  $arField->getHasField(true);
151  $arField->loadFromArray($fieldname, $attributes);
152  $this->fields[] = $arField;
153  if ($arField->getPrimary()) {
154  $this->setPrimaryField($arField);
155  }
156  }
157  }
158  }
Class arField.
$errors fields
Definition: imgupload.php:48
setPrimaryField($primary_field)
+ Here is the call graph for this function:

◆ initRawFields()

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

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

References $raw_fields, and setRawFields().

220  {
221  $regex = "/[ ]*\\* @(" . implode('|', self::$prefixes) . ")_([a-zA-Z0-9_]*)[ ]*([a-zA-Z0-9_]*)/u";
222  $reflectionClass = new ReflectionClass($ar);
223  $raw_fields = array();
224  foreach ($reflectionClass->getProperties() as $property) {
225  if (in_array($property->getName(), self::$protected_names)) {
226  continue;
227  }
228  $properties_array = array();
229  $has_property = false;
230  foreach (explode("\n", $property->getDocComment()) as $line) {
231  if (preg_match($regex, $line, $matches)) {
232  $has_property = true;
233  $properties_array[(string)$matches[2]] = $matches[3];
234  }
235  }
236  if ($has_property) {
237  $raw_fields[$property->getName()] = $properties_array;
238  }
239  }
240 
241  $this->setRawFields($raw_fields);
242  }
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 250 of file class.arFieldList.php.

250  {
251  return in_array($attribute_name, array_merge(self::$allowed_description_fields, array( self::HAS_FIELD )));
252  }

◆ isField()

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

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

References getFields().

187  {
188  $is_field = false;
189  foreach ($this->getFields() as $field) {
190  if ($field->getName() == $field_name) {
191  $is_field = true;
192  }
193  }
194 
195  return $is_field;
196  }
+ Here is the call graph for this function:

◆ mapKey()

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

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

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

79  {
80  if (isset(self::$key_maps[$key])) {
81  return self::$key_maps[$key];
82  }
83 
84  return $key;
85  }
+ Here is the caller graph for this function:

◆ setFields()

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

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

References $fields, and fields.

278  {
279  $this->fields = $fields;
280  }
$errors fields
Definition: imgupload.php:48

◆ setPrimaryField()

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

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

References $primary_field.

Referenced by initFields().

294  {
295  $this->primary_field = $primary_field;
296  }
+ Here is the caller graph for this function:

◆ setPrimaryFields()

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

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

References $primary_fields.

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

◆ setRawFields()

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

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

References $raw_fields.

Referenced by initRawFields().

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

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

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