oxvariantselectlist.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxVariantSelectList implements oxISelectList
00008 {
00013     protected $_sLabel = null;
00014 
00019     protected $_iIndex = 0;
00020 
00025     protected $_aList = array();
00026 
00031     protected $_oActiveSelection = null;
00032 
00041     public function __construct( $sLabel, $iIndex )
00042     {
00043         $this->_sLabel = trim( $sLabel );
00044         $this->_iIndex = $iIndex;
00045     }
00046 
00052     public function getLabel()
00053     {
00054         return getStr()->htmlspecialchars( $this->_sLabel );
00055     }
00056 
00067     public function addVariant( $sName, $sValue, $blDisabled, $blActive )
00068     {
00069         if ( ( $sName = trim( $sName ) ) ) {
00070             $sKey = $sValue;
00071 
00072             // creating new
00073             if ( !isset( $this->_aList[$sKey] ) ) {
00074                 $this->_aList[$sKey] = oxNew( "oxSelection", $sName, $sValue, $blDisabled, $blActive );
00075             } else {
00076 
00077                 // overriding states
00078                 if ( $this->_aList[$sKey]->isDisabled() && !$blDisabled ) {
00079                     $this->_aList[$sKey]->setDisabled( $blDisabled );
00080                 }
00081 
00082                 if ( !$this->_aList[$sKey]->isActive() && $blActive ) {
00083                     $this->_aList[$sKey]->setActiveState( $blActive );
00084                 }
00085             }
00086 
00087             // storing active selection
00088             if ( $this->_aList[$sKey]->isActive() ) {
00089                 $this->_oActiveSelection = $this->_aList[$sKey];
00090             }
00091         }
00092     }
00093 
00099     public function getActiveSelection()
00100     {
00101         return $this->_oActiveSelection;
00102     }
00103 
00109     public function getSelections()
00110     {
00111         return $this->_aList;
00112     }
00113 }