Go to the documentation of this file.00001 <?php
00002
00009 class Account_Recommlist extends Account
00010 {
00016 protected $_sThisTemplate = 'page/account/recommendationlist.tpl';
00017
00023 protected $_blSavedEntry = false;
00024
00030 protected $_oActRecommListArticles = null;
00031
00037 protected $_aUserRecommLists = null;
00038
00044 protected $_oActRecommList = null;
00045
00051 protected $_iAllArtCnt = 0;
00052
00057 protected $_oPageNavigation = null;
00058
00067 public function render()
00068 {
00069 parent::render();
00070
00071
00072 if ( !( $oUser = $this->getUser() ) ) {
00073 return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00074 }
00075
00076 $oLists = $this->getRecommLists();
00077 $oActList = $this->getActiveRecommList();
00078
00079
00080 if ( !$oActList && $oLists->count() ) {
00081 $this->_iAllArtCnt = $oUser->getRecommListsCount();
00082 $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00083 $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 10;
00084 $this->_iCntPages = round( $this->_iAllArtCnt / $iNrofCatArticles + 0.49 );
00085 }
00086
00087 return $this->_sThisTemplate;
00088 }
00089
00095 public function getNavigationParams()
00096 {
00097 $aParams = parent::getNavigationParams();
00098
00099
00100 if ( ( $oList = $this->getActiveRecommList() ) ) {
00101 $aParams['recommid'] = $oList->getId();
00102 }
00103
00104 return $aParams;
00105 }
00106
00112 public function getRecommLists()
00113 {
00114 if ( $this->_aUserRecommLists === null ) {
00115 $this->_aUserRecommLists = false;
00116 if ( ( $oUser = $this->getUser() ) ) {
00117
00118 $this->_aUserRecommLists = $oUser->getUserRecommLists();
00119 }
00120 }
00121 return $this->_aUserRecommLists;
00122 }
00123
00129 public function getArticleList()
00130 {
00131 if ( $this->_oActRecommListArticles === null ) {
00132 $this->_oActRecommListArticles = false;
00133
00134 if ( ( $oRecommList = $this->getActiveRecommList() ) ) {
00135 $oItemList = $oRecommList->getArticles();
00136
00137 if ( $oItemList->count() ) {
00138 foreach ( $oItemList as $oItem ) {
00139 $oItem->text = $oRecommList->getArtDescription( $oItem->getId() );
00140 }
00141 $this->_oActRecommListArticles = $oItemList;
00142 }
00143 }
00144 }
00145
00146 return $this->_oActRecommListArticles;
00147 }
00148
00154 public function getActiveRecommList()
00155 {
00156 if (!$this->getViewConfig()->getShowListmania()) {
00157 return false;
00158 }
00159
00160 if ( $this->_oActRecommList === null ) {
00161 $this->_oActRecommList = false;
00162
00163 if ( ( $oUser = $this->getUser() ) &&
00164 ( $sRecommId = oxConfig::getParameter( 'recommid' ) )) {
00165
00166 $oRecommList = oxNew( 'oxrecommlist' );
00167 if ( ( $oRecommList->load( $sRecommId ) ) && $oUser->getId() === $oRecommList->oxrecommlists__oxuserid->value ) {
00168 $this->_oActRecommList = $oRecommList;
00169 }
00170 }
00171 }
00172
00173 return $this->_oActRecommList;
00174 }
00175
00183 public function setActiveRecommList( $oRecommList )
00184 {
00185 $this->_oActRecommList = $oRecommList;
00186 }
00187
00193 public function saveRecommList()
00194 {
00195 if (!$this->getViewConfig()->getShowListmania()) {
00196 return;
00197 }
00198
00199 if ( ( $oUser = $this->getUser() ) ) {
00200 if ( !( $oRecommList = $this->getActiveRecommList() ) ) {
00201 $oRecommList = oxNew( 'oxrecommlist' );
00202 $oRecommList->oxrecommlists__oxuserid = new oxField( $oUser->getId());
00203 $oRecommList->oxrecommlists__oxshopid = new oxField( $this->getConfig()->getShopId() );
00204 } else {
00205 $this->_sThisTemplate = 'page/account/recommendationedit.tpl';
00206 }
00207
00208 $sTitle = trim( ( string ) oxConfig::getParameter( 'recomm_title', 1 ) );
00209 $sAuthor = trim( ( string ) oxConfig::getParameter( 'recomm_author', 1 ) );
00210 $sText = trim( ( string ) oxConfig::getParameter( 'recomm_desc', 1 ) );
00211
00212 $oRecommList->oxrecommlists__oxtitle = new oxField( $sTitle );
00213 $oRecommList->oxrecommlists__oxauthor = new oxField( $sAuthor );
00214 $oRecommList->oxrecommlists__oxdesc = new oxField( $sText );
00215
00216 try {
00217
00218 $this->_blSavedEntry = (bool) $oRecommList->save();
00219 $this->setActiveRecommList( $this->_blSavedEntry ? $oRecommList : false );
00220 } catch (oxObjectException $oEx ) {
00221
00222 oxUtilsView::getInstance()->addErrorToDisplay( $oEx, false, true, 'user' );
00223 }
00224 }
00225 }
00226
00232 public function isSavedList()
00233 {
00234 return $this->_blSavedEntry;
00235 }
00236
00242 public function editList()
00243 {
00244 if (!$this->getViewConfig()->getShowListmania()) {
00245 return;
00246 }
00247
00248
00249 if ( ( $sAction = oxConfig::getParameter( 'deleteList' ) ) &&
00250 ( $oRecommList = $this->getActiveRecommList() ) ) {
00251 $oRecommList->delete();
00252 $this->setActiveRecommList( false );
00253 } else {
00254 $this->_sThisTemplate = 'page/account/recommendationedit.tpl';
00255 }
00256 }
00257
00263 public function removeArticle()
00264 {
00265 if (!$this->getViewConfig()->getShowListmania()) {
00266 return;
00267 }
00268
00269 if ( ( $sArtId = oxConfig::getParameter( 'aid' ) ) &&
00270 ( $oRecommList = $this->getActiveRecommList() ) ) {
00271 $oRecommList->removeArticle( $sArtId );
00272 }
00273 $this->_sThisTemplate = 'page/account/recommendationedit.tpl';
00274 }
00275
00281 public function getPageNavigation()
00282 {
00283 if ( $this->_oPageNavigation === null ) {
00284 $this->_oPageNavigation = false;
00285 if ( !$this->getActiveRecommlist() ) {
00286 $this->_oPageNavigation = $this->generatePageNavigation();
00287 }
00288 }
00289 return $this->_oPageNavigation;
00290 }
00291
00297 public function getBreadCrumb()
00298 {
00299 $aPaths = array();
00300 $aPath = array();
00301
00302 $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_MY_ACCOUNT', oxLang::getInstance()->getBaseLanguage(), false );
00303 $aPath['link'] = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
00304 $aPaths[] = $aPath;
00305
00306 $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_RECOMMENDATIONLIST_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
00307 $aPath['link'] = $this->getLink();
00308 $aPaths[] = $aPath;
00309
00310 return $aPaths;
00311 }
00312
00313 }