Subversion Repositories Applications.papyrus

Rev

Rev 1688 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1463 alexandre_ 1
<?php
2
// +----------------------------------------------------------------------+
3
// | PEAR :: I18Nv2 :: DecoratedList                                      |
4
// +----------------------------------------------------------------------+
5
// | This source file is subject to version 3.0 of the PHP license,       |
6
// | that is available at http://www.php.net/license/3_0.txt              |
7
// | If you did not receive a copy of the PHP license and are unable      |
8
// | to obtain it through the world-wide-web, please send a note to       |
9
// | license@php.net so we can mail you a copy immediately.               |
10
// +----------------------------------------------------------------------+
11
// | Copyright (c) 2004 Michael Wallner <mike@iworks.at>                  |
12
// +----------------------------------------------------------------------+
13
//
14
// $Id: DecoratedList.php,v 1.1 2007-06-25 09:55:28 alexandre_tb Exp $
15
 
16
/**
17
 * I18Nv2::DecoratedList
18
 *
19
 * Decorator for I18Nv2_CommonList objects.
20
 *
21
 * @package     I18Nv2
22
 * @category    Internationalization
23
 */
24
 
25
/**
26
 * I18Nv2_DecoratedList
27
 *
28
 * @author      Michael Wallner <mike@php.net>
29
 * @version     $Revision: 1.1 $
30
 * @package     I18Nv2
31
 * @access      public
32
 */
33
class I18Nv2_DecoratedList
34
{
35
    /**
36
     * I18Nv2_(Common|Decorated)List
37
     *
38
     * @access  protected
39
     * @var     object
40
     */
41
    var $list = null;
42
 
43
    /**
44
     * Constructor
45
     *
46
     * @access  public
47
     * @param   object  $list   I18Nv2_DecoratedList or I18Nv2_CommonList
48
     */
49
    function I18Nv2_DecoratedList(&$list)
50
    {
51
        if (is_a($list, 'I18Nv2_CommonList') ||
52
            is_a($list, 'I18Nv2_DecoratedList')) {
53
            $this->list = &$list;
54
        }
55
    }
56
 
57
    /**
58
     * Get all codes
59
     *
60
     * @access  public
61
     * @return  array
62
     */
63
    function getAllCodes()
64
    {
65
        return $this->decorate($this->list->getAllCodes());
66
    }
67
 
68
    /**
69
     * Check if code is valid
70
     *
71
     * @access  public
72
     * @return  bool
73
     * @param   string  $code
74
     */
75
    function isValidCode($code)
76
    {
77
        return $this->decorate($this->list->isValidCode($code));
78
    }
79
 
80
    /**
81
     * Get name for code
82
     *
83
     * @access  public
84
     * @return  string
85
     * @param   string  $code
86
     */
87
    function getName($code)
88
    {
89
        return $this->decorate($this->list->getName($code));
90
    }
91
 
92
    /**
93
     * Decorate
94
     *
95
     * @abstract
96
     * @access  protected
97
     * @return  mixed
98
     * @param   mixed   $value
99
     */
100
    function decorate($value)
101
    {
102
        return $value;
103
    }
104
 
105
    /**
106
     * Decorate this list
107
     *
108
     * @access  public
109
     * @return  object  I18NV2_DecoratedList
110
     * @param   string  $type
111
     */
112
    function &toDecoratedList($type)
113
    {
114
        require_once 'I18Nv2/DecoratedList/'. $type .'.php';
115
        $decoratedList = 'I18Nv2_DecoratedList_' . $type;
116
        return new $decoratedList($this);
117
    }
118
 
119
    /**
120
     * Change Key Case
121
     *
122
     * @access  protected
123
     * @return  string
124
     * @param   string  $code
125
     */
126
    function changeKeyCase($code)
127
    {
128
        return $this->list->changeKeyCase($code);
129
    }
130
 
131
    /**
132
     * Set active language
133
     *
134
     * Note that each time you set a different language the corresponding
135
     * language file has to be loaded again, too.
136
     *
137
     * @access  public
138
     * @return  bool
139
     * @param   string  $language
140
     */
141
    function setLanguage($language)
142
    {
143
        return $this->list->setLanguage($language);
144
    }
145
 
146
    /**
147
     * Get current language
148
     *
149
     * @access  public
150
     * @return  string
151
     */
152
    function getLanguage()
153
    {
154
        return $this->list->getLanguage();
155
    }
156
 
157
    /**
158
     * Set active encoding
159
     *
160
     * @access  public
161
     * @return  bool
162
     * @param   string  $encoding
163
     */
164
    function setEncoding($encoding)
165
    {
166
        return $this->list->setEncoding($encoding);
167
    }
168
 
169
    /**
170
     * Get current encoding
171
     *
172
     * @access  public
173
     * @return  string
174
     */
175
    function getEncoding()
176
    {
177
        return $this->list->getEncoding();
178
    }
179
}
180
?>