PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.9.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.9.1
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Admin / Form / Template / TemplateProvider.php

TemplateProvider.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.9.1, at includes/Admin/Form/Template/TemplateProvider.php

81 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Admin\Form\Template;
4
5 use FilesystemIterator;
6
7 final class TemplateProvider
8 {
9 /**
10 * Undocumented function
11 *
12 * @return all
13 */
14 public function getAllTemplates()
15 {
16 return $this->allTemplates();
17 }
18
19 /**
20 * Undocumented function
21 *
22 * @return void
23 */
24 protected function allTemplates()
25 {
26 $dirs = new FilesystemIterator(__DIR__);
27 foreach ($dirs as $dirInfo) {
28 if ($dirInfo->isFile()) {
29 $integartionBaseName = basename($dirInfo);
30 if ('Template.php' === substr($integartionBaseName, -strlen('Template.php'))) {
31 $className = substr($integartionBaseName, 0, strpos($integartionBaseName, '.php'));
32 $className = __NAMESPACE__ . '\\' . $className;
33 $templateDetail = new $className();
34 $Templates[] = [
35 'title' => $templateDetail->getTitle(),
36 'description' => $templateDetail->getDescription(),
37 'status' => $templateDetail->getStatus(),
38 'thumbnail' => $templateDetail->getThumbnail(),
39 'category' => $templateDetail->getCategory()
40 ];
41 }
42 }
43 }
44 return json_encode($Templates);
45 }
46
47 /**
48 * Undocumented function
49 *
50 * @param String $name
51 * @return void
52 */
53 protected function setTemplate($name = 'Contact Form', $newFormId)
54 {
55 $name = is_null($name) ? 'Contact Form' : $name;
56 $name = str_replace(' ', '', $name);
57 $file = false !== strpos($name, 'Template') ? $name . '.php' : $name . 'Template.php';
58 if (file_exists(__DIR__ . '/' . $file)) {
59 $className = __NAMESPACE__ . '\\' . $name . 'Template';
60 $templateDetail = new $className();
61 return [
62 'fields' => json_decode($templateDetail->getFields($newFormId)),
63 'layout' => json_decode($templateDetail->getLayout($newFormId)),
64 'form_name' => $templateDetail->getTitle()
65 ];
66 } else {
67 return false;
68 }
69 }
70
71 /**
72 * This function helps to get TEMPLATE
73 *
74 * @return bool setTemplate()
75 */
76 public function getTemplate($name, $newFormId)
77 {
78 return $this->setTemplate($name, $newFormId);
79 }
80 }
81