| 1 |
<?php |
| 2 |
|
| 3 |
/* Constants */ |
| 4 |
|
| 5 |
if ( !defined('CNR_DEV') ) { |
| 6 |
define('CNR_DEV', ( isset( $_REQUEST['cnr_dev'] ) && !!$_REQUEST['cnr_dev'] ) ); |
| 7 |
} |
| 8 |
|
| 9 |
/* Class Management */ |
| 10 |
|
| 11 |
/** |
| 12 |
* Class loading handler |
| 13 |
* @param string $classname Class to load |
| 14 |
*/ |
| 15 |
function cnr_autoload($classname) { |
| 16 |
$prefix = 'cnr_'; |
| 17 |
$cls = strtolower($classname); |
| 18 |
//Remove prefix |
| 19 |
if ( 0 !== strpos($cls, $prefix) ) { |
| 20 |
return false; |
| 21 |
} |
| 22 |
//Format class for filename |
| 23 |
$fn = 'class.' . substr($cls, strlen($prefix)) . '.php'; |
| 24 |
//Build path |
| 25 |
$path = dirname(__FILE__) . '/' . "includes/" . $fn; |
| 26 |
//Load file |
| 27 |
if ( is_readable($path) ) { |
| 28 |
require $path; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
// Register autoloader |
| 33 |
spl_autoload_register('cnr_autoload'); |
| 34 |
|
| 35 |
/* Load Assets */ |
| 36 |
$path = dirname(__FILE__) . '/'; |
| 37 |
require_once $path . 'controller.php'; |
| 38 |
require_once $path . 'functions.php'; |
| 39 |
|
| 40 |
/* Variables */ |
| 41 |
|
| 42 |
//Global content type variables |
| 43 |
if ( !isset($GLOBALS['cnr_content_types']) ) |
| 44 |
$GLOBALS['cnr_content_types'] = array(); |
| 45 |
if ( !isset($GLOBALS['cnr_field_types']) ) |
| 46 |
$GLOBALS['cnr_field_types'] = array(); |
| 47 |
|
| 48 |
/* Init */ |
| 49 |
$GLOBALS['cnr_content_utilities'] = new CNR_Content_Utilities(); |
| 50 |
$GLOBALS['cnr_content_utilities']->init(); |
| 51 |
|
| 52 |
/* Hooks */ |
| 53 |
|
| 54 |
// Register Default placeholder handlers |
| 55 |
cnr_register_placeholder_handler('all', array('CNR_Field_Type', 'process_placeholder_default'), 11); |
| 56 |
cnr_register_placeholder_handler('field_id', array('CNR_Field_Type', 'process_placeholder_id')); |
| 57 |
cnr_register_placeholder_handler('field_name', array('CNR_Field_Type', 'process_placeholder_name')); |
| 58 |
cnr_register_placeholder_handler('data', array('CNR_Field_Type', 'process_placeholder_data')); |
| 59 |
cnr_register_placeholder_handler('loop', array('CNR_Field_Type', 'process_placeholder_loop')); |
| 60 |
cnr_register_placeholder_handler('data_ext', array('CNR_Field_Type', 'process_placeholder_data_ext')); |
| 61 |
cnr_register_placeholder_handler('rich_editor', array('CNR_Field_Type', 'process_placeholder_rich_editor')); |
| 62 |
|
| 63 |
/* Start */ |
| 64 |
|
| 65 |
$GLOBALS['cnr'] = new Cornerstone(); |