Go to the documentation of this file.00001 <?php
00002
00007 class oxSelectlist extends oxI18n implements oxISelectList
00008 {
00009
00015 protected $_aFieldList = null;
00016
00022 protected $_sClassName = 'oxselectlist';
00023
00029 protected $_aList = null;
00030
00036 protected $_dVat = null;
00037
00043 protected $_oActiveSelection = null;
00044
00050 public function __construct()
00051 {
00052 parent::__construct();
00053 $this->init('oxselectlist');
00054 }
00055
00063 public function getFieldList($dVat = null)
00064 {
00065 if ($this->_aFieldList == null && $this->oxselectlist__oxvaldesc->value) {
00066 $this->_aFieldList = oxRegistry::getUtils()->assignValuesFromText($this->oxselectlist__oxvaldesc->value, $dVat);
00067 foreach ($this->_aFieldList as $sKey => $oField) {
00068 $this->_aFieldList[$sKey]->name = getStr()->strip_tags($this->_aFieldList[$sKey]->name);
00069 }
00070 }
00071
00072 return $this->_aFieldList;
00073 }
00074
00082 public function delete($sOXID = null)
00083 {
00084 if (!$sOXID) {
00085 $sOXID = $this->getId();
00086 }
00087 if (!$sOXID) {
00088 return false;
00089 }
00090
00091
00092 if ($blRemove = parent::delete($sOXID)) {
00093 $oDb = oxDb::getDb();
00094 $oDb->execute("delete from oxobject2selectlist where oxselnid = " . $oDb->quote($sOXID) . " ");
00095 }
00096
00097 return $blRemove;
00098 }
00099
00105 public function setVat($dVat)
00106 {
00107 $this->_dVat = $dVat;
00108 }
00109
00115 public function getVat()
00116 {
00117 return $this->_dVat;
00118 }
00119
00125 public function getLabel()
00126 {
00127 return $this->oxselectlist__oxtitle->value;
00128 }
00129
00135 public function getSelections()
00136 {
00137 if ($this->_aList === null && $this->oxselectlist__oxvaldesc->value) {
00138 $this->_aList = false;
00139 $aList = oxRegistry::getUtils()->assignValuesFromText($this->oxselectlist__oxvaldesc->getRawValue(), $this->getVat());
00140 foreach ($aList as $sKey => $oField) {
00141 if ($oField->name) {
00142 $this->_aList[$sKey] = oxNew("oxSelection", getStr()->strip_tags($oField->name), $sKey, false, $this->_aList === false ? true : false);
00143 }
00144 }
00145 }
00146
00147 return $this->_aList;
00148 }
00149
00155 public function getActiveSelection()
00156 {
00157 if ($this->_oActiveSelection === null) {
00158 if (($aSelections = $this->getSelections())) {
00159
00160 $this->_oActiveSelection = reset($aSelections);
00161 }
00162 }
00163
00164 return $this->_oActiveSelection;
00165 }
00166
00172 public function setActiveSelectionByIndex($iIdx)
00173 {
00174 if (($aSelections = $this->getSelections())) {
00175 $iSelIdx = 0;
00176 foreach ($aSelections as $oSelection) {
00177 $oSelection->setActiveState($iSelIdx == $iIdx);
00178 if ($iSelIdx == $iIdx) {
00179 $this->_oActiveSelection = $oSelection;
00180 }
00181 $iSelIdx++;
00182 }
00183 }
00184 }
00185
00186 }