guestbook.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class GuestBook extends oxUBase
00008 {
00013     protected $_iCntPages = null;
00014 
00019     protected $_blShowLogin = false;
00020 
00025     protected $_aSortColumns = false;
00026 
00031     protected $_sSortBy = false;
00032 
00037     protected $_sSortDir = false;
00038 
00043     protected $_blFloodProtection = null;
00044 
00049     protected $_aEntries = null;
00050 
00055     protected $_sThisTemplate = 'guestbook.tpl';
00056 
00061     protected $_sThisLoginTemplate = 'guestbook_login.tpl';
00062 
00067     protected $_blShowSorting = true;
00068 
00073     protected $_oPageNavigation = null;
00074 
00080     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00081 
00092     public function render()
00093     {
00094         parent::render();
00095 
00096         // #774C no user mail and password check in guesbook
00097         if ( $this->_blShowLogin ) {
00098             //no valid login
00099             return $this->_sThisLoginTemplate;
00100         }
00101 
00102         $myConfig = $this->getConfig();
00103 
00104 
00105         // flood protection
00106         $this->_aViewData['hideentries'] = $this->floodProtection();
00107 
00108         $this->_aViewData["allsortcolumns"] = $this->getSortColumns();
00109 
00110         $this->_aViewData['gborderby'] = $this->getGbSortBy();
00111         $this->_aViewData['gborder']   = $this->getGbSortDir();
00112 
00113         // loading GB records
00114         $this->_aViewData['entries'] = $this->getEntries();
00115 
00116         // page navigation object
00117         $this->_aViewData['pageNavigation'] = $this->getPageNavigation;
00118 
00119         return $this->_sThisTemplate;
00120     }
00121 
00127     public function showLogin()
00128     {
00129         $this->_blShowLogin = true;
00130     }
00131 
00137     public function getSortColumns()
00138     {
00139         return $this->_aSortColumns;
00140     }
00141 
00147     public function getGbSortBy()
00148     {
00149         return $this->_sSortBy;
00150     }
00151 
00157     public function getGbSortDir()
00158     {
00159         return $this->_sSortDir;
00160     }
00161 
00167     public function getEntries()
00168     {
00169         if ( $this->_aEntries === null) {
00170             $this->_aEntries  = false;
00171             $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00172             $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 10;
00173 
00174             // loading only if there is some data
00175             $oEntries = oxNew( 'oxgbentry' );
00176             if ( $iCnt = $oEntries->getEntryCount() ) {
00177                 $this->_iCntPages = round( $iCnt / $iNrofCatArticles + 0.49 );
00178                 $this->_aEntries  = $oEntries->getAllEntries( $this->getActPage() * $iNrofCatArticles, $iNrofCatArticles, $this->getSortingSql( 'oxgb' ) );
00179             }
00180         }
00181         return $this->_aEntries;
00182     }
00183 
00189     public function floodProtection()
00190     {
00191         if ( $this->_blFloodProtection === null ) {
00192             $this->_blFloodProtection = false;
00193             // is user logged in ?
00194             $sUserId = oxSession::getVar( 'usr' );
00195             $sUserId = $sUserId ? $sUserId : 0;
00196 
00197             $oEntries = oxNew( 'oxgbentry' );
00198             $this->_blFloodProtection = $oEntries->floodProtection( $this->getConfig()->getShopId(), $sUserId );
00199 
00200         }
00201         return $this->_blFloodProtection;
00202     }
00203 
00217     public function prepareSortColumns()
00218     {
00219         $oUtils = oxUtils::getInstance();
00220 
00221         $this->_aSortColumns  = array( 'oxuser.oxusername', 'oxgbentries.oxcreate' );
00222 
00223         $sSortBy  = oxConfig::getParameter( 'gborderby' );
00224         $sSortDir = oxConfig::getParameter( 'gborder' );
00225 
00226         if ( !$sSortBy && $aSorting = $this->getSorting( 'oxgb' ) ) {
00227             $sSortBy  = $aSorting['sortby'];
00228             $sSortDir = $aSorting['sortdir'];
00229         }
00230 
00231         // finally setting defaults
00232         if ( !$sSortBy ) {
00233             $sSortBy  = 'oxgbentries.oxcreate';
00234             $sSortDir = 'desc';
00235         }
00236 
00237         if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
00238              $sSortDir && oxUtils::getInstance()->isValidAlpha( $sSortDir ) ) {
00239 
00240             $this->_sSortBy  = $sSortBy;
00241             $this->_sSortDir = $sSortDir;
00242 
00243             // caching sorting config
00244             $this->setItemSorting( 'oxgb', $sSortBy, $sSortDir );
00245         }
00246     }
00247 
00253     public function getPageNavigation()
00254     {
00255         if ( $this->_oPageNavigation === null ) {
00256             $this->_oPageNavigation = false;
00257             $this->_oPageNavigation = $this->generatePageNavigation();
00258         }
00259         return $this->_oPageNavigation;
00260     }
00261 
00262 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5