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 $sOutput = 'OXID__Problem : no valid oxid !';
00031 $oProduct = null;
00032
00033 if ( ( $sId = oxConfig::getParameter( 'oxid' ) ) ) {
00034 $oProduct = oxNewArticle( $sId );
00035 } elseif ( $myConfig->getConfigParam( 'bl_perfLoadAktion' ) ) {
00036 $oArtList = oxNew( 'oxarticlelist');
00037 $oArtList->loadAktionArticles( 'OXAFFILIATE' );
00038 $oProduct = $oArtList->current();
00039 }
00040
00041 if ( $oProduct ) {
00042
00043 $aExport = array();
00044
00045 $aClassVars = get_object_vars( $oProduct );
00046 $oStr = getStr();
00047
00048
00049 while ( list( $sFieldName, ) = each( $aClassVars ) ) {
00050 if ( $oStr->strstr( $sFieldName, 'oxarticles' ) ) {
00051 $sName = str_replace( 'oxarticles__', '', $sFieldName );
00052 $aExport[$sName] = $oProduct->$sFieldName->value;
00053 }
00054 }
00055
00056 $oPrice = $oProduct->getPrice();
00057 $oTPrice = $oProduct->getTPrice();
00058
00059 $aExport['vatPercent'] = $oPrice->getVat();
00060 $aExport['netPrice'] = $myUtils->fRound( $oPrice->getNettoPrice() );
00061 $aExport['brutPrice'] = $myUtils->fRound( $oPrice->getBruttoPrice() );
00062 $aExport['vat'] = $oPrice->getVatValue();
00063 $aExport['fprice'] = $oProduct->getFPrice();
00064 $aExport['ftprice'] = oxLang::getInstance()->formatCurrency( $myUtils->fRound( $oTPrice->getBruttoPrice() ) );
00065
00066 $aExport['oxdetaillink'] = $oProduct->getLink();
00067 $aExport['oxmoredetaillink'] = $oProduct->getMoreDetailLink();
00068 $aExport['tobasketlink'] = $oProduct->getToBasketLink();
00069 $aExport['thumbnaillink'] = $myConfig->getDynImageDir() ."/". $aExport['oxthumb'];
00070 $sOutput = serialize( $aExport );
00071 }
00072
00073
00074 $myUtils->showMessageAndExit( $sOutput );
00075 }
00076
00088 public function toCompareList( $sProductId = null, $dAmount = null, $aSel = null, $blOverride = false, $blBundle = false )
00089 {
00090
00091 if ( $this->getViewConfig()->getShowCompareList() && !oxUtils::getInstance()->isSearchEngine() ) {
00092
00093
00094 $blAddCompare = oxConfig::getParameter( 'addcompare' );
00095 $blRemoveCompare = oxConfig::getParameter( 'removecompare' );
00096 $sProductId = $sProductId ? $sProductId:oxConfig::getParameter( 'aid' );
00097 if ( ( $blAddCompare || $blRemoveCompare ) && $sProductId ) {
00098
00099
00100 $aItems = oxConfig::getParameter( 'aFiltcompproducts' );
00101 if ( $blAddCompare && !isset( $aItems[$sProductId] ) ) {
00102 $aItems[$sProductId] = true;
00103 }
00104
00105 if ( $blRemoveCompare ) {
00106 unset( $aItems[$sProductId] );
00107 }
00108
00109 oxSession::setVar( 'aFiltcompproducts', $aItems );
00110 $oParentView = $this->getParent();
00111
00112
00113 if ( ( $oProduct = $oParentView->getViewProduct() ) ) {
00114 if ( isset( $aItems[$oProduct->getId()] ) ) {
00115 $oProduct->setOnComparisonList( true );
00116 } else {
00117 $oProduct->setOnComparisonList( false );
00118 }
00119 }
00120
00121 $aViewProds = $oParentView->getViewProductList();
00122 if ( is_array( $aViewProds ) && count( $aViewProds ) ) {
00123 foreach ( $aViewProds as $oProduct ) {
00124 if ( isset( $aItems[$oProduct->getId()] ) ) {
00125 $oProduct->setOnComparisonList( true );
00126 } else {
00127 $oProduct->setOnComparisonList( false );
00128 }
00129 }
00130 }
00131 }
00132 }
00133 }
00134
00145 public function toNoticeList( $sProductId = null, $dAmount = null, $aSel = null)
00146 {
00147 $this->_toList( 'noticelist', $sProductId, $dAmount, $aSel );
00148 }
00149
00160 public function toWishList( $sProductId = null, $dAmount = null, $aSel = null )
00161 {
00162
00163 if ( $this->getViewConfig()->getShowWishlist() ) {
00164 $this->_toList( 'wishlist', $sProductId, $dAmount, $aSel );
00165 }
00166 }
00167
00178 protected function _toList( $sListType, $sProductId, $dAmount, $aSel )
00179 {
00180
00181 if ( $oUser = $this->getUser() ) {
00182
00183 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'aid' );
00184 $sProductId = ($sProductId) ? $sProductId : oxConfig::getParameter( 'itmid' );
00185 $dAmount = isset( $dAmount ) ? $dAmount : oxConfig::getParameter( 'am' );
00186 $aSel = $aSel ? $aSel : oxConfig::getParameter( 'sel' );
00187
00188
00189 $dAmount = str_replace( ',', '.', $dAmount );
00190 if ( !$this->getConfig()->getConfigParam( 'blAllowUnevenAmounts' ) ) {
00191 $dAmount = round( ( string ) $dAmount );
00192 }
00193
00194 $oBasket = $oUser->getBasket( $sListType );
00195 $oBasket->addItemToBasket( $sProductId, abs( $dAmount ), $aSel );
00196
00197
00198 $oBasket->getItemCount( true );
00199 }
00200 }
00201
00207 public function render()
00208 {
00209 parent::render();
00210
00211 $myConfig = $this->getConfig();
00212 $oParentView = $this->getParent();
00213
00214 if ( ( $oUser = $this->getUser() ) ) {
00215
00216
00217 if ( ( $sUserId = oxConfig::getParameter( 'wishid' ) ) ) {
00218 $oWishUser = oxNew( 'oxuser' );
00219 if ( $oWishUser->load( $sUserId ) ) {
00220 $oParentView->setWishlistName( $oWishUser->oxuser__oxfname->value );
00221
00222 $oParentView->addTplParam( 'ShowWishlistName', $oParentView->getWishlistName() );
00223 }
00224 }
00225 }
00226
00227
00228 $oContentList = oxNew( 'oxcontentlist' );
00229 $oContentList->loadMainMenulist();
00230 $oParentView->setMenueList( $oContentList );
00231
00232
00233 $oParentView->addTplParam( 'aMenueList', $oParentView->getMenueList() );
00234
00235
00236 if ( !$myConfig->getConfigParam( 'bl_perfLoadCompare' ) ||
00237 ( $myConfig->getConfigParam( 'blDisableNavBars' ) && $myConfig->getActiveView()->getIsOrderStep() ) ) {
00238 $oParentView->addTplParam('isfiltering', false );
00239 return;
00240 }
00241
00242
00243 $aItems = oxConfig::getParameter( 'aFiltcompproducts' );
00244 if ( is_array( $aItems ) && count( $aItems ) ) {
00245
00246 $oArticle = oxNew( 'oxarticle' );
00247
00248
00249 $sInSql = implode( ",", oxDb::getInstance()->quoteArray( array_keys( $aItems ) ) );
00250 $sSelect = "select count(oxid) from oxarticles where oxarticles.oxid in (".$sInSql.") ";
00251 $sSelect .= 'and '.$oArticle->getSqlActiveSnippet();
00252
00253 $iCnt = (int) oxDb::getDb()->getOne( $sSelect );
00254
00255
00256 $oParentView->setCompareItemsCnt( $iCnt );
00257
00258 $oParentView->addTplParam( 'oxcmp_compare', $oParentView->getCompareItemsCnt() );
00259
00260
00261 return $iCnt;
00262 }
00263 }
00264 }