From 9b7bef7a1657497495e002a8f3322187be02086d Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sat, 5 Jun 2021 14:43:14 +0530 Subject: [PATCH 01/74] create language constant for Add Module Button field --- administrator/language/en-GB/com_templates.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/administrator/language/en-GB/com_templates.ini b/administrator/language/en-GB/com_templates.ini index 8e16303aa43..2dadfdbc533 100644 --- a/administrator/language/en-GB/com_templates.ini +++ b/administrator/language/en-GB/com_templates.ini @@ -27,6 +27,7 @@ COM_TEMPLATES_CHECK_FILE_OWNERSHIP="Check file ownership" COM_TEMPLATES_CLICK_TO_ENLARGE="Select to enlarge." COM_TEMPLATES_COMPILE_ERROR="An error occurred. Failed to compile." COM_TEMPLATES_COMPILE_LESS="You should compile %s to generate a CSS file." +COM_TEMPLATES_CONFIG_ADD_MODULE_LABEL="Add Module Button" COM_TEMPLATES_CONFIG_FIELDSET_DESC="Global configuration for templates." COM_TEMPLATES_CONFIG_FONT_LABEL="Valid Font Formats" COM_TEMPLATES_CONFIG_IMAGE_LABEL="Valid Image Formats" From 77932798aea3a2a2beccff046a4a7841d5db57b6 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sat, 5 Jun 2021 15:44:04 +0530 Subject: [PATCH 02/74] switcher for Add Module field --- administrator/components/com_templates/config.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/administrator/components/com_templates/config.xml b/administrator/components/com_templates/config.xml index 6641561dd5e..2b533e48fb1 100644 --- a/administrator/components/com_templates/config.xml +++ b/administrator/components/com_templates/config.xml @@ -16,6 +16,17 @@ + + + + + Date: Sat, 5 Jun 2021 16:01:53 +0530 Subject: [PATCH 03/74] add module button field value to param in installation sql script --- installation/sql/mysql/base.sql | 2 +- installation/sql/postgresql/base.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index 795e0b55b8b..dfe7705acc6 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -163,7 +163,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, (0, 'com_modules', 'component', 'com_modules', '', 1, 1, 1, 1, 1, '', '', ''), (0, 'com_newsfeeds', 'component', 'com_newsfeeds', '', 1, 1, 1, 0, 1, '', '{"newsfeed_layout":"_:default","save_history":"1","history_limit":5,"show_feed_image":"1","show_feed_description":"1","show_item_description":"1","feed_character_count":"0","feed_display_order":"des","float_first":"right","float_second":"right","show_tags":"1","category_layout":"_:default","show_category_title":"1","show_description":"1","show_description_image":"1","maxLevel":"-1","show_empty_categories":"0","show_subcat_desc":"1","show_cat_items":"1","show_cat_tags":"1","show_base_description":"1","maxLevelcat":"-1","show_empty_categories_cat":"0","show_subcat_desc_cat":"1","show_cat_items_cat":"1","filter_field":"1","show_pagination_limit":"1","show_headings":"1","show_articles":"0","show_link":"1","show_pagination":"1","show_pagination_results":"1","sef_ids":1}', ''), (0, 'com_plugins', 'component', 'com_plugins', '', 1, 1, 1, 1, 1, '', '', ''), -(0, 'com_templates', 'component', 'com_templates', '', 1, 1, 1, 1, 1, '', '{"template_positions_display":"0","upload_limit":"10","image_formats":"gif,bmp,jpg,jpeg,png,webp","source_formats":"txt,less,ini,xml,js,php,css,scss,sass,json","font_formats":"woff,ttf,otf","compressed_formats":"zip"}', ''), +(0, 'com_templates', 'component', 'com_templates', '', 1, 1, 1, 1, 1, '', '{"template_positions_display":"0","show_add_module_button":"1","upload_limit":"10","image_formats":"gif,bmp,jpg,jpeg,png,webp","source_formats":"txt,less,ini,xml,js,php,css,scss,sass,json","font_formats":"woff,ttf,otf","compressed_formats":"zip"}', ''), (0, 'com_content', 'component', 'com_content', '', 1, 1, 0, 1, 1, '', '{"article_layout":"_:default","show_title":"1","link_titles":"1","show_intro":"1","show_category":"1","link_category":"1","show_parent_category":"0","link_parent_category":"0","show_author":"1","link_author":"0","show_create_date":"0","show_modify_date":"0","show_publish_date":"1","show_item_navigation":"1","show_vote":"0","show_tags":"1","show_readmore":"1","show_readmore_title":"1","readmore_limit":"100","record_hits":"1","show_hits":"1","show_noauth":"0","show_publishing_options":"1","show_article_options":"1","save_history":"1","history_limit":10,"show_urls_images_frontend":"0","show_urls_images_backend":"1","targeta":0,"targetb":0,"targetc":0,"float_intro":"left","float_fulltext":"left","category_layout":"_:blog","show_category_title":"0","show_description":"0","show_description_image":"0","maxLevel":"1","show_empty_categories":"0","show_no_articles":"1","show_subcat_desc":"1","show_cat_num_articles":"0","show_base_description":"1","maxLevelcat":"-1","show_empty_categories_cat":"0","show_subcat_desc_cat":"1","show_cat_num_articles_cat":"1","num_leading_articles":"1","num_intro_articles":"4","num_links":"4","show_subcategory_content":"0","link_intro_image":"0","show_pagination_limit":"1","filter_field":"hide","show_headings":"1","list_show_date":"0","date_format":"","list_show_hits":"1","list_show_author":"1","orderby_pri":"order","orderby_sec":"rdate","order_date":"published","show_pagination":"2","show_pagination_results":"1","show_feed_link":"1","feed_summary":"0","sef_ids":1}', ''), (0, 'com_config', 'component', 'com_config', '', 1, 1, 0, 1, 1, '', '{"filters":{"1":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"9":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"6":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"7":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"2":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"3":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"4":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"5":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"8":{"filter_type":"NONE","filter_tags":"","filter_attributes":""}}}', ''), (0, 'com_redirect', 'component', 'com_redirect', '', 1, 1, 0, 0, 1, '', '', ''), diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql index f50279c8447..253dff12d9d 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -169,7 +169,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", (0, 'com_modules', 'component', 'com_modules', '', 1, 1, 1, 1, 1, '', '', '', 0, 0), (0, 'com_newsfeeds', 'component', 'com_newsfeeds', '', 1, 1, 1, 0, 1, '', '{"newsfeed_layout":"_:default","save_history":"1","history_limit":5,"show_feed_image":"1","show_feed_description":"1","show_item_description":"1","feed_character_count":"0","feed_display_order":"des","float_first":"right","float_second":"right","show_tags":"1","category_layout":"_:default","show_category_title":"1","show_description":"1","show_description_image":"1","maxLevel":"-1","show_empty_categories":"0","show_subcat_desc":"1","show_cat_items":"1","show_cat_tags":"1","show_base_description":"1","maxLevelcat":"-1","show_empty_categories_cat":"0","show_subcat_desc_cat":"1","show_cat_items_cat":"1","filter_field":"1","show_pagination_limit":"1","show_headings":"1","show_articles":"0","show_link":"1","show_pagination":"1","show_pagination_results":"1","sef_ids":1}', '', 0, 0), (0, 'com_plugins', 'component', 'com_plugins', '', 1, 1, 1, 1, 1, '', '', '', 0, 0), -(0, 'com_templates', 'component', 'com_templates', '', 1, 1, 1, 1, 1, '', '{"template_positions_display":"0","upload_limit":"10","image_formats":"gif,bmp,jpg,jpeg,png,webp","source_formats":"txt,less,ini,xml,js,php,css,scss,sass,json","font_formats":"woff,ttf,otf","compressed_formats":"zip"}', '', 0, 0), +(0, 'com_templates', 'component', 'com_templates', '', 1, 1, 1, 1, 1, '', '{"template_positions_display":"0","show_add_module_button":"1","upload_limit":"10","image_formats":"gif,bmp,jpg,jpeg,png,webp","source_formats":"txt,less,ini,xml,js,php,css,scss,sass,json","font_formats":"woff,ttf,otf","compressed_formats":"zip"}', '', 0, 0), (0, 'com_content', 'component', 'com_content', '', 1, 1, 0, 1, 1, '', '{"article_layout":"_:default","show_title":"1","link_titles":"1","show_intro":"1","show_category":"1","link_category":"1","show_parent_category":"0","link_parent_category":"0","show_author":"1","link_author":"0","show_create_date":"0","show_modify_date":"0","show_publish_date":"1","show_item_navigation":"1","show_vote":"0","show_tags":"1","show_readmore":"1","show_readmore_title":"1","readmore_limit":"100","record_hits":"1","show_hits":"1","show_noauth":"0","show_publishing_options":"1","show_article_options":"1","save_history":"1","history_limit":10,"show_urls_images_frontend":"0","show_urls_images_backend":"1","targeta":0,"targetb":0,"targetc":0,"float_intro":"left","float_fulltext":"left","category_layout":"_:blog","show_category_title":"0","show_description":"0","show_description_image":"0","maxLevel":"1","show_empty_categories":"0","show_no_articles":"1","show_subcat_desc":"1","show_cat_num_articles":"0","show_base_description":"1","maxLevelcat":"-1","show_empty_categories_cat":"0","show_subcat_desc_cat":"1","show_cat_num_articles_cat":"1","num_leading_articles":"1","num_intro_articles":"4","num_links":"4","show_subcategory_content":"0","link_intro_image":"0","show_pagination_limit":"1","filter_field":"hide","show_headings":"1","list_show_date":"0","date_format":"","list_show_hits":"1","list_show_author":"1","orderby_pri":"order","orderby_sec":"rdate","order_date":"published","show_pagination":"2","show_pagination_results":"1","show_feed_link":"1","feed_summary":"0","sef_ids":1}', '', 0, 0), (0, 'com_config', 'component', 'com_config', '', 1, 1, 0, 1, 1, '', '{"filters":{"1":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"9":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"6":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"7":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"2":{"filter_type":"NH","filter_tags":"","filter_attributes":""},"3":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"4":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"5":{"filter_type":"BL","filter_tags":"","filter_attributes":""},"8":{"filter_type":"NONE","filter_tags":"","filter_attributes":""}}}', '', 0, 0), (0, 'com_redirect', 'component', 'com_redirect', '', 1, 1, 0, 0, 1, '', '', '', 0, 0), From cd3cfc174b01663bb9e13bd372fda78e5feebfbe Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sat, 5 Jun 2021 18:27:36 +0530 Subject: [PATCH 04/74] display Add Module Here button when pm is passed as a get parameter --- administrator/language/en-GB/joomla.ini | 1 + api/language/en-GB/joomla.ini | 1 + language/en-GB/joomla.ini | 1 + layouts/chromes/outline.php | 7 +++++++ libraries/src/Helper/ModuleHelper.php | 4 ++-- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index 0056c54e344..4cea15459a1 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -556,6 +556,7 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" +JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PUBLISHED_DATE="Published Date" diff --git a/api/language/en-GB/joomla.ini b/api/language/en-GB/joomla.ini index 8c83f815474..c6dfff6eb91 100644 --- a/api/language/en-GB/joomla.ini +++ b/api/language/en-GB/joomla.ini @@ -551,6 +551,7 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" +JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PUBLISHED_DATE="Published Date" diff --git a/language/en-GB/joomla.ini b/language/en-GB/joomla.ini index 4f85e9610ed..0f8145fc4c6 100644 --- a/language/en-GB/joomla.ini +++ b/language/en-GB/joomla.ini @@ -322,6 +322,7 @@ JGLOBAL_NUM="#" JGLOBAL_OTPMETHOD_NONE="Disable Two Factor Authentication" JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." +JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PRINT="Print" diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 1312c50ffc7..d7b6086c54b 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -18,6 +18,8 @@ $module = $displayData['module']; +// Place Modules Button +$showModuleButton = Factory::getApplication()->input->getBool('pm'); ?>
@@ -27,6 +29,11 @@
style); ?>
+
+ + + +
content; ?> diff --git a/libraries/src/Helper/ModuleHelper.php b/libraries/src/Helper/ModuleHelper.php index b955e276469..eab408aeb5d 100644 --- a/libraries/src/Helper/ModuleHelper.php +++ b/libraries/src/Helper/ModuleHelper.php @@ -100,7 +100,7 @@ public static function &getModules($position) if (\count($result) === 0) { - if ($input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) + if (($input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) || $input->getBool('pm')) { $result[0] = static::createDummyModule(); $result[0]->title = $position; @@ -208,7 +208,7 @@ public static function renderModule($module, $attribs = array()) } // Dynamically add outline style - if ($app->input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) + if (($app->input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) || $app->input->getBool('pm')) { $attribs['style'] .= ' outline'; } From 50ca7ceb0e26833e23e1e456208e8356a5d50309 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sat, 5 Jun 2021 20:02:04 +0530 Subject: [PATCH 05/74] add module button added to the frontend that links to the place module page --- language/en-GB/tpl_cassiopeia.ini | 1 + templates/cassiopeia/index.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/language/en-GB/tpl_cassiopeia.ini b/language/en-GB/tpl_cassiopeia.ini index 9bfc8b9a0b7..fb54ef46cce 100644 --- a/language/en-GB/tpl_cassiopeia.ini +++ b/language/en-GB/tpl_cassiopeia.ini @@ -4,6 +4,7 @@ ; Note : All ini files need to be saved as UTF-8 CASSIOPEIA="Cassiopeia Site template" +TPL_CASSIOPEIA_ADD_MODULE="Add Module" TPL_CASSIOPEIA_BACKTOTOP="Back to Top" TPL_CASSIOPEIA_BACKTOTOP_LABEL="Back-to-top Link" TPL_CASSIOPEIA_BRAND_LABEL="Brand" diff --git a/templates/cassiopeia/index.php b/templates/cassiopeia/index.php index 517fc465b0e..480d09ab983 100644 --- a/templates/cassiopeia/index.php +++ b/templates/cassiopeia/index.php @@ -9,6 +9,7 @@ defined('_JEXEC') or die; +use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; @@ -34,6 +35,9 @@ $menu = $app->getMenu()->getActive(); $pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : ''; +// Do not display Add Module Button if Template Position Preview or Place Modules is True +$displayAddModuleBtn = !$app->input->getBool('tp') && !$app->input->getBool('pm') && ComponentHelper::getParams('com_templates')->get('show_add_module_button'); + // Template path $templatePath = 'templates/' . $this->template; @@ -188,6 +192,12 @@
+ +
+ + +
+
From e7ce2f1526cb9dff0f990bfac26d92adeec0e3e3 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sun, 6 Jun 2021 11:17:52 +0530 Subject: [PATCH 06/74] Make Add Module Here button accessible by mentioning the position --- administrator/language/en-GB/joomla.ini | 2 +- api/language/en-GB/joomla.ini | 2 +- language/en-GB/joomla.ini | 2 +- layouts/chromes/outline.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index 4cea15459a1..98987cc3cdd 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -556,7 +556,7 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" -JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here" +JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PUBLISHED_DATE="Published Date" diff --git a/api/language/en-GB/joomla.ini b/api/language/en-GB/joomla.ini index c6dfff6eb91..235eb43c580 100644 --- a/api/language/en-GB/joomla.ini +++ b/api/language/en-GB/joomla.ini @@ -551,7 +551,7 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" -JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here" +JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PUBLISHED_DATE="Published Date" diff --git a/language/en-GB/joomla.ini b/language/en-GB/joomla.ini index 0f8145fc4c6..b9aae7130e3 100644 --- a/language/en-GB/joomla.ini +++ b/language/en-GB/joomla.ini @@ -322,7 +322,7 @@ JGLOBAL_NUM="#" JGLOBAL_OTPMETHOD_NONE="Disable Two Factor Authentication" JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." -JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here" +JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PRINT="Print" diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index d7b6086c54b..319fde4eca3 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -31,7 +31,7 @@
From 246391e6b3356798cb9d2ecdc47c1417ceca0d73 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sun, 6 Jun 2021 15:25:43 +0530 Subject: [PATCH 07/74] Permissions Check for Add Module Frontend Flow --- layouts/chromes/outline.php | 11 ++++++----- libraries/src/Helper/ModuleHelper.php | 5 +++-- templates/cassiopeia/index.php | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 319fde4eca3..690654f3560 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -10,6 +10,7 @@ defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; Factory::getApplication()->getDocument() @@ -19,7 +20,7 @@ $module = $displayData['module']; // Place Modules Button -$showModuleButton = Factory::getApplication()->input->getBool('pm'); +$showModuleButton = Factory::getApplication()->input->getBool('pm') && ContentHelper::getActions('com_modules')->get('core.create'); ?>
@@ -29,11 +30,11 @@
style); ?>
-
- + + +
+
content; ?> diff --git a/libraries/src/Helper/ModuleHelper.php b/libraries/src/Helper/ModuleHelper.php index eab408aeb5d..260af14f02a 100644 --- a/libraries/src/Helper/ModuleHelper.php +++ b/libraries/src/Helper/ModuleHelper.php @@ -15,6 +15,7 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\LanguageHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; @@ -100,7 +101,7 @@ public static function &getModules($position) if (\count($result) === 0) { - if (($input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) || $input->getBool('pm')) + if (($input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) || ($input->getBool('pm') && ContentHelper::getActions('com_modules')->get('core.create'))) { $result[0] = static::createDummyModule(); $result[0]->title = $position; @@ -208,7 +209,7 @@ public static function renderModule($module, $attribs = array()) } // Dynamically add outline style - if (($app->input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) || $app->input->getBool('pm')) + if (($app->input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display')) || ($app->input->getBool('pm') && ContentHelper::getActions('com_modules')->get('core.create'))) { $attribs['style'] .= ' outline'; } diff --git a/templates/cassiopeia/index.php b/templates/cassiopeia/index.php index 480d09ab983..b314f51544e 100644 --- a/templates/cassiopeia/index.php +++ b/templates/cassiopeia/index.php @@ -11,6 +11,7 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; +use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Uri\Uri; @@ -36,7 +37,7 @@ $pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : ''; // Do not display Add Module Button if Template Position Preview or Place Modules is True -$displayAddModuleBtn = !$app->input->getBool('tp') && !$app->input->getBool('pm') && ComponentHelper::getParams('com_templates')->get('show_add_module_button'); +$displayAddModuleBtn = !$app->input->getBool('tp') && !$app->input->getBool('pm') && ComponentHelper::getParams('com_templates')->get('show_add_module_button') && ContentHelper::getActions('com_modules')->get('core.create'); // Template path $templatePath = 'templates/' . $this->template; From 75f6d64211b0cb1d0a0d2437e692539fdf42c19c Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sun, 6 Jun 2021 18:05:52 +0530 Subject: [PATCH 08/74] Added language constant for Invalid Position Error --- administrator/language/en-GB/com_modules.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/administrator/language/en-GB/com_modules.ini b/administrator/language/en-GB/com_modules.ini index 0958eb86ac8..6f0cef77858 100644 --- a/administrator/language/en-GB/com_modules.ini +++ b/administrator/language/en-GB/com_modules.ini @@ -32,6 +32,7 @@ COM_MODULES_EMPTYSTATE_TITLE_SITE="No Site Modules have been created yet." COM_MODULES_ERR_XML="Module XML data not available" COM_MODULES_ERROR_CANNOT_FIND_MODULE="Can't find module" COM_MODULES_ERROR_INVALID_EXTENSION="Invalid module" +COM_MODULES_ERROR_INVALID_POSITION="Invalid position" COM_MODULES_ERROR_NO_MODULES_SELECTED="No module selected." COM_MODULES_EXPAND="Expand" COM_MODULES_EXTENSION_PUBLISHED_DISABLED="Module disabled and published." From ffca089060df0a3a06ab065c50ae786d6495be0c Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sun, 6 Jun 2021 19:32:14 +0530 Subject: [PATCH 09/74] added links for passing data from add module btn --- layouts/chromes/outline.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 690654f3560..86807172c14 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -13,14 +13,19 @@ use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; -Factory::getApplication()->getDocument() +$app = Factory::getApplication(); +$app->getDocument() ->getWebAssetManager() ->registerAndUseStyle('layouts.chromes.outline', 'layouts/chromes/outline.css'); $module = $displayData['module']; // Place Modules Button -$showModuleButton = Factory::getApplication()->input->getBool('pm') && ContentHelper::getActions('com_modules')->get('core.create'); +$showModuleButton = $app->input->getBool('pm') && ContentHelper::getActions('com_modules')->get('core.create'); + +// Redirect URL Params for Placing Modules +$menuId = $app->getMenu()->getActive(); +$templateId = $app->getTemplate(true)->id; ?>
@@ -32,7 +37,9 @@
From 5c5de2d281ecd0704a47d9f0070c28e05710dd25 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Sun, 6 Jun 2021 19:32:54 +0530 Subject: [PATCH 10/74] init new controller for set position of module --- .../src/Controller/ModuleController.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/administrator/components/com_modules/src/Controller/ModuleController.php b/administrator/components/com_modules/src/Controller/ModuleController.php index 3a1d093ab77..a3c822aa29b 100644 --- a/administrator/components/com_modules/src/Controller/ModuleController.php +++ b/administrator/components/com_modules/src/Controller/ModuleController.php @@ -68,6 +68,43 @@ public function add() $app->setUserState('com_modules.add.module.params', $params); } + /** + * Set Position given by Frontend Module Placement. + * + * @return \Exception|void True if the record can be added, a \Exception object if not. + * + * @since __DEPLOY_VERSION__ + */ + public function setPosition() + { + $app = $this->app; + + // Look for the Template, Menu ID and Position. + $menuId = $this->input->getInt('menu'); + $position = $this->input->get('position'); + $templateId = $this->input->getInt('template'); + + // To Do: Remove the echo and properly redirect & pass the data + echo $position . "
"; + echo $menuId . "
"; + echo $templateId . "
"; + die(); + + if (empty($position) || empty($templateId)) + { + $redirectUrl = $this->input->server->getString('HTTP_REFERER'); + + $this->setRedirect(Route::_($redirectUrl, false)); + + $app->enqueueMessage(Text::_('COM_MODULES_ERROR_INVALID_POSITION'), 'warning'); + } + + $app->setUserState('com_modules.add.module.menuId', $menuId); + $app->setUserState('com_modules.add.module.position', $position); + $app->setUserState('com_modules.add.module.templateId', $templateId); + echo "es";die(); + } + /** * Override parent cancel method to reset the add module state. * From e84db8798b66f3cfcb062a49171861251754b85c Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Mon, 7 Jun 2021 11:30:54 +0530 Subject: [PATCH 11/74] Separate HTML tags from language constants for Place Module --- administrator/language/en-GB/joomla.ini | 3 ++- api/language/en-GB/joomla.ini | 3 ++- language/en-GB/joomla.ini | 3 ++- layouts/chromes/outline.php | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index 98987cc3cdd..c858433c7d7 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -556,7 +556,8 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" -JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here in Position: %s" +JGLOBAL_PREVIEW_PLACE_MODULE="Add Module Here" +JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PUBLISHED_DATE="Published Date" diff --git a/api/language/en-GB/joomla.ini b/api/language/en-GB/joomla.ini index 235eb43c580..abfc34377bc 100644 --- a/api/language/en-GB/joomla.ini +++ b/api/language/en-GB/joomla.ini @@ -551,7 +551,8 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" -JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here in Position: %s" +JGLOBAL_PREVIEW_PLACE_MODULE="Add Module Here" +JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PUBLISHED_DATE="Published Date" diff --git a/language/en-GB/joomla.ini b/language/en-GB/joomla.ini index b9aae7130e3..e7bc1ea80e9 100644 --- a/language/en-GB/joomla.ini +++ b/language/en-GB/joomla.ini @@ -322,7 +322,8 @@ JGLOBAL_NUM="#" JGLOBAL_OTPMETHOD_NONE="Disable Two Factor Authentication" JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." -JGLOBAL_PREVIEW_ADD_MODULE="Add Module Here in Position: %s" +JGLOBAL_PREVIEW_PLACE_MODULE="Add Module Here" +JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" JGLOBAL_PRINT="Print" diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 86807172c14..238b1c3a37e 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -38,7 +38,10 @@ From 80cf9a7a113b1d87c40cfed8b14dbe97e3422db5 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Mon, 7 Jun 2021 11:32:05 +0530 Subject: [PATCH 12/74] Rephrase Add Module to Place Module --- administrator/language/en-GB/joomla.ini | 2 +- api/language/en-GB/joomla.ini | 2 +- language/en-GB/joomla.ini | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index c858433c7d7..ae24ac992d4 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -556,7 +556,7 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" -JGLOBAL_PREVIEW_PLACE_MODULE="Add Module Here" +JGLOBAL_PREVIEW_PLACE_MODULE="Place Module Here" JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" diff --git a/api/language/en-GB/joomla.ini b/api/language/en-GB/joomla.ini index abfc34377bc..3426939bfca 100644 --- a/api/language/en-GB/joomla.ini +++ b/api/language/en-GB/joomla.ini @@ -551,7 +551,7 @@ JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions" JGLOBAL_PREVIEW="Preview" -JGLOBAL_PREVIEW_PLACE_MODULE="Add Module Here" +JGLOBAL_PREVIEW_PLACE_MODULE="Place Module Here" JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" diff --git a/language/en-GB/joomla.ini b/language/en-GB/joomla.ini index e7bc1ea80e9..00da65fcd22 100644 --- a/language/en-GB/joomla.ini +++ b/language/en-GB/joomla.ini @@ -322,7 +322,7 @@ JGLOBAL_NUM="#" JGLOBAL_OTPMETHOD_NONE="Disable Two Factor Authentication" JGLOBAL_PASSWORD="Password" JGLOBAL_PASSWORD_RESET_REQUIRED="You are required to reset your password before proceeding." -JGLOBAL_PREVIEW_PLACE_MODULE="Add Module Here" +JGLOBAL_PREVIEW_PLACE_MODULE="Place Module Here" JGLOBAL_PREVIEW_PLACE_MODULE_POSITION="in Position: %s" JGLOBAL_PREVIEW_POSITION="Position: %s" JGLOBAL_PREVIEW_STYLE="Style: %s" From 792bfc146fb25e018fc7cf223e6fdd6251ed9ee1 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Mon, 7 Jun 2021 12:02:42 +0530 Subject: [PATCH 13/74] Remove redundant Template ID from URL params for place modules --- .../com_modules/src/Controller/ModuleController.php | 8 ++------ layouts/chromes/outline.php | 5 ++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/administrator/components/com_modules/src/Controller/ModuleController.php b/administrator/components/com_modules/src/Controller/ModuleController.php index a3c822aa29b..b423baa6f93 100644 --- a/administrator/components/com_modules/src/Controller/ModuleController.php +++ b/administrator/components/com_modules/src/Controller/ModuleController.php @@ -82,15 +82,12 @@ public function setPosition() // Look for the Template, Menu ID and Position. $menuId = $this->input->getInt('menu'); $position = $this->input->get('position'); - $templateId = $this->input->getInt('template'); // To Do: Remove the echo and properly redirect & pass the data echo $position . "
"; echo $menuId . "
"; - echo $templateId . "
"; - die(); - if (empty($position) || empty($templateId)) + if (empty($position)) { $redirectUrl = $this->input->server->getString('HTTP_REFERER'); @@ -101,8 +98,7 @@ public function setPosition() $app->setUserState('com_modules.add.module.menuId', $menuId); $app->setUserState('com_modules.add.module.position', $position); - $app->setUserState('com_modules.add.module.templateId', $templateId); - echo "es";die(); + die(); } /** diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 238b1c3a37e..c3a96d1062d 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -23,9 +23,8 @@ // Place Modules Button $showModuleButton = $app->input->getBool('pm') && ContentHelper::getActions('com_modules')->get('core.create'); -// Redirect URL Params for Placing Modules +// Redirect URL Menu ID Param for Placing Modules $menuId = $app->getMenu()->getActive(); -$templateId = $app->getTemplate(true)->id; ?>
@@ -37,7 +36,7 @@
- + position); ?> From 929716912e7ace6800c810ef3b85eafb49caef9a Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Mon, 7 Jun 2021 13:09:44 +0530 Subject: [PATCH 14/74] Controller for Set Position works and clear new state vars after save --- .../src/Controller/ModuleController.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/administrator/components/com_modules/src/Controller/ModuleController.php b/administrator/components/com_modules/src/Controller/ModuleController.php index b423baa6f93..e91121121bf 100644 --- a/administrator/components/com_modules/src/Controller/ModuleController.php +++ b/administrator/components/com_modules/src/Controller/ModuleController.php @@ -71,7 +71,7 @@ public function add() /** * Set Position given by Frontend Module Placement. * - * @return \Exception|void True if the record can be added, a \Exception object if not. + * @return void * * @since __DEPLOY_VERSION__ */ @@ -83,10 +83,6 @@ public function setPosition() $menuId = $this->input->getInt('menu'); $position = $this->input->get('position'); - // To Do: Remove the echo and properly redirect & pass the data - echo $position . "
"; - echo $menuId . "
"; - if (empty($position)) { $redirectUrl = $this->input->server->getString('HTTP_REFERER'); @@ -98,7 +94,9 @@ public function setPosition() $app->setUserState('com_modules.add.module.menuId', $menuId); $app->setUserState('com_modules.add.module.position', $position); - die(); + + $redirectUrl = 'index.php?option=com_modules&view=select&client_id=0'; + $this->setRedirect(Route::_($redirectUrl, false)); } /** @@ -116,6 +114,8 @@ public function cancel($key = null) $this->app->setUserState('com_modules.add.module.extension_id', null); $this->app->setUserState('com_modules.add.module.params', null); + $this->app->setUserState('com_modules.add.module.menuId', null); + $this->app->setUserState('com_modules.add.module.position', null); if ($return = $this->input->get('return', '', 'BASE64')) { @@ -239,6 +239,8 @@ protected function postSaveHook(BaseDatabaseModel $model, $validData = array()) } $this->app->setUserState('com_modules.add.module.params', null); + $this->app->setUserState('com_modules.add.module.menuId', null); + $this->app->setUserState('com_modules.add.module.position', null); } /** From e21bd091d9ef315ae1cbf4b8e7f2e65149a0355e Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Tue, 8 Jun 2021 17:02:11 +0530 Subject: [PATCH 15/74] Pre select module position --- .../com_modules/src/Controller/ModuleController.php | 2 +- .../components/com_modules/src/Model/ModuleModel.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_modules/src/Controller/ModuleController.php b/administrator/components/com_modules/src/Controller/ModuleController.php index e91121121bf..ae8bef7a328 100644 --- a/administrator/components/com_modules/src/Controller/ModuleController.php +++ b/administrator/components/com_modules/src/Controller/ModuleController.php @@ -92,7 +92,7 @@ public function setPosition() $app->enqueueMessage(Text::_('COM_MODULES_ERROR_INVALID_POSITION'), 'warning'); } - $app->setUserState('com_modules.add.module.menuId', $menuId); + $app->setUserState('com_modules.add.module.menu_id', $menuId); $app->setUserState('com_modules.add.module.position', $position); $redirectUrl = 'index.php?option=com_modules&view=select&client_id=0'; diff --git a/administrator/components/com_modules/src/Model/ModuleModel.php b/administrator/components/com_modules/src/Model/ModuleModel.php index f0634bbd374..fe2ca90a32a 100644 --- a/administrator/components/com_modules/src/Model/ModuleModel.php +++ b/administrator/components/com_modules/src/Model/ModuleModel.php @@ -642,7 +642,17 @@ protected function loadFormData() $clientId = $app->input->getInt('client_id', 0); $filters = (array) $app->getUserState('com_modules.modules.' . $clientId . '.filter'); $data->set('published', $app->input->getInt('published', ((isset($filters['state']) && $filters['state'] !== '') ? $filters['state'] : null))); - $data->set('position', $app->input->getInt('position', (!empty($filters['position']) ? $filters['position'] : null))); + + // Pre-select Module Position set by Frontend Placement if it exists. + if ($position = $app->getUserState('com_modules.add.module.position')) + { + $data->set('position', $position); + } + else + { + $data->set('position', $app->input->getInt('position', (!empty($filters['position']) ? $filters['position'] : null))); + } + $data->set('language', $app->input->getString('language', (!empty($filters['language']) ? $filters['language'] : null))); $data->set('access', $app->input->getInt('access', (!empty($filters['access']) ? $filters['access'] : $app->get('access')))); } From 696a524ce21953d0b4e90b2def2d1d8d505e493d Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Tue, 8 Jun 2021 20:49:20 +0530 Subject: [PATCH 16/74] rename menuId to menu_id --- .../com_modules/src/Controller/ModuleController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_modules/src/Controller/ModuleController.php b/administrator/components/com_modules/src/Controller/ModuleController.php index ae8bef7a328..13543280c67 100644 --- a/administrator/components/com_modules/src/Controller/ModuleController.php +++ b/administrator/components/com_modules/src/Controller/ModuleController.php @@ -114,7 +114,7 @@ public function cancel($key = null) $this->app->setUserState('com_modules.add.module.extension_id', null); $this->app->setUserState('com_modules.add.module.params', null); - $this->app->setUserState('com_modules.add.module.menuId', null); + $this->app->setUserState('com_modules.add.module.menu_id', null); $this->app->setUserState('com_modules.add.module.position', null); if ($return = $this->input->get('return', '', 'BASE64')) @@ -239,7 +239,7 @@ protected function postSaveHook(BaseDatabaseModel $model, $validData = array()) } $this->app->setUserState('com_modules.add.module.params', null); - $this->app->setUserState('com_modules.add.module.menuId', null); + $this->app->setUserState('com_modules.add.module.menu_id', null); $this->app->setUserState('com_modules.add.module.position', null); } From 6260cfae818718dbfe15122b5f0da4cb192339d3 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Wed, 9 Jun 2021 14:39:33 +0530 Subject: [PATCH 17/74] Rephrase setPosition controller to selectPosition --- .../com_modules/src/Controller/ModuleController.php | 4 ++-- layouts/chromes/outline.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_modules/src/Controller/ModuleController.php b/administrator/components/com_modules/src/Controller/ModuleController.php index 13543280c67..59ce5941bd2 100644 --- a/administrator/components/com_modules/src/Controller/ModuleController.php +++ b/administrator/components/com_modules/src/Controller/ModuleController.php @@ -69,13 +69,13 @@ public function add() } /** - * Set Position given by Frontend Module Placement. + * Set Position for the New Module in Frontend Module Placement. * * @return void * * @since __DEPLOY_VERSION__ */ - public function setPosition() + public function selectPosition() { $app = $this->app; diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index c3a96d1062d..070a82af767 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -36,7 +36,7 @@
- + position); ?> From e18a07bef1366b8366fd6c4b5472218921aee62e Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Wed, 9 Jun 2021 16:36:38 +0530 Subject: [PATCH 18/74] Pre select Module Menu Item --- .../com_modules/src/Model/ModuleModel.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_modules/src/Model/ModuleModel.php b/administrator/components/com_modules/src/Model/ModuleModel.php index fe2ca90a32a..c6d446c48ba 100644 --- a/administrator/components/com_modules/src/Model/ModuleModel.php +++ b/administrator/components/com_modules/src/Model/ModuleModel.php @@ -686,6 +686,7 @@ protected function loadFormData() */ public function getItem($pk = null) { + $app = Factory::getApplication(); $pk = (!empty($pk)) ? (int) $pk : (int) $this->getState('module.id'); $db = $this->getDbo(); @@ -767,8 +768,16 @@ public function getItem($pk = null) if (empty($pk)) { - // If this is a new module, assign to all pages. - $assignment = 0; + if ($menuId = (int) $app->getUserState('com_modules.add.module.menu_id')) + { + // If a Menu ID is selected via Frontend Placements then use that. + $assignment = 1; + $assigned[] = $menuId; + } + else{ + // If this is a new module, assign to all pages. + $assignment = 0; + } } elseif (empty($assigned)) { From c6a6248b2e6985d6fbd873f47c1881bb7beb1d25 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Wed, 9 Jun 2021 18:10:50 +0530 Subject: [PATCH 19/74] Removed redundant permission check --- layouts/chromes/outline.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 070a82af767..5c8265dd0c8 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -10,7 +10,6 @@ defined('_JEXEC') or die; use Joomla\CMS\Factory; -use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Text; $app = Factory::getApplication(); @@ -21,7 +20,7 @@ $module = $displayData['module']; // Place Modules Button -$showModuleButton = $app->input->getBool('pm') && ContentHelper::getActions('com_modules')->get('core.create'); +$showModuleButton = $app->input->getBool('pm'); // Redirect URL Menu ID Param for Placing Modules $menuId = $app->getMenu()->getActive(); From 42bf2b8e499e76124a40abebb88f6116a30ce552 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Wed, 9 Jun 2021 18:44:01 +0530 Subject: [PATCH 20/74] made place module layout flexible for backend edit position modal --- layouts/chromes/outline.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 5c8265dd0c8..f576ef7380e 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -22,8 +22,16 @@ // Place Modules Button $showModuleButton = $app->input->getBool('pm'); -// Redirect URL Menu ID Param for Placing Modules +// Attributes of Select Position Tag for Placing Modules $menuId = $app->getMenu()->getActive(); +$action = 'href="administrator/index.php?option=com_modules&task=module.selectPosition&position=' . $module->position . "&menu=" . $menuId->id . '"'; +$tag = "a"; + +if ($showModuleButton && $app->input->getBool('edit')) +{ + $tag = "button"; + $action = 'onclick="selectPosition(' . "'" . $module->position . "'" . ')"'; +} ?> From 626675cfa81a0600c2b611f06d444389dfbed015 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Wed, 9 Jun 2021 18:45:01 +0530 Subject: [PATCH 21/74] add comment --- layouts/chromes/outline.php | 1 + 1 file changed, 1 insertion(+) diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index f576ef7380e..098c68b0b53 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -27,6 +27,7 @@ $action = 'href="administrator/index.php?option=com_modules&task=module.selectPosition&position=' . $module->position . "&menu=" . $menuId->id . '"'; $tag = "a"; +// True for Backend Edit Module Position's Modal Iframe if ($showModuleButton && $app->input->getBool('edit')) { $tag = "button"; From 4c795454a745b664df2da0e1428928e59a1311de Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Wed, 9 Jun 2021 20:20:33 +0530 Subject: [PATCH 22/74] new js file for submitting the place module modal form --- build/media_source/layouts/js/chromes/outline.js | 0 layouts/chromes/outline.php | 1 + 2 files changed, 1 insertion(+) create mode 100644 build/media_source/layouts/js/chromes/outline.js diff --git a/build/media_source/layouts/js/chromes/outline.js b/build/media_source/layouts/js/chromes/outline.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index 098c68b0b53..d92c67376c3 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -16,6 +16,7 @@ $app->getDocument() ->getWebAssetManager() ->registerAndUseStyle('layouts.chromes.outline', 'layouts/chromes/outline.css'); + ->registerAndUseScript('layouts.chromes.outline', 'layouts/chromes/outline.js'); $module = $displayData['module']; From ff563d8cd25801c44561503b50dfb0c1bf549086 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Thu, 10 Jun 2021 14:10:48 +0530 Subject: [PATCH 23/74] remove extra semicolon --- layouts/chromes/outline.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/chromes/outline.php b/layouts/chromes/outline.php index d92c67376c3..0fe03bae352 100644 --- a/layouts/chromes/outline.php +++ b/layouts/chromes/outline.php @@ -15,7 +15,7 @@ $app = Factory::getApplication(); $app->getDocument() ->getWebAssetManager() - ->registerAndUseStyle('layouts.chromes.outline', 'layouts/chromes/outline.css'); + ->registerAndUseStyle('layouts.chromes.outline', 'layouts/chromes/outline.css') ->registerAndUseScript('layouts.chromes.outline', 'layouts/chromes/outline.js'); $module = $displayData['module']; From 11a1c71fd300c7c403064b278c5678a5eef47871 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Fri, 11 Jun 2021 00:45:18 +0530 Subject: [PATCH 24/74] Backend Preview Modal --- .../joomla/form/field/modulespositionedit.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php b/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php index 2af5c7d562a..4e84a99d9a1 100644 --- a/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php +++ b/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php @@ -12,6 +12,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +use Joomla\CMS\Uri\Uri; extract($displayData); @@ -85,4 +86,20 @@ ) ); ?> - + 'Select position from template', + 'url' => Uri::root() . '?pm=1&edit=1', + 'height' => '400px', + 'width' => 'auto', + 'bodyHeight' => 70, + 'modalWidth' => 95, + 'footer' => '', + ) + ); +?> +Select position from template From 3c9ef2a3965071ede13cba1b99a1458932530b0e Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Fri, 11 Jun 2021 12:58:07 +0530 Subject: [PATCH 25/74] Add language constant for select position --- .../layouts/joomla/form/field/modulespositionedit.php | 4 ++-- administrator/language/en-GB/com_modules.ini | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php b/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php index 4e84a99d9a1..4ae90505dea 100644 --- a/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php +++ b/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php @@ -91,7 +91,7 @@ 'bootstrap.renderModal', 'Modal_position', array( - 'title' => 'Select position from template', + 'title' => Text::_('COM_MODULES_MODULE_TEMPLATE_SELECT_POSITION'), 'url' => Uri::root() . '?pm=1&edit=1', 'height' => '400px', 'width' => 'auto', @@ -102,4 +102,4 @@ ) ); ?> -Select position from template + diff --git a/administrator/language/en-GB/com_modules.ini b/administrator/language/en-GB/com_modules.ini index 6f0cef77858..2dd707e1fe4 100644 --- a/administrator/language/en-GB/com_modules.ini +++ b/administrator/language/en-GB/com_modules.ini @@ -92,6 +92,7 @@ COM_MODULES_MODULE="Module" COM_MODULES_MODULE_ASSIGN="Module Assignment" COM_MODULES_MODULE_DESCRIPTION="Module Description" COM_MODULES_MODULE_TEMPLATE_POSITION="%1$s (%2$s)" +COM_MODULES_MODULE_TEMPLATE_SELECT_POSITION="Select Position from Template" COM_MODULES_MODULES="Modules" COM_MODULES_MODULES_FILTER_SEARCH_DESC="Search in module title and note. Prefix with ID: to search for a module ID." COM_MODULES_MODULES_FILTER_SEARCH_LABEL="Search Modules" From 8a4aa38b702104184cde9ce2bf3f0bf0e9bd3f56 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Fri, 11 Jun 2021 23:51:13 +0530 Subject: [PATCH 26/74] Rephrase template preview constant --- administrator/language/en-GB/com_modules.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/com_modules.ini b/administrator/language/en-GB/com_modules.ini index 2dd707e1fe4..350f4cf984c 100644 --- a/administrator/language/en-GB/com_modules.ini +++ b/administrator/language/en-GB/com_modules.ini @@ -92,7 +92,7 @@ COM_MODULES_MODULE="Module" COM_MODULES_MODULE_ASSIGN="Module Assignment" COM_MODULES_MODULE_DESCRIPTION="Module Description" COM_MODULES_MODULE_TEMPLATE_POSITION="%1$s (%2$s)" -COM_MODULES_MODULE_TEMPLATE_SELECT_POSITION="Select Position from Template" +COM_MODULES_MODULE_TEMPLATE_POSITIONS_PREVIEW="Preview Template Positions" COM_MODULES_MODULES="Modules" COM_MODULES_MODULES_FILTER_SEARCH_DESC="Search in module title and note. Prefix with ID: to search for a module ID." COM_MODULES_MODULES_FILTER_SEARCH_LABEL="Search Modules" From 34f7f56be18c6b5da31269d9a8dd573c42536041 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Fri, 11 Jun 2021 23:52:04 +0530 Subject: [PATCH 27/74] new tmpl for the modal --- .../joomla/form/field/modulespositionedit.php | 9 +++---- .../tmpl/module/preview_positions.php | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 administrator/components/com_modules/tmpl/module/preview_positions.php diff --git a/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php b/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php index 4ae90505dea..ad4a9ea219a 100644 --- a/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php +++ b/administrator/components/com_modules/layouts/joomla/form/field/modulespositionedit.php @@ -12,7 +12,6 @@ use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; -use Joomla\CMS\Uri\Uri; extract($displayData); @@ -91,10 +90,8 @@ 'bootstrap.renderModal', 'Modal_position', array( - 'title' => Text::_('COM_MODULES_MODULE_TEMPLATE_SELECT_POSITION'), - 'url' => Uri::root() . '?pm=1&edit=1', - 'height' => '400px', - 'width' => 'auto', + 'title' => Text::_('COM_MODULES_MODULE_TEMPLATE_POSITIONS_PREVIEW'), + 'url' => 'index.php?option=com_modules&view=module&layout=preview_positions&id=17&client_id=', 'bodyHeight' => 70, 'modalWidth' => 95, 'footer' => ' -
diff --git a/templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss b/templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss new file mode 100644 index 00000000000..7d4e55cca5e --- /dev/null +++ b/templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss @@ -0,0 +1,22 @@ +// Frontend Module Placement + +.btn.jmodadd { + width: 100%; + padding-top: $cassiopeia-grid-gutter*2; + padding-bottom: $cassiopeia-grid-gutter*2; + margin-top: $cassiopeia-grid-gutter; + margin-bottom: $cassiopeia-grid-gutter; + font-size: 1.1em; + font-weight: 500; + color: var(--cassiopeia-color-primary, $standard-color-primary); + background-color: rgba(255,255,255,.5); + border: 1px solid var(--cassiopeia-color-primary); + border-radius: .25rem; + + &:hover, + &:focus { + color: var(--white, $white); + background-color: var(--cassiopeia-color-hover); + border-color: var(--cassiopeia-color-hover); + } +} diff --git a/templates/cassiopeia/scss/template.scss b/templates/cassiopeia/scss/template.scss index 10b0fd079ad..9e2794293a5 100644 --- a/templates/cassiopeia/scss/template.scss +++ b/templates/cassiopeia/scss/template.scss @@ -19,6 +19,7 @@ @import "blocks/footer"; @import "blocks/form"; @import "blocks/frontend-edit"; +@import "blocks/frontend-mod-placement"; @import "blocks/header"; @import "blocks/icons"; @import "blocks/iframe"; From 7048e3db9f909f01132544a8335b2f91e8932d70 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Tue, 15 Jun 2021 16:43:55 +0530 Subject: [PATCH 48/74] remove margin top from Add Module btn --- templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss b/templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss index 7d4e55cca5e..64f992a44a2 100644 --- a/templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss +++ b/templates/cassiopeia/scss/blocks/_frontend-mod-placement.scss @@ -4,7 +4,6 @@ width: 100%; padding-top: $cassiopeia-grid-gutter*2; padding-bottom: $cassiopeia-grid-gutter*2; - margin-top: $cassiopeia-grid-gutter; margin-bottom: $cassiopeia-grid-gutter; font-size: 1.1em; font-weight: 500; From 08e764dfdc67d0bb243f7f9fb5dbf452ea81a50e Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Tue, 15 Jun 2021 16:51:54 +0530 Subject: [PATCH 49/74] Hide frontend editing icon from place module view --- libraries/src/Document/Renderer/Html/ModulesRenderer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/src/Document/Renderer/Html/ModulesRenderer.php b/libraries/src/Document/Renderer/Html/ModulesRenderer.php index 70629c347e1..90f277bc080 100644 --- a/libraries/src/Document/Renderer/Html/ModulesRenderer.php +++ b/libraries/src/Document/Renderer/Html/ModulesRenderer.php @@ -40,7 +40,7 @@ public function render($position, $params = array(), $content = null) $app = Factory::getApplication(); $user = Factory::getUser(); - $frontediting = ($app->isClient('site') && $app->get('frontediting', 1) && !$user->guest); + $frontediting = ($app->isClient('site') && $app->get('frontediting', 1) && !$user->guest && !$app->input->get('pm')); $menusEditing = ($app->get('frontediting', 1) == 2) && $user->authorise('core.edit', 'com_menus'); foreach (ModuleHelper::getModules($position) as $mod) From 3f22e74b968f49e1e1c27e6e0fedb0e9a0e61169 Mon Sep 17 00:00:00 2001 From: YatharthVyas Date: Thu, 17 Jun 2021 11:44:30 +0530 Subject: [PATCH 50/74] backend flow modal view set to select position --- .../tmpl/module/preview_positions.php | 2 +- .../layouts/js/chromes/outline.es6.js | 35 +++++++++++++++++++ .../layouts/js/chromes/outline.js | 0 layouts/chromes/outline.php | 4 +-- templates/cassiopeia/index.php | 2 +- 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 build/media_source/layouts/js/chromes/outline.es6.js delete mode 100644 build/media_source/layouts/js/chromes/outline.js diff --git a/administrator/components/com_modules/tmpl/module/preview_positions.php b/administrator/components/com_modules/tmpl/module/preview_positions.php index e900fc4f907..42e92c48625 100644 --- a/administrator/components/com_modules/tmpl/module/preview_positions.php +++ b/administrator/components/com_modules/tmpl/module/preview_positions.php @@ -33,7 +33,7 @@ ?>