eZPublish  4.5
eZMultiOption Class Reference

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

 Contains the multioption counter value. More...
 Contains the Option name. More...
 Contains the option counter value. More...
 Contains the Options. More...

Detailed Description

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.

  • id : is a unique representation of all multioptions.
  • name : name of multioption.
  • priority : Priority value is is used to sort the multioption after sorting it will change the original priority value to 1,2,3...
  • default_option_id : is to displaying the default option from the list.
  • optionlist : list of all option elements.

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.

  • id : unique representation of options in a multioption.
  • option_id : option_id is unique among all options, it is used to retrieve values for shop or similar operations.
  • value : value is a string and it is a value used as display for that option.
  • additional_price : This is an additional price that will add to the original price and will display in currency format for that value. If the price value is not given then it will will not display anything in that place.

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.
| |\/|
| Model - A <A3> 100.00 |
| Model - B <A3> 200.00 |
| Model - C <A3> 300.00 |
| |\/|
| 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.

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

Member Function Documentation

eZMultiOption::addMultiOption (   $name,

Adds an Multioption named $name

$namecontains the name of multioption.
$multiOptionPriorityis stored for displaying the array in order.
$defaultValueis stored to display the options by default.
The ID of the multioption that was added.

Referenced by decodeXML().

eZMultiOption::addOption (   $newID,

Adds an Option to multioption $name

$newIDis the element key value to which the new option will be added.
$optionValueis the original value to display for users.
$optionAdditionalPriceis a price value that is used to store price of the option values.

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.

eZMultiOption::attributes ( )
list of supported attributes

Referenced by hasAttribute().

eZMultiOption::changeMultiOptionId ( )

Change the id of multioption in ascending order.

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.

$xmlStringcontains the complete data structure for multioptions.
See Also
eZMultiOption::eZMultiOption (   $name)

Initializes with empty multioption list.

eZMultiOption::hasAttribute (   $name)

Returns true if object have an attribute. The valid attributes are name and multioption_list.

$namecontains the name of attribute
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_removeis the array of those multiOptions which is selected to remove.
See Also
eZMultiOption::removeOptions (   $arrayRemove,

Remove Options from the multioption. This function first remove selected options and then reset the key value if all options for that multioption.

$arrayRemoveis a list of all array elements which is selected to remove from the multioptions.
$optionIdis the key value if multioption from which it is required to remove the options.
See Also
eZMultiOption::resetOptionCounter ( )

Finds the largest option_id among the options and sets it as $this->OptionCounter

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.

eZMultiOption::xmlString ( )

Will return the XML string for this MultiOption set.

See Also

Member Data Documentation


Contains the multioption counter value.

Referenced by addMultiOption().


Contains the Option name.

Referenced by attribute().


Contains the option counter value.

Referenced by addOption().


Contains the Options.

Referenced by attribute().

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