<?php
/**
 * File: nikisaz-admin-header.php
 * Description: ساختار هدر و منوی ادمین برای افزونه نیکی‌ساز
 */

// آدرس فایل اصلی افزونه برای خواندن متا (نام فایل ممکن است متفاوت باشد، معمولاً نام فایل اصلی افزونه است)
// فرض بر این است که نام فایل اصلی افزونه 'nikisaz-webapp-generator.php' است.
$plugin_file = WP_PLUGIN_DIR . '/nikisaz-webapp-generator/nikisaz-webapp-generator.php';

// اگر نام فایل اصلی متفاوت است، خط بالا را اصلاح کنید.
if (!file_exists($plugin_file)) {
    // تلاش برای یافتن فایل در صورت تغییر نام پوشه
    $plugin_file = WP_PLUGIN_DIR . '/nikisaz-webapp-generator.php';
}
?>

<div class="hdwebapp-body">
    <header class="hdwebapp-Header">
        <div class="hdwebapp-Header-logo">
            <!-- لوگوی نیکی‌ساز (آدرس لوگوی واقعی را اینجا قرار دهید) -->
            <img src="https://nikisaz.com/img/logo.svg" width="163"
                 height="44" alt="NikiSaz Logo" class="hdwebapp-Header-logo-desktop">
            <img src="https://nikisaz.com/img/logo.svg" width="28"
                 height="50" alt="NikiSaz Logo" class="hdwebapp-Header-logo-mobile">
            <div>
                <p class="desktop"> NikiSaz</p>
                <p class="mobile" > NS</p>
            </div>
        </div>
        
        <nav class="hdwebapp-Header-nav">
            <!-- ساختن اپلیکیشن -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-create-app') ?>" 
               id="hdwebapp-nav-dashboard" 
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-create-app") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'Create an Application', 'nikisaz-webapp-generator' ); ?></div>
            </a>

            <!-- لیست اپلیکیشن‌ها -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-app-list') ?>"  
               id="hdwebapp-phone_android" 
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-app-list") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'Applications List', 'nikisaz-webapp-generator' ); ?></div>
            </a>

            <!-- یادگیری -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-learnings') ?>"  
               id="hdwebapp-bullhorn" 
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-learnings") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'Learnings', 'nikisaz-webapp-generator' ); ?></div>
            </a>

            <!-- PWA -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-pwa') ?>" 
               id="hdwebapp-ios"  
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-pwa") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'PWA', 'nikisaz-webapp-generator' ); ?></div>
            </a>

            <!-- تب‌های موبایل -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-mobile-tabs') ?>" 
               id="hdwebapp-tabs" 
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-mobile-tabs") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'Mobile Tabs', 'nikisaz-webapp-generator' ); ?></div>
            </a>

            <!-- اینترو اپلیکیشن -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-app-intro') ?>" 
               id="hdwebapp-intro" 
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-app-intro") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'Mobile App Intro', 'nikisaz-webapp-generator' ); ?></div>
            </a>

            <!-- اپلیکیشن‌های نصب شده -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-installed-apps') ?>" 
               id="hdwebapp-installed-app" 
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-installed-apps") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'Installed Apps', 'nikisaz-webapp-generator' ); ?></div>
            </a>

            <!-- تنظیمات -->
            <a href="<?php echo admin_url('admin.php?page=nikisaz-settings') ?>" 
               id="hdwebapp-setting" 
               class="hdwebapp-menuItem <?php if(isset($_REQUEST["page"]) && $_REQUEST["page"]=="nikisaz-settings") echo 'isActive'; ?>">
                <div class="hdwebapp-menuItem-title"><?php _e( 'Settings', 'nikisaz-webapp-generator' ); ?></div>
            </a>
        </nav>

        <div class="hdwebapp-Header-footer">
            <?php 
                $plugin_data = get_plugin_data($plugin_file);
                echo esc_html__('App Version', 'nikisaz-webapp-generator') . " " . $plugin_data["Version"]; 
            ?>
        </div>
    </header>

    <section class="hdwebapp-Content">
        <?php
            // بررسی صفحه فعلی و فراخوانی فایل مربوطه
            $current_page = isset($_REQUEST["page"]) ? $_REQUEST["page"] : '';
            
            switch ($current_page){
                case "nikisaz-create-app":
                    include __DIR__ . "/create-app.php";
                    break;
                case "nikisaz-app-list":
                    include __DIR__ . "/application-list.php";
                    break;
                case "nikisaz-create-notification":
                    include __DIR__ . "/create-notification.php";
                    break;
                case "nikisaz-learnings":
                    include __DIR__ . "/push-help.php";
                    break;
                case "nikisaz-notification-list":
                    include __DIR__ . "/notification-list.php";
                    break;
                case "nikisaz-settings":
                    include __DIR__ . "/settings.php";
                    break;
                case "nikisaz-mobile-tabs":
                    include __DIR__ . "/mobile-tabs.php";
                    break;
                case "nikisaz-app-intro":
                    include __DIR__ . "/app-intro.php";
                    break;
                case "nikisaz-pwa":
                    include __DIR__ . "/pwa.php";
                    break;
                case "nikisaz-installed-apps":
                    include __DIR__ . "/installed-apps.php";
                    break;
                default:
                    // صفحه پیش‌فرض اگر صفحه‌ای انتخاب نشده باشد
                    if(!file_exists(__DIR__ . "/create-app.php")) {
                        echo '<p>' . __('No page selected or file not found.', 'nikisaz-webapp-generator') . '</p>';
                    } else {
                        include __DIR__ . "/create-app.php";
                    }
                    break;
            }
        ?>
    </section>

    <aside class="hdwebapp-Sidebar" style="display: block;">
        <?php if(isset($_REQUEST["errors"])){ ?>
            <div class="hdwebapp-Sidebar-warning">
                <i class="hdwebapp-icon-information2"></i>
                <h4><?php echo esc_html($_REQUEST["errors"]); ?></h4>
            </div>
        <?php } ?>
        <?php if(isset($_REQUEST["messages"])){ ?>
            <div class="hdwebapp-Sidebar-info">
                <i class="hdwebapp-icon-information2"></i>
                <h4><?php echo esc_html($_REQUEST["messages"]); ?></h4>
            </div>
        <?php } ?>
    </aside>
</div>