From a7c928b4eac6eb0b2a79fcc758a8a99ddc15a15d Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Tue, 14 Nov 2017 21:23:23 +0100 Subject: [PATCH 1/8] Extract user agent name for global use --- system/modules/Monitoring/classes/Monitoring.php | 2 +- system/modules/Monitoring/config/config.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/system/modules/Monitoring/classes/Monitoring.php b/system/modules/Monitoring/classes/Monitoring.php index 3653d80..b1626bd 100644 --- a/system/modules/Monitoring/classes/Monitoring.php +++ b/system/modules/Monitoring/classes/Monitoring.php @@ -293,7 +293,7 @@ private function loadSite($url) ( 'http'=>array ( - 'user_agent' => "ContaoMonitoringClient" + 'user_agent' => $GLOBALS['TL_CONFIG']['MONITORING_AGENT_NAME'] ) ); $context = stream_context_create($opts); diff --git a/system/modules/Monitoring/config/config.php b/system/modules/Monitoring/config/config.php index 4b2a96d..62d02dd 100644 --- a/system/modules/Monitoring/config/config.php +++ b/system/modules/Monitoring/config/config.php @@ -57,4 +57,9 @@ // Hourly cron job to check all server $GLOBALS['TL_CRON']['hourly'][] = array('Monitoring', 'checkScheduled'); +/** + * Global names + */ +$GLOBALS['TL_CONFIG']['MONITORING_AGENT_NAME'] = "ContaoMonitoringClient"; + ?> \ No newline at end of file From 47af85682105b10d7c4708c5d8c3f33d12408040 Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Tue, 14 Nov 2017 21:23:38 +0100 Subject: [PATCH 2/8] Increment branch alias --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7a8662d..dd38598 100644 --- a/composer.json +++ b/composer.json @@ -36,7 +36,7 @@ } }, "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.9.x-dev" } } } \ No newline at end of file From 36be78fec5790650f603965e5928852cd8aa745c Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Mon, 27 Nov 2017 20:25:35 +0100 Subject: [PATCH 3/8] Replace `$GLOBALS['TL_CONFIG']` access with `\Config::get()` --- system/modules/Monitoring/classes/Monitoring.php | 14 +++++++------- .../modules/Monitoring/dca/tl_monitoring_test.php | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/system/modules/Monitoring/classes/Monitoring.php b/system/modules/Monitoring/classes/Monitoring.php index b1626bd..fae8362 100644 --- a/system/modules/Monitoring/classes/Monitoring.php +++ b/system/modules/Monitoring/classes/Monitoring.php @@ -106,13 +106,13 @@ public function checkScheduled() { $errorMsg = self::EMAIL_MESSAGE_START . $this->getErroneousCheckEntriesAsString(); $this->log($errorMsg, __METHOD__, TL_ERROR); - if ($GLOBALS['TL_CONFIG']['monitoringMailingActive'] && $GLOBALS['TL_CONFIG']['monitoringAdminEmail'] != '') + if (\Config::get('monitoringMailingActive') && \Config::get('monitoringAdminEmail') != '') { $objEmail = new \Email(); $objEmail->subject = self::EMAIL_SUBJECT; $objEmail->text = $errorMsg . sprintf(self::EMAIL_MESSAGE_END, \Environment::get('base') . "contao"); - $objEmail->sendTo($GLOBALS['TL_CONFIG']['monitoringAdminEmail']); - $this->logDebugMsg("Scheduled monitoring check ended with errors. Monitoring admin informed via email (" . $GLOBALS['TL_CONFIG']['monitoringAdminEmail'] . ").", __METHOD__); + $objEmail->sendTo(\Config::get('monitoringAdminEmail')); + $this->logDebugMsg("Scheduled monitoring check ended with errors. Monitoring admin informed via email (" . \Config::get('monitoringAdminEmail') . ").", __METHOD__); } else { @@ -136,13 +136,13 @@ private function checkSingle($id, $checkType) $testString = $this->valString($objMonitoringEntry->test_string, true); $repitition = 0; - $maxRepititions = $GLOBALS['TL_CONFIG']['monitoringTestCirculation']; + $maxRepititions = \Config::get('monitoringTestCirculation'); if (!is_int($maxRepititions) || $maxRepititions < 1) { $maxRepititions = 1; } - $delay = $GLOBALS['TL_CONFIG']['monitoringTestCirculationDelay']; + $delay = \Config::get('monitoringTestCirculationDelay'); if (!is_int($delay) || $delay < 1 || $delay > 99) { $delay = 10; @@ -293,7 +293,7 @@ private function loadSite($url) ( 'http'=>array ( - 'user_agent' => $GLOBALS['TL_CONFIG']['MONITORING_AGENT_NAME'] + 'user_agent' => \Config::get('MONITORING_AGENT_NAME') ) ); $context = stream_context_create($opts); @@ -355,7 +355,7 @@ private function returnToList($act) */ private function logDebugMsg($msg, $origin) { - if ($GLOBALS['TL_CONFIG']['monitoringDebugMode'] === TRUE) + if (\Config::get('monitoringDebugMode') === TRUE) { $this->log($msg, $origin, TL_INFO); } diff --git a/system/modules/Monitoring/dca/tl_monitoring_test.php b/system/modules/Monitoring/dca/tl_monitoring_test.php index fb00252..057ae86 100644 --- a/system/modules/Monitoring/dca/tl_monitoring_test.php +++ b/system/modules/Monitoring/dca/tl_monitoring_test.php @@ -234,7 +234,7 @@ public function getTestResultOutput($arrRow) array ( 'col_0' => $GLOBALS['TL_LANG']['tl_monitoring_test']['date'][0], - 'col_1' => \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['date']) + 'col_1' => \Date::parse(\Config::get('datimFormat'), $arrRow['date']) ), array ( From 55f42978713678732f92ca979e66cfe9806700c7 Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Mon, 27 Nov 2017 20:26:40 +0100 Subject: [PATCH 4/8] Devide `storeUrl` function into `deleteLastTestValues` and `prepareUrl` to provide better reusage possibilities --- system/modules/Monitoring/dca/tl_monitoring.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/system/modules/Monitoring/dca/tl_monitoring.php b/system/modules/Monitoring/dca/tl_monitoring.php index 00f61be..9a75d46 100644 --- a/system/modules/Monitoring/dca/tl_monitoring.php +++ b/system/modules/Monitoring/dca/tl_monitoring.php @@ -209,7 +209,7 @@ 'exclude' => true, 'search' => true, 'inputType' => 'text', - 'save_callback' => array(array('tl_monitoring', 'storeUrl')), + 'save_callback' => array(array('tl_monitoring', 'deleteLastTestValues'), array('tl_monitoring', 'prepareUrl')), 'eval' => array('tl_class'=>'long', 'mandatory'=>true, 'rgxp'=>'url'), 'sql' => "text NOT NULL" ), @@ -363,13 +363,13 @@ public function getLabel($row, $label, DataContainer $dc, $args) } /** - * Empties test values when editing the url + * Empties the last test values when url has changed */ - public function storeUrl($value, DataContainer $dc) + public function deleteLastTestValues($value, DataContainer $dc) { if ($value != $dc->activeRecord->url) { - // url is new ... set unchecked + // url is changed ... set unchecked $arrSet = array(); $arrSet['last_test_date'] = 0; $arrSet['last_test_status'] = Monitoring::STATUS_UNTESTED; @@ -380,6 +380,14 @@ public function storeUrl($value, DataContainer $dc) ->execute(\Input::get('id')); } + return $value; + } + + /** + * Adds `http://` if not set + */ + public function prepareUrl($value, DataContainer $dc) + { if ($value != '' && !preg_match('@^https?://@', $value)) { $value = 'http://' . $value; From 8dc40ea3869f815dcab6b7f498efad7d04b80ec6 Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Mon, 27 Nov 2017 20:29:57 +0100 Subject: [PATCH 5/8] Extract user agent name for global use --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 482450f..d76060b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Contao Extension "Monitoring" ============================= +Version 1.9.0 (2017-12-xx) +-------------------------- +- extracted user agent name for global use + Version 1.8.1 (2017-06-28) -------------------------- - Contao 4 ready From 55dd2155195120f9692d50298fc9c319f5ccdf06 Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Mon, 27 Nov 2017 20:30:22 +0100 Subject: [PATCH 6/8] Replace `$GLOBALS['TL_CONFIG']` access with `\Config::get()` --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d76060b..5c71762 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Contao Extension "Monitoring" Version 1.9.0 (2017-12-xx) -------------------------- - extracted user agent name for global use +- replaced `$GLOBALS['TL_CONFIG']` access with `\Config::get()` Version 1.8.1 (2017-06-28) -------------------------- From 94f46325ca91652df0c2e607e04ab4cc85d8d7f9 Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Mon, 27 Nov 2017 20:30:57 +0100 Subject: [PATCH 7/8] Devide `storeUrl` function into `deleteLastTestValues` and `prepareUrl` to provide better reusage possibilities --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c71762..56d68b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Version 1.9.0 (2017-12-xx) -------------------------- - extracted user agent name for global use - replaced `$GLOBALS['TL_CONFIG']` access with `\Config::get()` +- devided `storeUrl` function into `deleteLastTestValues` and `prepareUrl` to provide better reusage possibilities Version 1.8.1 (2017-06-28) -------------------------- From 757b195a0c965d0e0169af19018a71bf7634d80c Mon Sep 17 00:00:00 2001 From: Cliff Parnitzky Date: Tue, 19 Dec 2017 22:07:17 +0100 Subject: [PATCH 8/8] Updated url to gitbooks.io --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b797136..e0ad495 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,6 @@ The following extensions are recommended: Documentation ------------- -[Read the manual](https://cliffparnitzky.gitbooks.io/contaomonitoring) +[Read the manual](https://contaomonitoring.gitbooks.io/contaomonitoring) -![EN](https://raw.githubusercontent.com/ContaoMonitoring/documentation/master/en/en.png) [English manual](https://cliffparnitzky.gitbooks.io/contaomonitoring/content/en/index.html) +![EN](https://raw.githubusercontent.com/ContaoMonitoring/documentation/master/en/en.png) [English manual](https://contaomonitoring.gitbooks.io/contaomonitoring/en/index.html)