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