Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1] A new Icon for com_tags to the quickicon module #32223

Merged
merged 2 commits into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\AdminController;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Router\Route;

/**
Expand Down Expand Up @@ -69,4 +70,28 @@ public function rebuild()
return false;
}
}

/**
* Method to get the number of published tags for quickicons
*
* @return string The JSON-encoded amount of published articles
*
* @since __DEPLOY_VERSION__
*/
public function getQuickiconContent()
{
$model = $this->getModel('tags');

$model->setState('filter.published', 1);

$amount = (int) $model->getTotal();

$result = [];

$result['amount'] = $amount;
$result['sronly'] = Text::plural('COM_TAGS_N_QUICKICON_SRONLY', $amount);
$result['name'] = Text::plural('COM_TAGS_N_QUICKICON', $amount);

echo new JsonResponse($result);
}
}
6 changes: 6 additions & 0 deletions administrator/language/en-GB/com_tags.ini
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ COM_TAGS_N_ITEMS_TRASHED="%d tags trashed."
COM_TAGS_N_ITEMS_TRASHED_1="Tag trashed."
COM_TAGS_N_ITEMS_UNPUBLISHED="%d tags unpublished."
COM_TAGS_N_ITEMS_UNPUBLISHED_1="Tag unpublished."
COM_TAGS_N_QUICKICON="Tags"
COM_TAGS_N_QUICKICON_0="Tags"
COM_TAGS_N_QUICKICON_1="Tag"
COM_TAGS_N_QUICKICON_SRONLY="Tags: %s tags are published."
COM_TAGS_N_QUICKICON_SRONLY_0="Tags: No tag is published."
COM_TAGS_N_QUICKICON_SRONLY_1="Tags: One tag is published."
COM_TAGS_NONE="None"
COM_TAGS_NUMBER_TAG_ITEMS_LABEL="Show Number of Items"
COM_TAGS_OPTIONS="Tag Options"
Expand Down
3 changes: 3 additions & 0 deletions administrator/language/en-GB/mod_quickicon.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ MOD_QUICKICON_SHOW_MODULES_LABEL="Modules Icon"
MOD_QUICKICON_SHOW_OVERRIDEUPDATE_LABEL="Override Update Check"
MOD_QUICKICON_SHOW_PLUGINS_LABEL="Plugins Icon"
MOD_QUICKICON_SHOW_PRIVACYREQUEST_LABEL="Privacy Requests"
MOD_QUICKICON_SHOW_TAGS_LABEL="Tags Icon"
MOD_QUICKICON_SHOW_TEMPLATE_CODE_LABEL="Template Code Icon"
MOD_QUICKICON_SHOW_TEMPLATE_STYLES_LABEL="Template Styles Icon"
MOD_QUICKICON_SHOW_USERS_LABEL="User Icon"
MOD_QUICKICON_SITE="Icons Site"
MOD_QUICKICON_STRUCTURE="Structure"
MOD_QUICKICON_SYSTEM="Icons System"
MOD_QUICKICON_TAGS_MANAGER="Tags"
MOD_QUICKICON_TAGS_MANAGER_ADD="Add Tag"
MOD_QUICKICON_TEMPLATE_CODE="Template Code"
MOD_QUICKICON_TEMPLATE_STYLES="Template Styles"
MOD_QUICKICON_TYPE="Icon Type"
Expand Down
13 changes: 13 additions & 0 deletions administrator/modules/mod_quickicon/mod_quickicon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@
<option value="1">JSHOW</option>
<option value="2">MOD_QUICKICON_WITH_COUNT</option>
</field>

<field
name="show_tags"
type="list"
label="MOD_QUICKICON_SHOW_TAGS_LABEL"
default="0"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
<option value="2">MOD_QUICKICON_WITH_COUNT</option>
</field>

<field
name="show_modules"
type="list"
Expand Down
19 changes: 19 additions & 0 deletions administrator/modules/mod_quickicon/src/Helper/QuickIconHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,25 @@ public static function &getButtons(Registry $params, CMSApplication $application
self::$buttons[$key][] = $tmp;
}

if ($params->get('show_tags'))
{
$tmp = [
'image' => 'icon-tag',
'link' => Route::_('index.php?option=com_tags&view=tags'),
'linkadd' => Route::_('index.php?option=com_tags&task=tag.edit'),
'name' => 'MOD_QUICKICON_TAGS_MANAGER',
'access' => array('core.manage', 'com_tags', 'core.create', 'com_tags'),
'group' => 'MOD_QUICKICON_SITE',
];

if ($params->get('show_tags') == 2)
{
$tmp['ajaxurl'] = 'index.php?option=com_tags&amp;task=tags.getQuickiconContent&amp;format=json';
}

self::$buttons[$key][] = $tmp;
}

if ($params->get('show_categories'))
{
$tmp = [
Expand Down