first commit

This commit is contained in:
2026-02-08 21:16:11 +01:00
commit e17b7026fd
8881 changed files with 1160453 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,36 @@
<?php
/**
* @name Mobile Menu CK
* @copyright Copyright (C) 2018. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
/*
* Global method that can be called easily
*/
function loadMobileMenuCK($selector, $options = array()) {
return \Mobilemenuck\Menu::load($selector, $options);
}
/*
* Global method that can be called easily, direct injection
*/
function loadMobileMenuCKInline($selector, $options = array()) {
return \Mobilemenuck\Menu::load($selector, $options, true);
}
/*
* Global method that can be called easily
*/
function loadThemeMobileMenuCK($id, $themeid = null) {
return \Mobilemenuck\Menu::loadTheme($id, false, $themeid);
}
/*
* Global method that can be called easily
*/
function loadThemeMobileMenuCKInline($id, $themeid = null) {
return \Mobilemenuck\Menu::loadTheme($id, true, $themeid);
}

View File

@@ -0,0 +1,226 @@
<?php
/**
* @name Mobile Menu CK
* @copyright Copyright (C) 2018. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
namespace Mobilemenuck;
// No direct access
defined('MOBILEMENUCK_LOADED') or die;
class Helper
{
/**
* Render a html message
*
* @return string
*
*/
public static function renderProMessage() {
$html = '<div><a href="https://www.joomlack.fr/en/joomla-extensions/mobile-menu-ck" target="_blank">Not available in the free version</a></div>';
return $html;
}
/**
* List the replacement between the tags and the real final CSS rules
*/
public static function getCssReplacement() {
$cssreplacements = Array(
'[menu-bar]' => ' .mobilemenuck-bar-title'
,'[menu-bar-button]' => ' .mobilemenuck-bar-button'
,'[menu]' => '.mobilemenuck'
,'[menu-topbar]' => ' .mobilemenuck-title'
,'[menu-topbar-button]' => ' .mobilemenuck-button'
,'[level1menuitem]' => ' .mobilemenuck-item > .level1'
,'[level1menuitemhover] a' => ' .mobilemenuck-item > .level1:hover a, |ID| .mobilemenuck-item > .level1.open a'
,'[level1menuitemhover]' => ' .mobilemenuck-item > .level1:hover, |ID| .mobilemenuck-item > .level1.open'
,'[level1menuitemactive]' => ' .mobilemenuck-item > .level1.active'
,'[level1submenu]' => ' .mobilemenuck-item > .level1 + .mobilemenuck-submenu'
,'[level2menuitem]' => ' .mobilemenuck-item > .level2'
,'[level2menuitemhover] a' => ' .mobilemenuck-item > .level2:hover a, |ID| .mobilemenuck-item > .level2.open a'
,'[level2menuitemhover]' => ' .mobilemenuck-item > .level2:hover, |ID| .mobilemenuck-item > .level2.open'
,'[level2menuitemactive]' => ' .mobilemenuck-item > .level2.active'
,'[level2submenu]' => ' .mobilemenuck-item > .level2 + .mobilemenuck-submenu'
,'[level3menuitem]' => ' .level2 + .mobilemenuck-submenu .mobilemenuck-item > div'
,'[level3menuitemhover] a' => ' .level2 + .mobilemenuck-submenu .mobilemenuck-item > div:hover a, |ID| .mobilemenuck-item > .level2 + .mobilemenuck-submenu .mobilemenuck-item > div.open a'
,'[level3menuitemhover]' => ' .level2 + .mobilemenuck-submenu .mobilemenuck-item > div:hover, |ID| .mobilemenuck-item > .level2 + .mobilemenuck-submenu .mobilemenuck-item > div.open'
,'[level3menuitemactive]' => ' .level2 + .mobilemenuck-submenu .mobilemenuck-item > div.active'
,'[level3submenu]' => ' .mobilemenuck-item > .level2 .mobilemenuck-submenu'
,'[togglericon]' => ' .mobilemenuck-togglericon:after'
,'[PRESETS_URI]' => MOBILEMENUCK_MEDIA_URI . '/presets'
);
return $cssreplacements;
}
/**
* Do the replacement between the tags and the real final CSS rules
*/
public static function makeCssReplacement(&$css) {
$cssreplacementlist = self::getCssReplacement();
foreach ($cssreplacementlist as $tag => $rep) {
$css = str_replace($tag, $rep, $css);
}
}
/**
* Get the name of the style
*/
public static function getStyleNameById($id) {
if (! $id) return '';
// Create a new query object.
$db = \JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select('a.name');
$query->from($db->quoteName('#__mobilemenuck_styles') . ' AS a');
$query->where('(a.state IN (0, 1))');
$query->where('a.id = ' . (int)$id);
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$result = $db->loadResult();
return $result;
}
/**
* Get the name of the style
*/
public static function getStyleById($id, $select = '*', $type = 'result') {
if (! $id) return '';
// Create a new query object.
$db = \JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($select);
$query->from($db->quoteName('#__mobilemenuck_styles') . ' AS a');
$query->where('(a.state IN (0, 1))');
$query->where('a.id = ' . (int)$id);
// Reset the query using our newly populated query object.
$db->setQuery($query);
switch($type) {
default :
case "result" :
$result = $db->loadResult();
break;
case "object" :
$result = $db->loadObject();
break;
}
return $result;
}
/**
* Get the name of the style
*/
public static function getStyles($select = '*') {
// Create a new query object.
$db = \JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($select);
$query->from($db->quoteName('#__mobilemenuck_styles') . ' AS a');
$query->where('(a.state IN (0, 1))');
// Reset the query using our newly populated query object.
$db->setQuery($query);
$result = $db->loadObjectList();
return $result;
}
/**
* Get the name of the style
*/
public static function getModuleById($id, $select = '*') {
if (! $id) return '';
// Create a new query object.
$db = \JFactory::getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select($select);
$query->from($db->quoteName('#__modules') . ' AS a');
// $query->where('(a.published IN (0, 1))');
$query->where('a.id = ' . (int)$id);
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$result = $db->loadObject();
return $result;
}
/**
* Look if the pro version is installed
*
* @return boolean
*/
public static function checkIsProVersion() {
return self::searchTable('mobilemenuck_styles') && file_exists(JPATH_ROOT . '/administrator/components/com_mobilemenuck/mobilemenuck.php');
}
/**
* Look if the table exists, if not then create it
*
* @param type $tableName
* @return boolean
*/
private static function searchTable($tableName) {
$db = \JFactory::getDbo();
$tablesList = $db->getTableList();
$tableExists = in_array($db->getPrefix() . $tableName, $tablesList);
return $tableExists;
}
public static function createIdForModule($module) {
if ($module->module == 'mod_maximenuck') {
$params = new \JRegistry($module->params);
if ($params->get('menuid', '') === '' || is_numeric($params->get('menuid', ''))) {
$id = 'maximenuck' . $module->id;
} else {
$id = $params->get('menuid', '');
}
} else if ($module->module == 'mod_accordeonmenuck') {
$params = new \JRegistry($module->params);
if ($params->get('menuid', '') === '' || is_numeric($params->get('menuid', ''))) {
$id = 'accordeonck' . $module->id;
} else {
$id = $params->get('menuid', '');
}
} else {
$id = 'mobilemenuck-' . $module->id;
}
return $id;
}
public static function getLayoutCss() {
$doc = \JFactory::getDocument();
$overrideSrc = JPATH_ROOT . '/templates/' . $doc->template . '/css/mobilemenuck.css';
$overrideSrc2 = JPATH_ROOT . '/media/templates/site/' . $template . '/css/mobilemenuck.css';
if (file_exists($overrideSrc)) {
$layoutcss = file_get_contents($overrideSrc);
} else if (file_exists($overrideSrc2)) {
$layoutcss = file_get_contents($overrideSrc2);
} else {
$layoutcss = file_get_contents(MOBILEMENUCK_PATH . '/default.txt');
}
return $layoutcss;
}
}

