本文整理汇总了PHP中Mautic\CoreBundle\Helper\InputHelper::_方法的典型用法代码示例。如果您正苦于以下问题:PHP InputHelper::_方法的具体用法?PHP InputHelper::_怎么用?PHP InputHelper::_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Helper\InputHelper
的用法示例。
在下文中一共展示了InputHelper::_方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setBuilderContentAction
/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function setBuilderContentAction(Request $request)
{
$dataArray = array('success' => 0);
$entityId = InputHelper::clean($request->request->get('entity'));
$session = $this->factory->getSession();
if (!empty($entityId)) {
$sessionVar = 'mautic.emailbuilder.' . $entityId . '.content';
// Check for an array of slots
$slots = InputHelper::_($request->request->get('slots', array(), true), 'html');
$content = $session->get($sessionVar, array());
if (!is_array($content)) {
$content = array();
}
if (!empty($slots)) {
// Builder was closed so save each content
foreach ($slots as $slot => $newContent) {
$content[$slot] = $newContent;
}
$session->set($sessionVar, $content);
$dataArray['success'] = 1;
} else {
// Check for a single slot
$newContent = InputHelper::html($request->request->get('content'));
$slot = InputHelper::clean($request->request->get('slot'));
if (!empty($slot)) {
$content[$slot] = $newContent;
$session->set($sessionVar, $content);
$dataArray['success'] = 1;
}
}
}
return $this->sendJsonResponse($dataArray);
}
示例2: preSubmitData
/**
* @param FormEvent $event
*/
public function preSubmitData(FormEvent $event)
{
$data = $event->getData();
//clean the data
$data = InputHelper::_($data, $this->masks);
$event->setData($data);
}
示例3: generatePreviewAction
/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function generatePreviewAction(Request $request)
{
$data = ['html' => '', 'style' => ''];
$focus = $request->request->all();
if (isset($focus['focus'])) {
$focusArray = InputHelper::_($focus['focus']);
if (!empty($focusArray['style']) && !empty($focusArray['type'])) {
/** @var \MauticPlugin\MauticFocusBundle\Model\FocusModel $model */
$model = $this->getModel('focus');
$focusArray['id'] = 'preview';
$data = $model->generateJavascript($focusArray, true);
}
}
return $this->sendJsonResponse($data);
}
示例4: onKernelRequest
public function onKernelRequest(GetResponseEvent $event)
{
if ($event->isMasterRequest()) {
// get the current event request
$request = $event->getRequest();
$requestUri = $request->getRequestUri();
$formGenerateUrl = $this->router->generate('mautic_form_generateform');
if (strpos($requestUri, $formGenerateUrl) !== false) {
$id = InputHelper::_($this->request->get('id'));
if (strpos($id, 'mf-') === 0) {
$mfId = str_replace('mf-', '', $id);
$focusGenerateUrl = $this->router->generate('mautic_focus_generate', ['id' => $mfId]);
$event->setResponse(new RedirectResponse($focusGenerateUrl));
}
}
}
}
示例5: saveSubmission
/**
* @param $post
* @param $server
* @param Form $form
*
* @return boolean|string false if no error was encountered; otherwise the error message
*/
public function saveSubmission($post, $server, Form $form)
{
$fieldHelper = new FormFieldHelper($this->translator);
//everything matches up so let's save the results
$submission = new Submission();
$submission->setDateSubmitted(new \DateTime());
$submission->setForm($form);
$ipAddress = $this->factory->getIpAddress();
$submission->setIpAddress($ipAddress);
if (!empty($post['return'])) {
$referer = $post['return'];
} elseif (!empty($server['HTTP_REFERER'])) {
$referer = $server['HTTP_REFERER'];
} else {
$referer = '';
}
//clean the referer by removing mauticError and mauticMessage
$referer = InputHelper::url($referer, null, null, array('mauticError', 'mauticMessage'));
$submission->setReferer($referer);
$fields = $form->getFields();
$fieldArray = array();
$results = array();
$tokens = array();
$leadFieldMatches = array();
$validationErrors = array();
foreach ($fields as $f) {
$id = $f->getId();
$type = $f->getType();
$alias = $f->getAlias();
$value = isset($post[$alias]) ? $post[$alias] : '';
$fieldArray[$id] = array('id' => $id, 'type' => $type, 'alias' => $alias);
if (in_array($type, array('button', 'freetext'))) {
//don't save items that don't have a value associated with it
continue;
} elseif ($type == 'captcha') {
$captcha = $fieldHelper->validateFieldValue($type, $value, $f);
if (!empty($captcha)) {
$props = $f->getProperties();
//check for a custom message
$validationErrors[$alias] = !empty($props['errorMessage']) ? $props['errorMessage'] : implode('<br />', $captcha);
}
continue;
}
if ($f->isRequired() && empty($value)) {
//somehow the user got passed the JS validation
$msg = $f->getValidationMessage();
if (empty($msg)) {
$msg = $this->translator->trans('mautic.form.field.generic.validationfailed', array('%label%' => $f->getLabel()), 'validators');
}
$validationErrors[$alias] = $msg;
continue;
}
//clean and validate the input
if ($f->isCustom()) {
$params = $f->getCustomParameters();
if (!empty($value)) {
if (isset($params['valueFilter'])) {
if (is_string($params['inputFilter'] && method_exists('\\Mautic\\CoreBundle\\Helper\\InputHelper', $params['valueFilter']))) {
$value = InputHelper::_($value, $params['valueFilter']);
} elseif (is_callable($params['valueFilter'])) {
$value = call_user_func_array($params['valueFilter'], array($f, $value));
} else {
$value = InputHelper::_($value, 'clean');
}
} else {
$value = InputHelper::_($value, 'clean');
}
}
if (isset($params['valueConstraints']) && is_callable($params['valueConstraints'])) {
$customErrors = call_user_func_array($params['valueConstraints'], array($f, $value));
if (!empty($customErrors)) {
$validationErrors[$alias] = is_array($customErrors) ? implode('<br />', $customErrors) : $customErrors;
}
}
} elseif (!empty($value)) {
$filter = $fieldHelper->getFieldFilter($type);
$value = InputHelper::_($value, $filter);
$validation = $fieldHelper->validateFieldValue($type, $value);
if (!empty($validation)) {
$validationErrors[$alias] = is_array($validation) ? implode('<br />', $validation) : $validation;
}
}
//convert array from checkbox groups and multiple selects
if (is_array($value)) {
$value = implode(", ", $value);
}
$tokens["{formfield={$alias}}"] = $value;
//save the result
if ($f->getSaveResult() !== false) {
$results[$alias] = $value;
}
$leadField = $f->getLeadField();
if (!empty($leadField)) {
//.........这里部分代码省略.........
示例6: saveSubmission
/**
* @param $post
* @param $server
* @param Form $form
*
* @return bool|array
*/
public function saveSubmission($post, $server, Form $form, Request $request = null, $returnEvent = false)
{
$leadFields = $this->leadFieldModel->getFieldListWithProperties(false);
//everything matches up so let's save the results
$submission = new Submission();
$submission->setDateSubmitted(new \DateTime());
$submission->setForm($form);
//set the landing page the form was submitted from if applicable
if (!empty($post['mauticpage'])) {
$page = $this->pageModel->getEntity((int) $post['mauticpage']);
if ($page != null) {
$submission->setPage($page);
}
}
$ipAddress = $this->ipLookupHelper->getIpAddress();
$submission->setIpAddress($ipAddress);
if (!empty($post['return'])) {
$referer = $post['return'];
} elseif (!empty($server['HTTP_REFERER'])) {
$referer = $server['HTTP_REFERER'];
} else {
$referer = '';
}
//clean the referer by removing mauticError and mauticMessage
$referer = InputHelper::url($referer, null, null, ['mauticError', 'mauticMessage']);
$submission->setReferer($referer);
// Create an event to be dispatched through the processes
$submissionEvent = new SubmissionEvent($submission, $post, $server, $request);
// Get a list of components to build custom fields from
$components = $this->formModel->getCustomComponents();
$fields = $form->getFields();
$fieldArray = [];
$results = [];
$tokens = [];
$leadFieldMatches = [];
$validationErrors = [];
/** @var Field $f */
foreach ($fields as $f) {
$id = $f->getId();
$type = $f->getType();
$alias = $f->getAlias();
$value = isset($post[$alias]) ? $post[$alias] : '';
$fieldArray[$id] = ['id' => $id, 'type' => $type, 'alias' => $alias];
if ($type == 'captcha') {
$captcha = $this->fieldHelper->validateFieldValue($type, $value, $f);
if (!empty($captcha)) {
$props = $f->getProperties();
//check for a custom message
$validationErrors[$alias] = !empty($props['errorMessage']) ? $props['errorMessage'] : implode('<br />', $captcha);
}
continue;
}
if ($f->isRequired() && empty($value)) {
//field is required, but hidden from form because of 'ShowWhenValueExists'
if ($f->getShowWhenValueExists() === false && !isset($post[$alias])) {
continue;
}
//somehow the user got passed the JS validation
$msg = $f->getValidationMessage();
if (empty($msg)) {
$msg = $this->translator->trans('mautic.form.field.generic.validationfailed', ['%label%' => $f->getLabel()], 'validators');
}
$validationErrors[$alias] = $msg;
continue;
}
if (in_array($type, $components['viewOnlyFields'])) {
//don't save items that don't have a value associated with it
continue;
}
//clean and validate the input
if ($f->isCustom()) {
if (!isset($components['fields'][$f->getType()])) {
continue;
}
$params = $components['fields'][$f->getType()];
if (!empty($value)) {
if (isset($params['valueFilter'])) {
if (is_string($params['valueFilter']) && is_callable(['\\Mautic\\CoreBundle\\Helper\\InputHelper', $params['valueFilter']])) {
$value = InputHelper::_($value, $params['valueFilter']);
} elseif (is_callable($params['valueFilter'])) {
$value = call_user_func_array($params['valueFilter'], [$f, $value]);
} else {
$value = InputHelper::_($value, 'clean');
}
} else {
$value = InputHelper::_($value, 'clean');
}
}
// @deprecated - BC support; to be removed in 3.0 - be sure to remove support in FormBuilderEvent as well
if (isset($params['valueConstraints']) && is_callable($params['valueConstraints'])) {
$customErrors = call_user_func_array($params['valueConstraints'], [$f, $value]);
if (!empty($customErrors)) {
$validationErrors[$alias] = is_array($customErrors) ? implode('<br />', $customErrors) : $customErrors;
//.........这里部分代码省略.........