Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Profile Class Reference

Public Member Functions

 tableName ()
 rules ()
 castToNull ($attribute)
 relations ()
 attributeLabels ()
 widgetAttributes ()
 widgetParams ($fieldName)
 getFields ()
 setAttributes ($values, $safeOnly=true)
 behaviors ()

Static Public Member Functions

static model ($className=__CLASS__)
static range ($str, $fieldValue=NULL)

Public Attributes

 $regMode = false

Detailed Description

Definition at line 3 of file Profile.php.

Member Function Documentation

Profile::attributeLabels ( )
Returns
array customized attribute labels (name=>label)

Definition at line 126 of file Profile.php.

References UserModule\t().

{
$labels = array(
'user_id' => UserModule::t('User ID'),
);
$model = $this->getFields();
foreach ($model as $field)
$labels[$field->varname] = ((Yii::app()->getModule('user')->fieldsMessage) ? UserModule::t($field->title, array(), Yii::app()->getModule('user')->fieldsMessage) : UserModule::t($field->title));
return $labels;
}
static Profile::model (   $className = __CLASS__)
static

Returns the static model of the specified AR class.

Returns
CActiveRecord the static model class

Definition at line 19 of file Profile.php.

Referenced by BulkController\actionClear(), ProfileFieldController\actionCreate(), AdminController\actionDelete(), ProfileFieldController\actionDelete(), SUserIdentity\authenticate(), ImportFile\overrideExisted(), and CommentsFormWidget\run().

{
return parent::model($className);
}
Profile::relations ( )
Returns
array relational rules.

Definition at line 112 of file Profile.php.

{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
$relations = array(
'user' => array(self::HAS_ONE, 'User', 'id'),
);
if (isset(Yii::app()->getModule('user')->profileRelations)) $relations = array_merge($relations, Yii::app()->getModule('user')->profileRelations);
return $relations;
}
Profile::rules ( )
Returns
array validation rules for model attributes.

Definition at line 35 of file Profile.php.

References UserModule\t().

{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
$required = array();
$numerical = array();
$rules = array();
$model = $this->getFields();
foreach ($model as $field) {
$field_rule = array();
if ($field->required == ProfileField::REQUIRED_YES_NOT_SHOW_REG || $field->required == ProfileField::REQUIRED_YES_SHOW_REG)
array_push($required, $field->varname);
if ($field->field_type == 'FLOAT' || $field->field_type == 'INTEGER')
array_push($numerical, $field->varname);
if ($field->field_type == 'VARCHAR' || $field->field_type == 'TEXT') {
array_push($rules, array($field->varname, 'common.components.NotContainsTagsValidator'));
$field_rule = array($field->varname, 'length', 'max' => $field->field_size, 'min' => $field->field_size_min);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules, $field_rule);
}
if ($field->other_validator) {
if (strpos($field->other_validator, '{') === 0) {
$validator = (array)CJavaScript::jsonDecode($field->other_validator);
foreach ($validator as $name => $val) {
$field_rule = array($field->varname, $name);
$field_rule = array_merge($field_rule, (array)$validator[$name]);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules, $field_rule);
}
} else {
$field_rule = array($field->varname, $field->other_validator);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules, $field_rule);
}
} elseif ($field->field_type == 'DATE') {
$field_rule = array($field->varname, 'type', 'type' => 'date', 'dateFormat' => 'yyyy-mm-dd', 'allowEmpty' => true);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules, $field_rule);
$field_rule = array($field->varname, 'castToNull');
array_push($rules, $field_rule);
}
if ($field->match) {
$field_rule = array($field->varname, 'match', 'pattern' => $field->match);
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules, $field_rule);
}
if ($field->range) {
if ($field->required == ProfileField::REQUIRED_YES_NOT_SHOW_REG || $field->required == ProfileField::REQUIRED_YES_SHOW_REG) {
$field_rule = array($field->varname, 'in', 'range' => self::rangeRules($field->range));
} else {
$field_rule = array($field->varname, 'in', 'range' => self::rangeRules($field->range), 'allowEmpty' => true);
}
if ($field->error_message) $field_rule['message'] = UserModule::t($field->error_message);
array_push($rules, $field_rule);
}
}
array_push($rules, array(implode(',', $required), 'required'));
array_push($rules, array(implode(',', $numerical), 'numerical', 'integerOnly' => true));
return $rules;
}
Profile::setAttributes (   $values,
  $safeOnly = true 
)

Extends setAttributes to handle active date fields

Parameters
$valuesarray
$safeOnlyboolean

Definition at line 216 of file Profile.php.

{
foreach ($this->widgetAttributes() as $fieldName => $className) {
if (isset($values[$fieldName]) && class_exists($className)) {
$class = new $className;
$arr = $this->widgetParams($fieldName);
if ($arr) {
$newParams = $class->params;
$arr = (array)CJavaScript::jsonDecode($arr);
foreach ($arr as $p => $v) {
if (isset($newParams[$p])) $newParams[$p] = $v;
}
$class->params = $newParams;
}
if (method_exists($class, 'setAttributes')) {
$values[$fieldName] = $class->setAttributes($values[$fieldName], $this, $fieldName);
}
}
}
parent::setAttributes($values, $safeOnly);
}
Profile::tableName ( )
Returns
string the associated database table name

Definition at line 27 of file Profile.php.

{
return Yii::app()->getModule('user')->tableProfiles;
}

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