Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
renekreijveld committed Jul 14, 2021
1 parent 49f8904 commit 940c43f
Show file tree
Hide file tree
Showing 8 changed files with 1,152 additions and 0 deletions.
674 changes: 674 additions & 0 deletions src/LICENSE.txt

Large diffs are not rendered by default.

136 changes: 136 additions & 0 deletions src/helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php
/**
* @package YOOtheme MegaMenu
* @version 1.0.0
* @copyright Copyright (C) 2021 Destiny B.V., All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
* @author url: https://www.destiny.nl
* @author email email@renekreijveld.nl
*
* YOOtheme MegaMenu is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

defined('_JEXEC') or die;

use \Joomla\CMS\Factory;

/**
* Helper for mod_yootheme_megamenu
*/
abstract class ModYoothemeMegamenuHelper
{
/**
* Get the mega menu items
*
* @param \Joomla\Registry\Registry &$params object holding the models parameters
*
* @return mixed
*
* @since 1.6
*/
public static function getItems(&$params)
{
$db = Factory::getDbo();

$toplevelitems = $params->get('toplevelitems');
$nritems = count($toplevelitems) + 1;;
$count = 0;

# Check for each item if internal link title should be used and cleanup unnecessary fields
foreach ($toplevelitems as $item)
{
# Set the module name
$count++;
$item->modulename = (string) 'megamenu' . $count;

# If the link is internal and we need to use the linked menu item title, get it from the database
if ($item->linktype == 'internal' && $item->useinternallinktitle == '1')
{
$item->externallink = '';
$item->target = '';
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__menu'))
->where($db->quoteName('id') . ' = ' . (int) $item->internallink);
$db->setQuery($query);
$item->title = $db->loadResult();
}

# If the link is external clear the internal link and the internal link title
if ($item->linktype == 'external')
{
$item->internallink = '';
$item->useinternallinktitle = '';
}

# If the item is a link construct it
if ($item->islink == '1')
{
if ($item->linktype == 'internal')
{
$item->link = 'index.php?Itemid=' . $item->internallink;
$item->target = '';
}

if ($item->linktype == 'external')
{
$item->link = $item->externallink;
# Check if the external link needs to be opened in a new browser tab
if ($item->target == '_blank')
{
$item->target = ' target="_blank"';
}
}
}
else
{
$item->link = '#';
$item->target = '';
}

# Check if a dropdown indicator needs to be shown
if ($item->showdd == '1')
{
$item->showdd = ' <span uk-icon="icon: ' . $item->ddicon . '"></span>';
}
else
{
$item->showdd = '';
}

# Check if an offset needs to be set
if ($item->offset)
{
$item->offset = 'offset:' . $item->offset . ';';
}

# Check for an item postion
if ($item->position)
{
$item->position = 'pos:' . $item->position . ';';
}

# Check if item is a single column dropdown, if so set columns to 1.
if ($item->ddkind == 'single')
{
$item->columns = 1;
}

# Check for animation
if ($item->useanimation == '1')
{
$item->animation = 'animation:' . $item->animation . ';duration:' . $item->animationduration . ';';
}
else
{
$item->animation = '';
}
}

return $toplevelitems;
}
}
60 changes: 60 additions & 0 deletions src/language/en-GB/en-GB.mod_yootheme_megamenu.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
; package YOOtheme MegaMenu
; English language file
; version 1.0.0
; copyright (C) 2021 Destiny B.V., All rights reserved.
; license GNU General Public License version 3 or later; see LICENSE.txt
; author url: https://www.destiny.nl
; author email email@renekreijveld.nl
MOD_YT_MEGAMENU_LBL_MODULECLASS="Submenu CSS class"
MOD_YT_MEGAMENU_DESC_MODULECLASS="Input a CSS class here, for easy styling of the whole mega menu"
MOD_YT_MEGAMENU_LBL_SHOWPOSITIONS="Show module positions"
MOD_YT_MEGAMENU_DESC_SHOWPOSITIONS="Use this option to show the module positions in the columns of the dropdown. Do not use on production websites!"
MOD_YT_MEGAMENU_LBL_TOPLEVELITEMS="Top Level Items"
MOD_YT_MEGAMENU_DESC_TOPLEVELITEMS="Define your top levle items here. These are menu buttons that can display a mega menu dropdown or a single column dropdown. Use the + to add more items."
MOD_YT_MEGAMENU_LBL_TITLE="Menu item title"
MOD_YT_MEGAMENU_LBL_ISLINK="Is this a link?"
MOD_YT_MEGAMENU_LBL_LINKTYPE="Link type"
MOD_YT_MEGAMENU_OPT_LINKTYPE_INTERNAL="Internal"
MOD_YT_MEGAMENU_OPT_LINKTYPE_EXTERNAL="External"
MOD_YT_MEGAMENU_LBL_INTERNALLINK="Internal link"
MOD_YT_MEGAMENU_LBL_EXTERNALLINK="External link"
MOD_YT_MEGAMENU_LBL_USEINTERNALLINKTITLE="Use internal link title"
MOD_YT_MEGAMENU_NOTEILTITLE="<b>Attention</b>: the internal link title will be used, the Menu item title above will be ignored."
MOD_YT_MEGAMENU_LBL_TARGET="Open in"
MOD_YT_MEGAMENU_OPT_TARGET_NEW="New tab/window"
MOD_YT_MEGAMENU_OPT_TARGET_SAME="Same frame"
MOD_YT_MEGAMENU_LBL_SHOWDD="Show dropdown indicator"
MOD_YT_MEGAMENU_LBL_DDICON="Indicator icon"
MOD_YT_MEGAMENU_LBL_DDKIND="Dropdown style"
MOD_YT_MEGAMENU_DESC_DDKIND="What kind of dropdown should appear, megamenu or single column"
MOD_YT_MEGAMENU_OPT_DDKIND_MEGA="Mega Menu"
MOD_YT_MEGAMENU_OPT_DDKIND_SINGLE="Single Column"
MOD_YT_MEGAMENU_LBL_COLUMNS="Columns"
MOD_YT_MEGAMENU_NOTEMEGA="Each column in the dropdown has its own unique moduleposition name.<br>
The name is <b>megamenuxy</b>. <b>x</b> is the number of the toplevel item, <b>y</b> is the number of the column.<br>
For the 1st toplevel item, 1st column it is <b>megamenu11</b>, the 3rd toplevel item, 2nd column it is <b>megamenu32</b> etc."
MOD_YT_MEGAMENU_NOTESINGLE="The column in the dropdown has its own unique moduleposition name. The name is <b>megamenux1</b>. <b>x</b> is the number of the toplevel item.<br>
For the 1st toplevel item it is <b>megamenu11</b>, for the 2nd toplevel item it is <b>megamenu21</b> etc."
MOD_YT_MEGAMENU_LBL_OFFSET="Offset"
MOD_YT_MEGAMENU_DESC_OFFSET="Custom offset in pixels between the dropdown container and the menu button"
MOD_YT_MEGAMENU_LBL_POSITION="Position alignment"
MOD_YT_MEGAMENU_DESC_POSITION="Choose the postion of the dropdown to adjust its alignment"
MOD_YT_MEGAMENU_POS_DEFAULT="Default"
MOD_YT_MEGAMENU_POS_BOTLEFT="Bottom Left"
MOD_YT_MEGAMENU_POS_BOTCENTER="Bottom Center"
MOD_YT_MEGAMENU_POS_BOTRIGHT="Bottom Right"
MOD_YT_MEGAMENU_POS_BOTJUSTIFY="Bottom Justify"
MOD_YT_MEGAMENU_POS_TOPLEFT="Top Left"
MOD_YT_MEGAMENU_POS_TOPCENTER="Top Center"
MOD_YT_MEGAMENU_POS_TOPRIGHT="Top Right"
MOD_YT_MEGAMENU_POS_TOPJUSTIFY="Top Justify"
MOD_YT_MEGAMENU_POS_LEFTTOP="Left Top"
MOD_YT_MEGAMENU_POS_LEFTCENTER="Left Center"
MOD_YT_MEGAMENU_POS_LEFTBOTTOM="Left Bottom"
MOD_YT_MEGAMENU_POS_RIGHTTOP="Right Top"
MOD_YT_MEGAMENU_POS_RIGHTCENTER="Right Center"
MOD_YT_MEGAMENU_POS_RIGHTBOTTOM="Right Bottom"
MOD_YT_MEGAMENU_LBL_USEANIMATION="Use animation?"
MOD_YT_MEGAMENU_LBL_ANIMATION="Animation"
MOD_YT_MEGAMENU_LBL_DURATION="Animation duration"
MOD_YT_MEGAMENU_DESC_DURATION="Animation duration in milliseconds"
60 changes: 60 additions & 0 deletions src/language/nl-NL/nl-NL.mod_yootheme_megamenu.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
; package YOOtheme MegaMenu
; Dutch language file
; version 1.0.0
; copyright (C) 2021 Destiny B.V., All rights reserved.
; license GNU General Public License version 3 or later; see LICENSE.txt
; author url: https://www.destiny.nl
; author email email@renekreijveld.nl
MOD_YT_MEGAMENU_LBL_MODULECLASS="Megamenu CSS class"
MOD_YT_MEGAMENU_DESC_MODULECLASS="Vul hier een CSS class in, zodat je het menu gemakkelijk kunt stylen"
MOD_YT_MEGAMENU_LBL_SHOWPOSITIONS="Toon module posities"
MOD_YT_MEGAMENU_DESC_SHOWPOSITIONS="Gebruik deze optie om de modulepositities te tonen in de kolommen van de dropdown. Gebruik deze optie niet op productie websites!"
MOD_YT_MEGAMENU_LBL_TOPLEVELITEMS="Top Level Items"
MOD_YT_MEGAMENU_DESC_TOPLEVELITEMS="Definieer hier je top level items. Dit zijn de menuknoppen waaronder je een megamenu dropdown of een enkele kolom dropdown kunt tonen. Gebruik de + om meer items toe te voegen."
MOD_YT_MEGAMENU_LBL_TITLE="Menu item titel"
MOD_YT_MEGAMENU_LBL_ISLINK="Is dit een link?"
MOD_YT_MEGAMENU_LBL_LINKTYPE="Link type"
MOD_YT_MEGAMENU_OPT_LINKTYPE_INTERNAL="Intern"
MOD_YT_MEGAMENU_OPT_LINKTYPE_EXTERNAL="Extern"
MOD_YT_MEGAMENU_LBL_INTERNALLINK="Interne link"
MOD_YT_MEGAMENU_LBL_EXTERNALLINK="Externe link"
MOD_YT_MEGAMENU_LBL_USEINTERNALLINKTITLE="Gebruik interne link titel"
MOD_YT_MEGAMENU_NOTEILTITLE="<b>Let op</b>: de interne link titel wordt gebruikt, de Menu item titel hierboven wordt genegeerd."
MOD_YT_MEGAMENU_LBL_TARGET="Openen in"
MOD_YT_MEGAMENU_OPT_TARGET_NEW="Nieuw tabblad"
MOD_YT_MEGAMENU_OPT_TARGET_SAME="Hetzelfde tabblad"
MOD_YT_MEGAMENU_LBL_SHOWDD="Toon dropdown aanduiding"
MOD_YT_MEGAMENU_LBL_DDICON="Aanduiding icoon"
MOD_YT_MEGAMENU_LBL_DDKIND="Dropdown soort"
MOD_YT_MEGAMENU_DESC_DDKIND="Wat voor soort dropdown moet er verschijnen, megamenu of één kolom"
MOD_YT_MEGAMENU_OPT_DDKIND_MEGA="Mega Menu"
MOD_YT_MEGAMENU_OPT_DDKIND_SINGLE="Eén kolom"
MOD_YT_MEGAMENU_LBL_COLUMNS="Colummen"
MOD_YT_MEGAMENU_NOTEMEGA="Elke kolom in de dropdown heeft zijn eigen unieke modulepositie naam.<br>
Deze naam is <b>megamenuxy</b>. <b>x</b> is het nummer van het toplevel item, <b>y</b> is het kolomnummer.<br>
Voor het 1e toplevel item, 1e kolom is dat <b>megamenu11</b>, voor het 3e toplevel item, 2e kolom is dat <b>megamenu32</b> enz."
MOD_YT_MEGAMENU_NOTESINGLE="De kolom in de dropdown heeft zijn eigen unieke modulepositie naam. De naam is <b>megamenux1</b>. <b>x</b> is het nummer van het toplevel item.<br>
Voor het 1e toplevel item is dat <b>megamenu11</b>, voor het 2e toplevel item is dat <b>megamenu21</b> enz."
MOD_YT_MEGAMENU_LBL_OFFSET="Offset"
MOD_YT_MEGAMENU_DESC_OFFSET="De offset in pixels tussen de dropdown en de toplevel menuknop"
MOD_YT_MEGAMENU_LBL_POSITION="Positionering"
MOD_YT_MEGAMENU_DESC_POSITION="Kies de positionering van de dropdown ten opzicht van het toplevel item"
MOD_YT_MEGAMENU_POS_DEFAULT="Standaard"
MOD_YT_MEGAMENU_POS_BOTLEFT="Onder Links"
MOD_YT_MEGAMENU_POS_BOTCENTER="Onder Midden"
MOD_YT_MEGAMENU_POS_BOTRIGHT="Onder Rechts"
MOD_YT_MEGAMENU_POS_BOTJUSTIFY="Onder Uitgelijnd"
MOD_YT_MEGAMENU_POS_TOPLEFT="Boven Links"
MOD_YT_MEGAMENU_POS_TOPCENTER="Boven Midden"
MOD_YT_MEGAMENU_POS_TOPRIGHT="Boven Rechts"
MOD_YT_MEGAMENU_POS_TOPJUSTIFY="Boven Uitgelijnd"
MOD_YT_MEGAMENU_POS_LEFTTOP="Links Boven"
MOD_YT_MEGAMENU_POS_LEFTCENTER="Links Midden"
MOD_YT_MEGAMENU_POS_LEFTBOTTOM="Links Onder"
MOD_YT_MEGAMENU_POS_RIGHTTOP="Rechts Boven"
MOD_YT_MEGAMENU_POS_RIGHTCENTER="Rechts Midden"
MOD_YT_MEGAMENU_POS_RIGHTBOTTOM="Rechts Onder"
MOD_YT_MEGAMENU_LBL_USEANIMATION="Gebruik animatie?"
MOD_YT_MEGAMENU_LBL_ANIMATION="Animatie"
MOD_YT_MEGAMENU_LBL_DURATION="Animatie duur"
MOD_YT_MEGAMENU_DESC_DURATION="Animatie duur in milliseconden"
30 changes: 30 additions & 0 deletions src/mod_yootheme_megamenu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @package YOOtheme MegaMenu
* @version 1.0.0
* @copyright Copyright (C) 2021 Destiny B.V., All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
* @author url: https://www.destiny.nl
* @author email email@renekreijveld.nl
*
* YOOtheme MegaMenu is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

