Initial push
This commit is contained in:
57
hubzilla/addon/vs01/Widget/CivicNav.php
Normal file
57
hubzilla/addon/vs01/Widget/CivicNav.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Zotlabs\Widget;
|
||||
|
||||
/**
|
||||
* CivicNav — top-level section navigation widget.
|
||||
*
|
||||
* Renders Vital Signs / DSC Categories / Scenarios links with the current
|
||||
* association slug carried through each URL. Active section is highlighted.
|
||||
*
|
||||
* Registered by vs01. Shared across vs01, dsc01, and scn01 PDLs.
|
||||
* Requires argv(1) to contain the association slug — returns empty string
|
||||
* on the module index page (no slug).
|
||||
*/
|
||||
class CivicNav {
|
||||
|
||||
public function widget($arr) {
|
||||
$slug = \argv(1) ?? '';
|
||||
if (!$slug) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (function_exists('head_add_css')) {
|
||||
head_add_css('/addon/vs01/view/css/civicnav.css');
|
||||
}
|
||||
|
||||
$module = \App::$module ?? '';
|
||||
|
||||
$sections = [
|
||||
'vs01' => 'Vital Signs',
|
||||
'dsc01' => 'DSC Categories',
|
||||
'scn01' => 'Scenarios',
|
||||
];
|
||||
|
||||
$slug_safe = htmlspecialchars($slug, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$out = '<nav class="civicnav" aria-label="Kane Diagnostics">';
|
||||
$out .= '<ul class="civicnav-list">';
|
||||
|
||||
foreach ($sections as $mod => $label) {
|
||||
$is_active = ($module === $mod);
|
||||
$url = z_root() . '/' . $mod . '/' . $slug_safe;
|
||||
$out .= '<li class="civicnav-item' . ($is_active ? ' civicnav-active' : '') . '">';
|
||||
if ($is_active) {
|
||||
$out .= '<span class="civicnav-link civicnav-current">' . $label . '</span>';
|
||||
} else {
|
||||
$out .= '<a href="' . $url . '" class="civicnav-link">' . $label . '</a>';
|
||||
}
|
||||
$out .= '</li>';
|
||||
}
|
||||
|
||||
$out .= '</ul>';
|
||||
$out .= '</nav>';
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user