From fe882f6fee1cb9f6bb729e556a7127698668df84 Mon Sep 17 00:00:00 2001 From: Thomas Hunziker Date: Thu, 23 Sep 2021 19:49:50 +0200 Subject: [PATCH] [4.0] Remove JHELP_ strings for com_categories (#35534) --- .../components/com_banners/forms/category.xml | 5 ++ .../src/View/Categories/HtmlView.php | 51 +++++++++++++++---- .../src/View/Category/HtmlView.php | 39 ++++++++------ .../components/com_contact/forms/category.xml | 5 ++ .../components/com_content/forms/category.xml | 2 + .../com_newsfeeds/forms/category.xml | 5 ++ .../components/com_users/forms/category.xml | 5 ++ administrator/language/en-GB/joomla.ini | 15 ------ api/language/en-GB/joomla.ini | 15 ------ 9 files changed, 86 insertions(+), 56 deletions(-) create mode 100644 administrator/components/com_banners/forms/category.xml create mode 100644 administrator/components/com_contact/forms/category.xml create mode 100644 administrator/components/com_newsfeeds/forms/category.xml create mode 100644 administrator/components/com_users/forms/category.xml diff --git a/administrator/components/com_banners/forms/category.xml b/administrator/components/com_banners/forms/category.xml new file mode 100644 index 0000000000000..7b3e2282f42e5 --- /dev/null +++ b/administrator/components/com_banners/forms/category.xml @@ -0,0 +1,5 @@ + +
+ + + diff --git a/administrator/components/com_categories/src/View/Categories/HtmlView.php b/administrator/components/com_categories/src/View/Categories/HtmlView.php index 695d1a24534ef..6b322b3c97bc5 100644 --- a/administrator/components/com_categories/src/View/Categories/HtmlView.php +++ b/administrator/components/com_categories/src/View/Categories/HtmlView.php @@ -13,6 +13,7 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; +use Joomla\CMS\Filesystem\Path; use Joomla\CMS\Helper\ContentHelper; use Joomla\CMS\Language\Multilanguage; use Joomla\CMS\Language\Text; @@ -149,6 +150,7 @@ public function display($tpl = null) * * @return void * + * @throws \Exception * @since 1.6 */ protected function addToolbar() @@ -273,27 +275,54 @@ protected function addToolbar() $toolbar->preferences($component); } - // Compute the ref_key if it does exist in the component - if (!$lang->hasKey($ref_key = strtoupper($component . ($section ? "_$section" : '')) . '_CATEGORIES_HELP_KEY')) + // Get the component form if it exists for the help key/url + $name = 'category' . ($section ? ('.' . $section) : ''); + + // Looking first in the component forms folder + $path = Path::clean(JPATH_ADMINISTRATOR . "/components/$component/forms/$name.xml"); + + // Looking in the component models/forms folder (J! 3) + if (!file_exists($path)) + { + $path = Path::clean(JPATH_ADMINISTRATOR . "/components/$component/models/forms/$name.xml"); + } + + // Look first in form for help key and url + if (file_exists($path)) + { + if (!$xml = simplexml_load_file($path)) + { + throw new \Exception(Text::_('JERROR_LOADFILE_FAILED')); + } + + $ref_key = (string) $xml->listhelp['key']; + $url = (string) $xml->listhelp['url']; + } + + if (!$ref_key) { - $ref_key = 'JHELP_COMPONENTS_' . strtoupper(substr($component, 4) . ($section ? "_$section" : '')) . '_CATEGORIES'; + // Compute the ref_key if it does exist in the component + if (!$lang->hasKey($ref_key = strtoupper($component . ($section ? "_$section" : '')) . '_CATEGORIES_HELP_KEY')) + { + $ref_key = 'JHELP_COMPONENTS_' . strtoupper(substr($component, 4) . ($section ? "_$section" : '')) . '_CATEGORIES'; + } } /* * Get help for the categories view for the component by + * -remotely searching in a URL defined in the category form * -remotely searching in a language defined dedicated URL: *component*_HELP_URL * -locally searching in a component help file if helpURL param exists in the component and is set to '' * -remotely searching in a component URL if helpURL param exists in the component and is NOT set to '' */ - if ($lang->hasKey($lang_help_url = strtoupper($component) . '_HELP_URL')) + if (!$url) { - $debug = $lang->setDebug(false); - $url = Text::_($lang_help_url); - $lang->setDebug($debug); - } - else - { - $url = null; + if ($lang->hasKey($lang_help_url = strtoupper($component) . '_HELP_URL')) + { + $debug = $lang->setDebug(false); + $url = Text::_($lang_help_url); + $lang->setDebug($debug); + } } $toolbar->help($ref_key, ComponentHelper::getParams($component)->exists('helpURL'), $url); diff --git a/administrator/components/com_categories/src/View/Category/HtmlView.php b/administrator/components/com_categories/src/View/Category/HtmlView.php index 0446bdfc7c57f..ba2a0b188c285 100644 --- a/administrator/components/com_categories/src/View/Category/HtmlView.php +++ b/administrator/components/com_categories/src/View/Category/HtmlView.php @@ -258,32 +258,41 @@ protected function addToolbar() ToolbarHelper::divider(); - // Compute the ref_key - $ref_key = strtoupper($component . ($section ? "_$section" : '')) . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_HELP_KEY'; + // Look first in form for help key + $ref_key = (string) $this->form->getXml()->help['key']; - // Check if the computed ref_key does exist in the component - if (!$lang->hasKey($ref_key)) + // Try with a language string + if (!$ref_key) { - $ref_key = 'JHELP_COMPONENTS_' - . strtoupper(substr($component, 4) . ($section ? "_$section" : '')) - . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT'); + // Compute the ref_key + $ref_key = strtoupper($component . ($section ? "_$section" : '')) . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT') . '_HELP_KEY'; + + // Check if the computed ref_key does exist in the component + if (!$lang->hasKey($ref_key)) + { + $ref_key = 'JHELP_COMPONENTS_' + . strtoupper(substr($component, 4) . ($section ? "_$section" : '')) + . '_CATEGORY_' . ($isNew ? 'ADD' : 'EDIT'); + } } /* * Get help for the category/section view for the component by + * -remotely searching in a URL defined in the category form * -remotely searching in a language defined dedicated URL: *component*_HELP_URL * -locally searching in a component help file if helpURL param exists in the component and is set to '' * -remotely searching in a component URL if helpURL param exists in the component and is NOT set to '' */ - if ($lang->hasKey($lang_help_url = strtoupper($component) . '_HELP_URL')) - { - $debug = $lang->setDebug(false); - $url = Text::_($lang_help_url); - $lang->setDebug($debug); - } - else + $url = (string) $this->form->getXml()->help['url']; + + if (!$url) { - $url = null; + if ($lang->hasKey($lang_help_url = strtoupper($component) . '_HELP_URL')) + { + $debug = $lang->setDebug(false); + $url = Text::_($lang_help_url); + $lang->setDebug($debug); + } } ToolbarHelper::help($ref_key, $componentParams->exists('helpURL'), $url, $component); diff --git a/administrator/components/com_contact/forms/category.xml b/administrator/components/com_contact/forms/category.xml new file mode 100644 index 0000000000000..8e1fdedc1c90e --- /dev/null +++ b/administrator/components/com_contact/forms/category.xml @@ -0,0 +1,5 @@ + +
+ + + diff --git a/administrator/components/com_content/forms/category.xml b/administrator/components/com_content/forms/category.xml index 7fb3cbd4790e4..c2cceda1dfb3c 100644 --- a/administrator/components/com_content/forms/category.xml +++ b/administrator/components/com_content/forms/category.xml @@ -1,5 +1,7 @@
+ +
+ + + + diff --git a/administrator/components/com_users/forms/category.xml b/administrator/components/com_users/forms/category.xml new file mode 100644 index 0000000000000..044744f627062 --- /dev/null +++ b/administrator/components/com_users/forms/category.xml @@ -0,0 +1,5 @@ + +
+ + + diff --git a/administrator/language/en-GB/joomla.ini b/administrator/language/en-GB/joomla.ini index 7a4cd09240166..6eb2582f4042a 100644 --- a/administrator/language/en-GB/joomla.ini +++ b/administrator/language/en-GB/joomla.ini @@ -712,20 +712,11 @@ JHELP_COMPONENTS_ASSOCIATIONS="Multilingual_Associations" JHELP_COMPONENTS_ASSOCIATIONS_EDIT="Multilingual_Associations:_Edit" JHELP_COMPONENTS_BANNERS_BANNERS="Banners" JHELP_COMPONENTS_BANNERS_BANNERS_EDIT="Banners:_Edit" -JHELP_COMPONENTS_BANNERS_CATEGORIES="Banners:_Categories" -JHELP_COMPONENTS_BANNERS_CATEGORY_ADD="Banners:_New_or_Edit_Category" -JHELP_COMPONENTS_BANNERS_CATEGORY_EDIT="Banners:_New_or_Edit_Category" JHELP_COMPONENTS_BANNERS_CLIENTS="Banners:_Clients" JHELP_COMPONENTS_BANNERS_CLIENTS_EDIT="Banners:_New_or_Edit_Client" JHELP_COMPONENTS_BANNERS_TRACKS="Banners:_Tracks" -JHELP_COMPONENTS_CONTACT_CATEGORIES="Contacts:_Categories" -JHELP_COMPONENTS_CONTACT_CATEGORY_ADD="Contacts:_New_or_Edit_Category" -JHELP_COMPONENTS_CONTACT_CATEGORY_EDIT="Contacts:_New_or_Edit_Category" JHELP_COMPONENTS_CONTACTS_CONTACTS="Contacts" JHELP_COMPONENTS_CONTACTS_CONTACTS_EDIT="Contacts:_New_or_Edit" -JHELP_COMPONENTS_CONTENT_CATEGORIES="Articles:_Categories" -JHELP_COMPONENTS_CONTENT_CATEGORY_ADD="Articles:_New_or_Edit_Category" -JHELP_COMPONENTS_CONTENT_CATEGORY_EDIT="Articles:_New_or_Edit_Category" JHELP_COMPONENTS_FIELDS_FIELD_GROUPS="Component:_Field_Groups" JHELP_COMPONENTS_FIELDS_FIELD_GROUPS_EDIT="Component:_New_or_Edit_Field_Group" JHELP_COMPONENTS_FIELDS_FIELDS="Component:_Fields" @@ -742,9 +733,6 @@ JHELP_COMPONENTS_MAILS_TEMPLATE_EDIT="Mail_Template:_Edit" JHELP_COMPONENTS_MESSAGING_INBOX="Private_Messages" JHELP_COMPONENTS_MESSAGING_READ="Private_Messages:_Read" JHELP_COMPONENTS_MESSAGING_WRITE="Private_Messages:_Write" -JHELP_COMPONENTS_NEWSFEEDS_CATEGORIES="News_Feeds:_Categories" -JHELP_COMPONENTS_NEWSFEEDS_CATEGORY_ADD="News_Feeds:_New_or_Edit_Category" -JHELP_COMPONENTS_NEWSFEEDS_CATEGORY_EDIT="News_Feeds:_New_or_Edit_Category" JHELP_COMPONENTS_NEWSFEEDS_FEEDS="News_Feeds" JHELP_COMPONENTS_NEWSFEEDS_FEEDS_EDIT="News_Feeds:_New_or_Edit" JHELP_COMPONENTS_POST_INSTALLATION_MESSAGES="Post-installation_Messages_for_Joomla_CMS" @@ -758,9 +746,6 @@ JHELP_COMPONENTS_REDIRECT_MANAGER="Redirects:_Links" JHELP_COMPONENTS_REDIRECT_MANAGER_EDIT="Redirects:_New_or_Edit" JHELP_COMPONENTS_TAGS_MANAGER="Tags" JHELP_COMPONENTS_TAGS_MANAGER_EDIT="Tags:_New_or_Edit" -JHELP_COMPONENTS_USERS_CATEGORIES="User_Notes:_Categories" -JHELP_COMPONENTS_USERS_CATEGORY_ADD="User_Notes:_New_or_Edit_Category" -JHELP_COMPONENTS_USERS_CATEGORY_EDIT="User_Notes:_New_or_Edit_Category" JHELP_COMPONENTS_WORKFLOW_STAGES_LIST="Stages_List:_Basic_Workflow" JHELP_COMPONENTS_WORKFLOW_TRANSITIONS_LIST="Transitions_List:_Basic_Workflow" JHELP_COMPONENTS_WORKFLOW_WORKFLOWS_LIST="Workflows_List" diff --git a/api/language/en-GB/joomla.ini b/api/language/en-GB/joomla.ini index b7beb430406a3..f787cfd847a6e 100644 --- a/api/language/en-GB/joomla.ini +++ b/api/language/en-GB/joomla.ini @@ -708,20 +708,11 @@ JHELP_COMPONENTS_ASSOCIATIONS="Multilingual_Associations" JHELP_COMPONENTS_ASSOCIATIONS_EDIT="Multilingual_Associations:_Edit" JHELP_COMPONENTS_BANNERS_BANNERS="Banners" JHELP_COMPONENTS_BANNERS_BANNERS_EDIT="Banners:_Edit" -JHELP_COMPONENTS_BANNERS_CATEGORIES="Banners:_Categories" -JHELP_COMPONENTS_BANNERS_CATEGORY_ADD="Banners:_New_or_Edit_Category" -JHELP_COMPONENTS_BANNERS_CATEGORY_EDIT="Banners:_New_or_Edit_Category" JHELP_COMPONENTS_BANNERS_CLIENTS="Banners:_Clients" JHELP_COMPONENTS_BANNERS_CLIENTS_EDIT="Banners:_New_or_Edit_Client" JHELP_COMPONENTS_BANNERS_TRACKS="Banners:_Tracks" -JHELP_COMPONENTS_CONTACT_CATEGORIES="Contacts:_Categories" -JHELP_COMPONENTS_CONTACT_CATEGORY_ADD="Contacts:_New_or_Edit_Category" -JHELP_COMPONENTS_CONTACT_CATEGORY_EDIT="Contacts:_New_or_Edit_Category" JHELP_COMPONENTS_CONTACTS_CONTACTS="Contacts" JHELP_COMPONENTS_CONTACTS_CONTACTS_EDIT="Contacts:_New_or_Edit" -JHELP_COMPONENTS_CONTENT_CATEGORIES="Articles:_Categories" -JHELP_COMPONENTS_CONTENT_CATEGORY_ADD="Articles:_New_or_Edit_Category" -JHELP_COMPONENTS_CONTENT_CATEGORY_EDIT="Articles:_New_or_Edit_Category" JHELP_COMPONENTS_FIELDS_FIELD_GROUPS="Component:_Field_Groups" JHELP_COMPONENTS_FIELDS_FIELD_GROUPS_EDIT="Component:_New_or_Edit_Field_Group" JHELP_COMPONENTS_FIELDS_FIELDS="Component:_Fields" @@ -738,9 +729,6 @@ JHELP_COMPONENTS_MAILS_TEMPLATE_EDIT="Mail_Template:_Edit" JHELP_COMPONENTS_MESSAGING_INBOX="Private_Messages" JHELP_COMPONENTS_MESSAGING_READ="Private_Messages:_Read" JHELP_COMPONENTS_MESSAGING_WRITE="Private_Messages:_Write" -JHELP_COMPONENTS_NEWSFEEDS_CATEGORIES="News_Feeds:_Categories" -JHELP_COMPONENTS_NEWSFEEDS_CATEGORY_ADD="News_Feeds:_New_or_Edit_Category" -JHELP_COMPONENTS_NEWSFEEDS_CATEGORY_EDIT="News_Feeds:_New_or_Edit_Category" JHELP_COMPONENTS_NEWSFEEDS_FEEDS="News_Feeds" JHELP_COMPONENTS_NEWSFEEDS_FEEDS_EDIT="News_Feeds:_New_or_Edit" JHELP_COMPONENTS_POST_INSTALLATION_MESSAGES="Post-installation_Messages_for_Joomla_CMS" @@ -754,9 +742,6 @@ JHELP_COMPONENTS_REDIRECT_MANAGER="Redirects:_Links" JHELP_COMPONENTS_REDIRECT_MANAGER_EDIT="Redirects:_New_or_Edit" JHELP_COMPONENTS_TAGS_MANAGER="Tags" JHELP_COMPONENTS_TAGS_MANAGER_EDIT="Tags:_New_or_Edit" -JHELP_COMPONENTS_USERS_CATEGORIES="User_Notes:_Categories" -JHELP_COMPONENTS_USERS_CATEGORY_ADD="User_Notes:_New_or_Edit_Category" -JHELP_COMPONENTS_USERS_CATEGORY_EDIT="User_Notes:_New_or_Edit_Category" JHELP_COMPONENTS_WORKFLOW_STAGES_LIST="Stages_List:_Basic_Workflow" JHELP_COMPONENTS_WORKFLOW_TRANSITIONS_LIST="Transitions_List:_Basic_Workflow" JHELP_COMPONENTS_WORKFLOW_WORKFLOWS_LIST="Workflows_List"