<?php
namespace Phpcmf\App\Ciyun_publisher\Controllers;

class Config extends \Phpcmf\Common
{
    public function index()
    {
        $config = ciyun_xunruicms_config();
        header('Content-Type: text/plain; charset=utf-8');
        echo "Ciyun Publisher\n\n";
        echo "API: /index.php?s=ciyun_publisher&c=api&m=index\n";
        echo "Token configured: " . (strlen($config['token']) >= 32 ? 'yes' : 'no') . "\n";
        echo "Module: " . $config['module'] . "\n";
        echo "Force draft: " . $config['force_draft'] . "\n";
    }
}

function ciyun_xunruicms_config()
{
    $default = include dirname(__DIR__) . '/Config/Setting.php';
    if (function_exists('dr_site_value')) {
        $saved = dr_site_value('ciyun_publisher');
        if (is_array($saved)) {
            return array_merge($default, $saved);
        }
    }
    return $default;
}
