Skip to content

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.

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.

The foundation classes that all other XOOPS components build upon.

DocumentationDescription
XoopsObjectBase class for all data objects in XOOPS
XoopsObjectHandlerHandler pattern for CRUD operations

Database abstraction and query building utilities.

DocumentationDescription
XoopsDatabaseDatabase abstraction layer
Criteria SystemQuery criteria and conditions
QueryBuilderModern fluent query building

HTML form generation and validation.

DocumentationDescription
XoopsFormForm container and rendering
Form ElementsAll available form element types

Core system components and services.

DocumentationDescription
Kernel ClassesSystem kernel and core components

Module management and lifecycle.

DocumentationDescription
Module SystemModule loading, installation, and management

Smarty template integration.

DocumentationDescription
Template SystemSmarty integration and template management

User management and authentication.

DocumentationDescription
User SystemUser accounts, groups, and permissions
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 --> XT
classDiagram
class XoopsObject {
<<Base>>
+getVar()
+setVar()
+toArray()
}
XoopsObject <|-- XoopsUser
XoopsObject <|-- XoopsGroup
XoopsObject <|-- XoopsModule
XoopsObject <|-- XoopsBlock
XoopsObject <|-- XoopsComment
XoopsObject <|-- XoopsNotification
classDiagram
class XoopsObjectHandler {
<<Base>>
+create()
+get()
+insert()
+delete()
}
class XoopsPersistableObjectHandler {
+getObjects()
+getCount()
+deleteAll()
}
XoopsObjectHandler <|-- XoopsPersistableObjectHandler
XoopsPersistableObjectHandler <|-- XoopsUserHandler
XoopsPersistableObjectHandler <|-- XoopsGroupHandler
XoopsPersistableObjectHandler <|-- XoopsModuleHandler
XoopsPersistableObjectHandler <|-- XoopsBlockHandler
XoopsObjectHandler <|-- CustomModuleHandlers
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 <|-- XoopsFormEditor

The XOOPS API implements several well-known design patterns:

Used for global services like database connections and container instances.

$db = XoopsDatabase::getInstance();
$container = XoopsContainer::getInstance();

Object handlers create domain objects consistently.

$handler = xoops_getHandler('user');
$user = $handler->create();

Forms contain multiple form elements; criteria can contain nested criteria.

$criteria = new CriteriaCompo();
$criteria->add(new Criteria('status', 1));
$criteria->add(new CriteriaCompo(...)); // Nested

The event system allows loose coupling between modules.

$dispatcher->addListener('module.news.article_published', $callback);
// 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);
// 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);
$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();
TypeConventionExample
ClassesPascalCaseXoopsUser, CriteriaCompo
MethodscamelCasegetVar(), setVar()
PropertiescamelCase (protected)$_vars, $_handler
ConstantsUPPER_SNAKE_CASEXOBJ_DTYPE_INT
Database Tablessnake_caseusers, groups_users_link

XOOPS defines standard data types for object variables:

ConstantTypeDescription
XOBJ_DTYPE_TXTBOXStringText input (sanitized)
XOBJ_DTYPE_TXTAREAStringTextarea content
XOBJ_DTYPE_INTIntegerNumeric values
XOBJ_DTYPE_URLStringURL validation
XOBJ_DTYPE_EMAILStringEmail validation
XOBJ_DTYPE_ARRAYArraySerialized arrays
XOBJ_DTYPE_OTHERMixedCustom handling
XOBJ_DTYPE_SOURCEStringSource code (minimal sanitization)
XOBJ_DTYPE_STIMEIntegerShort timestamp
XOBJ_DTYPE_MTIMEIntegerMedium timestamp
XOBJ_DTYPE_LTIMEIntegerLong timestamp

The API supports multiple authentication methods:

X-API-Key: your-api-key
Authorization: Bearer your-oauth-token

Uses existing XOOPS session when logged in.

When the REST API is enabled:

EndpointMethodDescription
/api.php/rest/usersGETList users
/api.php/rest/users/{id}GETGet user by ID
/api.php/rest/usersPOSTCreate user
/api.php/rest/users/{id}PUTUpdate user
/api.php/rest/users/{id}DELETEDelete user
/api.php/rest/modulesGETList modules
  • Module Development Guide
  • Theme Development Guide
  • System Configuration
  • Security Best Practices
VersionChanges
2.5.11Current stable release
2.5.10Added GraphQL API support
2.5.9Enhanced Criteria system
2.5.8PSR-4 autoloading support

This documentation is part of the XOOPS Knowledge Base. For the latest updates, visit the XOOPS GitHub repository.