diff --git a/hubzilla/addon/cry01/Widget/Cry01.php b/hubzilla/addon/cry01/Widget/Cry01.php index 7f10744..fe4f820 100644 --- a/hubzilla/addon/cry01/Widget/Cry01.php +++ b/hubzilla/addon/cry01/Widget/Cry01.php @@ -2,132 +2,31 @@ namespace Zotlabs\Widget; -/** - * Cry01 — sidebar widget. - * Renders the institutional directory for the cry01 addon. - * Follows the standard four-tab pattern: Core, Tier-I, Tier-II, Other. - */ +require_once 'addon/vs01/directory_widget.php'; + class Cry01 { public function widget($arr) { - // Loads listings and renders the four-tab institutional directory. + if (function_exists('head_add_css')) { + \head_add_css('/addon/vs01/view/css/vs01-directory.css'); + } + $listings = $this->load_listings(); + return \KdxDirectoryWidget::render($listings, 'cry01'); + } + + private function load_listings() { + $config = $this->load_config(); + $path = $config['listings_file'] ?? 'addon/cry01/listings.json'; + $raw = @file_get_contents($path); + if ($raw === false) return ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; + $data = json_decode($raw, true); + return (json_last_error() === JSON_ERROR_NONE) ? $data : ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; + } + + private function load_config() { if (!function_exists('cry01_load_config')) { require_once 'addon/cry01/cry01_chain.php'; } - $config = cry01_load_config(); - $path = $config['listings_file'] ?? ''; - $listings = $this->load_listings($path); - return $this->render_directory($listings, $config); - } - - private function load_listings($path) { - // Loads listings.json from the operator-configured path. - if (!$path) return ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; - $raw = @file_get_contents($path); - if ($raw === false) return ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; - $data = json_decode($raw, true); - return (json_last_error() === JSON_ERROR_NONE) - ? $data - : ['core' => [], 'tier1' => [], 'tier2' => [], 'other' => []]; - } - - private function render_directory($listings, $config) { - // Renders the four-tab Bootstrap directory widget. - $default_tab = $config['directory_default_tab'] ?? 'core'; - $uid = 'cry01-dir-' . substr(md5(uniqid()), 0, 6); - - $tabs = [ - 'core' => 'Core', - 'tier1' => 'Tier-I', - 'tier2' => 'Tier-II', - 'other' => 'Other', - ]; - - $out = '
No ' . $this->h($label) . ' listings yet.
'; - } - $out = ''; - foreach ($entries as $entry) { - $name = $this->h($entry['name'] ?? ''); - $role = $this->h($entry['role'] ?? ''); - $url = $entry['url'] ?? ''; - $desc = $this->h($entry['description'] ?? ''); - $out .= '