forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zend_Currency-Description.xml
170 lines (132 loc) · 5.45 KB
/
Zend_Currency-Description.xml
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?xml version="1.0" encoding="utf-8"?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="zend.currency.description"><info><title>What makes a currency?</title></info>
<para>
The currency consists of several informations. A name, a abbreviation and a sign. Each
of these could be relevant to be displayed, but only one at the same time. It would not
be a good practice to display something like "USD 1.000 $".
</para>
<para>
Therefor <classname>Zend_Currency</classname> supports the definition of the currency
information which has to be rendered. The following constants can be used:
</para>
<table xml:id="zend.currency.description.table-1"><info><title>Rendered informations for a currency</title></info>
<tgroup cols="2" align="left">
<thead>
<row>
<entry>Constant</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><constant>NO_SYMBOL</constant></entry>
<entry>No currency representation will be rendered at all</entry>
</row>
<row>
<entry><constant>USE_SYMBOL</constant></entry>
<entry>
The currency symbol will be rendered. For US Dollar this would be '$'
</entry>
</row>
<row>
<entry><constant>USE_SHORTNAME</constant></entry>
<entry>
The abbreviation for this currency will be rendered. For US Dollar this
would be 'USD'. Most abbreviations consist of 3 characters
</entry>
</row>
<row>
<entry><constant>USE_NAME</constant></entry>
<entry>
The full name for this currency will be rendered. For US Dollar the full
name would be "US Dollar"
</entry>
</row>
</tbody>
</tgroup>
</table>
<example xml:id="zend.currency.description.example-1"><info><title>Selecting the currency description</title></info>
<para>
Let's assume that your client has again set "en_US" as locale. Using no option the
returned value could look like this:
</para>
<programlisting language="php"><![CDATA[
$currency = new Zend_Currency(
array(
'value' => 100,
)
);
print $currency; // Could return '$ 100'
]]></programlisting>
<para>
By giving the proper option you can define what information which has to be
rendered.
</para>
<programlisting language="php"><![CDATA[
$currency = new Zend_Currency(
array(
'value' => 100,
'display' => Zend_Currency::USE_SHORTNAME,
)
);
print $currency; // Could return 'USD 100'
]]></programlisting>
<para>
Without providing the <property>display</property> the currency sign will be used
when rendering the object. When the currency has no sign, the abbreviation will be
used as replacement.
</para>
</example>
<note><info><title>Not all currencies have signs</title></info>
<para>
You should note that not all currencies have default currency signs. This means,
that when there is no default sign, and you set the sign to be rendered, you will
not have a rendered currency at all because the sign is an empty string.
</para>
</note>
<para>
Sometimes it is necessary to change the default informations. You can set each of the
three currency informations independently by giving the proper option. See the following
example.
</para>
<example xml:id="zend.currency.description.example-2"><info><title>Changing the currency description</title></info>
<para>
Let's assume that your client has again set "en_US" as locale. But now we don't want
to use the default settings but set our own description. This can simply be done
providing the proper option:
</para>
<programlisting language="php"><![CDATA[
$currency = new Zend_Currency(
array(
'value' => 100,
'name' => 'Dollar',
)
);
print $currency; // Could return 'Dollar 100'
]]></programlisting>
<para>
You could also set a sign or an abbreviations yourself.
</para>
<programlisting language="php"><![CDATA[
$currency = new Zend_Currency(
array(
'value' => 100,
'symbol' => '$$$',
)
);
print $currency; // Could return '$$$ 100'
]]></programlisting>
</example>
<note><info><title>Automatic display settings</title></info>
<para>
When you set a name, abbreviation or sign yourself, than this new information will
automatically be set to be rendered. This simplification prevents you from setting
the proper <property>display</property> option when you set a information.
</para>
<para>
So using the <property>sign</property> option you can omit
<property>display</property> and don't neet to setting it to
'<constant>USE_SYMBOL</constant>'.
</para>
</note>
</section>