QoL 51: browser tab titles take the menu name of each page from reportCatalog, settingsPages and a short list, acronyms in capitals, no double-escaped ampersands, and rack, instance and template pages show the record name

This commit is contained in:
johnnyq
2026-11-21 01:07:46 -05:00
parent 15aeab602d
commit f61d4143ae
7 changed files with 61 additions and 11 deletions

View File

@@ -281,6 +281,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
- Messages: archiving, restoring, deleting, favoriting or setting the category of several contacts, clients, assets or products said contact(s), client(s) and so on, an import of network IPs said IP(s), and the message after restoring clients started "You restored". They now say 1 contact, 3 contacts, with the number in bold, like the rest.
- Contacts: the button in the archive window read Arhive.
- Tickets: cancelling Reset the timer still marked the timer as stopped in that browser, so it showed as stopped after a reload while it was still counting.
- Browser tabs: many pages were named after their file - Kb, Ai Providers, Rmm Providers, Sla, Settings Ticket, Profit Loss - and one with & in its name showed &. Each tab now has the name the menu gives the page, and a rack, an instance and a ticket, document or project template show their own name.
### Developer Updates
@@ -447,6 +448,7 @@ Update from Maintenance > Update — Queue Update hands the job to cron, which u
- Confirms: `itflowConfirm({title, text, button, icon, danger})` in `js/confirm_modal.js` asks the SweetAlert question from script and resolves true when confirmed; `confirm-link` goes through it, and with no `data-confirm-button` takes the link's own text (three words or fewer) for the button. `fa-ellipsis-v`, `fa-trash`, `fa-redo` and `fa-download` are the icons for More, Delete, Restore and Export - `fa-redo-alt` stays for recurring and `fa-undo` for restoring a backup or a version.
- UI text: titles, menu items and buttons in Title Case, with a, an, the, and, but, or, for, as, at, by, in, of, on, to, via, from, with and into lower case unless first or last, and a verb's particle capitalised (Turn Off, Back Up, Sign In); field labels, section headings, tabs and help in sentence case. Proper names and acronyms keep their capitals either way. The empty-state and header `'actions'` labels are buttons, so Title Case too.
- Lists: `sortLink($column, $label, $first, $title, $class)` in `functions/format.php` draws a sortable column header from what `includes/filter_header.php` sets, and `sortFirstOrder()` picks the first direction from the column's name. It replaces the 48 copied `$sort_link` closures and the 115 header links written out by hand; a page with its own first directions passes `$first`.
- Tab titles: `includes/page_title.php` takes a report's title from `reportCatalog()`, a settings page's from `settingsPages()` and a few others from a short list, and makes the rest from the file name with its acronyms in capitals. `$page_title` is no longer HTML-escaped there - the footer writes it with `json_encode()` and `emptyStateHtml()` escapes it.
## [26.11.8]

View File

