Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | // Set up the global CI functions in their most minimal core representation |
| 4 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 5 | if ( ! function_exists('get_instance')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 6 | { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 7 | function &get_instance() |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 8 | { |
| 9 | $test = CI_TestCase::instance(); |
Andrey Andreev | 36de42e | 2012-06-10 13:55:55 +0300 | [diff] [blame] | 10 | $test = $test->ci_instance(); |
| 11 | return $test; |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 12 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 13 | } |
| 14 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 15 | // -------------------------------------------------------------------- |
| 16 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 17 | if ( ! function_exists('get_config')) |
| 18 | { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 19 | function &get_config() |
| 20 | { |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 21 | $test = CI_TestCase::instance(); |
Andrey Andreev | 62fd52d | 2012-06-10 07:11:41 +0300 | [diff] [blame] | 22 | $config = $test->ci_get_config(); |
| 23 | return $config; |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 24 | } |
| 25 | } |
| 26 | |
| 27 | if ( ! function_exists('config_item')) |
| 28 | { |
| 29 | function config_item($item) |
| 30 | { |
| 31 | $config =& get_config(); |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 32 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 33 | if ( ! isset($config[$item])) |
| 34 | { |
Andrey Andreev | d444d44 | 2014-10-06 00:00:08 +0300 | [diff] [blame] | 35 | return NULL; |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 36 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 37 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 38 | return $config[$item]; |
Pascal Kriete | 88b2963 | 2011-04-21 01:21:55 -0400 | [diff] [blame] | 39 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 40 | } |
| 41 | |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 42 | if ( ! function_exists('get_mimes')) |
| 43 | { |
| 44 | /** |
| 45 | * Returns the MIME types array from config/mimes.php |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | function &get_mimes() |
| 50 | { |
| 51 | static $_mimes = array(); |
| 52 | |
| 53 | if (empty($_mimes)) |
| 54 | { |
| 55 | $path = realpath(PROJECT_BASE.'application/config/mimes.php'); |
| 56 | if (is_file($path)) |
| 57 | { |
| 58 | $_mimes = include($path); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return $_mimes; |
| 63 | } |
| 64 | } |
| 65 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 66 | // -------------------------------------------------------------------- |
| 67 | |
Andrey Andreev | c26b9eb | 2014-02-24 11:31:36 +0200 | [diff] [blame] | 68 | /* |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 69 | if ( ! function_exists('load_class')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 70 | { |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 71 | function load_class($class, $directory = 'libraries', $prefix = 'CI_') |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 72 | { |
Alex Bilbie | d6d1150 | 2012-06-02 11:12:55 +0100 | [diff] [blame] | 73 | if ($directory !== 'core' OR $prefix !== 'CI_') |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 74 | { |
| 75 | throw new Exception('Not Implemented: Non-core load_class()'); |
| 76 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 77 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 78 | $test = CI_TestCase::instance(); |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 79 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 80 | $obj =& $test->ci_core_class($class); |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 81 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 82 | if (is_string($obj)) |
| 83 | { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 84 | throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class); |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 85 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 86 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 87 | return $obj; |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 88 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 89 | } |
Andrey Andreev | c26b9eb | 2014-02-24 11:31:36 +0200 | [diff] [blame] | 90 | */ |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 91 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 92 | // Clean up error messages |
| 93 | // -------------------------------------------------------------------- |
| 94 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 95 | if ( ! function_exists('show_error')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 96 | { |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 97 | function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') |
| 98 | { |
| 99 | throw new RuntimeException('CI Error: '.$message); |
| 100 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 101 | } |
| 102 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 103 | if ( ! function_exists('show_404')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 104 | { |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 105 | function show_404($page = '', $log_error = TRUE) |
| 106 | { |
| 107 | throw new RuntimeException('CI Error: 404'); |
| 108 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 109 | } |
| 110 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 111 | if ( ! function_exists('_exception_handler')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 112 | { |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 113 | function _exception_handler($severity, $message, $filepath, $line) |
| 114 | { |
| 115 | throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line); |
| 116 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 117 | } |
| 118 | |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 119 | // We assume a few things about our environment ... |
| 120 | // -------------------------------------------------------------------- |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 121 | if ( ! function_exists('is_loaded')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 122 | { |
dchill42 | 4f42be5 | 2012-10-21 21:31:19 -0400 | [diff] [blame] | 123 | function &is_loaded() |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 124 | { |
dchill42 | 4f42be5 | 2012-10-21 21:31:19 -0400 | [diff] [blame] | 125 | $loaded = array(); |
| 126 | return $loaded; |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 127 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 128 | } |
| 129 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 130 | if ( ! function_exists('log_message')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 131 | { |
Andrey Andreev | 838c9a9 | 2013-09-13 14:05:13 +0300 | [diff] [blame] | 132 | function log_message($level, $message) |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 133 | { |
| 134 | return TRUE; |
| 135 | } |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 136 | } |
| 137 | |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 138 | if ( ! function_exists('set_status_header')) |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 139 | { |
Taufan Aditya | b2e10b7 | 2012-05-27 15:31:53 +0700 | [diff] [blame] | 140 | function set_status_header($code = 200, $text = '') |
| 141 | { |
| 142 | return TRUE; |
| 143 | } |
Andrey Andreev | f964b16 | 2013-11-12 17:04:55 +0200 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | if ( ! function_exists('is_cli')) |
| 147 | { |
| 148 | // In order to test HTTP functionality, we need to lie about this |
| 149 | function is_cli() |
| 150 | { |
| 151 | return FALSE; |
| 152 | } |
dchill42 | 4f42be5 | 2012-10-21 21:31:19 -0400 | [diff] [blame] | 153 | } |