<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Session BaÅŸlat
session_start();

// Config ve Database
require_once '../config/database.php';
require_once '../app/Core/Database.php';
require_once '../app/Core/Controller.php';
require_once '../app/Core/Router.php';

$router = new Router();

// --- 1. ADMIN GENEL ROTALARI ---
$router->add('admin/login', 'AdminController', 'login');
$router->add('admin/dashboard', 'AdminController', 'dashboard');
$router->add('admin/properties', 'AdminController', 'properties');
$router->add('admin/projects', 'AdminController', 'projects');
$router->add('admin/messages', 'AdminController', 'messages');
$router->add('admin/message-update/{id}', 'AdminController', 'message_update');
$router->add('admin/users', 'AdminController', 'users');
$router->add('admin/user-add', 'AdminController', 'user_add');     // DanÄ±ÅŸman ekleme
$router->add('admin/user-delete/{id}', 'AdminController', 'user_delete'); // DanÄ±ÅŸman silme
$router->add('admin/settings', 'AdminController', 'settings');
$router->add('admin/profile', 'AdminController', 'profile');
$router->add('admin/logout', 'AdminController', 'logout');

// --- 2. KATEGORÄ° YÃ–NETÄ°MÄ° (YENÄ° EKLENDÄ°) ---
$router->add('admin/categories', 'AdminController', 'categories');
$router->add('admin/category_add', 'AdminController', 'category_add');
$router->add('admin/category_delete/{id}', 'AdminController', 'category_delete');

// --- 3. PROJE Ä°ÅLEMLERÄ° ---
$router->add('admin/project-add', 'AdminController', 'project_add');
$router->add('admin/project-save', 'AdminController', 'project_save');
$router->add('admin/project-edit-save/{id}', 'AdminController', 'project_edit_save'); // Kaydetme rotasÄ±
$router->add('admin/project-edit/{id}', 'AdminController', 'project_edit');
$router->add('admin/project-delete/{id}', 'AdminController', 'project_delete');

// --- 4. Ä°LAN Ä°ÅLEMLERÄ° ---
$router->add('admin/property-add', 'AdminController', 'property_add');
$router->add('admin/property-save', 'AdminController', 'property_save');
$router->add('admin/property-edit/{id}', 'AdminController', 'property_edit');
$router->add('admin/property-delete/{id}', 'AdminController', 'property_delete');
$router->add('admin/property-approve/{id}', 'AdminController', 'property_approve');
$router->add('admin/property-reject/{id}', 'AdminController', 'property_reject');
$router->add('admin/property-import', 'AdminController', 'property_import');
$router->add('admin/property-import-save', 'AdminController', 'property_import_save');
$router->add('admin/image-delete/{img_id}/{prop_id}', 'AdminController', 'image_delete');

// --- 5. Ã–N YÃœZ (FRONT) ROTALARI ---

// Anasayfa
$router->add('', 'HomeController', 'index'); 

// Ä°lanlar (Ã–NEMLÄ°: Detay rotasÄ±, genel listeden Ã–NCE olmalÄ±)
$router->add('properties/detail', 'PropertiesController', 'detail'); // Detay
$router->add('properties', 'PropertiesController', 'index');         // Liste

// Projeler (AynÄ± mantÄ±k: Detay varsa Ã¼ste)
$router->add('projects/detail', 'ProjectsController', 'detail'); // EÄŸer varsa
$router->add('projects', 'ProjectsController', 'index');

// Ä°letiÅŸim
$router->add('contact', 'ContactController', 'index');
$router->add('contact/send', 'ContactController', 'send'); // Form gÃ¶nderme
$router->add('message/send', 'MessageController', 'send'); // Ä°lan detaydan mesaj

// Favori / KarÅŸÄ±laÅŸtÄ±rma
$router->add('favorites', 'EngagementController', 'favorites');
$router->add('favorites/toggle/{id}', 'EngagementController', 'toggleFavorite');
$router->add('favorites/clear', 'EngagementController', 'clearFavorites');
$router->add('compare', 'EngagementController', 'compare');
$router->add('compare/toggle/{id}', 'EngagementController', 'toggleCompare');
$router->add('compare/clear', 'EngagementController', 'clearCompare');

// --- SÄ°STEMÄ° BAÅLAT ---
$router->dispatch();

