예제 #1
0
 /**
  * Returns the JQuery snippet which should be rendered in every the page the campaign popup should appear.
  *
  * @param TrackableCampaignInterface $campaign The campaign to be presented
  * @param int                        $timeout  How many seconds after page load should the popup appear
  *
  * @return string
  */
 public function getJsSnippet(TrackableCampaignInterface $campaign, $timeout)
 {
     $impressions = $this->impressionsOperator->loadOrCreateFor($campaign);
     if ($this->impressionsOperator->areImpressionsEnabled() && $impressions->canBeIncreasedToday() || $this->isDebugModeEnabled) {
         return $this->jsGenerator->getScript($campaign, $timeout);
     } else {
         return '';
     }
 }
예제 #2
0
 /**
  *
  */
 public function subscribeEmail()
 {
     $email = $this->dataResolver->getEmail();
     $campaign = $this->campaignLoader->getTracked();
     $listId = $campaign->getListId();
     if ($this->newsletterSubscriber->subscribe($email, $listId)) {
         echo sprintf('Email "%s" subscribed successfully through campaign %s', $email, $campaign->getTrackingId());
         $this->impressionsOperator->disableFutureImpressions();
     } else {
         header("HTTP/1.0 400 " . $this->newsletterSubscriber->getErrorMessage());
     }
 }
예제 #3
0
 /**
  * @param TrackableCampaignInterface $campaign
  *
  * @return bool|string
  */
 public function render(TrackableCampaignInterface $campaign)
 {
     $impressions = $this->impressionsOperator->loadOrCreateFor($campaign);
     $template = '';
     if ($this->impressionsOperator->areImpressionsEnabled() && $impressions->canBeIncreasedToday()) {
         $template = $this->newsletterFormTransformer->transform($campaign, $impressions, $campaign->getContent());
     }
     if ($this->transformer) {
         $content = $this->transformer->transform($campaign, $impressions, $template);
     } else {
         $content = $template;
     }
     $this->impressionsOperator->increase($impressions);
     return $content;
 }
예제 #4
0
 /**
  * @param TrackableCampaignInterface $campaign
  * @param Impressions                $impressions
  *
  * @return string
  */
 private function getVisibilityText(TrackableCampaignInterface $campaign, Impressions $impressions)
 {
     if ($this->impressionsOperator->areImpressionsEnabled()) {
         if ($impressions->canBeIncreasedToday()) {
             $text = 'Popup is showed in normal mode. This is impression ' . ($impressions->getForToday() + 1) . ' out of ' . $campaign->getMaxImpressionPerDay() . ' for today';
         } else {
             $text = 'Popup is not showed in normal mode. The ' . $campaign->getMaxImpressionPerDay() . ' impressions for today  were exhausted.';
         }
     } else {
         $text = 'Popup is not showed in normal mode. All impressions were disabled.';
     }
     ob_start();
     require_once __DIR__ . '/../templates/debug.php';
     $content = ob_get_clean();
     return $content;
 }