PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.9
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.9
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 1.9, at includes/Admin/Form/Template/TemplateProvider.php

78 lines 2.4 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 * Undocumented function
20 *
21 * @return void
22 */
23 protected function allTemplates()
24 {
25 $dirs = new FilesystemIterator(__DIR__);
26 foreach ($dirs as $dirInfo) {
27 if ($dirInfo->isFile()) {
28 $integartionBaseName = basename($dirInfo);
29 if (substr($integartionBaseName, -strlen('Template.php')) === 'Template.php') {
30 $className = substr($integartionBaseName, 0, strpos($integartionBaseName, '.php'));
31 $className = __NAMESPACE__ . '\\' . $className;
32 $templateDetail = new $className;
33 $Templates[] = array(
34 'title' => $templateDetail->getTitle(),
35 'description' => $templateDetail->getDescription(),
36 'status' => $templateDetail->getStatus(),
37 'thumbnail' => $templateDetail->getThumbnail(),
38 'category' => $templateDetail->getCategory()
39 );
40 }
41 }
42 }
43 return json_encode($Templates);
44 }
45 /**
46 * Undocumented function
47 *
48 * @param String $name
49 * @return void
50 */
51 protected function setTemplate($name = 'Contact Form', $newFormId)
52 {
53 $name = is_null($name) ? 'Contact Form' : $name;
54 $name = str_replace(' ', null, $name);
55 $file = strpos($name, 'Template') !== false ? $name . '.php' : $name . 'Template.php';
56 if (file_exists(__DIR__ . '/' . $file)) {
57 $className = __NAMESPACE__ . '\\' . $name . 'Template';
58 $templateDetail = new $className;
59 return array(
60 'fields' => json_decode($templateDetail->getFields($newFormId)),
61 'layout' => json_decode($templateDetail->getLayout($newFormId)),
62 'form_name' => $templateDetail->getTitle()
63 );
64 } else {
65 return false;
66 }
67 }
68 /**
69 * This function helps to get TEMPLATE
70 *
71 * @return bool setTemplate()
72 */
73 public function getTemplate($name, $newFormId)
74 {
75 return $this->setTemplate($name, $newFormId);
76 }
77 }
78