Skip to content

Commit

Permalink
Merge pull request #6 from lavipr/toggle-logo
Browse files Browse the repository at this point in the history
fix loading of custom logos
  • Loading branch information
fancyFranci committed Feb 20, 2019
2 parents c286997 + 473c546 commit d75a077
Show file tree
Hide file tree
Showing 12 changed files with 364 additions and 60 deletions.
10 changes: 6 additions & 4 deletions administrator/language/en-GB/en-GB.mod_quickicon.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@
; Note : All ini files need to be saved as UTF-8

MOD_QUICKICON="Quick Icons"
MOD_QUICKICON_ADD_NEW_ARTICLE="New Article"
MOD_QUICKICON_ADD_NEW="Add New"
MOD_QUICKICON_ARTICLE_MANAGER="Articles"
MOD_QUICKICON_CATEGORY_MANAGER="Categories"
MOD_QUICKICON_CATEGORY_MANAGER="Article Categories"
MOD_QUICKICON_CHECKINS="Global Checkin"
MOD_QUICKICON_CONFIGURATION="Configuration"
MOD_QUICKICON_CONTENT="Content"
MOD_QUICKICON_EXTENSIONS="Extensions"
MOD_QUICKICON_EXTENSION_MANAGER="Extension Manager"
MOD_QUICKICON_GLOBAL_CONFIGURATION="Global"
MOD_QUICKICON_GLOBAL_CONFIGURATION="Global<br>Configuration"
MOD_QUICKICON_GROUP_DESC="The group of this module (this value is compared with the group value used in <strong>Quick Icons</strong> plugins to inject icons). The 'mod_quickicon' group always displays the Joomla! core icons."
MOD_QUICKICON_GROUP_LABEL="Group"
MOD_QUICKICON_INSTALL_EXTENSIONS="Install Extensions"
MOD_QUICKICON_LANGUAGE_MANAGER="Languages"
MOD_QUICKICON_MAINTENANCE="Maintenance"
MOD_QUICKICON_MEDIA_MANAGER="Media"
MOD_QUICKICON_MENU_MANAGER="Menu(s)"
MOD_QUICKICON_MENUITEMS_MANAGER="MenuItems"
MOD_QUICKICON_MODULE_MANAGER="Modules"
MOD_QUICKICON_NAV_LABEL="Quick Links"
MOD_QUICKICON_STRUCTURE="Structure"
MOD_QUICKICON_TEMPLATE_MANAGER="Templates"
MOD_QUICKICON_THSD="Thsd."
MOD_QUICKICON_USER_MANAGER="Users"
MOD_QUICKICON_USERS="Users"
MOD_QUICKICON_XML_DESCRIPTION="This module shows Quick Icons that are visible on the Control Panel (administrator area home page)."
7 changes: 2 additions & 5 deletions administrator/modules/mod_quickicon/Dispatcher/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@
class Dispatcher extends AbstractModuleDispatcher
{
/**
* Returns the layout data. This function can be overridden by subclasses to add more
* attributes for the layout.
* Returns the layout data.
*
* If false is returned, then it means that the dispatch process should be aborted.
*
* @return array|false
* @return array
*
* @since 4.0.0
*/
Expand Down
223 changes: 205 additions & 18 deletions administrator/modules/mod_quickicon/Helper/QuickIconHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@

defined('_JEXEC') or die;

use Joomla\CMS\Access\Access;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Categories\Administrator\Model\CategoriesModel;
use Joomla\Component\Checkin\Administrator\Model\CheckinModel;
use Joomla\Component\Content\Administrator\Model\ArticlesModel;
use Joomla\Component\Content\Administrator\Model\ModulesModel;
use Joomla\Component\Installer\Administrator\Model\ManageModel;
use Joomla\Component\Menus\Administrator\Model\ItemsModel;
use Joomla\Module\Quickicon\Administrator\Event\QuickIconsEvent;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;

/**
* Helper for mod_quickicon
Expand All @@ -33,7 +42,7 @@ abstract class QuickIconHelper
* @since 1.6
*/
protected static $buttons = array();

/**
* Helper method to return button list.
*
Expand All @@ -55,7 +64,7 @@ public static function &getButtons(Registry $params, CMSApplication $application
}

$key = (string) $params;

if (!isset(self::$buttons[$key]))
{
$context = $params->get('context', 'mod_quickicon');
Expand All @@ -64,35 +73,60 @@ public static function &getButtons(Registry $params, CMSApplication $application
{
// Load mod_quickicon language file in case this method is called before rendering the module
$application->getLanguage()->load('mod_quickicon');

self::$buttons[$key] = array(
array(
'link' => Route::_('index.php?option=com_config'),
'image' => 'fa fa-cog',
'text' => Text::_('MOD_QUICKICON_GLOBAL_CONFIGURATION'),
'access' => array('core.manage', 'com_config', 'core.admin', 'com_config'),
'group' => 'MOD_QUICKICON_CONFIGURATION',
),
array(
'amount' => self::countUsers(),
'link' => Route::_('index.php?option=com_users&task=user.add'),
'name' => Text::_('MOD_QUICKICON_USER_MANAGER'),
'text' => Text::_('MOD_QUICKICON_ADD_NEW'),
'access' => array('core.manage', 'com_categories', 'core.create', 'com_categories'),
'group' => 'MOD_QUICKICON_USERS',
),
array(
'amount' => self::countMenuItems(),
'link' => Route::_('index.php?option=com_menus&task=item.add'),
'name' => Text::_('MOD_QUICKICON_MENUITEMS_MANAGER'),
'text' => Text::_('MOD_QUICKICON_ADD_NEW'),
'access' => array('core.manage', 'com_menus', 'core.create', 'com_menus'),
'group' => 'MOD_QUICKICON_STRUCTURE',
),
array(
'amount' => self::countArticles(),
'link' => Route::_('index.php?option=com_content&task=article.add'),
'image' => 'fa fa-pencil-square',
'text' => Text::_('MOD_QUICKICON_ADD_NEW_ARTICLE'),
'name' => Text::_('MOD_QUICKICON_ARTICLE_MANAGER'),
'text' => Text::_('MOD_QUICKICON_ADD_NEW'),
'access' => array('core.manage', 'com_content', 'core.create', 'com_content'),
'group' => 'MOD_QUICKICON_CONTENT',
),
array(
'link' => Route::_('index.php?option=com_media'),
'image' => 'fa fa-image',
'text' => Text::_('MOD_QUICKICON_MEDIA_MANAGER'),
'access' => array('core.manage', 'com_media'),
'amount' => self::countArticleCategories(),
'link' => Route::_('index.php?option=com_categories&task=category.add'),
'name' => Text::_('MOD_QUICKICON_CATEGORY_MANAGER'),
'text' => Text::_('MOD_QUICKICON_ADD_NEW'),
'access' => array('core.manage', 'com_categories', 'core.create', 'com_categories'),
'group' => 'MOD_QUICKICON_CONTENT',
),
array(
'link' => Route::_('index.php?option=com_config'),
'image' => 'fa fa-cog',
'text' => Text::_('MOD_QUICKICON_GLOBAL_CONFIGURATION'),
'access' => array('core.manage', 'com_config', 'core.admin', 'com_config'),
'group' => 'MOD_QUICKICON_CONFIGURATION',
),
array(
'amount' => self::countModules(),
'link' => Route::_('index.php?option=com_modules'),
'image' => 'fa fa-cubes',
'text' => Text::_('MOD_QUICKICON_MODULE_MANAGER'),
'access' => array('core.manage', 'com_modules'),
'group' => 'MOD_QUICKICON_STRUCTURE'
),
array(
'amount' => self::countCheckin(),
'link' => Route::_('index.php?option=com_checkin'),
'text' => Text::_('MOD_QUICKICON_CHECKINS'),
'access' => array('core.manage', 'com_checkin'),
'group' => 'MOD_QUICKICON_CONTENT'
)
);
}
Expand All @@ -114,8 +148,10 @@ public static function &getButtons(Registry $params, CMSApplication $application
foreach ($response as $icon)
{
$default = array(
'amount' => null,
'link' => null,
'image' => 'fa fa-cog',
'name' => null,
'image' => null,
'text' => null,
'access' => true,
'group' => 'MOD_QUICKICON_EXTENSIONS',
Expand All @@ -132,4 +168,155 @@ public static function &getButtons(Registry $params, CMSApplication $application

return self::$buttons[$key];
}

/**
* Method to get the number of published modules in frontend.
*
* @return integer The amount of published modules in frontend
*
* @since 4.0
*/
private function countModules()
{
$app = Factory::getApplication();

// Get an instance of the generic articles model (administrator)
$model = $app->bootComponent('com_modules')->getMVCFactory()
->createModel('Modules', 'Administrator', ['ignore_request' => true]);

// $model->setState('list.select', 'COUNT(a.id) as amount'); doesn't work
$model->setState('list.select', '*');

// Set the Start and Limit to 'all'
$model->setState('list.start', 0);
$model->setState('list.limit', 0);
$model->setState('filter.published', 1);
$model->setState('filter.client_id', 0);

return count($model->getItems());
}
/**
* Method to get the number of published articles.
*
* @return integer The amount of published articles
*
* @since 4.0
*/
private function countArticles()
{
$app = Factory::getApplication();

// Get an instance of the generic articles model (administrator)
$model = $app->bootComponent('com_content')->getMVCFactory()
->createModel('Articles', 'Administrator', ['ignore_request' => true]);

// Count IDs
$model->setState('list.select', 'COUNT(a.id) as amount');

// Set the Start and Limit to 'all'
$model->setState('list.start', 0);
$model->setState('list.limit', 0);
$model->setState('filter.published', 1);

$result = $model->getItems();

return reset($result)->amount;
}

/**
* Method to get the number of published menu tems.
*
* @return integer The amount of active menu Items
*
* @since 4.0
*/
private function countMenuItems()
{
$app = Factory::getApplication();

// Get an instance of the generic articles model (administrator)
$model = $app->bootComponent('com_menus')->getMVCFactory()->createModel('Items', 'Administrator', ['ignore_request' => true]);

// Count IDs
$model->setState('list.select', 'COUNT(a.id) as amount');

// Set the Start and Limit to 'all'
$model->setState('list.start', 0);
$model->setState('list.limit', 0);
$model->setState('filter.published', 1);
$model->setState('filter.client_id', 0);

$result = $model->getItems();

return reset($result)->amount;
}

/**
* Method to get the number of extensions
*
* @return integer The amount of active extensions
*
* @since 4.0
*/
private function countUsers()
{
$app = Factory::getApplication();

// Get an instance of the generic articles model (administrator)
$model = $app->bootComponent('com_users')->getMVCFactory()->createModel('Users', 'Administrator', ['ignore_request' => true]);

// Count IDs
$model->setState('list.select', '*');

// Set the Start and Limit to 'all'
$model->setState('list.start', 0);
$model->setState('list.limit', 0);
$model->setState('filter.state', 0);

return count($model->getItems());
}


/**
* Method to get the number of content categories
*
* @return integer The amount of active menu Items
*
* @since 4.0
*/
private function countArticleCategories()
{
$app = Factory::getApplication();

// Get an instance of the generic articles model (administrator)
$model = $app->bootComponent('com_categories')->getMVCFactory()->createModel('Categories', 'Administrator', ['ignore_request' => true]);

// Count IDs
$model->setState('list.select', 'COUNT(a.id) as amount');

// Set the Start and Limit to 'all'
$model->setState('list.start', 0);
$model->setState('list.limit', 0);
$model->setState('filter.published', 1);

$result = $model->getItems();

return count($result);
}

/**
* Method to get checkin
*
* @return integer The amount of checkins
*
* @since 4.0
*/
private function countCheckin()
{
$app = Factory::getApplication();

$model = $app->bootComponent('com_checkin')->getMVCFactory()->createModel('Checkin', 'Administrator', ['ignore_request' => true]);

return $model->getTotal();
}
}
2 changes: 1 addition & 1 deletion administrator/modules/mod_quickicon/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
?>
<?php if (!empty($html)) : ?>
<nav class="quick-icons" aria-label="<?php echo Text::_('MOD_QUICKICON_NAV_LABEL'); ?>">
<ul>
<ul class="nav d-flex flex-wrap">
<?php echo $html; ?>
</ul>
</nav>
Expand Down
9 changes: 7 additions & 2 deletions administrator/templates/atum/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@
$joomlaLogo = $this->baseurl . '/templates/' . $this->template . '/images/logo.svg';

