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