/** * Note if this submission is from a focus submit. * * @param SubmissionEvent $event */ public function onFormSubmit(SubmissionEvent $event) { // Check the request for a focus field $id = $this->request->request->get('mauticform[focusId]', false, true); if (!empty($id)) { $focus = $this->model->getEntity($id); if ($focus && $focus->isPublished()) { // Make sure the form is still applicable $form = $event->getSubmission()->getForm(); if ((int) $form->getId() === (int) $focus->getForm()) { $this->model->addStat($focus, Stat::TYPE_FORM, $event->getSubmission()); } } } }
/** * @param Request $request * * @return \Symfony\Component\HttpFoundation\JsonResponse */ protected function getWebsiteSnapshotAction(Request $request) { $data = ['success' => 0]; if ($this->get('mautic.security')->isGranted('plugin:focus:items:create')) { $website = InputHelper::url($request->request->get('website')); if ($website) { // Let's try to extract colors from image $id = InputHelper::int($request->request->get('id')); if (!empty($id)) { // Tell the JS to not populate with default colors $data['ignoreDefaultColors'] = true; } $snapshotUrl = $this->get('mautic.helper.core_parameters')->getParameter('website_snapshot_url'); $snapshotKey = $this->get('mautic.helper.core_parameters')->getParameter('website_snapshot_key'); $http = $this->get('mautic.http.connector'); $response = $http->get($snapshotUrl . '?url=' . urlencode($website) . '&key=' . $snapshotKey, [], 30); if ($response->code === 200) { $package = json_decode($response->body, true); if (isset($package['images'])) { $data['image']['desktop'] = $package['images']['desktop']; $data['image']['mobile'] = $package['images']['mobile']; $palette = $package['palette']; $data['colors'] = ['primaryColor' => $palette[0], 'textColor' => FocusModel::isLightColor($palette[0]) ? '#000000' : '#ffffff', 'buttonColor' => $palette[1], 'buttonTextColor' => FocusModel::isLightColor($palette[1]) ? '#000000' : '#ffffff']; $data['success'] = 1; } } } } return $this->sendJsonResponse($data); }
/** * Add a delete entry to the audit log. * * @param Events\FormEvent $event */ public function onFormDelete(Events\FormEvent $event) { $form = $event->getForm(); $formId = $form->deletedId; $foci = $this->model->getRepository()->findByForm($formId); if (empty($foci)) { return; } // Rebuild each focus /** @var \MauticPlugin\MauticFocusBundle\Entity\Focus $focus */ foreach ($foci as $focus) { $focus->setForm(null); $focus->setCache($this->model->generateJavascript($focus)); } $this->model->saveEntities($foci); }
/** * @param PageDisplayEvent $event */ public function onPageDisplay(PageDisplayEvent $event) { $content = $event->getContent(); $regex = '/' . $this->regex . '/i'; preg_match_all($regex, $content, $matches); if (count($matches[0])) { foreach ($matches[1] as $k => $id) { $focus = $this->model->getEntity($id); if ($focus !== null && ($focus->isPublished() || $this->security->hasEntityAccess('plugin:focus:items:viewown', 'plugin:focus:items:viewother', $focus->getCreatedBy()))) { $script = '<script src="' . $this->router->generate('mautic_focus_generate', ['id' => $id], true) . '" type="text/javascript" charset="utf-8" async="async"></script>'; $content = preg_replace('#{focus=' . $id . '}#', $script, $content); } else { $content = preg_replace('#{focus=' . $id . '}#', '', $content); } } } $event->setContent($content); }
echo $scale; ?> ) rotate(<?php echo $direction; ?> <?php echo $transformSize; ?> <?php echo $transformSize; ?> )"> <desc>Created with Raphaël 2.1.2</desc> <defs> <?php $color = \MauticPlugin\MauticFocusBundle\Model\FocusModel::isLightColor($props['colors']['primary']) ? '000000' : 'ffffff'; ?> <linearGradient gradientTransform="matrix(1,0,0,1,-4,-4)" y2="0" x2="6.123233995736766e-17" y1="1" x1="0" id="1390-_0050af-_002c62"> <stop stop-color="#<?php echo $color; ?> " offset="0%"></stop> <stop stop-color="#<?php echo $color; ?> " offset="100%"></stop> </linearGradient> </defs> <path transform="matrix(1,0,0,1,4,4)" opacity="0" stroke-linejoin="round" stroke-width="3" d="M16,1.466C7.973,1.466,1.466,7.973,1.466,16C1.466,24.027,7.973,30.534,16,30.534C24.027,30.534,30.534,24.027,30.534,15.999999999999998C30.534,7.973,24.027,1.466,16,1.466ZM13.665,25.725L10.129,22.186L16.316,15.998999999999999L10.128999999999998,9.811999999999998L13.664999999999997,6.275999999999998L23.388999999999996,15.998999999999999L13.665,25.725Z"