Skip to content

Commit

Permalink
added a new field
Browse files Browse the repository at this point in the history
  • Loading branch information
mediafoks committed Nov 14, 2024
1 parent 505570d commit 8bc43da
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 42 deletions.
11 changes: 4 additions & 7 deletions language/en-GB/mod_contacts_birthday.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
MOD_CONTACTS_BIRTHDAY = "Contact birthdays"
MOD_CONTACTS_BIRTHDAY_XML_DESCRIPTION = "Happy Birthday contacts. Set contact creation date to Birthday"

MOD_CONTACTS_BIRTHDAY_FIELD_CATEGORY_LABEL = "Category"

MOD_CONTACTS_BIRTHDAY_FIELD_PREPARE_CONTENT_LABEL="Prepare Content"
MOD_CONTACTS_BIRTHDAY_FIELD_PREPARE_CONTENT_DESC="Optionally prepare the content with the Joomla Content Plugins"
MOD_CONTACTS_BIRTHDAY_FIELD_BACKGROUNDIMAGE_LABEL="Select a Background Image"

MOD_CONTACTS_BIRTHDAY_EVENT_TXT="birthday"
MOD_CONTACTS_BIRTHDAY_INTRO_TXT="Today"
MOD_CONTACTS_BIRTHDAY_SUFFIX_ACTION_TXT="celebrate"
MOD_CONTACTS_BIRTHDAY_SUFFIX_SINGULAR_TXT="s"
MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT=""
MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT=""

MOD_CONTACTS_BIRTHDAY_FIELD_SUFFIX_TEXT_LABEL="Additional text"
MOD_CONTACTS_BIRTHDAY_FIELD_SUFFIX_TEXT_DESC="Add the text. It will be displayed after congratulations"
11 changes: 4 additions & 7 deletions language/ru-RU/mod_contacts_birthday.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
MOD_CONTACTS_BIRTHDAY = "Дни рождения контактов"
MOD_CONTACTS_BIRTHDAY_XML_DESCRIPTION = "Поздравляет с Днем рождения контакты. Установите дату создания контакта, соответствующую Дню рождения"

MOD_CONTACTS_BIRTHDAY_FIELD_CATEGORY_LABEL = "Категория"

MOD_CONTACTS_BIRTHDAY_FIELD_PREPARE_CONTENT_LABEL="Обработка событиями"
MOD_CONTACTS_BIRTHDAY_FIELD_PREPARE_CONTENT_DESC="Включить или отключить функцию обработки содержимого модуля событиями плагина (onContentPrepare)"
MOD_CONTACTS_BIRTHDAY_FIELD_BACKGROUNDIMAGE_LABEL="Фоновое изображение"

MOD_CONTACTS_BIRTHDAY_EVENT_TXT="День рождения"
MOD_CONTACTS_BIRTHDAY_INTRO_TXT="Сегодня"
MOD_CONTACTS_BIRTHDAY_SUFFIX_ACTION_TXT="отмеча"
MOD_CONTACTS_BIRTHDAY_SUFFIX_SINGULAR_TXT="ет"
MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT="ют"
MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT="ют"

MOD_CONTACTS_BIRTHDAY_FIELD_SUFFIX_TEXT_LABEL="Дополнительный текст"
MOD_CONTACTS_BIRTHDAY_FIELD_SUFFIX_TEXT_DESC="Добавьте текст. Будет отображаться после поздравления"
22 changes: 5 additions & 17 deletions 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.0.4</version>
<version>1.1.0</version>
<description>MOD_CONTACTS_BIRTHDAY_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\ContactsBirthday</namespace>
<files>
Expand All @@ -25,34 +25,22 @@
<config>
<fields name="params">

