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