Esempio n. 1
0
 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->addEventSubscriber(new CleanFormSubscriber(array('content' => 'html', 'customHtml' => 'html')));
     $builder->addEventSubscriber(new FormExitSubscriber('email.email', $options));
     $variantParent = $options['data']->getVariantParent();
     $isVariant = !empty($variantParent);
     $builder->add('name', 'text', array('label' => 'mautic.email.form.internal.name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control')));
     $emojiTransformer = new EmojiToShortTransformer();
     $builder->add($builder->create('subject', 'text', array('label' => 'mautic.email.subject', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => false))->addModelTransformer($emojiTransformer));
     $builder->add('fromName', 'text', array('label' => 'mautic.email.from_name', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'preaddon' => 'fa fa-user', 'tooltip' => 'mautic.email.from_name.tooltip'), 'required' => false));
     $builder->add('fromAddress', 'text', array('label' => 'mautic.email.from_email', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'preaddon' => 'fa fa-envelope', 'tooltip' => 'mautic.email.from_email.tooltip'), 'required' => false));
     $builder->add('replyToAddress', 'text', array('label' => 'mautic.email.reply_to_email', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'preaddon' => 'fa fa-envelope', 'tooltip' => 'mautic.email.reply_to_email.tooltip'), 'required' => false));
     $builder->add('bccAddress', 'text', array('label' => 'mautic.email.bcc', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'preaddon' => 'fa fa-envelope', 'tooltip' => 'mautic.email.bcc.tooltip'), 'required' => false));
     $builder->add('template', 'theme_list', array('feature' => 'email', 'attr' => array('class' => 'form-control', 'tooltip' => 'mautic.email.form.template.help', 'onchange' => 'Mautic.onBuilderModeSwitch(this);'), 'empty_value' => 'mautic.core.none'));
     $builder->add('isPublished', 'yesno_button_group');
     $builder->add('publishUp', 'datetime', array('widget' => 'single_text', 'label' => 'mautic.core.form.publishup', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-toggle' => 'datetime'), 'format' => 'yyyy-MM-dd HH:mm', 'required' => false));
     $builder->add('publishDown', 'datetime', array('widget' => 'single_text', 'label' => 'mautic.core.form.publishdown', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-toggle' => 'datetime'), 'format' => 'yyyy-MM-dd HH:mm', 'required' => false));
     $builder->add('plainText', 'textarea', array('label' => 'mautic.email.form.plaintext', 'label_attr' => array('class' => 'control-label'), 'attr' => array('tooltip' => 'mautic.email.form.plaintext.help', 'class' => 'form-control', 'rows' => '15', 'data-token-callback' => 'email:getBuilderTokens', 'data-token-activator' => '{', 'data-token-visual' => 'false'), 'required' => false));
     $url = $this->request->getSchemeAndHttpHost() . $this->request->getBasePath();
     $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($url) {
         $parser = new PlainTextHelper(array('base_url' => $url));
         $data = $event->getData();
         // Then strip out HTML
         $data['plainText'] = $parser->setHtml($data['plainText'])->getText();
         $event->setData($data);
     });
     $builder->add($builder->create('customHtml', 'textarea', array('label' => 'mautic.email.form.body', 'label_attr' => array('class' => 'control-label'), 'required' => false, 'attr' => array('class' => 'form-control editor-fullpage editor-builder-tokens', 'data-token-callback' => 'email:getBuilderTokens', 'data-token-activator' => '{')))->addModelTransformer($emojiTransformer));
     $transformer = new IdToEntityModelTransformer($this->em, 'MauticFormBundle:Form', 'id');
     $builder->add($builder->create('unsubscribeForm', 'form_list', array('label' => 'mautic.email.form.unsubscribeform', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'tootlip' => 'mautic.email.form.unsubscribeform.tooltip', 'data-placeholder' => $this->translator->trans('mautic.core.form.chooseone')), 'required' => false, 'multiple' => false, 'empty_value' => ''))->addModelTransformer($transformer));
     if ($isVariant) {
         $builder->add('variantSettings', 'emailvariant', array('label' => false));
     } else {
         //add category
         $builder->add('category', 'category', array('bundle' => 'email'));
         //add lead lists
         $transformer = new IdToEntityModelTransformer($this->em, 'MauticLeadBundle:LeadList', 'id', true);
         $builder->add($builder->create('lists', 'leadlist_choices', array('label' => 'mautic.email.form.list', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'multiple' => true, 'expanded' => false, 'required' => true))->addModelTransformer($transformer));
         $builder->add('language', 'locale', array('label' => 'mautic.core.language', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control'), 'required' => false));
     }
     //add lead lists
     $transformer = new IdToEntityModelTransformer($this->em, 'MauticAssetBundle:Asset', 'id', true);
     $builder->add($builder->create('assetAttachments', 'asset_list', array('label' => 'mautic.email.attachments', 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'onchange' => 'Mautic.getTotalAttachmentSize();'), 'multiple' => true, 'expanded' => false))->addModelTransformer($transformer));
     $builder->add('sessionId', 'hidden');
     $builder->add('emailType', 'hidden');
     $customButtons = array(array('name' => 'builder', 'label' => 'mautic.core.builder', 'attr' => array('class' => 'btn btn-default btn-dnd btn-nospin text-primary btn-builder', 'icon' => 'fa fa-cube', 'onclick' => "Mautic.launchBuilder('emailform', 'email');")));
     if (!empty($options['update_select'])) {
         $builder->add('buttons', 'form_buttons', array('apply_text' => false, 'pre_extra_buttons' => $customButtons));
         $builder->add('updateSelect', 'hidden', array('data' => $options['update_select'], 'mapped' => false));
     } else {
         $builder->add('buttons', 'form_buttons', array('pre_extra_buttons' => $customButtons));
     }
     if (!empty($options["action"])) {
         $builder->setAction($options["action"]);
     }
 }
Esempio n. 2
0
 /**
  * Parses html into basic plaintext
  *
  * @param string $content
  */
 public function parsePlainText($content = null)
 {
     if ($content == null) {
         $content = $this->message->getBody();
     }
     $request = $this->factory->getRequest();
     $parser = new PlainTextHelper(array('base_url' => $request->getSchemeAndHttpHost() . $request->getBasePath()));
     $this->plainText = $parser->setHtml($content)->getText();
 }
Esempio n. 3
0
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function generatePlaintTextAction(Request $request)
 {
     $dataArray = array();
     $mode = $request->request->get('mode');
     $custom = $request->request->get('custom');
     $id = $request->request->get('id');
     $parser = new PlainTextHelper(array('base_url' => $request->getSchemeAndHttpHost() . $request->getBasePath()));
     if ($mode == 'custom') {
         // Convert placeholders into raw tokens
         BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($custom);
         $dataArray['text'] = $parser->setHtml($custom)->getText();
     } else {
         $session = $this->factory->getSession();
         $contentName = 'mautic.emailbuilder.' . $id . '.content';
         $content = $session->get($contentName, array());
         if (strpos($id, 'new') === false) {
             $entity = $this->factory->getModel('email')->getEntity($id);
             $existingContent = $entity->getContent();
             $content = array_merge($existingContent, $content);
         }
         // Convert placeholders into raw tokens
         BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($content);
         $content = implode("<br /><br />", $content);
         $dataArray['text'] = $parser->setHtml($content)->getText();
     }
     return $this->sendJsonResponse($dataArray);
 }
Esempio n. 4
0
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function generatePlaintTextAction(Request $request)
 {
     $custom = $request->request->get('custom');
     $id = $request->request->get('id');
     $parser = new PlainTextHelper(['base_url' => $request->getSchemeAndHttpHost() . $request->getBasePath()]);
     // Convert placeholders into raw tokens
     BuilderTokenHelper::replaceVisualPlaceholdersWithTokens($custom);
     $dataArray = ['text' => $parser->setHtml($custom)->getText()];
     return $this->sendJsonResponse($dataArray);
 }