فهرست منبع

Merge branch 'master' of http://192.168.0.152:12300/svalavuo/website

svalavuo 6 روز پیش
والد
کامیت
dd9508d8fe
5فایلهای تغییر یافته به همراه0 افزوده شده و 290 حذف شده
  1. 0 39
      test_language.php
  2. 0 65
      test_language_logic.php
  3. 0 46
      test_language_switching.php
  4. 0 22
      test_switcher.php
  5. 0 118
      test_wysiwyg.html

+ 0 - 39
test_language.php

@@ -1,39 +0,0 @@
-<?php
-// Start session
-session_start();
-
-require_once 'includes/config.php';
-require_once 'includes/translation.php';
-
-// Simulate different scenarios
-echo "=== Testing Language Switching ===\n\n";
-
-// Test 1: Default language (no session, no GET param)
-$_SESSION = array(); // Clear session
-$_GET = array(); // Clear GET params
-
-$translation = Translation::getInstance();
-echo "Test 1 - Default: " . $translation->getCurrentLanguage() . "\n";
-echo "Session language: " . ($_SESSION['language'] ?? 'not set') . "\n\n";
-
-// Test 2: Language parameter in URL
-$_GET['lang'] = 'fi';
-$translation = Translation::getInstance(); // Fresh instance
-echo "Test 2 - With GET lang=fi: " . $translation->getCurrentLanguage() . "\n";
-echo "Session language: " . ($_SESSION['language'] ?? 'not set') . "\n\n";
-
-// Test 3: Session persistence
-$_GET = array(); // Clear GET params
-$translation = Translation::getInstance(); // Fresh instance
-echo "Test 3 - Session persistence: " . $translation->getCurrentLanguage() . "\n";
-echo "Session language: " . ($_SESSION['language'] ?? 'not set') . "\n\n";
-
-// Test 4: Test translation
-echo "Test 4 - Translation test:\n";
-echo "English 'nav_home': " . $translation->translate('nav_home') . "\n";
-echo "Finnish 'nav_home': " . $translation->translate('nav_home') . "\n\n";
-
-// Test 5: Language switcher
-echo "Test 5 - Language switcher HTML:\n";
-echo $translation->getLanguageSwitcher('test.php') . "\n";
-?>

+ 0 - 65
test_language_logic.php

@@ -1,65 +0,0 @@
-<?php
-// Test language switching logic without redirects
-session_start();
-require_once 'includes/config.php';
-
-echo "=== Testing Language Switching Logic ===\n\n";
-
-// Test URL parsing logic directly
-function testUrlParsing($testUrl) {
-    echo "Testing URL: $testUrl\n";
-    
-    $parsedUrl = parse_url($testUrl);
-    $redirectUrl = $parsedUrl['path'];
-    
-    if (isset($parsedUrl['query'])) {
-        parse_str($parsedUrl['query'], $queryParams);
-        unset($queryParams['lang']); // Remove lang parameter
-        
-        if (!empty($queryParams)) {
-            $redirectUrl .= '?' . http_build_query($queryParams);
-        }
-    }
-    
-    echo "Parsed redirect URL: $redirectUrl\n\n";
-    return $redirectUrl;
-}
-
-// Test various URL scenarios
-$testUrls = [
-    '/index.php?lang=fi&category=test',
-    '/index.php?category=test&lang=fi',
-    '/index.php?lang=fi',
-    '/index.php?category=test&page=2',
-    '/index.php'
-];
-
-foreach ($testUrls as $url) {
-    testUrlParsing($url);
-}
-
-// Test session handling
-echo "=== Testing Session Handling ===\n";
-
-// Simulate language setting
-$_SESSION['language'] = 'fi';
-echo "Session language set to: " . $_SESSION['language'] . "\n";
-
-// Test translation initialization
-try {
-    require_once 'includes/translation.php';
-    
-    // Clear GET to avoid redirect
-    $_GET = array();
-    
-    $translation = Translation::getInstance();
-    echo "Translation instance created successfully\n";
-    echo "Current language: " . $translation->getCurrentLanguage() . "\n";
-    echo "Supported languages: " . implode(', ', array_keys($translation->getSupportedLanguages())) . "\n";
-    
-} catch (Exception $e) {
-    echo "Error: " . $e->getMessage() . "\n";
-}
-
-echo "\n=== Language Switching Logic Test Complete ===\n";
-?>

+ 0 - 46
test_language_switching.php

@@ -1,46 +0,0 @@
-<?php
-// Start session
-session_start();
-
-require_once 'includes/config.php';
-require_once 'includes/translation.php';
-
-echo "=== Testing Language Switching Fix ===\n\n";
-
-// Test 1: Simulate URL with lang parameter
-$_GET['lang'] = 'fi';
-$_SERVER['REQUEST_URI'] = '/index.php?lang=fi&category=test';
-
-echo "Test 1 - URL with lang parameter: $_SERVER[REQUEST_URI]\n";
-
-try {
-    $translation = Translation::getInstance();
-    echo "Current language after lang parameter: " . $translation->getCurrentLanguage() . "\n";
-    echo "Session language: " . ($_SESSION['language'] ?? 'not set') . "\n";
-    echo "SUCCESS: Language switching works!\n\n";
-} catch (Exception $e) {
-    echo "ERROR: " . $e->getMessage() . "\n\n";
-}
-
-// Test 2: Simulate URL without lang parameter (should use session)
-$_GET = array(); // Clear GET params
-$_SERVER['REQUEST_URI'] = '/index.php?category=test';
-
-echo "Test 2 - URL without lang parameter: $_SERVER[REQUEST_URI]\n";
-
-try {
-    $translation = Translation::getInstance();
-    echo "Current language from session: " . $translation->getCurrentLanguage() . "\n";
-    echo "Session language: " . ($_SESSION['language'] ?? 'not set') . "\n";
-    echo "SUCCESS: Session persistence works!\n\n";
-} catch (Exception $e) {
-    echo "ERROR: " . $e->getMessage() . "\n\n";
-}
-
-// Test 3: Test language switcher generation
-echo "Test 3 - Language switcher generation:\n";
-$switcherHtml = $translation->getLanguageSwitcher('index.php?category=test');
-echo "Language switcher HTML:\n$switcherHtml\n\n";
-
-echo "=== All Tests Completed ===\n";
-?>

