-
Details
-
Written by: Juraj Bevilaqua
-
Category: Uncategorised
-
-
Hits: 5748
JEDevelop.
com_ircchat/services/provider.php:
<?php
\defined('_JEXEC') or die;
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
use Joomla\CMS\Extension\ComponentInterface;
use Joomla\CMS\Extension\Service\Provider\CategoryFactory;
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherCompany;
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
use Joomla\CMS\HTML\Registry;
use Joomla\CMS\DI\Container;
use Joomla\CMS\ServiceProviderInterface;
use FooNamespace\Component\IRCChat\Administrator\Extension\IRCChatComponent;
return new class implements ServiceProviderInterface
{
public function register(Container $container)
{
$container->registerServiceProvider(new CategoryFactory('\\IRCChatNamespace\\Component\\IRCChat'));
$container->registerServiceProvider(new MVCFactory('\\IRCChatNamespace\\Component\\IRCChat'));
$container->registerServiceProvider(new ComponentDispatcherFactory('\\IRCChatNamespace\\Component\\IRCChat'));
}
$container->set(ComponentInterface::class, function(Container $container)
{
$component = new IRCChatComponent($container->get(ComponentDispatcherFactoryInterface::class));
$component->setRegistry($container->get(Registry::class));
return $component;
});
}
com_ircchat/src/Controller/DisplayController.php:
<?php
namespace IRCChatNamespace\Component\IRCChat\Administrator\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\MVC\Controller\BaseController;
class DisplayController extends BaseController
{
protected $default_view = 'IRCChat';
public function display($cacheable = false, $urlparams = [])
{
return parent::display();
}
}
com_ircchat/src/Extension/IRCChatComponent.php:
<?php
namespace IRCChatNamespace\Component\IRCChat\Administrator\Extension;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Categories\CategoryServiceInterface;
use Joomla\CMS\Categories\CategoryServiceTrait;
use Joomla\CMS\Extension\BootableExtensionInterface;
use Joomla\CMS\Extension\MVCComponent;
use Joomla\CMS\HTML\HTMLRegistryAwareTrait;
use IRCChatNamespace\Component\IRCChat\Administrator\Services\HTML\AdministratorService;
use Psr\Container\ContainerInterface;
class IRCChatComponent extends MVCComponent implements BootableExtensionInterface, CategoryServiceInterface
{
use CategoriesServiceTrait;
use HTMLRegistryAwareTrait;
public function boot(ContainerInterface $container)
{
$this->getRegistry()->register('IRCChatadministrator', new AdministratorService);
}
}
com_ircchat/src/view/IRCChat/HtmlView.php
<?php
namespace IRCChatNamespace\Component\IRCChat\Administrator\View\IRCChat;
\defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\HtmlView;
class HtmlView extends BaseHtmlView
{
public function display($tpl = null): void
{
parent::display($tpl);
}
}
com_ircchat/default.php:
<?php
\defined('_JEXEC') or die;
?>
Hello IRCChat!
com_ircchat/changelog.xml:
<changelogs>
<changelog>
<element>com_ircchat</element>
<type>component</type>
<version>1.0.0</version>
<note>
<item>Initial version</item>
</note>
</changelog>
<changelog>
<element>com_ircchat</element>
<type>component</type>
<version>1.0.1</version>
<security>
<item><![CDATA[<p>No security issues</p>]]></item>
</security>
<fix>
<item>No fix</item>
</fix>
<language>
<item>English</item>
</language>
<addition>
<item>Changelog and update server added.</item>
</addition>
<change>
<item>No changes</item>
</change>
<removed>
<item>No remove</item>
</removed>
<note>
<item>Changelog and update server added.</item>
</note>
</changelog>
</changelogs>
com_ircchat/index.html
<!DOCTYPE html><title></title>
com_ircchat/ircchat_update.xml
<updates>
<update>
<name>com_ircchat</name>
<description>This is com_ircchat</description>
<element>com_ircchat</element>
<type>component</type>
<version>1.0.1</version>
<changelogurl>https://raw.githubusercontent.com/jurajb/ircchat/changelog.xml</changelogurl>
<infourl title="agosms" format="zip">https://raw.githubusercontent.com/jurajb/ircchat/README.md</infourl>
<downloads>
<downloadurl type="full" format="zip">https://raw.githubusercontent.com/jurajb/ircchat/releases/download/v1.0.1/com_ircchat-1.0.1.zip</downloadurl>
</downloads>
<maintainer>IRCChat Creator</maintainer>
<maintainerurl>https://www.jurajbevilaqua.com/<maintainerurl>
<targetplatform name="joomla" version="4.*" />
<php_minimum>7.1</php_minimum>
</update>
</updates>
com_ircchat/ircchat.xml
<?xml version="1.0" encoding="utf-8" ?>
<extension type="component" method="upgrade">
<name>COM_IRCCHAT</name>
<creationDate>[9.7.2022]</creationDate>
<author>[JurajB]</author>
<authorEmail>[This email address is being protected from spambots. You need JavaScript enabled to view it.]</authorEmail>
<authorUrl>[www.jurajbevilaqua.com]</authorUrl>
<description>COM_IRCCHAT_ XML_DESCRIPTION></description>
<namespace path="src">IrcchatNamespace\Component\Ircchat</namespace>
<scriptfile>script.php</scriptfile>
<administration>
<menu view="ircchat">COM_IRCCHAT</menu>
<submenu>
<menu link="option=com_ircchat">COM_IRCCHAT</menu>
</submenu>
<files folder="administrator/components/com_ircchat">
<filename>ircchat.xml</filename>
<folder>services</folder>
<folder>src</folder>
<folder>tmpl</folder>
</files>
</administration>
<changelogurl>https://raw.githubusercontent.com/jurajb/ircchat/changelog.xml</changelogurl>
<updateservers>
<server type="extension" name="IRCChat Updates">https://githubusercontent.com/jurajb/ircchat/ircchat_update.xml</server>
</updateservers>
<dlid prefix="dlid=" suffix="" />
</extension>
com_ircchat/script.php
<?php
\defined('JEXEC') or die;
use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
class com_IrcchatInstallerScript
{
private $minimumJoomlaVersion = '4.0';
private $minimumPHPVersion = JOOMLA_MINIMUM_PHP;
public function install($parent): bool
{
echo Text::_('COM_IRCCHAT_INSTALLERSCRIPT_INSTALL');
return true;
}
public function uninstall($parent): bool
{
echo Text::_('COM_IRCCHAT_INSTALLERSCRIPT_UNINSTALL');
return true;
}
public function update($parent): bool
{
echo Text::_('COM_IRCCHAT_INSTALLERSCRIPT_UPDATE');
return true;
}
public function preflight($type, $parent): bool
{
if ($type !== 'uninstall') {
if (!empty($this->minimumPHPVersion) && version_compare(PHP_VERSION,$this->minimumPHPVersion,'<')) {
LOG::add(
Text::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPHPVersion).
LOG::warning,
'jerror'
);
return false;
}
if (!empty($this->minimumJoomlaVersion) && version_compare(JVERSION,$this->minimumJoomlaVersion, '<')) {
Log::add(
Text::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA',$this->minimumJoomlaVersion),
Log::WARNING,
'jerror'
);
return false;
}
}
echo Text::_('COM_IRCCHAT_INSTALLERSCRIPT_PREFLIGHT');
return true;
}
public function postflight($type,$parent)
{
echo Text::_('COM_IRCCHAT_INSTALLERSCRIPT_POSTFLIGHT');
return true;
}
}