View File

@@ -0,0 +1,50 @@
<?php
/**
* @name Mobile Menu CK
* @copyright Copyright (C) 2018. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
namespace Mobilemenuck;
// No direct access
defined('MOBILEMENUCK_LOADED') or die;
class CKLoader
{
public static function loadScriptDeclaration($js) {
$doc = \JFactory::getDocument();
$doc->addScriptDeclaration($js);
}
public static function loadScriptDeclarationInline($js) {
echo '<script>' . $js . '</script>';
}
public static function loadScript($file) {
$doc = \JFactory::getDocument();
$doc->addScript($file);
}
public static function loadScriptInline($file) {
echo '<script src="' . $file . '"></script>';
}
public static function loadStyleDeclaration($css) {
$doc = \JFactory::getDocument();
$doc->addStyleDeclaration($css);
}
public static function loadStyleDeclarationInline($css) {
echo '<style>' . $css . '</style>';
}
public static function loadStylesheet($file) {
$doc = \JFactory::getDocument();
$doc->addStylesheet($file);
}
public static function loadStylesheetInline($file) {
echo '<link href="' . $file . '"" rel="stylesheet" />';
}
}

View File

@@ -0,0 +1,215 @@
<?php
/**
* @name Mobile Menu CK
* @copyright Copyright (C) 2018. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author Cedric Keiflin - https://www.template-creator.com - https://www.joomlack.fr
*/
namespace Mobilemenuck;
// No direct access
defined('MOBILEMENUCK_LOADED') or die;
class Menu
{
/**
* Create the menu, call JS and CSS
*
* @return string the mobile menu ID
*
*/
public static function load($selector, $options = array(), $inline = false) {
require_once(MOBILEMENUCK_PLATFORM . '/loader.php');
require_once('Mobile_Detect.php');
// loads the language files
$lang = \JFactory::getLanguage();
$lang->load('plg_system_mobilemenuck', JPATH_SITE . '/plugins/system/mobilemenuck', $lang->getTag(), false);
$lang->load('plg_system_mobilemenuck', JPATH_ADMINISTRATOR, $lang->getTag(), false);
// create a unique ID for the menu
$menuid = 'mobilemenuck-' . (int) (microtime(true) * 100);
$defaults = self::getDefaultOptions();
$defaults['menuid'] = $menuid; // unique text identifier
$options = array_merge($defaults, $options);
// set the text for the menu bar
switch ($options['showmobilemenutext']) {
case 'none':
$options['mobilemenutext'] = '&nbsp;';
break;
case 'default':
default:
$options['mobilemenutext'] = \JText::_('PLG_MOBILEMENUCK_MENU');
break;
case 'custom':
$options['mobilemenutext'] = addslashes($options['mobilemenutext']);
break;
}
// B/C for old logo position option
if ((int)$options['showlogo'] > 0 && !isset($options['logo_where'])) {
$options['logo_where'] = array($options['showlogo']);
}
\JHTML::_("jquery.framework");
$file = MOBILEMENUCK_PLUGIN_MEDIA_URI . '/assets/mobilemenuck.js?ver=1.5.9';
$js = "jQuery(document).ready(function(){"
. " new MobileMenuCK(jQuery('" . $selector . "'), {";
foreach ($options as $name => $value) {
$js .= $name . " : '" . $value . "',";
}
$js .= "uriroot : '" . \JUri::root(true) . "'";
$js .= "});"
. " });";
$css = self::getMediaQueries($selector, $options);
if ($inline) {
CKLoader::loadScriptInline($file);
CKLoader::loadScriptDeclarationInline($js);
CKLoader::loadStyleDeclarationInline($css);
} else {
CKLoader::loadScript($file);
CKLoader::loadScriptDeclaration($js);
CKLoader::loadStyleDeclaration($css);
}
return $menuid;
}
public static function getDefaultOptions() {
$defaults = [
// 'menuid' => $menuid // unique text identifier
'menubarbuttoncontent' => '&#x2261;' // character to put in the button
,'topbarbuttoncontent' => '×' // character to put in the button
,'showmobilemenutext' => 'default' // default, custom, none
,'mobilemenutext' => \JText::_('PLG_MOBILEMENUCK_MENU') // text to use if showmobilemenutext = custom
,'container' => 'body' // body, topfixed, menu
,'detectiontype' => 'resolution' // resolution, phone, tablet
,'resolution' => '640' // value in px
,'usemodules' => '0' // 0, 1
,'useimages' => '0' // 0, 1
,'showlogo' => '1' // 0 (no), 1 (yes), 2 (in menu bar), 3 (in top bar)
,'showdesc' => '0' // 0, 1
,'displaytype' => 'accordion' // flat, accordion, fade, push
,'displayeffect' => 'normal' // normal, slideleft, slideright, slideleftover, sliderightover, topfixed, open
,'menuwidth' => '300' // value in px
,'openedonactiveitem' => '0' // 0, 1
,'mobilebackbuttontext' => \JText::_('PLG_MOBILEMENUCK_MOBILEBACKBUTTON') // text
,'menuselector' => 'ul' // text
,'uriroot' => \JUri::root(true) // base uri of the website
,'tooglebarevent' => 'click' // event used to open the menu
,'tooglebaron' => 'all' // target used to open the menu
// Logo options
,'logo_source' => 'maximenuck' // maximenuck, custom
,'logo_image' => '' // the image src
,'logo_link' => '' // the link url
,'logo_alt' => '' // the alt tag
,'logo_position' => 'left' // left, center, right
,'logo_width' => '' // image width
,'logo_height' => '' // image height
,'logo_margintop' => '' // margin top
,'logo_marginright' => '' // margin right
,'logo_marginbottom' => '' // margin bototm
,'logo_marginleft' => '' // margin left
,'topfixedeffect' => 'always' // always or onscroll
,'lock_button' => '0'
,'lock_forced' => '0'
,'accordion_use_effects' => '0'
,'accordion_toggle' => '0'
,'show_icons' => '1'
,'counter' => '0'
,'hide_desktop' => '1'
,'overlay' => '0'
];
return $defaults;
}
/**
* Search for the CSS styles from default theme, or in the template
*
* @return void
*
*/
public static function loadTheme($id, $inline = false, $themeid = null) {
require_once(MOBILEMENUCK_PLATFORM . '/loader.php');
$layoutcss = '';
if ((int) $themeid) {
$layoutcss = Helper::getStyleById($themeid, $select = 'layoutcss', $type = 'result');
}
// if we don't have a layout according to the ID, then use the default one
if (!(int) $themeid || ! $layoutcss){
$layoutcss = Helper::getLayoutCss();
}
Helper::makeCssReplacement($layoutcss);
$css = str_replace('|ID|', '[data-id="' . $id . '"]', $layoutcss);
if ($inline) {
CKLoader::loadStyleDeclarationInline($css);
} else {
CKLoader::loadStyleDeclaration($css);
}
}
/**
* Set the mediaqueries to hide - show the module and mobile bar
*
* @return string - the css to load in the page
*
*/
private static function getMediaQueries($selector, $options) {
$detect_type = $options['detectiontype'];
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$bodypadding = ($options['container'] == 'body' || $options['container'] == 'topfixed') ? 'body { padding-top: 40px !important; }' : '';
if ($detect_type == 'resolution') {
$css = "#" . $options['menuid'] . "-mobile-bar, #" . $options['menuid'] . "-mobile-bar-wrap-topfixed { display: none; }
@media only screen and (max-width:" . str_replace('px', '', $options['resolution']) . "px){
" . ($options['hide_desktop'] === '0' ? '' : $selector . " { display: none !important; }") . "
#" . $options['menuid'] . "-mobile-bar, #" . $options['menuid'] . "-mobile-bar-wrap-topfixed { display: block; }
.mobilemenuck-hide {display: none !important;}
" . $bodypadding . " }";
} else if (($detect_type == 'tablet' && $detect->isMobile()) || ($detect_type == 'phone' && $detect->isMobile() && !$detect->isTablet())) {
$css = $selector . " { display: none !important; }
#" . $options['menuid'] . "-mobile-bar, #" . $options['menuid'] . "-mobile-bar-wrap-topfixed { display: block; }
.mobilemenuck-hide {display: none !important;}
" . $bodypadding;
} else if ($detect_type == 'all') {
$css = "#" . $options['menuid'] . "-mobile-bar, #" . $options['menuid'] . "-mobile-bar-wrap-topfixed { display: block; }
" . $selector . " { display: none !important; }
.mobilemenuck-hide {display: none !important;}
" . $bodypadding;
} else {
$css = '';
}
return $css;
}
/**
* Determines what to use as character
*
* @return string - the html value
*
*/
static function getButtonContent($value, $styleParams) {
switch ($value) {
case 'hamburger':
$content = '&#x2261;';
break;
case 'close':
$content = '×';
break;
case 'custom' :
$content = $styleParams->menubarbuttoncontentcustomtext;
break;
default :
case 'none':
$content = '';
break;
}
return $content;
}
}