addMetasRelationshipToMenuElement(); $this->updateMegaMenuBlade(); $this->addFooterMenuSupport(); $this->addFooterMenuColorSettings(); $this->updateProfileMenu(); $this->addMobileHeaderForStaffLogin(); $this->addGJSPageRelationshipToMenuElement(); $this->addGJSPageSupportToMegaMenu(); } public static function addMetasRelationshipToMenuElement() { if (isModuleActive('Menu')) { $path = module_path('Menu', 'Entities/MenuElement.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/public function metas\(\) {[.\s\S]+?}/", $content)) { $matches = null; preg_match("/public function childs\(\){[.\s\S]+?}/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " public function metas() { return \$this->hasMany(Meta::class, 'element_id', 'id'); } "; $code .= $snippet; $content = preg_replace("/public function childs\(\){[.\s\S]+?}/", $code, $content); //file_put_contents($path, $content); $update = true; } } if (!preg_match("/use Modules\\\MenuPlus\\\Entities\\\Meta;/", $content)) { $matches = null; preg_match("/use Modules\\\Setup\\\Entities\\\Tag;/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " use Modules\MenuPlus\Entities\Meta; "; $code .= $snippet; $content = preg_replace("/use Modules\\\Setup\\\Entities\\\Tag;/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } } public function updateMegaMenuBlade() { $theme = app('theme'); if ($theme) { $theme_name = app('theme')->folder_path; $path = resource_path('views/frontend/amazy/partials/_mega_menu.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/MMSES/", $content)) { $content = preg_replace_callback('|
  • [.\s\S]+?<\/li>|', function ($matches) { $nli = preg_replace('/
  • /', "
  • getValue(\$element->id, 'hash') }}\" class=\"{{ app(\Modules\MenuPlus\Repositories\MetaRepository::class)->getValue(\$element->id, 'class') }}\">", $matches[0]); return " {{-- MMSES --}} @if (isModuleActive('MenuPlus')) @if (app(\Modules\MenuPlus\Services\CommonService::class)->isVisible(\$element)) ".$nli." @endif @else ".$matches[0]." @endif"; }, $content); file_put_contents($path, $content); } } } } public static function addFooterMenuColorSettings() { if (isModuleActive('Appearance')) { $path = module_path('Appearance', 'Resources/views/theme_color/index.blade.php'); if (file_exists($path)) { $content = file_get_contents($path); if (!preg_match("/@include\('menuplus::components\._footer_color_settings'\)/", $content)) { $matches = null; preg_match("/@error\('danger_color'\)[.\s\S]+?<\/div>[.\s\S]+?<\/div>/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('MenuPlus')) @include('menuplus::components._footer_color_settings') @endif "; $code .= $snippet; $content = preg_replace("/@error\('danger_color'\)[.\s\S]+?<\/div>[.\s\S]+?<\/div>/", $code, $content); file_put_contents($path, $content); } } } } } public function addFooterMenuSupport() { $path = resource_path('views/frontend/amazy/partials/_footer.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('menuplus::components\._footer_style'\)/", $content)) { $matches = null; preg_match("//", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('MenuPlus')) @include('menuplus::components._footer_style') @endif "; $code = $snippet.$code; $content = preg_replace("//", $code, $content); //file_put_contents($path, $content); $update = true; } } if (!preg_match("/@include\('menuplus::components\._footer_menu_1'\)/", $content)) { $matches = null; preg_match("/@foreach\(\\\$sectionWidgets->where\('section','1'\)[.\s\S]+?@endforeach/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (false) ".$code." @endif @if (isModuleActive('MenuPlus')) @include('menuplus::components._footer_menu_1') @endif "; $code = $snippet; $content = preg_replace("/@foreach\(\\\$sectionWidgets->where\('section','1'\)[.\s\S]+?@endforeach/", $code, $content); //file_put_contents($path, $content); $update = true; } } if (!preg_match("/@include\('menuplus::components\._footer_menu_2'\)/", $content)) { $matches = null; preg_match("/@foreach\(\\\$sectionWidgets->where\('section','2'\)[.\s\S]+?@endforeach/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (false) ".$code." @endif @if (isModuleActive('MenuPlus')) @include('menuplus::components._footer_menu_2') @endif "; $code = $snippet; $content = preg_replace("/@foreach\(\\\$sectionWidgets->where\('section','2'\)[.\s\S]+?@endforeach/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function updateProfileMenu() { $path = resource_path('views/backEnd/partials/_menu.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@if \(isModuleActive\('MenuPlus'\)\)/", $content)) { $matches = null; preg_match('/
    /', $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('MenuPlus')) @include('menuplus::components._profile_menu') @endif "; $code .= $snippet; $content = preg_replace('/
    /', $code, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public function addMobileHeaderForStaffLogin() { $path = resource_path('views/frontend/amazy/partials/_header.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/@include\('menuplus::components\._top_mobile_menu'\)/", $content)) { $matches = null; preg_match("//", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @if (isModuleActive('MenuPlus')) @include('menuplus::components._top_mobile_menu') @endif "; $code .= $snippet; $content = preg_replace("//", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } public static function addGJSPageRelationshipToMenuElement() { if (isModuleActive('Menu')) { $path = module_path('Menu', 'Entities/MenuElement.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/public function gjspage\(\) {[.\s\S]+?}/", $content)) { $matches = null; preg_match("/public function childs\(\){[.\s\S]+?}/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " public function gjspage() { return \$this->belongsTo(\Modules\PageBuilderPlus\Entities\GJSPage::class, 'element_id', 'id'); } "; $code .= $snippet; $content = preg_replace("/public function childs\(\){[.\s\S]+?}/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } } public function addGJSPageSupportToMegaMenu() { $path = resource_path('views/frontend/amazy/partials/_mega_menu.blade.php'); if (file_exists($path)) { $update = false; $content = file_get_contents($path); if (!preg_match("/\\\$element->type == 'gjspage'/", $content)) { $matches = null; preg_match("/@elseif\(\\\$element->type == 'category'\)/", $content, $matches); if (count($matches) > 0) { $code = $matches[0]; $snippet = " @elseif (\$element->type == 'gjspage') @if (isModuleActive('PageBuilderPlus') && isModuleActive('MenuPlus')) @if (app(\Modules\MenuPlus\Services\CommonService::class)->isVisible(\$element))
  • getValue(\$element->id, 'hash') }}\" class=\"{{ app(\Modules\MenuPlus\Repositories\MetaRepository::class)->getValue(\$element->id, 'class') }}\"> gjspage->slug) }}\" target=\"{{\$element->is_newtab == 1?'_blank':''}}\">{{ ucfirst(textLimit(\$element->title, 20)) }}
  • @endif @endif "; $code = $snippet.$code; $content = preg_replace("/@elseif\(\\\$element->type == 'category'\)/", $code, $content); //file_put_contents($path, $content); $update = true; } } if ($update) { file_put_contents($path, $content); } } } }