// Template params
$siteLogo = $this->params->get('siteLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-joomla-blue.svg');
$smallLogo = $this->params->get('smallLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-blue.svg');
$siteLogo = $this->params->get('siteLogo')
? JUri::root() . $this->params->get('siteLogo')
: $this->params->get('siteLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-joomla-blue.svg');
$smallLogo = $this->params->get('smallLogo')
? JUri::root() . $this->params->get('smallLogo')
: $this->params->get('smallLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-blue.svg');


// Enable assets
$wa->enableAsset('template.atum.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr'));
Expand Down
9 changes: 7 additions & 2 deletions administrator/templates/atum/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@
$sitename = $app->get('sitename');

// Template params
$siteLogo = $this->params->get('siteLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-joomla-blue.svg');
$loginLogo = $this->params->get('loginLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-blue.svg');
$siteLogo = $this->params->get('siteLogo')
? JUri::root() . $this->params->get('siteLogo')
: $this->params->get('siteLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-joomla-blue.svg');
$loginLogo = $this->params->get('loginLogo')
? JUri::root() . $this->params->get('loginLogo')
: $this->params->get('loginLogo', $this->baseurl . '/templates/' . $this->template . '/images/logo-blue.svg');


// Set some meta data
$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
Expand Down
Loading

0 comments on commit d75a077

Please sign in to comment.