Files
kane-diagnostics/hubzilla/addon/scn01/Widget/Scn01.php
2026-06-13 16:00:33 -04:00

33 lines
1.1 KiB
PHP

<?php
namespace Zotlabs\Widget;
require_once 'addon/vs01/directory_widget.php';
class Scn01 {
public function widget($arr) {
if (function_exists('head_add_css')) {
\head_add_css('/addon/vs01/view/css/vs01-directory.css');
}
$listings = $this->load_listings();
return \KdxDirectoryWidget::render($listings, 'scn01');
}
private function load_listings() {
$config = $this->load_config();
$path = $config['listings_file'] ?? 'addon/scn01/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() {
$raw = @file_get_contents('addon/scn01/config.json');
if ($raw === false) return [];
$data = json_decode($raw, true);
return (json_last_error() === JSON_ERROR_NONE) ? $data : [];
}
}