<!DOCTYPE html>
<html lang='en'>
    <head>
        <meta content='text/html; charset=utf-8' http-equiv='content-type'/>
        <meta name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1'/>
        <title><?=$page->title?></title>
        <link rel='shortcut icon' href='<?=$page->favicon?>'/>
        <!-- CSS files -->
        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>ui.css'/>
        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>runes.css'/>
        <link rel='stylesheet' type='text/css' href='<?=$path["css"]?>filters.css'/>
        <!-- Script files -->
        <script src="<?=$path["js"]?>ui.js"></script>
        <!-- Meta tags -->
        <link rel='canonical' href='<?=$page->canonical?>'/>
        <link rel='author' href='<?=$page->author?>'/>
        <link rel='publisher' href='<?=$page->author?>'/>
        <meta name='description' content='<?=$page->description?>'/>
        <meta property='og:title' content='<?=$page->title?>'/>
        <meta property='og:url' content='<?=$page->canonical?>'/>
        <meta property='og:description' content='<?=$page->description?>'/>
        <meta property='og:image' content='<?=$page->icon?>'/>
        <meta property='og:site_name' content='<?=$page->name?>'/>
        <meta property='og:type' content='website'/>
        <meta property='og:locale' content='en'/>
        <meta name='twitter:card' content='summary'/>
        <meta name='twitter:title' content='<?=$page->title?>'/>
        <meta name='twitter:description' content='<?=$page->description?>'/>
        <meta name='twitter:image' content='<?=$page->icon?>'/>
        <meta name='twitter:url' content='<?=$page->canonical?>'/>
        <meta name='robots' content='index follow'/>
    </head>
    <body>
<?php
        include __DIR__ . "/inc/header.php";
?>
            <section class='filters'>
                <h2>
                    Rune filters
                </h2>
<?php
                $filters = $page->filters;
                $custom_filters = $page->custom_filters;
                include __DIR__ . "/inc/filter_runes.php";
?>

            </section> <!-- #filters -->
<?php
                $prev_group = "";
                $group = "";
                $group_title = "";
                $group_image = "";
                foreach ($page->runes as $rune){
                    switch ($page->filters["group"]){
                        case 1: // "TYPE":
                            $group = $rune->type->name;
                            $group_title = $rune->type->name;
                            $group_image = $path["img"]["rune"] . str_pad($rune->type->id, 2, '0', STR_PAD_LEFT) . ".png";
                            break;
                        default:
                            $group = $rune->slot;
                            $group_title = "Slot " . $rune->slot;
                            $group_image = $path["img"]["rune"] . "base.png";
                    }
                    if ($prev_group != $group){
                        if ($prev_group == ""){
?>
                            <section class='list'>
<?php
                        }
                        else{
?>
                                </article>
                            </section>
                            <section class='list'>
<?php
                        }
                        $prev_group = $group;
?>
                        <h2>
                            <img class='group_image_<?=$group?>' alt='<?=$group_title?>' src='<?=$group_image?>'>
                            <span>
                                <?=$group_title?>
                            </span>
                        </h2>
                        <article>
<?php
                    }
?>
                    <?=html_rune_table($rune, $rune->assigned_to)?>
<?php
                }
?>
                </article> <!-- Close last group -->
            </section>

<?php
        include __DIR__ . "/inc/footer.php";
?>
    </body>
</html>
