- Created separate MoneyFlix project directory - Copied Node.js redirector from production server - Added CRM PHP code (Redirects module, Core classes, Config, Routes, Views) - Created comprehensive documentation (README_MONEYFLIX.md) - Added sync script to keep CRM code updated (sync-from-crm.sh) - Configured .gitignore for Node.js and PHP - Set up proper project structure for multi-client isolation This separates MoneyFlix from the main CRM to avoid confusion between different client systems and provides a dedicated environment for MoneyFlix-specific development and maintenance.
41 lines
2.0 KiB
PHP
41 lines
2.0 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Core;
|
|
|
|
class MenuRenderer
|
|
{
|
|
/**
|
|
* Renderiza um menu dinâmico (estrutura recursiva).
|
|
* @param array $menu Estrutura do menu.
|
|
* @param string $currentUrl URL atual para marcar ativo.
|
|
* @param bool $editMode Ativa atributos de edição/drag.
|
|
*/
|
|
public static function render(array $menu, string $currentUrl, bool $editMode = false): void
|
|
{
|
|
foreach ($menu as $item) {
|
|
$isActive = ($item['url'] === $currentUrl) || (!empty($item['children']) && array_reduce($item['children'], function($carry, $child) use ($currentUrl) { return $carry || ($child['url'] === $currentUrl); }, false));
|
|
$hasChildren = !empty($item['children']);
|
|
$dragAttr = $editMode ? ' draggable="true" data-menu-id="'.$item['id'].'"' : '';
|
|
echo '<li class="nav-item"'.$dragAttr.'>';
|
|
echo '<a class="nav-link menu-link'.($isActive ? ' active' : '').($hasChildren ? ' with-submenu' : '').'" href="'.htmlspecialchars($item['url']).'">';
|
|
echo '<i class="'.$item['icon'].'"></i> <span>'.htmlspecialchars($item['label']).'</span>';
|
|
if ($hasChildren) echo ' <span class="menu-arrow"></span>';
|
|
echo '</a>';
|
|
if ($hasChildren) {
|
|
echo '<ul class="nav nav-sm flex-column submenu'.($isActive ? ' show' : '').'">';
|
|
foreach ($item['children'] as $child) {
|
|
$childActive = ($child['url'] === $currentUrl);
|
|
$childDrag = $editMode ? ' draggable="true" data-menu-id="'.$child['id'].'"' : '';
|
|
echo '<li class="nav-item"'.$childDrag.'>';
|
|
echo '<a class="nav-link'.($childActive ? ' active' : '').'" href="'.htmlspecialchars($child['url']).'">';
|
|
echo '<i class="'.$child['icon'].'"></i> <span>'.htmlspecialchars($child['label']).'</span>';
|
|
echo '</a>';
|
|
echo '</li>';
|
|
}
|
|
echo '</ul>';
|
|
}
|
|
echo '</li>';
|
|
}
|
|
}
|
|
}
|