本文整理汇总了PHP中Mautic\CoreBundle\Helper\InputHelper::int方法的典型用法代码示例。如果您正苦于以下问题:PHP InputHelper::int方法的具体用法?PHP InputHelper::int怎么用?PHP InputHelper::int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mautic\CoreBundle\Helper\InputHelper
的用法示例。
在下文中一共展示了InputHelper::int方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: setIntegrationFilterAction
/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function setIntegrationFilterAction(Request $request)
{
$session = $this->factory->getSession();
$pluginFilter = InputHelper::int($this->request->get('plugin'));
$session->set('mautic.integrations.filter', $pluginFilter);
return $this->sendJsonResponse(array('success' => 1));
}
示例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);
}
示例4: getWebsiteSnapshotAction
/**
* @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);
}
示例5: 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);
}
示例6: updateDownloadChartAction
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function updateDownloadChartAction(Request $request)
{
$assetId = InputHelper::int($request->request->get('assetId'));
$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('MauticAssetBundle:Download')->getDownloads($assetId, $amount, $unit);
$dataArray['success'] = 1;
return $this->sendJsonResponse($dataArray);
}
示例7: 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);
}
示例8: updateFormFieldsAction
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function updateFormFieldsAction(Request $request)
{
$formId = InputHelper::int($request->request->get('formId'));
$dataArray = array('success' => 0);
$model = $this->factory->getModel('form');
$entity = $model->getEntity($formId);
$formFields = $entity->getFields();
$fields = array();
foreach ($formFields as $field) {
if ($field->getType() != 'button') {
$properties = $field->getProperties();
$options = array();
if (!empty($properties['list']['list'])) {
$options = $properties['list']['list'];
}
$fields[] = array('id' => $field->getId(), 'label' => $field->getLabel(), 'alias' => $field->getAlias(), 'type' => $field->getType(), 'options' => $options);
}
}
$dataArray['fields'] = $fields;
$dataArray['success'] = 1;
return $this->sendJsonResponse($dataArray);
}
示例9: reorderAction
/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function reorderAction(Request $request)
{
$dataArray = array('success' => 0);
$order = InputHelper::clean($request->request->get('field'));
$page = InputHelper::int($request->get('page'));
$limit = InputHelper::int($request->get('limit'));
if (!empty($order)) {
/** @var \Mautic\LeadBundle\Model\FieldModel $model */
$model = $this->factory->getModel('lead.field');
$startAt = $page > 1 ? $page * $limit + 1 : 1;
$model->reorderFieldsByList($order, $startAt);
$dataArray['success'] = 1;
}
return $this->sendJsonResponse($dataArray);
}
示例10: clearNotificationAction
/**
* @param Request $request
*
* @return JsonResponse
*/
protected function clearNotificationAction(Request $request)
{
$id = InputHelper::int($request->get('id', 0));
/** @var \Mautic\CoreBundle\Model\NotificationModel $model */
$model = $this->factory->getModel('core.notification');
$model->clearNotification($id);
return $this->sendJsonResponse(array('success' => 1));
}
示例11: generateAction
/**
* Generates JS file for automatic form generation
*
* @return Response
*/
public function generateAction()
{
$formId = InputHelper::int($this->request->get('id'));
$model = $this->factory->getModel('form.form');
$form = $model->getEntity($formId);
$js = '';
if ($form !== null) {
$status = $form->getPublishStatus();
if ($status == 'published') {
$js = $model->getAutomaticJavascript($form);
}
}
$response = new Response();
$response->setContent($js);
$response->setStatusCode(Response::HTTP_OK);
$response->headers->set('Content-Type', 'text/javascript');
return $response;
}
示例12: embedAction
public function embedAction()
{
$formId = InputHelper::int($this->request->get('id'));
$model = $this->getModel('form');
$form = $model->getEntity($formId);
if ($form !== null) {
$status = $form->getPublishStatus();
if ($status === 'published') {
if ($this->request->get('video')) {
return $this->render('MauticFormBundle:Public:videoembed.html.php', ['form' => $form]);
}
$content = $model->getContent($form, false, true);
return new Response($content);
}
}
return new Response('', Response::HTTP_NOT_FOUND);
}
示例13: toggleLeadCampaignAction
/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function toggleLeadCampaignAction(Request $request)
{
$dataArray = array('success' => 0);
$leadId = InputHelper::int($request->request->get('leadId'));
$campaignId = InputHelper::int($request->request->get('campaignId'));
$action = InputHelper::clean($request->request->get('campaignAction'));
if (!empty($leadId) && !empty($campaignId) && in_array($action, array('remove', 'add'))) {
$leadModel = $this->factory->getModel('lead');
$campaignModel = $this->factory->getModel('campaign');
$lead = $leadModel->getEntity($leadId);
$campaign = $campaignModel->getEntity($campaignId);
if ($lead !== null && $campaign !== null) {
$class = "{$action}Lead";
$campaignModel->{$class}($campaign, $lead, true);
$dataArray['success'] = 1;
}
}
return $this->sendJsonResponse($dataArray);
}
示例14: updateStatsChartAction
/**
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\JsonResponse
*/
protected function updateStatsChartAction(Request $request)
{
$emailId = InputHelper::int($request->request->get('emailId'));
$emailType = InputHelper::clean($request->request->get('emailType'));
$includeVariants = InputHelper::boolean($request->request->get('includeVariants', false));
$amount = InputHelper::int($request->request->get('amount'));
$unit = InputHelper::clean($request->request->get('unit'));
$dataArray = array('success' => 0);
/** @var \Mautic\EmailBundle\Model\EmailModel $model */
$model = $this->factory->getModel('email');
$dataArray['stats'] = $emailType == 'template' ? $model->getEmailGeneralStats($emailId, $includeVariants, $amount, $unit) : $model->getEmailListStats($emailId, $includeVariants);
$dataArray['success'] = 1;
return $this->sendJsonResponse($dataArray);
}
示例15: contactAction
/**
* Contacts a user
*
* @param int $objectId
*
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
*/
public function contactAction($objectId)
{
$model = $this->getModel('user.user');
$user = $model->getEntity($objectId);
//user not found
if ($user === null) {
return $this->postActionRedirect(array('returnUrl' => $this->generateUrl('mautic_dashboard_index'), 'contentTemplate' => 'MauticUserBundle:User:contact', 'flashes' => array(array('type' => 'error', 'msg' => 'mautic.user.user.error.notfound', 'msgVars' => array('%id%' => $objectId)))));
}
$action = $this->generateUrl('mautic_user_action', array('objectAction' => 'contact', 'objectId' => $objectId));
$form = $this->createForm(new FormType\ContactType(), array(), array('action' => $action));
$currentUser = $this->factory->getUser();
if ($this->request->getMethod() == 'POST') {
$formUrl = $this->request->request->get('contact[returnUrl]', '', true);
$returnUrl = $formUrl ? urldecode($formUrl) : $this->generateUrl('mautic_dashboard_index');
$valid = false;
if (!($cancelled = $this->isFormCancelled($form))) {
if ($valid = $this->isFormValid($form)) {
$subject = InputHelper::clean($form->get('msg_subject')->getData());
$body = InputHelper::clean($form->get('msg_body')->getData());
$message = \Swift_Message::newInstance()->setSubject($subject)->setFrom($currentUser->getEmail(), $currentUser->getName())->setTo($user->getEmail(), $user->getName())->setBody($body);
$this->get('mailer')->send($message);
$reEntity = $form->get('entity')->getData();
if (empty($reEntity)) {
$bundle = $object = 'user';
$entityId = $user->getId();
} else {
$bundle = $object = $reEntity;
if (strpos($reEntity, ':')) {
list($bundle, $object) = explode(':', $reEntity);
}
$entityId = $form->get('id')->getData();
}
$serializer = $this->get('jms_serializer');
$details = $serializer->serialize(array('from' => $currentUser->getName(), 'to' => $user->getName(), 'subject' => $subject, 'message' => $body), 'json');
$log = array('bundle' => $bundle, 'object' => $object, 'objectId' => $entityId, 'action' => 'communication', 'details' => $details, 'ipAddress' => $this->factory->getIpAddressFromRequest());
$this->getModel('core.auditLog')->writeToLog($log);
$this->addFlash('mautic.user.user.notice.messagesent', array('%name%' => $user->getName()));
}
}
if ($cancelled || $valid) {
return $this->redirect($returnUrl);
}
} else {
$reEntityId = InputHelper::int($this->request->get('id'));
$reSubject = InputHelper::clean($this->request->get('subject'));
$returnUrl = InputHelper::clean($this->request->get('returnUrl', $this->generateUrl('mautic_dashboard_index')));
$reEntity = InputHelper::clean($this->request->get('entity'));
$form->get('entity')->setData($reEntity);
$form->get('id')->setData($reEntityId);
$form->get('returnUrl')->setData($returnUrl);
if (!empty($reEntity) && !empty($reEntityId)) {
$model = $this->getModel($reEntity);
$entity = $model->getEntity($reEntityId);
if ($entity !== null) {
$subject = $model->getUserContactSubject($reSubject, $entity);
$form->get('msg_subject')->setData($subject);
}
}
}
return $this->delegateView(array('viewParameters' => array('form' => $form->createView(), 'user' => $user), 'contentTemplate' => 'MauticUserBundle:User:contact.html.php', 'passthroughVars' => array('route' => $action, 'mauticContent' => 'user')));
}