PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.10
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.10
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / FB / Box.php

Box.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.10, at Inc/Core/FB/Box.php

953 lines 22.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.10 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\FB;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 use FireBox\Core\Helpers\BoxHelper;
20 use FPFramework\Libs\Registry;
21 use FPFramework\Helpers\Fields\DimensionsHelper;
22 use FPFramework\Helpers\CSS;
23
24 class Box
25 {
26 /**
27 * Send useful JS snippet once in first box
28 *
29 * @var boolean
30 */
31 static $loadedLocalizedScript = false;
32
33 /**
34 * The box.
35 *
36 * @param object
37 */
38 private $box = null;
39
40 /**
41 * Factory
42 *
43 * @var Factory
44 */
45 private $factory = null;
46
47 /**
48 * FireBox settings.
49 *
50 * @var object
51 */
52 private $params = null;
53
54 /**
55 * Popup CSS.
56 *
57 * @var CSS
58 */
59 public $css = null;
60
61 /**
62 * Display condition groups that must be resolved in the browser before the
63 * campaign may open (session-dependent rules like Time on Site/Pageviews).
64 * Populated by pass(), shipped to the frontend runtime via prepare().
65 *
66 * @var array
67 */
68 private $clientRuleGroups = [];
69
70 /**
71 * Constructor.
72 *
73 * @param object $box
74 * @param object $factory
75 *
76 * @return void
77 */
78 public function __construct($box = null, $factory = null)
79 {
80 if ($box)
81 {
82 $this->box = $this->prepareConstructorBox($box);
83 }
84
85 if (!$factory)
86 {
87 $factory = new \FPFramework\Base\Factory();
88 }
89 $this->factory = $factory;
90
91 $this->params = new Registry(BoxHelper::getParams());
92 }
93
94 /**
95 * Allow to set either a box ID or box object
96 * and we then set the box object.
97 *
98 * @param mixed $box
99 *
100 * @return object
101 */
102 private function prepareConstructorBox($box)
103 {
104 if (!is_object($box))
105 {
106 $box = $this->get($box);
107 }
108
109 return $box;
110 }
111
112 /**
113 * Get a box.
114 *
115 * @param int $id
116 * @param string $status
117 *
118 * @return object|null
119 */
120 public function get($id = null, $status = null)
121 {
122 if (!$id)
123 {
124 return null;
125 }
126
127 $payload = [
128 'where' => [
129 'ID' => ' = ' . intval($id),
130 'post_type' => " = 'firebox'"
131 ]
132 ];
133
134 // apply status if given
135 if ($status)
136 {
137 $payload['where']['post_status'] = ' = \'' . sanitize_key($status) . '\'';
138 }
139
140 if (!$box = firebox()->tables->box->getResults($payload))
141 {
142 return null;
143 }
144
145 if (!isset($box[0]))
146 {
147 return null;
148 }
149
150 $this->box = $box[0];
151
152 // get meta options for box
153 $meta = \FireBox\Core\Helpers\BoxHelper::getMeta($id);
154 $this->box->params = new Registry($meta);
155
156 return $this->box;
157 }
158
159 /**
160 * Renders the box.
161 *
162 * @return void
163 */
164 public function render()
165 {
166 // Check Publishing Assignments
167 if (!$this->pass())
168 {
169 return false;
170 }
171
172 $fbox = $this->box;
173
174 /**
175 * Runs before rendering the box.
176 */
177 $this->box = apply_filters('firebox/box/before_render', $this->box);
178
179 $this->prepare();
180
181 $css = $this->getCustomCSS();
182
183 add_action('wp_enqueue_scripts', function() use ($fbox, $css) {
184 // Loads all media files.
185 $this->loadBoxMedia($fbox);
186
187 // Load CSS
188 if ($css)
189 {
190 wp_add_inline_style('firebox', $css);
191 }
192
193
194 });
195
196 // Allow to manipulate the box before rendering
197 $this->box = apply_filters('firebox/box/edit', $this->box);
198
199 // payload
200 $payload = [
201 'box' => $this->box,
202 'params' => $this->params,
203 ];
204
205 // print campaign HTML
206 add_action('wp_footer', function() use ($payload) {
207 echo $this->getFinalCampaignHTML($payload); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
208 });
209
210 return true;
211 }
212
213 public function renderEmbed()
214 {
215 // Check Publishing Assignments
216 if (!$this->pass())
217 {
218 return false;
219 }
220
221 /**
222 * Runs before rendering the box.
223 */
224 $this->box = apply_filters('firebox/box/before_render', $this->box);
225
226 $this->prepare();
227
228 // Loads all media files.
229 $this->loadBoxMedia($this->box);
230
231 $css = $this->getCustomCSS();
232
233 wp_register_style('fireboxStyle', false);
234 wp_enqueue_style('fireboxStyle');
235
236 // Load CSS
237 if ($css)
238 {
239 wp_add_inline_style('fireboxStyle', $css);
240 }
241
242
243
244 // Allow to manipulate the box before rendering
245 $this->box = apply_filters('firebox/box/edit', $this->box);
246
247 // payload
248 $payload = [
249 'box' => $this->box,
250 'params' => $this->params,
251 ];
252
253 // return box template
254 return $this->getFinalCampaignHTML($payload);
255 }
256
257 public function getFinalCampaignHTML($payload)
258 {
259 $html = firebox()->renderer->public->render('box', $payload, true);
260
261 /**
262 * Runs after rendering the box.
263 */
264 return apply_filters('firebox/box/after_render', $html, $payload['box']);
265 }
266
267 /**
268 * Gets the Custom CSS of the popup.
269 *
270 * @return string
271 */
272 public function getCustomCSS()
273 {
274 if (!is_object($this->box) || !isset($this->box->params))
275 {
276 return '';
277 }
278
279 return $this->box->params->get('customcss', '');
280 }
281
282 /**
283 * Recursively casts an object/array tree to a plain array, without the
284 * json_decode(wp_json_encode()) round-trip.
285 *
286 * @param mixed $data
287 *
288 * @return array
289 */
290 private static function recursiveToArray($data)
291 {
292 if (is_object($data))
293 {
294 $data = get_object_vars($data);
295 }
296
297 if (!is_array($data))
298 {
299 return [];
300 }
301
302 foreach ($data as $key => $value)
303 {
304 if (is_object($value) || is_array($value))
305 {
306 $data[$key] = self::recursiveToArray($value);
307 }
308 }
309
310 return $data;
311 }
312
313 /**
314 * Send a helpful object to JavaScript files
315 *
316 * @return void
317 */
318 public static function setJSObject()
319 {
320 if (self::$loadedLocalizedScript)
321 {
322 return;
323 }
324 self::$loadedLocalizedScript = true;
325
326 /**
327 * The referrer is deliberately not included here. On a full-page-cached site this
328 * HTML is written once and served to everyone, so a baked-in referrer would report
329 * whoever warmed the cache. The runtime reads `document.referrer` instead.
330 */
331 $data = [
332 'ajax_url' => admin_url('admin-ajax.php'),
333 'nonce' => wp_create_nonce('fbox_js_nonce'),
334 'site_url' => site_url('/'),
335
336 // Shown when a form submission never gets a usable response back (network error,
337 // non-JSON body, PHP fatal). The form messages themselves come from the block.
338 'form_submit_failed' => firebox()->_('FB_FORM_SUBMIT_FAILED'),
339
340 /**
341 * The scripts write cookies PHP has to read back, so they need the
342 * same name, path and domain it uses: the prefix keeps the sites of
343 * a subdirectory network apart, the path is the site's own corner of
344 * the domain, and the domain is whatever COOKIE_DOMAIN says.
345 */
346 'cookie_prefix' => \FireBox\Core\Helpers\BoxHelper::cookiePrefix(),
347 'cookie_path' => \FireBox\Core\Helpers\BoxHelper::cookiePath(),
348 'cookie_domain' => \FireBox\Core\Helpers\BoxHelper::cookieDomain()
349 ];
350
351 wp_add_inline_script('firebox-main', 'const fbox_js_object = ' . wp_json_encode($data), 'before');
352 }
353
354 /**
355 * Load Box Media
356 *
357 * @return void
358 */
359 public function loadBoxMedia($box)
360 {
361 $box = new Registry($box);
362
363 $this->loadAnimationsMedia($box);
364
365 /**
366 * FireBox JS
367 */
368 wp_enqueue_script('firebox-main');
369
370
371
372 // Add Custom Javascript
373 $custom_code = $box->get('params.data.customcode', '');
374 if (is_string($custom_code) && !empty($custom_code))
375 {
376 $custom_code = html_entity_decode(stripslashes($custom_code));
377 BoxHelper::addInlineScript($custom_code);
378 }
379
380 // run above the main JS script to run only once
381 self::setJSObject();
382
383 /**
384 * FireBox CSS
385 */
386 wp_enqueue_style(
387 'firebox',
388 FBOX_MEDIA_PUBLIC_URL . 'css/firebox.css',
389 [],
390 FBOX_VERSION
391 );
392
393 /**
394 * Page Slide mode JS
395 */
396 if ($box->get('params.data.mode') == 'pageslide')
397 {
398 // This script moves the campaign instances into the page-slide wrapper after
399 // firebox-main creates them. Deferring is safe: deferred scripts execute in
400 // document order and firebox-main is declared as a dependency, so it always
401 // runs first. All inline scripts on firebox-main are attached in the "before"
402 // position, which keeps its defer strategy intact.
403 wp_enqueue_script(
404 'firebox-pageslide-mode',
405 FBOX_MEDIA_PUBLIC_URL . 'js/pageslide_mode.js',
406 ['firebox-main'],
407 FBOX_VERSION,
408 ['in_footer' => true, 'strategy' => 'defer']
409 );
410 }
411
412
413 }
414
415 /**
416 * Enqueues only the Animate.css animations the campaign actually uses.
417 *
418 * The full library is 71 KB of render-blocking CSS for what is almost always a
419 * single fade, so it is split at build time (gulp build-animations) into one file
420 * per animation plus a shared base. Campaigns rendering on the same page union
421 * their animations naturally, since each gets its own handle.
422 *
423 * @param Registry $box
424 *
425 * @return void
426 */
427 private function loadAnimationsMedia($box)
428 {
429 /**
430 * Escape hatch for campaigns whose custom code applies arbitrary
431 * firebox__animate__* classes that we cannot see server-side.
432 */
433 if (apply_filters('firebox/box/load_full_animations', false))
434 {
435 wp_enqueue_style(
436 'firebox-animations',
437 FBOX_MEDIA_PUBLIC_URL . 'css/vendor/animate.min.css',
438 [],
439 FBOX_VERSION
440 );
441
442 return;
443 }
444
445 $animations = array_filter([
446 $box->get('params.data.animationin', ''),
447 $box->get('params.data.animationout', '')
448 ], 'is_string');
449
450 $animations = array_unique(array_filter(array_map('trim', $animations)));
451
452 if (!$animations)
453 {
454 return;
455 }
456
457 $dir = FBOX_PLUGIN_DIR . 'media/public/css/vendor/animations/';
458 $url = FBOX_MEDIA_PUBLIC_URL . 'css/vendor/animations/';
459
460 $enqueued = false;
461
462 foreach ($animations as $animation)
463 {
464 // Animation names are a fixed camelCase slug set; anything else is either a
465 // stale value or a name we no longer ship, and must not reach the filesystem.
466 if (!preg_match('#^[A-Za-z0-9]+$#', $animation) || !file_exists($dir . $animation . '.css'))
467 {
468 continue;
469 }
470
471 if (!$enqueued)
472 {
473 wp_enqueue_style('firebox-animations-base', $url . 'base.css', [], FBOX_VERSION);
474 $enqueued = true;
475 }
476
477 wp_enqueue_style(
478 'firebox-animation-' . $animation,
479 $url . $animation . '.css',
480 ['firebox-animations-base'],
481 FBOX_VERSION
482 );
483 }
484 }
485
486 /**
487 * Prepares the box before rendering
488 *
489 * @return void
490 */
491 public function prepare()
492 {
493 remove_filter('the_content', 'wptexturize');
494
495 $cParam = BoxHelper::getParams();
496 $cParam = new Registry($cParam);
497
498 $this->box->post_content = apply_filters('the_content', $this->box->post_content);
499
500 $mode = $this->box->params->get('mode');
501
502 /* Classes */
503 $css_class = [
504 $this->box->ID,
505 $mode
506 ];
507
508 if (in_array($mode, ['popup', 'stickybar', 'sidebar', 'floating', 'slide-in']))
509 {
510 $position = $this->box->params->get('position', '');
511 $position = !is_string($position) ? '' : $position;
512 if ($position)
513 {
514 $css_class[] = $position;
515 }
516 }
517 else if ($mode === 'fullscreen')
518 {
519 if ($center_content = $this->box->params->get('center_content', false)) {
520 $css_class[] = 'center-content';
521 }
522 }
523
524 self::prefixCSSClasses($css_class);
525
526 // Class suffix
527 $classSuffix = $this->box->params->get('classsuffix', '');
528 $classSuffix = is_string($classSuffix) ? $classSuffix : '';
529
530 $css_class[] = $classSuffix;
531
532 $this->box->classes = $css_class;
533
534 // Dialog CSS Classes
535 $dialog_css_classes = [
536 // Add Box shadow
537 $this->box->params->get('boxshadow') ? 'shdelevation' : null
538 ];
539
540 // Align Content
541 $aligncontent = is_string($this->box->params->get('aligncontent')) ? explode(' ', $this->box->params->get('aligncontent')) : [];
542 $dialog_css_classes = array_merge($dialog_css_classes, $aligncontent);
543
544 self::prefixCSSClasses($dialog_css_classes);
545 $this->box->dialog_classes = $dialog_css_classes;
546
547 $trigger_point_methods = [
548 'pageload' => 'onPageLoad',
549 'onclick' => 'onClick',
550 'elementHover' => 'onHover',
551 'ondemand' => 'onDemand',
552
553 ];
554
555 /* Other Settings */
556 $this->box->params->set('animation_duration', $this->box->params->get('animation_duration', 0.2));
557
558 $scroll_amount = $this->box->params->get('scroll_amount', '80%');
559
560 // Parse scroll_amount to extract unit and value
561 $scroll_amount_data = $this->parseScrollAmount($scroll_amount);
562
563 $delay = in_array($this->box->params->get('triggermethod'), ['floatingbutton', 'onexternallink']) ? 0 : (int) $this->box->params->get('triggerdelay') * 1000;
564
565 $trigger_method = (is_string($this->box->params->get('triggermethod'))) && array_key_exists($this->box->params->get('triggermethod'), $trigger_point_methods) ? $trigger_point_methods[$this->box->params->get('triggermethod')] : $this->box->params->get('triggermethod');
566
567 $trigger_element = is_scalar($this->box->params->get('triggerelement', '')) ? $this->box->params->get('triggerelement', '') : '';
568
569 // Use Namespaced classes for each trigger point and let them manipulate the settings dynamicaly.
570 $this->box->settings = [
571 'name' => $this->box->post_title,
572 'trigger' => $trigger_method,
573 'trigger_selector' => $trigger_method === 'onExternalLink' ? '' : rtrim($trigger_element, ','),
574 'delay' => $delay,
575
576 'close_on_esc' => (bool) $this->box->params->get('close_on_esc', false),
577 'animation_open' => $this->box->params->get('animationin'),
578 'animation_close' => $this->box->params->get('animationout'),
579 'animation_duration' => (float) $this->box->params->get('animation_duration') * 1000,
580 'prevent_default' => true,
581 'backdrop' => (bool) $this->box->params->get('overlay'),
582 'backdrop_color' => $this->box->params->get('overlay_color'),
583 'backdrop_click' => (bool) $this->box->params->get('overlayclick'),
584 'disable_page_scroll' => (bool) $this->box->params->get('preventpagescroll'),
585 'test_mode' => (bool) $this->box->params->get('testmode'),
586 'debug' => (bool) $cParam->get('debug', false),
587 'auto_focus' => (bool) $this->box->params->get('autofocus', false),
588 'mode' => $this->box->params->get('mode'),
589 // Session-dependent display conditions resolved in the browser (see pass())
590 'client_rules' => $this->clientRuleGroups
591 ];
592
593 $this->css = new Styling\CSS($this->box);
594
595 // Apply Popup CSS
596 $this->box->params->set('customcss', $this->box->params->get('customcss') . $this->css->getCSS());
597
598 $this->replaceBoxSmartTags();
599
600 add_filter('the_content', 'wptexturize');
601 }
602
603 /**
604 * Parses scroll_amount to extract unit and value
605 *
606 * @param mixed $scroll_amount
607 *
608 * @return array
609 */
610 private function parseScrollAmount($scroll_amount)
611 {
612 if (is_array($scroll_amount))
613 {
614 return [
615 'unit' => $scroll_amount['unit'] ?? '%',
616 'value' => $scroll_amount['value'] ?? 80
617 ];
618 }
619
620 if (is_string($scroll_amount) && preg_match('/^(\d+)(px|%)$/', $scroll_amount, $matches))
621 {
622 return [
623 'unit' => $matches[2],
624 'value' => $matches[1]
625 ];
626 }
627
628 return [
629 'unit' => '%',
630 'value' => 80
631 ];
632 }
633
634 /**
635 * Replaces all box smart tags
636 *
637 * @return void
638 */
639 public function replaceBoxSmartTags()
640 {
641 $tags = new \FPFramework\Base\SmartTags\SmartTags();
642
643 // register FB Smart Tags
644 $tags->register('\FireBox\Core\SmartTags', FBOX_BASE_FOLDER . '/Inc/Core/SmartTags', $this->box);
645
646 $this->box = $tags->replace($this->box);
647 }
648
649 /**
650 * Checks if a box passes assignments
651 *
652 * @return boolean
653 */
654 public function pass()
655 {
656 $this->clientRuleGroups = [];
657
658 if (!$this->box || !is_object($this->box))
659 {
660 return false;
661 }
662
663 // Check first local assignments
664 if (!$this->passLocalAssignments())
665 {
666 return false;
667 }
668
669 $displayConditionsType = $this->box->params->get('display_conditions_type', '');
670
671 // If empty, display popup sitewide
672 if (empty($displayConditionsType) || $displayConditionsType === 'all')
673 {
674 return true;
675 }
676
677 // Mirror Display Conditions of another popup.
678 if ($displayConditionsType == 'mirror' && $mirror_box_id = $this->box->params->get('mirror_box'))
679 {
680 $this->box->params->merge(self::getAssignmentsForMirroring($mirror_box_id));
681 }
682
683 // Get a recursive array of all rules
684 $rules = $this->box->params->get('rules', []);
685 $rules = is_string($rules) ? json_decode($rules, true) : self::recursiveToArray($rules);
686
687 // Normalize to an array; an empty or invalid-JSON "rules" string decodes to null.
688 $rules = is_array($rules) ? $rules : [];
689
690 // If testmode is enabled disable the User Groups condition
691 if ($this->box->params->get('testmode'))
692 {
693 foreach ($rules as $key => &$group)
694 {
695 if (!isset($group['rules']) || !is_array($group['rules']))
696 {
697 continue;
698 }
699
700 foreach ($group['rules'] as $_key => &$rule)
701 {
702 if (!isset($rule['name']) || empty($rule['name']))
703 {
704 continue;
705 }
706
707 if ($rule['name'] === 'WP\UserGroup')
708 {
709 unset($group['rules'][$_key]);
710 }
711 }
712 }
713 unset($group);
714 }
715
716 // Check framework based conditions. Session-dependent (client-side) rules are
717 // deferred: the box renders hidden and the frontend runtime resolves them.
718 $result = \FPFramework\Base\Conditions\ConditionBuilder::passWithClientRules($rules, $this->factory);
719
720 $this->clientRuleGroups = $result['client_groups'];
721
722 return $result['pass'];
723 }
724
725 /**
726 * Display condition groups deferred to the frontend runtime by pass().
727 *
728 * @return array
729 */
730 public function getClientRuleGroups()
731 {
732 return $this->clientRuleGroups;
733 }
734
735 /**
736 * Check if a box passes local conditions
737 *
738 * @return boolean
739 */
740 private function passLocalAssignments()
741 {
742 $localAssignments = new \FireBox\Core\FB\Assignments($this, $this->factory);
743 return $localAssignments->passAll();
744 }
745
746 /**
747 * Gets assignments of mirrored box
748 *
749 * @param int $box_id
750 *
751 * @return object
752 */
753 private function getAssignmentsForMirroring($box_id)
754 {
755 // Several campaigns commonly mirror the same source, and every campaign is
756 // evaluated on every page view, so resolve each source at most once per request.
757 static $cache = [];
758
759 $box_id = intval($box_id);
760
761 if (array_key_exists($box_id, $cache))
762 {
763 return $cache[$box_id];
764 }
765
766 $cache[$box_id] = null;
767
768 // The published campaigns are already loaded (and their meta primed) for this
769 // request, so read the mirrored campaign from that list instead of querying again.
770 $boxes = BoxHelper::getAllBoxes();
771 $mirrored = null;
772
773 foreach ($boxes->posts as $box)
774 {
775 if ((int) $box->ID === $box_id)
776 {
777 $mirrored = $box;
778 break;
779 }
780 }
781
782 if (!$mirrored)
783 {
784 return $cache[$box_id];
785 }
786
787 // get meta options for box
788 $params = new Registry(BoxHelper::getMeta($mirrored->ID));
789
790 $cache[$box_id] = new Registry(['rules' => $params->get('rules')]);
791
792 return $cache[$box_id];
793 }
794
795 /**
796 * Prefixes the CSS classes
797 *
798 * @param array $classes
799 * @param string $prefix
800 *
801 * @return void
802 */
803 private static function prefixCSSClasses(&$classes, $prefix = 'fb-')
804 {
805 $classes = array_filter($classes);
806
807 if (empty($classes))
808 {
809 return;
810 }
811
812 foreach ($classes as &$class)
813 {
814 $class = $prefix . $class;
815 }
816 }
817
818 /**
819 * Track box open
820 *
821 * @param integer $box_id
822 * @param string $page
823 * @param string $referrer
824 *
825 * @return void
826 */
827 public function logOpenEvent($box_id, $page = null, $referrer = null)
828 {
829 $box = $this->get($box_id);
830
831 if (!is_object($box) || !isset($box->params))
832 {
833 return;
834 }
835
836 // Do not track if statistics option is disabled
837 $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? true : $box->params->get('stats'));
838 if (!$track_open_event)
839 {
840 return;
841 }
842
843 return firebox()->log->track($box_id, 1, null, $page, $referrer);
844 }
845
846 /**
847 * Track box close
848 *
849 * @param integer $box_id
850 * @param integer $box_log_id
851 *
852 * @return void
853 */
854 public function logCloseEvent($box_id, $box_log_id)
855 {
856 $box = $this->get($box_id);
857
858 if (!is_object($box) || !isset($box->params))
859 {
860 return null;
861 }
862
863 // Do not track if statistics option is disabled
864 $track_open_event = (bool) (is_null($box->params->get('stats', null)) ? true : $box->params->get('stats'));
865 if (!$track_open_event)
866 {
867 return null;
868 }
869
870 firebox()->log->track($box_id, 2, $box_log_id);
871 }
872
873 /**
874 * Get total box impressions
875 *
876 * @param array $payload
877 *
878 * @return array
879 */
880 public function getTotalImpressions($payload)
881 {
882 // Cached: the same campaign/period is counted once per request even when
883 // several conditions ask for it.
884 return firebox()->tables->boxlog->getResults($payload, true, true);
885 }
886
887 /**
888 * Returns the cookie instance.
889 *
890 * @return mixed
891 */
892 public function getCookie()
893 {
894 if (!$this->box)
895 {
896 return;
897 }
898
899 return new Cookie($this->box);
900 }
901
902 /**
903 * Returns the box.
904 *
905 * @return object
906 */
907 public function getBox()
908 {
909 return $this->box;
910 }
911
912 /**
913 * Sets the box.
914 *
915 * @param object $box
916 *
917 * @return Box
918 */
919 public function setBox($box)
920 {
921 $this->box = $box;
922
923 return $this;
924 }
925
926 public function getParams()
927 {
928 return $this->params;
929 }
930
931 public function setParams($params)
932 {
933 $this->params = $params;
934
935 return $this;
936 }
937
938 public function getCampaignParams()
939 {
940 return isset($this->box->params) ? $this->box->params : null;
941 }
942
943 public function setCampaignParams($params)
944 {
945 if (isset($this->box->params))
946 {
947 $this->box->params = $params;
948 }
949
950 return $this;
951 }
952 }
953