Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Greg Aker | 741de1c | 2010-11-10 14:52:57 -0600 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.1.6 or newer |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
| 18 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 19 | * @package CodeIgniter |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
| 27 | |
| 28 | // ------------------------------------------------------------------------ |
| 29 | |
| 30 | /** |
| 31 | * CodeIgniter Config Class |
| 32 | * |
| 33 | * This class contains functions that enable config files to be managed |
| 34 | * |
| 35 | * @package CodeIgniter |
| 36 | * @subpackage Libraries |
| 37 | * @category Libraries |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 38 | * @author EllisLab Dev Team |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 39 | * @link http://codeigniter.com/user_guide/libraries/config.html |
| 40 | */ |
| 41 | class CI_Config { |
| 42 | |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 43 | /** |
| 44 | * List of all loaded config values |
| 45 | * |
| 46 | * @var array |
| 47 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 48 | public $config = array(); |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 49 | /** |
| 50 | * List of all loaded config files |
| 51 | * |
| 52 | * @var array |
| 53 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 54 | public $is_loaded = array(); |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 55 | /** |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 56 | * List of paths to search when trying to load a config file. |
| 57 | * This must be public as it's used by the Loader class. |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 58 | * |
| 59 | * @var array |
| 60 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 61 | public $_config_paths = array(APPPATH); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * Constructor |
| 65 | * |
| 66 | * Sets the $config data from the primary config.php file as a class variable |
| 67 | * |
Derek Jones | 4b9c629 | 2011-07-01 17:40:48 -0500 | [diff] [blame] | 68 | * @param string the config file name |
| 69 | * @param boolean if configuration values should be loaded into their own section |
| 70 | * @param boolean true if errors should just return false, false if an error message should be displayed |
| 71 | * @return boolean if the file was successfully loaded or not |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 72 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 73 | public function __construct() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 74 | { |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 75 | $this->config =& get_config(); |
Andrey Andreev | d52b242 | 2012-01-07 21:28:32 +0200 | [diff] [blame^] | 76 | log_message('debug', 'Config Class Initialized'); |
Phil Sturgeon | 4df8b22 | 2010-12-15 14:23:14 +0000 | [diff] [blame] | 77 | |
| 78 | // Set the base_url automatically if none was provided |
| 79 | if ($this->config['base_url'] == '') |
| 80 | { |
Pascal Kriete | 5d5895f | 2011-02-14 13:27:07 -0500 | [diff] [blame] | 81 | if (isset($_SERVER['HTTP_HOST'])) |
Phil Sturgeon | 4df8b22 | 2010-12-15 14:23:14 +0000 | [diff] [blame] | 82 | { |
Phil Sturgeon | fb55238 | 2010-12-15 14:29:21 +0000 | [diff] [blame] | 83 | $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 84 | $base_url .= '://'. $_SERVER['HTTP_HOST'] |
| 85 | . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); |
Phil Sturgeon | 4df8b22 | 2010-12-15 14:23:14 +0000 | [diff] [blame] | 86 | } |
Phil Sturgeon | 4df8b22 | 2010-12-15 14:23:14 +0000 | [diff] [blame] | 87 | else |
| 88 | { |
| 89 | $base_url = 'http://localhost/'; |
| 90 | } |
| 91 | |
| 92 | $this->set_item('base_url', $base_url); |
| 93 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 94 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 95 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 96 | // -------------------------------------------------------------------- |
| 97 | |
| 98 | /** |
| 99 | * Load Config File |
| 100 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 101 | * @param string the config file name |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 102 | * @param boolean if configuration values should be loaded into their own section |
| 103 | * @param boolean true if errors should just return false, false if an error message should be displayed |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 104 | * @return boolean if the file was loaded correctly |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 105 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 106 | public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 107 | { |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 108 | $file = ($file == '') ? 'config' : str_replace('.php', '', $file); |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 109 | $found = $loaded = FALSE; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 110 | |
Pascal Kriete | 5d5895f | 2011-02-14 13:27:07 -0500 | [diff] [blame] | 111 | foreach ($this->_config_paths as $path) |
Phil Sturgeon | 05fa611 | 2011-04-06 22:57:43 +0100 | [diff] [blame] | 112 | { |
| 113 | $check_locations = defined('ENVIRONMENT') |
Andrey Andreev | d52b242 | 2012-01-07 21:28:32 +0200 | [diff] [blame^] | 114 | ? array(ENVIRONMENT.'/'.$file, $file) |
Phil Sturgeon | 05fa611 | 2011-04-06 22:57:43 +0100 | [diff] [blame] | 115 | : array($file); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 116 | |
Phil Sturgeon | 05fa611 | 2011-04-06 22:57:43 +0100 | [diff] [blame] | 117 | foreach ($check_locations as $location) |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 118 | { |
Andrey Andreev | d52b242 | 2012-01-07 21:28:32 +0200 | [diff] [blame^] | 119 | $file_path = $path.'config/'.$location.'.php'; |
Phil Sturgeon | 05fa611 | 2011-04-06 22:57:43 +0100 | [diff] [blame] | 120 | |
| 121 | if (in_array($file_path, $this->is_loaded, TRUE)) |
| 122 | { |
| 123 | $loaded = TRUE; |
| 124 | continue 2; |
| 125 | } |
| 126 | |
| 127 | if (file_exists($file_path)) |
| 128 | { |
| 129 | $found = TRUE; |
| 130 | break; |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | if ($found === FALSE) |
| 135 | { |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 136 | continue; |
| 137 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 138 | |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 139 | include($file_path); |
| 140 | |
| 141 | if ( ! isset($config) OR ! is_array($config)) |
| 142 | { |
| 143 | if ($fail_gracefully === TRUE) |
| 144 | { |
| 145 | return FALSE; |
| 146 | } |
| 147 | show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.'); |
| 148 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 149 | |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 150 | if ($use_sections === TRUE) |
| 151 | { |
| 152 | if (isset($this->config[$file])) |
| 153 | { |
| 154 | $this->config[$file] = array_merge($this->config[$file], $config); |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | $this->config[$file] = $config; |
| 159 | } |
| 160 | } |
| 161 | else |
| 162 | { |
| 163 | $this->config = array_merge($this->config, $config); |
| 164 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 165 | |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 166 | $this->is_loaded[] = $file_path; |
| 167 | unset($config); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 168 | |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 169 | $loaded = TRUE; |
| 170 | log_message('debug', 'Config file loaded: '.$file_path); |
katzgrau | d127e61 | 2011-04-22 10:59:25 -0400 | [diff] [blame] | 171 | break; |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 172 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 173 | |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 174 | if ($loaded === FALSE) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 175 | { |
| 176 | if ($fail_gracefully === TRUE) |
| 177 | { |
| 178 | return FALSE; |
| 179 | } |
Greg Aker | 3a74665 | 2011-04-19 10:59:47 -0500 | [diff] [blame] | 180 | show_error('The configuration file '.$file.'.php'.' does not exist.'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 181 | } |
Phil Sturgeon | 05fa611 | 2011-04-06 22:57:43 +0100 | [diff] [blame] | 182 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 183 | return TRUE; |
| 184 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 185 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 186 | // -------------------------------------------------------------------- |
| 187 | |
| 188 | /** |
| 189 | * Fetch a config file item |
| 190 | * |
| 191 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 192 | * @param string the config item name |
| 193 | * @param string the index name |
| 194 | * @param bool |
| 195 | * @return string |
| 196 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 197 | public function item($item, $index = '') |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 198 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 199 | if ($index == '') |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 200 | { |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 201 | return isset($this->config[$item]) ? $this->config[$item] : FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 204 | return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : FALSE; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 205 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 206 | |
| 207 | // -------------------------------------------------------------------- |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 208 | |
| 209 | /** |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 210 | * Fetch a config file item - adds slash after item (if item is not empty) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 211 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 212 | * @param string the config item name |
| 213 | * @param bool |
| 214 | * @return string |
| 215 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 216 | public function slash_item($item) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 217 | { |
| 218 | if ( ! isset($this->config[$item])) |
| 219 | { |
| 220 | return FALSE; |
| 221 | } |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 222 | elseif (trim($this->config[$item]) == '') |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 223 | { |
| 224 | return ''; |
| 225 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 226 | |
Phil Sturgeon | 4df8b22 | 2010-12-15 14:23:14 +0000 | [diff] [blame] | 227 | return rtrim($this->config[$item], '/').'/'; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 228 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 229 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 230 | // -------------------------------------------------------------------- |
| 231 | |
| 232 | /** |
| 233 | * Site URL |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 234 | * Returns base_url . index_page [. uri_string] |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 235 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 236 | * @param string the URI string |
| 237 | * @return string |
| 238 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 239 | public function site_url($uri = '') |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 240 | { |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 241 | if ($uri == '') |
| 242 | { |
Phil Sturgeon | 4df8b22 | 2010-12-15 14:23:14 +0000 | [diff] [blame] | 243 | return $this->slash_item('base_url').$this->item('index_page'); |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | if ($this->item('enable_query_strings') == FALSE) |
| 247 | { |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 248 | $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); |
| 249 | return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; |
| 250 | } |
| 251 | else |
| 252 | { |
| 253 | return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri); |
| 254 | } |
| 255 | } |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 256 | |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 257 | // ------------------------------------------------------------- |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 258 | |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 259 | /** |
| 260 | * Base URL |
| 261 | * Returns base_url [. uri_string] |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 262 | * |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 263 | * @param string $uri |
| 264 | * @return string |
| 265 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 266 | public function base_url($uri = '') |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 267 | { |
| 268 | return $this->slash_item('base_url').ltrim($this->_uri_string($uri),'/'); |
| 269 | } |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 270 | |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 271 | // ------------------------------------------------------------- |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 272 | |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 273 | /** |
| 274 | * Build URI string for use in Config::site_url() and Config::base_url() |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 275 | * |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 276 | * @param mixed $uri |
anaxamaxan@blackdog.local | d09c51a | 2011-02-02 23:00:16 -0800 | [diff] [blame] | 277 | * @return string |
| 278 | */ |
| 279 | protected function _uri_string($uri) |
| 280 | { |
| 281 | if ($this->item('enable_query_strings') == FALSE) |
| 282 | { |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 283 | if (is_array($uri)) |
| 284 | { |
| 285 | $uri = implode('/', $uri); |
| 286 | } |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 287 | return trim($uri, '/'); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 288 | } |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 289 | elseif (is_array($uri)) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 290 | { |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 291 | $i = 0; |
| 292 | $str = ''; |
| 293 | foreach ($uri as $key => $val) |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 294 | { |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 295 | $prefix = ($i === 0) ? '' : '&'; |
| 296 | $str .= $prefix.$key.'='.$val; |
| 297 | $i++; |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 298 | } |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 299 | return $str; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 300 | } |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 301 | |
Greg Aker | 03abee3 | 2011-12-25 00:31:29 -0600 | [diff] [blame] | 302 | return $uri; |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 303 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 304 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 305 | // -------------------------------------------------------------------- |
David Behler | 2d2c9c6 | 2011-08-14 20:03:08 +0200 | [diff] [blame] | 306 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 307 | /** |
| 308 | * System URL |
| 309 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 310 | * @return string |
| 311 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 312 | public function system_url() |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 313 | { |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 314 | $x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH)); |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 315 | return $this->slash_item('base_url').end($x).'/'; |
| 316 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 317 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 318 | // -------------------------------------------------------------------- |
| 319 | |
| 320 | /** |
| 321 | * Set a config file item |
| 322 | * |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 323 | * @param string the config item key |
| 324 | * @param string the config item value |
| 325 | * @return void |
| 326 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 327 | public function set_item($item, $value) |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 328 | { |
| 329 | $this->config[$item] = $value; |
| 330 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 331 | |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 332 | // -------------------------------------------------------------------- |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 333 | |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 334 | /** |
| 335 | * Assign to Config |
| 336 | * |
| 337 | * This function is called by the front controller (CodeIgniter.php) |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 338 | * after the Config class is instantiated. It permits config items |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 339 | * to be assigned or overriden by variables contained in the index.php file |
| 340 | * |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 341 | * @param array |
| 342 | * @return void |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 343 | */ |
Andrey Andreev | ccabcfd | 2012-01-07 19:30:47 +0200 | [diff] [blame] | 344 | public function _assign_to_config($items = array()) |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 345 | { |
| 346 | if (is_array($items)) |
| 347 | { |
| 348 | foreach ($items as $key => $val) |
| 349 | { |
| 350 | $this->set_item($key, $val); |
| 351 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 352 | } |
Derek Jones | 6d743e2 | 2010-03-02 13:22:03 -0600 | [diff] [blame] | 353 | } |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 354 | } |
| 355 | |
Derek Allard | 2067d1a | 2008-11-13 22:59:24 +0000 | [diff] [blame] | 356 | /* End of file Config.php */ |
katzgrau | d127e61 | 2011-04-22 10:59:25 -0400 | [diff] [blame] | 357 | /* Location: ./system/core/Config.php */ |