当前位置: 首页>>代码示例>>PHP>>正文


PHP InputHelper::clean方法代码示例

本文整理汇总了PHP中Mautic\CoreBundle\Helper\InputHelper::clean方法的典型用法代码示例。如果您正苦于以下问题:PHP InputHelper::clean方法的具体用法?PHP InputHelper::clean怎么用?PHP InputHelper::clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mautic\CoreBundle\Helper\InputHelper的用法示例。


在下文中一共展示了InputHelper::clean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getActionFormAction

 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function getActionFormAction(Request $request)
 {
     $dataArray = ['success' => 0, 'html' => ''];
     $type = InputHelper::clean($request->request->get('actionType'));
     if (!empty($type)) {
         //get the HTML for the form
         /** @var \Mautic\PointBundle\Model\PointModel $model */
         $model = $this->getModel('point');
         $actions = $model->getPointActions();
         if (isset($actions['actions'][$type])) {
             $themes = ['MauticPointBundle:FormTheme\\Action'];
             if (!empty($actions['actions'][$type]['formTheme'])) {
                 $themes[] = $actions['actions'][$type]['formTheme'];
             }
             $formType = !empty($actions['actions'][$type]['formType']) ? $actions['actions'][$type]['formType'] : 'genericpoint_settings';
             $formTypeOptions = !empty($actions['actions'][$type]['formTypeOptions']) ? $actions['actions'][$type]['formTypeOptions'] : [];
             $form = $this->get('form.factory')->create('pointaction', [], ['formType' => $formType, 'formTypeOptions' => $formTypeOptions]);
             $html = $this->renderView('MauticPointBundle:Point:actionform.html.php', ['form' => $this->setFormTheme($form, 'MauticPointBundle:Point:actionform.html.php', $themes)]);
             //replace pointaction with point
             $html = str_replace('pointaction', 'point', $html);
             $dataArray['html'] = $html;
             $dataArray['success'] = 1;
         }
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:31,代码来源:AjaxController.php

示例2: getActionFormAction

 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function getActionFormAction(Request $request)
 {
     $dataArray = array('success' => 0, 'html' => '');
     $type = InputHelper::clean($request->request->get('actionType'));
     if (!empty($type)) {
         //get the HTML for the form
         /** @var \Mautic\StageBundle\Model\StageModel $model */
         $model = $this->getModel('stage');
         $actions = $model->getStageActions();
         if (isset($actions['actions'][$type])) {
             $themes = array('MauticStageBundle:FormTheme\\Action');
             if (!empty($actions['actions'][$type]['formTheme'])) {
                 $themes[] = $actions['actions'][$type]['formTheme'];
             }
             $formType = !empty($actions['actions'][$type]['formType']) ? $actions['actions'][$type]['formType'] : 'genericstage_settings';
             $formTypeOptions = !empty($actions['actions'][$type]['formTypeOptions']) ? $actions['actions'][$type]['formTypeOptions'] : array();
             $form = $this->get('form.factory')->create('stageaction', array(), array('formType' => $formType, 'formTypeOptions' => $formTypeOptions));
             $html = $this->renderView('MauticStageBundle:Stage:actionform.html.php', array('form' => $this->setFormTheme($form, 'MauticStageBundle:Stage:actionform.html.php', $themes)));
             $html = str_replace('stageaction', 'stage', $html);
             $dataArray['html'] = $html;
             $dataArray['success'] = 1;
         }
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:Yame-,项目名称:mautic,代码行数:30,代码来源:AjaxController.php

示例3: getAbTestForm

 /**
  * @param Request $request
  * @param         $modelName
  * @param         $abSettingsFormName
  * @param         $parentFormName
  * @param         $abFormTemplate
  * @param array   $formThemes
  *
  * @return mixed
  */
 private function getAbTestForm(Request $request, $modelName, $abSettingsFormName, $parentFormName, $abFormTemplate, $formThemes = [])
 {
     $dataArray = ['success' => 0, 'html' => ''];
     $type = InputHelper::clean($request->request->get('abKey'));
     $id = InputHelper::int($request->request->get('id'));
     if (!empty($type)) {
         //get the HTML for the form
         $model = $this->getModel($modelName);
         $entity = $model->getEntity($id);
         $abTestComponents = $model->getBuilderComponents($entity, 'abTestWinnerCriteria');
         $abTestSettings = $abTestComponents['criteria'];
         if (isset($abTestSettings[$type])) {
             $html = '';
             $formType = !empty($abTestSettings[$type]['formType']) ? $abTestSettings[$type]['formType'] : '';
             if (!empty($formType)) {
                 $formOptions = !empty($abTestSettings[$type]['formTypeOptions']) ? $abTestSettings[$type]['formTypeOptions'] : [];
                 $form = $this->get('form.factory')->create($abSettingsFormName, [], ['formType' => $formType, 'formTypeOptions' => $formOptions]);
                 $html = $this->renderView($abFormTemplate, ['form' => $this->setFormTheme($form, $formThemes)]);
             }
             $html = str_replace(["{$abSettingsFormName}[", "{$abSettingsFormName}_", $abSettingsFormName], ["{$parentFormName}[variantSettings][", "{$parentFormName}_variantSettings_", $parentFormName], $html);
             $dataArray['html'] = $html;
             $dataArray['success'] = 1;
         }
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:36,代码来源:VariantAjaxControllerTrait.php

示例4: saveApiKeyAction

 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function saveApiKeyAction(Request $request)
 {
     $apiKey = InputHelper::clean($request->request->get('apiKey'));
     $dataArray = ['success' => 0];
     /** @var \Mautic\InstallBundle\Configurator\Configurator $configurator */
     $configurator = $this->get('mautic.configurator');
     if ($configurator->isFileWritable()) {
         try {
             $cronfigConfig = array('api_key' => $apiKey);
             // Ensure the config has a secret key
             $params = $configurator->getParameters();
             if (!isset($params['cronfig']) || empty($params['cronfig']['secret_key'])) {
                 $cronfigConfig['secret_key'] = EncryptionHelper::generateKey();
                 $dataArray['secret_key'] = $cronfigConfig['secret_key'];
             }
             // Save the API key only if it doesn't exist or has changed
             if (!isset($params['cronfig']['api_key']) || !isset($params['cronfig']['secret_key']) || isset($params['cronfig']['api_key']) && $params['cronfig']['api_key'] == $apiKey || isset($params['cronfig']['secret_key']) && $params['cronfig']['secret_key'] == $apiKey) {
                 $configurator->mergeParameters(array('cronfig' => $cronfigConfig));
                 $configurator->write();
                 $dataArray['success'] = 1;
                 // We must clear the application cache for the updated values to take effect
                 /** @var \Mautic\CoreBundle\Helper\CacheHelper $cacheHelper */
                 $cacheHelper = $this->factory->getHelper('cache');
                 $cacheHelper->clearContainerFile();
             }
         } catch (\RuntimeException $exception) {
             $this->addFlash('mautic.config.config.error.not.updated', ['%exception%' => $exception->getMessage()], 'error');
         }
     } else {
         $form->addError(new FormError($this->factory->getTranslator()->trans('mautic.config.notwritable')));
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:cronfig,项目名称:mautic-cronfig,代码行数:37,代码来源:AjaxController.php

示例5: getAbTestFormAction

 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function getAbTestFormAction(Request $request)
 {
     $dataArray = array('success' => 0, 'html' => '');
     $type = InputHelper::clean($request->request->get('abKey'));
     $emailId = InputHelper::int($request->request->get('emailId'));
     if (!empty($type)) {
         //get the HTML for the form
         /** @var \Mautic\EmailBundle\Model\EmailModel $model */
         $model = $this->factory->getModel('email');
         $email = $model->getEntity($emailId);
         $abTestComponents = $model->getBuilderComponents($email, 'abTestWinnerCriteria');
         $abTestSettings = $abTestComponents['criteria'];
         if (isset($abTestSettings[$type])) {
             $html = '';
             $formType = !empty($abTestSettings[$type]['formType']) ? $abTestSettings[$type]['formType'] : '';
             if (!empty($formType)) {
                 $formOptions = !empty($abTestSettings[$type]['formTypeOptions']) ? $abTestSettings[$type]['formTypeOptions'] : array();
                 $form = $this->get('form.factory')->create('email_abtest_settings', array(), array('formType' => $formType, 'formTypeOptions' => $formOptions));
                 $html = $this->renderView('MauticEmailBundle:AbTest:form.html.php', array('form' => $this->setFormTheme($form, 'MauticEmailBundle:AbTest:form.html.php', 'MauticEmailBundle:FormTheme\\Email')));
             }
             $html = str_replace(array('email_abtest_settings[', 'email_abtest_settings_', 'email_abtest_settings'), array('emailform[variantSettings][', 'emailform_variantSettings_', 'emailform'), $html);
             $dataArray['html'] = $html;
             $dataArray['success'] = 1;
         }
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:32,代码来源:AjaxController.php

示例6: sendHookTestAction

 protected function sendHookTestAction(Request $request)
 {
     $url = InputHelper::clean($request->request->get('url'));
     // validate the URL
     if ($url == '' || !$url) {
         // default to an error message
         $dataArray = array('success' => 1, 'html' => '<div class="has-error"><span class="help-block">' . $this->factory->getTranslator()->trans('mautic.webhook.label.no.url') . '</span></div>');
         return $this->sendJsonResponse($dataArray);
     }
     // get the selected types
     $selectedTypes = InputHelper::cleanArray($request->request->get('types'));
     $payloadPaths = $this->getPayloadPaths($selectedTypes);
     $payloads = $this->loadPayloads($payloadPaths);
     $now = new \DateTime();
     $payloads['timestamp'] = $now->format('c');
     // instantiate new http class
     $http = new Http();
     // set the response
     $response = $http->post($url, json_encode($payloads));
     // default to an error message
     $dataArray = array('success' => 1, 'html' => '<div class="has-error"><span class="help-block">' . $this->factory->getTranslator()->trans('mautic.webhook.label.warning') . '</span></div>');
     // if we get a 200 response convert to success message
     if ($response->code == 200) {
         $dataArray['html'] = '<div class="has-success"><span class="help-block">' . $this->factory->getTranslator()->trans('mautic.webhook.label.success') . '</span></div>';
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:spdaly,项目名称:mautic,代码行数:27,代码来源:AjaxController.php

示例7: 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.pagebuilder.' . $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);
 }
开发者ID:Yame-,项目名称:mautic,代码行数:38,代码来源:AjaxController.php

示例8: categoryListAction

 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function categoryListAction(Request $request)
 {
     $filter = InputHelper::clean($request->query->get('filter'));
     $results = $this->factory->getModel('asset.asset')->getLookupResults('category', $filter, 10);
     $dataArray = array();
     foreach ($results as $r) {
         $dataArray[] = array("label" => $r['title'] . " ({$r['id']})", "value" => $r['id']);
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:14,代码来源:AjaxController.php

示例9: getDataAction

 /**
  * Obtains a list of available widget types.
  *
  * @param string $type of the widget
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function getDataAction($type)
 {
     $start = microtime(true);
     $timezone = InputHelper::clean($this->request->get('timezone', null));
     $from = InputHelper::clean($this->request->get('dateFrom', null));
     $to = InputHelper::clean($this->request->get('dateTo', null));
     $dataFormat = InputHelper::clean($this->request->get('dataFormat', null));
     $response = ['success' => 0];
     if ($timezone) {
         $fromDate = new \DateTime($from, new \DateTimeZone($timezone));
         $toDate = new \DateTime($to, new \DateTimeZone($timezone));
     } else {
         $fromDate = new \DateTime($from);
         $toDate = new \DateTime($to);
     }
     $params = ['timeUnit' => InputHelper::clean($this->request->get('timeUnit', 'Y')), 'dateFormat' => InputHelper::clean($this->request->get('dateFormat', null)), 'dateFrom' => $fromDate, 'dateTo' => $toDate, 'limit' => InputHelper::int($this->request->get('limit', null)), 'filter' => $this->request->get('filter', [])];
     $cacheTimeout = InputHelper::int($this->request->get('cacheTimeout', null));
     $widgetHeight = InputHelper::int($this->request->get('height', 300));
     $widget = new Widget();
     $widget->setParams($params);
     $widget->setType($type);
     $widget->setHeight($widgetHeight);
     if ($cacheTimeout === null) {
         $widget->setCacheTimeout($cacheTimeout);
     }
     $this->model->populateWidgetContent($widget);
     $data = $widget->getTemplateData();
     if (!$data) {
         return $this->notFound();
     }
     if ($dataFormat == 'raw') {
         if (isset($data['chartData']['labels']) && isset($data['chartData']['datasets'])) {
             $rawData = [];
             foreach ($data['chartData']['datasets'] as $dataset) {
                 $rawData[$dataset['label']] = [];
                 foreach ($dataset['data'] as $key => $value) {
                     $rawData[$dataset['label']][$data['chartData']['labels'][$key]] = $value;
                 }
             }
             $data = $rawData;
         } elseif (isset($data['raw'])) {
             $data = $data['raw'];
         }
     } else {
         if (isset($data['raw'])) {
             unset($data['raw']);
         }
     }
     $response['cached'] = $widget->isCached();
     $response['execution_time'] = microtime(true) - $start;
     $response['success'] = 1;
     $response['data'] = $data;
     $view = $this->view($response, Codes::HTTP_OK);
     return $this->handleView($view);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:62,代码来源:WidgetApiController.php

示例10: categoryListAction

 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function categoryListAction(Request $request)
 {
     $bundle = InputHelper::clean($request->query->get('bundle'));
     $filter = InputHelper::clean($request->query->get('filter'));
     $results = $this->getModel('category')->getLookupResults($bundle, $filter, 10);
     $dataArray = [];
     foreach ($results as $r) {
         $dataArray[] = ['label' => $r['title'] . " ({$r['id']})", 'value' => $r['id']];
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:16,代码来源:AjaxController.php

示例11: updateSubmissionChartAction

 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function updateSubmissionChartAction(Request $request)
 {
     $formId = InputHelper::int($request->request->get('formId'));
     $amount = InputHelper::int($request->request->get('amount'));
     $unit = InputHelper::clean($request->request->get('unit'));
     $dataArray = array('success' => 0);
     // Download stats per time period
     $dataArray['stats'] = $this->factory->getEntityManager()->getRepository('MauticFormBundle:Submission')->getSubmissionsSince($formId, $amount, $unit);
     $dataArray['success'] = 1;
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:15,代码来源:AjaxController.php

示例12: _

 /**
  * Format a string
  *
  * @param $val
  * @param $type
  */
 public function _($val, $type, $textOnly = false, $round = 1)
 {
     if (empty($val)) {
         return $val;
     }
     switch ($type) {
         case 'array':
             if (!is_array($val)) {
                 //assume that it's serialized
                 $unserialized = unserialize($val);
                 if ($unserialized) {
                     $val = $unserialized;
                 }
             }
             $stringParts = array();
             foreach ($val as $k => $v) {
                 if (is_array($v)) {
                     $stringParts = $this->_($v, 'array', $textOnly, $round + 1);
                 } else {
                     $stringParts[] = $v;
                 }
             }
             if ($round === 1) {
                 $string = implode('; ', $stringParts);
             } else {
                 $string = implode(', ', $stringParts);
             }
             break;
         case 'datetime':
             $string = $this->dateHelper->toFull($val, 'utc');
             break;
         case 'time':
             $string = $this->dateHelper->toTime($val, 'utc');
             break;
         case 'date':
             $string = $this->dateHelper->toDate($val, 'utc');
             break;
         case 'url':
             $string = $textOnly ? $val : '<a href="' . $val . '" target="_new">' . $val . '</a>';
             break;
         case 'email':
             $string = $textOnly ? $val : '<a href="mailto:' . $val . '">' . $val . '</a>';
             break;
         case 'int':
             $string = (int) $val;
             break;
         default:
             $string = InputHelper::clean($val);
             break;
     }
     return $string;
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:58,代码来源:FormatterHelper.php

示例13: updateConnectionsAction

 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function updateConnectionsAction(Request $request)
 {
     $session = $this->factory->getSession();
     $campaignId = InputHelper::clean($request->query->get('campaignId'));
     $canvasSettings = $this->request->request->get('canvasSettings', array(), true);
     if (empty($campaignId)) {
         $dataArray = array('success' => 0);
     } else {
         $session->set('mautic.campaign.' . $campaignId . '.events.canvassettings', $canvasSettings);
         $dataArray = array('success' => 1);
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:18,代码来源:AjaxController.php

示例14: updateGraphAction

 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function updateGraphAction(Request $request)
 {
     $reportId = InputHelper::int($request->request->get('reportId'));
     $options = InputHelper::clean($request->request->all());
     $dataArray = array('success' => 0);
     /* @type \Mautic\ReportBundle\Model\ReportModel $model */
     $model = $this->factory->getModel('report');
     $report = $model->getEntity($reportId);
     $options['ignoreTableData'] = true;
     $reportData = $model->getReportData($report, $this->container->get('form.factory'), $options);
     $dataArray['graph'] = $reportData['graphs'][$options['graphName']]['data'];
     $dataArray['success'] = 1;
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:18,代码来源:AjaxController.php

示例15: reorderFieldsAction

 /**
  * @param Request $request
  * @param string  $name
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse
  */
 protected function reorderFieldsAction(Request $request, $name = 'fields')
 {
     $dataArray = array('success' => 0);
     $sessionId = InputHelper::clean($request->request->get('formId'));
     $sessionName = 'mautic.form.' . $sessionId . '.' . $name . '.modified';
     $session = $this->factory->getSession();
     $orderName = $name == 'fields' ? 'mauticform' : 'mauticform_action';
     $order = InputHelper::clean($request->request->get($orderName));
     $components = $session->get($sessionName);
     if (!empty($order) && !empty($components)) {
         $components = array_replace(array_flip($order), $components);
         $session->set($sessionName, $components);
         $dataArray['success'] = 1;
     }
     return $this->sendJsonResponse($dataArray);
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:22,代码来源:AjaxController.php


注:本文中的Mautic\CoreBundle\Helper\InputHelper::clean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。