PageLayoutHelper
in package
Helper class for generating page layout elements.
Provides methods for generating page headers, footers, navigation menus, and other layout components.
Tags
Table of Contents
Methods
- buildActionCard() : string
- Generate an action card with buttons (non-collapsible).
- buildDocumentTitle() : string
- Build the document title tag content.
- buildExecutionTime() : string
- Build the execution time display.
- buildLogo() : string
- Generate the LWT logo HTML.
- buildMetaTags() : string
- Build the HTML head meta tags.
- buildNavbar() : string
- Generate the main navigation bar HTML using Alpine.js and Bulma.
- buildPager() : string
- Generate pagination controls HTML.
- buildPageTitle() : string
- Build the page title HTML element.
- renderFramesetHeader() : void
- Render a frameset page header.
- renderMessage() : void
- Display a message (success/error) to the user.
- renderPageEnd() : void
- Render the page footer (closing body and html tags).
- renderPageStart() : void
- Render a standard page header with navigation.
- renderPageStartKernelNobody() : void
- Render a minimal page header (kernel, no database).
- renderPageStartNobody() : void
- Render a full page header (no database).
- sendNoCacheHeaders() : void
- Generate HTTP cache prevention headers.
- buildDataThemeAttr() : string
- Build the data-theme attribute for the <html> element.
- getRequiredModules() : array<string|int, string>
- Determine which frontend feature modules the current page needs.
Methods
buildActionCard()
Generate an action card with buttons (non-collapsible).
public
static buildActionCard(array<string|int, array{url: string, label: string, icon?: string, class?: string, target?: string, attrs?: string}> $actions) : string
Creates a Bulma card with action buttons for page-level actions.
Parameters
- $actions : array<string|int, array{url: string, label: string, icon?: string, class?: string, target?: string, attrs?: string}>
-
Array of actions
Return values
string —HTML for the action card
buildDocumentTitle()
Build the document title tag content.
public
static buildDocumentTitle(string $title) : string
Parameters
- $title : string
-
Page title
Return values
string —HTML title element
buildExecutionTime()
Build the execution time display.
public
static buildExecutionTime(float $executionTime) : string
Parameters
- $executionTime : float
-
Execution time in seconds
Return values
string —HTML paragraph with execution time
buildLogo()
Generate the LWT logo HTML.
public
static buildLogo([string $imagePath = 'assets/images/lwt_icon_48.png' ]) : string
Parameters
- $imagePath : string = 'assets/images/lwt_icon_48.png'
-
Path to the logo image
Return values
string —HTML img element for the logo
buildMetaTags()
Build the HTML head meta tags.
public
static buildMetaTags() : string
Return values
string —HTML meta tags
buildNavbar()
Generate the main navigation bar HTML using Alpine.js and Bulma.
public
static buildNavbar([string $currentPage = '' ]) : string
Parameters
- $currentPage : string = ''
-
Optional identifier for the current page to highlight
Return values
string —HTML navbar element
buildPager()
Generate pagination controls HTML.
public
static buildPager(int $currentPage, int $totalPages, string $scriptUrl, string $formName[, array<string, mixed> $preserveParams = [] ]) : string
Parameters
- $currentPage : int
-
Current page number
- $totalPages : int
-
Total number of pages
- $scriptUrl : string
-
Base URL for pagination links
- $formName : string
-
Form name for JavaScript reference (unused, kept for BC)
- $preserveParams : array<string, mixed> = []
-
Query parameters to preserve in pagination links
Return values
string —HTML pagination controls
buildPageTitle()
Build the page title HTML element.
public
static buildPageTitle(string $title) : string
Parameters
- $title : string
-
Page title
Return values
string —HTML h1 element with title
renderFramesetHeader()
Render a frameset page header.
public
static renderFramesetHeader(string $title) : void
Outputs directly to browser. For legacy frameset-based pages.
Parameters
- $title : string
-
Page title
renderMessage()
Display a message (success/error) to the user.
public
static renderMessage(string $message[, bool $autoHide = true ]) : void
Renders a Bulma notification with appropriate styling. Error messages (starting with "Error") are shown as danger notifications with a back button. Success messages are shown as success notifications and auto-hide.
Parameters
- $message : string
-
The message to display
- $autoHide : bool = true
-
Whether to auto-hide the message (default: true)
renderPageEnd()
Render the page footer (closing body and html tags).
public
static renderPageEnd() : void
renderPageStart()
Render a standard page header with navigation.
public
static renderPageStart(string $title, bool $close[, string $currentPage = '' ]) : void
Calls renderPageStartNobody then adds navbar and page title.
Parameters
- $title : string
-
Page title
- $close : bool
-
Whether to show full navigation (true) or minimal header (false)
- $currentPage : string = ''
-
Optional identifier for the current page to highlight in navbar
renderPageStartKernelNobody()
Render a minimal page header (kernel, no database).
public
static renderPageStartKernelNobody(string $title) : void
Outputs directly to browser. Sets cache control headers, renders HTML5 doctype, head, and opening body.
Parameters
- $title : string
-
Page title
renderPageStartNobody()
Render a full page header (no database).
public
static renderPageStartNobody(string $title[, string $bodyClass = '' ]) : void
Outputs directly to browser. Sets cache control headers, renders HTML5 doctype, full head with assets, and opening body.
Parameters
- $title : string
-
Page title
- $bodyClass : string = ''
-
Optional CSS class for body element
sendNoCacheHeaders()
Generate HTTP cache prevention headers.
public
static sendNoCacheHeaders() : void
buildDataThemeAttr()
Build the data-theme attribute for the <html> element.
private
static buildDataThemeAttr() : string
When a user has explicitly selected a theme (not auto-detect), returns a data-theme attribute with the theme's mode ("light" or "dark"). When auto-detect is active (empty theme dir or legacy default), returns empty string so the CSS prefers-color-scheme media query applies.
Return values
string —HTML attribute string (e.g., ' data-theme="dark"') or empty
getRequiredModules()
Determine which frontend feature modules the current page needs.
private
static getRequiredModules() : array<string|int, string>
Maps the request URI to the set of dynamically-loaded JS modules that should be imported. Pages that only use statically-bundled modules (home, auth, tags, dictionary) return an empty array.
Return values
array<string|int, string> —Module names (e.g. ['vocabulary', 'text'])