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


PHP InputHelper::alphanum方法代码示例

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


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

示例1: saveEntity

 /**
  * {@inheritdoc}
  *
  * @param      $entity
  * @param bool $unlock
  * @return mixed|void
  */
 public function saveEntity($entity, $unlock = true)
 {
     $isNew = $entity->getId() ? false : true;
     //set some defaults
     $this->setTimestamps($entity, $isNew, $unlock);
     $alias = $entity->getAlias();
     if (empty($alias)) {
         $alias = strtolower(InputHelper::alphanum($entity->getName(), false, '-'));
     } else {
         $alias = strtolower(InputHelper::alphanum($alias, false, '-'));
     }
     //make sure alias is not already taken
     $repo = $this->getRepository();
     $testAlias = $alias;
     $user = $this->factory->getUser();
     $existing = $repo->getLists($user, $testAlias, $entity->getId());
     $count = count($existing);
     $aliasTag = $count;
     while ($count) {
         $testAlias = $alias . $aliasTag;
         $existing = $repo->getLists($user, $testAlias, $entity->getId());
         $count = count($existing);
         $aliasTag++;
     }
     if ($testAlias != $alias) {
         $alias = $testAlias;
     }
     $entity->setAlias($alias);
     $event = $this->dispatchEvent("pre_save", $entity, $isNew);
     $repo->saveEntity($entity);
     $this->dispatchEvent("post_save", $entity, $isNew, $event);
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:39,代码来源:ListModel.php

示例2: saveEntity

 /**
  * {@inheritdoc}
  *
  * @param       $entity
  * @param       $unlock
  * @return mixed
  */
 public function saveEntity($entity, $unlock = true)
 {
     $alias = $entity->getAlias();
     if (empty($alias)) {
         $alias = strtolower(InputHelper::alphanum($entity->getTitle(), false, '-'));
     } else {
         $alias = strtolower(InputHelper::alphanum($alias, false, '-'));
     }
     //make sure alias is not already taken
     $repo = $this->getRepository();
     $testAlias = $alias;
     $bundle = $entity->getBundle();
     $count = $repo->checkUniqueCategoryAlias($bundle, $testAlias, $entity);
     $aliasTag = $count;
     while ($count) {
         $testAlias = $alias . $aliasTag;
         $count = $repo->checkUniqueCategoryAlias($bundle, $testAlias, $entity);
         $aliasTag++;
     }
     if ($testAlias != $alias) {
         $alias = $testAlias;
     }
     $entity->setAlias($alias);
     parent::saveEntity($entity, $unlock);
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:32,代码来源:CategoryModel.php

示例3: saveEntity

 /**
  * {@inheritdoc}
  */
 public function saveEntity($entity, $unlock = true)
 {
     if (empty($this->inConversion)) {
         $alias = $entity->getAlias();
         if (empty($alias)) {
             $alias = strtolower(InputHelper::alphanum($entity->getTitle(), false, '-'));
         } else {
             $alias = strtolower(InputHelper::alphanum($alias, false, '-'));
         }
         //make sure alias is not already taken
         $repo = $this->getRepository();
         $testAlias = $alias;
         $count = $repo->checkUniqueAlias($testAlias, $entity);
         $aliasTag = $count;
         while ($count) {
             $testAlias = $alias . $aliasTag;
             $count = $repo->checkUniqueAlias($testAlias, $entity);
             $aliasTag++;
         }
         if ($testAlias != $alias) {
             $alias = $testAlias;
         }
         $entity->setAlias($alias);
     }
     //set the author for new asset
     if (!$entity->isNew()) {
         //increase the revision
         $revision = $entity->getRevision();
         $revision++;
         $entity->setRevision($revision);
     }
     parent::saveEntity($entity, $unlock);
 }
开发者ID:smotalima,项目名称:mautic,代码行数:36,代码来源:AssetModel.php

示例4: buildForm

 /**
  * @param FormBuilderInterface $builder
  * @param array                $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     foreach ($options['integration_fields'] as $field => $details) {
         $label = is_array($details) ? $details['label'] : $details;
         $field = InputHelper::alphanum($field, false, '_');
         $builder->add($field, 'choice', array('choices' => $options['lead_fields'], 'label' => $label, 'required' => is_array($details) && isset($details['required']) ? $details['required'] : false, 'label_attr' => array('class' => 'control-label'), 'attr' => array('class' => 'form-control', 'data-placeholder' => ' ')));
     }
 }
开发者ID:spdaly,项目名称:mautic,代码行数:12,代码来源:FieldsType.php

示例5: saveEntity

 /**
  * @param       $entity
  * @param       $unlock
  * @return mixed
  */
 public function saveEntity($entity, $unlock = true)
 {
     if (!$entity instanceof LeadField) {
         throw new MethodNotAllowedHttpException(array('LeadEntity'));
     }
     $isNew = $entity->getId() ? false : true;
     //set some defaults
     $this->setTimestamps($entity, $isNew, $unlock);
     $alias = $entity->getAlias();
     if ($isNew) {
         if (empty($alias)) {
             $alias = strtolower(InputHelper::alphanum($entity->getName()));
         }
         // clean the alias
         $alias = $this->cleanAlias($alias);
         // make sure alias is not already taken
         $repo = $this->getRepository();
         $testAlias = $alias;
         $aliases = $repo->getAliases($entity->getId());
         $count = (int) in_array($testAlias, $aliases);
         $aliasTag = $count;
         while ($count) {
             $testAlias = $alias . $aliasTag;
             $count = (int) in_array($testAlias, $aliases);
             $aliasTag++;
         }
         if ($testAlias != $alias) {
             $alias = $testAlias;
         }
         $entity->setAlias($alias);
     }
     if ($entity->getType() == 'time') {
         //time does not work well with list filters
         $entity->setIsListable(false);
     }
     $event = $this->dispatchEvent("pre_save", $entity, $isNew);
     $this->getRepository()->saveEntity($entity);
     $this->dispatchEvent("post_save", $entity, $isNew, $event);
     if ($entity->getId()) {
         //create the field as its own column in the leads table
         $leadsSchema = $this->factory->getSchemaHelper('column', 'leads');
         if ($isNew || !$isNew && !$leadsSchema->checkColumnExists($alias)) {
             $leadsSchema->addColumn(array('name' => $alias, 'type' => 'text', 'options' => array('notnull' => false)));
             $leadsSchema->executeChanges();
         }
     }
     //update order of other fields
     $this->reorderFieldsByEntity($entity);
 }
开发者ID:Jornve,项目名称:mautic,代码行数:54,代码来源:FieldModel.php

示例6: generateAlias

 /**
  * @param $formId
  * @param $label
  */
 public function generateAlias($label, &$aliases)
 {
     // Some labels are quite long if a question so cut this short
     $alias = substr(strtolower(InputHelper::alphanum($label, false, '_')), 0, 25);
     if (substr($alias, -1) == '_') {
         $alias = substr($alias, 0, -1);
     }
     //make sure alias is not already taken
     $testAlias = $alias;
     $count = (int) in_array($alias, $aliases);
     $aliasTag = $count;
     while ($count) {
         $testAlias = $alias . $aliasTag;
         $count = (int) in_array($testAlias, $aliases);
         $aliasTag++;
     }
     $aliases[] = $testAlias;
     return $testAlias;
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:23,代码来源:FieldModel.php

示例7: generateFormName

 /**
  * Generate a form name for HTML attributes
  */
 public function generateFormName()
 {
     $name = strtolower(InputHelper::alphanum(InputHelper::transliterate($this->name)));
     return empty($name) ? 'form-' . $this->id : $name;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:8,代码来源:Form.php

示例8: saveEntity

 /**
  * {@inheritdoc}
  *
  * @param Page $entity
  * @param bool $unlock
  */
 public function saveEntity($entity, $unlock = true)
 {
     if (empty($this->inConversion)) {
         $alias = $entity->getAlias();
         if (empty($alias)) {
             $alias = strtolower(InputHelper::alphanum($entity->getTitle(), false, '-'));
         } else {
             $alias = strtolower(InputHelper::alphanum($alias, false, '-'));
         }
         //make sure alias is not already taken
         $repo = $this->getRepository();
         $testAlias = $alias;
         $count = $repo->checkUniqueAlias($testAlias, $entity);
         $aliasTag = $count;
         while ($count) {
             $testAlias = $alias . $aliasTag;
             $count = $repo->checkUniqueAlias($testAlias, $entity);
             $aliasTag++;
         }
         if ($testAlias != $alias) {
             $alias = $testAlias;
         }
         $entity->setAlias($alias);
     }
     $now = new \DateTime();
     //set the author for new pages
     if (!$entity->isNew()) {
         //increase the revision
         $revision = $entity->getRevision();
         $revision++;
         $entity->setRevision($revision);
         //reset the variant hit and start date if there are any changes
         $changes = $entity->getChanges();
         $isVariant = $entity->getVariantStartDate();
         if ($isVariant !== null && !empty($changes) && empty($this->inConversion)) {
             $entity->setVariantHits(0);
             $entity->setVariantStartDate($now);
         }
     }
     parent::saveEntity($entity, $unlock);
     //also reset variants if applicable due to changes
     if (!empty($changes) && empty($this->inConversion)) {
         $parent = $entity->getVariantParent();
         $children = !empty($parent) ? $parent->getVariantChildren() : $entity->getVariantChildren();
         $variants = array();
         if (!empty($parent)) {
             $parent->setVariantHits(0);
             $parent->setVariantStartDate($now);
             $variants[] = $parent;
         }
         if (count($children)) {
             foreach ($children as $child) {
                 $child->setVariantHits(0);
                 $child->setVariantStartDate($now);
                 $variants[] = $child;
             }
         }
         //if the parent was changed, then that parent/children must also be reset
         if (isset($changes['variantParent'])) {
             $parent = $this->getEntity($changes['variantParent'][0]);
             if (!empty($parent)) {
                 $parent->setVariantHits(0);
                 $parent->setVariantStartDate($now);
                 $variants[] = $parent;
                 $children = $parent->getVariantChildren();
                 if (count($children)) {
                     foreach ($children as $child) {
                         $child->setVariantHits(0);
                         $child->setVariantStartDate($now);
                         $variants[] = $child;
                     }
                 }
             }
         }
         if (!empty($variants)) {
             $this->saveEntities($variants, false);
         }
     }
 }
开发者ID:Jornve,项目名称:mautic,代码行数:85,代码来源:PageModel.php

示例9: saveEntity

 /**
  * @param       $entity
  * @param       $unlock
  * @return mixed
  */
 public function saveEntity($entity, $unlock = true)
 {
     if (!$entity instanceof LeadField) {
         throw new MethodNotAllowedHttpException(array('LeadEntity'));
     }
     $isNew = $entity->getId() ? false : true;
     //set some defaults
     $this->setTimestamps($entity, $isNew, $unlock);
     $alias = $entity->getAlias();
     if ($isNew) {
         if (empty($alias)) {
             $alias = strtolower(InputHelper::alphanum($entity->getName()));
         }
         // clean the alias
         $alias = $this->cleanAlias($alias);
         // make sure alias is not already taken
         $repo = $this->getRepository();
         $testAlias = $alias;
         $aliases = $repo->getAliases($entity->getId());
         $count = (int) in_array($testAlias, $aliases);
         $aliasTag = $count;
         while ($count) {
             $testAlias = $alias . $aliasTag;
             $count = (int) in_array($testAlias, $aliases);
             $aliasTag++;
         }
         if ($testAlias != $alias) {
             $alias = $testAlias;
         }
         $entity->setAlias($alias);
     }
     $type = $entity->getType();
     if ($type == 'time') {
         //time does not work well with list filters
         $entity->setIsListable(false);
     } elseif ($type == 'select' || $type == 'lookup') {
         // Convert to a string
         $properties = $entity->getProperties();
         if (isset($properties['list']) && is_array($properties['list'])) {
             $properties['list'] = implode('|', array_map('trim', $properties['list']));
         }
         $entity->setProperties($properties);
     }
     $event = $this->dispatchEvent("pre_save", $entity, $isNew);
     $this->getRepository()->saveEntity($entity);
     $this->dispatchEvent("post_save", $entity, $isNew, $event);
     $isUnique = $entity->getIsUniqueIdentifier();
     if ($entity->getId()) {
         //create the field as its own column in the leads table
         $leadsSchema = $this->factory->getSchemaHelper('column', 'leads');
         if ($isNew || !$isNew && !$leadsSchema->checkColumnExists($alias)) {
             $leadsSchema->addColumn(array('name' => $alias, 'type' => in_array($alias, array('country', 'email')) || $isUnique ? 'string' : 'text', 'options' => array('notnull' => false)));
             $leadsSchema->executeChanges();
             if ($isUnique) {
                 // Get list of current uniques
                 $uniqueIdentifierFields = $this->getUniqueIdentifierFields();
                 // Always use email
                 $indexColumns = array('email');
                 $indexColumns = array_merge($indexColumns, array_keys($uniqueIdentifierFields));
                 $indexColumns[] = $alias;
                 // Only use three to prevent max key length errors
                 $indexColumns = array_slice($indexColumns, 0, 3);
                 try {
                     // Update the unique_identifier_search index
                     /** @var \Mautic\CoreBundle\Doctrine\Helper\IndexSchemaHelper $modifySchema */
                     $modifySchema = $this->factory->getSchemaHelper('index', 'leads');
                     $modifySchema->allowColumn($alias);
                     $modifySchema->addIndex($indexColumns, 'unique_identifier_search');
                     $modifySchema->addIndex(array($alias), 'lead_field' . $alias . '_search');
                     $modifySchema->executeChanges();
                 } catch (\Exception $e) {
                     error_log($e);
                     die(var_dump($e));
                 }
             }
         }
     }
     //update order of other fields
     $this->reorderFieldsByEntity($entity);
 }
开发者ID:smotalima,项目名称:mautic,代码行数:85,代码来源:FieldModel.php

示例10: exportResults

 /**
  * Export report
  *
  * @param $format
  * @param $report
  * @param $reportData
  *
  * @return StreamedResponse|Response
  * @throws \Exception
  */
 public function exportResults($format, $report, $reportData)
 {
     $formatter = $this->formatterHelper;
     $date = (new DateTimeHelper())->toLocalString();
     $name = str_replace(' ', '_', $date) . '_' . InputHelper::alphanum($report->getName(), false, '-');
     switch ($format) {
         case 'csv':
             $response = new StreamedResponse(function () use($reportData, $report, $formatter) {
                 $handle = fopen('php://output', 'r+');
                 $header = [];
                 //build the data rows
                 foreach ($reportData['data'] as $count => $data) {
                     $row = [];
                     foreach ($data as $k => $v) {
                         if ($count === 0) {
                             //set the header
                             $header[] = $k;
                         }
                         $row[] = $formatter->_($v, $reportData['columns'][$reportData['dataColumns'][$k]]['type'], true);
                     }
                     if ($count === 0) {
                         //write the row
                         fputcsv($handle, $header);
                     } else {
                         fputcsv($handle, $row);
                     }
                     //free memory
                     unset($row, $reportData['data'][$count]);
                 }
                 fclose($handle);
             });
             $response->headers->set('Content-Type', 'application/force-download');
             $response->headers->set('Content-Type', 'application/octet-stream');
             $response->headers->set('Content-Disposition', 'attachment; filename="' . $name . '.csv"');
             $response->headers->set('Expires', 0);
             $response->headers->set('Cache-Control', 'must-revalidate');
             $response->headers->set('Pragma', 'public');
             return $response;
         case 'html':
             $content = $this->templatingHelper->getTemplating()->renderResponse('MauticReportBundle:Report:export.html.php', ['data' => $reportData['data'], 'columns' => $reportData['columns'], 'pageTitle' => $name, 'graphs' => $reportData['graphs'], 'report' => $report, 'dateFrom' => $reportData['dateFrom'], 'dateTo' => $reportData['dateTo']])->getContent();
             return new Response($content);
         case 'xlsx':
             if (class_exists('PHPExcel')) {
                 $response = new StreamedResponse(function () use($formatter, $reportData, $report, $name) {
                     $objPHPExcel = new \PHPExcel();
                     $objPHPExcel->getProperties()->setTitle($name);
                     $objPHPExcel->createSheet();
                     $header = [];
                     //build the data rows
                     foreach ($reportData['data'] as $count => $data) {
                         $row = [];
                         foreach ($data as $k => $v) {
                             if ($count === 0) {
                                 //set the header
                                 $header[] = $k;
                             }
                             $row[] = $formatter->_($v, $reportData['columns'][$reportData['dataColumns'][$k]]['type'], true);
                         }
                         //write the row
                         if ($count === 0) {
                             $objPHPExcel->getActiveSheet()->fromArray($header, null, 'A1');
                         } else {
                             $rowCount = $count + 1;
                             $objPHPExcel->getActiveSheet()->fromArray($row, null, "A{$rowCount}");
                         }
                         //free memory
                         unset($row, $reportData['data'][$count]);
                     }
                     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
                     $objWriter->setPreCalculateFormulas(false);
                     $objWriter->save('php://output');
                 });
                 $response->headers->set('Content-Type', 'application/force-download');
                 $response->headers->set('Content-Type', 'application/octet-stream');
                 $response->headers->set('Content-Disposition', 'attachment; filename="' . $name . '.xlsx"');
                 $response->headers->set('Expires', 0);
                 $response->headers->set('Cache-Control', 'must-revalidate');
                 $response->headers->set('Pragma', 'public');
                 return $response;
             }
             throw new \Exception('PHPExcel is required to export to Excel spreadsheets');
         default:
             return new Response();
     }
 }
开发者ID:Yame-,项目名称:mautic,代码行数:95,代码来源:ReportModel.php

示例11: getDirectoryName

 private function getDirectoryName($newName)
 {
     return InputHelper::alphanum($newName, true);
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:4,代码来源:ThemeHelper.php

示例12: array

    $wrapDiv = false;
}
$count = 0;
$firstId = 'mauticform_' . $containerType . '_' . $type . '_' . $field['alias'] . '_' . \Mautic\CoreBundle\Helper\InputHelper::alphanum($list[0]);
$formButtons = !empty($inForm) ? $view->render('MauticFormBundle:Builder:actions.html.php', array('deleted' => !empty($deleted) ? $deleted : false, 'id' => $id, 'formId' => $formId, 'formName' => $formName)) : '';
$label = !$field['showLabel'] ? '' : <<<HTML

                <label {$labelAttr} for="{$firstId}">{$view->escape($field['label'])}</label>
HTML;
$help = empty($field['helpMessage']) ? '' : <<<HTML

                <span class="mauticform-helpmessage">{$field['helpMessage']}</span>
HTML;
$options = array();
foreach ($list as $l) {
    $id = $field['alias'] . '_' . \Mautic\CoreBundle\Helper\InputHelper::alphanum($l);
    $checked = $field['defaultValue'] == $l ? 'checked="checked"' : '';
    $checkboxBrackets = $type == 'checkbox' ? '[]' : '';
    $option = <<<HTML

                    <label id="mauticform_{$containerType}_label_{$id}" for="mauticform_{$containerType}_{$type}_{$id}" {$optionLabelAttr}>
                        <input {$inputAttr}{$checked} name="mauticform[{$field['alias']}]{$checkboxBrackets}" id="mauticform_{$containerType}_{$type}_{$id}" type="{$type}" value="{$view->escape($l)}" />
                        {$view->escape($l)}
                    </label>
HTML;
    if ($wrapDiv) {
        $option = <<<HTML

                <div class="mauticform-{$containerType}-row">{$option}
                </div>
HTML;
开发者ID:Jandersolutions,项目名称:mautic,代码行数:31,代码来源:group.html.php

示例13: strtolower

<?php

/**
 * @package     Mautic
 * @copyright   2014 Mautic Contributors. All rights reserved.
 * @author      Mautic
 * @link        http://mautic.org
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
$formName = strtolower(\Mautic\CoreBundle\Helper\InputHelper::alphanum($form->getName()));
$fields = $form->getFields();
$required = array();
?>

<?php 
echo $view->render($theme . 'MauticFormBundle:Builder:script.html.php', array('form' => $form, 'formName' => $formName));
?>

<?php 
echo $view->render($theme . 'MauticFormBundle:Builder:style.html.php', array('form' => $form, 'formName' => $formName));
?>

<div id="mauticform_wrapper_<?php 
echo $formName;
?>
" class="mauticform_wrapper">
    <form autocomplete="off" target="mauticiframe_<?php 
echo $formName;
?>
" role="form" method="post" action="<?php 
echo $view['router']->generate('mautic_form_postresults', array('formId' => $form->getId()), true);
开发者ID:woakes070048,项目名称:mautic,代码行数:31,代码来源:form.html.php

示例14: applyFilters

 /**
  * @param array        $filters
  * @param QueryBuilder $queryBuilder
  * @param array        $filterDefinitions
  *
  * @return bool
  */
 private function applyFilters(array $filters, QueryBuilder $queryBuilder, array $filterDefinitions)
 {
     $expr = $queryBuilder->expr();
     $filterExpr = $expr->andX();
     if (count($filters)) {
         foreach ($filters as $filter) {
             $exprFunction = isset($filter['expr']) ? $filter['expr'] : $filter['condition'];
             $paramName = InputHelper::alphanum($filter['column']);
             switch ($exprFunction) {
                 case 'notEmpty':
                     $filterExpr->add($expr->isNotNull($filter['column']));
                     $filterExpr->add($expr->neq($filter['column'], $expr->literal('')));
                     break;
                 case 'empty':
                     $filterExpr->add($expr->isNull($filter['column']));
                     $filterExpr->add($expr->eq($filter['column'], $expr->literal('')));
                     break;
                 default:
                     if (trim($filter['value']) == '') {
                         // Ignore empty
                         break;
                     }
                     $columnValue = ":{$paramName}";
                     switch ($filterDefinitions[$filter['column']]['type']) {
                         case 'bool':
                         case 'boolean':
                             if ((int) $filter['value'] > 1) {
                                 // Ignore the "reset" value of "2"
                                 break;
                             }
                             $queryBuilder->setParameter($paramName, $filter['value'], 'boolean');
                             break;
                         case 'float':
                             $columnValue = (double) $filter['value'];
                             break;
                         case 'int':
                         case 'integer':
                             $columnValue = (int) $filter['value'];
                             break;
                         default:
                             $queryBuilder->setParameter($paramName, $filter['value']);
                     }
                     $filterExpr->add($expr->{$exprFunction}($filter['column'], $columnValue));
             }
         }
     }
     if ($filterExpr->count()) {
         $queryBuilder->andWhere($filterExpr);
         return true;
     }
     return false;
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:59,代码来源:MauticReportBuilder.php

示例15: exportAction

 /**
  * Exports the widgets of current user into a json file
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function exportAction()
 {
     /** @var \Mautic\DashboardBundle\Model\DashboardModel $model */
     $model = $this->factory->getModel('dashboard');
     $widgetsPaginator = $model->getWidgets();
     $usersName = $this->factory->getUser()->getName();
     $dateTime = new \DateTime();
     $dateStamp = $dateTime->format('Y-m-d H:i:s');
     $name = $this->request->get('name', 'dashboard-of-' . str_replace(' ', '-', $usersName) . '-' . $dateStamp);
     $description = $this->get('translator')->trans('mautic.dashboard.generated_by', array('%name%' => $usersName, '%date%' => $dateStamp));
     $dashboard = array('name' => $name, 'description' => $description, 'widgets' => array());
     foreach ($widgetsPaginator as $widget) {
         $dashboard['widgets'][] = array('name' => $widget->getName(), 'width' => $widget->getWidth(), 'height' => $widget->getHeight(), 'ordering' => $widget->getOrdering(), 'type' => $widget->getType(), 'params' => $widget->getParams(), 'template' => $widget->getTemplate());
     }
     // Make the filename safe
     $filename = InputHelper::alphanum($name, false, '_') . '.json';
     if ($this->request->get('save', false)) {
         // Save to the user's folder
         $dir = $this->factory->getSystemPath('dashboard.user');
         file_put_contents($dir . '/' . $filename, json_encode($dashboard));
         return $this->redirect($this->get('router')->generate('mautic_dashboard_action', array('objectAction' => 'import')));
     }
     $response = new JsonResponse($dashboard);
     $response->setEncodingOptions($response->getEncodingOptions() | JSON_PRETTY_PRINT);
     $response->headers->set('Content-Length', strlen($response->getContent()));
     $response->headers->set('Content-Type', 'application/force-download');
     $response->headers->set('Content-Type', 'application/octet-stream');
     $response->headers->set('Content-Disposition', 'attachment; filename="' . $filename . '"');
     $response->headers->set('Expires', 0);
     $response->headers->set('Cache-Control', 'must-revalidate');
     $response->headers->set('Pragma', 'public');
     return $response;
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:38,代码来源:DashboardController.php


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