Viewing File core/Language.php of 0.01.1a
|
1: <?php 2: /* ------------------------------------------------------------- 3: This file is part of FreeDESK 4: 5: FreeDESK is (C) Copyright 2012 David Cutting 6: 7: FreeDESK is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeDESK is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeDESK. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freedesk/ 21: -------------------------------------------------------------- */ 22: 23: /** 24: * FreeDESK Language Class 25: **/ 26: class Language 27: { 28: /** 29: * FreeDESK Instance 30: **/ 31: private $DESK = null; 32: 33: /** 34: * Default Language 35: **/ 36: private $default = "English"; 37: 38: /** 39: * Language Items 40: **/ 41: private $items = array(); 42: 43: /** 44: * Constructor 45: * @param mixed &$freeDESK FreeDESK instance 46: **/ 47: function Language(&$freeDESK) 48: { 49: $this->DESK = &$freeDESK; 50: $this->default = $this->DESK->Configuration->Get("language.default","English"); 51: $this->Load($this->default, true); 52: } 53: 54: /** 55: * Load Language 56: * @param string $language 57: * @param bool $override Override already-loaded check (optional, default false) 58: * @return bool True on success or false on failure 59: **/ 60: function Load($language, $override=false) 61: { 62: if (!$override && ($language == $this->default)) 63: return true; // already loaded 64: $class="FDL_".$language; 65: $this->DESK->Include->IncludeFile("language/".$language.".php", false, true); 66: if (class_exists($class)) 67: $class::$language($this->items); 68: else 69: return false; 70: return true; 71: } 72: 73: /** 74: * Get a language element 75: * @param string $element Language element 76: **/ 77: function Get($element) 78: { 79: if (isset($this->items[$element])) 80: return $this->items[$element]; 81: else 82: return "ULE:".$element; 83: } 84: 85: } 86: ?> 87: