oxselectlist.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSelectlist extends oxI18n implements oxISelectList
00008 {
00013     protected $_aFieldList = null;
00014 
00019     protected $_sClassName = 'oxselectlist';
00020 
00026     protected $_aList = null;
00027 
00032     protected $_dVat = null;
00033 
00038     protected $_oActiveSelection = null;
00039 
00048     public function __construct( $sObjectsInListName = 'oxselectlist')
00049     {
00050         parent::__construct();
00051         $this->init( 'oxselectlist' );
00052     }
00053 
00061     public function getFieldList( $dVat = null )
00062     {
00063         if ( $this->_aFieldList == null && $this->oxselectlist__oxvaldesc->value ) {
00064             $this->_aFieldList = oxRegistry::getUtils()->assignValuesFromText( $this->oxselectlist__oxvaldesc->value, $dVat );
00065             foreach ( $this->_aFieldList as $sKey => $oField ) {
00066                 $this->_aFieldList[$sKey]->name = getStr()->strip_tags( $this->_aFieldList[$sKey]->name );
00067             }
00068         }
00069         return $this->_aFieldList;
00070     }
00071 
00079     public function delete( $sOXID = null )
00080     {
00081         if ( !$sOXID ) {
00082             $sOXID = $this->getId();
00083         }
00084         if ( !$sOXID ) {
00085             return false;
00086         }
00087 
00088         // remove selectlists from articles also
00089         if ( $blRemove = parent::delete( $sOXID ) ) {
00090             $oDb = oxDb::getDb();
00091             $oDb->execute( "delete from oxobject2selectlist where oxselnid = " . $oDb->quote( $sOXID ) . " " );
00092         }
00093 
00094         return $blRemove;
00095     }
00096 
00104     public function setVat( $dVat )
00105     {
00106         $this->_dVat = $dVat;
00107     }
00108 
00114     public function getVat()
00115     {
00116         return $this->_dVat;
00117     }
00118 
00124     public function getLabel()
00125     {
00126         return $this->oxselectlist__oxtitle->value;
00127     }
00128 
00134     public function getSelections()
00135     {
00136         if ( $this->_aList === null && $this->oxselectlist__oxvaldesc->value ) {
00137             $this->_aList = false;
00138             $aList = oxRegistry::getUtils()->assignValuesFromText( $this->oxselectlist__oxvaldesc->getRawValue(), $this->getVat() );
00139             foreach ( $aList as $sKey => $oField ) {
00140                 if ( $oField->name ) {
00141                    $this->_aList[$sKey] = oxNew( "oxSelection", getStr()->strip_tags( $oField->name ), $sKey, false, $this->_aList === false ? true : false );
00142                 }
00143             }
00144         }
00145         return $this->_aList;
00146     }
00147 
00153     public function getActiveSelection()
00154     {
00155         if ( $this->_oActiveSelection === null ) {
00156             if ( ( $aSelections = $this->getSelections() ) ) {
00157                 // first is allways active
00158                 $this->_oActiveSelection = reset( $aSelections );
00159             }
00160         }
00161 
00162         return $this->_oActiveSelection;
00163     }
00164 
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 
00187 
00188 
00189 }