<?php

$themesDir = Config::get('cms.themesDir');
$uploadsDir = Config::get('cms.uploadsDir');

$warnings = [];
$writablePaths = [
    $themesDir,
    $uploadsDir,
    $uploadsDir.'/public',
    $uploadsDir.'/protected',
    '/app/storage',
    '/app/storage/logs',
    '/app/storage/cache',
    '/app/storage/twig',
    '/app/storage/meta',
    '/app/storage/combiner',
];
$requiredExtensions = [
    'GD' => extension_loaded('gd'),
    'fileinfo' => extension_loaded('fileinfo'),
    'Zip' => class_exists('ZipArchive'),
    'cURL' => function_exists('curl_init') && defined('CURLOPT_FOLLOWLOCATION'),
    'OpenSSL' => function_exists('openssl_random_pseudo_bytes'),
];

foreach ($writablePaths as $path) {
    if (!is_writable(PATH_BASE.$path))
        $warnings[] = Lang::get('backend::lang.warnings.permissions', ['name' => '<strong>'.$path.'</strong>']);
}
foreach ($requiredExtensions as $extension => $installed) {
    if (!$installed)
        $warnings[] = Lang::get('backend::lang.warnings.extension', ['name' => '<strong>'.$extension.'</strong>']);
}

?>
<?php if (count($warnings)): ?>
    <div class="callout callout-warning">
        <div class="header">
            <i class="icon-warning"></i>
            <h3><?= e(trans('backend::lang.warnings.tips')) ?></h3>
            <p><?= e(trans('backend::lang.warnings.tips_description')) ?></p>
        </div>

        <div class="content">
            <ul>
                <?php foreach ($warnings as $warning): ?>
                    <li><?= $warning ?></li>
                <?php endforeach ?>
            </ul>
        </div>
    </div>
<?php endif ?>
