|
eZ Publish
[4.2]
|
Encapsulates multiple options in one datatype. More...
Public Member Functions | |
| addMultiOption ($name, $multiOptionPriority, $defaultValue) | |
| addOption ($newID, $OptionID, $optionValue, $optionAdditionalPrice) | |
| attribute ($name) | |
| attributes () | |
| changeMultiOptionId () | |
| decodeXML ($xmlString) | |
| eZMultiOption ($name) | |
| hasAttribute ($name) | |
| removeMultiOptions ($array_remove) | |
| removeOptions ($arrayRemove, $optionId) | |
| resetOptionCounter () | |
| sortMultiOptions () | |
| xmlString () | |
Public Attributes | |
| $MultiOptionCount | |
| Contains the multioption counter value. | |
| $Name | |
| Contains the Option name. | |
| $OptionCounter | |
| Contains the option counter value. | |
| $Options | |
| Contains the Options. | |
Encapsulates multiple options in one datatype.
This class encapsulates multiple options by storing an array with multioption elements each containing a list of options. Managing multioptions is done using addMultiOption(), removeMultiOption() and changeMultiOption(). For a multioption you can add and remove options with addOption() and removeOptions(). For storage use the xmlString() and decodeXML() methods.
A multioption is a list of the group of options. All multioption's name are displayed simultaneously.
Multioption consists of id, name, priority and default_option_id.
An option is a list of values in which only one value can be selected at a time from drop down combobox. In the following e.g. Model-A,Model-B, Model-C are options for Model multioption and Red and Blue are options for Color multioption.
Option consists of id, option_id, value and additional_price.
In the following example Model and Color is known as an multioption. Examples: 1. If a motor car company is having different models and colors then it will be.
CAR
Model
----------------------
| |\/|
----------------------
| Model - A £ 100.00 |
| Model - B £ 200.00 |
| Model - C £ 300.00 |
----------------------
Color
-------------
| |\/|
-------------
| Red |
| Blue |
-------------
The xmlstring for the above eg will look like as follow
Array( [0] => Array(
[id] => 1
[name] => CAR
[priority] => 1
[default_option_id] => 2
[optionlist] => Array( [0] => Array( [id] => 1 [option_id] => 1 [value] => Model-A [additional_price] => 100 )
[1] => Array( [id] => 2 [option_id] => 2 [value] => Model-B [additional_price] => 200 )
[2] => Array( [id] => 3 [option_id] => 5 [value] => Model-C [additional_price] => 300 )
)
)
[1] => Array(
[id] => 2
[name] => Color
[priority] => 2
[default_option_id] => 1
[optionlist] => Array( [0] => Array( [id] => 1 [option_id] => 3 [value] => Red [additional_price] => )
[1] => Array( [id] => 2 [option_id] => 4 [value] => Blue[additional_price] => )
)
)
)
Example of how to crete an option, adding multioptions and options and finally retrieving the xml structure.
//include_once( "kernel/classes/datatypes/ezoption/ezmultioption.php" ); $option = new eZOption( "Car" ); $newID = $option->addMultiOption("Model",$priority,false); $option->addOption( $newID, "", "Model - A", "100", false ); $option->addOption( $newID, "", "Model - B", "100", false ); $option->addOption( $newID, "", "Model - C", "100", false ); $newID = $option->addMultiOption( "Color", $priority, false ); $option->addOption( $newID, "", "Red", "", false ); $option->addOption( $newID, "", "Blue", "", false ); // Serialize the class to an XML document $xmlString = $option->xmlString();
Definition at line 134 of file ezmultioption.php.
| eZMultiOption::addMultiOption | ( | $ | name, |
| $ | multiOptionPriority, | ||
| $ | defaultValue | ||
| ) |
Adds an Multioption named $name
| $name | contains the name of multioption. |
| $multiOptionPriority | is stored for displaying the array in order. |
| $defaultValue | is stored to display the options by default. |
Definition at line 154 of file ezmultioption.php.
Referenced by decodeXML().
| eZMultiOption::addOption | ( | $ | newID, |
| $ | OptionID, | ||
| $ | optionValue, | ||
| $ | optionAdditionalPrice | ||
| ) |
Adds an Option to multioption $name
| $newID | is the element key value to which the new option will be added. |
| $optionValue | is the original value to display for users. |
| $optionAdditionalPrice | is a price value that is used to store price of the option values. |
Definition at line 171 of file ezmultioption.php.
Referenced by decodeXML().
| eZMultiOption::attribute | ( | $ | name | ) |
Returns an attribute. The valid attributes are name and multioption_list name contains the name of multioption multioption_list contains the list of all multioptions.
Definition at line 291 of file ezmultioption.php.
| eZMultiOption::attributes | ( | ) |
Definition at line 270 of file ezmultioption.php.
Referenced by hasAttribute().
| eZMultiOption::changeMultiOptionId | ( | ) |
Change the id of multioption in ascending order.
Definition at line 218 of file ezmultioption.php.
Referenced by removeMultiOptions().
| eZMultiOption::decodeXML | ( | $ | xmlString | ) |
Will decode an xml string and initialize the eZ Multi option object. If $xmlString is on empty then it will call addMultiOption() and addOption() functions to create new multioption else it will decode the xml string.
| $xmlString | contains the complete data structure for multioptions. |
Definition at line 319 of file ezmultioption.php.
| eZMultiOption::eZMultiOption | ( | $ | name | ) |
Initializes with empty multioption list.
Definition at line 139 of file ezmultioption.php.
| eZMultiOption::hasAttribute | ( | $ | name | ) |
Returns true if object have an attribute. The valid attributes are name and multioption_list.
| $name | contains the name of attribute |
Definition at line 281 of file ezmultioption.php.
| eZMultiOption::removeMultiOptions | ( | $ | array_remove | ) |
Remove MultiOption from the array. After calling this function all the options associated with that multioption will be removed. This function also calles to changeMultiOption to reset the key value of multioption array.
| $array_remove | is the array of those multiOptions which is selected to remove. |
Definition at line 235 of file ezmultioption.php.
| eZMultiOption::removeOptions | ( | $ | arrayRemove, |
| $ | optionId | ||
| ) |
Remove Options from the multioption. This function first remove selected options and then reset the key value if all options for that multioption.
| $arrayRemove | is a list of all array elements which is selected to remove from the multioptions. |
| $optionId | is the key value if multioption from which it is required to remove the options. |
Definition at line 252 of file ezmultioption.php.
| eZMultiOption::resetOptionCounter | ( | ) |
Finds the largest option_id among the options and sets it as $this->OptionCounter
Definition at line 199 of file ezmultioption.php.
| eZMultiOption::sortMultiOptions | ( | ) |
Sorts the current multioption on the basis of it's priority value. After softing array it calles the function changeMultiOptionID, which again rearragnes the current priority value to 1,2,3......etc.
Definition at line 190 of file ezmultioption.php.
| eZMultiOption::xmlString | ( | ) |
Will return the XML string for this MultiOption set.
Definition at line 359 of file ezmultioption.php.
| eZMultiOption::$MultiOptionCount |
Contains the multioption counter value.
Definition at line 403 of file ezmultioption.php.
| eZMultiOption::$Name |
Contains the Option name.
Definition at line 399 of file ezmultioption.php.
| eZMultiOption::$OptionCounter |
Contains the option counter value.
Definition at line 405 of file ezmultioption.php.
| eZMultiOption::$Options |
Contains the Options.
Definition at line 401 of file ezmultioption.php.