/**
  * Displays the contact page
  */
 public function actionContact()
 {
     $model = CustomPage::LoadByRequestUrl('contact-us');
     $this->pageTitle = $model->PageTitle;
     $this->pageDescription = $model->meta_description;
     $this->breadcrumbs = array($model->title => $model->RequestUrl);
     $this->layout = "//layouts/column" . $model->column_template;
     $ContactForm = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $ContactForm->attributes = $_POST['ContactForm'];
         if ($ContactForm->validate()) {
             $objEmail = new EmailQueue();
             if (!Yii::app()->user->isGuest) {
                 $objCustomer = Customer::GetCurrent();
                 $objEmail->customer_id = $objCustomer->id;
                 $ContactForm->fromName = $objCustomer->mainname;
                 $ContactForm->fromEmail = $objCustomer->email;
             }
             $strHtmlBody = $this->renderPartial('/mail/_contactform', array('model' => $ContactForm), true);
             $strSubject = Yii::t('email', 'Contact Us:') . $ContactForm->contactSubject;
             $objEmail->htmlbody = $strHtmlBody;
             $objEmail->subject = $strSubject;
             $orderEmail = _xls_get_conf('ORDER_FROM', '');
             $objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail;
             $objHtml = new HtmlToText();
             //If we get back false, it means conversion failed which 99.9% of the time means improper HTML.
             $strPlain = $objHtml->convert_html_to_text($strHtmlBody);
             if ($strPlain !== false) {
                 $objEmail->plainbody = $strPlain;
             }
             if (!$objEmail->save()) {
                 Yii::log("Error creating email " . print_r($objEmail, true) . " " . print_r($objEmail->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             }
             Yii::app()->user->setFlash('success', Yii::t('email', 'Message sent. Thank you for contacting us. We will respond to you as soon as possible.'));
             //Attempt to use an AJAX call to send the email. If it doesn't work, the Download process will catch it anyway.
             $jsScript = "\$.ajax({url:\"" . CController::createUrl('site/sendemail', array("id" => $objEmail->id)) . "\"});";
             Yii::app()->clientScript->registerScript('sendemail', $jsScript, CClientScript::POS_READY);
         } else {
             Yii::app()->user->setFlash('error', Yii::t('cart', 'Please check your form for errors.'));
             if (YII_DEBUG) {
                 Yii::app()->user->setFlash('error', print_r($ContactForm->getErrors(), true));
             }
         }
     }
     if (!Yii::app()->user->isGuest) {
         $objCustomer = Customer::GetCurrent();
         $ContactForm->fromName = $objCustomer->mainname;
         $ContactForm->fromEmail = $objCustomer->email;
     }
     $this->canonicalUrl = $model->canonicalUrl;
     $this->render('contact', array('ContactForm' => $ContactForm, 'model' => $model));
 }
Example #2
0
 public function plaintext()
 {
     $h2t = new HtmlToText($this->getRequest()->get('html'), array('enableInlineLinks' => true, 'enableLinkList' => false));
     return new JSONResponse(array('plaintext' => $h2t->get_text()), 'ok');
 }
Example #3
0
    public function testSniptfromTerraPorta()
    {
        $html = '<div class="ctnHeadline">
                    <!--// S1 para tablet -->
                    

                    
                        <div class="channel channelHeader">
                            <a class="border-news hover-news" href="http://noticias.terra.com.br/brasil/">Brasil</a>
                        </div>
                    
                    
                    <div itemprop="headline" class="title headline">
                        <h1>Haddad anuncia projeto para punir abuso de água em São Paulo</h1>
                    </div>
                    
                    
                        <div itemprop="description" class="subtitle subtitle--M">
                            <h2>Prefeito paulistano disse também que se surpreendeu com o anúncio de rodízio, feito pela Sabesp, nesta terça-feira</h2>
                        </div>
                    

                    
                    <!--// Updated at: 01/10/2014 //-->
















                                <!--// BBC TESTING TO INCLUDE AUTOR //-->
                                
                                
                                    
                                
                                
                                

                                
                                    
                                    
                                        <!--// NAO É BBC  - INI //-->
                                        <!--// Autor inicio //-->
                                        
                                    
                                


                    <div class="datetime subtitle--XS">
                        
                            
                                
                                
                                      <!--// sem foto nao mobile //-->
                                      <div data-timestamp="1422466380000" datetime="2015-01-28T17:33:00+0000" itemprop="datePublished" class="date">
                                         <div class="calendar calendar_gray_dark16"></div>
                                         <span class="day-month">28 Jan</span><span class="year"> 2015</span>
                                         <div class="icon clock_gray16"></div>
                                         <span class="time">15h33</span>
                                      </div>
                                      <div class="rescence">
                                         <span>
                                            
                                         </span>
                                      </div>
                                
                            
                        
                    </div>

                    <!-- CONTENT SHARE-->
                    
                    
                    
                    <div class="contentShare">
                        <ul class="socialWrapper">
                            <li td.idz="content_contentshare_facebook" class="facebook32 iconFacebook iconSocial"></li>
                            <li td.idz="content_contentshare_twitter" class="twitter32 iconTwitter iconSocial"></li>
                            <li td.idz="content_contentshare_gplus" class="g_plus32 iconGplus iconSocial"></li>
                            <li td.idz="content_contentshare_pinterest" class="pinterest32 iconPinterest iconSocial"></li>
                            <li class="separator iconSocial"><img src="http://s1.trrsf.com/fe/portal/content/_img/separador.png"></li>
                            <li td.idz="content_comments_commenticon" class="comment32 iconComment iconSocial"><a href="#disqus_thread">6</a></li>
                            <li class="commentLabel iconSocial"><span>comentários</span></li>
                        </ul>
                    </div>
                    
                    
                    <!--// CONTENT SHARE-->

                </div>';
        $result = HtmlToText::get($html);
        $this->AssertEquals(" Brasil [http://noticias.terra.com.br/brasil/] \n\nHADDAD ANUNCIA PROJETO PARA PUNIR ABUSO DE ÁGUA EM SÃO PAULO\n\nPREFEITO PAULISTANO DISSE TAMBÉM QUE SE SURPREENDEU COM O ANÚNCIO DE\nRODÍZIO, FEITO PELA SABESP, NESTA TERÇA-FEIRA\n\n 28 Jan 2015 \n 15h33 \n\n \t* \n \t* \n \t* \n \t* \n \t* \n \t* 6\n \t* comentários\n\n ", $result);
    }
 public function actionEmail()
 {
     if (Yii::app()->user->isGuest) {
         _xls_404();
     }
     $model = new ShareForm();
     if (isset($_POST['ShareForm'])) {
         $model->attributes = $_POST['ShareForm'];
         if ($model->validate()) {
             $strCode = $model->code;
             //Make sure code we've been passed is valid
             $objWishlist = Wishlist::model()->findByAttributes(array('gift_code' => $strCode));
             if (!$objWishlist->Visible) {
                 _xls_404();
             }
             if (!Yii::app()->user->isGuest) {
                 $objCustomer = Customer::model()->findByPk(Yii::app()->user->Id);
                 $model->fromEmail = $objCustomer->email;
                 $model->fromName = $objCustomer->fullname;
             }
             $strHtmlBody = $this->renderPartial('/mail/_cart', array('model' => $model), true);
             $strSubject = _xls_format_email_subject('EMAIL_SUBJECT_WISHLIST', $objWishlist->customer->fullname, null);
             $objEmail = new EmailQueue();
             $objEmail->customer_id = $objWishlist->customer_id;
             $objEmail->htmlbody = $strHtmlBody;
             $objEmail->subject = $strSubject;
             $objEmail->to = $model->toEmail;
             $objHtml = new HtmlToText();
             //If we get back false, it means conversion failed which 99.9% of the time means improper HTML.
             $strPlain = $objHtml->convert_html_to_text($strHtmlBody);
             if ($strPlain !== false) {
                 $objEmail->plainbody = $strPlain;
             }
             $objEmail->save();
             $response_array = array('status' => "success", 'message' => Yii::t('wishlist', 'Your wish list has been sent'), 'url' => CController::createUrl('site/sendemail', array("id" => $objEmail->id)), 'reload' => true);
         } else {
             $response_array['status'] = 'error';
             $response_array['errormsg'] = _xls_convert_errors($model->getErrors());
         }
         echo json_encode($response_array);
     }
 }
Example #5
0
if ($response) {
    if (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_VIEW) {
        $campaign = $response->Data[0];
    }
} else {
    // case, id is not a newsletter's id but a campaign's id
    $response = $api->campaign(array('method' => 'VIEW', 'ID' => $campaignId));
    if (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_VIEW) {
        $campaign = $api->newsletter(array('method' => 'VIEW', 'ID' => $response->Data[0]->NewsLetterID))->Data[0];
    }
}
if ($pageId && $valid) {
    $contentErrors = CMS_module_mailjet::checkNewsletterContent($pageId);
    $email = CMS_module_mailjet::getNewsletterContent($pageId);
    $htmlVersion = $email['content'];
    $textVersion = HtmlToText::convert_html_to_text($htmlVersion);
}
if (!$valid || count($contentErrors) > 0) {
    $disableActions = true;
}
$validateContentSubmitted = io::post('validate-content');
if ($validateContentSubmitted) {
    $params = array('method' => 'PUT', 'ID' => $campaignId, 'Html-part' => $htmlVersion, 'Text-part' => $textVersion);
    $response = $api->newsletterDetailContent($params);
    if (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_VIEW) {
        $contentOk = true;
    } elseif (isset($api->_response_code) && $api->_response_code === MailjetAPI::MAILJET_STATUS_CODE_OK_ERROR) {
        $errors[] = 'Erreur pendant l\'envoi du code source de l\'email à Mailjet.';
    } else {
        $errors[] = 'Erreur interne pendant l\'envoi du code source de l\'email à Mailjet.';
    }