-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextension.driver.php
More file actions
135 lines (107 loc) · 3.52 KB
/
extension.driver.php
File metadata and controls
135 lines (107 loc) · 3.52 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
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
<?php
require_once(EXTENSIONS . "/database_migrations/lib/utils.class.php");
Class Extension_Database_Migrations extends Extension {
public function __construct(Array $args) {
parent::__construct($args);
}
public function about() {
return array(
'name' => 'Database Migrations',
'version' => '1.0.2',
'release-date' => '2011-05-07',
'author' => array(
'name' => 'Tom Johnson',
'website' => 'http://symphony-cms.com/'
),
'description' => 'Tracks database changes and generates change scripts.'
);
}
public function install($location='database-migrations') {
$savePath=Database_Migrations_Utils::getSavePath();
if(!file_exists($savePath)){
mkdir($savePath);
}
Database_Migrations_Utils::createBaseline();
Symphony::Configuration()->set('track-structure-only', 'yes', $location);
Symphony::Configuration()->set('enabled', '1', $location);
Symphony::Configuration()->set('allow-blueprints-access','1', $location);
Administration::instance()->saveConfig();
return true;
}
public function uninstall($location='database-migrations') {
Symphony::Configuration()->set('enabled', '0', $location);
Symphony::Configuration()->remove($location);
Administration::instance()->saveConfig();
return true;
}
public function getSubscribedDelegates() {
return array(
array(
'page' => '/backend/',
'delegate' => 'AppendPageAlert',
'callback' => 'appendAlert'
),
array(
'page' => '/frontend/',
'delegate' => 'PostQueryExecution',
'callback' => 'processQuery'
),
array(
'page' => '/backend/',
'delegate' => 'PostQueryExecution',
'callback' => 'processQuery'
),
array(
'page' => '/backend/',
'delegate' => 'ExtensionsAddToNavigation',
'callback' => 'mod_navigation'
)
);
}
public function processQuery($context) {
return Database_Migrations_Utils::saveQuery(trim($context["query"]));
}
public function appendAlert($context) {
if(Symphony::Configuration()->get("allow-blueprints-access", "database-migrations") == "0") {
Administration::instance()->Page->pageAlert(
__('Database Migrations is in \'live\' mode and has prevented access to Symphony Blueprints.'),
Alert::ERROR
);
}
//check still installed and worth running
if(Symphony::Configuration()->get("enabled", "database-migrations") == "1" ){
if(isset($_GET["db-update"])) {
if($_GET["db-update"] == "success") {
Administration::instance()->Page->pageAlert(
__('Your database was updated.'),
Alert::SUCCESS
);
}
else {
Administration::instance()->Page->pageAlert(
__('Database update failed.'),
Alert::ERROR
);
}
}
else{
if(Database_Migrations_Utils::instanceIsOutOfDate()) {
Administration::instance()->Page->pageAlert(
__('Your database is out of date.') . ' <a href="' . SYMPHONY_URL . '/extension/database_migrations?action=update&redirect=' . getCurrentPage() . '">' . __('Update?') . '</a>',
Alert::ERROR
);
}
}
}
}
public function mod_navigation($context) {
$context['navigation'][200]['children'][] = array(
'link' => '/extension/database_migrations/',
'name' => __('Database Migrations'),
'visible' => 'yes'
);
if(Symphony::Configuration()->get("allow-blueprints-access", "database-migrations") == "0") {
$context['navigation'][200] = array();
}
}
}