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