Bootstrap Process - xoopscube/legacy GitHub Wiki

XCL Bootstrap Process

The XCL (XOOPS Cube Legacy) bootstrap process is a sophisticated sequence that loads the core framework,
initializes the rendering system, and outputs the final theme.

1. Bootstrap Initialization (mainfile.php)

The process begins with mainfile.php, which serves as the entry point for all requests:

  • Define constants and paths
  • Root path (public)
  • Trust path (private)
  • URL
  • etc.

And requires:

  • Load protector (security module) pre-check
  • Initialize cubecore
  • Load common functionality if not prevented
  • Load protector post-check

2. Core Initialization (cubecore_init.php)

cubecore_init.php loads the core classes and initializes the configuration system:

  • XCL version constants
  • XCube_Root class
  • XCube_Controller class
  • IniHandler class

Defined configuration file paths

  • Default settings : site_default.ini
  • XCUBE_SITE_CUSTOM_FILE settings : site_custom.ini

3. Loading Definitions (definition.inc.php)

The system loads definition.inc.php which contains essential constants:

  • Block positions
  • Path definitions
    • CACHE PATH
    • MODULE PATH
  • Render system definition
    • Legacy_RenderSystem

4. Configuration Loading (site_default.ini)

The system reads site_default.ini to configure components:

[Cube]
Root=XOOPS_ROOT_PATH
Controller=Legacy_Controller
SystemModules=legacy,legacyRender,user,profile,stdCache,altsys,message,protector
// ...

[RenderSystems]
Legacy_RenderSystem=Legacy_RenderSystem
Legacy_AdminRenderSystem=Legacy_AdminRenderSystem
// ...

[Legacy_RenderSystem]
path=/modules/legacyRender/kernel
class=Legacy_RenderSystem
// ...

5. Controller Initialization (Legacy_Controller)

The Legacy_Controller is initialized based on the configuration:

// In Legacy_Controller.class.php
class Legacy_Controller extends XCube_Controller
{
    // Initialize modules, services, and context
    public function __construct()
    {
        parent::__construct();
        $this->_mStrategy = new Legacy_PublicControllerStrategy($this);
        // ...
    }
    
    // Execute the request
    public function execute()
    {
        // Process blocks, modules, and render the page
        // ...
    }
}

6. Render System Initialization (Legacy_RenderSystem)

The Legacy_RenderSystem is loaded to handle the rendering process:

// In Legacy_RenderSystem.class.php
class Legacy_RenderSystem extends XCube_RenderSystem
{
    // Initialize Smarty and template system
    public function __construct()
    {
        parent::__construct();
        // ...
    }
    
    // Create render targets for different parts of the page
    public function createRenderTarget($type = null)
    {
        // Create theme, block, or main content render targets
        // ...
    }
    
    // Render the page
    public function render(&$target)
    {
        // Process templates and output HTML
        // ...
    }
}

7. Template Processing (Smarty)

The system uses Smarty for template processing:

// In Legacy_RenderSystem.class.php
function render(&$target)
{
    // Initialize Smarty template engine
    $smarty = new XoopsTpl();
    
    // Set template variables
    foreach ($target->getAttributes() as $key => $value) {
        $smarty->assign($key, $value);
    }
    
    // Process the template
    $result = $smarty->fetch($target->getTemplateName());
    
    // Set the result
    $target->setResult($result);
}

8. Final Output

The final output process combines all rendered components:

  1. The main content is rendered by the module's action
  2. Blocks are rendered and positioned according to their settings
  3. The theme template (theme.html) is loaded and populated with content
  4. The complete HTML is sent to the browser

Flow Summary

  1. mainfile.php → Sets up environment and loads core
  2. cubecore_init.php → Initializes XCube core classes
  3. definition.inc.php → Defines constants and paths
  4. site_default.ini → Configures components and modules
  5. Legacy_Controller → Processes the request
  6. Legacy_RenderSystem → Handles template rendering
  7. Smarty → Processes templates
  8. Theme output → Final HTML sent to browser

This architecture allows XCL to maintain a clean separation between content,
presentation, and logic while providing a flexible framework for module development.