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 if (!oxRegistry::getSession()->checkSessionChallenge()) {
00154 return;
00155 }
00156
00157 $this->_toList('noticelist', $sProductId, $dAmount, $aSel);
00158 }
00159
00170 public function toWishList( $sProductId = null, $dAmount = null, $aSel = null )
00171 {
00172 if (!oxRegistry::getSession()->checkSessionChallenge()) {
00173 return;
00174 }
00175
00176
00177 if ( $this->getViewConfig()->getShowWishlist() ) {
00178 $this->_toList( 'wishlist', $sProductId, $dAmount, $aSel );
00179 }
00180 }
00181
00192 protected function _toList( $sListType, $sProductId, $dAmount, $aSel )
00193 {
00194
00195 if ( $oUser = $this->getUser() ) {
00196
00197 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'itmid' );
00198 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'aid' );
00199 $dAmount = isset( $dAmount ) ? $dAmount : oxConfig::getParameter( 'am' );
00200 $aSel = $aSel ? $aSel : oxConfig::getParameter( 'sel' );
00201
00202
00203 $dAmount = str_replace( ',', '.', $dAmount );
00204 if ( !$this->getConfig()->getConfigParam( 'blAllowUnevenAmounts' ) ) {
00205 $dAmount = round( ( string ) $dAmount );
00206 }
00207
00208 $oBasket = $oUser->getBasket( $sListType );
00209 $oBasket->addItemToBasket( $sProductId, abs( $dAmount ), $aSel, ($dAmount == 0) );
00210
00211
00212 $oBasket->getItemCount( true );
00213 }
00214 }
00215
00221 public function render()
00222 {
00223 parent::render();
00224
00225 $myConfig = $this->getConfig();
00226 $oParentView = $this->getParent();
00227
00228
00229 $oContentList = oxNew( 'oxcontentlist' );
00230 $oContentList->loadMainMenulist();
00231 $oParentView->setMenueList( $oContentList );
00232
00233 return;
00234 }
00235 }