isClient('site') && ! $app->isClient('administrator'))
{
return false;
}
if ($app->isClient('cli'))
{
return false;
}
if ($app->isClient('api'))
{
return false;
}
$doc = JFactory::getDocument();
$doctype = $doc->getType();
// $document = \Joomla\CMS\Factory::getApplication()->getDocument();
if ($doctype !== 'html')
{
return false;
}
return true;
}
public function onContentPrepareForm($form, $data) {
if (! $this->shallLoad()) return;
$this->callLibraries();
if (
($form->getName() != 'com_modules.module' && $form->getName() != 'com_advancedmodules.module'
|| (($form->getName() == 'com_modules.module' || $form->getName() == 'com_advancedmodules.module') && $data && isset($data->module) && $data->module != 'mod_maximenuck' && $data->module != 'mod_accordeonck' && $data->module != 'mod_accordeonmenuck' && $data->module != 'mod_menu')
)
&& ($form->getName() != 'com_menus.item' && $form->getName() != 'com_menumanagerck.itemedition')
)
return;
JForm::addFormPath(MOBILEMENUCK_PATH .'/params');
JForm::addFieldPath(MOBILEMENUCK_PATH . '/elements');
// get the language
$this->loadLanguage();
// load the additional options in the module
if ($form->getName() == 'com_modules.module' || $form->getName() == 'com_advancedmodules.module') {
$form->loadFile('mobilemenuck_params', false);
}
// menu item options
if ($form->getName() == 'com_menus.item' || $form->getName() == 'com_menumanagerck.itemedition') {
$form->loadFile('mobilemenuck_itemparams', false);
}
}
/**
* Event launched when the module is rendered in the page
*
* @param object The module element.
* @param array The attributes to render the module.
* @return void
*/
public function onRenderModule($module, &$attribs) {
if (! $this->shallLoad()) return;
$app = JFactory::getApplication();
$input = $app->input;
if ($app->isClient('administrator')) {
return;
}
// exit if we are in one of these cases
if ($input->get('option', '', 'string') == 'com_modulesmanagerck'
|| $input->get('option', '', 'string') == 'com_media'
|| $input->get('format', '', 'string') == 'raw'
|| $input->get('option', '', 'string') == 'com_config'
|| $input->get('ck', '', 'string') === '1'
) {
return;
}
// $loadAssets = false;
$moduleParams = new JRegistry($module->params);
// find a module enabled for mobile
if ($moduleParams->get('mobilemenuck_enable', 0, 'int')) {
$attribs['style'] .= ' mobilemenuck';
// $loadAssets = true;
if (!empty ($module->content)) {
include_once(dirname(__FILE__) . '/defines.php');
include_once(dirname(__FILE__) . '/helpers/helper.php');
include_once(dirname(__FILE__) . '/helpers/menu.php');
include_once(dirname(__FILE__) . '/helpers/function.php');
$id = \Mobilemenuck\Helper::createIdForModule($module);
if ($module->module == 'mod_maximenuck') {
$selector = '#' . $id;
$menuselector = 'ul.maximenuck';
} else if ($module->module == 'mod_accordeonmenuck') {
$selector = '#' . $id . '-wrap';
$html = '
' . $module->content . '
';
$module->content = $html;
$menuselector = 'ul.menu';
} else {
if (version_compare(JVERSION, '4') >= 0) {
$selector = '#' . $id . '-wrap ul.nav';
} else {
$selector = '#' . $id . '-wrap ul.nav';
}
$html = '
' . $module->content . '
';
$module->content = $html;
$menuselector = 'ul';
}
$styleid = $moduleParams->get('mobilemenuck_styles');
$menubarbuttoncontent = '≡';
$topbarbuttoncontent = '×';
if ($styleid) {
$styleParams = json_decode(\Mobilemenuck\Helper::getStyleById($styleid, 'a.params'));
if (! isset($styleParams->menubarbuttoncontent)) $styleParams->menubarbuttoncontent = 'hamburger';
if (! isset($styleParams->topbarbuttoncontent)) $styleParams->topbarbuttoncontent = JText::_('JCLOSE');
$menubarbuttoncontent = \Mobilemenuck\Menu::getButtonContent($styleParams->menubarbuttoncontent, $styleParams);
$topbarbuttoncontent = \Mobilemenuck\Menu::getButtonContent($styleParams->topbarbuttoncontent, $styleParams);
}
// 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);
$merge = $moduleParams->get('mobilemenuck_merge', '');
$mergeorder = $moduleParams->get('mobilemenuck_mergeorder', '');
if ($merge) {
$mergemodule = \Mobilemenuck\Helper::getModuleById($merge);
$merge = \Mobilemenuck\Helper::createIdForModule($mergemodule);
}
// manage the general options
$options = array(
'menuid' => $id
,'menubarbuttoncontent' => $menubarbuttoncontent
,'topbarbuttoncontent' => $topbarbuttoncontent
,'showmobilemenutext' => $moduleParams->get('mobilemenuck_showmobilemenutext', 'default')
,'mobilemenutext' => JText::_($moduleParams->get('mobilemenuck_mobilemenutext', 'PLG_MOBILEMENUCK_MENU'))
,'container' => $moduleParams->get('mobilemenuck_container', 'body')
,'detectiontype' => $moduleParams->get('mobilemenuck_detectiontype', 'resolution')
,'resolution' => $moduleParams->get('mobilemenuck_resolution', '640')
,'usemodules' => $moduleParams->get('mobilemenuck_usemodules', '0')
,'useimages' => $moduleParams->get('mobilemenuck_useimages', '0')
,'showlogo' => $moduleParams->get('mobilemenuck_showlogo', '1')
,'showdesc' => $moduleParams->get('mobilemenuck_showdesc', '0')
,'displaytype' => $moduleParams->get('mobilemenuck_displaytype', 'accordion')
,'displayeffect' => $moduleParams->get('mobilemenuck_displayeffect', 'normal')
,'menuwidth' => $moduleParams->get('mobilemenuck_menuwidth', '300')
,'openedonactiveitem' => $moduleParams->get('mobilemenuck_openedonactiveitem', '0')
,'mobilebackbuttontext' => JText::_($moduleParams->get('mobilemenuck_mobilebackbuttontext', 'PLG_MOBILEMENUCK_MOBILEBACKBUTTON'))
,'menuselector' => $menuselector
,'merge' => $merge
,'beforetext' => addslashes($moduleParams->get('mobilemenuck_beforetext', ''))
,'aftertext' => addslashes($moduleParams->get('mobilemenuck_aftertext', ''))
,'mergeorder' => $mergeorder
,'tooglebarevent' => $moduleParams->get('mobilemenuck_tooglebarevent', 'click')
,'tooglebaron' => $moduleParams->get('mobilemenuck_tooglebaron', 'all')
// Logo options
,'logo_where' => implode(',', $moduleParams->get('mobilemenuck_logo_where', array(0 => '1'))) // 1, 2, 3
,'logo_source' => $moduleParams->get('mobilemenuck_logo_source', 'maximenuck') // maximenuck, custom
,'logo_image' => $moduleParams->get('mobilemenuck_logoimage', '') // the image src
,'logo_link' => $moduleParams->get('mobilemenuck_logolink', '') // the link url
,'logo_alt' => $moduleParams->get('mobilemenuck_logoalt', '') // the alt tag
,'logo_position' => $moduleParams->get('mobilemenuck_logoposition', 'left') // left, center, right
,'logo_width' => $moduleParams->get('mobilemenuck_logowidth', '') // image width
,'logo_height' => $moduleParams->get('mobilemenuck_logoheight', '') // image height
,'logo_margintop' => $moduleParams->get('mobilemenuck_logomargintop', '') // margin top
,'logo_marginright' => $moduleParams->get('mobilemenuck_logomarginright', '') // margin right
,'logo_marginbottom' => $moduleParams->get('mobilemenuck_logomarginbottom', '') // margin bototm
,'logo_marginleft' => $moduleParams->get('mobilemenuck_logomarginleft', '') // margin left
,'lock_button' => $moduleParams->get('mobilemenuck_lock_button', '0')
,'lock_forced' => $moduleParams->get('mobilemenuck_lock_forced', '0')
,'topfixedeffect' => $moduleParams->get('mobilemenuck_topfixedeffect', 'always')
,'accordion_use_effects' => $moduleParams->get('mobilemenuck_accordion_use_effects', '0')
,'accordion_toggle' => $moduleParams->get('mobilemenuck_accordion_toggle', '0')
,'show_icons' => $moduleParams->get('mobilemenuck_show_icons', '1')
,'counter' => $moduleParams->get('mobilemenuck_counter', '0')
,'hide_desktop' => $moduleParams->get('mobilemenuck_hide_desktop', '1')
,'overlay' => $moduleParams->get('mobilemenuck_overlay', '0')
);
// manage logo options
$logoOptions = array();
if ($moduleParams->get('mobilemenuck_logo_source', 'maximenuck') == 'custom') {
$logoOptions = array(
'logoimage' => $moduleParams->get('mobilemenuck_logoimage', '')
// , 'container' => $moduleParams->get('mobilemenuck_container', 'body')
);
}
$options = array_merge($options, $logoOptions);
loadMobileMenuCK($selector,
$options
);
} else {
return;
}
}
}
public function onAfterRender() {
if (! $this->shallLoad()) return;
// exit if in admin
if (! JFactory::getApplication()->isClient('site')) return;
// get the page body
if (version_compare(JVERSION, '4') >= 0) {
$body = JFactory::getApplication()->getBody();
} else {
$body = JResponse::getBody();
}
$html = '';
if (! empty($this->modulesbar)) {
$html .= '';
}
if (! empty($this->modulestop)) {
$html .= '';
}
if (! empty($this->modulesbottom)) {
$html .= '';
}
if ($html) {
// add the html code
$body = str_replace("