Skip to content

Commit 2b07ae8

Browse files
Merge remote-tracking branch 'refs/remotes/origin/develop'
2 parents a8e08d7 + a3e1f5d commit 2b07ae8

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Contao Extension "Monitoring"
33
=============================
44

5+
Version 1.9.0 (2018-01-xx)
6+
--------------------------
7+
- extracted user agent name for global use
8+
- replaced `$GLOBALS['TL_CONFIG']` access with `\Config::get()`
9+
- devided `storeUrl` function into `deleteLastTestValues` and `prepareUrl` to provide better reusage possibilities
10+
511
Version 1.8.2 (2018-01-25)
612
--------------------------
713
- Fix bug when loading language files in Contao 4

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ The following extensions are recommended:
5353
Documentation
5454
-------------
5555

56-
[Read the manual](https://cliffparnitzky.gitbooks.io/contaomonitoring)
56+
[Read the manual](https://contaomonitoring.gitbooks.io/contaomonitoring)
5757

58-
![EN](https://raw.githubusercontent.com/ContaoMonitoring/documentation/master/en/en.png) [English manual](https://cliffparnitzky.gitbooks.io/contaomonitoring/content/en/index.html)
58+
![EN](https://raw.githubusercontent.com/ContaoMonitoring/documentation/master/en/en.png) [English manual](https://contaomonitoring.gitbooks.io/contaomonitoring/en/index.html)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
},
3838
"branch-alias": {
39-
"dev-master": "1.8.x-dev"
39+
"dev-master": "1.9.x-dev"
4040
}
4141
}
4242
}

system/modules/Monitoring/classes/Monitoring.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ public function checkScheduled()
106106
{
107107
$errorMsg = self::EMAIL_MESSAGE_START . $this->getErroneousCheckEntriesAsString();
108108
$this->log($errorMsg, __METHOD__, TL_ERROR);
109-
if ($GLOBALS['TL_CONFIG']['monitoringMailingActive'] && $GLOBALS['TL_CONFIG']['monitoringAdminEmail'] != '')
109+
if (\Config::get('monitoringMailingActive') && \Config::get('monitoringAdminEmail') != '')
110110
{
111111
$objEmail = new \Email();
112112
$objEmail->subject = self::EMAIL_SUBJECT;
113113
$objEmail->text = $errorMsg . sprintf(self::EMAIL_MESSAGE_END, \Environment::get('base') . "contao");
114-
$objEmail->sendTo($GLOBALS['TL_CONFIG']['monitoringAdminEmail']);
115-
$this->logDebugMsg("Scheduled monitoring check ended with errors. Monitoring admin informed via email (" . $GLOBALS['TL_CONFIG']['monitoringAdminEmail'] . ").", __METHOD__);
114+
$objEmail->sendTo(\Config::get('monitoringAdminEmail'));
115+
$this->logDebugMsg("Scheduled monitoring check ended with errors. Monitoring admin informed via email (" . \Config::get('monitoringAdminEmail') . ").", __METHOD__);
116116
}
117117
else
118118
{
@@ -136,13 +136,13 @@ private function checkSingle($id, $checkType)
136136
$testString = $this->valString($objMonitoringEntry->test_string, true);
137137

138138
$repitition = 0;
139-
$maxRepititions = $GLOBALS['TL_CONFIG']['monitoringTestCirculation'];
139+
$maxRepititions = \Config::get('monitoringTestCirculation');
140140
if (!is_int($maxRepititions) || $maxRepititions < 1)
141141
{
142142
$maxRepititions = 1;
143143
}
144144

145-
$delay = $GLOBALS['TL_CONFIG']['monitoringTestCirculationDelay'];
145+
$delay = \Config::get('monitoringTestCirculationDelay');
146146
if (!is_int($delay) || $delay < 1 || $delay > 99)
147147
{
148148
$delay = 10;
@@ -293,7 +293,7 @@ private function loadSite($url)
293293
(
294294
'http'=>array
295295
(
296-
'user_agent' => "ContaoMonitoringClient"
296+
'user_agent' => \Config::get('MONITORING_AGENT_NAME')
297297
)
298298
);
299299
$context = stream_context_create($opts);
@@ -355,7 +355,7 @@ private function returnToList($act)
355355
*/
356356
private function logDebugMsg($msg, $origin)
357357
{
358-
if ($GLOBALS['TL_CONFIG']['monitoringDebugMode'] === TRUE)
358+
if (\Config::get('monitoringDebugMode') === TRUE)
359359
{
360360
$this->log($msg, $origin, TL_INFO);
361361
}

system/modules/Monitoring/config/config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,9 @@
5757
// Hourly cron job to check all server
5858
$GLOBALS['TL_CRON']['hourly'][] = array('Monitoring', 'checkScheduled');
5959

60+
/**
61+
* Global names
62+
*/
63+
$GLOBALS['TL_CONFIG']['MONITORING_AGENT_NAME'] = "ContaoMonitoringClient";
64+
6065
?>

system/modules/Monitoring/dca/tl_monitoring.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
'exclude' => true,
210210
'search' => true,
211211
'inputType' => 'text',
212-
'save_callback' => array(array('tl_monitoring', 'storeUrl')),
212+
'save_callback' => array(array('tl_monitoring', 'deleteLastTestValues'), array('tl_monitoring', 'prepareUrl')),
213213
'eval' => array('tl_class'=>'long', 'mandatory'=>true, 'rgxp'=>'url'),
214214
'sql' => "text NOT NULL"
215215
),
@@ -363,13 +363,13 @@ public function getLabel($row, $label, DataContainer $dc, $args)
363363
}
364364

365365
/**
366-
* Empties test values when editing the url
366+
* Empties the last test values when url has changed
367367
*/
368-
public function storeUrl($value, DataContainer $dc)
368+
public function deleteLastTestValues($value, DataContainer $dc)
369369
{
370370
if ($value != $dc->activeRecord->url)
371371
{
372-
// url is new ... set unchecked
372+
// url is changed ... set unchecked
373373
$arrSet = array();
374374
$arrSet['last_test_date'] = 0;
375375
$arrSet['last_test_status'] = Monitoring::STATUS_UNTESTED;
@@ -380,6 +380,14 @@ public function storeUrl($value, DataContainer $dc)
380380
->execute(\Input::get('id'));
381381
}
382382

383+
return $value;
384+
}
385+
386+
/**
387+
* Adds `http://` if not set
388+
*/
389+
public function prepareUrl($value, DataContainer $dc)
390+
{
383391
if ($value != '' && !preg_match('@^https?://@', $value))
384392
{
385393
$value = 'http://' . $value;

system/modules/Monitoring/dca/tl_monitoring_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function getTestResultOutput($arrRow)
234234
array
235235
(
236236
'col_0' => $GLOBALS['TL_LANG']['tl_monitoring_test']['date'][0],
237-
'col_1' => \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['date'])
237+
'col_1' => \Date::parse(\Config::get('datimFormat'), $arrRow['date'])
238238
),
239239
array
240240
(

0 commit comments

Comments
 (0)