-
Notifications
You must be signed in to change notification settings - Fork 1
/
load.php
65 lines (52 loc) · 1.91 KB
/
load.php
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
<?php
/* Constants */
if ( !defined('CNR_DEV') ) {
define('CNR_DEV', ( isset( $_REQUEST['cnr_dev'] ) && !!$_REQUEST['cnr_dev'] ) );
}
/* Class Management */
/**
* Class loading handler
* @param string $classname Class to load
*/
function cnr_autoload($classname) {
$prefix = 'cnr_';
$cls = strtolower($classname);
//Remove prefix
if ( 0 !== strpos($cls, $prefix) ) {
return false;
}
//Format class for filename
$fn = 'class.' . substr($cls, strlen($prefix)) . '.php';
//Build path
$path = dirname(__FILE__) . '/' . "includes/" . $fn;
//Load file
if ( is_readable($path) ) {
require $path;
}
}
// Register autoloader
spl_autoload_register('cnr_autoload');
/* Load Assets */
$path = dirname(__FILE__) . '/';
require_once $path . 'controller.php';
require_once $path . 'functions.php';
/* Variables */
//Global content type variables
if ( !isset($GLOBALS['cnr_content_types']) )
$GLOBALS['cnr_content_types'] = array();
if ( !isset($GLOBALS['cnr_field_types']) )
$GLOBALS['cnr_field_types'] = array();
/* Init */
$GLOBALS['cnr_content_utilities'] = new CNR_Content_Utilities();
$GLOBALS['cnr_content_utilities']->init();
/* Hooks */
// Register Default placeholder handlers
cnr_register_placeholder_handler('all', array('CNR_Field_Type', 'process_placeholder_default'), 11);
cnr_register_placeholder_handler('field_id', array('CNR_Field_Type', 'process_placeholder_id'));
cnr_register_placeholder_handler('field_name', array('CNR_Field_Type', 'process_placeholder_name'));
cnr_register_placeholder_handler('data', array('CNR_Field_Type', 'process_placeholder_data'));
cnr_register_placeholder_handler('loop', array('CNR_Field_Type', 'process_placeholder_loop'));
cnr_register_placeholder_handler('data_ext', array('CNR_Field_Type', 'process_placeholder_data_ext'));
cnr_register_placeholder_handler('rich_editor', array('CNR_Field_Type', 'process_placeholder_rich_editor'));
/* Start */
$GLOBALS['cnr'] = new Cornerstone();