/** * @inheritdoc * * @return Impressions */ public function findImpressionsByCampaign(TrackableCampaignInterface $campaign) { $data = $this->getData($campaign->getTrackingId()); if (empty($data)) { return null; } return new Impressions($campaign, $this->getImpressionsForToday($data), $this->getTotalImpressions($data)); }
/** * Returns the Javascript code which deals with the showing of the popup. * * We show a fancybox, which gets its content from the specified URL via AJAX, after a specified timeout. * * @param TrackableCampaignInterface $campaign * @param $timeout The timeout after which the popup should appear in seconds. * * @return string */ public function getScript(TrackableCampaignInterface $campaign, $timeout) { $js = sprintf(' (function () { var %s = "%s"; var url = "%s"; var tout = %s; $(document).ready(function () { setTimeout(function() { if (!$.fancybox.isOpen) { $.fancybox.open({ type: "ajax", ajax: { data: "%1$s=" + %1$s }, href: url, }); } }, tout); }) }());', DataResolver::CAMPAIGN_ID_KEY, $campaign->getTrackingId(), $this->url, $timeout * 1000); return sprintf("<script>%s</script>", $js); }
/** * Return the ID of the campaign. * * @return int */ public function getCampaignTrackingId() { return $this->campaign->getTrackingId(); }