+ 0 - 22
test_switcher.php

@@ -1,22 +0,0 @@
-<?php
-session_start();
-require_once 'includes/config.php';
-require_once 'includes/translation.php';
-
-$translation = Translation::getInstance();
-
-echo "Current language: " . $translation->getCurrentLanguage() . "\n";
-echo "Supported languages: " . implode(', ', array_keys($translation->getSupportedLanguages())) . "\n\n";
-
-echo "Language switcher HTML:\n";
-echo $translation->getLanguageSwitcher('test.php') . "\n\n";
-
-// Test URL generation
-echo "Testing URL generation:\n";
-foreach (['en', 'fi'] as $lang) {
-    $url = 'test.php';
-    $separator = strpos($url, '?') !== false ? '&' : '?';
-    $switcherUrl = $url . $separator . 'lang=' . $lang;
-    echo "Language $lang: $switcherUrl\n";
-}
-?>

+ 0 - 118
test_wysiwyg.html

@@ -1,118 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>WYSIWYG Editor Test</title>
-    <link rel="stylesheet" href="css/wysiwyg.css">
-    <style>
-        body {
-            font-family: Arial, sans-serif;
-            max-width: 800px;
-            margin: 0 auto;
-            padding: 20px;
-        }
-        .test-form {
-            margin-top: 20px;
-        }
-        .btn {
-            padding: 10px 20px;
-            border: none;
-            border-radius: 4px;
-            cursor: pointer;
-            margin: 5px;
-        }
-        .btn-primary {
-            background-color: #3b82f6;
-            color: white;
-        }
-        .btn-secondary {
-            background-color: #6b7280;
-            color: white;
-        }
-        .output {
-            margin-top: 20px;
-            padding: 15px;
-            border: 1px solid #d1d5db;
-            border-radius: 4px;
-            background-color: #f9fafb;
-        }
-    </style>
-</head>
-<body>
-    <h1>WYSIWYG Editor Test</h1>
-    
-    <form class="test-form" id="testForm">
-        <div class="form-group">
-            <label for="title">Title:</label>
-            <input type="text" id="title" name="title" value="Test Publication">
-        </div>
-        
-        <div class="form-group">
-            <label for="content" class="wysiwyg-label">Content:</label>
-            <textarea id="content" name="content" rows="20" style="display: none;">
-                <h2>Welcome to the WYSIWYG Editor</h2>
-                <p>This is a <strong>test</strong> of the rich text editor. You can:</p>
-                <ul>
-                    <li>Format text with <strong>bold</strong>, <em>italic</em>, and <u>underline</u></li>
-                    <li>Create headings (H1, H2, H3)</li>
-                    <li>Add links and images</li>
-                    <li>Create ordered and unordered lists</li>
-                </ul>
-                <p>Try editing this content to test the editor features!</p>
-            </textarea>
-        </div>
-        
-        <div class="form-actions">
-            <button type="submit" class="btn btn-primary">Submit Form</button>
-            <button type="button" class="btn btn-secondary" onclick="showContent()">Show Content</button>
-            <button type="button" class="btn btn-secondary" onclick="clearContent()">Clear</button>
-        </div>
-    </form>
-    
-    <div id="output" class="output" style="display: none;">
-        <h3>Form Output:</h3>
-        <pre id="outputText"></pre>
-    </div>
-    
-    <div id="preview" class="output" style="display: none;">
-        <h3>Content Preview:</h3>
-        <div id="previewContent"></div>
-    </div>
-    
-    <script src="js/wysiwyg.js"></script>
-    <script>
-        // Override the default initialization since we're not in the admin context
-        document.addEventListener('DOMContentLoaded', () => {
-            const editor = new WYSIWYGEditor('content');
-            window.wysiwygEditor = editor;
-            
-            // Handle form submission
-            const form = document.getElementById('testForm');
-            form.addEventListener('submit', (e) => {
-                e.preventDefault();
-                showContent();
-            });
-        });
-        
-        function showContent() {
-            const content = document.getElementById('content').value;
-            const title = document.getElementById('title').value;
-            
-            // Show raw content
-            document.getElementById('outputText').textContent = `Title: ${title}\nContent: ${content}`;
-            document.getElementById('output').style.display = 'block';
-            
-            // Show preview
-            document.getElementById('previewContent').innerHTML = content;
-            document.getElementById('preview').style.display = 'block';
-        }
-        
-        function clearContent() {
-            window.wysiwygEditor.setContent('');
-            document.getElementById('output').style.display = 'none';
-            document.getElementById('preview').style.display = 'none';
-        }
-    </script>
-</body>
-</html>