当前位置: 首页>>代码示例>>PHP>>正文


PHP Newsletter::getCampaign方法代码示例

本文整理汇总了PHP中Newsletter::getCampaign方法的典型用法代码示例。如果您正苦于以下问题:PHP Newsletter::getCampaign方法的具体用法?PHP Newsletter::getCampaign怎么用?PHP Newsletter::getCampaign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Newsletter的用法示例。


在下文中一共展示了Newsletter::getCampaign方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveData

 protected function saveData()
 {
     $relocate = true;
     $message = null;
     $email = $this->ui->getWidget('email')->value;
     $campaign_type = $this->newsletter->instance instanceof SiteInstance ? $this->newsletter->instance->shortname : null;
     $campaign = $this->newsletter->getCampaign($this->app, $campaign_type);
     try {
         // re-save campaign, this makes life easier when testing template
         // changes
         $this->list->saveCampaign($campaign);
         // save/update campaign resources.
         DeliveranceCampaign::uploadResources($this->app, $campaign);
         $this->list->sendCampaignTest($campaign, array($email));
         $message = new SwatMessage(sprintf(Deliverance::_('A preview of “%s” has been sent to %s.'), $this->newsletter->subject, $email));
     } catch (DeliveranceAPIConnectionException $e) {
         $relocate = false;
         // log api connection exceptions in the admin to keep a track of how
         // frequent they are.
         $e->processAndContinue();
         $message = new SwatMessage(Deliverance::_('There was an issue connecting to the email ' . 'service provider.'), 'error');
         $message->content_type = 'text/xml';
         $message->secondary_content = sprintf('<strong>%s</strong><br />%s', sprintf(Deliverance::_('The preview of “%s” has not been sent.'), $this->newsletter->subject), Deliverance::_('Connection issues are typically short-lived ' . 'and attempting to re-send the preview again after a ' . 'delay will usually be successful.'));
     } catch (Exception $e) {
         $relocate = false;
         $e = new DeliveranceException($e);
         $e->processAndContinue();
         $message = new SwatMessage(Deliverance::_('An error has occurred. The newsletter preview ' . 'has not been sent.'), 'system-error');
     }
     if ($message !== null) {
         $this->app->messages->add($message);
     }
     return $relocate;
 }
开发者ID:GervaisdeM,项目名称:deliverance,代码行数:34,代码来源:Preview.php

示例2: saveDBData

 protected function saveDBData()
 {
     $schedule = true;
     $relocate = true;
     $message = null;
     // Note: DeliveranceMailChimpList expects campaign send dates to be in
     // local time. Send date must be set on the newsletter so that its
     // internal campaign can get the correct send_date.
     if ($this->ui->getWidget('send_date')->value instanceof SwatDate) {
         $message_text = Deliverance::ngettext('“%1$s” will be sent to one subscriber on %3$s at %4$s %5$s.', '“%1$s” will be sent to %2$s subscribers on %3$s at %4$s %5$s.', $this->send_count);
         // Preserve all the date fields
         $send_date = $this->ui->getWidget('send_date')->value;
         $send_date->setTZ($this->app->default_time_zone);
     } else {
         $schedule = false;
         $message_text = Deliverance::ngettext('“%1$s” was sent to one subscriber.', '“%1$s” was sent to %2$s subscribers.', $this->send_count);
         // Convert all the date fields to the timezone
         $send_date = new SwatDate();
         $send_date->setTimezone($this->app->default_time_zone);
     }
     // build the success message before date conversion to prevent needing
     // to convert to UTC for saving and then back to local time for display.
     $locale = SwatI18NLocale::get();
     $message = new SwatMessage(sprintf($message_text, $this->newsletter->subject, $locale->formatNumber($this->send_count), $send_date->formatLikeIntl(SwatDate::DF_DATE), $send_date->formatLikeIntl(SwatDate::DF_TIME), $send_date->formatTZ(SwatDate::TZ_CURRENT_SHORT)));
     $message->secondary_content = Deliverance::_('Subscriber counts are ' . 'estimates. Full statistics will be available once the newsletter ' . 'has been sent.');
     $campaign_type = $this->newsletter->instance instanceof SiteInstance ? $this->newsletter->instance->shortname : null;
     // grab campaign with old send date to clear out the resources.
     $campaign = $this->newsletter->getCampaign($this->app, $campaign_type);
     // If not a draft, remove the resources first in case they came from an
     // old directory. Don't delete draft newsletter resources as they are
     // shared across all drafts.
     if ($this->newsletter->isScheduled()) {
         DeliveranceCampaign::removeResources($this->app, $campaign);
     }
     // Finally set the date with the local timezone.
     // As DeliveranceMailChimpList expects.
     $this->newsletter->send_date = $send_date;
     // re-grab the campaign with the new send_date;
     $campaign = $this->newsletter->getCampaign($this->app, $campaign_type);
     try {
         // resave campaign so that resource urls are rewritten.
         $this->list->saveCampaign($campaign, false);
         // save/update campaign resources.
         DeliveranceCampaign::uploadResources($this->app, $campaign);
         if ($schedule) {
             $this->list->scheduleCampaign($campaign);
         } else {
             $this->list->sendCampaign($campaign);
         }
         // Before we save the newsletter we need to convert it to UTC.
         $this->newsletter->send_date->toUTC();
         $this->newsletter->save();
     } catch (DeliveranceAPIConnectionException $e) {
         // send date needs to be reset to null so the page titles stay
         // correct.
         $this->newsletter->send_date = null;
         $relocate = false;
         // log api connection exceptions in the admin to keep a track of how
         // frequent they are.
         $e->processAndContinue();
         $message = new SwatMessage(Deliverance::_('There was an issue connecting to the email ' . 'service provider.'), 'error');
         $message->content_type = 'text/xml';
         if ($schedule) {
             $message->secondary_content = sprintf('<strong>%s</strong><br />%s', sprintf(Deliverance::_('“%s” has not been scheduled.'), $this->newsletter->subject), Deliverance::_('Connection issues are typically ' . 'short-lived  and attempting to schedule the ' . 'newsletter again after a delay will usually be ' . 'successful.'));
         } else {
             $message->secondary_content = sprintf('<strong>%s</strong><br />%s', sprintf(Deliverance::_('“%s” has not been sent.'), $this->newsletter->subject), Deliverance::_('Connection issues are typically ' . 'short-lived and attempting to send the newsletter ' . 'again after a delay will usually be successful.'));
         }
     } catch (Exception $e) {
         // send date needs to be reset to null so the page titles stay
         // correct.
         $this->newsletter->send_date = null;
         $relocate = false;
         $e = new DeliveranceException($e);
         $e->processAndContinue();
         if ($schedule) {
             $message_text = Deliverance::_('An error has occurred. The ' . 'newsletter has not been scheduled.');
         } else {
             $message_text = Deliverance::_('An error has occurred. The ' . 'newsletter has not been sent.');
         }
         $message = new SwatMessage($message_text, 'system-error');
     }
     if ($message !== null) {
         $this->app->messages->add($message);
     }
     return $relocate;
 }
开发者ID:GervaisdeM,项目名称:deliverance,代码行数:86,代码来源:Schedule.php


注:本文中的Newsletter::getCampaign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。