1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Jaeger |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2015-2016, mithra62 |
6
|
|
|
* @link http://jaeger-app.com |
7
|
|
|
* @version 1.0 |
8
|
|
|
* @filesource ./Platforms/Concrete5.php |
9
|
|
|
*/ |
10
|
|
|
namespace JaegerApp\Platforms; |
11
|
|
|
|
12
|
|
|
use JaegerApp\Platforms\AbstractPlatform; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Jaeger - Concrete5 Platform Object |
16
|
|
|
* |
17
|
|
|
* The bridge between mithra62 code and Concrete5 specific logic |
18
|
|
|
* |
19
|
|
|
* @package Platforms\Concrete5 |
20
|
|
|
* @author Eric Lamb <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class Concrete5 extends AbstractPlatform |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* The Concrete5 App object |
26
|
|
|
* @var \Concrete\Core\Support\Facade\Application |
27
|
|
|
*/ |
28
|
|
|
private $app = null; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* (non-PHPdoc) |
32
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getDbCredentials() |
33
|
|
|
*/ |
34
|
|
|
public function getDbCredentials() |
35
|
|
|
{ |
36
|
|
|
$database_config = \Config::get('database'); |
37
|
|
|
$database_config = $database_config['connections'][$database_config['default-connection']]; |
38
|
|
|
|
39
|
|
|
return array( |
40
|
|
|
'user' => $database_config['username'], |
41
|
|
|
'password' => $database_config['password'], |
42
|
|
|
'database' => $database_config['database'], |
43
|
|
|
'host' => $database_config['server'], |
44
|
|
|
'prefix' => '', |
45
|
|
|
'settings_table_name' => 'backup_pro_settings' |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* (non-PHPdoc) |
51
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getEmailConfig() |
52
|
|
|
*/ |
53
|
|
|
public function getEmailConfig() |
54
|
|
|
{ |
55
|
|
|
if(!\Config::get('concrete.email.enabled')) { |
56
|
|
|
throw new Exception('Concrete5 email is disabled... you have to enable that for email to function'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$email = \Config::get('concrete.mail'); |
60
|
|
|
$this->email_config = array(); |
|
|
|
|
61
|
|
|
$this->email_config['type'] = $email['method']; |
|
|
|
|
62
|
|
|
$this->email_config['port'] = $email['methods']['smtp']['port']; |
|
|
|
|
63
|
|
|
if ($email['method'] == 'smtp') { |
64
|
|
|
$this->email_config['smtp_options']['host'] = $email['methods']['smtp']['server']; |
|
|
|
|
65
|
|
|
$this->email_config['smtp_options']['connection_config']['username'] = $email['methods']['smtp']['username']; |
|
|
|
|
66
|
|
|
$this->email_config['smtp_options']['connection_config']['password'] = $email['methods']['smtp']['password']; |
|
|
|
|
67
|
|
|
$this->email_config['smtp_options']['port'] = $email['methods']['smtp']['port']; |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$this->email_config['sender_name'] = $this->getSiteName(); |
|
|
|
|
71
|
|
|
$this->email_config['from_email'] = \Config::get('concrete.email.default.address'); |
|
|
|
|
72
|
|
|
return $this->email_config; |
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* (non-PHPdoc) |
77
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getCurrentUrl() |
78
|
|
|
*/ |
79
|
|
|
public function getCurrentUrl() |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
return $_SERVER["REQUEST_URI"]; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* (non-PHPdoc) |
86
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getSiteName() |
87
|
|
|
*/ |
88
|
|
|
public function getSiteName() |
89
|
|
|
{ |
90
|
|
|
return \Config::get('concrete.site'); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* (non-PHPdoc) |
95
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getTimezone() |
96
|
|
|
*/ |
97
|
|
|
public function getTimezone() |
98
|
|
|
{ |
99
|
|
|
return \Config::get('app.timezone'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* (non-PHPdoc) |
104
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getSiteUrl() |
105
|
|
|
*/ |
106
|
|
|
public function getSiteUrl() |
107
|
|
|
{ |
108
|
|
|
$app = $this->getApp(); |
109
|
|
|
return (string)rtrim($app->make('url/canonical'), '/'); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* (non-PHPdoc) |
114
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getEncryptionKey() |
115
|
|
|
*/ |
116
|
|
|
public function getEncryptionKey() |
117
|
|
|
{ |
118
|
|
|
return \Config::get('concrete.security.token.encryption'); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* (non-PHPdoc) |
123
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getConfigOverrides() |
124
|
|
|
*/ |
125
|
|
|
public function getConfigOverrides() |
126
|
|
|
{ |
127
|
|
|
$config = \Config::get('backup_pro.overrides'); |
128
|
|
|
if( is_array($config) ) { |
129
|
|
|
return $config; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
return array(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* (non-PHPdoc) |
137
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::redirect() |
138
|
|
|
*/ |
139
|
|
|
public function redirect($url) |
140
|
|
|
{ |
141
|
|
|
return \Concrete\Core\Routing\Redirect::url($url); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* (non-PHPdoc) |
146
|
|
|
* |
147
|
|
|
* @see \mithra62\Platforms\AbstractPlatform::getPost() |
148
|
|
|
*/ |
149
|
|
|
public function getPost($key, $default = false) |
|
|
|
|
150
|
|
|
{ |
151
|
|
|
if (isset($_POST[$key])) { |
152
|
|
|
return $_POST[$key]; |
153
|
|
|
} elseif (isset($_GET[$key])) { |
154
|
|
|
return $_GET[$key]; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
return $default; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Returns an instance of the Concrete5 app object |
162
|
|
|
* @return \Concrete\Core\Support\Facade\Application |
163
|
|
|
*/ |
164
|
|
|
private function getApp() |
165
|
|
|
{ |
166
|
|
|
if( is_null($this->app) ) { |
167
|
|
|
$this->app = \Concrete\Core\Support\Facade\Application::getFacadeApplication(); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
return $this->app; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
} |
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.