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 = oxUtils::getInstance();
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->loadAktionArticles( '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->getDynImageDir() ."/". $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() && !oxUtils::getInstance()->isSearchEngine() ) {
00095
00096
00097 $blAddCompare = oxConfig::getParameter( 'addcompare' );
00098 $blRemoveCompare = oxConfig::getParameter( 'removecompare' );
00099 $sProductId = $sProductId ? $sProductId:oxConfig::getParameter( 'aid' );
00100 if ( ( $blAddCompare || $blRemoveCompare ) && $sProductId ) {
00101
00102
00103 $aItems = oxConfig::getParameter( 'aFiltcompproducts' );
00104 if ( $blAddCompare && !isset( $aItems[$sProductId] ) ) {
00105 $aItems[$sProductId] = true;
00106 }
00107
00108 if ( $blRemoveCompare ) {
00109 unset( $aItems[$sProductId] );
00110 }
00111
00112 oxSession::setVar( 'aFiltcompproducts', $aItems );
00113 $oParentView = $this->getParent();
00114
00115
00116 if ( ( $oProduct = $oParentView->getViewProduct() ) ) {
00117 if ( isset( $aItems[$oProduct->getId()] ) ) {
00118 $oProduct->setOnComparisonList( true );
00119 } else {
00120 $oProduct->setOnComparisonList( false );
00121 }
00122 }
00123
00124 $aViewProds = $oParentView->getViewProductList();
00125 if ( is_array( $aViewProds ) && count( $aViewProds ) ) {
00126 foreach ( $aViewProds as $oProduct ) {
00127 if ( isset( $aItems[$oProduct->getId()] ) ) {
00128 $oProduct->setOnComparisonList( true );
00129 } else {
00130 $oProduct->setOnComparisonList( false );
00131 }
00132 }
00133 }
00134 }
00135 }
00136 }
00137
00148 public function toNoticeList( $sProductId = null, $dAmount = null, $aSel = null)
00149 {
00150 $this->_toList( 'noticelist', $sProductId, $dAmount, $aSel );
00151 }
00152
00163 public function toWishList( $sProductId = null, $dAmount = null, $aSel = null )
00164 {
00165
00166 if ( $this->getViewConfig()->getShowWishlist() ) {
00167 $this->_toList( 'wishlist', $sProductId, $dAmount, $aSel );
00168 }
00169 }
00170
00181 protected function _toList( $sListType, $sProductId, $dAmount, $aSel )
00182 {
00183
00184 if ( $oUser = $this->getUser() ) {
00185
00186 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'aid' );
00187 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'itmid' );
00188 $dAmount = isset( $dAmount ) ? $dAmount : oxConfig::getParameter( 'am' );
00189 $aSel = $aSel ? $aSel : oxConfig::getParameter( 'sel' );
00190
00191
00192 $dAmount = str_replace( ',', '.', $dAmount );
00193 if ( !$this->getConfig()->getConfigParam( 'blAllowUnevenAmounts' ) ) {
00194 $dAmount = round( ( string ) $dAmount );
00195 }
00196
00197 $oBasket = $oUser->getBasket( $sListType );
00198 $oBasket->addItemToBasket( $sProductId, abs( $dAmount ), $aSel, ($dAmount == 0) );
00199
00200
00201 $oBasket->getItemCount( true );
00202 }
00203 }
00204
00210 public function render()
00211 {
00212 parent::render();
00213
00214 $myConfig = $this->getConfig();
00215 $oParentView = $this->getParent();
00216
00217 if ( ( $oUser = $this->getUser() ) ) {
00218
00219
00220 if ( ( $sUserId = oxConfig::getParameter( 'wishid' ) ) ) {
00221 $oWishUser = oxNew( 'oxuser' );
00222 if ( $oWishUser->load( $sUserId ) ) {
00223 $oParentView->setWishlistName( $oWishUser->oxuser__oxfname->value );
00224
00225 $oParentView->addTplParam( 'ShowWishlistName', $oParentView->getWishlistName() );
00226 }
00227 }
00228 }
00229
00230
00231 $oContentList = oxNew( 'oxcontentlist' );
00232 $oContentList->loadMainMenulist();
00233 $oParentView->setMenueList( $oContentList );
00234
00235
00236 $oParentView->addTplParam( 'aMenueList', $oParentView->getMenueList() );
00237
00238
00239 if ( !$myConfig->getConfigParam( 'bl_perfLoadCompare' ) ||
00240 ( $myConfig->getConfigParam( 'blDisableNavBars' ) && $myConfig->getActiveView()->getIsOrderStep() ) ) {
00241 $oParentView->addTplParam('isfiltering', false );
00242 return;
00243 }
00244
00245
00246 $aItems = oxConfig::getParameter( 'aFiltcompproducts' );
00247 if ( is_array( $aItems ) && count( $aItems ) ) {
00248
00249 $oArticle = oxNew( 'oxarticle' );
00250
00251
00252 $sInSql = implode( ",", oxDb::getInstance()->quoteArray( array_keys( $aItems ) ) );
00253 $sSelect = "select count(oxid) from oxarticles where oxarticles.oxid in (".$sInSql.") ";
00254 $sSelect .= 'and '.$oArticle->getSqlActiveSnippet();
00255
00256 $iCnt = (int) oxDb::getDb()->getOne( $sSelect );
00257
00258
00259 $oParentView->setCompareItemsCnt( $iCnt );
00260
00261 $oParentView->addTplParam( 'oxcmp_compare', $oParentView->getCompareItemsCnt() );
00262
00263
00264 return $iCnt;
00265 }
00266 }
00267 }