XOOPS API Reference
Welcome to the comprehensive XOOPS API Reference documentation. This section provides detailed documentation for all core classes, methods, and systems that make up the XOOPS Content Management System.
Overview
Section titled “Overview”The XOOPS API is organized into several major subsystems, each responsible for a specific aspect of the CMS functionality. Understanding these APIs is essential for developing modules, themes, and extensions for XOOPS.
API Sections
Section titled “API Sections”Core Classes
Section titled “Core Classes”The foundation classes that all other XOOPS components build upon.
| Documentation | Description |
|---|---|
| XoopsObject | Base class for all data objects in XOOPS |
| XoopsObjectHandler | Handler pattern for CRUD operations |
Database Layer
Section titled “Database Layer”Database abstraction and query building utilities.
| Documentation | Description |
|---|---|
| XoopsDatabase | Database abstraction layer |
| Criteria System | Query criteria and conditions |
| QueryBuilder | Modern fluent query building |
Form System
Section titled “Form System”HTML form generation and validation.
| Documentation | Description |
|---|---|
| XoopsForm | Form container and rendering |
| Form Elements | All available form element types |
Kernel Classes
Section titled “Kernel Classes”Core system components and services.
| Documentation | Description |
|---|---|
| Kernel Classes | System kernel and core components |
Module System
Section titled “Module System”Module management and lifecycle.
| Documentation | Description |
|---|---|
| Module System | Module loading, installation, and management |
Template System
Section titled “Template System”Smarty template integration.
| Documentation | Description |
|---|---|
| Template System | Smarty integration and template management |
User System
Section titled “User System”User management and authentication.
| Documentation | Description |
|---|---|
| User System | User accounts, groups, and permissions |
Architecture Overview
Section titled “Architecture Overview”flowchart TB subgraph "Foundation Layer" XO[XoopsObject<br/>Base Class] XD[XoopsDatabase<br/>DB Abstraction] XF[XoopsForm<br/>Form Generation] end
subgraph "Handler Layer" XOH[XoopsObjectHandler<br/>CRUD Operations] CR[Criteria<br/>Query Building] XFE[XoopsFormElement<br/>Input Types] end
subgraph "Module Layer" XM[XoopsModule<br/>Module Management] end
subgraph "Presentation Layer" XT[XoopsTpl<br/>Template Engine] end
XO --> XOH XD --> CR XF --> XFE XOH --> XM CR --> XM XFE --> XM XM --> XTClass Hierarchy
Section titled “Class Hierarchy”Object Model
Section titled “Object Model”classDiagram class XoopsObject { <<Base>> +getVar() +setVar() +toArray() } XoopsObject <|-- XoopsUser XoopsObject <|-- XoopsGroup XoopsObject <|-- XoopsModule XoopsObject <|-- XoopsBlock XoopsObject <|-- XoopsComment XoopsObject <|-- XoopsNotificationHandler Model
Section titled “Handler Model”classDiagram class XoopsObjectHandler { <<Base>> +create() +get() +insert() +delete() } class XoopsPersistableObjectHandler { +getObjects() +getCount() +deleteAll() } XoopsObjectHandler <|-- XoopsPersistableObjectHandler XoopsPersistableObjectHandler <|-- XoopsUserHandler XoopsPersistableObjectHandler <|-- XoopsGroupHandler XoopsPersistableObjectHandler <|-- XoopsModuleHandler XoopsPersistableObjectHandler <|-- XoopsBlockHandler XoopsObjectHandler <|-- CustomModuleHandlersForm Model
Section titled “Form Model”classDiagram class XoopsForm { <<Base>> +addElement() +render() +display() } XoopsForm <|-- XoopsThemeForm XoopsForm <|-- XoopsSimpleForm
class XoopsFormElement { <<Base>> +getName() +render() +getValue() } XoopsFormElement <|-- XoopsFormText XoopsFormElement <|-- XoopsFormTextArea XoopsFormElement <|-- XoopsFormSelect XoopsFormElement <|-- XoopsFormCheckBox XoopsFormElement <|-- XoopsFormRadio XoopsFormElement <|-- XoopsFormButton XoopsFormElement <|-- XoopsFormFile XoopsFormElement <|-- XoopsFormHidden XoopsFormElement <|-- XoopsFormLabel XoopsFormElement <|-- XoopsFormPassword XoopsFormElement <|-- XoopsFormEditorDesign Patterns
Section titled “Design Patterns”The XOOPS API implements several well-known design patterns:
Singleton Pattern
Section titled “Singleton Pattern”Used for global services like database connections and container instances.
$db = XoopsDatabase::getInstance();$container = XoopsContainer::getInstance();Factory Pattern
Section titled “Factory Pattern”Object handlers create domain objects consistently.
$handler = xoops_getHandler('user');$user = $handler->create();Composite Pattern
Section titled “Composite Pattern”Forms contain multiple form elements; criteria can contain nested criteria.
$criteria = new CriteriaCompo();$criteria->add(new Criteria('status', 1));$criteria->add(new CriteriaCompo(...)); // NestedObserver Pattern
Section titled “Observer Pattern”The event system allows loose coupling between modules.
$dispatcher->addListener('module.news.article_published', $callback);Quick Start Examples
Section titled “Quick Start Examples”Creating and Saving an Object
Section titled “Creating and Saving an Object”// Get the handler$handler = xoops_getHandler('user');
// Create a new object$user = $handler->create();$user->setVar('uname', 'newuser');$user->setVar('email', 'user@example.com');
// Save to database$handler->insert($user);Querying with Criteria
Section titled “Querying with Criteria”// Build criteria$criteria = new CriteriaCompo();$criteria->add(new Criteria('level', 0, '>'));$criteria->setSort('uname');$criteria->setOrder('ASC');$criteria->setLimit(10);
// Get objects$handler = xoops_getHandler('user');$users = $handler->getObjects($criteria);Creating a Form
Section titled “Creating a Form”$form = new XoopsThemeForm('User Profile', 'userform', 'save.php', 'post', true);$form->addElement(new XoopsFormText('Username', 'uname', 50, 255, $user->getVar('uname')));$form->addElement(new XoopsFormTextArea('Bio', 'bio', $user->getVar('bio')));$form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));echo $form->render();API Conventions
Section titled “API Conventions”Naming Conventions
Section titled “Naming Conventions”| Type | Convention | Example |
|---|---|---|
| Classes | PascalCase | XoopsUser, CriteriaCompo |
| Methods | camelCase | getVar(), setVar() |
| Properties | camelCase (protected) | $_vars, $_handler |
| Constants | UPPER_SNAKE_CASE | XOBJ_DTYPE_INT |
| Database Tables | snake_case | users, groups_users_link |
Data Types
Section titled “Data Types”XOOPS defines standard data types for object variables:
| Constant | Type | Description |
|---|---|---|
XOBJ_DTYPE_TXTBOX | String | Text input (sanitized) |
XOBJ_DTYPE_TXTAREA | String | Textarea content |
XOBJ_DTYPE_INT | Integer | Numeric values |
XOBJ_DTYPE_URL | String | URL validation |
XOBJ_DTYPE_EMAIL | String | Email validation |
XOBJ_DTYPE_ARRAY | Array | Serialized arrays |
XOBJ_DTYPE_OTHER | Mixed | Custom handling |
XOBJ_DTYPE_SOURCE | String | Source code (minimal sanitization) |
XOBJ_DTYPE_STIME | Integer | Short timestamp |
XOBJ_DTYPE_MTIME | Integer | Medium timestamp |
XOBJ_DTYPE_LTIME | Integer | Long timestamp |
Authentication Methods
Section titled “Authentication Methods”The API supports multiple authentication methods:
API Key Authentication
Section titled “API Key Authentication”X-API-Key: your-api-keyOAuth Bearer Token
Section titled “OAuth Bearer Token”Authorization: Bearer your-oauth-tokenSession-Based Authentication
Section titled “Session-Based Authentication”Uses existing XOOPS session when logged in.
REST API Endpoints
Section titled “REST API Endpoints”When the REST API is enabled:
| Endpoint | Method | Description |
|---|---|---|
/api.php/rest/users | GET | List users |
/api.php/rest/users/{id} | GET | Get user by ID |
/api.php/rest/users | POST | Create user |
/api.php/rest/users/{id} | PUT | Update user |
/api.php/rest/users/{id} | DELETE | Delete user |
/api.php/rest/modules | GET | List modules |
Related Documentation
Section titled “Related Documentation”- Module Development Guide
- Theme Development Guide
- System Configuration
- Security Best Practices
Version History
Section titled “Version History”| Version | Changes |
|---|---|
| 2.5.11 | Current stable release |
| 2.5.10 | Added GraphQL API support |
| 2.5.9 | Enhanced Criteria system |
| 2.5.8 | PSR-4 autoloading support |
This documentation is part of the XOOPS Knowledge Base. For the latest updates, visit the XOOPS GitHub repository.