eZ Publish  [4.2]
eZMultiOption Class Reference

Encapsulates multiple options in one datatype. More...

List of all members.

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.

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


Member Function Documentation

eZMultiOption::addMultiOption ( name,
multiOptionPriority,
defaultValue 
)

Adds an Multioption named $name

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

Definition at line 154 of file ezmultioption.php.

Referenced by decodeXML().

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

Adds an Option to multioption $name

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

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 ( )
Returns:
list of supported 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.

Parameters:
$xmlStringcontains the complete data structure for multioptions.
See also:
xmlString()

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.

Parameters:
$namecontains 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.

Parameters:
$array_removeis the array of those multiOptions which is selected to remove.
See also:
removeOptions()

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.

Parameters:
$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:
removeMultiOptions()

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.

See also:
decodeXML()

Definition at line 359 of file ezmultioption.php.


Member Data Documentation

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.


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