1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | <?php /** * GitPHP Resource * * Resource factory * * @author Christopher Han <xiphux@gmail.com> * @copyright Copyright (c) 2010 Christopher Han * @package GitPHP */ require_once(GITPHP_BASEDIR . 'lib/php-gettext/streams.php'); require_once(GITPHP_BASEDIR . 'lib/php-gettext/gettext.php'); /** * Resource * * @package GitPHP * @subpackage Resource */ class GitPHP_Resource { /** * instance * * Stores the singleton instance of the resource provider * * @access protected * @static */ protected static $instance = null; /** * currentLocale * * Stores the currently instantiated locale identifier * * @access protected * @static */ protected static $currentLocale = ''; /** * GetInstance * * Returns the singleton instance * * @access public * @static * @return mixed instance of resource class */ public static function GetInstance() { return self::$instance; } /** * Instantiated * * Tests if the resource provider has been instantiated * * @access public * @static * @return boolean true if resource provider is instantiated */ public static function Instantiated() { return (self::$instance !== null); } /** * GetLocale * * Gets the currently instantiated locale * * @access public * @static * @return string locale identifier */ public static function GetLocale() { return self::$currentLocale; } /** * Instantiate * * Instantiates the singleton instance * * @access public * @static * @param string $locale locale to instantiate * @return boolean true if resource provider was instantiated successfully */ public static function Instantiate($locale) { self::$instance = null; self::$currentLocale = ''; $reader = null; if (!(($locale == 'en_US') || ($locale == 'en'))) { $reader = new FileReader(GITPHP_LOCALEDIR . $locale . '/gitphp.mo'); if (!$reader) return false; } self::$instance = new gettext_reader($reader); self::$currentLocale = $locale; return true; } } |