Bỏ qua để đến nội dung

Phân tích mô-đun nhà xuất bản

Tài liệu này cung cấp phân tích kỹ thuật về kiến trúc, mẫu và chi tiết triển khai mô-đun Nhà xuất bản. Sử dụng tài liệu này làm tài liệu tham khảo để hiểu cách cấu trúc mô-đun XOOPS chất lượng sản xuất.

flowchart TB
subgraph "Presentation Layer"
FE[Frontend Pages]
AD[Admin Panel]
BL[Blocks]
end
subgraph "Application Layer"
PH[Page Handlers]
BH[Block Handlers]
FO[Forms]
end
subgraph "Domain Layer"
IT[Item Entity]
CA[Category Entity]
FI[File Entity]
end
subgraph "Infrastructure"
IH[ItemHandler]
CH[CategoryHandler]
FH[FileHandler]
DB[(Database)]
end
FE --> PH
AD --> PH
BL --> BH
PH --> IT
PH --> CA
BH --> IT
IT --> IH
CA --> CH
FI --> FH
IH --> DB
CH --> DB
FH --> DB
publisher/
├── admin/
│ ├── index.php # Admin dashboard
│ ├── item.php # Article management
│ ├── category.php # Category management
│ ├── permission.php # Permissions
│ ├── file.php # File manager
│ └── menu.php # Admin menu
├── assets/
│ ├── css/
│ ├── js/
│ └── images/
├── class/
│ ├── Category.php # Category entity
│ ├── CategoryHandler.php # Category data access
│ ├── Item.php # Article entity
│ ├── ItemHandler.php # Article data access
│ ├── File.php # File attachment
│ ├── FileHandler.php # File data access
│ ├── Form/ # Form classes
│ ├── Common/ # Utilities
│ └── Helper.php # Module helper
├── include/
│ ├── common.php # Initialization
│ ├── functions.php # Utility functions
│ ├── oninstall.php # Install hooks
│ ├── onupdate.php # Update hooks
│ └── search.php # Search integration
├── language/
├── templates/
├── sql/
└── xoops_version.php
class Item extends \XoopsObject
{
// Fields
public function initVar(): void
{
$this->initVar('itemid', XOBJ_DTYPE_INT, null, false);
$this->initVar('categoryid', XOBJ_DTYPE_INT, 0, false);
$this->initVar('title', XOBJ_DTYPE_TXTBOX, '', true);
$this->initVar('subtitle', XOBJ_DTYPE_TXTBOX, '');
$this->initVar('summary', XOBJ_DTYPE_TXTAREA, '');
$this->initVar('body', XOBJ_DTYPE_TXTAREA, '', true);
$this->initVar('uid', XOBJ_DTYPE_INT, 0);
$this->initVar('status', XOBJ_DTYPE_INT, 0);
$this->initVar('datesub', XOBJ_DTYPE_INT, time());
// ... more fields
}
// Business methods
public function isPublished(): bool
{
return $this->getVar('status') == _PUBLISHER_STATUS_PUBLISHED;
}
public function canEdit(int $userId): bool
{
return $this->getVar('uid') == $userId
|| $this->isAdmin($userId);
}
}
class ItemHandler extends \XoopsPersistableObjectHandler
{
public function __construct(\XoopsDatabase $db)
{
parent::__construct(
$db,
'publisher_items',
Item::class,
'itemid',
'title'
);
}
public function getPublishedItems(int $limit = 10): array
{
$criteria = new \CriteriaCompo();
$criteria->add(new \Criteria('status', _PUBLISHER_STATUS_PUBLISHED));
$criteria->setSort('datesub');
$criteria->setOrder('DESC');
$criteria->setLimit($limit);
return $this->getObjects($criteria);
}
}
Giấy phépMô tả
publisher_viewXem danh mục/bài viết
publisher_submitGửi bài viết mới
publisher_approveTự động phê duyệt bài nộp
publisher_moderateXem lại các bài viết đang chờ xử lý
publisher_globalQuyền mô-đun toàn cầu
class PermissionHandler
{
public function isGranted(string $permission, int $categoryId): bool
{
$userId = $GLOBALS['xoopsUser']?->uid() ?? 0;
$groups = $this->getUserGroups($userId);
return $this->grouppermHandler->checkRight(
$permission,
$categoryId,
$groups,
$this->helper->getModule()->mid()
);
}
}
stateDiagram-v2
[*] --> Draft: Create
Draft --> Submitted: Submit
Submitted --> Published: Approve
Submitted --> Rejected: Reject
Submitted --> Draft: Return for Edit
Published --> Offline: Unpublish
Offline --> Published: Republish
Published --> [*]: Delete
Rejected --> [*]: Delete
MẫuMục đích
publisher_index.tplTrang chủ mô-đun
publisher_item.tplBài viết đơn
publisher_category.tplDanh sách danh mục
publisher_submit.tplNộp hồ sơ
publisher_search.tplKết quả tìm kiếm
MẫuMục đích
publisher_block_latest.tplCác bài viết gần đây
publisher_block_spotlight.tplBài viết nổi bật
publisher_block_category.tplThực đơn danh mục
  1. Mẫu trình xử lý - Đóng gói truy cập dữ liệu
  2. Đối tượng giá trị - Hằng trạng thái
  3. Phương pháp mẫu - Tạo biểu mẫu
  4. Chiến lược - Các chế độ hiển thị khác nhau
  5. Người quan sát - Thông báo về các sự kiện
  1. Sử dụng XoopsPersistableObjectHandler cho CRUD
  2. Triển khai các quyền chi tiết
  3. Tách cách trình bày khỏi logic
  4. Sử dụng Tiêu chí cho truy vấn
  5. Hỗ trợ nhiều trạng thái nội dung
  6. Tích hợp với hệ thống thông báo XOOPS
  • Tạo bài viết - Quản lý bài viết
  • Quản lý-Danh mục - Hệ thống danh mục
  • Quyền-Cài đặt - Cấu hình quyền
  • Hướng dẫn dành cho nhà phát triển/Móc và sự kiện - Điểm mở rộng