OXID eShop CE  4.9.5
 All Classes Files Functions Variables Pages
wishlist.php
Go to the documentation of this file.
1 <?php
2 
6 class Wishlist extends oxUBase
7 {
8 
14  protected $_sThisTemplate = 'page/wishlist/wishlist.tpl';
15 
21  protected $_oWishUser = null;
22 
28  protected $_oWishList = null;
29 
35  protected $_sSearchParam = null;
36 
42  protected $_oWishListUsers = false;
43 
49  protected $_blBargainAction = true;
50 
51 
57  public function getWishUser()
58  {
59 
60  if ($this->_oWishUser === null) {
61  $this->_oWishUser = false;
62 
63  $sWishIdParameter = oxRegistry::getConfig()->getRequestParameter('wishid');
64  $sUserId = $sWishIdParameter ? $sWishIdParameter : oxRegistry::getSession()->getVariable('wishid');
65  if ($sUserId) {
66  $oUser = oxNew('oxuser');
67  if ($oUser->load($sUserId)) {
68 
69  // passing wishlist information
70  $this->_oWishUser = $oUser;
71 
72  // store this one to session
73  oxRegistry::getSession()->setVariable('wishid', $sUserId);
74  }
75  }
76  }
77 
78  return $this->_oWishUser;
79  }
80 
86  public function getWishList()
87  {
88  if ($this->_oWishList === null) {
89  $this->_oWishList = false;
90 
91  // passing wishlist information
92  if ($oUser = $this->getWishUser()) {
93 
94  $oWishlistBasket = $oUser->getBasket('wishlist');
95  $this->_oWishList = $oWishlistBasket->getArticles();
96 
97  if (!$oWishlistBasket->isVisible()) {
98  $this->_oWishList = false;
99  }
100 
101 
102  }
103  }
104 
105  return $this->_oWishList;
106  }
107 
116  public function searchForWishList()
117  {
118  if ($sSearch = oxRegistry::getConfig()->getRequestParameter('search')) {
119 
120  // search for baskets
121  $oUserList = oxNew('oxuserlist');
122  $oUserList->loadWishlistUsers($sSearch);
123  if ($oUserList->count()) {
124  $this->_oWishListUsers = $oUserList;
125  }
126  $this->_sSearchParam = $sSearch;
127  }
128  }
129 
136  public function getWishListUsers()
137  {
138  return $this->_oWishListUsers;
139  }
140 
146  public function getWishListSearchParam()
147  {
148  return $this->_sSearchParam;
149  }
150 
156  public function getBreadCrumb()
157  {
158  $aPaths = array();
159  $aPath = array();
160 
161  $iBaseLanguage = oxRegistry::getLang()->getBaseLanguage();
162  $aPath['title'] = oxRegistry::getLang()->translateString('PUBLIC_GIFT_REGISTRIES', $iBaseLanguage, false);
163  $aPath['link'] = $this->getLink();
164  $aPaths[] = $aPath;
165 
166  return $aPaths;
167  }
168 
174  public function getTitle()
175  {
176  $oLang = oxRegistry::getLang();
177  if ($oUser = $this->getWishUser()) {
178  $sTranslatedString = $oLang->translateString('GIFT_REGISTRY_OF_3', $oLang->getBaseLanguage(), false);
179  $sFirstnameField = 'oxuser__oxfname';
180  $sLastnameField = 'oxuser__oxlname';
181 
182  $sTitle = $sTranslatedString . ' ' . $oUser->$sFirstnameField->value . ' ' . $oUser->$sLastnameField->value;
183  } else {
184  $sTitle = $oLang->translateString('PUBLIC_GIFT_REGISTRIES', $oLang->getBaseLanguage(), false);
185  }
186 
187  return $sTitle;
188  }
189 }