跳到內容

XOOPS 模組系統

XOOPS 模組系統為開發、安裝、管理和擴充模組功能提供完整的框架。模組是自包含的套件,可使用額外功能和功能擴充 XOOPS。

graph TD
A[Module Package] -->|contains| B[xoops_version.php]
A -->|contains| C[Admin Interface]
A -->|contains| D[User Interface]
A -->|contains| E[Class Files]
A -->|contains| F[SQL Schema]
B -->|defines| G[Module Metadata]
B -->|defines| H[Admin Pages]
B -->|defines| I[User Pages]
B -->|defines| J[Blocks]
B -->|defines| K[Hooks]
L[Module Manager] -->|reads| B
L -->|controls| M[Installation]
L -->|controls| N[Activation]
L -->|controls| O[Update]
L -->|controls| P[Uninstallation]

標準 XOOPS 模組目錄結構:

mymodule/
├── xoops_version.php # Module manifest and configuration
├── admin.php # Admin main page
├── index.php # User main page
├── admin/ # Admin pages directory
│ ├── main.php
│ ├── manage.php
│ └── settings.php
├── class/ # Module classes
│ ├── Handler/
│ │ ├── ItemHandler.php
│ │ └── CategoryHandler.php
│ └── Objects/
│ ├── Item.php
│ └── Category.php
├── sql/ # Database schemas
│ ├── mysql.sql
│ └── postgres.sql
├── include/ # Include files
│ ├── common.inc.php
│ └── functions.php
├── templates/ # Module templates
│ ├── admin/
│ │ └── main.tpl
│ └── user/
│ ├── index.tpl
│ └── item.tpl
├── blocks/ # Module blocks
│ └── blocks.php
├── tests/ # Unit tests
├── language/ # Language files
│ ├── english/
│ │ └── main.php
│ └── spanish/
│ └── main.php
└── docs/ # Documentation

XoopsModule 類別代表已安裝的 XOOPS 模組。

namespace Xoops\Core\Module;
class XoopsModule extends XoopsObject
{
protected int $moduleid = 0;
protected string $name = '';
protected string $dirname = '';
protected string $version = '';
protected string $description = '';
protected array $config = [];
protected array $blocks = [];
protected array $adminPages = [];
protected array $userPages = [];
}
屬性型別描述
$moduleidint唯一模組 ID
$namestring模組顯示名稱
$dirnamestring模組目錄名稱
$versionstring目前模組版本
$descriptionstring模組描述
$configarray模組設定
$blocksarray模組區塊
$adminPagesarray管理面板頁面
$userPagesarray使用者面向頁面
public function __construct()

建立新的模組實例並初始化變數。

取得模組的顯示名稱。

public function getName(): string

傳回值: string - 模組顯示名稱

取得模組的目錄名稱。

public function getDirname(): string

傳回值: string - 模組目錄名稱

取得目前的模組版本。

public function getVersion(): string

傳回值: string - 版本字串

取得模組描述。

public function getDescription(): string

傳回值: string - 模組描述

檢索模組設定。

public function getConfig(string $key = null): mixed

參數:

參數型別描述
$keystring設定鍵(全部為 null)

傳回值: mixed - 設定值或陣列


另請參閱:XOOPS 模組文件