oxvariantselectlist.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxVariantSelectList implements oxISelectList
00008 {
00009 
00015     protected $_sLabel = null;
00016 
00022     protected $_iIndex = 0;
00023 
00029     protected $_aList = array();
00030 
00036     protected $_oActiveSelection = null;
00037 
00046     public function __construct($sLabel, $iIndex)
00047     {
00048         $this->_sLabel = trim($sLabel);
00049         $this->_iIndex = $iIndex;
00050     }
00051 
00057     public function getLabel()
00058     {
00059         return getStr()->htmlspecialchars($this->_sLabel);
00060     }
00061 
00070     public function addVariant($sName, $sValue, $blDisabled, $blActive)
00071     {
00072         if (($sName = trim($sName))) {
00073             $sKey = $sValue;
00074 
00075             // creating new
00076             if (!isset($this->_aList[$sKey])) {
00077                 $this->_aList[$sKey] = oxNew("oxSelection", $sName, $sValue, $blDisabled, $blActive);
00078             } else {
00079 
00080                 // overriding states
00081                 if ($this->_aList[$sKey]->isDisabled() && !$blDisabled) {
00082                     $this->_aList[$sKey]->setDisabled($blDisabled);
00083                 }
00084 
00085                 if (!$this->_aList[$sKey]->isActive() && $blActive) {
00086                     $this->_aList[$sKey]->setActiveState($blActive);
00087                 }
00088             }
00089 
00090             // storing active selection
00091             if ($this->_aList[$sKey]->isActive()) {
00092                 $this->_oActiveSelection = $this->_aList[$sKey];
00093             }
00094         }
00095     }
00096 
00102     public function getActiveSelection()
00103     {
00104         return $this->_oActiveSelection;
00105     }
00106 
00112     public function getSelections()
00113     {
00114         return $this->_aList;
00115     }
00116 }