Go to the documentation of this file.00001 <?php
00002
00006 class Wrapping extends oxUBase
00007 {
00013 protected $_sThisTemplate = 'wrapping.tpl';
00014
00020 protected $_aBasketItemList = null;
00021
00027 protected $_oWrappings = null;
00028
00034 protected $_oCards = null;
00035
00046 public function render()
00047 {
00048 parent::render();
00049
00050
00051 $this->_aViewData['basketitemlist'] = $this->getBasketItems();
00052 $this->_aViewData['wrappings'] = $this->getWrappingList();
00053 $this->_aViewData['cards'] = $this->getCardList();
00054
00055 return $this->_sThisTemplate;
00056 }
00057
00063 public function getBasketItems()
00064 {
00065 if ( $this->_aBasketItemList === null ) {
00066 $this->_aBasketItemList = false;
00067
00068
00069 if ( $oBasket = $this->getSession()->getBasket() ) {
00070 $this->_aBasketItemList = $oBasket->getBasketArticles();
00071 }
00072 }
00073
00074 return $this->_aBasketItemList;
00075 }
00076
00082 public function getWrappingList()
00083 {
00084 if ( $this->_oWrappings === null ) {
00085 $this->_oWrappings = new oxlist();
00086
00087
00088 if ( $this->getViewConfig()->getShowGiftWrapping() ) {
00089 $this->_oWrappings = oxNew( 'oxwrapping' )->getWrappingList( 'WRAP' );
00090 }
00091 }
00092 return $this->_oWrappings;
00093 }
00094
00100 public function getCardList()
00101 {
00102 if ( $this->_oCards === null ) {
00103 $this->_oCards = new oxlist();
00104
00105
00106 if ( $this->getViewConfig()->getShowGiftWrapping() ) {
00107 $this->_oCards = oxNew( 'oxwrapping' )->getWrappingList( 'CARD' );
00108 }
00109 }
00110
00111 return $this->_oCards;
00112 }
00113
00125 public function changeWrapping()
00126 {
00127 $aWrapping = oxConfig::getParameter( 'wrapping' );
00128 if ( $this->getViewConfig()->getShowGiftWrapping() &&
00129 is_array( $aWrapping ) && count( $aWrapping ) ) {
00130 $oBasket = $this->getSession()->getBasket();
00131
00132
00133 foreach ( $oBasket->getContents() as $sKey => $oBasketItem ) {
00134
00135 if ( isset( $aWrapping[$sKey] ) ) {
00136 $oBasketItem->setWrapping( $aWrapping[$sKey] );
00137 }
00138 }
00139
00140 $oBasket->setCardMessage( oxConfig::getParameter( 'giftmessage' ) );
00141 $oBasket->setCardId( oxConfig::getParameter( 'chosencard' ) );
00142 }
00143
00144 return 'order';
00145 }
00146 }