Explorar el Código

Updated initial setup.php nad one translation

svalavuo hace 5 días
padre
commit
8c2189164e
Se han modificado 3 ficheros con 102 adiciones y 0 borrados
  1. 1 0
      languages/en.php
  2. 1 0
      languages/fi.php
  3. 100 0
      setup.sql

+ 1 - 0
languages/en.php

@@ -45,6 +45,7 @@ return [
     'search_publications' => 'Search for publications...',
     'search_placeholder' => 'Search publications...',
     'no_publications_found' => 'No publications found.',
+    'back_to_publications' => 'Back to publications',
     'by_author' => 'By {author}',
     'on_date' => 'on {date}',
     'read_more' => 'Read more',

+ 1 - 0
languages/fi.php

@@ -46,6 +46,7 @@ return [
     'search_publications' => 'Etsi julkaisuja...',
     'search_placeholder' => 'Hae julkaisuja...',
     'no_publications_found' => 'Julkaisuja ei löytynyt.',
+    'back_to_publications' => 'Takaisin julkaisuihin',
     'by_author' => 'Tekijä {author}',
     'on_date' => '{date}',
     'read_more' => 'Lue lisää',

+ 100 - 0
setup.sql

@@ -0,0 +1,100 @@
+-- Web Publication System Complete Database Schema
+-- MariaDB/MySQL compatible
+-- Combined schema with all migrations for setup.php
+-- Note: Database creation and selection is handled by setup script
+
+-- Publications table
+CREATE TABLE publications (
+    id INT AUTO_INCREMENT PRIMARY KEY,
+    title VARCHAR(255) NOT NULL,
+    slug VARCHAR(255),
+    content TEXT NOT NULL,
+    summary VARCHAR(500),
+    author VARCHAR(100) NOT NULL,
+    status ENUM('draft', 'published', 'archived') DEFAULT 'draft',
+    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    published_at TIMESTAMP NULL DEFAULT NULL,
+    INDEX idx_publications_slug (slug)
+);
+
+-- Users table for admin authentication with LDAP support
+CREATE TABLE users (
+    id INT AUTO_INCREMENT PRIMARY KEY,
+    username VARCHAR(50) UNIQUE NOT NULL,
+    password VARCHAR(255),
+    email VARCHAR(255),
+    role ENUM('admin', 'editor', 'user') DEFAULT 'editor',
+    auth_type ENUM('local', 'ldap') DEFAULT 'local',
+    ldap_dn VARCHAR(255),
+    status ENUM('active', 'inactive') NOT NULL DEFAULT 'active',
+    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    last_login TIMESTAMP NULL,
+    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+    INDEX idx_users_role (role),
+    INDEX idx_users_status (status)
+);
+
+-- Categories table
+CREATE TABLE categories (
+    id INT AUTO_INCREMENT PRIMARY KEY,
+    name VARCHAR(100) UNIQUE NOT NULL,
+    description TEXT,
+    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+-- Publication categories junction table
+CREATE TABLE publication_categories (
+    publication_id INT,
+    category_id INT,
+    PRIMARY KEY (publication_id, category_id),
+    FOREIGN KEY (publication_id) REFERENCES publications(id) ON DELETE CASCADE,
+    FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE CASCADE
+);
+
+-- Images table for WYSIWYG editor
+CREATE TABLE IF NOT EXISTS images (
+    id INT AUTO_INCREMENT PRIMARY KEY,
+    filename VARCHAR(255) NOT NULL,
+    original_name VARCHAR(255) NOT NULL,
+    file_size INT NOT NULL,
+    mime_type VARCHAR(100),
+    uploaded_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+    uploaded_by INT,
+    INDEX idx_uploaded_at (uploaded_at),
+    INDEX idx_uploaded_by (uploaded_by)
+);
+
+-- Add foreign key constraint for images table
+ALTER TABLE images ADD CONSTRAINT fk_images_user FOREIGN KEY (uploaded_by) REFERENCES users(id) ON DELETE SET NULL;
+
+-- Insert default admin user (password: admin123)
+INSERT INTO users (username, password, email, role, auth_type, status) VALUES 
+('admin', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', 'admin@example.com', 'admin', 'local', 'active');
+
+-- Insert sample categories
+INSERT INTO categories (name, description) VALUES 
+('Technology', 'Articles about technology and programming'),
+('News', 'Current events and news articles'),
+('Tutorial', 'How-to guides and tutorials'),
+('Opinion', 'Editorials and opinion pieces');
+
+-- Insert sample publications
+INSERT INTO publications (title, slug, content, summary, author, status, published_at) VALUES 
+('Welcome to Web Publication System', 'welcome-to-web-publication-system', 'This is a sample publication to demonstrate the system capabilities. You can edit or delete this publication from the admin panel.', 'A welcome message for new users', 'admin', 'published', NOW()),
+('Getting Started with PHP', 'getting-started-with-php', 'PHP is a popular server-side scripting language designed for web development. This article covers the basics of getting started with PHP development.', 'Introduction to PHP programming', 'admin', 'published', NOW()),
+('Database Design Best Practices', 'database-design-best-practices', 'Good database design is crucial for application performance and maintainability. This article covers essential principles and practices.', 'Tips for designing efficient databases', 'admin', 'draft', NULL);
+
+-- Update existing publications to generate slugs from titles (for any existing data)
+UPDATE publications 
+SET slug = LOWER(REPLACE(REPLACE(REPLACE(title, '[^a-z0-9 ]', ''), ' ', '-'), '-', '')) 
+WHERE slug IS NULL OR slug = '';
+
+-- Update published_at for existing published publications (for any existing data)
+UPDATE publications 
+SET published_at = created_at 
+WHERE status = 'published' AND published_at IS NULL;
+
+-- Update existing users to have default role and status (for any existing data)
+UPDATE users SET role = 'admin' WHERE id = 1; -- Make first user admin
+UPDATE users SET status = 'active' WHERE status IS NULL;