<?php
$translation     = \DynCom\mysyde\common\classes\Registry::get("translation");
$formname        = "form_category_list";
$inputname       = "input_id";
?>

<ul class="toolbar_menu">
    <?= button("save", $translation->get("save"), $formname, ""); ?>
    <?= button("save", $translation->get("save_and_close"), $formname, "backButton()"); ?>
</ul>
<div id="mainContent">

    <h1><?php echo get_translation('community_board_category'); ?></h1>

    <form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
        <input name="input_id" type="hidden" value="<?= $input_id ?>">
        <input type="hidden" class="selected_linklist_row" name="input_category_id" value="" />
        <input type="hidden" name="fieldtype" value="" />
        <input type="hidden" name="type_id" value="" />
        <ul class="toolbar_menu community_board_category new">
            <?= button("new", $translation->get("new"), $formname, "loadCard('new_community_board_category', true)", "", FALSE); ?>
            <?= button("edit", $translation->get("edit"), $formname, "loadCard('edit_community_board_category')", "", FALSE); ?>
            <?= button("delete", $translation->get("delete"), $formname, "loadCard('delete_community_board_category', false, '{$translation->get('delete_community_board_category_confirm')}')", "", FALSE); ?>
            <?= button("up", $translation->get("go_up"), $formname, "loadCard('moveup_community_board_category')", "", FALSE); ?>
            <?= button("down", $translation->get("go_down"), $formname, "loadCard('movedown_community_board_category')", "", FALSE); ?>
        </ul>
        <?php
        $query = "SELECT * FROM community_board_category ORDER BY sorting ASC";
        if ($result = @mysqli_query($GLOBALS['mysql_con'], $query)) {
            $num_rows = @mysqli_num_rows($result);
            if ($num_rows >= 1) {
                echo "  <table data-sortableupdateaction=\"update_sortorder_community_board_category\" cellpadding=0 cellspacing=0 border=0 class=\"linklist sortableTable\">\n";
                echo "<tr>";
                echo format_key($translation->get("description"), "");
                echo format_key("", "");
                echo "</tr>";
                echo "<tr>";
                echo format_seperator("");
                echo format_seperator("");
                echo "</tr>";
                while ($row = @mysqli_fetch_array($result, 1)) {
                    echo "    <tr id=\"linklistid_{$row['id']}\" class=\"linklist_content\" data-checked=\"{$checkedRow}\" data-inputname=\"input_id\" data-action=\"edit_community_board_category\" data-inputid=\"{$row['id']}\">\n";
                    echo format_value($row['description'], "input_id");
                    echo format_value("", "sorticon", "sort");
                    echo "    </tr>\n";
                }
                echo "  </table>\n";
            } else {
                echo "<div class=\"infobox\">" . $translation->get("no_rows_found") . "</div>";
            }
        }
        ?>
    </form>
</div>