Pages Controller Documentation
File: /controllers/pages.php
Purpose: Content Management System for static pages with image handling and content management
Last Updated: December 20, 2024
Total Functions: 4
Lines of Code: ~220
---
๐ Overview
The Pages Controller provides a basic CMS functionality for managing static website pages. It supports page creation, editing, deletion with image uploads, and content management in both Arabic and English languages.
Primary Functions
- โ Static page content management
- โ Dual language support (Arabic/English)
- โ Image upload and management
- โ Page status control (active/inactive)
- โ CRUD operations for pages
- โ AJAX/cURL API support
---
๐๏ธ Database Tables
| Table Name | Purpose | Key Columns |
|---|---|---|
| **pages** | CMS page content | id, title, titleEn, content, contentEn, image, isActive, sysDate, userid, isdel |
๐ Key Functions
1. add() - Create New Page
Location: Lines 151-180
Purpose: Create new static page with image upload
Function Signature:
function add()
Process Flow:
1. Collect form data (title, content in both languages)
2. Handle image upload via uploadnew()
3. Store page data using RedBean ORM
4. Set default values and system metadata
Key Features:
// Image handling
$image = uploadnew('image', False, 0, 0, 'pages');
// Page creation
$rdispense = R::dispense('pages');
$rdispense->title = $title;
$rdispense->titleEn = $titleEn;
$rdispense->content = $content;
$rdispense->contentEn = $contentEn;
$rdispense->image = $image;
$rdispense->isActive = $isActive;
$rdispense->sysDate = date("Y-m-d H:i:s");
$rdispense->userid = $_SESSION['userid'];
$rdispense->isdel = 0;
2. update() - Modify Existing Page
Location: Lines 182-210
Purpose: Update page content and images
3. deleteFinaly() - Delete Page
Location: Lines 212-219
Purpose: Permanently delete page and associated image files
---
๐ URL Routes & Actions
| URL Parameter | Function | Description | |
|---|---|---|---|
| `do=` (empty) | Default | Show add form | |
| `do=add` | add() | Create new page | |
| `do=show` | List | Display all pages | |
| `do=edit` | Edit form | Show edit form | |
| `do=update` | update() | Update page | |
| `do=deleteFinaly` | deleteFinaly() | Delete page |
- โข
title- Page title (Arabic) - โข
titleEn- Page title (English) - โข
content- Page content (Arabic) - โข
contentEn- Page content (English) - โข
isActive- Page status (0/1) - โข
image- Page image file
---
๐ Security & Features
API Support
- โข Supports both web form and AJAX/cURL submissions
- โข JSON response format for API calls
- โข Content-type detection for response formatting
Image Management
- โข Automatic image upload to
/upload/pages/directory - โข File permission management (chmod)
- โข Image deletion on page removal
---
Documented By: AI Assistant
Review Status: โ Complete