[289] | 1 | <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 4 | * Modular Extensions - HMVC
|
---|
| 5 | *
|
---|
| 6 | * Adapted from the CodeIgniter Core Classes
|
---|
| 7 | * @link http://codeigniter.com
|
---|
| 8 | *
|
---|
| 9 | * Description:
|
---|
| 10 | * This library extends the CodeIgniter CI_Language class
|
---|
| 11 | * and adds features allowing use of modules and the HMVC design pattern.
|
---|
| 12 | *
|
---|
| 13 | * Install this file as application/third_party/MX/Lang.php
|
---|
| 14 | *
|
---|
| 15 | * @copyright Copyright (c) 2011 Wiredesignz
|
---|
| 16 | * @version 5.4
|
---|
| 17 | *
|
---|
| 18 | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
---|
| 19 | * of this software and associated documentation files (the "Software"), to deal
|
---|
| 20 | * in the Software without restriction, including without limitation the rights
|
---|
| 21 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
---|
| 22 | * copies of the Software, and to permit persons to whom the Software is
|
---|
| 23 | * furnished to do so, subject to the following conditions:
|
---|
| 24 | *
|
---|
| 25 | * The above copyright notice and this permission notice shall be included in
|
---|
| 26 | * all copies or substantial portions of the Software.
|
---|
| 27 | *
|
---|
| 28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
| 29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
| 30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
---|
| 31 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
---|
| 32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
---|
| 33 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
---|
| 34 | * THE SOFTWARE.
|
---|
| 35 | **/
|
---|
| 36 | class MX_Lang extends CI_Lang
|
---|
| 37 | {
|
---|
| 38 | public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') {
|
---|
| 39 |
|
---|
| 40 | if (is_array($langfile)) {
|
---|
| 41 | foreach($langfile as $_lang) $this->load($_lang);
|
---|
| 42 | return $this->language;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | $deft_lang = CI::$APP->config->item('language');
|
---|
| 46 | $idiom = ($lang == '') ? $deft_lang : $lang;
|
---|
| 47 |
|
---|
| 48 | if (in_array($langfile.'_lang'.EXT, $this->is_loaded, TRUE))
|
---|
| 49 | return $this->language;
|
---|
| 50 |
|
---|
| 51 | $_module OR $_module = CI::$APP->router->fetch_module();
|
---|
| 52 | list($path, $_langfile) = Modules::find($langfile.'_lang', $_module, 'language/'.$idiom.'/');
|
---|
| 53 |
|
---|
| 54 | if ($path === FALSE) {
|
---|
| 55 |
|
---|
| 56 | if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) return $lang;
|
---|
| 57 |
|
---|
| 58 | } else {
|
---|
| 59 |
|
---|
| 60 | if($lang = Modules::load_file($_langfile, $path, 'lang')) {
|
---|
| 61 | if ($return) return $lang;
|
---|
| 62 | $this->language = array_merge($this->language, $lang);
|
---|
| 63 | $this->is_loaded[] = $langfile.'_lang'.EXT;
|
---|
| 64 | unset($lang);
|
---|
| 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | return $this->language;
|
---|
| 69 | }
|
---|
| 70 | } |
---|