Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Public Attributes | List of all members
eZMultiOption Class Reference

Encapsulates multiple options in one datatype. More...

## Public Member Functions
| __construct ( $name)
| addMultiOption ( $name, $multiOptionPriority, $defaultValue)
| addOption ( $newID, $OptionID, $optionValue, $optionAdditionalPrice)
| sortMultiOptions ()
| resetOptionCounter ()
| changeMultiOptionId ()
| removeMultiOptions ( $array_remove)
| removeOptions ( $arrayRemove, $optionId)
| attributes ()
| hasAttribute ( $name)
| attribute ( $name)
| decodeXML ( $xmlString)
| xmlString ()

## Public Attributes
| $Name
| $Options
| Contains the Options. More...
| $MultiOptionCount
| Contains the multioption counter value. More...
| $OptionCounter
| Contains the option counter value. 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.

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

$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();
eZOption
eZOption handles option set datatypes
Definition: ezoption.php:29

Definition at line 113 of file ezmultioption.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZMultiOption::__construct | ( |  | $name | ) |

Initializes with empty multioption list.

Parameters

  string | $name |

Definition at line 123 of file ezmultioption.php.

## Member Function Documentation

## ◆ addMultiOption()

eZMultiOption::addMultiOption | ( |  | $name,
|  |  | $multiOptionPriority,
|  |  | $defaultValue
| ) |  |

Adds an Multioption named $name

Parameters

  $name | contains the name of multioption.
  $multiOptionPriority | is stored for displaying the array in order.
  $defaultValue | is stored to display the options by default.

Returns
  The ID of the multioption that was added.

Definition at line 138 of file ezmultioption.php.

References $MultiOptionCount.

Referenced by decodeXML().

## ◆ addOption()

eZMultiOption::addOption | ( |  | $newID,
|  |  | $OptionID,
|  |  | $optionValue,
|  |  | $optionAdditionalPrice
| ) |  |

Adds an Option to multioption $name

Parameters

  $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 155 of file ezmultioption.php.

References $OptionCounter.

Referenced by decodeXML().

## ◆ attribute()

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 282 of file ezmultioption.php.

References $Name, $Options, and eZDebug\writeError().

## ◆ attributes()

eZMultiOption::attributes | ( |  | ) |

Returns
  list of supported attributes

Definition at line 261 of file ezmultioption.php.

Referenced by hasAttribute().

## ◆ changeMultiOptionId()

eZMultiOption::changeMultiOptionId | ( |  | ) |

Change the id of multioption in ascending order.

Definition at line 209 of file ezmultioption.php.

Referenced by removeMultiOptions().

## ◆ decodeXML()

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.

Parameters

  $xmlString | contains the complete data structure for multioptions.

See also
  xmlString()

Definition at line 310 of file ezmultioption.php.

References addMultiOption(), and addOption().

## ◆ hasAttribute()

eZMultiOption::hasAttribute | ( |  | $name | ) |

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

Parameters

  $name | contains the name of attribute

Definition at line 272 of file ezmultioption.php.

References attributes().

## ◆ removeMultiOptions()

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.

Parameters

  $array_remove | is the array of those multiOptions which is selected to remove.

See also
  removeOptions()

Definition at line 226 of file ezmultioption.php.

References changeMultiOptionId().

## ◆ removeOptions()

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.

Parameters

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

See also
  removeMultiOptions()

Definition at line 243 of file ezmultioption.php.

## ◆ resetOptionCounter()

eZMultiOption::resetOptionCounter | ( |  | ) |

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

Definition at line 190 of file ezmultioption.php.

## ◆ sortMultiOptions()

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 174 of file ezmultioption.php.

## ◆ xmlString()

eZMultiOption::xmlString | ( |  | ) |

Will return the XML string for this MultiOption set.

See also
  decodeXML()

Definition at line 344 of file ezmultioption.php.

## Member Data Documentation

## ◆ $MultiOptionCount

eZMultiOption::$MultiOptionCount

Contains the multioption counter value.

Definition at line 388 of file ezmultioption.php.

Referenced by addMultiOption().

## ◆ $Name

eZMultiOption::$Name

Contains the Option name

Definition at line 384 of file ezmultioption.php.

Referenced by attribute().

## ◆ $OptionCounter

eZMultiOption::$OptionCounter

Contains the option counter value.

Definition at line 390 of file ezmultioption.php.

Referenced by addOption().

## ◆ $Options

eZMultiOption::$Options

Contains the Options.

Definition at line 386 of file ezmultioption.php.

Referenced by attribute().

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

- ezmultioption.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.