@@ -5,7 +5,7 @@ |
||
5 | 5 | * @link https://github.com/pradosoft/prado |
6 | 6 | * @copyright Copyright © 2005-2016 The PRADO Group |
7 | 7 | * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT |
8 | - * @package Prado\Data\ActiveRecord\Scaffold\InputBuilder |
|
8 | + * @package Prado\Data\ActiveRecord\Scaffold\InputBuilder |
|
9 | 9 | */ |
10 | 10 | |
11 | 11 | namespace Prado\Data\ActiveRecord\Scaffold\InputBuilder; |
@@ -1032,26 +1032,26 @@ |
||
1032 | 1032 | return isset(self::$_relations[get_class($this)][strtolower($property)]); |
1033 | 1033 | } |
1034 | 1034 | |
1035 | - /** |
|
1036 | - * Return record data as array |
|
1037 | - * @return array of column name and column values |
|
1038 | - * @since 3.2.4 |
|
1039 | - */ |
|
1040 | - public function toArray(){ |
|
1041 | - $result=array(); |
|
1042 | - foreach($this->getRecordTableInfo()->getLowerCaseColumnNames() as $columnName){ |
|
1043 | - $result[$columnName]=$this->getColumnValue($columnName); |
|
1044 | - } |
|
1035 | + /** |
|
1036 | + * Return record data as array |
|
1037 | + * @return array of column name and column values |
|
1038 | + * @since 3.2.4 |
|
1039 | + */ |
|
1040 | + public function toArray(){ |
|
1041 | + $result=array(); |
|
1042 | + foreach($this->getRecordTableInfo()->getLowerCaseColumnNames() as $columnName){ |
|
1043 | + $result[$columnName]=$this->getColumnValue($columnName); |
|
1044 | + } |
|
1045 | 1045 | |
1046 | - return $result; |
|
1047 | - } |
|
1046 | + return $result; |
|
1047 | + } |
|
1048 | 1048 | |
1049 | - /** |
|
1050 | - * Return record data as JSON |
|
1051 | - * @return JSON |
|
1052 | - * @since 3.2.4 |
|
1053 | - */ |
|
1054 | - public function toJSON(){ |
|
1055 | - return json_encode($this->toArray()); |
|
1056 | - } |
|
1049 | + /** |
|
1050 | + * Return record data as JSON |
|
1051 | + * @return JSON |
|
1052 | + * @since 3.2.4 |
|
1053 | + */ |
|
1054 | + public function toJSON(){ |
|
1055 | + return json_encode($this->toArray()); |
|
1056 | + } |
|
1057 | 1057 | } |
1058 | 1058 | \ No newline at end of file |
@@ -24,48 +24,48 @@ |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | /** |
27 | - * To format numbers in locale sensitive manner use |
|
28 | - * <code> |
|
29 | - * <com:TNumberFormat Pattern="0.##" value="2.0" /> |
|
30 | - * </code> |
|
31 | - * |
|
32 | - * Numbers can be formatted as currency, percentage, decimal or scientific |
|
33 | - * numbers by specifying the Type attribute. The known types are |
|
34 | - * "currency", "percentage", "decimal" and "scientific". |
|
35 | - * |
|
36 | - * If someone from US want to see sales figures from a store in |
|
37 | - * Germany (say using the EURO currency), formatted using the german |
|
38 | - * currency, you would need to use the attribute Culture="de_DE" to get |
|
39 | - * the currency right, e.g. 100,00. The decimal and grouping separator is |
|
40 | - * then also from the de_DE locale. This may lead to some confusion because |
|
41 | - * people from US know the "," as thousand separator. Therefore a "Currency" |
|
42 | - * attribute is available, so that the output from the following example |
|
43 | - * results in 100.00. |
|
44 | - * <code> |
|
45 | - * <com:TNumberFormat Type="currency" Culture="en_US" Currency="EUR" Value="100" /> |
|
46 | - * </code> |
|
47 | - * |
|
48 | - * Namespace: System.I18N |
|
49 | - * |
|
50 | - * Properties |
|
51 | - * - <b>Value</b>, number, |
|
52 | - * <br>Gets or sets the number to format. The tag content is used as Value |
|
53 | - * if the Value property is not specified. |
|
54 | - * - <b>Type</b>, string, |
|
55 | - * <br>Gets or sets the formatting type. The valid types are |
|
56 | - * 'decimal', 'currency', 'percentage' and 'scientific'. |
|
57 | - * - <b>Currency</b>, string, |
|
58 | - * <br>Gets or sets the currency symbol for the currency format. |
|
59 | - * The default is 'USD' if the Currency property is not specified. |
|
60 | - * - <b>Pattern</b>, string, |
|
61 | - * <br>Gets or sets the custom number formatting pattern. |
|
62 | - * - <b>DefaultText</b>, string, |
|
63 | - * <br>Gets or sets the default text. If Value is not set, DefaultText will be |
|
64 | - * shown instead of the default currency Value/Pattern. |
|
65 | - * |
|
66 | - * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
67 | - * @package Prado\I18N |
|
68 | - */ |
|
27 | + * To format numbers in locale sensitive manner use |
|
28 | + * <code> |
|
29 | + * <com:TNumberFormat Pattern="0.##" value="2.0" /> |
|
30 | + * </code> |
|
31 | + * |
|
32 | + * Numbers can be formatted as currency, percentage, decimal or scientific |
|
33 | + * numbers by specifying the Type attribute. The known types are |
|
34 | + * "currency", "percentage", "decimal" and "scientific". |
|
35 | + * |
|
36 | + * If someone from US want to see sales figures from a store in |
|
37 | + * Germany (say using the EURO currency), formatted using the german |
|
38 | + * currency, you would need to use the attribute Culture="de_DE" to get |
|
39 | + * the currency right, e.g. 100,00. The decimal and grouping separator is |
|
40 | + * then also from the de_DE locale. This may lead to some confusion because |
|
41 | + * people from US know the "," as thousand separator. Therefore a "Currency" |
|
42 | + * attribute is available, so that the output from the following example |
|
43 | + * results in 100.00. |
|
44 | + * <code> |
|
45 | + * <com:TNumberFormat Type="currency" Culture="en_US" Currency="EUR" Value="100" /> |
|
46 | + * </code> |
|
47 | + * |
|
48 | + * Namespace: System.I18N |
|
49 | + * |
|
50 | + * Properties |
|
51 | + * - <b>Value</b>, number, |
|
52 | + * <br>Gets or sets the number to format. The tag content is used as Value |
|
53 | + * if the Value property is not specified. |
|
54 | + * - <b>Type</b>, string, |
|
55 | + * <br>Gets or sets the formatting type. The valid types are |
|
56 | + * 'decimal', 'currency', 'percentage' and 'scientific'. |
|
57 | + * - <b>Currency</b>, string, |
|
58 | + * <br>Gets or sets the currency symbol for the currency format. |
|
59 | + * The default is 'USD' if the Currency property is not specified. |
|
60 | + * - <b>Pattern</b>, string, |
|
61 | + * <br>Gets or sets the custom number formatting pattern. |
|
62 | + * - <b>DefaultText</b>, string, |
|
63 | + * <br>Gets or sets the default text. If Value is not set, DefaultText will be |
|
64 | + * shown instead of the default currency Value/Pattern. |
|
65 | + * |
|
66 | + * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com> |
|
67 | + * @package Prado\I18N |
|
68 | + */ |
|
69 | 69 | class TNumberFormat extends TI18NControl implements \Prado\IDataRenderer |
70 | 70 | { |
71 | 71 | /** |
@@ -52,304 +52,304 @@ |
||
52 | 52 | */ |
53 | 53 | class TGettext_MO extends TGettext |
54 | 54 | { |
55 | - /** |
|
56 | - * file handle |
|
57 | - * |
|
58 | - * @access private |
|
59 | - * @var resource |
|
60 | - */ |
|
61 | - protected $_handle = null; |
|
62 | - |
|
63 | - /** |
|
64 | - * big endianess |
|
65 | - * |
|
66 | - * Whether to write with big endian byte order. |
|
67 | - * |
|
68 | - * @access public |
|
69 | - * @var bool |
|
70 | - */ |
|
71 | - protected $writeBigEndian = false; |
|
72 | - |
|
73 | - /** |
|
74 | - * Constructor |
|
75 | - * |
|
76 | - * @access public |
|
77 | - * @return object File_Gettext_MO |
|
78 | - * @param string $file path to GNU MO file |
|
79 | - */ |
|
80 | - function __construct($file = '') |
|
81 | - { |
|
82 | - $this->file = $file; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * _read |
|
87 | - * |
|
88 | - * @access private |
|
89 | - * @return mixed |
|
90 | - * @param int $bytes |
|
91 | - */ |
|
92 | - function _read($bytes = 1) |
|
93 | - { |
|
94 | - if (0 < $bytes = abs($bytes)) { |
|
95 | - return fread($this->_handle, $bytes); |
|
96 | - } |
|
97 | - return null; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * _readInt |
|
102 | - * |
|
103 | - * @access private |
|
104 | - * @return int |
|
105 | - * @param bool $bigendian |
|
106 | - */ |
|
107 | - function _readInt($bigendian = false) |
|
108 | - { |
|
55 | + /** |
|
56 | + * file handle |
|
57 | + * |
|
58 | + * @access private |
|
59 | + * @var resource |
|
60 | + */ |
|
61 | + protected $_handle = null; |
|
62 | + |
|
63 | + /** |
|
64 | + * big endianess |
|
65 | + * |
|
66 | + * Whether to write with big endian byte order. |
|
67 | + * |
|
68 | + * @access public |
|
69 | + * @var bool |
|
70 | + */ |
|
71 | + protected $writeBigEndian = false; |
|
72 | + |
|
73 | + /** |
|
74 | + * Constructor |
|
75 | + * |
|
76 | + * @access public |
|
77 | + * @return object File_Gettext_MO |
|
78 | + * @param string $file path to GNU MO file |
|
79 | + */ |
|
80 | + function __construct($file = '') |
|
81 | + { |
|
82 | + $this->file = $file; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * _read |
|
87 | + * |
|
88 | + * @access private |
|
89 | + * @return mixed |
|
90 | + * @param int $bytes |
|
91 | + */ |
|
92 | + function _read($bytes = 1) |
|
93 | + { |
|
94 | + if (0 < $bytes = abs($bytes)) { |
|
95 | + return fread($this->_handle, $bytes); |
|
96 | + } |
|
97 | + return null; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * _readInt |
|
102 | + * |
|
103 | + * @access private |
|
104 | + * @return int |
|
105 | + * @param bool $bigendian |
|
106 | + */ |
|
107 | + function _readInt($bigendian = false) |
|
108 | + { |
|
109 | 109 | //unpack returns a reference???? |
110 | 110 | $unpacked = unpack($bigendian ? 'N' : 'V', $this->_read(4)); |
111 | - return array_shift($unpacked); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * _writeInt |
|
116 | - * |
|
117 | - * @access private |
|
118 | - * @return int |
|
119 | - * @param int $int |
|
120 | - */ |
|
121 | - function _writeInt($int) |
|
122 | - { |
|
123 | - return $this->_write(pack($this->writeBigEndian ? 'N' : 'V', (int) $int)); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * _write |
|
128 | - * |
|
129 | - * @access private |
|
130 | - * @return int |
|
131 | - * @param string $data |
|
132 | - */ |
|
133 | - function _write($data) |
|
134 | - { |
|
135 | - return fwrite($this->_handle, $data); |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * _writeStr |
|
140 | - * |
|
141 | - * @access private |
|
142 | - * @return int |
|
143 | - * @param string $string |
|
144 | - */ |
|
145 | - function _writeStr($string) |
|
146 | - { |
|
147 | - return $this->_write($string . "\0"); |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * _readStr |
|
152 | - * |
|
153 | - * @access private |
|
154 | - * @return string |
|
155 | - * @param array $params associative array with offset and length |
|
156 | - * of the string |
|
157 | - */ |
|
158 | - function _readStr($params) |
|
159 | - { |
|
160 | - fseek($this->_handle, $params['offset']); |
|
161 | - return $this->_read($params['length']); |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Load MO file |
|
166 | - * |
|
167 | - * @access public |
|
168 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
169 | - * @param string $file |
|
170 | - */ |
|
171 | - function load($file = null) |
|
172 | - { |
|
173 | - if (!isset($file)) { |
|
174 | - $file = $this->file; |
|
175 | - } |
|
176 | - |
|
177 | - // open MO file |
|
178 | - if (!is_resource($this->_handle = @fopen($file, 'rb'))) { |
|
179 | - return false; |
|
180 | - } |
|
181 | - // lock MO file shared |
|
182 | - if (!@flock($this->_handle, LOCK_SH)) { |
|
183 | - @fclose($this->_handle); |
|
184 | - return false; |
|
185 | - } |
|
186 | - |
|
187 | - // read (part of) magic number from MO file header and define endianess |
|
111 | + return array_shift($unpacked); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * _writeInt |
|
116 | + * |
|
117 | + * @access private |
|
118 | + * @return int |
|
119 | + * @param int $int |
|
120 | + */ |
|
121 | + function _writeInt($int) |
|
122 | + { |
|
123 | + return $this->_write(pack($this->writeBigEndian ? 'N' : 'V', (int) $int)); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * _write |
|
128 | + * |
|
129 | + * @access private |
|
130 | + * @return int |
|
131 | + * @param string $data |
|
132 | + */ |
|
133 | + function _write($data) |
|
134 | + { |
|
135 | + return fwrite($this->_handle, $data); |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * _writeStr |
|
140 | + * |
|
141 | + * @access private |
|
142 | + * @return int |
|
143 | + * @param string $string |
|
144 | + */ |
|
145 | + function _writeStr($string) |
|
146 | + { |
|
147 | + return $this->_write($string . "\0"); |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * _readStr |
|
152 | + * |
|
153 | + * @access private |
|
154 | + * @return string |
|
155 | + * @param array $params associative array with offset and length |
|
156 | + * of the string |
|
157 | + */ |
|
158 | + function _readStr($params) |
|
159 | + { |
|
160 | + fseek($this->_handle, $params['offset']); |
|
161 | + return $this->_read($params['length']); |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Load MO file |
|
166 | + * |
|
167 | + * @access public |
|
168 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
169 | + * @param string $file |
|
170 | + */ |
|
171 | + function load($file = null) |
|
172 | + { |
|
173 | + if (!isset($file)) { |
|
174 | + $file = $this->file; |
|
175 | + } |
|
176 | + |
|
177 | + // open MO file |
|
178 | + if (!is_resource($this->_handle = @fopen($file, 'rb'))) { |
|
179 | + return false; |
|
180 | + } |
|
181 | + // lock MO file shared |
|
182 | + if (!@flock($this->_handle, LOCK_SH)) { |
|
183 | + @fclose($this->_handle); |
|
184 | + return false; |
|
185 | + } |
|
186 | + |
|
187 | + // read (part of) magic number from MO file header and define endianess |
|
188 | 188 | |
189 | 189 | //unpack returns a reference???? |
190 | 190 | $unpacked = unpack('c', $this->_read(4)); |
191 | - switch ($magic = array_shift($unpacked)) |
|
192 | - { |
|
193 | - case -34: |
|
194 | - $be = false; |
|
195 | - break; |
|
196 | - |
|
197 | - case -107: |
|
198 | - $be = true; |
|
199 | - break; |
|
200 | - |
|
201 | - default: |
|
202 | - return false; |
|
203 | - } |
|
204 | - |
|
205 | - // check file format revision - we currently only support 0 |
|
206 | - if (0 !== ($_rev = $this->_readInt($be))) { |
|
207 | - return false; |
|
208 | - } |
|
209 | - |
|
210 | - // count of strings in this file |
|
211 | - $count = $this->_readInt($be); |
|
212 | - |
|
213 | - // offset of hashing table of the msgids |
|
214 | - $offset_original = $this->_readInt($be); |
|
215 | - // offset of hashing table of the msgstrs |
|
216 | - $offset_translat = $this->_readInt($be); |
|
217 | - |
|
218 | - // move to msgid hash table |
|
219 | - fseek($this->_handle, $offset_original); |
|
220 | - // read lengths and offsets of msgids |
|
221 | - $original = array(); |
|
222 | - for ($i = 0; $i < $count; $i++) { |
|
223 | - $original[$i] = array( |
|
224 | - 'length' => $this->_readInt($be), |
|
225 | - 'offset' => $this->_readInt($be) |
|
226 | - ); |
|
227 | - } |
|
228 | - |
|
229 | - // move to msgstr hash table |
|
230 | - fseek($this->_handle, $offset_translat); |
|
231 | - // read lengths and offsets of msgstrs |
|
232 | - $translat = array(); |
|
233 | - for ($i = 0; $i < $count; $i++) { |
|
234 | - $translat[$i] = array( |
|
235 | - 'length' => $this->_readInt($be), |
|
236 | - 'offset' => $this->_readInt($be) |
|
237 | - ); |
|
238 | - } |
|
239 | - |
|
240 | - // read all |
|
241 | - for ($i = 0; $i < $count; $i++) { |
|
242 | - $this->strings[$this->_readStr($original[$i])] = |
|
243 | - $this->_readStr($translat[$i]); |
|
244 | - } |
|
245 | - |
|
246 | - // done |
|
247 | - @flock($this->_handle, LOCK_UN); |
|
248 | - @fclose($this->_handle); |
|
249 | - $this->_handle = null; |
|
250 | - |
|
251 | - // check for meta info |
|
252 | - if (isset($this->strings[''])) { |
|
253 | - $this->meta = parent::meta2array($this->strings['']); |
|
254 | - unset($this->strings['']); |
|
255 | - } |
|
256 | - |
|
257 | - return true; |
|
258 | - } |
|
259 | - |
|
260 | - /** |
|
261 | - * Save MO file |
|
262 | - * |
|
263 | - * @access public |
|
264 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
265 | - * @param string $file |
|
266 | - */ |
|
267 | - function save($file = null) |
|
268 | - { |
|
269 | - if (!isset($file)) { |
|
270 | - $file = $this->file; |
|
271 | - } |
|
272 | - |
|
273 | - // open MO file |
|
274 | - if (!is_resource($this->_handle = @fopen($file, 'wb'))) { |
|
275 | - return false; |
|
276 | - } |
|
277 | - // lock MO file exclusively |
|
278 | - if (!@flock($this->_handle, LOCK_EX)) { |
|
279 | - @fclose($this->_handle); |
|
280 | - return false; |
|
281 | - } |
|
282 | - |
|
283 | - // write magic number |
|
284 | - if ($this->writeBigEndian) { |
|
285 | - $this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde)); |
|
286 | - } else { |
|
287 | - $this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95)); |
|
288 | - } |
|
289 | - |
|
290 | - // write file format revision |
|
291 | - $this->_writeInt(0); |
|
292 | - |
|
293 | - $count = count($this->strings) + ($meta = (count($this->meta) ? 1 : 0)); |
|
294 | - // write count of strings |
|
295 | - $this->_writeInt($count); |
|
296 | - |
|
297 | - $offset = 28; |
|
298 | - // write offset of orig. strings hash table |
|
299 | - $this->_writeInt($offset); |
|
300 | - |
|
301 | - $offset += ($count * 8); |
|
302 | - // write offset transl. strings hash table |
|
303 | - $this->_writeInt($offset); |
|
304 | - |
|
305 | - // write size of hash table (we currently ommit the hash table) |
|
306 | - $this->_writeInt(0); |
|
307 | - |
|
308 | - $offset += ($count * 8); |
|
309 | - // write offset of hash table |
|
310 | - $this->_writeInt($offset); |
|
311 | - |
|
312 | - // unshift meta info |
|
313 | - if ($this->meta) { |
|
314 | - $meta = ''; |
|
315 | - foreach ($this->meta as $key => $val) { |
|
316 | - $meta .= $key . ': ' . $val . "\n"; |
|
317 | - } |
|
318 | - $strings = array('' => $meta) + $this->strings; |
|
319 | - } else { |
|
320 | - $strings = $this->strings; |
|
321 | - } |
|
322 | - |
|
323 | - // write offsets for original strings |
|
324 | - foreach (array_keys($strings) as $o) { |
|
325 | - $len = strlen($o); |
|
326 | - $this->_writeInt($len); |
|
327 | - $this->_writeInt($offset); |
|
328 | - $offset += $len + 1; |
|
329 | - } |
|
330 | - |
|
331 | - // write offsets for translated strings |
|
332 | - foreach ($strings as $t) { |
|
333 | - $len = strlen($t); |
|
334 | - $this->_writeInt($len); |
|
335 | - $this->_writeInt($offset); |
|
336 | - $offset += $len + 1; |
|
337 | - } |
|
338 | - |
|
339 | - // write original strings |
|
340 | - foreach (array_keys($strings) as $o) { |
|
341 | - $this->_writeStr($o); |
|
342 | - } |
|
343 | - |
|
344 | - // write translated strings |
|
345 | - foreach ($strings as $t) { |
|
346 | - $this->_writeStr($t); |
|
347 | - } |
|
348 | - |
|
349 | - // done |
|
350 | - @flock($this->_handle, LOCK_UN); |
|
351 | - @fclose($this->_handle); |
|
352 | - chmod($file,PRADO_CHMOD); |
|
353 | - return true; |
|
354 | - } |
|
191 | + switch ($magic = array_shift($unpacked)) |
|
192 | + { |
|
193 | + case -34: |
|
194 | + $be = false; |
|
195 | + break; |
|
196 | + |
|
197 | + case -107: |
|
198 | + $be = true; |
|
199 | + break; |
|
200 | + |
|
201 | + default: |
|
202 | + return false; |
|
203 | + } |
|
204 | + |
|
205 | + // check file format revision - we currently only support 0 |
|
206 | + if (0 !== ($_rev = $this->_readInt($be))) { |
|
207 | + return false; |
|
208 | + } |
|
209 | + |
|
210 | + // count of strings in this file |
|
211 | + $count = $this->_readInt($be); |
|
212 | + |
|
213 | + // offset of hashing table of the msgids |
|
214 | + $offset_original = $this->_readInt($be); |
|
215 | + // offset of hashing table of the msgstrs |
|
216 | + $offset_translat = $this->_readInt($be); |
|
217 | + |
|
218 | + // move to msgid hash table |
|
219 | + fseek($this->_handle, $offset_original); |
|
220 | + // read lengths and offsets of msgids |
|
221 | + $original = array(); |
|
222 | + for ($i = 0; $i < $count; $i++) { |
|
223 | + $original[$i] = array( |
|
224 | + 'length' => $this->_readInt($be), |
|
225 | + 'offset' => $this->_readInt($be) |
|
226 | + ); |
|
227 | + } |
|
228 | + |
|
229 | + // move to msgstr hash table |
|
230 | + fseek($this->_handle, $offset_translat); |
|
231 | + // read lengths and offsets of msgstrs |
|
232 | + $translat = array(); |
|
233 | + for ($i = 0; $i < $count; $i++) { |
|
234 | + $translat[$i] = array( |
|
235 | + 'length' => $this->_readInt($be), |
|
236 | + 'offset' => $this->_readInt($be) |
|
237 | + ); |
|
238 | + } |
|
239 | + |
|
240 | + // read all |
|
241 | + for ($i = 0; $i < $count; $i++) { |
|
242 | + $this->strings[$this->_readStr($original[$i])] = |
|
243 | + $this->_readStr($translat[$i]); |
|
244 | + } |
|
245 | + |
|
246 | + // done |
|
247 | + @flock($this->_handle, LOCK_UN); |
|
248 | + @fclose($this->_handle); |
|
249 | + $this->_handle = null; |
|
250 | + |
|
251 | + // check for meta info |
|
252 | + if (isset($this->strings[''])) { |
|
253 | + $this->meta = parent::meta2array($this->strings['']); |
|
254 | + unset($this->strings['']); |
|
255 | + } |
|
256 | + |
|
257 | + return true; |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * Save MO file |
|
262 | + * |
|
263 | + * @access public |
|
264 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
265 | + * @param string $file |
|
266 | + */ |
|
267 | + function save($file = null) |
|
268 | + { |
|
269 | + if (!isset($file)) { |
|
270 | + $file = $this->file; |
|
271 | + } |
|
272 | + |
|
273 | + // open MO file |
|
274 | + if (!is_resource($this->_handle = @fopen($file, 'wb'))) { |
|
275 | + return false; |
|
276 | + } |
|
277 | + // lock MO file exclusively |
|
278 | + if (!@flock($this->_handle, LOCK_EX)) { |
|
279 | + @fclose($this->_handle); |
|
280 | + return false; |
|
281 | + } |
|
282 | + |
|
283 | + // write magic number |
|
284 | + if ($this->writeBigEndian) { |
|
285 | + $this->_write(pack('c*', 0x95, 0x04, 0x12, 0xde)); |
|
286 | + } else { |
|
287 | + $this->_write(pack('c*', 0xde, 0x12, 0x04, 0x95)); |
|
288 | + } |
|
289 | + |
|
290 | + // write file format revision |
|
291 | + $this->_writeInt(0); |
|
292 | + |
|
293 | + $count = count($this->strings) + ($meta = (count($this->meta) ? 1 : 0)); |
|
294 | + // write count of strings |
|
295 | + $this->_writeInt($count); |
|
296 | + |
|
297 | + $offset = 28; |
|
298 | + // write offset of orig. strings hash table |
|
299 | + $this->_writeInt($offset); |
|
300 | + |
|
301 | + $offset += ($count * 8); |
|
302 | + // write offset transl. strings hash table |
|
303 | + $this->_writeInt($offset); |
|
304 | + |
|
305 | + // write size of hash table (we currently ommit the hash table) |
|
306 | + $this->_writeInt(0); |
|
307 | + |
|
308 | + $offset += ($count * 8); |
|
309 | + // write offset of hash table |
|
310 | + $this->_writeInt($offset); |
|
311 | + |
|
312 | + // unshift meta info |
|
313 | + if ($this->meta) { |
|
314 | + $meta = ''; |
|
315 | + foreach ($this->meta as $key => $val) { |
|
316 | + $meta .= $key . ': ' . $val . "\n"; |
|
317 | + } |
|
318 | + $strings = array('' => $meta) + $this->strings; |
|
319 | + } else { |
|
320 | + $strings = $this->strings; |
|
321 | + } |
|
322 | + |
|
323 | + // write offsets for original strings |
|
324 | + foreach (array_keys($strings) as $o) { |
|
325 | + $len = strlen($o); |
|
326 | + $this->_writeInt($len); |
|
327 | + $this->_writeInt($offset); |
|
328 | + $offset += $len + 1; |
|
329 | + } |
|
330 | + |
|
331 | + // write offsets for translated strings |
|
332 | + foreach ($strings as $t) { |
|
333 | + $len = strlen($t); |
|
334 | + $this->_writeInt($len); |
|
335 | + $this->_writeInt($offset); |
|
336 | + $offset += $len + 1; |
|
337 | + } |
|
338 | + |
|
339 | + // write original strings |
|
340 | + foreach (array_keys($strings) as $o) { |
|
341 | + $this->_writeStr($o); |
|
342 | + } |
|
343 | + |
|
344 | + // write translated strings |
|
345 | + foreach ($strings as $t) { |
|
346 | + $this->_writeStr($t); |
|
347 | + } |
|
348 | + |
|
349 | + // done |
|
350 | + @flock($this->_handle, LOCK_UN); |
|
351 | + @fclose($this->_handle); |
|
352 | + chmod($file,PRADO_CHMOD); |
|
353 | + return true; |
|
354 | + } |
|
355 | 355 | } |
@@ -51,110 +51,110 @@ |
||
51 | 51 | */ |
52 | 52 | class TGettext_PO extends TGettext |
53 | 53 | { |
54 | - /** |
|
55 | - * Constructor |
|
56 | - * |
|
57 | - * @access public |
|
58 | - * @return object File_Gettext_PO |
|
59 | - * @param string path to GNU PO file |
|
60 | - */ |
|
61 | - function __construct($file = '') |
|
62 | - { |
|
63 | - $this->file = $file; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Load PO file |
|
68 | - * |
|
69 | - * @access public |
|
70 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
71 | - * @param string $file |
|
72 | - */ |
|
73 | - function load($file = null) |
|
74 | - { |
|
75 | - if (!isset($file)) { |
|
76 | - $file = $this->file; |
|
77 | - } |
|
78 | - |
|
79 | - // load file |
|
80 | - if (!$contents = @file($file)) { |
|
81 | - return false; |
|
82 | - } |
|
83 | - $contents = implode('', $contents); |
|
84 | - |
|
85 | - // match all msgid/msgstr entries |
|
86 | - $matched = preg_match_all( |
|
87 | - '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' . |
|
88 | - '(msgstr\s+("([^"]|\\\\")*?"\s*)+)/', |
|
89 | - $contents, $matches |
|
90 | - ); |
|
91 | - unset($contents); |
|
92 | - |
|
93 | - if (!$matched) { |
|
94 | - return false; |
|
95 | - } |
|
96 | - |
|
97 | - // get all msgids and msgtrs |
|
98 | - for ($i = 0; $i < $matched; $i++) { |
|
99 | - $msgid = preg_replace( |
|
100 | - '/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]); |
|
101 | - $msgstr= preg_replace( |
|
102 | - '/\s*msgstr\s*"(.*)"\s*/s', '\\1', $matches[4][$i]); |
|
103 | - $this->strings[parent::prepare($msgid)] = parent::prepare($msgstr); |
|
104 | - } |
|
105 | - |
|
106 | - // check for meta info |
|
107 | - if (isset($this->strings[''])) { |
|
108 | - $this->meta = parent::meta2array($this->strings['']); |
|
109 | - unset($this->strings['']); |
|
110 | - } |
|
111 | - |
|
112 | - return true; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Save PO file |
|
117 | - * |
|
118 | - * @access public |
|
119 | - * @return mixed Returns true on success or PEAR_Error on failure. |
|
120 | - * @param string $file |
|
121 | - */ |
|
122 | - function save($file = null) |
|
123 | - { |
|
124 | - if (!isset($file)) { |
|
125 | - $file = $this->file; |
|
126 | - } |
|
127 | - |
|
128 | - // open PO file |
|
129 | - if (!is_resource($fh = @fopen($file, 'w'))) { |
|
130 | - return false; |
|
131 | - } |
|
132 | - |
|
133 | - // lock PO file exclusively |
|
134 | - if (!flock($fh, LOCK_EX)) { |
|
135 | - fclose($fh); |
|
136 | - return false; |
|
137 | - } |
|
138 | - // write meta info |
|
139 | - if (count($this->meta)) { |
|
140 | - $meta = 'msgid ""' . "\nmsgstr " . '""' . "\n"; |
|
141 | - foreach ($this->meta as $k => $v) { |
|
142 | - $meta .= '"' . $k . ': ' . $v . '\n"' . "\n"; |
|
143 | - } |
|
144 | - fwrite($fh, $meta . "\n"); |
|
145 | - } |
|
146 | - // write strings |
|
147 | - foreach ($this->strings as $o => $t) { |
|
148 | - fwrite($fh, |
|
149 | - 'msgid "' . parent::prepare($o, true) . '"' . "\n" . |
|
150 | - 'msgstr "' . parent::prepare($t, true) . '"' . "\n\n" |
|
151 | - ); |
|
152 | - } |
|
153 | - |
|
154 | - //done |
|
155 | - @flock($fh, LOCK_UN); |
|
156 | - @fclose($fh); |
|
157 | - chmod($file,PRADO_CHMOD); |
|
158 | - return true; |
|
159 | - } |
|
54 | + /** |
|
55 | + * Constructor |
|
56 | + * |
|
57 | + * @access public |
|
58 | + * @return object File_Gettext_PO |
|
59 | + * @param string path to GNU PO file |
|
60 | + */ |
|
61 | + function __construct($file = '') |
|
62 | + { |
|
63 | + $this->file = $file; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Load PO file |
|
68 | + * |
|
69 | + * @access public |
|
70 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
71 | + * @param string $file |
|
72 | + */ |
|
73 | + function load($file = null) |
|
74 | + { |
|
75 | + if (!isset($file)) { |
|
76 | + $file = $this->file; |
|
77 | + } |
|
78 | + |
|
79 | + // load file |
|
80 | + if (!$contents = @file($file)) { |
|
81 | + return false; |
|
82 | + } |
|
83 | + $contents = implode('', $contents); |
|
84 | + |
|
85 | + // match all msgid/msgstr entries |
|
86 | + $matched = preg_match_all( |
|
87 | + '/(msgid\s+("([^"]|\\\\")*?"\s*)+)\s+' . |
|
88 | + '(msgstr\s+("([^"]|\\\\")*?"\s*)+)/', |
|
89 | + $contents, $matches |
|
90 | + ); |
|
91 | + unset($contents); |
|
92 | + |
|
93 | + if (!$matched) { |
|
94 | + return false; |
|
95 | + } |
|
96 | + |
|
97 | + // get all msgids and msgtrs |
|
98 | + for ($i = 0; $i < $matched; $i++) { |
|
99 | + $msgid = preg_replace( |
|
100 | + '/\s*msgid\s*"(.*)"\s*/s', '\\1', $matches[1][$i]); |
|
101 | + $msgstr= preg_replace( |
|
102 | + '/\s*msgstr\s*"(.*)"\s*/s', '\\1', $matches[4][$i]); |
|
103 | + $this->strings[parent::prepare($msgid)] = parent::prepare($msgstr); |
|
104 | + } |
|
105 | + |
|
106 | + // check for meta info |
|
107 | + if (isset($this->strings[''])) { |
|
108 | + $this->meta = parent::meta2array($this->strings['']); |
|
109 | + unset($this->strings['']); |
|
110 | + } |
|
111 | + |
|
112 | + return true; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Save PO file |
|
117 | + * |
|
118 | + * @access public |
|
119 | + * @return mixed Returns true on success or PEAR_Error on failure. |
|
120 | + * @param string $file |
|
121 | + */ |
|
122 | + function save($file = null) |
|
123 | + { |
|
124 | + if (!isset($file)) { |
|
125 | + $file = $this->file; |
|
126 | + } |
|
127 | + |
|
128 | + // open PO file |
|
129 | + if (!is_resource($fh = @fopen($file, 'w'))) { |
|
130 | + return false; |
|
131 | + } |
|
132 | + |
|
133 | + // lock PO file exclusively |
|
134 | + if (!flock($fh, LOCK_EX)) { |
|
135 | + fclose($fh); |
|
136 | + return false; |
|
137 | + } |
|
138 | + // write meta info |
|
139 | + if (count($this->meta)) { |
|
140 | + $meta = 'msgid ""' . "\nmsgstr " . '""' . "\n"; |
|
141 | + foreach ($this->meta as $k => $v) { |
|
142 | + $meta .= '"' . $k . ': ' . $v . '\n"' . "\n"; |
|
143 | + } |
|
144 | + fwrite($fh, $meta . "\n"); |
|
145 | + } |
|
146 | + // write strings |
|
147 | + foreach ($this->strings as $o => $t) { |
|
148 | + fwrite($fh, |
|
149 | + 'msgid "' . parent::prepare($o, true) . '"' . "\n" . |
|
150 | + 'msgstr "' . parent::prepare($t, true) . '"' . "\n\n" |
|
151 | + ); |
|
152 | + } |
|
153 | + |
|
154 | + //done |
|
155 | + @flock($fh, LOCK_UN); |
|
156 | + @fclose($fh); |
|
157 | + chmod($file,PRADO_CHMOD); |
|
158 | + return true; |
|
159 | + } |
|
160 | 160 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * For a given DSN (database connection string), return some information |
24 | 24 | * about the DSN. This function comes from PEAR's DB package. |
25 | - * |
|
25 | + * |
|
26 | 26 | * LICENSE: This source file is subject to version 3.0 of the PHP license |
27 | 27 | * that is available through the world-wide-web at the following URI: |
28 | 28 | * http://www.php.net/license/3_0.txt. If you did not receive a copy of |
@@ -38,120 +38,120 @@ discard block |
||
38 | 38 | * @license http://www.php.net/license/3_0.txt PHP License 3.0 |
39 | 39 | * @link http://pear.php.net/package/DB |
40 | 40 | */ |
41 | - function parseDSN($dsn) |
|
42 | - { |
|
43 | - if (is_array($dsn)) { |
|
44 | - return $dsn; |
|
45 | - } |
|
46 | - |
|
47 | - $parsed = array( |
|
48 | - 'phptype' => false, |
|
49 | - 'dbsyntax' => false, |
|
50 | - 'username' => false, |
|
51 | - 'password' => false, |
|
52 | - 'protocol' => false, |
|
53 | - 'hostspec' => false, |
|
54 | - 'port' => false, |
|
55 | - 'socket' => false, |
|
56 | - 'database' => false |
|
57 | - ); |
|
58 | - |
|
59 | - // Find phptype and dbsyntax |
|
60 | - if (($pos = strpos($dsn, '://')) !== false) { |
|
61 | - $str = substr($dsn, 0, $pos); |
|
62 | - $dsn = substr($dsn, $pos + 3); |
|
63 | - } else { |
|
64 | - $str = $dsn; |
|
65 | - $dsn = null; |
|
66 | - } |
|
67 | - |
|
68 | - // Get phptype and dbsyntax |
|
69 | - // $str => phptype(dbsyntax) |
|
70 | - if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { |
|
71 | - $parsed['phptype'] = $arr[1]; |
|
72 | - $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; |
|
73 | - } else { |
|
74 | - $parsed['phptype'] = $str; |
|
75 | - $parsed['dbsyntax'] = $str; |
|
76 | - } |
|
77 | - |
|
78 | - if (empty($dsn)) { |
|
79 | - return $parsed; |
|
80 | - } |
|
81 | - |
|
82 | - // Get (if found): username and password |
|
83 | - // $dsn => username:password@protocol+hostspec/database |
|
84 | - if (($at = strrpos($dsn,'@')) !== false) { |
|
85 | - $str = substr($dsn, 0, $at); |
|
86 | - $dsn = substr($dsn, $at + 1); |
|
87 | - if (($pos = strpos($str, ':')) !== false) { |
|
88 | - $parsed['username'] = rawurldecode(substr($str, 0, $pos)); |
|
89 | - $parsed['password'] = rawurldecode(substr($str, $pos + 1)); |
|
90 | - } else { |
|
91 | - $parsed['username'] = rawurldecode($str); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - // Find protocol and hostspec |
|
96 | - |
|
97 | - // $dsn => proto(proto_opts)/database |
|
98 | - if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { |
|
99 | - $proto = $match[1]; |
|
100 | - $proto_opts = (!empty($match[2])) ? $match[2] : false; |
|
101 | - $dsn = $match[3]; |
|
102 | - |
|
103 | - // $dsn => protocol+hostspec/database (old format) |
|
104 | - } else { |
|
105 | - if (strpos($dsn, '+') !== false) { |
|
106 | - list($proto, $dsn) = explode('+', $dsn, 2); |
|
107 | - } |
|
108 | - if (strpos($dsn, '/') !== false) { |
|
109 | - list($proto_opts, $dsn) = explode('/', $dsn, 2); |
|
110 | - } else { |
|
111 | - $proto_opts = $dsn; |
|
112 | - $dsn = null; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - // process the different protocol options |
|
117 | - $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; |
|
118 | - $proto_opts = rawurldecode($proto_opts); |
|
119 | - if ($parsed['protocol'] == 'tcp') { |
|
120 | - if (strpos($proto_opts, ':') !== false) { |
|
121 | - list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts); |
|
122 | - } else { |
|
123 | - $parsed['hostspec'] = $proto_opts; |
|
124 | - } |
|
125 | - } elseif ($parsed['protocol'] == 'unix') { |
|
126 | - $parsed['socket'] = $proto_opts; |
|
127 | - } |
|
128 | - |
|
129 | - // Get dabase if any |
|
130 | - // $dsn => database |
|
131 | - if (!empty($dsn)) { |
|
132 | - // /database |
|
133 | - if (($pos = strpos($dsn, '?')) === false) { |
|
134 | - $parsed['database'] = $dsn; |
|
135 | - // /database?param1=value1¶m2=value2 |
|
136 | - } else { |
|
137 | - $parsed['database'] = substr($dsn, 0, $pos); |
|
138 | - $dsn = substr($dsn, $pos + 1); |
|
139 | - if (strpos($dsn, '&') !== false) { |
|
140 | - $opts = explode('&', $dsn); |
|
141 | - } else { // database?param1=value1 |
|
142 | - $opts = array($dsn); |
|
143 | - } |
|
144 | - foreach ($opts as $opt) { |
|
145 | - list($key, $value) = explode('=', $opt); |
|
146 | - if (!isset($parsed[$key])) { // don't allow params overwrite |
|
147 | - $parsed[$key] = rawurldecode($value); |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
152 | - |
|
153 | - return $parsed; |
|
154 | - } |
|
41 | + function parseDSN($dsn) |
|
42 | + { |
|
43 | + if (is_array($dsn)) { |
|
44 | + return $dsn; |
|
45 | + } |
|
46 | + |
|
47 | + $parsed = array( |
|
48 | + 'phptype' => false, |
|
49 | + 'dbsyntax' => false, |
|
50 | + 'username' => false, |
|
51 | + 'password' => false, |
|
52 | + 'protocol' => false, |
|
53 | + 'hostspec' => false, |
|
54 | + 'port' => false, |
|
55 | + 'socket' => false, |
|
56 | + 'database' => false |
|
57 | + ); |
|
58 | + |
|
59 | + // Find phptype and dbsyntax |
|
60 | + if (($pos = strpos($dsn, '://')) !== false) { |
|
61 | + $str = substr($dsn, 0, $pos); |
|
62 | + $dsn = substr($dsn, $pos + 3); |
|
63 | + } else { |
|
64 | + $str = $dsn; |
|
65 | + $dsn = null; |
|
66 | + } |
|
67 | + |
|
68 | + // Get phptype and dbsyntax |
|
69 | + // $str => phptype(dbsyntax) |
|
70 | + if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { |
|
71 | + $parsed['phptype'] = $arr[1]; |
|
72 | + $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; |
|
73 | + } else { |
|
74 | + $parsed['phptype'] = $str; |
|
75 | + $parsed['dbsyntax'] = $str; |
|
76 | + } |
|
77 | + |
|
78 | + if (empty($dsn)) { |
|
79 | + return $parsed; |
|
80 | + } |
|
81 | + |
|
82 | + // Get (if found): username and password |
|
83 | + // $dsn => username:password@protocol+hostspec/database |
|
84 | + if (($at = strrpos($dsn,'@')) !== false) { |
|
85 | + $str = substr($dsn, 0, $at); |
|
86 | + $dsn = substr($dsn, $at + 1); |
|
87 | + if (($pos = strpos($str, ':')) !== false) { |
|
88 | + $parsed['username'] = rawurldecode(substr($str, 0, $pos)); |
|
89 | + $parsed['password'] = rawurldecode(substr($str, $pos + 1)); |
|
90 | + } else { |
|
91 | + $parsed['username'] = rawurldecode($str); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + // Find protocol and hostspec |
|
96 | + |
|
97 | + // $dsn => proto(proto_opts)/database |
|
98 | + if (preg_match('|^([^(]+)\((.*?)\)/?(.*?)$|', $dsn, $match)) { |
|
99 | + $proto = $match[1]; |
|
100 | + $proto_opts = (!empty($match[2])) ? $match[2] : false; |
|
101 | + $dsn = $match[3]; |
|
102 | + |
|
103 | + // $dsn => protocol+hostspec/database (old format) |
|
104 | + } else { |
|
105 | + if (strpos($dsn, '+') !== false) { |
|
106 | + list($proto, $dsn) = explode('+', $dsn, 2); |
|
107 | + } |
|
108 | + if (strpos($dsn, '/') !== false) { |
|
109 | + list($proto_opts, $dsn) = explode('/', $dsn, 2); |
|
110 | + } else { |
|
111 | + $proto_opts = $dsn; |
|
112 | + $dsn = null; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + // process the different protocol options |
|
117 | + $parsed['protocol'] = (!empty($proto)) ? $proto : 'tcp'; |
|
118 | + $proto_opts = rawurldecode($proto_opts); |
|
119 | + if ($parsed['protocol'] == 'tcp') { |
|
120 | + if (strpos($proto_opts, ':') !== false) { |
|
121 | + list($parsed['hostspec'], $parsed['port']) = explode(':', $proto_opts); |
|
122 | + } else { |
|
123 | + $parsed['hostspec'] = $proto_opts; |
|
124 | + } |
|
125 | + } elseif ($parsed['protocol'] == 'unix') { |
|
126 | + $parsed['socket'] = $proto_opts; |
|
127 | + } |
|
128 | + |
|
129 | + // Get dabase if any |
|
130 | + // $dsn => database |
|
131 | + if (!empty($dsn)) { |
|
132 | + // /database |
|
133 | + if (($pos = strpos($dsn, '?')) === false) { |
|
134 | + $parsed['database'] = $dsn; |
|
135 | + // /database?param1=value1¶m2=value2 |
|
136 | + } else { |
|
137 | + $parsed['database'] = substr($dsn, 0, $pos); |
|
138 | + $dsn = substr($dsn, $pos + 1); |
|
139 | + if (strpos($dsn, '&') !== false) { |
|
140 | + $opts = explode('&', $dsn); |
|
141 | + } else { // database?param1=value1 |
|
142 | + $opts = array($dsn); |
|
143 | + } |
|
144 | + foreach ($opts as $opt) { |
|
145 | + list($key, $value) = explode('=', $opt); |
|
146 | + if (!isset($parsed[$key])) { // don't allow params overwrite |
|
147 | + $parsed[$key] = rawurldecode($value); |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | + |
|
153 | + return $parsed; |
|
154 | + } |
|
155 | 155 | |
156 | 156 | |
157 | 157 | /** |
@@ -21,44 +21,44 @@ |
||
21 | 21 | class TWsatGenerateAR extends TPage |
22 | 22 | { |
23 | 23 | |
24 | - public function generate($sender) |
|
25 | - { |
|
26 | - if ($this->IsValid) |
|
27 | - { |
|
28 | - $tableName = $this->table_name->Text; |
|
29 | - $outputFolderNs = $this->output_folder->Text; |
|
30 | - $classPrefix = $this->class_prefix->Text; |
|
31 | - $classSuffix = $this->class_suffix->Text; |
|
24 | + public function generate($sender) |
|
25 | + { |
|
26 | + if ($this->IsValid) |
|
27 | + { |
|
28 | + $tableName = $this->table_name->Text; |
|
29 | + $outputFolderNs = $this->output_folder->Text; |
|
30 | + $classPrefix = $this->class_prefix->Text; |
|
31 | + $classSuffix = $this->class_suffix->Text; |
|
32 | 32 | |
33 | - try |
|
34 | - { |
|
35 | - $ar_generator = new TWsatARGenerator(); |
|
36 | - $ar_generator->setOpFile($outputFolderNs); |
|
37 | - $ar_generator->setClasPrefix($classPrefix); |
|
38 | - $ar_generator->setClassSufix($classSuffix); |
|
33 | + try |
|
34 | + { |
|
35 | + $ar_generator = new TWsatARGenerator(); |
|
36 | + $ar_generator->setOpFile($outputFolderNs); |
|
37 | + $ar_generator->setClasPrefix($classPrefix); |
|
38 | + $ar_generator->setClassSufix($classSuffix); |
|
39 | 39 | |
40 | - if ($this->build_rel->Checked) |
|
41 | - $ar_generator->buildRelations(); |
|
40 | + if ($this->build_rel->Checked) |
|
41 | + $ar_generator->buildRelations(); |
|
42 | 42 | |
43 | - if ($tableName != "*") |
|
44 | - $ar_generator->generate($tableName); |
|
45 | - else |
|
46 | - $ar_generator->generateAll(); |
|
43 | + if ($tableName != "*") |
|
44 | + $ar_generator->generate($tableName); |
|
45 | + else |
|
46 | + $ar_generator->generateAll(); |
|
47 | 47 | |
48 | - $this->feedback_panel->CssClass = "green_panel"; |
|
49 | - $this->generation_msg->Text = "The code has been generated successfully."; |
|
50 | - } catch (Exception $ex) |
|
51 | - { |
|
52 | - $this->feedback_panel->CssClass = "red_panel"; |
|
53 | - $this->generation_msg->Text = $ex->getMessage(); |
|
54 | - } |
|
55 | - $this->feedback_panel->Visible = true; |
|
56 | - } |
|
57 | - } |
|
48 | + $this->feedback_panel->CssClass = "green_panel"; |
|
49 | + $this->generation_msg->Text = "The code has been generated successfully."; |
|
50 | + } catch (Exception $ex) |
|
51 | + { |
|
52 | + $this->feedback_panel->CssClass = "red_panel"; |
|
53 | + $this->generation_msg->Text = $ex->getMessage(); |
|
54 | + } |
|
55 | + $this->feedback_panel->Visible = true; |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - public function preview($sender) |
|
60 | - { |
|
61 | - throw new THttpException(500, "Not implemented yet."); |
|
62 | - } |
|
59 | + public function preview($sender) |
|
60 | + { |
|
61 | + throw new THttpException(500, "Not implemented yet."); |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -190,7 +190,7 @@ |
||
190 | 190 | |
191 | 191 | /** |
192 | 192 | * @return integer|float a timestamp given a local time |
193 | - */ |
|
193 | + */ |
|
194 | 194 | function getTimeStamp($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_gmt=false) |
195 | 195 | { |
196 | 196 | $dt = new DateTime(); |
@@ -496,8 +496,8 @@ |
||
496 | 496 | $className=basename($path); |
497 | 497 | $namespacedClassName = static::PAGE_NAMESPACE_PREFIX .str_replace('.', '\\', $pagePath); |
498 | 498 | |
499 | - if(!class_exists($className,false) && !class_exists($namespacedClassName, false)) |
|
500 | - include_once($path.Prado::CLASS_FILE_EXT); |
|
499 | + if(!class_exists($className,false) && !class_exists($namespacedClassName, false)) |
|
500 | + include_once($path.Prado::CLASS_FILE_EXT); |
|
501 | 501 | |
502 | 502 | if(!class_exists($className,false)) |
503 | 503 | $className = $namespacedClassName; |