OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
oxselectlist.php
Go to the documentation of this file.
1 <?php
2 
7 class oxSelectlist extends oxI18n implements oxISelectList
8 {
9 
15  protected $_aFieldList = null;
16 
22  protected $_sClassName = 'oxselectlist';
23 
29  protected $_aList = null;
30 
36  protected $_dVat = null;
37 
43  protected $_oActiveSelection = null;
44 
50  public function __construct()
51  {
53  $this->init('oxselectlist');
54  }
55 
63  public function getFieldList($dVat = null)
64  {
65  if ($this->_aFieldList == null && $this->oxselectlist__oxvaldesc->value) {
66  $this->_aFieldList = oxRegistry::getUtils()->assignValuesFromText($this->oxselectlist__oxvaldesc->value, $dVat);
67  foreach ($this->_aFieldList as $sKey => $oField) {
68  $this->_aFieldList[$sKey]->name = getStr()->strip_tags($this->_aFieldList[$sKey]->name);
69  }
70  }
71 
72  return $this->_aFieldList;
73  }
74 
82  public function delete($sOXID = null)
83  {
84  if (!$sOXID) {
85  $sOXID = $this->getId();
86  }
87  if (!$sOXID) {
88  return false;
89  }
90 
91  // remove selectlists from articles also
92  if ($blRemove = parent::delete($sOXID)) {
93  $oDb = oxDb::getDb();
94  $oDb->execute("delete from oxobject2selectlist where oxselnid = " . $oDb->quote($sOXID) . " ");
95  }
96 
97  return $blRemove;
98  }
99 
105  public function setVat($dVat)
106  {
107  $this->_dVat = $dVat;
108  }
109 
115  public function getVat()
116  {
117  return $this->_dVat;
118  }
119 
125  public function getLabel()
126  {
127  return $this->oxselectlist__oxtitle->value;
128  }
129 
135  public function getSelections()
136  {
137  if ($this->_aList === null && $this->oxselectlist__oxvaldesc->value) {
138  $this->_aList = false;
139  $aList = oxRegistry::getUtils()->assignValuesFromText($this->oxselectlist__oxvaldesc->getRawValue(), $this->getVat());
140  foreach ($aList as $sKey => $oField) {
141  if ($oField->name) {
142  $this->_aList[$sKey] = oxNew("oxSelection", getStr()->strip_tags($oField->name), $sKey, false, $this->_aList === false ? true : false);
143  }
144  }
145  }
146 
147  return $this->_aList;
148  }
149 
155  public function getActiveSelection()
156  {
157  if ($this->_oActiveSelection === null) {
158  if (($aSelections = $this->getSelections())) {
159  // first is allways active
160  $this->_oActiveSelection = reset($aSelections);
161  }
162  }
163 
165  }
166 
172  public function setActiveSelectionByIndex($iIdx)
173  {
174  if (($aSelections = $this->getSelections())) {
175  $iSelIdx = 0;
176  foreach ($aSelections as $oSelection) {
177  $oSelection->setActiveState($iSelIdx == $iIdx);
178  if ($iSelIdx == $iIdx) {
179  $this->_oActiveSelection = $oSelection;
180  }
181  $iSelIdx++;
182  }
183  }
184  }
185 
186 }