<?php
/**
 * HuSNS - 编辑圈子后台页面
 */
?>
<div class="admin-page">
    <div class="page-header">
        <h2>编辑圈子</h2>
        <a href="<?php echo Helper::url('admin/circles'); ?>" class="btn">返回列表</a>
    </div>
    
    <?php if ($this->hasFlash('success')): ?>
    <div class="alert alert-success"><?php echo $this->flash('success'); ?></div>
    <?php endif; ?>
    
    <?php if ($this->hasFlash('error')): ?>
    <div class="alert alert-error"><?php echo $this->flash('error'); ?></div>
    <?php endif; ?>
    
    <form method="post" enctype="multipart/form-data">
        <input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?? ''; ?>">
        
        <div class="form-group">
            <label>圈子名称 *</label>
            <input type="text" name="name" required value="<?php echo $this->escape($circle['name']); ?>">
        </div>
        
        <div class="form-group">
            <label>圈子描述</label>
            <textarea name="description" rows="4"><?php echo $this->escape($circle['description']); ?></textarea>
        </div>
        
        <div class="form-group">
            <label>圈子头像</label>
            <?php if ($circle['avatar']): ?>
            <div>
                <img src="<?php echo $this->uploadUrl($circle['avatar']); ?>" alt="" style="max-width: 100px; border-radius: 50%;">
            </div>
            <?php endif; ?>
            <input type="file" name="avatar" accept="image/*">
            <p style="color: #999; font-size: 12px;">支持 JPG、PNG 格式，建议尺寸 100x100</p>
        </div>
        
        <div class="form-group">
            <label>圈子封面</label>
            <?php if (!empty($circle['cover'])): ?>
            <div>
                <img src="<?php echo $this->uploadUrl($circle['cover']); ?>" alt="" style="max-width: 400px;">
            </div>
            <?php endif; ?>
            <input type="file" name="banner" accept="image/*">
            <p style="color: #999; font-size: 12px;">支持 JPG、PNG 格式，建议尺寸 800x200</p>
        </div>
        
        <div class="form-group">
            <label>圈子类型</label>
            <label>
                <input type="radio" name="is_private" value="0" <?php echo empty($circle['is_private']) ? 'checked' : ''; ?>> 公开圈子
            </label>
            <label>
                <input type="radio" name="is_private" value="1" <?php echo !empty($circle['is_private']) ? 'checked' : ''; ?>> 私密圈子
            </label>
        </div>
        
        <div class="form-group">
            <label>认证状态</label>
            <label>
                <input type="radio" name="is_verified" value="1" <?php echo $circle['is_verified'] ? 'checked' : ''; ?>> 已认证
            </label>
            <label>
                <input type="radio" name="is_verified" value="0" <?php echo !$circle['is_verified'] ? 'checked' : ''; ?>> 未认证
            </label>
        </div>
        
        <div style="margin-top: 20px;">
            <button type="submit" class="btn btn-primary">保存修改</button>
            <a href="<?php echo Helper::url('admin/circles'); ?>" class="btn">取消</a>
        </div>
    </form>
</div>