Go to the documentation of this file.00001 <?php
00002
00009 class oxcmp_utils extends oxView
00010 {
00015 protected $_blIsComponent = true;
00016
00025 public function getArticle()
00026 {
00027 $myConfig = $this->getConfig();
00028 $myUtils = oxRegistry::getUtils();
00029
00030 if (!$myConfig->getConfigParam("blAllowRemoteArticleInfo"))
00031 return false;
00032
00033
00034 $sOutput = 'OXID__Problem : no valid oxid !';
00035 $oProduct = null;
00036
00037 if ( ( $sId = oxConfig::getParameter( 'oxid' ) ) ) {
00038 $oProduct = oxNew( 'oxArticle' );
00039 $oProduct->load( $sId );
00040 } elseif ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
00041 $oArtList = oxNew( 'oxarticlelist');
00042 $oArtList->loadActionArticles( 'OXAFFILIATE' );
00043 $oProduct = $oArtList->current();
00044 }
00045
00046 if ( $oProduct ) {
00047
00048 $aExport = array();
00049
00050 $aClassVars = get_object_vars( $oProduct );
00051 $oStr = getStr();
00052
00053
00054 while ( list( $sFieldName, ) = each( $aClassVars ) ) {
00055 if ( $oStr->strstr( $sFieldName, 'oxarticles' ) ) {
00056 $sName = str_replace( 'oxarticles__', '', $sFieldName );
00057 $aExport[$sName] = $oProduct->$sFieldName->value;
00058 }
00059 }
00060
00061 $oPrice = $oProduct->getPrice();
00062
00063 $aExport['vatPercent'] = $oPrice->getVat();
00064 $aExport['netPrice'] = $myUtils->fRound( $oPrice->getNettoPrice() );
00065 $aExport['brutPrice'] = $myUtils->fRound( $oPrice->getBruttoPrice() );
00066 $aExport['vat'] = $oPrice->getVatValue();
00067 $aExport['fprice'] = $oProduct->getFPrice();
00068 $aExport['ftprice'] = $oProduct->getFTPrice();
00069
00070 $aExport['oxdetaillink'] = $oProduct->getLink();
00071 $aExport['oxmoredetaillink'] = $oProduct->getMoreDetailLink();
00072 $aExport['tobasketlink'] = $oProduct->getToBasketLink();
00073 $aExport['thumbnaillink'] = $myConfig->getPictureUrl(null, false, $myConfig->isSsl()) ."/". $aExport['oxthumb'];
00074 $sOutput = serialize( $aExport );
00075 }
00076
00077
00078 $myUtils->showMessageAndExit( $sOutput );
00079 }
00080
00092 public function toCompareList( $sProductId = null, $dAmount = null, $aSel = null, $blOverride = false, $blBundle = false )
00093 {
00094
00095 if ( $this->getViewConfig()->getShowCompareList() && !oxRegistry::getUtils()->isSearchEngine() ) {
00096
00097
00098
00099
00100 $blAddCompare = oxConfig::getParameter( 'addcompare' );
00101 $blRemoveCompare = oxConfig::getParameter( 'removecompare' );
00102 $sProductId = $sProductId ? $sProductId:oxConfig::getParameter( 'aid' );
00103 if ( ( $blAddCompare || $blRemoveCompare ) && $sProductId ) {
00104
00105
00106 $aItems = oxSession::getVar( 'aFiltcompproducts' );
00107 if ( $blAddCompare && !isset( $aItems[$sProductId] ) ) {
00108 $aItems[$sProductId] = true;
00109 }
00110
00111 if ( $blRemoveCompare ) {
00112 unset( $aItems[$sProductId] );
00113 }
00114
00115 oxSession::setVar( 'aFiltcompproducts', $aItems );
00116 $oParentView = $this->getParent();
00117
00118
00119 if ( ( $oProduct = $oParentView->getViewProduct() ) ) {
00120 if ( isset( $aItems[$oProduct->getId()] ) ) {
00121 $oProduct->setOnComparisonList( true );
00122 } else {
00123 $oProduct->setOnComparisonList( false );
00124 }
00125 }
00126
00127 $aViewProds = $oParentView->getViewProductList();
00128 if ( is_array( $aViewProds ) && count( $aViewProds ) ) {
00129 foreach ( $aViewProds as $oProduct ) {
00130 if ( isset( $aItems[$oProduct->getId()] ) ) {
00131 $oProduct->setOnComparisonList( true );
00132 } else {
00133 $oProduct->setOnComparisonList( false );
00134 }
00135 }
00136 }
00137 }
00138 }
00139 }
00140
00151 public function toNoticeList( $sProductId = null, $dAmount = null, $aSel = null)
00152 {
00153 $this->_toList( 'noticelist', $sProductId, $dAmount, $aSel );
00154 }
00155
00166 public function toWishList( $sProductId = null, $dAmount = null, $aSel = null )
00167 {
00168
00169 if ( $this->getViewConfig()->getShowWishlist() ) {
00170 $this->_toList( 'wishlist', $sProductId, $dAmount, $aSel );
00171 }
00172 }
00173
00184 protected function _toList( $sListType, $sProductId, $dAmount, $aSel )
00185 {
00186
00187 if ( $oUser = $this->getUser() ) {
00188
00189 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'itmid' );
00190 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'aid' );
00191 $dAmount = isset( $dAmount ) ? $dAmount : oxConfig::getParameter( 'am' );
00192 $aSel = $aSel ? $aSel : oxConfig::getParameter( 'sel' );
00193
00194
00195 $dAmount = str_replace( ',', '.', $dAmount );
00196 if ( !$this->getConfig()->getConfigParam( 'blAllowUnevenAmounts' ) ) {
00197 $dAmount = round( ( string ) $dAmount );
00198 }
00199
00200 $oBasket = $oUser->getBasket( $sListType );
00201 $oBasket->addItemToBasket( $sProductId, abs( $dAmount ), $aSel, ($dAmount == 0) );
00202
00203
00204 $oBasket->getItemCount( true );
00205 }
00206 }
00207
00213 public function render()
00214 {
00215 parent::render();
00216
00217 $myConfig = $this->getConfig();
00218 $oParentView = $this->getParent();
00219
00220
00221 $oContentList = oxNew( 'oxcontentlist' );
00222 $oContentList->loadMainMenulist();
00223 $oParentView->setMenueList( $oContentList );
00224
00225 return;
00226 }
00227 }