defined('_JEXEC') or die;

use Joomla\CMS\Helper\ModuleHelper;

// Include the yootheme megamenu functions only once
JLoader::register('ModYoothemeMegamenuHelper', __DIR__ . '/helper.php');

// Get general module parameters
$moduleclass = $params->get('moduleclass');
$showpositions = $params->get('showpositions');
// Get toplevel items and the dropdown definitions
$toplevelitems = ModYoothemeMegamenuHelper::getItems($params);

require ModuleHelper::getLayoutPath('mod_yootheme_megamenu', 'default');
44 changes: 44 additions & 0 deletions src/mod_yootheme_megamenu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1" client="site" method="upgrade">
<name>YOOtheme MegaMenu</name>
<author>René Kreijveld</author>
<creationDate>July 2021</creationDate>
<copyright>Copyright (C) Destiny B.V., All rights reserved.</copyright>
<license>GNU General Public License version 3 or later</license>
<authorEmail>email@renekreijveld.nl</authorEmail>
<authorUrl>https://www.destiny.nl</authorUrl>
<version>1.0.0</version>
<description>This module generates a Mega Menu for YOOtheme Pro</description>
<files>
<filename>helper.php</filename>
<filename>LICENSE.txt</filename>
<filename module="mod_yootheme_megamenu">mod_yootheme_megamenu.php</filename>
<filename>mod_yootheme_megamenu.xml</filename>
<folder>language</folder>
<folder>subforms</folder>
<folder>tmpl</folder>
</files>
<config>
<fields name="params">
<fieldset name="basic">
<field name="moduleclass" type="text" label="MOD_YT_MEGAMENU_LBL_MODULECLASS" description="MOD_YT_MEGAMENU_DESC_MODULECLASS"/>
<field name="showpositions" type="radio" default="0" label="MOD_YT_MEGAMENU_LBL_SHOWPOSITIONS" description="MOD_YT_MEGAMENU_DESC_SHOWPOSITIONS" class="btn-group btn-group-yesno">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="toplevelitems" type="subform" label="MOD_YT_MEGAMENU_LBL_TOPLEVELITEMS" description="MOD_YT_MEGAMENU_DESC_TOPLEVELITEMS" multiple="true" min="1" max="8" required= "true" formsource= "modules/mod_yootheme_megamenu/subforms/subform_toplevelitem.xml" groupByFieldset="false" />
</fieldset>
<fieldset name="advanced">
<field name="layout" type="modulelayout" label="JFIELD_ALT_LAYOUT_LABEL" description="JFIELD_ALT_MODULE_LAYOUT_DESC" />
<field name="cache" default="1" label="COM_MODULES_FIELD_CACHING_LABEL" description="COM_MODULES_FIELD_CACHING_DESC">
<option value="1">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field name="cache_time" type="text" default="900" label="COM_MODULES_FIELD_CACHE_TIME_LABEL" description="COM_MODULES_FIELD_CACHE_TIME_DESC"/>
<field name="cachemode" type="hidden" default="itemid">
<option value="itemid"></option>
</field>
</fieldset>
</fields>
</config>
</extension>
Loading

0 comments on commit 940c43f

Please sign in to comment.