예제 #1
0
 /**
  * Test to string.
  *
  * @return null
  */
 public function testToString()
 {
     $oEmos = new Emos("xxx", "yyy");
     //$oEmos->appendPreScript( 'pre' );
     //$oEmos->appendPostScript( 'post' );
     //$oEmos->jsFormatPrescript = "__JSPreScript__";
     //$oEmos->jsFormatScript = "__JSScript__";
     //$sExpt = "pre<script type=\"text/javascript\">window.emosTrackVersion = 2;</script>\n<script type=\"text/javascript\" src=\"xxxyyy\"></script>\n<script type=\"text/javascript\"><!--\n\tvar emospro = {};\n\twindow.emosPropertiesEvent(emospro);\n//-->\n</script>\npost";
     $sExpt = "<script type=\"text/javascript\">window.emosTrackVersion = 2;</script>\n<script type=\"text/javascript\" src=\"xxxyyy\"></script>\n<script type=\"text/javascript\"><!--\n\tvar emospro = {};\n\twindow.emosPropertiesEvent(emospro);\n//-->\n</script>\n";
     $oEmos->prettyPrint();
     $this->assertEquals($sExpt, $oEmos->toString());
 }
예제 #2
0
 /**
  * Sets basket actions (update and add) information to Emos.
  *
  * @param Emos $oEmos
  */
 private function _setBasketActionsInfo($oEmos)
 {
     // get the last Call for special handling function "tobasket", "changebasket"
     if ($aLastCall = oxRegistry::getSession()->getVariable('aLastcall')) {
         oxRegistry::getSession()->deleteVariable('aLastcall');
     }
     // ADD To Basket and Remove from Basket
     if (is_array($aLastCall) && count($aLastCall)) {
         $sCallAction = key($aLastCall);
         $aCallData = current($aLastCall);
         switch ($sCallAction) {
             case 'changebasket':
                 foreach ($aCallData as $sItemId => $aItemData) {
                     $oProduct = oxNew('oxArticle');
                     if ($aItemData['oldam'] > $aItemData['am'] && $oProduct->load($aItemData['aid'])) {
                         //ECONDA FIX always use the main category
                         //$sPath = $this->_getDeepestCategoryPath( $oProduct );
                         $sPath = $this->_getBasketProductCatPath($oProduct);
                         $oEmos->removeFromBasket($this->_convProd2EmosItem($oProduct, $sPath, $aItemData['oldam'] - $aItemData['am']));
                         //$oEmos->appendPreScript($aItemData['oldam'].'->'.$aItemData['am'].':'.$oProduct->load( $aItemData['aid']));
                     } elseif ($aItemData['oldam'] < $aItemData['am'] && $oProduct->load($aItemData['aid'])) {
                         $sPath = $this->_getBasketProductCatPath($oProduct);
                         $oEmos->addToBasket($this->_convProd2EmosItem($oProduct, $sPath, $aItemData['am'] - $aItemData['oldam']));
                     }
                 }
                 break;
             case 'tobasket':
                 foreach ($aCallData as $sItemId => $aItemData) {
                     // ECONDA FIX if there is a "add to basket" in the artcle list view, we do not have a product ID here
                     $oProduct = oxNew('oxArticle');
                     if ($oProduct->load($sItemId)) {
                         //ECONDA FIX always use the main category
                         //$sPath = $this->_getDeepestCategoryPath( $oProduct );
                         $sPath = $this->_getBasketProductCatPath($oProduct);
                         $oEmos->addToBasket($this->_convProd2EmosItem($oProduct, $sPath, $aItemData['am']));
                     }
                 }
                 break;
         }
     }
 }