<fieldset name="basic">
<field name="catid" type="category" extension="com_contact" multiple="true" default="" size="10" label="MOD_CONTACTS_BIRTHDAY_FIELD_CATEGORY_LABEL" required="true">
</field>
</fieldset>
<fieldset name="options" label="COM_MODULES_BASIC_FIELDSET_LABEL">
<field name="prepare_content" type="radio" layout="joomla.form.field.radio.switcher" label="MOD_CONTACTS_BIRTHDAY_FIELD_PREPARE_CONTENT_LABEL" description="MOD_CONTACTS_BIRTHDAY_FIELD_PREPARE_CONTENT_DESC" default="0" filter="integer">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field name="backgroundimage" type="media" schemes="http,https,ftp,ftps,data,file" validate="url" relative="true" label="MOD_CONTACTS_BIRTHDAY_FIELD_BACKGROUNDIMAGE_LABEL" />
<fieldset name="basic" addfieldprefix="Joomla\Component\Contact\Administrator\Field">
<field name="catid" type="category" label="JCATEGORY" extension="com_contact" multiple="true" layout="joomla.form.field.list-fancy-select" filter="intarray" required="true" class="multipleCategories" />
<field name="suffix_text" type="text" label="MOD_CONTACTS_BIRTHDAY_FIELD_SUFFIX_TEXT_LABEL" description="MOD_CONTACTS_BIRTHDAY_FIELD_SUFFIX_TEXT_DESC" required="false" filter="string" />
</fieldset>

<fieldset name="advanced">
<field name="layout" type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" class="form-select" validate="moduleLayout" />

<field name="moduleclass_sfx" type="textarea" label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL" rows="3" validate="CssIdentifier" />

<field name="cache" type="list" label="COM_MODULES_FIELD_CACHING_LABEL" default="1" filter="integer" validate="options">
<field name="owncache" type="list" label="COM_MODULES_FIELD_CACHING_LABEL" default="1" filter="integer" validate="options">
<option value="1">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>

<field name="cache_time" type="number" label="COM_MODULES_FIELD_CACHE_TIME_LABEL" default="900" filter="integer" />

<field name="cachemode" type="hidden" default="static">
<option value="static"></option>
</field>
</fieldset>

</fields>
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.0.4
* @since 1.1.0
*/
return new class() implements ServiceProviderInterface
{
Expand All @@ -30,7 +30,7 @@
*
* @return void
*
* @since 1.0.4
* @since 1.1.0
*/
public function register(Container $container)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Dispatcher/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Dispatcher class for mod_contacts_birthday
*
* @since 1.0.4
* @since 1.1.0
*/
class Dispatcher extends AbstractModuleDispatcher
{
Expand All @@ -33,7 +33,7 @@ class Dispatcher extends AbstractModuleDispatcher
*
* @return array
*
* @since 1.0.4
* @since 1.1.0
*/
private $moduleExtension;

Expand Down
2 changes: 1 addition & 1 deletion src/Helper/ContactsBirthdayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/**
* Helper for mod_contacts_birthday
*
* @since 1.0.4
* @since 1.1.0
*/
class ContactsBirthdayHelper
{
Expand Down
1 change: 1 addition & 0 deletions tmpl/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
defined('_JEXEC') or die;

//$contacts - массив всех контактов.
if (!$contacts) return;

$today = date("m-d"); //Текущая дата

Expand Down
11 changes: 7 additions & 4 deletions tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@
use Joomla\CMS\Language\Text;

//$contacts - массив всех контактов.
if (!$contacts) return;

$today = date("m-d"); //Текущая дата
$arr_contacts_name = []; //Массив с именами контактов

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

foreach ($contacts as $key => $contact) {
$name = $contact->name; //Имя контакта
$birthday = date_format(date_create($contact->created), 'm-d'); //Дата создания контакта
if ($today == $birthday) array_push($arr_contacts_name, $name); //Если дата создания контакта (ДР) равна текущей дате, то добавляем имя контакта в массив
if ($today == $birthday) array_push($contacts_name, $name); //Если дата создания контакта (ДР) равна текущей дате, то добавляем имя контакта в массив
}
?>

<?php if (!empty($arr_contacts_name)) : ?>
<?php if (!empty($contacts_name)) : ?>
<div class="contacts-birthday">
<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(', ', $arr_contacts_name); ?></span> <?= Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_ACTION_TXT'), count($arr_contacts_name) > 1 ? Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT') : Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_SINGULAR_TXT'), ' ' . Text::_('MOD_CONTACTS_BIRTHDAY_EVENT_TXT'); ?>
<?= 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 ?: ''; ?>
</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.0.4</version>
<version>1.1.0</version>
<downloads>
<downloadurl type="full" format="zip">https://github.com/mediafoks/mod_contacts_birthday/archive/refs/tags/v1.0.4.zip</downloadurl>
<downloadurl type="full" format="zip">https://github.com/mediafoks/mod_contacts_birthday/archive/refs/tags/v1.1.0.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
Expand Down

0 comments on commit 8bc43da

Please sign in to comment.