GeniXCMS

Control Class

categoryAPI edit_calendar31 Mar 2026

Control Class


The Control class is the central dispatcher of GeniXCMS. It acts as the single entry point that reads the current URL, determines the appropriate area (frontend, backend, ajax, error, or install), and includes the corresponding controller file from the inc/lib/Control/ directory.

priority_high
ImportantControl does not implement business logic itself. It is purely a router/dispatcher that delegates execution to the correct controller file.

Application Bootstrap Flow

index.php
  └── GxMain::frontend()
        └── Control::frontend()
              ├── Control::route()       [Smart URL mode]
              │     └── Control::incFront('post', $param)
              └── Control::get()         [Non-Smart URL mode]
                    └── Control::incFront('post')

Methods

Frontend Method

Usage: Control::frontend();

Main dispatcher for all public-facing pages. It determines the routing mode (Smart URL vs. query string) and delegates to either route() or get().

  • Smart URL mode: Uses Router::run() to parse the URI.
  • Non-Smart URL mode: Reads from $_GET parameters directly.

Route Method

Usage: Control::route(array $allowed);

Used in Smart URL mode. Calls Router::run() to match the current URI, then calls incFront() with the matched controller name and parameters. Falls back to error('404') on no match.

Get Method

Usage: Control::get(array $allowed);

Used in non-Smart URL mode. Iterates over $_GET parameters to find a matching controller key from the $allowed list and calls incFront().

IncFront Method

Usage: Control::incFront(string $controller, array $param = '');

Includes a file from inc/lib/Control/Frontend/{$controller}.control.php. Falls back to error('404') if the file does not exist.

// Internally called as:
Control::incFront('post', $param);
// Includes: inc/lib/Control/Frontend/post.control.php

Backend Method

Usage: Control::backend();

Dispatcher for the admin dashboard. Reads $_GET['page'] and includes the matching file from inc/lib/Control/Backend/. Defaults to the dashboard (default.control.php) if no page is specified.

// URL: /admin/index.php?page=posts
// Includes: inc/lib/Control/Backend/posts.control.php

IncBack Method

Usage: Control::incBack(string $controller);

Includes a file from inc/lib/Control/Backend/{$controller}.control.php. Falls back to error('404', 'File Not Found') if the file does not exist.

Ajax Method

Usage: Control::ajax(string $endpoint, array $param = '');

Includes a file from inc/lib/Control/Ajax/{$endpoint}-ajax.control.php.

// URL: /ajax/api/TOKEN
// Includes: inc/lib/Control/Ajax/api-ajax.control.php

Error Method

Usage: Control::error(string $code = '', mixed $val = '');

Includes a file from inc/lib/Control/Error/{$code}.control.php. Common codes: 404, noaccess.

// Show 404 page
Control::error('404');

// Show access denied page
Control::error('noaccess');

Install Method

Usage: Control::install();

Includes the installation wizard controller at inc/lib/Control/Install/default.control.php.

Allowed Frontend Routes

The frontend() method allows the following route keys:

['ajax', 'post', 'page', 'cat', 'mod', 'sitemap', 'rss',
 'account', 'search', 'author', 'tag', 'thumb', 'default',
 'login', 'register', 'forgotpass', 'logout', 'archive']

See Also

  • BaseControl — Abstract class extended by all frontend controllers.
  • Router — URL pattern matching, used by Control::route().
  • Control Layer Reference — Full documentation of all individual controller files.