-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap.php
More file actions
75 lines (57 loc) · 2.21 KB
/
bootstrap.php
File metadata and controls
75 lines (57 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Kirby Form Bootstrapper
*
* Include this file to load all essential
* files to initiate a new Kirby Form object
*
* @package Kirby Form
* @author Bastian Allgeier <bastian@getkirby.com>
* @link http://getkirby.com
* @copyright Bastian Allgeier
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
// check for an existing toolkit
if(!defined('KIRBY_TOOLKIT_ROOT')) die('The Kirby Toolkit is required for the Form Builder plugin');
// avoid loading it twice
if(defined('KIRBY_FORM_ROOT')) return;
// define the current location of the form builder plugin
define('KIRBY_FORM_ROOT', __DIR__);
define('KIRBY_FORM_ROOT_LIB', KIRBY_FORM_ROOT . DS . 'lib');
/**
* Overwritable constants
* Define those before including the bootstrapper to set your
* own locations for buttons and fields
*/
if(!defined('KIRBY_FORM_ROOT_DEFAULT_FIELDS')) define('KIRBY_FORM_ROOT_DEFAULT_FIELDS', KIRBY_FORM_ROOT . DS . 'fields');
if(!defined('KIRBY_FORM_ROOT_DEFAULT_BUTTONS')) define('KIRBY_FORM_ROOT_DEFAULT_BUTTONS', KIRBY_FORM_ROOT . DS . 'buttons');
if(!defined('KIRBY_FORM_ROOT_CUSTOM_FIELDS')) define('KIRBY_FORM_ROOT_CUSTOM_FIELDS', false);
if(!defined('KIRBY_FORM_ROOT_CUSTOM_BUTTONS')) define('KIRBY_FORM_ROOT_CUSTOM_BUTTONS', false);
// initialize the autoloader
$autoloader = new Kirby\Toolkit\Autoloader();
// set the base root where all classes are located
$autoloader->root = KIRBY_FORM_ROOT_LIB;
// set the global namespace for all classes
$autoloader->namespace = 'Kirby\\Form';
// start autoloading
$autoloader->start();
// kill the first one to add a new autoloader
// for all field classes
unset($autloader);
// initialize the autoloader
$autoloader = new Kirby\Toolkit\Autoloader();
// set the base root where all classes are located
$autoloader->root = array(
KIRBY_FORM_ROOT_CUSTOM_FIELDS,
KIRBY_FORM_ROOT_DEFAULT_FIELDS,
);
// active loading in separate class folders
$autoloader->classfolder = true;
// set the global namespace for all classes
$autoloader->namespace = 'Kirby\\Form\\Field';
// start autoloading
$autoloader->start();
// start a session if not already started
s::start();
// load the form class
require_once(KIRBY_FORM_ROOT . DS . 'form.php');