first commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
PLG_QUANTUMMENUS="System - Add Quantum Manager menu item to the sidebar of administrator panel (menu)"
|
||||
PLG_QUANTUMMENUS_XML_DESCRIPTION="Plugin adds menu item to the sidebar of administrator panel (menu)."
|
||||
@@ -0,0 +1,2 @@
|
||||
PLG_QUANTUMMENUS="System - Adding Quantum Manager menu item to the sidebar of administrator panel (menu)"
|
||||
PLG_QUANTUMMENUS_XML_DESCRIPTION="Plugin adds menu item to the sidebar of administrator panel (menu)."
|
||||
@@ -0,0 +1,2 @@
|
||||
PLG_QUANTUMMENUS="Система - Добавление пункта меню от Quantum Manager в административную часть"
|
||||
PLG_QUANTUMMENUS_XML_DESCRIPTION="Плагин позволяет добавить пункт меню Quantum Manager в административную часть."
|
||||
@@ -0,0 +1,2 @@
|
||||
PLG_QUANTUMMENUS="Система - Добавление пункта меню от Quantum Manager в административную часть"
|
||||
PLG_QUANTUMMENUS_XML_DESCRIPTION="Плагин позволяет добавить пункт меню Quantum Manager в административную часть."
|
||||
115
plugins/system/quantummenus/quantummenus.php
Normal file
115
plugins/system/quantummenus/quantummenus.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* @package quantummenus
|
||||
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
|
||||
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see license.txt
|
||||
* @link https://www.norrnext.com
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Menu\AdministratorMenuItem;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Database\DatabaseDriver;
|
||||
|
||||
/**
|
||||
* Quantummenus plugin.
|
||||
*
|
||||
* @package quantummanagermedia
|
||||
* @since 1.0
|
||||
*/
|
||||
class plgSystemQuantummenus extends CMSPlugin
|
||||
{
|
||||
|
||||
protected $app;
|
||||
|
||||
|
||||
protected $db;
|
||||
|
||||
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
|
||||
protected $loadAdminMenu = false;
|
||||
|
||||
|
||||
protected $removeAdminMenu = false;
|
||||
|
||||
|
||||
protected $install_quantummanager = false;
|
||||
|
||||
|
||||
public function __construct(&$subject, $config = array())
|
||||
{
|
||||
parent::__construct($subject, $config);
|
||||
|
||||
if(file_exists(JPATH_SITE . '/administrator/components/com_quantummanager/quantummanager.php'))
|
||||
{
|
||||
$this->install_quantummanager = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function onPreprocessMenuItems($context, $children)
|
||||
{
|
||||
if(!$this->install_quantummanager)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
JLoader::register('QuantummanagerHelper', JPATH_ADMINISTRATOR . '/components/com_quantummanager/helpers/quantummanager.php');
|
||||
|
||||
if (
|
||||
QuantummanagerHelper::isJoomla4() &&
|
||||
QuantummanagerHelper::getParamsComponentValue('itemmenumove', false) &&
|
||||
$this->app->isClient('administrator') &&
|
||||
$context === 'com_menus.administrator.module' &&
|
||||
Factory::getUser()->authorise('core.create', 'com_quantummanager')
|
||||
)
|
||||
{
|
||||
if ($this->loadAdminMenu === false)
|
||||
{
|
||||
QuantummanagerHelper::loadLang();
|
||||
|
||||
$const = 'COM_QUANTUMMANAGER';
|
||||
|
||||
if (QuantummanagerHelper::getParamsComponentValue('itemmenumovefiles', false))
|
||||
{
|
||||
$const = 'COM_QUANTUMMANAGER_MENUS_FILES';
|
||||
}
|
||||
|
||||
$parent = new AdministratorMenuItem ([
|
||||
'title' => $const,
|
||||
'type' => 'component',
|
||||
'link' => 'index.php?option=com_quantummanager',
|
||||
'element' => 'com_quantummanager',
|
||||
'class' => 'class:folder-open',
|
||||
'ajaxbadge' => null,
|
||||
'dashboard' => false
|
||||
]);
|
||||
|
||||
/* @var $root AdministratorMenuItem */
|
||||
$root = $children[0]->getParent();
|
||||
$root->addChild($parent);
|
||||
$this->loadAdminMenu = true;
|
||||
|
||||
}
|
||||
elseif ($this->removeAdminMenu === false)
|
||||
{
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if ($child->type === 'component'
|
||||
&& (int) $child->component_id === ComponentHelper::getComponent('com_quantummanager')->id)
|
||||
{
|
||||
$child->getParent()->removeChild($child);
|
||||
$this->removeAdminMenu = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
plugins/system/quantummenus/quantummenus.xml
Normal file
27
plugins/system/quantummenus/quantummenus.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="3.8" group="system" method="upgrade">
|
||||
<name>PLG_QUANTUMMENUS</name>
|
||||
<creationDate>03.05.2022</creationDate>
|
||||
<author>Tsymbal</author>
|
||||
<authorEmail>cymbal@delo-design.ru</authorEmail>
|
||||
<authorUrl>https://www.norrnext.com</authorUrl>
|
||||
<copyright>Copyright © 2020 Delo Design & NorrNext. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 3 or later; see license.txt</license>
|
||||
<version>1.0</version>
|
||||
<description>PLG_QUANTUMMENUS_XML_DESCRIPTION</description>
|
||||
|
||||
<scriptfile>script.php</scriptfile>
|
||||
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_system_quantummenus.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_system_quantummenus.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_system_quantummenus.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_system_quantummenus.sys.ini</language>
|
||||
</languages>
|
||||
|
||||
<files>
|
||||
<filename plugin="quantummenus">quantummenus.php</filename>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
|
||||
</extension>
|
||||
56
plugins/system/quantummenus/script.php
Normal file
56
plugins/system/quantummenus/script.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* @package quantummenus
|
||||
* @author Dmitry Tsymbal <cymbal@delo-design.ru>
|
||||
* @copyright Copyright © 2019 Delo Design & NorrNext. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see license.txt
|
||||
* @link https://www.norrnext.com
|
||||
*/
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Version;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Quantummanagermedia script file.
|
||||
*
|
||||
* @package A package name
|
||||
* @since 1.0
|
||||
*/
|
||||
class plgSystemQuantummenusInstallerScript
|
||||
{
|
||||
|
||||
/**
|
||||
* Called after any type of action
|
||||
*
|
||||
* @param string $route Which action is happening (install|uninstall|discover_install|update)
|
||||
* @param JAdapterInstance $adapter The object responsible for running this script
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function postflight($route, $adapter)
|
||||
{
|
||||
if (
|
||||
$route === 'install' &&
|
||||
version_compare((new Version())->getShortVersion(), '4.0', '>=')
|
||||
)
|
||||
{
|
||||
$this->enablePlugin($adapter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function enablePlugin($parent)
|
||||
{
|
||||
$plugin = new stdClass();
|
||||
$plugin->type = 'plugin';
|
||||
$plugin->element = $parent->getElement();
|
||||
$plugin->folder = (string) $parent->getParent()->manifest->attributes()['group'];
|
||||
$plugin->enabled = 1;
|
||||
|
||||
Factory::getDbo()->updateObject('#__extensions', $plugin, ['type', 'element', 'folder']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user