-
Notifications
You must be signed in to change notification settings - Fork 2
/
extension.driver.php
executable file
·98 lines (79 loc) · 2.74 KB
/
extension.driver.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
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
<?php
/**
* @see http://www.getsymphony.com/learn/api/2.3.3/toolkit/extension/
*
* based on https://github.com/hananils/lang_german
*/
Class extension_lang_slovak extends Extension {
public function getSubscribedDelegates(){
return array(
array(
'page' => '/system/preferences/',
'delegate' => 'Save',
'callback' => '__toggleSlovak'
)
);
}
/**
* Toggle between Slovak and default date and time settings
*/
public function __toggleSlovak($context) {
// Set Slovak date and time settings
if($context['settings']['symphony']['lang'] == 'sk') {
$this->__setSlovak();
}
// Restore default date and time settings
else {
$this->__unsetSlovak();
}
}
public function install() {
// Fetch current date and time settings
$date = Symphony::Configuration()->get('date_format', 'region');
$time = Symphony::Configuration()->get('time_format', 'region');
$separator = Symphony::Configuration()->get('datetime_separator', 'region');
// Store current date and time settings
Symphony::Configuration()->set('date_format', $date, 'lang-slovak-storage');
Symphony::Configuration()->set('time_format', $time, 'lang-slovak-storage');
Symphony::Configuration()->set('datetime_separator', $separator, 'lang-slovak-storage');
Symphony::Configuration()->write();
}
public function enable(){
if(Symphony::Configuration()->get('lang', 'symphony') == 'sk') {
$this->__setSlovak();
}
}
public function disable(){
$this->__unsetSlovak();
}
public function uninstall() {
$this->__unsetSlovak();
// Remove storage
Symphony::Configuration()->remove('lang-slovak-storage');
Symphony::Configuration()->write();
}
/**
* Set Slovak date and time format
*/
private function __setSlovak() {
// Set Slovak date and time settings
Symphony::Configuration()->set('date_format', 'j.n.Y', 'region');
Symphony::Configuration()->set('time_format', 'G:i', 'region');
Symphony::Configuration()->set('datetime_separator', ', ', 'region');
Symphony::Configuration()->write();
}
/**
* Reset default date and time format
*/
private function __unsetSlovak() {
// Fetch current date and time settings
$date = Symphony::Configuration()->get('date_format', 'lang-slovak-storage');
$time = Symphony::Configuration()->get('time_format', 'lang-slovak-storage');
$separator = Symphony::Configuration()->get('datetime_separator', 'lang-slovak-storage');
// Store new date and time settings
Symphony::Configuration()->set('date_format', $date, 'region');
Symphony::Configuration()->set('time_format', $time, 'region');
Symphony::Configuration()->set('datetime_separator', $separator, 'region');
Symphony::Configuration()->write();
}
}