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         // @deprecated, added to fix top navigation problem
00120         $this->getPageNavigation = $this->getPageNavigation();
00121 
00122         return $this->_sThisTemplate;
00123     }
00124 
00130     public function showLogin()
00131     {
00132         $this->_blShowLogin = true;
00133     }
00134 
00140     public function getSortColumns()
00141     {
00142         return $this->_aSortColumns;
00143     }
00144 
00150     public function getGbSortBy()
00151     {
00152         return $this->_sSortBy;
00153     }
00154 
00160     public function getGbSortDir()
00161     {
00162         return $this->_sSortDir;
00163     }
00164 
00170     public function getEntries()
00171     {
00172         if ( $this->_aEntries === null) {
00173             $this->_aEntries  = false;
00174             $iNrofCatArticles = (int) $this->getConfig()->getConfigParam( 'iNrofCatArticles' );
00175             $iNrofCatArticles = $iNrofCatArticles ? $iNrofCatArticles : 10;
00176 
00177             // loading only if there is some data
00178             $oEntries = oxNew( 'oxgbentry' );
00179             if ( $iCnt = $oEntries->getEntryCount() ) {
00180                 $this->_iCntPages = round( $iCnt / $iNrofCatArticles + 0.49 );
00181                 $this->_aEntries  = $oEntries->getAllEntries( $this->getActPage() * $iNrofCatArticles, $iNrofCatArticles, $this->getSortingSql( 'oxgb' ) );
00182             }
00183         }
00184         return $this->_aEntries;
00185     }
00186 
00192     public function floodProtection()
00193     {
00194         if ( $this->_blFloodProtection === null ) {
00195             $this->_blFloodProtection = false;
00196             // is user logged in ?
00197             $sUserId = oxSession::getVar( 'usr' );
00198             $sUserId = $sUserId ? $sUserId : 0;
00199 
00200             $oEntries = oxNew( 'oxgbentry' );
00201             $this->_blFloodProtection = $oEntries->floodProtection( $this->getConfig()->getShopId(), $sUserId );
00202 
00203         }
00204         return $this->_blFloodProtection;
00205     }
00206 
00220     public function prepareSortColumns()
00221     {
00222         $oUtils = oxUtils::getInstance();
00223 
00224         $this->_aSortColumns  = array( 'oxuser.oxusername', 'oxgbentries.oxcreate' );
00225 
00226         $sSortBy  = oxConfig::getParameter( 'gborderby' );
00227         $sSortDir = oxConfig::getParameter( 'gborder' );
00228 
00229         if ( !$sSortBy && $aSorting = $this->getSorting( 'oxgb' ) ) {
00230             $sSortBy  = $aSorting['sortby'];
00231             $sSortDir = $aSorting['sortdir'];
00232         }
00233 
00234         // finally setting defaults
00235         if ( !$sSortBy ) {
00236             $sSortBy  = 'oxgbentries.oxcreate';
00237             $sSortDir = 'desc';
00238         }
00239 
00240         if ( $sSortBy && oxDb::getInstance()->isValidFieldName( $sSortBy ) &&
00241              $sSortDir && oxUtils::getInstance()->isValidAlpha( $sSortDir ) ) {
00242 
00243             $this->_sSortBy  = $sSortBy;
00244             $this->_sSortDir = $sSortDir;
00245 
00246             // caching sorting config
00247             $this->setItemSorting( 'oxgb', $sSortBy, $sSortDir );
00248         }
00249     }
00250 
00256     public function getPageNavigation()
00257     {
00258         if ( $this->_oPageNavigation === null ) {
00259             $this->_oPageNavigation = false;
00260             $this->_oPageNavigation = $this->generatePageNavigation();
00261         }
00262         return $this->_oPageNavigation;
00263     }
00264 
00265 }

Generated on Tue Sep 29 16:45:15 2009 for OXID eShop CE by  doxygen 1.5.5