CHtmlView
in package
CHtmlView Class
Manages HTML page rendering with templates and components.
Architecture:
- CHtmlRender: Template engine (handles [foreach], [if], {{ }} syntax)
- CComponent: Component renderer (handles
tags) - CHtmlView: Orchestrates page assembly
Features:
- Template file management and inclusion
- Component rendering with automatic CSS/JS injection
- Frame element resolution across modules and plugins
- Inline asset processing and minification
- Pre/post processor support
Tags
Table of Contents
Properties
- $cache : ICache|null
- Cache instance
- $component : CComponent
- Component renderer instance
- $css_folder : string
- CSS folder path
- $data : array<string|int, mixed>
- Main data elements for template rendering
- $dbms_type : string
- Database management system type
- $filenames : array<string|int, string>
- Template filenames queue for rendering
- $inline_css : array<string|int, string>
- Inline CSS files to include
- $inline_js : array<string|int, string>
- Inline JavaScript files to include
- $logger : ILogger|null
- Logger instance
- $modules : array<string, string>
- Active modules list
- $page_info : array<string|int, mixed>
- Page information metadata
- $renderer : CHtmlRender
- HTML renderer instance
- $request : CRequest
- Request object
- $response : CResponse
- Response object
- $user : CUser
- User object
- $view_foldernames : array<string, string>
- View folder names to search for templates
Methods
- __construct() : void
- Constructor
- Add() : void
- Add Templates
- FindFrameElement() : string|false
- Find Frame Element
- Get() : string
- Get Raw Content
- LoadHtmlElement() : mixed
- SendHTML() : string
- Send HTML
- ParseCssCode() : void
- Parse CSS Code
- ParseJsCode() : void
- Parse JS Code
- ProcessComponents() : string
- Process Components
- ProcessCoreAssets() : string
- Process Core Assets
- ProcessStaticReplacements() : string
- Process Static Replacements
- ProcessTemplateTags() : string
- Process Template Tags
Properties
$cache
Cache instance
protected
ICache|null
$cache
$component
Component renderer instance
protected
CComponent
$component
$css_folder
CSS folder path
protected
string
$css_folder
= DEFAULT_CSS_FOLDER
$data
Main data elements for template rendering
protected
array<string|int, mixed>
$data
= []
$dbms_type
Database management system type
protected
string
$dbms_type
= ""
$filenames
Template filenames queue for rendering
protected
array<string|int, string>
$filenames
= []
$inline_css
Inline CSS files to include
protected
array<string|int, string>
$inline_css
= []
$inline_js
Inline JavaScript files to include
protected
array<string|int, string>
$inline_js
= []
$logger
Logger instance
protected
ILogger|null
$logger
$modules
Active modules list
protected
array<string, string>
$modules
= []
$page_info
Page information metadata
protected
array<string|int, mixed>
$page_info
= []
$renderer
HTML renderer instance
protected
CHtmlRender
$renderer
$request
Request object
protected
CRequest
$request
$response
Response object
protected
CResponse
$response
$user
User object
protected
CUser
$user
$view_foldernames
View folder names to search for templates
protected
array<string, string>
$view_foldernames
= []
Methods
__construct()
Constructor
public
__construct(CRequest $request, CResponse $response, CUser $user, ICache|null $cache, ILogger|null $logger, array<string|int, mixed> $data[, string $module_name = 'base' ][, string $view_foldername = CURRENT_VIEW_FOLDER ][, string $css_folder = DEFAULT_CSS_FOLDER ]) : void
Initializes the view with request, response, user objects and configuration. Sets up CHtmlRender and CComponent with proper resolvers.
Parameters
- $request : CRequest
-
Request object
- $response : CResponse
-
Response object
- $user : CUser
-
User object
- $cache : ICache|null
-
Cache instance
- $logger : ILogger|null
-
Logger instance
- $data : array<string|int, mixed>
-
Data for template rendering
- $module_name : string = 'base'
-
Module name
- $view_foldername : string = CURRENT_VIEW_FOLDER
-
View folder name
- $css_folder : string = DEFAULT_CSS_FOLDER
-
CSS folder path
Add()
Add Templates
public
Add(array<string|int, mixed>|string|null $files) : void
Queues templates to the list of those to be displayed. Automatically finds associated CSS and JS files.
Parameters
- $files : array<string|int, mixed>|string|null
-
Filename or array of HTML template names
FindFrameElement()
Find Frame Element
public
FindFrameElement(string $module_name, string $filename) : string|false
Searches for a file with the following priority:
- Specific plugin
- Specific module in core
- Generic base module in core
Parameters
- $module_name : string
-
Module name
- $filename : string
-
Filename to search
Return values
string|false —Full path filename if found, false otherwise
Get()
Get Raw Content
public
Get() : string
Returns raw content of all queued templates without processing. Useful for debugging or content inspection.
Return values
string —Raw HTML content
LoadHtmlElement()
public
LoadHtmlElement(array<string|int, mixed> $data, array<string|int, mixed> $view_foldernames[, array<string|int, mixed> $son = [] ][, mixed $primary_element = false ]) : mixed
Parameters
- $data : array<string|int, mixed>
- $view_foldernames : array<string|int, mixed>
- $son : array<string|int, mixed> = []
- $primary_element : mixed = false
SendHTML()
Send HTML
public
SendHTML() : string
Main method to generate and send HTML output. Executes pre-processors, includes templates, renders with CHtmlRender, and processes all tags.
Return values
string —The assembled HTML result
ParseCssCode()
Parse CSS Code
protected
ParseCssCode(string &$code) : void
Performs quick CSS minification by removing whitespace and line breaks. Wraps result in <style> tags.
Parameters
- $code : string
-
CSS code to parse (modified by reference)
ParseJsCode()
Parse JS Code
protected
ParseJsCode(string &$code) : void
Removes comments from JavaScript code. Wraps result in <script> tags.
Parameters
- $code : string
-
JavaScript code to parse (modified by reference)
ProcessComponents()
Process Components
protected
ProcessComponents(string $output, string &$css_code, string &$js_code) : string
Processes
Syntax:
Parameters
- $output : string
-
HTML code to transform
- $css_code : string
-
CSS code accumulator (modified by reference)
- $js_code : string
-
JS code accumulator (modified by reference)
Return values
string —Processed HTML with components rendered
ProcessCoreAssets()
Process Core Assets
protected
ProcessCoreAssets(string $output) : string
Processes core asset declarations in templates and injects them into the appropriate placeholders in header/footer.
Declaration syntax (in form elements):
- [[CORE-ASSET-CSS:path/to/file.css]]
- [[CORE-ASSET-HEADER-JS:path/to/file.js]]
- [[CORE-ASSET-FOOTER-JS:path/to/file.js]]
Placeholder syntax (in Header/Footer templates):
- [[CORE-ASSETS-CSS]]
- [[CORE-ASSETS-HEADER-JS]]
- [[CORE-ASSETS-FOOTER-JS]]
Parameters
- $output : string
-
HTML code to transform
Return values
string —HTML with core assets properly injected
ProcessStaticReplacements()
Process Static Replacements
protected
ProcessStaticReplacements(string $output) : string
Replaces static placeholders like [[IMG-PLACEHOLDER,width,height,bg,fg]]. Generates SVG placeholder images.
Parameters
- $output : string
-
HTML code to transform
Return values
string —HTML with static placeholders replaced
ProcessTemplateTags()
Process Template Tags
protected
ProcessTemplateTags(string $input) : string
Main processing method that orchestrates all template transformations:
- Component rendering
- Static replacements
- Inline CSS/JS injection
- Token injection
- Pre/post processor execution
Parameters
- $input : string
-
HTML code to transform
Return values
string —Fully processed HTML