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