From e105d191c3abf3b00b549b3413a047d70da8229c Mon Sep 17 00:00:00 2001 From: TheRON Date: Sat, 13 Jun 2026 16:01:46 -0400 Subject: [PATCH] Updated --- hubzilla/addon/vs01/Widget/Vs01.php | 171 +--------------------------- 1 file changed, 5 insertions(+), 166 deletions(-) diff --git a/hubzilla/addon/vs01/Widget/Vs01.php b/hubzilla/addon/vs01/Widget/Vs01.php index 5c14352..028a7c9 100644 --- a/hubzilla/addon/vs01/Widget/Vs01.php +++ b/hubzilla/addon/vs01/Widget/Vs01.php @@ -2,6 +2,8 @@ namespace Zotlabs\Widget; +require_once 'addon/vs01/directory_widget.php'; + class Vs01 { public function widget($arr) { @@ -9,171 +11,16 @@ class Vs01 { \head_add_css('/addon/vs01/view/css/vs01-directory.css'); } $listings = $this->load_listings(); - return $this->render_directory($listings); + return \KdxDirectoryWidget::render($listings, 'vs01'); } - // --------------------------------------------------------------------------- - // DIRECTORY - // --------------------------------------------------------------------------- - - private function render_directory($listings) { - $out = '
'; - - // Horizontal Bootstrap nav-tabs - $out .= ''; - - // Tab panes - $out .= '
'; - $out .= '
'; - $out .= $this->render_core_tab($listings['core'] ?? []); - $out .= '
'; - $out .= '
'; - $out .= $this->render_tier_tab($listings['tier1'] ?? [], 'Mediators, subject matter experts, advisors, and authors will be listed here.'); - $out .= '
'; - $out .= '
'; - $out .= $this->render_tier_tab($listings['tier2'] ?? [], 'Attorneys who have concluded HOA homeowner cases in Illinois will be listed here.'); - $out .= '
'; - $out .= '
'; - $out .= $this->render_tier_tab($listings['other'] ?? [], 'Civic organizations, consumer protection entities, and oversight agencies will be listed here.'); - $out .= '
'; - $out .= '
'; // tab-content - - $out .= '
'; // vs01-directory - return $out; - } - - private function render_core_tab($core_entries) { - $slots = [ - [ - 'slot' => 'taxonomy-authority', - 'role' => 'Taxonomy Authority', - 'description' => 'The institutional source of the case law categories this diagnostic record is organized by.', - 'image' => '/addon/vs01/view/img/directory-core-taxonomy-authority.png', - ], - [ - 'slot' => 'methodology-certifier', - 'role' => 'Methodology Certifier', - 'description' => 'The law firm whose professional association with this project certifies the diagnostic record meets a standard the legal community can use.', - 'image' => '/addon/vs01/view/img/directory-core-methodology-certifier.png', - ], - [ - 'slot' => 'peer-operator', - 'role' => 'Peer Operator', - 'description' => 'The cooperating Civic Infrastructure host who can independently verify, support, and if necessary continue this diagnostic record.', - 'image' => '/addon/vs01/view/img/directory-core-peer-operator.png', - ], - ]; - - // Index populated entries by slot - $populated = []; - foreach ($core_entries as $entry) { - if (!empty($entry['slot']) && ($entry['status'] ?? '') === 'active') { - $populated[$entry['slot']] = $entry; - } - } - - $out = ''; - foreach ($slots as $slot) { - if (isset($populated[$slot['slot']])) { - $e = $populated[$slot['slot']]; - $name = $this->h($e['name'] ?? ''); - $url = $this->h($e['url'] ?? ''); - $image = $this->h($e['image'] ?? $slot['image']); - $out .= '
'; - $out .= '
'; - $out .= '
'; - $out .= '
' . $this->h($slot['role']) . '
'; - if ($url) { - $out .= ''; - } else { - $out .= '
' . $name . '
'; - } - $out .= '
'; - $out .= '
'; - } else { - $image = $this->h($slot['image']); - $out .= '
'; - $out .= '
' . $this->h($slot['role']) . ' — reserved
'; - $out .= '
'; - $out .= '
' . $this->h($slot['description']) . '
'; - $out .= '
'; - $out .= '
'; - } - } - return $out; - } - - private function render_tier_tab($entries, $placeholder) { - if (empty($entries)) { - return '
' . $this->h($placeholder) . '
'; - } - $out = ''; - foreach ($entries as $entry) { - $name = $this->h($entry['name'] ?? ''); - $role = $this->h($entry['role'] ?? ''); - $desc = $this->h($entry['description'] ?? ''); - $url = $this->h($entry['url'] ?? ''); - $image = $this->h($entry['image'] ?? '/addon/vs01/view/img/directory-tier-default.png'); - $out .= '
'; - $out .= '
'; - $out .= '
'; - if ($role) { - $out .= '
' . $role . '
'; - } - if ($url) { - $out .= ''; - } else { - $out .= '
' . $name . '
'; - } - if ($desc) { - $out .= '
' . $desc . '
'; - } - $out .= '
'; - $out .= '
'; - } - return $out; - } - - // --------------------------------------------------------------------------- - // LISTINGS LOADER - // --------------------------------------------------------------------------- - private function load_listings() { $config = $this->load_config(); $path = $config['listings_file'] ?? 'addon/vs01/listings.json'; $raw = @file_get_contents($path); - if ($raw === false) { - // Fail visibly — return structure with empty tiers, Core slots will show pending - return ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; - } + if ($raw === false) return ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; $data = json_decode($raw, true); - if (json_last_error() !== JSON_ERROR_NONE) { - return ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; - } - return $data; + return (json_last_error() === JSON_ERROR_NONE) ? $data : ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; } private function load_config() { @@ -182,12 +29,4 @@ class Vs01 { $data = json_decode($raw, true); return (json_last_error() === JSON_ERROR_NONE) ? $data : []; } - - // --------------------------------------------------------------------------- - // HELPER - // --------------------------------------------------------------------------- - - private function h($value) { - return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8'); - } }