Steam workshop UPDATE

This commit is contained in:
Frank Harris 2026-01-17 09:12:06 -06:00
parent 49600d1cfd
commit fcc1b18e4c
23 changed files with 1290 additions and 335 deletions

View file

@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
/** @var array $home */
/** @var array $config */
/** @var array $lang */
/** @var array $adapterOptions */
$homeName = htmlspecialchars($home['home_name'] ?? ('#' . $home['home_id']));
$homeId = (int)$home['home_id'];
?>
<div class="sw-admin sw-edit">
<p><a href="?m=steam_workshop&amp;p=main">&larr; <?php echo htmlspecialchars($lang['button_cancel']); ?></a></p>
<h3><?php echo htmlspecialchars(sprintf($lang['heading_edit_home'], $homeName)); ?></h3>
<form method="post" action="?m=steam_workshop&amp;p=main&amp;action=save" class="sw-form">
<input type="hidden" name="home_id" value="<?php echo $homeId; ?>" />
<?php $formConfig = $config; include __DIR__ . '/partials/form_fields.php'; ?>
<div class="sw-form__actions">
<button class="btn primary" type="submit"><?php echo htmlspecialchars($lang['button_save']); ?></button>
<a class="btn" href="?m=steam_workshop&amp;p=main"><?php echo htmlspecialchars($lang['button_cancel']); ?></a>
</div>
</form>
<?php include __DIR__ . '/partials/mod_table.php'; ?>
</div>

View file

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
/** @var array $records */
/** @var array $lang */
/** @var bool $isAdmin */
/** @var array $adapterOptions */
?>
<div class="sw-admin sw-index">
<?php if (empty($records)): ?>
<div class="sw-empty">
<p><?php echo $isAdmin ? htmlspecialchars($lang['empty_state_admin']) : htmlspecialchars($lang['empty_state_user']); ?></p>
</div>
<?php else: ?>
<div class="sw-grid">
<?php foreach ($records as $record): ?>
<?php $currentRecord = $record; include __DIR__ . '/partials/server_card.php'; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>

View file

@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
/** @var array $formConfig */
/** @var array $adapterOptions */
/** @var array $lang */
$enabled = !empty($formConfig['workshop_enabled']);
$interval = (int)$formConfig['update_interval_minutes'];
$stagingDir = htmlspecialchars($formConfig['staging_dir']);
$postInstall = htmlspecialchars($formConfig['post_install_script']);
$rawDefinition = htmlspecialchars($formConfig['raw_definition']);
$installStrategy = $formConfig['install_strategy'];
$onUpdateAction = $formConfig['on_update_action'];
?>
<div class="sw-form__grid">
<label class="sw-toggle">
<input type="checkbox" name="workshop[workshop_enabled]" value="1" <?php echo $enabled ? 'checked' : ''; ?> />
<span><?php echo htmlspecialchars($lang['label_feature_flag']); ?></span>
</label>
<label>
<span><?php echo htmlspecialchars($lang['label_adapter']); ?></span>
<select name="workshop[adapter_key]">
<?php foreach ($adapterOptions as $key => $label): ?>
<option value="<?php echo htmlspecialchars($key); ?>" <?php echo $formConfig['adapter_key'] === $key ? 'selected' : ''; ?>>
<?php echo htmlspecialchars($label); ?>
</option>
<?php endforeach; ?>
</select>
</label>
<label>
<span><?php echo htmlspecialchars($lang['label_interval']); ?></span>
<input type="number" min="15" max="360" step="5" name="workshop[update_interval_minutes]" value="<?php echo $interval; ?>" />
<small><?php echo htmlspecialchars($lang['label_interval_hint']); ?></small>
</label>
<label>
<span><?php echo htmlspecialchars($lang['label_staging_dir']); ?></span>
<input type="text" name="workshop[staging_dir]" value="<?php echo $stagingDir; ?>" placeholder="/home/ogp_agent/workshop-staging" />
</label>
<label>
<span><?php echo htmlspecialchars($lang['label_install_strategy']); ?></span>
<select name="workshop[install_strategy]">
<option value="copy" <?php echo $installStrategy === 'copy' ? 'selected' : ''; ?>><?php echo htmlspecialchars($lang['install_copy']); ?></option>
<option value="symlink" <?php echo $installStrategy === 'symlink' ? 'selected' : ''; ?>><?php echo htmlspecialchars($lang['install_symlink']); ?></option>
<option value="staging" <?php echo $installStrategy === 'staging' ? 'selected' : ''; ?>><?php echo htmlspecialchars($lang['install_staging']); ?></option>
</select>
</label>
<label>
<span><?php echo htmlspecialchars($lang['label_on_update_action']); ?></span>
<select name="workshop[on_update_action]">
<option value="queue_for_restart" <?php echo $onUpdateAction === 'queue_for_restart' ? 'selected' : ''; ?>><?php echo htmlspecialchars($lang['action_queue_for_restart']); ?></option>
<option value="hot_reload_if_supported" <?php echo $onUpdateAction === 'hot_reload_if_supported' ? 'selected' : ''; ?>><?php echo htmlspecialchars($lang['action_hot_reload_if_supported']); ?></option>
</select>
</label>
<label>
<span><?php echo htmlspecialchars($lang['label_post_install_script']); ?></span>
<input type="text" name="workshop[post_install_script]" value="<?php echo $postInstall; ?>" placeholder="/home/ogp_agent/scripts/workshop-hook.sh" />
</label>
</div>
<label>
<span><?php echo htmlspecialchars($lang['label_mod_import']); ?></span>
<textarea name="workshop[raw_items]" rows="8" placeholder="123456789,@Example Mod&#10;987654321,@QoL Pack"><?php echo $rawDefinition; ?></textarea>
<small><?php echo htmlspecialchars($lang['hint_mod_import']); ?></small>
</label>

