XOOPS 2.3.x Series¶
Legacy documentation for XOOPS 2.3.x (2007-2010).
⚠️ Legacy Notice¶
This documentation is for historical reference only. XOOPS 2.3.x is no longer supported. For current development, see Core Concepts.
Overview¶
XOOPS 2.3 introduced significant improvements to the module system and added new administrative features:
- Module Admin Framework: Standardized admin interface
- Improved Caching: Better template and data caching
- UTF-8 Support: Improved internationalization
- jQuery Integration: First official jQuery support
- Enhanced Security: Improved token handling
Key Innovations¶
Module Admin Framework¶
The 2.3 series introduced a standardized admin interface framework:
<?php
// admin/index.php in 2.3.x module
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
require_once XOOPS_ROOT_PATH . '/class/xoopsmoduleadmin.php';
$adminMenu = new XoopsModuleAdmin();
$adminMenu->displayNavigation(basename(__FILE__));
$adminMenu->displayIndex();
Admin Menu Structure¶
<?php
// admin/menu.php
$adminmenu = [];
$adminmenu[] = [
'title' => _MI_MYMODULE_ADMIN_INDEX,
'link' => 'admin/index.php',
'icon' => 'home.png'
];
$adminmenu[] = [
'title' => _MI_MYMODULE_ADMIN_ITEMS,
'link' => 'admin/items.php',
'icon' => 'content.png'
];
$adminmenu[] = [
'title' => _MI_MYMODULE_ADMIN_ABOUT,
'link' => 'admin/about.php',
'icon' => 'about.png'
];
Architecture Improvements¶
graph TB
subgraph "XOOPS 2.3 Architecture"
A[Core] --> B[Module Admin Framework]
A --> C[Cache System]
A --> D[jQuery Integration]
B --> E[Standardized Admin UI]
B --> F[Module Info Display]
B --> G[Update Checker]
C --> H[Template Cache]
C --> I[Data Cache]
C --> J[Module Cache]
end Cache System¶
<?php
// Using the 2.3 cache system
// Template caching (Smarty)
$xoopsTpl->caching = 1;
$xoopsTpl->cache_lifetime = 3600;
// Data caching
$cache = XoopsCache::getInstance();
$cacheKey = 'mymodule_items_' . md5($criteria);
if (!$items = $cache->read($cacheKey)) {
$items = $handler->getObjects($criteria);
$cache->write($cacheKey, $items, 3600);
}
jQuery Integration¶
<?php
// Including jQuery in 2.3.x
// In header.php or module file
$xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
// Custom scripts
$xoTheme->addScript(XOOPS_URL . '/modules/mymodule/assets/js/script.js');
// Using jQuery in templates
$(document).ready(function() {
$('.mymodule-item').click(function() {
// Handle click
});
});
Preload System¶
The 2.3 series introduced the preload system for event handling:
<?php
// preloads/core.php
class MymoduleCorePreload extends XoopsPreloadItem
{
/**
* Called after XOOPS core is loaded
*/
function eventCoreIncludeCommonEnd($args)
{
// Custom initialization
}
/**
* Called before header is rendered
*/
function eventCoreHeaderStart($args)
{
// Add custom header content
}
/**
* Called after footer
*/
function eventCoreFooterEnd($args)
{
// Cleanup or logging
}
}
Security Improvements¶
<?php
// CSRF Token handling in 2.3.x
// In form
$sform->addElement(new XoopsFormHiddenToken());
// Validation
if (!$GLOBALS['xoopsSecurity']->check()) {
redirect_header('index.php', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
exit;
}
// SQL Injection prevention
$cleanId = intval($_GET['id']);
$cleanString = $xoopsDB->escape($_POST['title']);
Module xoops_version.php (2.3 Style)¶
<?php
// xoops_version.php for 2.3.x module
$modversion['name'] = 'My Module';
$modversion['version'] = 1.50; // Decimal format
$modversion['description'] = 'Module description';
$modversion['author'] = 'Author Name';
$modversion['credits'] = 'XOOPS Community';
$modversion['license'] = 'GPL 2.0';
$modversion['image'] = 'images/logo.png';
$modversion['dirname'] = basename(__DIR__);
// Admin
$modversion['hasAdmin'] = 1;
$modversion['adminindex'] = 'admin/index.php';
$modversion['adminmenu'] = 'admin/menu.php';
// Menu
$modversion['hasMain'] = 1;
// Database
$modversion['sqlfile']['mysql'] = 'sql/mysql.sql';
$modversion['tables'] = [
$modversion['dirname'] . '_items',
$modversion['dirname'] . '_categories',
];
// Templates
$modversion['templates'][] = [
'file' => 'mymodule_index.html',
'description' => 'Index page'
];
// Blocks
$modversion['blocks'][] = [
'file' => 'blocks/myblock.php',
'name' => 'My Block',
'description' => 'Block description',
'show_func' => 'mymodule_block_show',
'edit_func' => 'mymodule_block_edit',
'options' => '5|0',
'template' => 'mymodule_block.html'
];
// Config
$modversion['config'][] = [
'name' => 'items_perpage',
'title' => '_MI_MYMODULE_ITEMS_PERPAGE',
'description' => '_MI_MYMODULE_ITEMS_PERPAGE_DESC',
'formtype' => 'textbox',
'valuetype' => 'int',
'default' => 10
];
Breaking Changes from 2.3 to 2.5¶
| Feature | 2.3.x | 2.5.x |
|---|---|---|
| PHP Version | 5.0+ | 5.3+ |
| Version Format | Decimal (1.50) | Semantic (1.5.0) |
| Namespaces | None | Supported |
| Composer | None | Supported |
| XMF | None | Integrated |