Remove unnecessary old resource classes, move resource class out of resource subpackage since it's the only resource file now
[gitphp.git] / include / Resource.class.php
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
<?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;
 
        /**
         * GetInstance
         *
         * Returns the singleton instance
         *
         * @access public
         * @static
         * @return mixed instance of resource class
         * @throws Exception if resource provider has not been instantiated yet
         */
        public static function GetInstance()
        {
                return self::$instance;
        }
 
        /**
         * Instantiate
         *
         * Instantiates the singleton instance
         *
         * @access public
         * @static
         * @param string $locale locale to instantiate
         * @throws Exception on invalid locale
         */
        public static function Instantiate($locale)
        {
                $reader = null;
 
                if (!(($locale == 'en_US') || ($locale == 'en'))) {
                        $reader = new FileReader(GITPHP_LOCALEDIR . $locale . '/LC_MESSAGES/gitphp.mo');
                }
 
                self::$instance = new gettext_reader($reader);
        }
 
}
 
comments