Public Member Functions | |
preDispatch () | |
indexAction () | |
postAction () | |
Public Attributes | |
const | XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email' |
const | XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity' |
const | XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template' |
const | XML_PATH_ENABLED = 'contacts/contacts/enabled' |
Definition at line 34 of file IndexController.php.
indexAction | ( | ) |
Definition at line 51 of file IndexController.php.
00052 { 00053 $this->loadLayout(); 00054 $this->getLayout()->getBlock('contactForm') 00055 ->setFormAction( Mage::getUrl('*/*/post') ); 00056 00057 $this->_initLayoutMessages('customer/session'); 00058 $this->_initLayoutMessages('catalog/session'); 00059 $this->renderLayout(); 00060 }
postAction | ( | ) |
Definition at line 62 of file IndexController.php.
00063 { 00064 $post = $this->getRequest()->getPost(); 00065 if ( $post ) { 00066 $translate = Mage::getSingleton('core/translate'); 00067 /* @var $translate Mage_Core_Model_Translate */ 00068 $translate->setTranslateInline(false); 00069 try { 00070 $postObject = new Varien_Object(); 00071 $postObject->setData($post); 00072 00073 $error = false; 00074 00075 if (!Zend_Validate::is(trim($post['name']) , 'NotEmpty')) { 00076 $error = true; 00077 } 00078 00079 if (!Zend_Validate::is(trim($post['comment']) , 'NotEmpty')) { 00080 $error = true; 00081 } 00082 00083 if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) { 00084 $error = true; 00085 } 00086 if ($error) { 00087 throw new Exception(); 00088 } 00089 $mailTemplate = Mage::getModel('core/email_template'); 00090 /* @var $mailTemplate Mage_Core_Model_Email_Template */ 00091 $mailTemplate->setDesignConfig(array('area' => 'frontend')) 00092 ->setReplyTo($post['email']) 00093 ->sendTransactional( 00094 Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), 00095 Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), 00096 Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), 00097 null, 00098 array('data' => $postObject) 00099 ); 00100 00101 if (!$mailTemplate->getSentSuccess()) { 00102 throw new Exception(); 00103 } 00104 00105 $translate->setTranslateInline(true); 00106 00107 Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.')); 00108 $this->_redirect('*/*/'); 00109 00110 return; 00111 } catch (Exception $e) { 00112 $translate->setTranslateInline(true); 00113 00114 Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later')); 00115 $this->_redirect('*/*/'); 00116 return; 00117 } 00118 00119 } else { 00120 $this->_redirect('*/*/'); 00121 } 00122 }
preDispatch | ( | ) |
Predispatch: shoud set layout area
Reimplemented from Mage_Core_Controller_Front_Action.
Definition at line 42 of file IndexController.php.
00043 { 00044 parent::preDispatch(); 00045 00046 if( !Mage::getStoreConfigFlag(self::XML_PATH_ENABLED) ) { 00047 $this->norouteAction(); 00048 } 00049 }
const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email' |
Definition at line 37 of file IndexController.php.
const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity' |
Definition at line 38 of file IndexController.php.
const XML_PATH_EMAIL_TEMPLATE = 'contacts/email/email_template' |
Definition at line 39 of file IndexController.php.
const XML_PATH_ENABLED = 'contacts/contacts/enabled' |
Definition at line 40 of file IndexController.php.