@@ -24,6 +24,7 @@ if (!$template) {
$document_template_id = intval($template['document_template_id']);
$name = escapeHtml($template['document_template_name']);
$page_title = $template['document_template_name'];
$archived = !empty($template['document_template_archived_at']);
$usage = documentTemplateUsage([$document_template_id])[$document_template_id] ?? ['count' => 0, 'clients' => 0, 'last' => null];
$content = trim((string) $template['document_template_content']) !== '' ? documentTemplateMarkBrackets(documentHtmlPurify($template['document_template_content'])) : '';

View File

@@ -29,6 +29,7 @@ if (!$row) { ?>
}
$name = escapeHtml($row['managed_instance_name']);
$page_title = $row['managed_instance_name'];
$removed = !empty($row['managed_instance_archived_at']);
$health = managedInstanceHealth($row);
$state = $health['state'];

View File

@@ -23,6 +23,8 @@ if (!$template) { ?>
exit;
}
$page_title = $template['project_template_name'];
// Its ticket templates in order, then all their tasks in one go
$sql = mysqli_query($mysqli, "SELECT ticket_templates.ticket_template_id, ticket_template_name, ticket_template_subject, ticket_template_description, ticket_template_order
FROM project_template_ticket_templates

View File

@@ -22,6 +22,7 @@ if (!$template) {
$ticket_template_id = intval($template['ticket_template_id']);
$name = escapeHtml($template['ticket_template_name']);
$page_title = $template['ticket_template_name'];
$archived = !empty($template['ticket_template_archived_at']);
$tasks = ticketTemplateTasks($ticket_template_id);
$task_minutes = array_sum(array_column($tasks, 'estimate'));

View File

@@ -40,6 +40,7 @@ if (mysqli_num_rows($sql) == 0) {
$row = mysqli_fetch_assoc($sql);
$rack_name = escapeHtml($row['rack_name']);
$page_title = $row['rack_name'];
$rack_description = escapeHtml($row['rack_description']);
$rack_model = escapeHtml($row['rack_model']);
$rack_depth = escapeHtml($row['rack_depth']);

View File

@@ -1,21 +1,63 @@
<?php
// Set Page Title
/*
* The page's name for the browser tab (includes/footer.php puts it after the
* company or client) and for the empty state's "No ... match". A report takes
* its title from reportCatalog(), a settings page from settingsPages(), and a
* few pages whose file name isn't what the menu calls them are named here;
* the rest come from the file name, in Title Case with their acronyms. A
* detail page sets $page_title to the record's name after this. Not escaped:
* the footer writes it through json_encode() and emptyStateHtml() escapes it.
*/
// Get the current page name without the .php extension
$page_title = basename($_SERVER['PHP_SELF'], '.php');
$page_file = basename($_SERVER['PHP_SELF'], '.php');
$page_dir = basename(dirname($_SERVER['PHP_SELF']));
// Lets make the Page title look pretty
// Replace any underscores with spaces
$page_title = str_replace('_', ' ', $page_title);
$page_names = [
'kb' => 'Knowledge Base',
'software' => 'Licenses',
'shares' => 'Shared Links',
'sla' => 'SLAs',
'tax_rates' => 'Taxes',
'getting_started' => 'Get Started',
'global_search' => 'Search',
'products_reprice' => 'Update Prices',
'products_count' => 'Count Stock',
'client_overview' => 'Overview',
'saved_payment_methods' => 'Saved Cards',
'user_details' => 'Profile',
'user_security' => 'Security',
'user_preferences' => 'Preferences',
'user_activity' => 'Activity',
'user_canned_responses' => 'Canned Responses',
];
// Capitize
$page_title = ucwords($page_title);
$page_title = '';
if ($page_dir === 'reports') {
if ($page_file === 'index') {
$page_title = 'Reports';
} else {
foreach (reportCatalog() as $report_group) {
if (isset($report_group['reports'][$page_file])) {
$page_title = $report_group['reports'][$page_file]['title'];
}
}
}
} elseif ($page_dir === 'admin' && strpos($page_file, 'settings_') === 0) {
foreach (settingsPages() as $settings_page) {
if (($settings_page['url'] ?? '') === "$page_file.php") {
$page_title = $settings_page['title'];
}
}
}
if ($page_title === '') {
$page_title = $page_names[$page_file] ?? ucwords(str_replace('_', ' ', $page_file));
// Acronyms in capitals, and the small words in lower case after the first
$page_title = preg_replace_callback('/\b(Ai|Api|Rmm|Sla|Sms|Ip|Mfa|Pdf|Csv|Id)\b/', function ($m) { return strtoupper($m[1]); }, $page_title);
$page_title = preg_replace_callback('/(?<=\s)(By|And|Of|To|For|In|On|Vs)\b(?=\s)/', function ($m) { return strtolower($m[1]); }, $page_title);
}
// Sanitize title for SQL input such as logging
$page_title_sanitized = escapeSql($page_title);
// Sanitize the page title to prevent XSS for output
$page_title = escapeHtml($page_title);
$tab_title = $session_company_name;