From 5968de3ea8d1164e3099d3d48059d7d8ebc159a4 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Fri, 25 Sep 2020 08:21:02 +0200 Subject: [PATCH 01/11] move joomla-alert from message to it's own JLayout --- layouts/joomla/system/joomla-alert.php | 28 +++++++++++++++ layouts/joomla/system/message.php | 50 +++++++++++--------------- 2 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 layouts/joomla/system/joomla-alert.php diff --git a/layouts/joomla/system/joomla-alert.php b/layouts/joomla/system/joomla-alert.php new file mode 100644 index 0000000000000..e1333c5ebae49 --- /dev/null +++ b/layouts/joomla/system/joomla-alert.php @@ -0,0 +1,28 @@ + + + +
+ + +
+
+ +
+ +
+ +
diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index 460a215a80055..175696518fc39 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -12,19 +12,20 @@ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Layout\LayoutHelper; $msgList = $displayData['msgList']; $alert = [ - CMSApplication::MSG_EMERGENCY => 'danger', - CMSApplication::MSG_ALERT => 'danger', - CMSApplication::MSG_CRITICAL => 'danger', - CMSApplication::MSG_ERROR => 'danger', - CMSApplication::MSG_WARNING => 'warning', - CMSApplication::MSG_NOTICE => 'info', - CMSApplication::MSG_INFO => 'info', - CMSApplication::MSG_DEBUG => 'info', - 'message' => 'success' + CMSApplication::MSG_EMERGENCY => 'danger', + CMSApplication::MSG_ALERT => 'danger', + CMSApplication::MSG_CRITICAL => 'danger', + CMSApplication::MSG_ERROR => 'danger', + CMSApplication::MSG_WARNING => 'warning', + CMSApplication::MSG_NOTICE => 'info', + CMSApplication::MSG_INFO => 'info', + CMSApplication::MSG_DEBUG => 'info', + 'message' => 'success' ]; // Load JavaScript message titles @@ -40,28 +41,17 @@ // Alerts progressive enhancement Factory::getDocument()->getWebAssetManager() - ->useStyle('webcomponent.joomla-alert') - ->useScript('webcomponent.joomla-alert'); + ->useStyle('webcomponent.joomla-alert') + ->useScript('webcomponent.joomla-alert'); +$output = null; + +if (is_array($msgList) && !empty($msgList)) : + foreach ($msgList as $type => $msgs) : + $output = LayoutHelper::render('joomla.system.joomla-alert', ['alertType' => $alert[$type], 'type' => $type, 'msg' => $msgs]); + endforeach; +endif; ?>
-
- - $msgs) : ?> - - -
- - -
-
- -
- -
- -
- - -
+
From 1ce10bb2cf16f1118e62ad59bae2a29889ba2e48 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Fri, 25 Sep 2020 11:28:32 +0200 Subject: [PATCH 02/11] Update message.php --- layouts/joomla/system/message.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index 175696518fc39..9df31b82e4f1e 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -17,15 +17,15 @@ $msgList = $displayData['msgList']; $alert = [ - CMSApplication::MSG_EMERGENCY => 'danger', - CMSApplication::MSG_ALERT => 'danger', - CMSApplication::MSG_CRITICAL => 'danger', - CMSApplication::MSG_ERROR => 'danger', - CMSApplication::MSG_WARNING => 'warning', - CMSApplication::MSG_NOTICE => 'info', - CMSApplication::MSG_INFO => 'info', - CMSApplication::MSG_DEBUG => 'info', - 'message' => 'success' + CMSApplication::MSG_EMERGENCY => 'danger', + CMSApplication::MSG_ALERT => 'danger', + CMSApplication::MSG_CRITICAL => 'danger', + CMSApplication::MSG_ERROR => 'danger', + CMSApplication::MSG_WARNING => 'warning', + CMSApplication::MSG_NOTICE => 'info', + CMSApplication::MSG_INFO => 'info', + CMSApplication::MSG_DEBUG => 'info', + 'message' => 'success' ]; // Load JavaScript message titles @@ -41,8 +41,8 @@ // Alerts progressive enhancement Factory::getDocument()->getWebAssetManager() - ->useStyle('webcomponent.joomla-alert') - ->useScript('webcomponent.joomla-alert'); + ->useStyle('webcomponent.joomla-alert') + ->useScript('webcomponent.joomla-alert'); $output = null; From 98e488d890c81b560d7bd35a84df63091557e349 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Fri, 25 Sep 2020 12:19:07 +0200 Subject: [PATCH 03/11] remove extra jlayout file --- layouts/joomla/system/joomla-alert.php | 28 -------------------------- 1 file changed, 28 deletions(-) delete mode 100644 layouts/joomla/system/joomla-alert.php diff --git a/layouts/joomla/system/joomla-alert.php b/layouts/joomla/system/joomla-alert.php deleted file mode 100644 index e1333c5ebae49..0000000000000 --- a/layouts/joomla/system/joomla-alert.php +++ /dev/null @@ -1,28 +0,0 @@ - - - -
- - -
-
- -
- -
- -
From e440e4240c2ae4b06e08e5ca7b0b9911eb57c537 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Fri, 25 Sep 2020 12:19:36 +0200 Subject: [PATCH 04/11] add the else statement when msgList is empty. that's easy --- layouts/joomla/system/message.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index 9df31b82e4f1e..b6023146a322d 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -12,7 +12,6 @@ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; -use Joomla\CMS\Layout\LayoutHelper; $msgList = $displayData['msgList']; @@ -44,14 +43,27 @@ ->useStyle('webcomponent.joomla-alert') ->useScript('webcomponent.joomla-alert'); -$output = null; - -if (is_array($msgList) && !empty($msgList)) : - foreach ($msgList as $type => $msgs) : - $output = LayoutHelper::render('joomla.system.joomla-alert', ['alertType' => $alert[$type], 'type' => $type, 'msg' => $msgs]); - endforeach; -endif; ?>
-
+ +
+ $msgs) : ?> + + +
+ + +
+
+ +
+ +
+ +
+ +
+ +
+
From 0d92d344ab86992d0b9f5b4f3b04546672cc2ee4 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Sat, 17 Oct 2020 22:16:22 +0200 Subject: [PATCH 05/11] rewrite current PHP code so all html will be put directly after each other --- layouts/joomla/system/message.php | 73 +++++++++++++++++-------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index b6023146a322d..e46a579864194 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -16,15 +16,15 @@ $msgList = $displayData['msgList']; $alert = [ - CMSApplication::MSG_EMERGENCY => 'danger', - CMSApplication::MSG_ALERT => 'danger', - CMSApplication::MSG_CRITICAL => 'danger', - CMSApplication::MSG_ERROR => 'danger', - CMSApplication::MSG_WARNING => 'warning', - CMSApplication::MSG_NOTICE => 'info', - CMSApplication::MSG_INFO => 'info', - CMSApplication::MSG_DEBUG => 'info', - 'message' => 'success' + CMSApplication::MSG_EMERGENCY => 'danger', + CMSApplication::MSG_ALERT => 'danger', + CMSApplication::MSG_CRITICAL => 'danger', + CMSApplication::MSG_ERROR => 'danger', + CMSApplication::MSG_WARNING => 'warning', + CMSApplication::MSG_NOTICE => 'info', + CMSApplication::MSG_INFO => 'info', + CMSApplication::MSG_DEBUG => 'info', + 'message' => 'success' ]; // Load JavaScript message titles @@ -40,30 +40,35 @@ // Alerts progressive enhancement Factory::getDocument()->getWebAssetManager() - ->useStyle('webcomponent.joomla-alert') - ->useScript('webcomponent.joomla-alert'); + ->useStyle('webcomponent.joomla-alert') + ->useScript('webcomponent.joomla-alert'); +$msgOutput = []; + +if (is_array($msgList) && !empty($msgList)) : + $msgOutput[] = '
'; + + foreach ($msgList as $type => $msgs) : + $msgOutput[] = ''; + + if (!empty($msgs)) : + $msgOutput[] = '
'; + $msgOutput[] = ''; + $msgOutput[] = '' . Text::_($type) . ''; + $msgOutput[] = '
'; + $msgOutput[] = '
'; + + foreach ($msgs as $msg) : + $msgOutput[] = '
' . $msg . '
'; + endforeach; + + $msgOutput[] = '
'; + endif; + + $msgOutput[] = '
'; + endforeach; + + $msgOutput[] = '
'; +endif; ?> -
- -
- $msgs) : ?> - - -
- - -
-
- -
- -
- -
- -
- -
- -
+
From 24bda34dfa498783cae301a9dbb14234d03b83e4 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Sat, 17 Oct 2020 22:19:55 +0200 Subject: [PATCH 06/11] Update layouts/joomla/system/message.php Co-authored-by: Richard Fath --- layouts/joomla/system/message.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index e46a579864194..347b7e90efae0 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -16,15 +16,15 @@ $msgList = $displayData['msgList']; $alert = [ - CMSApplication::MSG_EMERGENCY => 'danger', - CMSApplication::MSG_ALERT => 'danger', - CMSApplication::MSG_CRITICAL => 'danger', - CMSApplication::MSG_ERROR => 'danger', - CMSApplication::MSG_WARNING => 'warning', - CMSApplication::MSG_NOTICE => 'info', - CMSApplication::MSG_INFO => 'info', - CMSApplication::MSG_DEBUG => 'info', - 'message' => 'success' + CMSApplication::MSG_EMERGENCY => 'danger', + CMSApplication::MSG_ALERT => 'danger', + CMSApplication::MSG_CRITICAL => 'danger', + CMSApplication::MSG_ERROR => 'danger', + CMSApplication::MSG_WARNING => 'warning', + CMSApplication::MSG_NOTICE => 'info', + CMSApplication::MSG_INFO => 'info', + CMSApplication::MSG_DEBUG => 'info', + 'message' => 'success' ]; // Load JavaScript message titles From d8ba8905df05e90ab27b8e13a309a4f4f7a87c67 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Sat, 17 Oct 2020 22:20:03 +0200 Subject: [PATCH 07/11] Update layouts/joomla/system/message.php Co-authored-by: Richard Fath --- layouts/joomla/system/message.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index 347b7e90efae0..6c1db14a2a1eb 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -40,8 +40,8 @@ // Alerts progressive enhancement Factory::getDocument()->getWebAssetManager() - ->useStyle('webcomponent.joomla-alert') - ->useScript('webcomponent.joomla-alert'); + ->useStyle('webcomponent.joomla-alert') + ->useScript('webcomponent.joomla-alert'); $msgOutput = []; From a0562d6e4f0bf1dcb083ce6a5caec86b60cf5812 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Wed, 21 Oct 2020 09:02:00 +0200 Subject: [PATCH 08/11] move wrapper --- layouts/joomla/system/message.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index 6c1db14a2a1eb..6088b067acaf7 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -45,30 +45,25 @@ $msgOutput = []; +$msgOutput = []; +$msgOutput[] = '
'; if (is_array($msgList) && !empty($msgList)) : - $msgOutput[] = '
'; - foreach ($msgList as $type => $msgs) : $msgOutput[] = ''; - if (!empty($msgs)) : $msgOutput[] = '
'; $msgOutput[] = ''; $msgOutput[] = '' . Text::_($type) . ''; $msgOutput[] = '
'; $msgOutput[] = '
'; - foreach ($msgs as $msg) : $msgOutput[] = '
' . $msg . '
'; endforeach; - $msgOutput[] = '
'; endif; - $msgOutput[] = '
'; endforeach; - - $msgOutput[] = '
'; endif; +$msgOutput[] = '
'; ?>
From 88f15681b9a93a5b89929042b49627f7ff393692 Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Wed, 21 Oct 2020 09:06:50 +0200 Subject: [PATCH 09/11] put if-else in a wrapper --- layouts/joomla/system/message.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index 6088b067acaf7..dab59a8fcc623 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -49,7 +49,7 @@ $msgOutput[] = '
'; if (is_array($msgList) && !empty($msgList)) : foreach ($msgList as $type => $msgs) : - $msgOutput[] = ''; + $msgOutput[] = ''; if (!empty($msgs)) : $msgOutput[] = '
'; $msgOutput[] = ''; From e7c460d81be86a0fca3551d849550b91e22b419a Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Wed, 21 Oct 2020 09:44:58 +0200 Subject: [PATCH 10/11] changed array into string to prevent implode --- layouts/joomla/system/message.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index dab59a8fcc623..e2c88e3d7f845 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -43,27 +43,24 @@ ->useStyle('webcomponent.joomla-alert') ->useScript('webcomponent.joomla-alert'); -$msgOutput = []; - -$msgOutput = []; -$msgOutput[] = '
'; +$msgOutput = '
'; if (is_array($msgList) && !empty($msgList)) : foreach ($msgList as $type => $msgs) : - $msgOutput[] = ''; + $msgOutput .= ''; if (!empty($msgs)) : - $msgOutput[] = '
'; - $msgOutput[] = ''; - $msgOutput[] = '' . Text::_($type) . ''; - $msgOutput[] = '
'; - $msgOutput[] = '
'; + $msgOutput .= '
'; + $msgOutput .= ''; + $msgOutput .= '' . Text::_($type) . ''; + $msgOutput .= '
'; + $msgOutput .= '
'; foreach ($msgs as $msg) : - $msgOutput[] = '
' . $msg . '
'; + $msgOutput .= '
' . $msg . '
'; endforeach; - $msgOutput[] = '
'; + $msgOutput .= '
'; endif; - $msgOutput[] = '
'; + $msgOutput .= '
'; endforeach; endif; -$msgOutput[] = '
'; +$msgOutput .= '
'; ?> -
+
From 3450d604815d610477512c471da2137a168f484f Mon Sep 17 00:00:00 2001 From: Hans Kuijpers Date: Wed, 21 Oct 2020 10:17:55 +0200 Subject: [PATCH 11/11] :recycle: clean code --- layouts/joomla/system/message.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/layouts/joomla/system/message.php b/layouts/joomla/system/message.php index e2c88e3d7f845..cca4581cc4924 100644 --- a/layouts/joomla/system/message.php +++ b/layouts/joomla/system/message.php @@ -13,7 +13,8 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; -$msgList = $displayData['msgList']; +$msgList = $displayData['msgList']; +$msgOutput = ''; $alert = [ CMSApplication::MSG_EMERGENCY => 'danger', @@ -43,7 +44,6 @@ ->useStyle('webcomponent.joomla-alert') ->useScript('webcomponent.joomla-alert'); -$msgOutput = '
'; if (is_array($msgList) && !empty($msgList)) : foreach ($msgList as $type => $msgs) : $msgOutput .= ''; @@ -61,6 +61,5 @@ $msgOutput .= ''; endforeach; endif; -$msgOutput .= '
'; ?> -
+