Skip to content

Commit

Permalink
Модуль переписан с учетом новой структуры Joomla
Browse files Browse the repository at this point in the history
  • Loading branch information
mediafoks committed Nov 14, 2024
1 parent 8bc43da commit 13ad2f6
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion mod_contacts_birthday.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>https://github.com/mediafoks</authorUrl>
<version>1.1.0</version>
<version>2.0.0</version>
<description>MOD_CONTACTS_BIRTHDAY_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\ContactsBirthday</namespace>
<files>
Expand Down
4 changes: 2 additions & 2 deletions services/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* The Ks contacts birthday module service provider.
*
* @since 1.1.0
* @since 2.0.0
*/
return new class() implements ServiceProviderInterface
{
Expand All @@ -30,7 +30,7 @@
*
* @return void
*
* @since 1.1.0
* @since 2.0.0
*/
public function register(Container $container)
{
Expand Down
27 changes: 11 additions & 16 deletions src/Dispatcher/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

namespace Joomla\Module\ContactsBirthday\Site\Dispatcher;

use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
use Joomla\CMS\Extension\ModuleInterface;
use Joomla\Input\Input;
use Joomla\Registry\Registry;
use Joomla\Module\ContactsBirthday\Site\Helper\ContactsBirthdayHelper;
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
use Joomla\CMS\Helper\HelperFactoryAwareTrait;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -24,29 +21,27 @@
/**
* Dispatcher class for mod_contacts_birthday
*
* @since 1.1.0
* @since 2.0.0
*/
class Dispatcher extends AbstractModuleDispatcher
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface
{
use HelperFactoryAwareTrait;

/**
* Returns the layout data.
*
* @return array
*
* @since 1.1.0
* @since 2.0.0
*/
private $moduleExtension;

public function __construct(\stdClass $module, CMSApplicationInterface $app, Input $input)
{
parent::__construct($module, $app, $input);
}

protected function getLayoutData()
{
$data = parent::getLayoutData();
$helper = $this->app->bootModule('mod_contacts_birthday', 'Site')->getHelper('ContactsBirthdayHelper');
$data['contacts'] = $helper->getContacts($data['params'], $this->getApplication());
$data['suffixText'] = $data['params']->get('suffix_text', '');
$data['contacts'] = $this->getHelperFactory()
->getHelper('ContactsBirthdayHelper')
->getContacts($data['params'], $this->getApplication());
return $data;
}
}
11 changes: 7 additions & 4 deletions src/Helper/ContactsBirthdayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

namespace Joomla\Module\ContactsBirthday\Site\Helper;

use Joomla\CMS\Factory;
use Joomla\Database\DatabaseAwareInterface;
use Joomla\Database\DatabaseAwareTrait;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -19,13 +20,15 @@
/**
* Helper for mod_contacts_birthday
*
* @since 1.1.0
* @since 2.0.0
*/
class ContactsBirthdayHelper
class ContactsBirthdayHelper implements DatabaseAwareInterface
{
use DatabaseAwareTrait;

public function getContacts($params): array
{
$db = Factory::getContainer()->get('DatabaseDriver');
$db = $this->getDatabase();

$catId = join(',', $params->get('catid'));

Expand Down
3 changes: 1 addition & 2 deletions tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
$today = date("m-d"); //Текущая дата

$contacts_name = []; //Массив с именами контактов
$suffix_text = $params->get('suffix_text'); // Дополнительный текст

foreach ($contacts as $key => $contact) {
$name = $contact->name; //Имя контакта
Expand All @@ -32,6 +31,6 @@
<svg class="ico" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256">
<path d="M232,112a24,24,0,0,0-24-24H136V79a32.06,32.06,0,0,0,24-31c0-28-26.44-45.91-27.56-46.66a8,8,0,0,0-8.88,0C122.44,2.09,96,20,96,48a32.06,32.06,0,0,0,24,31v9H48a24,24,0,0,0-24,24v23.33a40.84,40.84,0,0,0,8,24.24V200a24,24,0,0,0,24,24H200a24,24,0,0,0,24-24V159.57a40.84,40.84,0,0,0,8-24.24ZM112,48c0-13.57,10-24.46,16-29.79,6,5.33,16,16.22,16,29.79a16,16,0,0,1-32,0ZM40,112a8,8,0,0,1,8-8H208a8,8,0,0,1,8,8v23.33c0,13.25-10.46,24.31-23.32,24.66A24,24,0,0,1,168,136a8,8,0,0,0-16,0,24,24,0,0,1-48,0,8,8,0,0,0-16,0,24,24,0,0,1-24.68,24C50.46,159.64,40,148.58,40,135.33Zm160,96H56a8,8,0,0,1-8-8V172.56A38.77,38.77,0,0,0,62.88,176a39.69,39.69,0,0,0,29-11.31A40.36,40.36,0,0,0,96,160a40,40,0,0,0,64,0,40.36,40.36,0,0,0,4.13,4.67A39.67,39.67,0,0,0,192,176c.38,0,.76,0,1.14,0A38.77,38.77,0,0,0,208,172.56V200A8,8,0,0,1,200,208Z"></path>
</svg>
<?= Text::_('MOD_CONTACTS_BIRTHDAY_INTRO_TXT'); ?> <span class="contacts-birthday__name"><?= implode(', ', $contacts_name); ?></span> <?= Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_ACTION_TXT'), count($contacts_name) > 1 ? Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT') : Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_SINGULAR_TXT'), ' ' . Text::_('MOD_CONTACTS_BIRTHDAY_EVENT_TXT') . ' ' . $suffix_text ?: ''; ?>
<?= Text::_('MOD_CONTACTS_BIRTHDAY_INTRO_TXT'); ?> <span class="contacts-birthday__name"><?= implode(', ', $contacts_name); ?></span> <?= Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_ACTION_TXT'), count($contacts_name) > 1 ? Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT') : Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_SINGULAR_TXT'), ' ' . Text::_('MOD_CONTACTS_BIRTHDAY_EVENT_TXT') . ' ' . $suffixText ?: ''; ?>
</div>
<?php endif; ?>
4 changes: 2 additions & 2 deletions update.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<element>mod_contacts_birthday</element>
<type>module</type>
<client>site</client>
<version>1.1.0</version>
<version>2.0.0</version>
<downloads>
<downloadurl type="full" format="zip">https://github.com/mediafoks/mod_contacts_birthday/archive/refs/tags/v1.1.0.zip</downloadurl>
<downloadurl type="full" format="zip">https://github.com/mediafoks/mod_contacts_birthday/archive/refs/tags/v2.0.0.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
Expand Down

0 comments on commit 13ad2f6

Please sign in to comment.