<?php
$development = $this->getParam('development', false);
$code = $this->getParam('code', 500);
$errorID = $this->getParam('errorID', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
$message = $this->getParam('message', '');
$trace = $this->getParam('trace', []);
$projectName = $this->getParam('projectName', '');
$projectURL = $this->getParam('projectURL', '');
$title = $this->getParam('title', '')
?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $title; ?></title>
</head>

<body>

    <section>
        <h1>Error <?php echo $code; ?></h1>

        <p><?php echo $message; ?></p>

        <small>Error ID: <?php echo $errorID; ?></small>

        <?php if (!empty($projectURL)) : ?>
            <hr />

            <p><a href="<?php echo $this->escape($projectURL); ?>" rel="noopener">Back to <?php echo $projectName; ?></a></p>
        <?php endif; ?>

        <?php if ($development) : ?>
            <div>

                <h2>Error Trace</h2>

                <?php foreach ($trace as $log) : ?>
                    <table>
                        <?php foreach ($log as $key => $value) : ?>
                            <tr>
                                <td style="width: 120px"><?php echo $key; ?></td>
                                <td>
                                    <?php if (is_array($value)) : ?>
                                        <?php var_dump($value); ?>
                                    <?php else : ?>
                                        <?php echo $value; ?>
                                    <?php endif; ?>
                                </td>
                            </tr>

                        <?php endforeach; ?>
                    </table>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>

    </section>
</body>

</html>