HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
StatesBinaryFieldBehavior Class Reference

Public Member Functions

 beforeSave ($event)
 afterSave ($event)
 afterFind ($event)
 checkState ($states)
 convertAttribute ($type= 'auto')
 getStatesData ()
 statesIncluded ($states)
 statesExact ($states)
 statesAtLeast ($states)
 validateStates ($states)

Static Public Member Functions

static createBitMask ($states, $data)

Public Attributes

 $attribute = 'states'
 $data = array()
 $convertBeforeSave = true
 $convertAfterSave = true
 $convertAfterFind = true

Private Member Functions

 toDatabaseInt ()
 convertStates ($states)
 toOutputArray ()

Detailed Description

CActiveRecordBehavior for converting checkBoxList data to INT database field Converts data of multiple checkboxes to int representation by setting bits of integer value (like at *nix chmod command).

Author
Evgeny Lexunin lexun.nosp@m.in@g.nosp@m.mail..nosp@m.com

1.0

Definition at line 115 of file StatesBinaryFieldBehavior.php.

Member Function Documentation

StatesBinaryFieldBehavior::afterFind (   $event)

AfterFind attribute conversion to ARRAY format.

Parameters
CEvent$event

Definition at line 277 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::afterSave (   $event)

AfterSave attribute conversion to ARRAY format.

Parameters
CEvent$event

Definition at line 243 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::beforeSave (   $event)

BeforeSave attribute conversion to INT format.

Parameters
CEvent$event

Definition at line 167 of file StatesBinaryFieldBehavior.php.

Here is the call graph for this function:

StatesBinaryFieldBehavior::checkState (   $states)

Checking of key state Checking makes regardless to current conversion format. If multiple states given, returns true only if all of them is set.

Usage: if ($model->checkState(array('state1','state3'))) echo 'States 1 and 3 is set';

Parameters
array$statesSelected keys of {
See Also
self::$data} array.
Returns
boolean Is keys checked.

Definition at line 299 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::convertAttribute (   $type = 'auto')

Converts attribute to given or opposite format Options: int - convert attribute to INT database format arr - convert attribute to ARRAY format (like: array('state1','state3')) note: array format may be used in {

See Also
CHtml::checkBoxList()} auto - convert attribute to opposite format (int->array or array->int).
Parameters
string$typeType of conversion. Default set to 'auto'.

Definition at line 344 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::convertStates (   $states)
private

Converts states array to integer representation.

Parameters
array$states
Returns
int

Definition at line 194 of file StatesBinaryFieldBehavior.php.

static StatesBinaryFieldBehavior::createBitMask (   $states,
  $data 
)
static

Creates integer representation of given states.

Usage:

$states=array('state1','state3'); $data=array( 'state1'=>'First model state', 'state2'=>'Second model state', 'state3'=>'Third model state', ); $bitmask=StatesBinaryFieldBehavior::createBitMask($states,$data); // Returns integer: 5

Parameters
array$statesArray of setted states
data$dataArray of all available states
Returns
int Interger representation of states

Definition at line 224 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::getStatesData ( )

States data.

Returns
array Returns states data.

Definition at line 365 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::statesAtLeast (   $states)

Adds ARModel conditions for selecting records including at least one of given states.

Parameters
array$statesArray of states. Example: array('state1','state3')
Returns
owner

Definition at line 419 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::statesExact (   $states)

Adds ARModel conditions for selecting records including exactly given states.

Parameters
array$statesArray of states. Example: array('state1','state3')
Returns
owner

Definition at line 398 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::statesIncluded (   $states)

Adds ARModel conditions for selecting records including all given states.

Parameters
array$statesArray of states. Example: array('state1','state3')
Returns
owner

Definition at line 377 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::toDatabaseInt ( )
private

Converts attribute to database INT format Only if attribute value is array.

Definition at line 178 of file StatesBinaryFieldBehavior.php.

Here is the caller graph for this function:

StatesBinaryFieldBehavior::toOutputArray ( )
private

Converts attribute to output ARRAY format Array format may be used in {

See Also
CHtml::checkBoxList()} and such attribute can be set by $_POST request of {
CActiveForm}. Only if attribute value is int.

Definition at line 256 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::validateStates (   $states)

Definition at line 437 of file StatesBinaryFieldBehavior.php.

Member Data Documentation

StatesBinaryFieldBehavior::$attribute = 'states'

Definition at line 120 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::$convertAfterFind = true

Definition at line 160 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::$convertAfterSave = true

Definition at line 152 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::$convertBeforeSave = true

Definition at line 145 of file StatesBinaryFieldBehavior.php.

StatesBinaryFieldBehavior::$data = array()

Definition at line 138 of file StatesBinaryFieldBehavior.php.


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