suggest.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Suggest extends oxUBase
00009 {
00014     protected $_sThisTemplate = 'suggest.tpl';
00015 
00020     protected $_aReqFields = array( 'rec_name', 'rec_email', 'send_name', 'send_email', 'send_message', 'send_subject' );
00021 
00026     protected $_oCrossSelling = null;
00027 
00032     protected $_oSimilarProducts = null;
00033 
00038     protected $_oRecommList = null;
00039 
00044     protected $_aSuggestData = null;
00045 
00051     public function init()
00052     {
00053         parent::init();
00054         $this->_oProduct = $this->getProduct();
00055     }
00056 
00069     public function render()
00070     {
00071         parent::render();
00072 
00073         $this->_aViewData['product']           = $this->getProduct();
00074         $this->_aViewData['crossselllist']     = $this->getCrossSelling();
00075         $this->_aViewData['similarlist']       = $this->getSimilarProducts();
00076         $this->_aViewData['similarrecommlist'] = $this->getRecommList();
00077 
00078         $this->_aViewData['editval'] = $this->getSuggestData();
00079 
00080         return $this->_sThisTemplate;
00081     }
00082 
00092     public function send()
00093     {
00094         $aParams = oxConfig::getParameter( 'editval' );
00095         if ( !is_array( $aParams ) ) {
00096             return;
00097         }
00098 
00099         // storing used written values
00100         $oParams = new Oxstdclass();
00101         reset( $aParams );
00102         while ( list( $sName, $sValue ) = each( $aParams ) ) {
00103             $oParams->$sName = $sValue;
00104         }
00105         $this->_aSuggestData = $oParams;
00106 
00107         // filled not all fields ?
00108         foreach ( $this->_aReqFields as $sFieldName ) {
00109             if ( !isset( $aParams[$sFieldName] ) || !$aParams[$sFieldName] ) {
00110                 oxUtilsView::getInstance()->addErrorToDisplay('SUGGEST_COMLETECORRECTLYFIELDS');
00111                 return;
00112             }
00113         }
00114 
00115         $sReturn = "";
00116         // #1834M - specialchar search
00117         $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
00118         if ( $sSearchParamForLink ) {
00119             $sReturn .= "&searchparam=$sSearchParamForLink";
00120         }
00121 
00122         $sSearchCatId = oxConfig::getParameter( 'searchcnid' );
00123         if ( $sSearchCatId ) {
00124             $sReturn .= "&searchcnid=$sSearchCatId";
00125         }
00126 
00127         $sSearchVendor = oxConfig::getParameter( 'searchvendor' );
00128         if ( $sSearchVendor ) {
00129             $sReturn .= "&searchvendor=$sSearchVendor";
00130         }
00131 
00132         $sListType = oxConfig::getParameter( 'listtype' );
00133         if ( $sListType ) {
00134             $sReturn .= "&listtype=$sListType";
00135         }
00136 
00137         // sending suggest email
00138         $oEmail = oxNew( 'oxemail' );
00139         if ( $oEmail->sendSuggestMail( $oParams, $this->_oProduct ) ) {
00140             return 'details?anid='.$this->_oProduct->getId().$sReturn;
00141         } else {
00142             oxUtilsView::getInstance()->addErrorToDisplay('SUGGEST_INVALIDMAIL');
00143         }
00144     }
00145 
00151     public function getProduct()
00152     {
00153         if ( $this->_oProduct === null ) {
00154             $this->_oProduct = false;
00155             
00156             if ( $sAnid = oxConfig::getParameter( 'anid' ) ) {
00157                 $this->_oProduct = oxNewArticle( $sAnid );
00158             }
00159         }
00160         return $this->_oProduct;
00161     }
00162 
00168     public function getCrossSelling()
00169     {
00170         if ( $this->_oCrossSelling === null ) {
00171             $this->_oCrossSelling = false;
00172             if ( $this->_oProduct ) {
00173                 $this->_oCrossSelling = $this->_oProduct->getCrossSelling();
00174             }
00175         }
00176         return $this->_oCrossSelling;
00177     }
00178 
00184     public function getSimilarProducts()
00185     {
00186         if ( $this->_oSimilarProducts === null ) {
00187             $this->_oSimilarProducts = false;
00188             if ( $this->_oProduct ) {
00189                 $this->_oSimilarProducts = $this->_oProduct->getSimilarProducts();
00190             }
00191         }
00192         return $this->_oSimilarProducts;
00193     }
00194 
00200     public function getRecommList()
00201     {
00202         if ( $this->_oRecommList === null ) {
00203             $this->_oRecommList = false;
00204             if ( $this->_oProduct ) {
00205                 $oRecommList = oxNew('oxrecommlist');
00206                 $this->_oRecommList = $oRecommList->getRecommListsByIds( array($this->_oProduct->getId()));
00207             }
00208         }
00209         return $this->_oRecommList;
00210     }
00211 
00217     public function getSuggestData()
00218     {
00219         return $this->_aSuggestData;
00220     }
00221 
00222 }

Generated on Thu Dec 4 12:04:57 2008 for OXID eShop CE by  doxygen 1.5.5