wishlist.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Wishlist extends oxUBase
00007 {
00008 
00014     protected $_sThisTemplate = 'page/wishlist/wishlist.tpl';
00015 
00021     protected $_oWishUser = null;
00022 
00028     protected $_oWishList = null;
00029 
00035     protected $_sSearchParam = null;
00036 
00042     protected $_oWishListUsers = false;
00043 
00049     protected $_blBargainAction = true;
00050 
00051 
00057     public function getWishUser()
00058     {
00059 
00060         if ($this->_oWishUser === null) {
00061             $this->_oWishUser = false;
00062 
00063             $sWishIdParameter = oxRegistry::getConfig()->getRequestParameter('wishid');
00064             $sUserId = $sWishIdParameter ? $sWishIdParameter : oxRegistry::getSession()->getVariable('wishid');
00065             if ($sUserId) {
00066                 $oUser = oxNew('oxuser');
00067                 if ($oUser->load($sUserId)) {
00068 
00069                     // passing wishlist information
00070                     $this->_oWishUser = $oUser;
00071 
00072                     // store this one to session
00073                     oxRegistry::getSession()->setVariable('wishid', $sUserId);
00074                 }
00075             }
00076         }
00077 
00078         return $this->_oWishUser;
00079     }
00080 
00086     public function getWishList()
00087     {
00088         if ($this->_oWishList === null) {
00089             $this->_oWishList = false;
00090 
00091             // passing wishlist information
00092             if ($oUser = $this->getWishUser()) {
00093 
00094                 $oWishlistBasket = $oUser->getBasket('wishlist');
00095                 $this->_oWishList = $oWishlistBasket->getArticles();
00096 
00097                 if (!$oWishlistBasket->isVisible()) {
00098                     $this->_oWishList = false;
00099                 }
00100 
00101 
00102             }
00103         }
00104 
00105         return $this->_oWishList;
00106     }
00107 
00116     public function searchForWishList()
00117     {
00118         if ($sSearch = oxRegistry::getConfig()->getRequestParameter('search')) {
00119 
00120             // search for baskets
00121             $oUserList = oxNew('oxuserlist');
00122             $oUserList->loadWishlistUsers($sSearch);
00123             if ($oUserList->count()) {
00124                 $this->_oWishListUsers = $oUserList;
00125             }
00126             $this->_sSearchParam = $sSearch;
00127         }
00128     }
00129 
00136     public function getWishListUsers()
00137     {
00138         return $this->_oWishListUsers;
00139     }
00140 
00146     public function getWishListSearchParam()
00147     {
00148         return $this->_sSearchParam;
00149     }
00150 
00156     public function getBreadCrumb()
00157     {
00158         $aPaths = array();
00159         $aPath = array();
00160 
00161         $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
00162         $aPath['title'] = oxRegistry::getLang()->translateString('PUBLIC_GIFT_REGISTRIES', $iBaseLanguage, false);
00163         $aPath['link'] = $this->getLink();
00164         $aPaths[] = $aPath;
00165 
00166         return $aPaths;
00167     }
00168 
00174     public function getTitle()
00175     {
00176         $oLang = oxRegistry::getLang();
00177         if ($oUser = $this->getWishUser()) {
00178             $sTranslatedString = $oLang->translateString('GIFT_REGISTRY_OF_3', $oLang->getBaseLanguage(), false);
00179             $sFirstnameField = 'oxuser__oxfname';
00180             $sLastnameField = 'oxuser__oxlname';
00181 
00182             $sTitle = $sTranslatedString . ' ' . $oUser->$sFirstnameField->value . ' ' . $oUser->$sLastnameField->value;
00183         } else {
00184             $sTitle = $oLang->translateString('PUBLIC_GIFT_REGISTRIES', $oLang->getBaseLanguage(), false);
00185         }
00186 
00187         return $sTitle;
00188     }
00189 }