From 21cbe59b55a68668dc3ad0801183e35d720efc2c Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Sat, 5 Sep 2026 16:01:33 +0200 Subject: [PATCH] Expose customer QR upload as top-level frontend menu item --- include/customer_qr_frontend_menu.inc.php | 105 ++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 include/customer_qr_frontend_menu.inc.php diff --git a/include/customer_qr_frontend_menu.inc.php b/include/customer_qr_frontend_menu.inc.php new file mode 100644 index 0000000..cc5aa08 --- /dev/null +++ b/include/customer_qr_frontend_menu.inc.php @@ -0,0 +1,105 @@ +get_id() !== 'menubar' || !method_exists($menu, 'register_block')) + { + return; + } + + if (!class_exists('RegisteredBlock')) + { + return; + } + + $menu->register_block(new RegisteredBlock( + 'mbBratonienCustomerQr', + 'QR-Code hochladen', + BRATONIEN_TOOLS_ID + )); +} + +function bratonien_tools_customer_qr_prepare_frontend_menu($menu_ref_array) +{ + if (defined('IN_ADMIN')) + { + return; + } + + $settings = bratonien_tools_customer_qr_settings(); + if (empty($settings['enabled'])) + { + return; + } + + if (!is_array($menu_ref_array) || empty($menu_ref_array[0]) || !is_object($menu_ref_array[0])) + { + return; + } + + $menu = $menu_ref_array[0]; + if (!method_exists($menu, 'get_id') || $menu->get_id() !== 'menubar') + { + return; + } + + $block = $menu->get_block('mbBratonienCustomerQr'); + if ($block === null) + { + return; + } + + $url = htmlspecialchars( + get_root_url().'plugins/'.BRATONIEN_TOOLS_ID.'/customer-qr-upload.php', + ENT_QUOTES, + 'UTF-8' + ); + + // Bootstrap Darkroom renders raw-content blocks directly in the root navbar. + // Keeping this as a separate Piwigo menu block avoids hiding the customer + // action inside mbMenu/"Entdecken" and still follows the normal menubar + // lifecycle instead of modifying the theme. + $block->raw_content = ''; + + if (method_exists($menu, 'set_block_position')) + { + // Core defaults: Specials=200, Menu=250. Darkroom combines those two as + // "Entdecken"; 225 therefore places QR upload directly after it. + $menu->set_block_position('mbBratonienCustomerQr', 225); + } +} + +add_event_handler( + 'blockmanager_register_blocks', + 'bratonien_tools_customer_qr_register_frontend_menu', + EVENT_HANDLER_PRIORITY_NEUTRAL + 10 +); +add_event_handler( + 'blockmanager_prepare_display', + 'bratonien_tools_customer_qr_prepare_frontend_menu', + EVENT_HANDLER_PRIORITY_NEUTRAL + 10 +);