-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule.php
More file actions
82 lines (74 loc) · 1.95 KB
/
Module.php
File metadata and controls
82 lines (74 loc) · 1.95 KB
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
<?php
namespace Floxim\Ui;
use Floxim\Floxim\System\Fx as fx;
class Module extends \Floxim\Floxim\Component\Module\Entity {
public function init()
{
fx::template()->register(
array(
'floxim.ui.slider',
'floxim.ui.tiles',
'floxim.ui.menu',
'floxim.ui.box',
'floxim.ui.record',
'floxim.ui.nav'
)
);
}
public function getDateFormats()
{
$formats = array(
'j %month:gen% Y',
'%Month% Y',
'd.m.Y',
'd/m/Y',
'H:i'
);
$res = array();
foreach ($formats as $f) {
$res[$f] = fx::date(time(), $f);
}
return $res;
}
public function getDefaultDateFormat()
{
return 'j %month:gen% Y';
}
public function getNumberFormats()
{
$formats = [
[
[0, '', ''],
'100500'
],
[
[0, '', ' '],
'100 500'
],
[
[2, ',', ' '],
'100 500,00'
]
];
$res = [];
foreach ($formats as $f) {
$res[json_encode($f[0])] = $f[1];
}
return $res;
}
public function getDefaultNumberFormat()
{
return '[0,"",""]';
}
static $formatterClosures = [];
public static function numberFormat($number, $format)
{
if (!isset(self::$formatterClosures[$format])) {
list($decimals, $dec_point, $thousands_sep) = json_decode($format);
self::$formatterClosures[$format] = function($val) use ($decimals, $dec_point, $thousands_sep) {
return call_user_func('number_format', $val, $decimals, $dec_point, $thousands_sep);
};
}
return call_user_func(self::$formatterClosures[$format], $number);
}
}