Ga naar inhoud

Analyse van uitgeversmodules

Dit document biedt een technische analyse van de architectuur, patronen en implementatiedetails van de Publisher-module. Gebruik dit als referentie om te begrijpen hoe een XOOPS-module van productiekwaliteit is gestructureerd.

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);
}
}
ToestemmingBeschrijving
publisher_viewBekijk categorie/artikelen
publisher_submitNieuwe artikelen indienen
publisher_approveInzendingen automatisch goedkeuren
publisher_moderateIn behandeling zijnde artikelen bekijken
publisher_globalAlgemene modulemachtigingen
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
SjabloonDoel
publisher_index.tplModule-startpagina
publisher_item.tplEnkel artikel
publisher_category.tplCategorieoverzicht
publisher_submit.tplInzendingsformulier
publisher_search.tplZoekresultaten
SjabloonDoel
publisher_block_latest.tplRecente artikelen
publisher_block_spotlight.tplUitgelicht artikel
publisher_block_category.tplCategoriemenu
  1. Handlerpatroon - Inkapseling van gegevenstoegang
  2. Waardeobject - Statusconstanten
  3. Sjabloonmethode - Formulier genereren
  4. Strategie - Verschillende weergavemodi
  5. Waarnemer - Meldingen over evenementen
  1. Gebruik XoopsPersistableObjectHandler voor CRUD
  2. Implementeer gedetailleerde machtigingen
  3. Scheid presentatie van logica
  4. Gebruik criteria voor query’s
  5. Ondersteuning van meerdere inhoudsstatussen
  6. Integreer met XOOPS-meldingssysteem
  • Artikelen aanmaken - Artikelbeheer
  • Beheren van categorieën - Categoriesysteem
  • Machtigingen-instellingen - Machtigingsconfiguratie
  • Developer-Guide/Hooks-and-Events - Extensiepunten