Example #1
0
 public function replaceString($string, $arraySeparator = ', ')
 {
     if (!$this->submission->fieldsubmissions) {
         $this->submission->getFieldsubmissions();
     }
     $string = preg_replace_callback('/\\$\\$(.+?)\\$\\$/is', function ($matches) use($arraySeparator) {
         $placeholder = explode(':', trim($matches[1]), 2);
         if (empty($placeholder[1]) || !isset($this->submission->fieldsubmissions[$placeholder[0]]) || !isset($this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]])) {
             return '';
         }
         return is_array($this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]]) ? implode($arraySeparator, $this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]]) : $this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]];
     }, $string);
     return $string;
 }
Example #2
0
 public function replaceString($string, $arraySeparator = ', ')
 {
     if (!$this->submission->fieldsubmissions) {
         $this->submission->getFieldsubmissions();
     }
     $string = preg_replace_callback('/\\$\\$(.+?)\\$\\$/is', function ($matches) use($arraySeparator) {
         $placeholder = explode(':', trim($matches[1]), 2);
         if (!empty($placeholder[1]) && $placeholder[0] == 'submission' && property_exists($this->submission, $placeholder[1])) {
             $key = $placeholder[1];
             return $key == 'created' ? $this->submission->{$key}->format('Y-m-d H:i:s') : $this->submission->{$key};
         }
         if (empty($placeholder[1]) || !isset($this->submission->fieldsubmissions[$placeholder[0]]) || !isset($this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]])) {
             return '';
         }
         return is_array($this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]]) ? implode($arraySeparator, $this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]]) : $this->submission->fieldsubmissions[$placeholder[0]][$placeholder[1]];
     }, $string);
     return $string;
 }
Example #3
0
 /**
  * Prepare form for display
  * @param App $app
  * @param \Bixie\Formmaker\FormmakerModule $formmaker
  */
 public function prepareView($app, $formmaker)
 {
     $form = $this;
     if ($this->get('recaptcha') && $formmaker->config('recaptha_secret_key')) {
         $app->on('view.footer', function ($event) {
             $event->addResult('<script src="https://www.google.com/recaptcha/api.js?onload=grecacapthaCallback&render=explicit" async defer></script>');
         });
     }
     $app->on('view.styles', function ($event, $styles) use($formmaker) {
         foreach ($this->getFields() as $field) {
             $formmaker->getFieldType($field->type)->addStyles($styles);
         }
     });
     $app->on('view.data', function ($event, $data) use($form, $formmaker) {
         $data->add('$formmaker', ['config' => $formmaker->publicConfig(), 'formitem' => $form, 'submission' => Submission::initData($form), 'fields' => array_values($form->getFields())]);
         $data->add('$fieldtypes', ['ajax_url' => 'api/formmaker/submission/ajax']);
     });
 }
 /**
  * @Route("/csv", methods="POST")
  * @Request({"options": "array"}, csrf=true)
  */
 public function exportCsvAction($options = [])
 {
     $csvString = '';
     $options = new ArrObject($options);
     if ($form_id = $options->get('form_id', 0)) {
         //get forminfo
         $form = Form::find($form_id);
         //get submissions
         $query = Submission::query();
         $query->where(['form_id = ?'], [$form_id])->whereIn('status', $options->get('status', []));
         //input cleaned?
         $submissions = $query->orderBy('created', 'desc')->get();
         $csvString = (new CsvHelper($submissions, $form, $options))->toCsv();
         if ($options->get('mark_archived', false)) {
             Submission::query()->whereIn('id', array_keys($submissions))->update(['status' => Submission::STATUS_ARCHIVED]);
         }
     } else {
         App::abort(404, 'Not a single form was given.');
     }
     return ['csv' => $csvString];
 }
 /**
  * @Route("/submissions", methods="GET")
  * @Request({"filter": "array", "page":"int"})
  */
 public function submissionsAction($filter = null, $page = 0)
 {
     return ['$view' => ['title' => __('Submissions'), 'name' => 'bixie/formmaker/admin/submissions.php'], '$data' => ['forms' => array_values(Form::query()->get()), 'statuses' => Submission::getStatuses(), 'config' => ['filter' => $filter, 'page' => $page]]];
 }
 /**
  * @Route("/submissions", methods="GET")
  * @Request({"filter": "array", "page":"int"})
  */
 public function submissionsAction($filter = null, $page = 0)
 {
     $formmaker = App::module('bixie/formmaker');
     return ['$view' => ['title' => __('Submissions'), 'name' => 'bixie/formmaker/admin/submissions.php'], '$data' => ['forms' => array_values(Form::query()->get()), 'statuses' => Submission::getStatuses(), 'config' => ['filter' => $filter, 'page' => $page]], 'frameworkValid' => $formmaker->checkFramework()];
 }