View file

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
/** @var array $config */
/** @var array $lang */
$mods = $config['workshop_items'] ?? [];
?>
<div class="sw-mods">
<h4><?php echo htmlspecialchars($lang['mods_table_heading']); ?></h4>
<?php if (empty($mods)): ?>
<p><?php echo htmlspecialchars($lang['mods_table_empty']); ?></p>
<?php else: ?>
<table class="table sw-mods__table">
<thead>
<tr>
<th><?php echo htmlspecialchars($lang['mods_header_id']); ?></th>
<th><?php echo htmlspecialchars($lang['mods_header_label']); ?></th>
<th><?php echo htmlspecialchars($lang['mods_header_source']); ?></th>
<th><?php echo htmlspecialchars($lang['mods_header_enabled']); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($mods as $mod): ?>
<tr>
<td><?php echo htmlspecialchars($mod['id']); ?></td>
<td><?php echo htmlspecialchars($mod['label']); ?></td>
<td><?php echo htmlspecialchars($mod['source']); ?></td>
<td><?php echo !empty($mod['enabled']) ? htmlspecialchars($lang['status_enabled']) : htmlspecialchars($lang['status_disabled']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>

View file

@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
/** @var array $currentRecord */
/** @var array $lang */
$home = $currentRecord['home'];
$config = $currentRecord['config'];
$adapter = $currentRecord['adapter'];
$homeName = htmlspecialchars($home['home_name'] ?? ('#' . $home['home_id']));
$homeId = (int)($home['home_id'] ?? 0);
$modCount = count($config['workshop_items']);
$interval = (int)$config['update_interval_minutes'];
$enabled = !empty($config['workshop_enabled']);
$lastSaved = $config['last_saved_at'] ? date('Y-m-d H:i', (int)$config['last_saved_at']) : '—';
$adapterName = htmlspecialchars($adapter['name'] ?? strtoupper($config['adapter_key']));
$hotReload = !empty($adapter['supports_hot_reload']);
$ip = htmlspecialchars($home['ip'] ?? '');
$port = $home['port'] ?? '';
$address = $ip;
if ($ip !== '' && $port !== '') {
$address .= ':' . htmlspecialchars((string)$port);
}
?>
<div class="sw-card">
<div class="sw-card__header">
<div>
<h3><?php echo $homeName; ?></h3>
<?php if ($address !== ''): ?>
<p><?php echo $address; ?></p>
<?php endif; ?>
</div>
<div>
<a class="btn" href="?m=steam_workshop&amp;p=main&amp;action=edit&amp;home_id=<?php echo $homeId; ?>">
<?php echo htmlspecialchars($lang['button_edit']); ?>
</a>
</div>
</div>
<dl class="sw-card__meta">
<div>
<dt><?php echo htmlspecialchars($lang['summary_adapter']); ?></dt>
<dd><?php echo $adapterName; ?></dd>
</div>
<div>
<dt><?php echo htmlspecialchars($lang['summary_interval']); ?></dt>
<dd><?php echo $interval; ?> min</dd>
</div>
<div>
<dt><?php echo htmlspecialchars($lang['summary_mods']); ?></dt>
<dd><?php echo $modCount; ?></dd>
</div>
<div>
<dt><?php echo htmlspecialchars($lang['summary_last_saved']); ?></dt>
<dd><?php echo htmlspecialchars($lastSaved); ?></dd>
</div>
<div>
<dt>Status</dt>
<dd><?php echo $enabled ? htmlspecialchars($lang['status_enabled']) : htmlspecialchars($lang['status_disabled']); ?></dd>
</div>
<div>
<dt><?php echo htmlspecialchars($lang['summary_hot_reload']); ?></dt>
<dd><?php echo $hotReload ? htmlspecialchars($lang['status_hot_reload']) : htmlspecialchars($lang['status_restart_required']); ?></dd>
</div>
</dl>
</div>