Skip to content

Commit

Permalink
[4.0] Remove JHELP_ strings for com_categories (joomla#35534)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bakual authored and brianteeman committed Oct 3, 2021
1 parent 52534c8 commit 7550cbe
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 56 deletions.
5 changes: 5 additions & 0 deletions administrator/components/com_banners/forms/category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<help key="Banners:_New_or_Edit_Category" />
<listhelp key="Banners:_Categories" />
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,6 +150,7 @@ public function display($tpl = null)
*
* @return void
*
* @throws \Exception
* @since 1.6
*/
protected function addToolbar()
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions administrator/components/com_contact/forms/category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<help key="Contacts:_New_or_Edit_Category" />
<listhelp key="Contacts:_Categories" />
</form>
2 changes: 2 additions & 0 deletions administrator/components/com_content/forms/category.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<help key="Articles:_New_or_Edit_Category" />
<listhelp key="Articles:_Categories" />
<fields name="params" addfieldprefix="Joomla\Component\Content\Administrator\Field">
<fieldset name="workflow" label="COM_CONTENT_WORKFLOW">
<field
Expand Down
5 changes: 5 additions & 0 deletions administrator/components/com_newsfeeds/forms/category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<help key="News_Feeds:_New_or_Edit_Category" />
<listhelp key="News_Feeds:_Categories" />
</form>
5 changes: 5 additions & 0 deletions administrator/components/com_users/forms/category.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<help key="User_Notes:_New_or_Edit_Category" />
<listhelp key="User_Notes:_Categories" />
</form>
15 changes: 0 additions & 15 deletions administrator/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
15 changes: 0 additions & 15 deletions api/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 7550cbe

Please sign in to comment.